| @@ -155,64 +155,8 @@ | ||
| 155 | 155 | echo new Alert_Presenter( $content ); |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | /** |
| 159 | - * Translates text strings for use in the meta box. | |
| 160 | - * | |
| 161 | - * IMPORTANT: if you want to add a new string (option) somewhere, make sure you add that array key to | |
| 162 | - * the main meta box definition array in the class WPSEO_Meta() as well!!!! | |
| 163 | - * | |
| 164 | - * @deprecated 23.5 | |
| 165 | - * @codeCoverageIgnore | |
| 166 | - * | |
| 167 | - * @return void | |
| 168 | - */ | |
| 169 | - public static function translate_meta_boxes() { | |
| 170 | - _deprecated_function( __METHOD__, 'Yoast SEO 23.5' ); | |
| 171 | - | |
| 172 | - WPSEO_Meta::$meta_fields['general']['title']['title'] = __( 'SEO title', 'wordpress-seo' ); | |
| 173 | - WPSEO_Meta::$meta_fields['general']['metadesc']['title'] = __( 'Meta description', 'wordpress-seo' ); | |
| 174 | - | |
| 175 | - /* translators: %s expands to the post type name. */ | |
| 176 | - WPSEO_Meta::$meta_fields['advanced']['meta-robots-noindex']['title'] = __( 'Allow search engines to show this %s in search results?', 'wordpress-seo' ); | |
| 177 | - if ( (string) get_option( 'blog_public' ) === '0' ) { | |
| 178 | - WPSEO_Meta::$meta_fields['advanced']['meta-robots-noindex']['description'] = '<span class="error-message">' . __( 'Warning: even though you can set the meta robots setting here, the entire site is set to noindex in the sitewide privacy settings, so these settings won\'t have an effect.', 'wordpress-seo' ) . '</span>'; | |
| 179 | - } | |
| 180 | - /* translators: %1$s expands to Yes or No, %2$s expands to the post type name.*/ | |
| 181 | - WPSEO_Meta::$meta_fields['advanced']['meta-robots-noindex']['options']['0'] = __( 'Default for %2$s, currently: %1$s', 'wordpress-seo' ); | |
| 182 | - WPSEO_Meta::$meta_fields['advanced']['meta-robots-noindex']['options']['2'] = __( 'Yes', 'wordpress-seo' ); | |
| 183 | - WPSEO_Meta::$meta_fields['advanced']['meta-robots-noindex']['options']['1'] = __( 'No', 'wordpress-seo' ); | |
| 184 | - | |
| 185 | - /* translators: %1$s expands to the post type name.*/ | |
| 186 | - WPSEO_Meta::$meta_fields['advanced']['meta-robots-nofollow']['title'] = __( 'Should search engines follow links on this %1$s?', 'wordpress-seo' ); | |
| 187 | - WPSEO_Meta::$meta_fields['advanced']['meta-robots-nofollow']['options']['0'] = __( 'Yes', 'wordpress-seo' ); | |
| 188 | - WPSEO_Meta::$meta_fields['advanced']['meta-robots-nofollow']['options']['1'] = __( 'No', 'wordpress-seo' ); | |
| 189 | - | |
| 190 | - WPSEO_Meta::$meta_fields['advanced']['meta-robots-adv']['title'] = __( 'Meta robots advanced', 'wordpress-seo' ); | |
| 191 | - WPSEO_Meta::$meta_fields['advanced']['meta-robots-adv']['description'] = __( 'If you want to apply advanced <code>meta</code> robots settings for this page, please define them in the following field.', 'wordpress-seo' ); | |
| 192 | - WPSEO_Meta::$meta_fields['advanced']['meta-robots-adv']['options']['noimageindex'] = __( 'No Image Index', 'wordpress-seo' ); | |
| 193 | - WPSEO_Meta::$meta_fields['advanced']['meta-robots-adv']['options']['noarchive'] = __( 'No Archive', 'wordpress-seo' ); | |
| 194 | - WPSEO_Meta::$meta_fields['advanced']['meta-robots-adv']['options']['nosnippet'] = __( 'No Snippet', 'wordpress-seo' ); | |
| 195 | - | |
| 196 | - WPSEO_Meta::$meta_fields['advanced']['bctitle']['title'] = __( 'Breadcrumbs Title', 'wordpress-seo' ); | |
| 197 | - WPSEO_Meta::$meta_fields['advanced']['bctitle']['description'] = __( 'Title to use for this page in breadcrumb paths', 'wordpress-seo' ); | |
| 198 | - | |
| 199 | - WPSEO_Meta::$meta_fields['advanced']['canonical']['title'] = __( 'Canonical URL', 'wordpress-seo' ); | |
| 200 | - | |
| 201 | - WPSEO_Meta::$meta_fields['advanced']['canonical']['description'] = sprintf( | |
| 202 | - /* translators: 1: link open tag; 2: link close tag. */ | |
| 203 | - __( 'The canonical URL that this page should point to. Leave empty to default to permalink. %1$sCross domain canonical%2$s supported too.', 'wordpress-seo' ), | |
| 204 | - '<a href="https://googlewebmastercentral.blogspot.com/2009/12/handling-legitimate-cross-domain.html" target="_blank" rel="noopener">', | |
| 205 | - WPSEO_Admin_Utils::get_new_tab_message() . '</a>', | |
| 206 | - ); | |
| 207 | - | |
| 208 | - WPSEO_Meta::$meta_fields['advanced']['redirect']['title'] = __( '301 Redirect', 'wordpress-seo' ); | |
| 209 | - WPSEO_Meta::$meta_fields['advanced']['redirect']['description'] = __( 'The URL that this page should redirect to.', 'wordpress-seo' ); | |
| 210 | - | |
| 211 | - do_action_deprecated( 'wpseo_tab_translate', [], 'Yoast SEO 23.5', '', 'WPSEO_Metabox::translate_meta_boxes is deprecated.' ); | |
| 212 | - } | |
| 213 | - | |
| 214 | - /** | |
| 215 | 159 | * Determines whether the metabox should be shown for the passed identifier. |
| 216 | 160 | * |
| 217 | 161 | * By default the check is done for post types, but can also be used for taxonomies. |
| 218 | 162 | * |
| @@ -357,10 +301,9 @@ | ||
| 357 | 301 | // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Output escaped in class. |
| 358 | 302 | echo new Meta_Fields_Presenter( $this->get_metabox_post(), 'social' ); |
| 359 | 303 | } |
| 360 | 304 | |
| 361 | - $screen = WP_Screen::get(); | |
| 362 | - $is_block_editor = $screen && $screen->is_block_editor(); | |
| 305 | + $is_block_editor = YoastSEO()->helpers->current_page->is_block_editor(); | |
| 363 | 306 | if ( $is_block_editor && $this->get_metabox_post()->post_type === 'post' ) { |
| 364 | 307 | /** |
| 365 | 308 | * Filter: 'wpseo_enable_ai_content_planner_inline_banner' - Allows hiding the AI Content Planner inline banner site-wide. |
| 366 | 309 | * |
| @@ -508,185 +451,8 @@ | ||
| 508 | 451 | return $tabs; |
| 509 | 452 | } |
| 510 | 453 | |
| 511 | 454 | /** |
| 512 | - * Adds a line in the meta box. | |
| 513 | - * | |
| 514 | - * @deprecated 23.5 | |
| 515 | - * @codeCoverageIgnore | |
| 516 | - * | |
| 517 | - * @param string[] $meta_field_def Contains the vars based on which output is generated. | |
| 518 | - * @param string $key Internal key (without prefix). | |
| 519 | - * | |
| 520 | - * @return string | |
| 521 | - */ | |
| 522 | - public function do_meta_box( $meta_field_def, $key = '' ) { | |
| 523 | - _deprecated_function( __METHOD__, 'Yoast SEO 23.5' ); | |
| 524 | - | |
| 525 | - $content = ''; | |
| 526 | - $esc_form_key = esc_attr( WPSEO_Meta::$form_prefix . $key ); | |
| 527 | - $meta_value = WPSEO_Meta::get_value( $key, $this->get_metabox_post()->ID ); | |
| 528 | - | |
| 529 | - $class = ''; | |
| 530 | - if ( isset( $meta_field_def['class'] ) && $meta_field_def['class'] !== '' ) { | |
| 531 | - $class = ' ' . $meta_field_def['class']; | |
| 532 | - } | |
| 533 | - | |
| 534 | - $placeholder = ''; | |
| 535 | - if ( isset( $meta_field_def['placeholder'] ) && $meta_field_def['placeholder'] !== '' ) { | |
| 536 | - $placeholder = $meta_field_def['placeholder']; | |
| 537 | - } | |
| 538 | - | |
| 539 | - $aria_describedby = ''; | |
| 540 | - $description = ''; | |
| 541 | - if ( isset( $meta_field_def['description'] ) ) { | |
| 542 | - $aria_describedby = ' aria-describedby="' . $esc_form_key . '-desc"'; | |
| 543 | - $description = '<p id="' . $esc_form_key . '-desc" class="yoast-metabox__description">' . $meta_field_def['description'] . '</p>'; | |
| 544 | - } | |
| 545 | - | |
| 546 | - // Add a hide_on_pages option that returns nothing when the field is rendered on a page. | |
| 547 | - if ( isset( $meta_field_def['hide_on_pages'] ) && $meta_field_def['hide_on_pages'] && get_post_type() === 'page' ) { | |
| 548 | - return ''; | |
| 549 | - } | |
| 550 | - | |
| 551 | - switch ( $meta_field_def['type'] ) { | |
| 552 | - case 'text': | |
| 553 | - $ac = ''; | |
| 554 | - if ( isset( $meta_field_def['autocomplete'] ) && $meta_field_def['autocomplete'] === false ) { | |
| 555 | - $ac = 'autocomplete="off" '; | |
| 556 | - } | |
| 557 | - if ( $placeholder !== '' ) { | |
| 558 | - $placeholder = ' placeholder="' . esc_attr( $placeholder ) . '"'; | |
| 559 | - } | |
| 560 | - $content .= '<input type="text"' . $placeholder . ' id="' . $esc_form_key . '" ' . $ac . 'name="' . $esc_form_key . '" value="' . esc_attr( $meta_value ) . '" class="large-text' . $class . '"' . $aria_describedby . '/>'; | |
| 561 | - break; | |
| 562 | - | |
| 563 | - case 'url': | |
| 564 | - if ( $placeholder !== '' ) { | |
| 565 | - $placeholder = ' placeholder="' . esc_attr( $placeholder ) . '"'; | |
| 566 | - } | |
| 567 | - $content .= '<input type="url"' . $placeholder . ' id="' . $esc_form_key . '" name="' . $esc_form_key . '" value="' . esc_attr( urldecode( $meta_value ) ) . '" class="large-text' . $class . '"' . $aria_describedby . '/>'; | |
| 568 | - break; | |
| 569 | - | |
| 570 | - case 'textarea': | |
| 571 | - $rows = 3; | |
| 572 | - if ( isset( $meta_field_def['rows'] ) && $meta_field_def['rows'] > 0 ) { | |
| 573 | - $rows = $meta_field_def['rows']; | |
| 574 | - } | |
| 575 | - $content .= '<textarea class="large-text' . $class . '" rows="' . esc_attr( $rows ) . '" id="' . $esc_form_key . '" name="' . $esc_form_key . '"' . $aria_describedby . '>' . esc_textarea( $meta_value ) . '</textarea>'; | |
| 576 | - break; | |
| 577 | - | |
| 578 | - case 'hidden': | |
| 579 | - $default = ''; | |
| 580 | - if ( isset( $meta_field_def['default'] ) ) { | |
| 581 | - $default = sprintf( ' data-default="%s"', esc_attr( $meta_field_def['default'] ) ); | |
| 582 | - } | |
| 583 | - $content .= '<input type="hidden" id="' . $esc_form_key . '" name="' . $esc_form_key . '" value="' . esc_attr( $meta_value ) . '"' . $default . '/>' . "\n"; | |
| 584 | - break; | |
| 585 | - case 'select': | |
| 586 | - if ( isset( $meta_field_def['options'] ) && is_array( $meta_field_def['options'] ) && $meta_field_def['options'] !== [] ) { | |
| 587 | - $content .= '<select name="' . $esc_form_key . '" id="' . $esc_form_key . '" class="yoast' . $class . '">'; | |
| 588 | - foreach ( $meta_field_def['options'] as $val => $option ) { | |
| 589 | - $selected = selected( $meta_value, $val, false ); | |
| 590 | - $content .= '<option ' . $selected . ' value="' . esc_attr( $val ) . '">' . esc_html( $option ) . '</option>'; | |
| 591 | - } | |
| 592 | - unset( $val, $option, $selected ); | |
| 593 | - $content .= '</select>'; | |
| 594 | - } | |
| 595 | - break; | |
| 596 | - | |
| 597 | - case 'multiselect': | |
| 598 | - if ( isset( $meta_field_def['options'] ) && is_array( $meta_field_def['options'] ) && $meta_field_def['options'] !== [] ) { | |
| 599 | - | |
| 600 | - // Set $meta_value as $selected_arr. | |
| 601 | - $selected_arr = $meta_value; | |
| 602 | - | |
| 603 | - // If the multiselect field is 'meta-robots-adv' we should explode on ,. | |
| 604 | - if ( $key === 'meta-robots-adv' ) { | |
| 605 | - $selected_arr = explode( ',', $meta_value ); | |
| 606 | - } | |
| 607 | - | |
| 608 | - if ( ! is_array( $selected_arr ) ) { | |
| 609 | - $selected_arr = (array) $selected_arr; | |
| 610 | - } | |
| 611 | - | |
| 612 | - $options_count = count( $meta_field_def['options'] ); | |
| 613 | - | |
| 614 | - $content .= '<select multiple="multiple" size="' . esc_attr( $options_count ) . '" name="' . $esc_form_key . '[]" id="' . $esc_form_key . '" class="yoast' . $class . '"' . $aria_describedby . '>'; | |
| 615 | - foreach ( $meta_field_def['options'] as $val => $option ) { | |
| 616 | - $selected = ''; | |
| 617 | - if ( in_array( $val, $selected_arr, true ) ) { | |
| 618 | - $selected = ' selected="selected"'; | |
| 619 | - } | |
| 620 | - $content .= '<option ' . $selected . ' value="' . esc_attr( $val ) . '">' . esc_html( $option ) . '</option>'; | |
| 621 | - } | |
| 622 | - $content .= '</select>'; | |
| 623 | - unset( $val, $option, $selected, $selected_arr, $options_count ); | |
| 624 | - } | |
| 625 | - break; | |
| 626 | - | |
| 627 | - case 'checkbox': | |
| 628 | - $checked = checked( $meta_value, 'on', false ); | |
| 629 | - $expl = ( isset( $meta_field_def['expl'] ) ) ? esc_html( $meta_field_def['expl'] ) : ''; | |
| 630 | - $content .= '<input type="checkbox" id="' . $esc_form_key . '" name="' . $esc_form_key . '" ' . $checked . ' value="on" class="yoast' . $class . '"' . $aria_describedby . '/> <label for="' . $esc_form_key . '">' . $expl . '</label>'; | |
| 631 | - unset( $checked, $expl ); | |
| 632 | - break; | |
| 633 | - | |
| 634 | - case 'radio': | |
| 635 | - if ( isset( $meta_field_def['options'] ) && is_array( $meta_field_def['options'] ) && $meta_field_def['options'] !== [] ) { | |
| 636 | - foreach ( $meta_field_def['options'] as $val => $option ) { | |
| 637 | - $checked = checked( $meta_value, $val, false ); | |
| 638 | - $content .= '<input type="radio" ' . $checked . ' id="' . $esc_form_key . '_' . esc_attr( $val ) . '" name="' . $esc_form_key . '" value="' . esc_attr( $val ) . '"/> <label for="' . $esc_form_key . '_' . esc_attr( $val ) . '">' . esc_html( $option ) . '</label> '; | |
| 639 | - } | |
| 640 | - unset( $val, $option, $checked ); | |
| 641 | - } | |
| 642 | - break; | |
| 643 | - } | |
| 644 | - | |
| 645 | - $html = ''; | |
| 646 | - if ( $content === '' ) { | |
| 647 | - $content = apply_filters_deprecated( 'wpseo_do_meta_box_field_' . $key, [ $content, $meta_value, $esc_form_key, $meta_field_def, $key ], 'Yoast SEO 23.5', '', 'do_meta_box is deprecated' ); | |
| 648 | - } | |
| 649 | - | |
| 650 | - if ( $content !== '' ) { | |
| 651 | - | |
| 652 | - $title = esc_html( $meta_field_def['title'] ); | |
| 653 | - | |
| 654 | - // By default, use the field title as a label element. | |
| 655 | - $label = '<label for="' . $esc_form_key . '">' . $title . '</label>'; | |
| 656 | - | |
| 657 | - // Set the inline help and help panel, if any. | |
| 658 | - $help_button = ''; | |
| 659 | - $help_panel = ''; | |
| 660 | - if ( isset( $meta_field_def['help'] ) && $meta_field_def['help'] !== '' ) { | |
| 661 | - $help = new WPSEO_Admin_Help_Panel( $key, $meta_field_def['help-button'], $meta_field_def['help'] ); | |
| 662 | - $help_button = $help->get_button_html(); | |
| 663 | - $help_panel = $help->get_panel_html(); | |
| 664 | - } | |
| 665 | - | |
| 666 | - // If it's a set of radio buttons, output proper fieldset and legend. | |
| 667 | - if ( $meta_field_def['type'] === 'radio' ) { | |
| 668 | - return '<fieldset><legend>' . $title . '</legend>' . $help_button . $help_panel . $content . $description . '</fieldset>'; | |
| 669 | - } | |
| 670 | - | |
| 671 | - // If it's a single checkbox, ignore the title. | |
| 672 | - if ( $meta_field_def['type'] === 'checkbox' ) { | |
| 673 | - $label = ''; | |
| 674 | - } | |
| 675 | - | |
| 676 | - // Other meta box content or form fields. | |
| 677 | - if ( $meta_field_def['type'] === 'hidden' ) { | |
| 678 | - $html = $content; | |
| 679 | - } | |
| 680 | - else { | |
| 681 | - $html = $label . $description . $help_button . $help_panel . $content; | |
| 682 | - } | |
| 683 | - } | |
| 684 | - | |
| 685 | - return $html; | |
| 686 | - } | |
| 687 | - | |
| 688 | - /** | |
| 689 | 455 | * Saves the WP SEO metadata for posts. |
| 690 | 456 | * |
| 691 | 457 | * {@internal $_POST parameters are validated via sanitize_post_meta().}} |
| 692 | 458 | * |
| @@ -800,9 +566,9 @@ | ||
| 800 | 566 | * |
| 801 | 567 | * @return bool Whether the given meta value key is disabled. |
| 802 | 568 | */ |
| 803 | 569 | public function is_meta_value_disabled( $key ) { |
| 804 | - if ( $key === 'linkdex' && ! $this->seo_analysis->is_enabled() ) { | |
| 570 | + if ( in_array( $key, [ 'linkdex', 'seo_title_score', 'meta_description_score' ], true ) && ! $this->seo_analysis->is_enabled() ) { | |
| 805 | 571 | return true; |
| 806 | 572 | } |
| 807 | 573 | |
| 808 | 574 | if ( $key === 'content_score' && ! $this->readability_analysis->is_enabled() ) { |
| @@ -861,9 +627,9 @@ | ||
| 861 | 627 | $asset_manager->enqueue_style( 'monorepo' ); |
| 862 | 628 | $asset_manager->enqueue_style( 'ai-generator' ); |
| 863 | 629 | $asset_manager->enqueue_style( 'ai-fix-assessments' ); |
| 864 | 630 | |
| 865 | - $is_block_editor = WP_Screen::get()->is_block_editor(); | |
| 631 | + $is_block_editor = YoastSEO()->helpers->current_page->is_block_editor(); | |
| 866 | 632 | $post_edit_handle = 'post-edit'; |
| 867 | 633 | if ( ! $is_block_editor ) { |
| 868 | 634 | $post_edit_handle = 'post-edit-classic'; |
| 869 | 635 | } |