Skip to content

Commit

Permalink
Merge branch 'trunk' of github.com:Yoast/wordpress-seo into 537-refac…
Browse files Browse the repository at this point in the history
…tor-microcaching-the-api-endpoints-into-using-cache-decorators

# Conflicts:
#	src/dashboard/infrastructure/score-results/readability-score-results/readability-score-results-collector.php
#	src/dashboard/infrastructure/score-results/seo-score-results/seo-score-results-collector.php
  • Loading branch information
thijsoo committed Dec 10, 2024
2 parents f809804 + 3bd4db6 commit bf9d254
Show file tree
Hide file tree
Showing 122 changed files with 3,287 additions and 478 deletions.
4 changes: 4 additions & 0 deletions admin/capabilities/class-register-capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ public function map_meta_cap_for_seo_manager( $caps, $cap ) {
return $caps;
}

if ( ! is_array( $user->roles ) ) {
return $caps;
}

// User must be of role wpseo_manager.
if ( ! in_array( 'wpseo_manager', $user->roles, true ) ) {
return $caps;
Expand Down
4 changes: 4 additions & 0 deletions admin/class-admin-asset-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,10 @@ protected function styles_to_be_registered() {
'wp-components',
],
],
[
'name' => 'block-editor',
'src' => 'block-editor-' . $flat_version,
],
[
'name' => 'ai-generator',
'src' => 'ai-generator-' . $flat_version,
Expand Down
4 changes: 2 additions & 2 deletions admin/class-gutenberg-compatibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ class WPSEO_Gutenberg_Compatibility {
*
* @var string
*/
public const CURRENT_RELEASE = '19.7.0';
public const CURRENT_RELEASE = '19.8.0';

/**
* The minimally supported version of Gutenberg by the plugin.
*
* @var string
*/
public const MINIMUM_SUPPORTED = '19.7.0';
public const MINIMUM_SUPPORTED = '19.8.0';

/**
* Holds the current version.
Expand Down
52 changes: 36 additions & 16 deletions admin/class-meta-columns.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ class WPSEO_Meta_Columns {
*/
private $score_icon_helper;

/**
* Holds the WPSEO_Admin_Asset_Manager instance.
*
* @var WPSEO_Admin_Asset_Manager
*/
private $admin_asset_manager;

/**
* When page analysis is enabled, just initialize the hooks.
*/
Expand All @@ -62,6 +69,7 @@ public function __construct() {
$this->analysis_readability = new WPSEO_Metabox_Analysis_Readability();
$this->admin_columns_cache = YoastSEO()->classes->get( Admin_Columns_Cache_Integration::class );
$this->score_icon_helper = YoastSEO()->helpers->score_icon;
$this->admin_asset_manager = YoastSEO()->classes->get( WPSEO_Admin_Asset_Manager::class );
}

/**
Expand Down Expand Up @@ -96,6 +104,9 @@ public function column_heading( $columns ) {
return $columns;
}

$this->admin_asset_manager->enqueue_script( 'edit-page' );
$this->admin_asset_manager->enqueue_style( 'edit-page' );

$added_columns = [];

if ( $this->analysis_seo->is_enabled() ) {
Expand Down Expand Up @@ -593,7 +604,7 @@ protected function build_filter_query( $vars, $filters ) {
$current_seo_filter = $this->get_current_seo_filter();

// This only applies for the SEO score filter because it can because the SEO score can be altered by the no-index option.
if ( $this->is_valid_filter( $current_seo_filter ) && ! in_array( $current_seo_filter, [ WPSEO_Rank::NO_INDEX, WPSEO_Rank::NO_FOCUS ], true ) ) {
if ( $this->is_valid_filter( $current_seo_filter ) && ! in_array( $current_seo_filter, [ WPSEO_Rank::NO_INDEX ], true ) ) {
$result['meta_query'] = array_merge( $result['meta_query'], [ $this->get_meta_robots_query_values() ] );
}

Expand Down Expand Up @@ -660,11 +671,6 @@ protected function create_no_index_filter() {
*/
protected function create_no_focus_keyword_filter() {
return [
[
'key' => WPSEO_Meta::$meta_prefix . 'meta-robots-noindex',
'value' => 'needs-a-value-anyway',
'compare' => 'NOT EXISTS',
],
[
'key' => WPSEO_Meta::$meta_prefix . 'linkdex',
'value' => 'needs-a-value-anyway',
Expand All @@ -681,12 +687,27 @@ protected function create_no_focus_keyword_filter() {
protected function create_no_readability_scores_filter() {
// We check the existence of the Estimated Reading Time, because readability scores of posts that haven't been manually saved while Yoast SEO is active, don't exist, which is also the case for posts with not enough content.
// Meanwhile, the ERT is a solid indicator of whether a post has ever been saved (aka, analyzed), so we're using that.
$rank = new WPSEO_Rank( WPSEO_Rank::BAD );
return [
[
'key' => WPSEO_Meta::$meta_prefix . 'estimated-reading-time-minutes',
'value' => 'needs-a-value-anyway',
'compare' => 'NOT EXISTS',
],
[
'relation' => 'OR',
[
'key' => WPSEO_Meta::$meta_prefix . 'content_score',
'value' => $rank->get_starting_score(),
'type' => 'numeric',
'compare' => '<',
],
[
'key' => WPSEO_Meta::$meta_prefix . 'content_score',
'value' => 'needs-a-value-anyway',
'compare' => 'NOT EXISTS',
],
],
];
}

Expand All @@ -698,25 +719,24 @@ protected function create_no_readability_scores_filter() {
protected function create_bad_readability_scores_filter() {
$rank = new WPSEO_Rank( WPSEO_Rank::BAD );
return [
'relation' => 'OR',
[
'key' => WPSEO_Meta::$meta_prefix . 'estimated-reading-time-minutes',
'compare' => 'EXISTS',
'key' => WPSEO_Meta::$meta_prefix . 'content_score',
'value' => [ $rank->get_starting_score(), $rank->get_end_score() ],
'type' => 'numeric',
'compare' => 'BETWEEN',
],
[
'relation' => 'OR',
[
'key' => WPSEO_Meta::$meta_prefix . 'content_score',
'value' => $rank->get_end_score(),
'type' => 'numeric',
'compare' => '<=',
],
[
'key' => WPSEO_Meta::$meta_prefix . 'content_score',
'value' => 'needs-a-value-anyway',
'compare' => 'NOT EXISTS',
],
[
'key' => WPSEO_Meta::$meta_prefix . 'estimated-reading-time-minutes',
'compare' => 'EXISTS',
],
],

];
}

Expand Down
7 changes: 1 addition & 6 deletions admin/metabox/class-metabox.php
Original file line number Diff line number Diff line change
Expand Up @@ -810,17 +810,12 @@ public function enqueue() {

$asset_manager = new WPSEO_Admin_Asset_Manager();

$is_editor = self::is_post_overview( $pagenow ) || self::is_post_edit( $pagenow );

if ( self::is_post_overview( $pagenow ) ) {
$asset_manager->enqueue_style( 'edit-page' );
$asset_manager->enqueue_script( 'edit-page' );

return;
}

/* Filter 'wpseo_always_register_metaboxes_on_admin' documented in wpseo-main.php */
if ( ( $is_editor === false && apply_filters( 'wpseo_always_register_metaboxes_on_admin', false ) === false ) || $this->display_metabox() === false ) {
if ( ( self::is_post_edit( $pagenow ) === false && apply_filters( 'wpseo_always_register_metaboxes_on_admin', false ) === false ) || $this->display_metabox() === false ) {
return;
}

Expand Down
1 change: 1 addition & 0 deletions admin/taxonomy/class-taxonomy.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ public function admin_enqueue_scripts() {

if ( self::is_term_overview( $pagenow ) ) {
$asset_manager->enqueue_script( 'edit-page' );
$asset_manager->enqueue_style( 'edit-page' );
}
}

Expand Down
4 changes: 2 additions & 2 deletions admin/views/tool-import-export.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* Yoast SEO that we can import stuff for that plugin.
*/
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are only comparing the variable so no need to sanitize.
if ( isset( $_POST['import_external'] ) && wp_unslash( $_POST['import_external'] ) === 'Import' ) {
if ( isset( $_POST['import_external'] ) && wp_unslash( $_POST['import_external'] ) === __( 'Import', 'wordpress-seo' ) ) {
check_admin_referer( 'wpseo-import-plugins' );
if ( isset( $_POST['import_external_plugin'] ) && is_string( $_POST['import_external_plugin'] ) ) {
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are using the variable as a class name.
Expand All @@ -32,7 +32,7 @@
}
}
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are only comparing the variable so no need to sanitize.
elseif ( isset( $_POST['clean_external'] ) && wp_unslash( $_POST['clean_external'] ) === 'Clean up' ) {
elseif ( isset( $_POST['clean_external'] ) && wp_unslash( $_POST['clean_external'] ) === __( 'Clean up', 'wordpress-seo' ) ) {
check_admin_referer( 'wpseo-clean-plugins' );
if ( isset( $_POST['clean_external_plugin'] ) && is_string( $_POST['clean_external_plugin'] ) ) {
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are using the variable as a class name.
Expand Down
4 changes: 4 additions & 0 deletions css/src/block-editor.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.editor-styles-wrapper mark.annotation-text-yoast {
background-color: #e1bee7;
}

20 changes: 14 additions & 6 deletions css/src/edit-page.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions css/src/metabox.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion inc/class-wpseo-admin-bar-menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ protected function add_root_menu( WP_Admin_Bar $wp_admin_bar ) {
'parent' => self::MENU_IDENTIFIER,
'id' => 'wpseo-notifications',
'title' => __( 'Notifications', 'wordpress-seo' ) . $counter,
'href' => $settings_url,
'href' => empty( $settings_url ) ? '' : $settings_url . '#/alert-center',
'meta' => [ 'tabindex' => ! empty( $settings_url ) ? false : '0' ],
];
$wp_admin_bar->add_menu( $admin_bar_menu_args );
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"webpack-bundle-analyzer": "^4.9.1"
},
"yoast": {
"pluginVersion": "24.0-RC4"
"pluginVersion": "24.1-RC3"
},
"version": "0.0.0"
}
41 changes: 20 additions & 21 deletions packages/js/src/components/SEMrushRelatedKeyphrasesModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import PropTypes from "prop-types";
import { NewButton, ButtonStyledLink } from "@yoast/components";

/* Internal dependencies */
import { ModalContainer } from "./modals/Container";
import Modal from "./modals/Modal";
import { ReactComponent as YoastIcon } from "../../images/Yoast_icon_kader.svg";
import { Modal } from "@yoast/related-keyphrase-suggestions";

/**
* Redux container for the RelatedKeyPhrasesModal modal.
Expand Down Expand Up @@ -154,7 +152,11 @@ class SEMrushRelatedKeyphrasesModal extends Component {
* @returns {wp.Element} The RelatedKeyPhrasesModal modal component.
*/
render() {
const { keyphrase, location, whichModalOpen, isLoggedIn, shouldCloseOnClickOutside, onClose } = this.props;
const { keyphrase, location, whichModalOpen, isLoggedIn, onClose, countryCode, learnMoreLink } = this.props;

const insightsLink = new URL( "https://www.semrush.com/analytics/keywordoverview/" );
insightsLink.searchParams.append( "q", keyphrase );
insightsLink.searchParams.append( "db", countryCode );

return (
<Fragment>
Expand All @@ -167,21 +169,16 @@ class SEMrushRelatedKeyphrasesModal extends Component {
{ __( "Get related keyphrases", "wordpress-seo" ) }
</NewButton>
</div> }
{ keyphrase && whichModalOpen === location &&
<Modal
title={ __( "Related keyphrases", "wordpress-seo" ) }
onRequestClose={ onClose }
icon={ <YoastIcon /> }
additionalClassName="yoast-related-keyphrases-modal"
shouldCloseOnClickOutside={ shouldCloseOnClickOutside }
>
<ModalContainer
className="yoast-gutenberg-modal__content yoast-related-keyphrases-modal__content"
>
<Slot name="YoastRelatedKeyphrases" />
</ModalContainer>
</Modal>
}
<Modal
isOpen={ Boolean( keyphrase ) && whichModalOpen === location }
onClose={ onClose }
insightsLink={ insightsLink.toString() }
learnMoreLink={ learnMoreLink }
>

<Slot name="YoastRelatedKeyphrases" />

</Modal>
{ ! isLoggedIn && <div className={ "yoast" }>
<ButtonStyledLink
variant={ "secondary" }
Expand Down Expand Up @@ -218,15 +215,17 @@ SEMrushRelatedKeyphrasesModal.propTypes = {
onOpenWithNoKeyphrase: PropTypes.func.isRequired,
onClose: PropTypes.func.isRequired,
onAuthentication: PropTypes.func.isRequired,
shouldCloseOnClickOutside: PropTypes.bool,
countryCode: PropTypes.string,
learnMoreLink: PropTypes.string,
};

SEMrushRelatedKeyphrasesModal.defaultProps = {
keyphrase: "",
location: "",
whichModalOpen: "none",
isLoggedIn: false,
shouldCloseOnClickOutside: true,
countryCode: "en_US",
learnMoreLink: "",
};

export default SEMrushRelatedKeyphrasesModal;
Loading

0 comments on commit bf9d254

Please sign in to comment.