Edit File by line
/home/barbar84/www/wp-conte.../plugins/wordpres.../src/integrat.../third-pa...
File: elementor.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Yoast\WP\SEO\Integrations\Third_Party;
[2] Fix | Delete
[3] Fix | Delete
use Elementor\Controls_Manager;
[4] Fix | Delete
use Elementor\Core\DocumentTypes\PageBase;
[5] Fix | Delete
use WP_Post;
[6] Fix | Delete
use WP_Screen;
[7] Fix | Delete
use WPSEO_Admin_Asset_Manager;
[8] Fix | Delete
use WPSEO_Admin_Asset_Yoast_Components_L10n;
[9] Fix | Delete
use WPSEO_Admin_Recommended_Replace_Vars;
[10] Fix | Delete
use WPSEO_Language_Utils;
[11] Fix | Delete
use WPSEO_Meta;
[12] Fix | Delete
use WPSEO_Metabox_Analysis_Readability;
[13] Fix | Delete
use WPSEO_Metabox_Analysis_SEO;
[14] Fix | Delete
use WPSEO_Metabox_Formatter;
[15] Fix | Delete
use WPSEO_Post_Metabox_Formatter;
[16] Fix | Delete
use WPSEO_Replace_Vars;
[17] Fix | Delete
use WPSEO_Utils;
[18] Fix | Delete
use Yoast\WP\SEO\Actions\Alert_Dismissal_Action;
[19] Fix | Delete
use Yoast\WP\SEO\Conditionals\Admin\Estimated_Reading_Time_Conditional;
[20] Fix | Delete
use Yoast\WP\SEO\Conditionals\Third_Party\Elementor_Edit_Conditional;
[21] Fix | Delete
use Yoast\WP\SEO\Helpers\Capability_Helper;
[22] Fix | Delete
use Yoast\WP\SEO\Helpers\Options_Helper;
[23] Fix | Delete
use Yoast\WP\SEO\Integrations\Integration_Interface;
[24] Fix | Delete
use Yoast\WP\SEO\Presenters\Admin\Meta_Fields_Presenter;
[25] Fix | Delete
[26] Fix | Delete
/**
[27] Fix | Delete
* Integrates the Yoast SEO metabox in the Elementor editor.
[28] Fix | Delete
*/
[29] Fix | Delete
class Elementor implements Integration_Interface {
[30] Fix | Delete
[31] Fix | Delete
/**
[32] Fix | Delete
* The identifier for the elementor tab.
[33] Fix | Delete
*/
[34] Fix | Delete
const YOAST_TAB = 'yoast-tab';
[35] Fix | Delete
[36] Fix | Delete
/**
[37] Fix | Delete
* Represents the post.
[38] Fix | Delete
*
[39] Fix | Delete
* @var WP_Post|null
[40] Fix | Delete
*/
[41] Fix | Delete
protected $post;
[42] Fix | Delete
[43] Fix | Delete
/**
[44] Fix | Delete
* Represents the admin asset manager.
[45] Fix | Delete
*
[46] Fix | Delete
* @var WPSEO_Admin_Asset_Manager
[47] Fix | Delete
*/
[48] Fix | Delete
protected $asset_manager;
[49] Fix | Delete
[50] Fix | Delete
/**
[51] Fix | Delete
* Represents the options helper.
[52] Fix | Delete
*
[53] Fix | Delete
* @var Options_Helper
[54] Fix | Delete
*/
[55] Fix | Delete
protected $options;
[56] Fix | Delete
[57] Fix | Delete
/**
[58] Fix | Delete
* Represents the capability helper.
[59] Fix | Delete
*
[60] Fix | Delete
* @var Capability_Helper
[61] Fix | Delete
*/
[62] Fix | Delete
protected $capability;
[63] Fix | Delete
[64] Fix | Delete
/**
[65] Fix | Delete
* Holds whether the socials are enabled.
[66] Fix | Delete
*
[67] Fix | Delete
* @var bool
[68] Fix | Delete
*/
[69] Fix | Delete
protected $social_is_enabled;
[70] Fix | Delete
[71] Fix | Delete
/**
[72] Fix | Delete
* Holds whether the advanced settings are enabled.
[73] Fix | Delete
*
[74] Fix | Delete
* @var bool
[75] Fix | Delete
*/
[76] Fix | Delete
protected $is_advanced_metadata_enabled;
[77] Fix | Delete
[78] Fix | Delete
/**
[79] Fix | Delete
* Helper to determine whether or not the SEO analysis is enabled.
[80] Fix | Delete
*
[81] Fix | Delete
* @var WPSEO_Metabox_Analysis_SEO
[82] Fix | Delete
*/
[83] Fix | Delete
protected $seo_analysis;
[84] Fix | Delete
[85] Fix | Delete
/**
[86] Fix | Delete
* Helper to determine whether or not the readability analysis is enabled.
[87] Fix | Delete
*
[88] Fix | Delete
* @var WPSEO_Metabox_Analysis_Readability
[89] Fix | Delete
*/
[90] Fix | Delete
protected $readability_analysis;
[91] Fix | Delete
[92] Fix | Delete
/**
[93] Fix | Delete
* Represents the estimated_reading_time_conditional.
[94] Fix | Delete
*
[95] Fix | Delete
* @var Estimated_Reading_Time_Conditional
[96] Fix | Delete
*/
[97] Fix | Delete
protected $estimated_reading_time_conditional;
[98] Fix | Delete
[99] Fix | Delete
/**
[100] Fix | Delete
* Returns the conditionals based in which this loadable should be active.
[101] Fix | Delete
*
[102] Fix | Delete
* @return array
[103] Fix | Delete
*/
[104] Fix | Delete
public static function get_conditionals() {
[105] Fix | Delete
return [ Elementor_Edit_Conditional::class ];
[106] Fix | Delete
}
[107] Fix | Delete
[108] Fix | Delete
/**
[109] Fix | Delete
* Constructor.
[110] Fix | Delete
*
[111] Fix | Delete
* @param WPSEO_Admin_Asset_Manager $asset_manager The asset manager.
[112] Fix | Delete
* @param Options_Helper $options The options helper.
[113] Fix | Delete
* @param Capability_Helper $capability The capability helper.
[114] Fix | Delete
* @param Estimated_Reading_Time_Conditional $estimated_reading_time_conditional The Estimated Reading Time
[115] Fix | Delete
* conditional.
[116] Fix | Delete
*/
[117] Fix | Delete
public function __construct(
[118] Fix | Delete
WPSEO_Admin_Asset_Manager $asset_manager,
[119] Fix | Delete
Options_Helper $options,
[120] Fix | Delete
Capability_Helper $capability,
[121] Fix | Delete
Estimated_Reading_Time_Conditional $estimated_reading_time_conditional
[122] Fix | Delete
) {
[123] Fix | Delete
$this->asset_manager = $asset_manager;
[124] Fix | Delete
$this->options = $options;
[125] Fix | Delete
$this->capability = $capability;
[126] Fix | Delete
[127] Fix | Delete
$this->seo_analysis = new WPSEO_Metabox_Analysis_SEO();
[128] Fix | Delete
$this->readability_analysis = new WPSEO_Metabox_Analysis_Readability();
[129] Fix | Delete
$this->social_is_enabled = $this->options->get( 'opengraph', false ) || $this->options->get( 'twitter', false );
[130] Fix | Delete
$this->is_advanced_metadata_enabled = $this->capability->current_user_can( 'wpseo_edit_advanced_metadata' ) || $this->options->get( 'disableadvanced_meta' ) === false;
[131] Fix | Delete
$this->estimated_reading_time_conditional = $estimated_reading_time_conditional;
[132] Fix | Delete
}
[133] Fix | Delete
[134] Fix | Delete
/**
[135] Fix | Delete
* Initializes the integration.
[136] Fix | Delete
*
[137] Fix | Delete
* This is the place to register hooks and filters.
[138] Fix | Delete
*
[139] Fix | Delete
* @return void
[140] Fix | Delete
*/
[141] Fix | Delete
public function register_hooks() {
[142] Fix | Delete
\add_action( 'wp_ajax_wpseo_elementor_save', [ $this, 'save_postdata' ] );
[143] Fix | Delete
[144] Fix | Delete
// We need to delay the post type lookup to give other plugins a chance to register custom post types.
[145] Fix | Delete
\add_action( 'init', [ $this, 'register_elementor_hooks' ], \PHP_INT_MAX );
[146] Fix | Delete
}
[147] Fix | Delete
[148] Fix | Delete
/**
[149] Fix | Delete
* Registers our Elementor hooks.
[150] Fix | Delete
*/
[151] Fix | Delete
public function register_elementor_hooks() {
[152] Fix | Delete
if ( ! $this->display_metabox( $this->get_metabox_post()->post_type ) ) {
[153] Fix | Delete
return;
[154] Fix | Delete
}
[155] Fix | Delete
[156] Fix | Delete
\add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'init' ] );
[157] Fix | Delete
[158] Fix | Delete
// We are too late for elementor/init. We should see if we can be on time, or else this workaround works (we do always get the "else" though).
[159] Fix | Delete
if ( ! \did_action( 'elementor/init' ) ) {
[160] Fix | Delete
\add_action( 'elementor/init', [ $this, 'add_yoast_panel_tab' ] );
[161] Fix | Delete
}
[162] Fix | Delete
else {
[163] Fix | Delete
$this->add_yoast_panel_tab();
[164] Fix | Delete
}
[165] Fix | Delete
\add_action( 'elementor/documents/register_controls', [ $this, 'register_document_controls' ] );
[166] Fix | Delete
}
[167] Fix | Delete
[168] Fix | Delete
/**
[169] Fix | Delete
* Initializes the integration.
[170] Fix | Delete
*
[171] Fix | Delete
* @return void
[172] Fix | Delete
*/
[173] Fix | Delete
public function init() {
[174] Fix | Delete
$this->asset_manager->register_assets();
[175] Fix | Delete
$this->enqueue();
[176] Fix | Delete
$this->render_hidden_fields();
[177] Fix | Delete
}
[178] Fix | Delete
[179] Fix | Delete
/**
[180] Fix | Delete
* Register a panel tab slug, in order to allow adding controls to this tab.
[181] Fix | Delete
*/
[182] Fix | Delete
public function add_yoast_panel_tab() {
[183] Fix | Delete
Controls_Manager::add_tab( $this::YOAST_TAB, \__( 'Yoast SEO', 'wordpress-seo' ) );
[184] Fix | Delete
}
[185] Fix | Delete
[186] Fix | Delete
/**
[187] Fix | Delete
* Register additional document controls.
[188] Fix | Delete
*
[189] Fix | Delete
* @param PageBase $document The PageBase document.
[190] Fix | Delete
*/
[191] Fix | Delete
public function register_document_controls( $document ) {
[192] Fix | Delete
// PageBase is the base class for documents like `post` `page` and etc.
[193] Fix | Delete
if ( ! $document instanceof PageBase || ! $document::get_property( 'has_elements' ) ) {
[194] Fix | Delete
return;
[195] Fix | Delete
}
[196] Fix | Delete
[197] Fix | Delete
// This is needed to get the tab to appear, but will be overwritten in the JavaScript.
[198] Fix | Delete
$document->start_controls_section(
[199] Fix | Delete
'yoast_temporary_section',
[200] Fix | Delete
[
[201] Fix | Delete
'label' => \__( 'Yoast SEO', 'wordpress-seo' ),
[202] Fix | Delete
'tab' => self::YOAST_TAB,
[203] Fix | Delete
]
[204] Fix | Delete
);
[205] Fix | Delete
[206] Fix | Delete
$document->end_controls_section();
[207] Fix | Delete
}
[208] Fix | Delete
[209] Fix | Delete
// Below is mostly copied from `class-metabox.php`. That constructor has side-effects we do not need.
[210] Fix | Delete
[211] Fix | Delete
/**
[212] Fix | Delete
* Determines whether the metabox should be shown for the passed identifier.
[213] Fix | Delete
*
[214] Fix | Delete
* By default the check is done for post types, but can also be used for taxonomies.
[215] Fix | Delete
*
[216] Fix | Delete
* @param string|null $identifier The identifier to check.
[217] Fix | Delete
* @param string $type The type of object to check. Defaults to post_type.
[218] Fix | Delete
*
[219] Fix | Delete
* @return bool Whether or not the metabox should be displayed.
[220] Fix | Delete
*/
[221] Fix | Delete
public function display_metabox( $identifier = null, $type = 'post_type' ) {
[222] Fix | Delete
return WPSEO_Utils::is_metabox_active( $identifier, $type );
[223] Fix | Delete
}
[224] Fix | Delete
[225] Fix | Delete
/**
[226] Fix | Delete
* Saves the WP SEO metadata for posts.
[227] Fix | Delete
*
[228] Fix | Delete
* Outputs JSON via wp_send_json then stops code execution.
[229] Fix | Delete
*
[230] Fix | Delete
* {@internal $_POST parameters are validated via sanitize_post_meta().}}
[231] Fix | Delete
*
[232] Fix | Delete
* @return void
[233] Fix | Delete
*/
[234] Fix | Delete
public function save_postdata() {
[235] Fix | Delete
global $post;
[236] Fix | Delete
[237] Fix | Delete
$post_id = \filter_input( \INPUT_POST, 'post_id', \FILTER_SANITIZE_NUMBER_INT );
[238] Fix | Delete
[239] Fix | Delete
if ( ! \current_user_can( 'manage_options' ) ) {
[240] Fix | Delete
\wp_send_json_error( 'Unauthorized', 401 );
[241] Fix | Delete
}
[242] Fix | Delete
[243] Fix | Delete
\check_ajax_referer( 'wpseo_elementor_save', '_wpseo_elementor_nonce' );
[244] Fix | Delete
[245] Fix | Delete
// Bail if this is a multisite installation and the site has been switched.
[246] Fix | Delete
if ( \is_multisite() && \ms_is_switched() ) {
[247] Fix | Delete
\wp_send_json_error( 'Switched multisite', 409 );
[248] Fix | Delete
}
[249] Fix | Delete
[250] Fix | Delete
\clean_post_cache( $post_id );
[251] Fix | Delete
// phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- To setup the post we need to do this explicitly.
[252] Fix | Delete
$post = \get_post( $post_id );
[253] Fix | Delete
[254] Fix | Delete
if ( ! \is_object( $post ) ) {
[255] Fix | Delete
// Non-existent post.
[256] Fix | Delete
\wp_send_json_error( 'Post not found', 400 );
[257] Fix | Delete
}
[258] Fix | Delete
[259] Fix | Delete
\do_action( 'wpseo_save_compare_data', $post );
[260] Fix | Delete
[261] Fix | Delete
// Initialize meta, amongst other things it registers sanitization.
[262] Fix | Delete
WPSEO_Meta::init();
[263] Fix | Delete
[264] Fix | Delete
$social_fields = [];
[265] Fix | Delete
if ( $this->social_is_enabled ) {
[266] Fix | Delete
$social_fields = WPSEO_Meta::get_meta_field_defs( 'social', $post->post_type );
[267] Fix | Delete
}
[268] Fix | Delete
[269] Fix | Delete
// The below methods use the global post so make sure it is setup.
[270] Fix | Delete
\setup_postdata( $post );
[271] Fix | Delete
$meta_boxes = \apply_filters( 'wpseo_save_metaboxes', [] );
[272] Fix | Delete
$meta_boxes = \array_merge(
[273] Fix | Delete
$meta_boxes,
[274] Fix | Delete
WPSEO_Meta::get_meta_field_defs( 'general', $post->post_type ),
[275] Fix | Delete
WPSEO_Meta::get_meta_field_defs( 'advanced', $post->post_type ),
[276] Fix | Delete
$social_fields,
[277] Fix | Delete
WPSEO_Meta::get_meta_field_defs( 'schema', $post->post_type )
[278] Fix | Delete
);
[279] Fix | Delete
[280] Fix | Delete
foreach ( $meta_boxes as $key => $meta_box ) {
[281] Fix | Delete
// If analysis is disabled remove that analysis score value from the DB.
[282] Fix | Delete
if ( $this->is_meta_value_disabled( $key ) ) {
[283] Fix | Delete
WPSEO_Meta::delete( $key, $post_id );
[284] Fix | Delete
continue;
[285] Fix | Delete
}
[286] Fix | Delete
[287] Fix | Delete
$data = null;
[288] Fix | Delete
$field_name = WPSEO_Meta::$form_prefix . $key;
[289] Fix | Delete
[290] Fix | Delete
if ( $meta_box['type'] === 'checkbox' ) {
[291] Fix | Delete
$data = isset( $_POST[ $field_name ] ) ? 'on' : 'off';
[292] Fix | Delete
}
[293] Fix | Delete
else {
[294] Fix | Delete
if ( isset( $_POST[ $field_name ] ) ) {
[295] Fix | Delete
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: Sanitized through sanitize_post_meta.
[296] Fix | Delete
$data = \wp_unslash( $_POST[ $field_name ] );
[297] Fix | Delete
[298] Fix | Delete
// For multi-select.
[299] Fix | Delete
if ( \is_array( $data ) ) {
[300] Fix | Delete
$data = \array_map( [ 'WPSEO_Utils', 'sanitize_text_field' ], $data );
[301] Fix | Delete
}
[302] Fix | Delete
[303] Fix | Delete
if ( \is_string( $data ) ) {
[304] Fix | Delete
$data = ( $key !== 'canonical' ) ? WPSEO_Utils::sanitize_text_field( $data ) : WPSEO_Utils::sanitize_url( $data );
[305] Fix | Delete
}
[306] Fix | Delete
}
[307] Fix | Delete
[308] Fix | Delete
// Reset options when no entry is present with multiselect - only applies to `meta-robots-adv` currently.
[309] Fix | Delete
if ( ! isset( $_POST[ $field_name ] ) && ( $meta_box['type'] === 'multiselect' ) ) {
[310] Fix | Delete
$data = [];
[311] Fix | Delete
}
[312] Fix | Delete
}
[313] Fix | Delete
[314] Fix | Delete
if ( $data !== null ) {
[315] Fix | Delete
WPSEO_Meta::set_value( $key, $data, $post_id );
[316] Fix | Delete
}
[317] Fix | Delete
}
[318] Fix | Delete
[319] Fix | Delete
// Saving the WP post to save the slug.
[320] Fix | Delete
$slug = \filter_input( \INPUT_POST, WPSEO_Meta::$form_prefix . 'slug', \FILTER_SANITIZE_STRING );
[321] Fix | Delete
if ( $post->post_name !== $slug ) {
[322] Fix | Delete
$post_array = $post->to_array();
[323] Fix | Delete
$post_array['post_name'] = $slug;
[324] Fix | Delete
[325] Fix | Delete
$save_successful = \wp_insert_post( $post_array );
[326] Fix | Delete
if ( \is_wp_error( $save_successful ) ) {
[327] Fix | Delete
\wp_send_json_error( 'Slug not saved', 400 );
[328] Fix | Delete
}
[329] Fix | Delete
[330] Fix | Delete
// Update the post object to ensure we have the actual slug.
[331] Fix | Delete
// phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- Updating the post is needed to get the current slug.
[332] Fix | Delete
$post = \get_post( $post_id );
[333] Fix | Delete
if ( ! \is_object( $post ) ) {
[334] Fix | Delete
\wp_send_json_error( 'Updated slug not found', 400 );
[335] Fix | Delete
}
[336] Fix | Delete
}
[337] Fix | Delete
[338] Fix | Delete
\do_action( 'wpseo_saved_postdata' );
[339] Fix | Delete
[340] Fix | Delete
// Output the slug, because it is processed by WP and we need the actual slug again.
[341] Fix | Delete
\wp_send_json_success( [ 'slug' => $post->post_name ] );
[342] Fix | Delete
}
[343] Fix | Delete
[344] Fix | Delete
/**
[345] Fix | Delete
* Determines if the given meta value key is disabled.
[346] Fix | Delete
*
[347] Fix | Delete
* @param string $key The key of the meta value.
[348] Fix | Delete
*
[349] Fix | Delete
* @return bool Whether the given meta value key is disabled.
[350] Fix | Delete
*/
[351] Fix | Delete
public function is_meta_value_disabled( $key ) {
[352] Fix | Delete
if ( $key === 'linkdex' && ! $this->seo_analysis->is_enabled() ) {
[353] Fix | Delete
return true;
[354] Fix | Delete
}
[355] Fix | Delete
[356] Fix | Delete
if ( $key === 'content_score' && ! $this->readability_analysis->is_enabled() ) {
[357] Fix | Delete
return true;
[358] Fix | Delete
}
[359] Fix | Delete
[360] Fix | Delete
return false;
[361] Fix | Delete
}
[362] Fix | Delete
[363] Fix | Delete
/**
[364] Fix | Delete
* Enqueues all the needed JS and CSS.
[365] Fix | Delete
*
[366] Fix | Delete
* @return void
[367] Fix | Delete
*/
[368] Fix | Delete
public function enqueue() {
[369] Fix | Delete
$post_id = \get_queried_object_id();
[370] Fix | Delete
if ( empty( $post_id ) ) {
[371] Fix | Delete
$post_id = \sanitize_text_field( \filter_input( \INPUT_GET, 'post' ) );
[372] Fix | Delete
}
[373] Fix | Delete
[374] Fix | Delete
if ( $post_id !== 0 ) {
[375] Fix | Delete
// Enqueue files needed for upload functionality.
[376] Fix | Delete
\wp_enqueue_media( [ 'post' => $post_id ] );
[377] Fix | Delete
}
[378] Fix | Delete
[379] Fix | Delete
$this->asset_manager->enqueue_style( 'admin-global' );
[380] Fix | Delete
$this->asset_manager->enqueue_style( 'metabox-css' );
[381] Fix | Delete
$this->asset_manager->enqueue_style( 'scoring' );
[382] Fix | Delete
$this->asset_manager->enqueue_style( 'select2' );
[383] Fix | Delete
$this->asset_manager->enqueue_style( 'monorepo' );
[384] Fix | Delete
$this->asset_manager->enqueue_style( 'admin-css' );
[385] Fix | Delete
$this->asset_manager->enqueue_style( 'elementor' );
[386] Fix | Delete
[387] Fix | Delete
$this->asset_manager->enqueue_script( 'elementor' );
[388] Fix | Delete
[389] Fix | Delete
$yoast_components_l10n = new WPSEO_Admin_Asset_Yoast_Components_L10n();
[390] Fix | Delete
$yoast_components_l10n->localize_script( 'elementor' );
[391] Fix | Delete
[392] Fix | Delete
$this->asset_manager->localize_script( 'elementor', 'wpseoAdminL10n', WPSEO_Utils::get_admin_l10n() );
[393] Fix | Delete
$this->asset_manager->localize_script( 'elementor', 'wpseoFeaturesL10n', WPSEO_Utils::retrieve_enabled_features() );
[394] Fix | Delete
[395] Fix | Delete
$plugins_script_data = [
[396] Fix | Delete
'replaceVars' => [
[397] Fix | Delete
'no_parent_text' => \__( '(no parent)', 'wordpress-seo' ),
[398] Fix | Delete
'replace_vars' => $this->get_replace_vars(),
[399] Fix | Delete
'recommended_replace_vars' => $this->get_recommended_replace_vars(),
[400] Fix | Delete
'hidden_replace_vars' => $this->get_hidden_replace_vars(),
[401] Fix | Delete
'scope' => $this->determine_scope(),
[402] Fix | Delete
'has_taxonomies' => $this->current_post_type_has_taxonomies(),
[403] Fix | Delete
],
[404] Fix | Delete
'shortcodes' => [
[405] Fix | Delete
'wpseo_filter_shortcodes_nonce' => \wp_create_nonce( 'wpseo-filter-shortcodes' ),
[406] Fix | Delete
'wpseo_shortcode_tags' => $this->get_valid_shortcode_tags(),
[407] Fix | Delete
],
[408] Fix | Delete
];
[409] Fix | Delete
[410] Fix | Delete
$worker_script_data = [
[411] Fix | Delete
'url' => \YoastSEO()->helpers->asset->get_asset_url( 'yoast-seo-analysis-worker' ),
[412] Fix | Delete
'dependencies' => \YoastSEO()->helpers->asset->get_dependency_urls_by_handle( 'yoast-seo-analysis-worker' ),
[413] Fix | Delete
'keywords_assessment_url' => \YoastSEO()->helpers->asset->get_asset_url( 'yoast-seo-used-keywords-assessment' ),
[414] Fix | Delete
'log_level' => WPSEO_Utils::get_analysis_worker_log_level(),
[415] Fix | Delete
// We need to make the feature flags separately available inside of the analysis web worker.
[416] Fix | Delete
'enabled_features' => WPSEO_Utils::retrieve_enabled_features(),
[417] Fix | Delete
];
[418] Fix | Delete
[419] Fix | Delete
$alert_dismissal_action = \YoastSEO()->classes->get( Alert_Dismissal_Action::class );
[420] Fix | Delete
$dismissed_alerts = $alert_dismissal_action->all_dismissed();
[421] Fix | Delete
[422] Fix | Delete
$script_data = [
[423] Fix | Delete
'media' => [ 'choose_image' => \__( 'Use Image', 'wordpress-seo' ) ],
[424] Fix | Delete
'metabox' => $this->get_metabox_script_data(),
[425] Fix | Delete
'userLanguageCode' => WPSEO_Language_Utils::get_language( \get_user_locale() ),
[426] Fix | Delete
'isPost' => true,
[427] Fix | Delete
'isBlockEditor' => WP_Screen::get()->is_block_editor(),
[428] Fix | Delete
'isElementorEditor' => true,
[429] Fix | Delete
'analysis' => [
[430] Fix | Delete
'plugins' => $plugins_script_data,
[431] Fix | Delete
'worker' => $worker_script_data,
[432] Fix | Delete
'estimatedReadingTimeEnabled' => $this->estimated_reading_time_conditional->is_met(),
[433] Fix | Delete
],
[434] Fix | Delete
'dismissedAlerts' => $dismissed_alerts,
[435] Fix | Delete
];
[436] Fix | Delete
[437] Fix | Delete
if ( \post_type_supports( $this->get_metabox_post()->post_type, 'thumbnail' ) ) {
[438] Fix | Delete
$this->asset_manager->enqueue_style( 'featured-image' );
[439] Fix | Delete
[440] Fix | Delete
$script_data['featuredImage'] = [
[441] Fix | Delete
'featured_image_notice' => \__( 'SEO issue: The featured image should be at least 200 by 200 pixels to be picked up by Facebook and other social media sites.', 'wordpress-seo' ),
[442] Fix | Delete
];
[443] Fix | Delete
}
[444] Fix | Delete
[445] Fix | Delete
$this->asset_manager->localize_script( 'elementor', 'wpseoScriptData', $script_data );
[446] Fix | Delete
$this->asset_manager->enqueue_user_language_script();
[447] Fix | Delete
}
[448] Fix | Delete
[449] Fix | Delete
/**
[450] Fix | Delete
* Renders the metabox hidden fields.
[451] Fix | Delete
*
[452] Fix | Delete
* @return void
[453] Fix | Delete
*/
[454] Fix | Delete
protected function render_hidden_fields() {
[455] Fix | Delete
// Wrap in a form with an action and post_id for the submit.
[456] Fix | Delete
\printf(
[457] Fix | Delete
'<form id="yoast-form" method="post" action="%1$s"><input type="hidden" name="action" value="wpseo_elementor_save" /><input type="hidden" id="post_ID" name="post_id" value="%2$s" />',
[458] Fix | Delete
\esc_url( \admin_url( 'admin-ajax.php' ) ),
[459] Fix | Delete
\esc_attr( $this->get_metabox_post()->ID )
[460] Fix | Delete
);
[461] Fix | Delete
[462] Fix | Delete
\wp_nonce_field( 'wpseo_elementor_save', '_wpseo_elementor_nonce' );
[463] Fix | Delete
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: Meta_Fields_Presenter->present is considered safe.
[464] Fix | Delete
echo new Meta_Fields_Presenter( $this->get_metabox_post(), 'general' );
[465] Fix | Delete
[466] Fix | Delete
if ( $this->is_advanced_metadata_enabled ) {
[467] Fix | Delete
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: Meta_Fields_Presenter->present is considered safe.
[468] Fix | Delete
echo new Meta_Fields_Presenter( $this->get_metabox_post(), 'advanced' );
[469] Fix | Delete
}
[470] Fix | Delete
[471] Fix | Delete
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: Meta_Fields_Presenter->present is considered safe.
[472] Fix | Delete
echo new Meta_Fields_Presenter( $this->get_metabox_post(), 'schema', $this->get_metabox_post()->post_type );
[473] Fix | Delete
[474] Fix | Delete
if ( $this->social_is_enabled ) {
[475] Fix | Delete
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: Meta_Fields_Presenter->present is considered safe.
[476] Fix | Delete
echo new Meta_Fields_Presenter( $this->get_metabox_post(), 'social' );
[477] Fix | Delete
}
[478] Fix | Delete
[479] Fix | Delete
\printf(
[480] Fix | Delete
'<input type="hidden" id="%1$s" name="%1$s" value="%2$s" />',
[481] Fix | Delete
\esc_attr( WPSEO_Meta::$form_prefix . 'slug' ),
[482] Fix | Delete
\esc_attr( $this->get_metabox_post()->post_name )
[483] Fix | Delete
);
[484] Fix | Delete
[485] Fix | Delete
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Output should be escaped in the filter.
[486] Fix | Delete
echo \apply_filters( 'wpseo_elementor_hidden_fields', '' );
[487] Fix | Delete
[488] Fix | Delete
echo '</form>';
[489] Fix | Delete
}
[490] Fix | Delete
[491] Fix | Delete
/**
[492] Fix | Delete
* Returns post in metabox context.
[493] Fix | Delete
*
[494] Fix | Delete
* @return WP_Post|null
[495] Fix | Delete
*/
[496] Fix | Delete
protected function get_metabox_post() {
[497] Fix | Delete
if ( $this->post !== null ) {
[498] Fix | Delete
return $this->post;
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function