C:\xampp\htdocs\landing\wp-content\plugins\wordpress-seo\src\integrations\third-party\elementor.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
<?php

namespace Yoast\WP\SEO\Integrations\Third_Party;

use 
WP_Post;
use 
WP_Screen;
use 
WPSEO_Admin_Asset;
use 
WPSEO_Admin_Asset_Analysis_Worker_Location;
use 
WPSEO_Admin_Asset_Manager;
use 
WPSEO_Admin_Asset_Yoast_Components_L10n;
use 
WPSEO_Admin_Recommended_Replace_Vars;
use 
WPSEO_Language_Utils;
use 
WPSEO_Meta;
use 
WPSEO_Metabox_Analysis_Readability;
use 
WPSEO_Metabox_Analysis_SEO;
use 
WPSEO_Metabox_Formatter;
use 
WPSEO_Post_Metabox_Formatter;
use 
WPSEO_Utils;
use 
Yoast\WP\SEO\Conditionals\Third_Party\Elementor_Edit_Conditional;
use 
Yoast\WP\SEO\Helpers\Capability_Helper;
use 
Yoast\WP\SEO\Helpers\Options_Helper;
use 
Yoast\WP\SEO\Integrations\Integration_Interface;
use 
Yoast\WP\SEO\Presenters\Admin\Meta_Fields_Presenter;
use 
Elementor\Controls_Manager;
use 
Elementor\Core\DocumentTypes\PageBase;
use 
Yoast\WP\SEO\Conditionals\Admin\Estimated_Reading_Time_Conditional;

/**
 * Integrates the Yoast SEO metabox in the Elementor editor.
 */
class Elementor implements Integration_Interface {

    
/**
     * Represents the post.
     *
     * @var WP_Post|null
     */
    
protected $post;

    
/**
     * Represents the admin asset manager.
     *
     * @var WPSEO_Admin_Asset_Manager
     */
    
protected $asset_manager;

    
/**
     * Represents the options helper.
     *
     * @var \Yoast\WP\SEO\Helpers\Options_Helper
     */
    
protected $options;

    
/**
     * Represents the capability helper.
     *
     * @var \Yoast\WP\SEO\Helpers\Capability_Helper
     */
    
protected $capability;

    
/**
     * Holds whether the socials are enabled.
     *
     * @var bool
     */
    
protected $social_is_enabled;

    
/**
     * Holds whether the advanced settings are enabled.
     *
     * @var bool
     */
    
protected $is_advanced_metadata_enabled;

    
/**
     * Helper to determine whether or not the SEO analysis is enabled.
     *
     * @var WPSEO_Metabox_Analysis_SEO
     */
    
protected $seo_analysis;

    
/**
     * Helper to determine whether or not the readability analysis is enabled.
     *
     * @var WPSEO_Metabox_Analysis_Readability
     */
    
protected $readability_analysis;

    
/**
     * Represents the estimated_reading_time_conditional.
     *
     * @var Estimated_Reading_Time_Conditional
     */
    
protected $estimated_reading_time_conditional;

    
/**
     * The identifier for the elementor tab.
     */
    
const YOAST_TAB 'yoast-tab';

    
/**
     * Returns the conditionals based in which this loadable should be active.
     *
     * @return array
     */
    
public static function get_conditionals() {
        return [ 
Elementor_Edit_Conditional::class ];
    }

    
/**
     * Constructor.
     *
     * @param WPSEO_Admin_Asset_Manager          $asset_manager                      The asset manager.
     * @param Options_Helper                     $options                            The options helper.
     * @param Capability_Helper                  $capability                         The capability helper.
     * @param Estimated_Reading_Time_Conditional $estimated_reading_time_conditional The Estimated Reading Time conditional.
     */
    
public function __construct(
        
WPSEO_Admin_Asset_Manager $asset_manager,
        
Options_Helper $options,
        
Capability_Helper $capability,
        
Estimated_Reading_Time_Conditional $estimated_reading_time_conditional
    
) {
        
$this->asset_manager $asset_manager;
        
$this->options       $options;
        
$this->capability    $capability;

        
$this->seo_analysis                       = new WPSEO_Metabox_Analysis_SEO();
        
$this->readability_analysis               = new WPSEO_Metabox_Analysis_Readability();
        
$this->social_is_enabled                  $this->options->get'opengraph'false ) || $this->options->get'twitter'false );
        
$this->is_advanced_metadata_enabled       $this->capability->current_user_can'wpseo_edit_advanced_metadata' ) || $this->options->get'disableadvanced_meta' ) === false;
        
$this->estimated_reading_time_conditional $estimated_reading_time_conditional;
    }

    
/**
     * Initializes the integration.
     *
     * This is the place to register hooks and filters.
     *
     * @return void
     */
    
public function register_hooks() {
        \
add_action'wp_ajax_wpseo_elementor_save', [ $this'save_postdata' ] );

        if ( ! 
$this->display_metabox$this->get_metabox_post()->post_type ) ) {
            return;
        }

        \
add_action'elementor/editor/before_enqueue_scripts', [ $this'init' ] );

        
// 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).
        
if ( ! \did_action'elementor/init' ) ) {
            \
add_action'elementor/init', [ $this'add_yoast_panel_tab' ] );
        }
        else {
            
$this->add_yoast_panel_tab();
        }
        \
add_action'elementor/documents/register_controls', [ $this'register_document_controls' ] );
    }

    
/**
     * Initializes the integration.
     *
     * @return void
     */
    
public function init() {
        
$this->asset_manager->register_assets();
        
$this->enqueue();
        
$this->render_hidden_fields();
    }

    
/**
     * Register a panel tab slug, in order to allow adding controls to this tab.
     */
    
public function add_yoast_panel_tab() {
        
Controls_Manager::add_tab$this::YOAST_TAB__'Yoast SEO''wordpress-seo' ) );
    }

    
/**
     * Register additional document controls.
     *
     * @param PageBase $document The PageBase document.
     */
    
public function register_document_controls$document ) {
        
// PageBase is the base class for documents like `post` `page` and etc.
        
if ( ! $document instanceof PageBase || ! $document::get_property'has_elements' ) ) {
            return;
        }

        
// This is needed to get the tab to appear, but will be overwritten in the JavaScript.
        
$document->start_controls_section(
            
'yoast_temporary_section',
            [
                
'label' => __'Yoast SEO''wordpress-seo' ),
                
'tab'   => self::YOAST_TAB,
            ]
        );

        
$document->end_controls_section();
    }

    
// Below is mostly copied from `class-metabox.php`. That constructor has side-effects we do not need.

    /**
     * Determines whether the metabox should be shown for the passed identifier.
     *
     * By default the check is done for post types, but can also be used for taxonomies.
     *
     * @param string|null $identifier The identifier to check.
     * @param string      $type       The type of object to check. Defaults to post_type.
     *
     * @return bool Whether or not the metabox should be displayed.
     */
    
public function display_metabox$identifier null$type 'post_type' ) {
        return 
WPSEO_Utils::is_metabox_active$identifier$type );
    }

    
/**
     * Saves the WP SEO metadata for posts.
     *
     * {@internal $_POST parameters are validated via sanitize_post_meta().}}
     *
     * @return void Outputs JSON via wp_send_json then stops code execution.
     */
    
public function save_postdata() {
        global 
$post;

        
$post_id = \filter_inputINPUT_POST'post_id'FILTER_SANITIZE_NUMBER_INT );

        if ( ! \
current_user_can'manage_options' ) ) {
            \
wp_send_json_error'Unauthorized'401 );
        }

        \
check_ajax_referer'wpseo_elementor_save''_wpseo_elementor_nonce' );

        
// Bail if this is a multisite installation and the site has been switched.
        
if ( \is_multisite() && \ms_is_switched() ) {
            \
wp_send_json_error'Switched multisite'409 );
        }

        \
clean_post_cache$post_id );
        
// phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- To setup the post we need to do this explicitly.
        
$post = \get_post$post_id );

        if ( ! \
is_object$post ) ) {
            
// Non-existent post.
            
\wp_send_json_error'Post not found'400 );
        }

        \
do_action'wpseo_save_compare_data'$post );

        
// Initialize meta, amongst other things it registers sanitization.
        
WPSEO_Meta::init();

        
$social_fields = [];
        if ( 
$this->social_is_enabled ) {
            
$social_fields WPSEO_Meta::get_meta_field_defs'social'$post->post_type );
        }

        
// The below methods use the global post so make sure it is setup.
        
\setup_postdata$post );
        
$meta_boxes = \apply_filters'wpseo_save_metaboxes', [] );
        
$meta_boxes = \array_merge(
            
$meta_boxes,
            
WPSEO_Meta::get_meta_field_defs'general'$post->post_type ),
            
WPSEO_Meta::get_meta_field_defs'advanced'$post->post_type ),
            
$social_fields,
            
WPSEO_Meta::get_meta_field_defs'schema'$post->post_type )
        );

        foreach ( 
$meta_boxes as $key => $meta_box ) {
            
// If analysis is disabled remove that analysis score value from the DB.
            
if ( $this->is_meta_value_disabled$key ) ) {
                
WPSEO_Meta::delete$key$post_id );
                continue;
            }

            
$data       null;
            
$field_name WPSEO_Meta::$form_prefix $key;

            if ( 
$meta_box['type'] === 'checkbox' ) {
                
$data = isset( $_POST$field_name ] ) ? 'on' 'off';
            }
            else {
                if ( isset( 
$_POST$field_name ] ) ) {
                    
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: Sanitized through sanitize_post_meta.
                    
$data = \wp_unslash$_POST$field_name ] );

                    
// For multi-select.
                    
if ( \is_array$data ) ) {
                        
$data = \array_map( [ 'WPSEO_Utils''sanitize_text_field' ], $data );
                    }

                    if ( \
is_string$data ) ) {
                        
$data = ( $key !== 'canonical' ) ? WPSEO_Utils::sanitize_text_field$data ) : WPSEO_Utils::sanitize_url$data );
                    }
                }

                
// Reset options when no entry is present with multiselect - only applies to `meta-robots-adv` currently.
                
if ( ! isset( $_POST$field_name ] ) && ( $meta_box['type'] === 'multiselect' ) ) {
                    
$data = [];
                }
            }

            if ( 
$data !== null ) {
                
WPSEO_Meta::set_value$key$data$post_id );
            }
        }

        
// Saving the WP post to save the slug.
        
$slug = \filter_inputINPUT_POSTWPSEO_Meta::$form_prefix 'slug'FILTER_SANITIZE_STRING );
        if ( 
$post->post_name !== $slug ) {
            
$post_array              $post->to_array();
            
$post_array['post_name'] = $slug;

            
$save_successful = \wp_insert_post$post_array );
            if ( \
is_wp_error$save_successful ) ) {
                \
wp_send_json_error'Slug not saved'400 );
            }

            
// Update the post object to ensure we have the actual slug.
            // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- Updating the post is needed to get the current slug.
            
$post = \get_post$post_id );
            if ( ! \
is_object$post ) ) {
                \
wp_send_json_error'Updated slug not found'400 );
            }
        }

        \
do_action'wpseo_saved_postdata' );

        
// Output the slug, because it is processed by WP and we need the actual slug again.
        
\wp_send_json_success( [ 'slug' => $post->post_name ] );
    }

    
/**
     * Determines if the given meta value key is disabled.
     *
     * @param string $key The key of the meta value.
     *
     * @return bool Whether the given meta value key is disabled.
     */
    
public function is_meta_value_disabled$key ) {
        if ( 
$key === 'linkdex' && ! $this->seo_analysis->is_enabled() ) {
            return 
true;
        }

        if ( 
$key === 'content_score' && ! $this->readability_analysis->is_enabled() ) {
            return 
true;
        }

        return 
false;
    }

    
/**
     * Enqueues all the needed JS and CSS.
     *
     * @return void
     */
    
public function enqueue() {
        
$post_id = \get_queried_object_id();
        if ( empty( 
$post_id ) ) {
            
$post_id = \sanitize_text_field( \filter_inputINPUT_GET'post' ) );
        }

        if ( 
$post_id !== ) {
            
// Enqueue files needed for upload functionality.
            
\wp_enqueue_media( [ 'post' => $post_id ] );
        }

        
$this->asset_manager->enqueue_style'admin-global' );
        
$this->asset_manager->enqueue_style'metabox-css' );
        
$this->asset_manager->enqueue_style'scoring' );
        
$this->asset_manager->enqueue_style'select2' );
        
$this->asset_manager->enqueue_style'monorepo' );
        
$this->asset_manager->enqueue_style'admin-css' );
        
$this->asset_manager->enqueue_style'elementor' );

        
$this->asset_manager->enqueue_script'elementor' );

        
$yoast_components_l10n = new WPSEO_Admin_Asset_Yoast_Components_L10n();
        
$yoast_components_l10n->localize_script'elementor' );

        
$this->asset_manager->localize_script'elementor''wpseoAdminL10n'WPSEO_Utils::get_admin_l10n() );
        
$this->asset_manager->localize_script'elementor''wpseoFeaturesL10n'WPSEO_Utils::retrieve_enabled_features() );

        
$analysis_worker_location          = new WPSEO_Admin_Asset_Analysis_Worker_Location$this->asset_manager->flatten_versionWPSEO_VERSION ) );
        
$used_keywords_assessment_location = new WPSEO_Admin_Asset_Analysis_Worker_Location$this->asset_manager->flatten_versionWPSEO_VERSION ), 'used-keywords-assessment' );

        
$plugins_script_data = [
            
'replaceVars' => [
                
'no_parent_text'           => __'(no parent)''wordpress-seo' ),
                
'replace_vars'             => $this->get_replace_vars(),
                
'recommended_replace_vars' => $this->get_recommended_replace_vars(),
                
'scope'                    => $this->determine_scope(),
                
'has_taxonomies'           => $this->current_post_type_has_taxonomies(),
            ],
            
'shortcodes'  => [
                
'wpseo_filter_shortcodes_nonce' => \wp_create_nonce'wpseo-filter-shortcodes' ),
                
'wpseo_shortcode_tags'          => $this->get_valid_shortcode_tags(),
            ],
        ];

        
$worker_script_data = [
            
'url'                     => $analysis_worker_location->get_url$analysis_worker_location->get_asset(), WPSEO_Admin_Asset::TYPE_JS ),
            
'keywords_assessment_url' => $used_keywords_assessment_location->get_url$used_keywords_assessment_location->get_asset(), WPSEO_Admin_Asset::TYPE_JS ),
            
'log_level'               => WPSEO_Utils::get_analysis_worker_log_level(),
            
// We need to make the feature flags separately available inside of the analysis web worker.
            
'enabled_features'        => WPSEO_Utils::retrieve_enabled_features(),
        ];

        
$script_data = [
            
'media'             => [ 'choose_image' => __'Use Image''wordpress-seo' ) ],
            
'metabox'           => $this->get_metabox_script_data(),
            
'userLanguageCode'  => WPSEO_Language_Utils::get_language( \get_user_locale() ),
            
'isPost'            => true,
            
'isBlockEditor'     => WP_Screen::get()->is_block_editor(),
            
'isElementorEditor' => true,
            
'analysis'          => [
                
'plugins'                     => $plugins_script_data,
                
'worker'                      => $worker_script_data,
                
'estimatedReadingTimeEnabled' => $this->estimated_reading_time_conditional->is_met(),
            ],
        ];

        if ( \
post_type_supports$this->get_metabox_post()->post_type'thumbnail' ) ) {
            
$this->asset_manager->enqueue_style'featured-image' );

            
$script_data['featuredImage'] = [
                
'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' ),
            ];
        }

        
$this->asset_manager->localize_script'elementor''wpseoScriptData'$script_data );
    }

    
/**
     * Renders the metabox hidden fields.
     *
     * @return void
     */
    
protected function render_hidden_fields() {
        
// Wrap in a form with an action and post_id for the submit.
        
printf(
            
'<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" />',
            \
esc_url( \admin_url'admin-ajax.php' ) ),
            \
esc_attr$this->get_metabox_post()->ID )
        );

        \
wp_nonce_field'wpseo_elementor_save''_wpseo_elementor_nonce' );
        
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: Meta_Fields_Presenter->present is considered safe.
        
echo new Meta_Fields_Presenter$this->get_metabox_post(), 'general' );

        if ( 
$this->is_advanced_metadata_enabled ) {
            
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: Meta_Fields_Presenter->present is considered safe.
            
echo new Meta_Fields_Presenter$this->get_metabox_post(), 'advanced' );
        }

        
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: Meta_Fields_Presenter->present is considered safe.
        
echo new Meta_Fields_Presenter$this->get_metabox_post(), 'schema'$this->get_metabox_post()->post_type );

        if ( 
$this->social_is_enabled ) {
            
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: Meta_Fields_Presenter->present is considered safe.
            
echo new Meta_Fields_Presenter$this->get_metabox_post(), 'social' );
        }

        
printf(
            
'<input type="hidden" id="%1$s" name="%1$s" value="%2$s" />',
            \
esc_attrWPSEO_Meta::$form_prefix 'slug' ),
            \
esc_attr$this->get_metabox_post()->post_name )
        );

        
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Output should be escaped in the filter.
        
echo apply_filters'wpseo_elementor_hidden_fields''' );

        echo 
'</form>';
    }

    
/**
     * Returns post in metabox context.
     *
     * @return WP_Post|null
     */
    
protected function get_metabox_post() {
        if ( 
$this->post !== null ) {
            return 
$this->post;
        }

        
$post = \filter_inputINPUT_GET'post' );
        if ( ! empty( 
$post ) ) {
            
$post_id = (int) WPSEO_Utils::validate_int$post );

            
$this->post = \get_post$post_id );

            return 
$this->post;
        }

        if ( isset( 
$GLOBALS['post'] ) ) {
            
$this->post $GLOBALS['post'];

            return 
$this->post;
        }

        return 
null;
    }

    
/**
     * Passes variables to js for use with the post-scraper.
     *
     * @return array
     */
    
protected function get_metabox_script_data() {
        
$permalink '';

        if ( \
is_object$this->get_metabox_post() ) ) {
            
$permalink = \get_sample_permalink$this->get_metabox_post()->ID );
            
$permalink $permalink[0];
        }

        
$post_formatter = new WPSEO_Metabox_Formatter(
            new 
WPSEO_Post_Metabox_Formatter$this->get_metabox_post(), [], $permalink )
        );

        
$values $post_formatter->get_values();

        
/** This filter is documented in admin/filters/class-cornerstone-filter.php. */
        
$post_types = \apply_filters'wpseo_cornerstone_post_types'YoastSEO()->helpers->post_type->get_accessible_post_types() );
        if ( 
$values['cornerstoneActive'] && ! \in_array$this->get_metabox_post()->post_type$post_typestrue ) ) {
            
$values['cornerstoneActive'] = false;
        }

        return 
$values;
    }

    
/**
     * Prepares the replace vars for localization.
     *
     * @return array Replace vars.
     */
    
protected function get_replace_vars() {
        
$cached_replacement_vars = [];

        
$vars_to_cache = [
            
'date',
            
'id',
            
'sitename',
            
'sitedesc',
            
'sep',
            
'page',
            
'currentyear',
            
'tag',
            
'category',
            
'primary_category',
            
'pt_single',
            
'pt_plural',
            
'modified',
            
'name',
            
'user_description',
            
'pagetotal',
            
'pagenumber',
        ];

        foreach ( 
$vars_to_cache as $var ) {
            
$cached_replacement_vars$var ] = \wpseo_replace_vars'%%' $var '%%'$this->get_metabox_post() );
        }

        
// Merge custom replace variables with the WordPress ones.
        
return \array_merge$cached_replacement_vars$this->get_custom_replace_vars$this->get_metabox_post() ) );
    }

    
/**
     * Prepares the recommended replace vars for localization.
     *
     * @return array Recommended replacement variables.
     */
    
protected function get_recommended_replace_vars() {
        
$recommended_replace_vars = new WPSEO_Admin_Recommended_Replace_Vars();

        
// What is recommended depends on the current context.
        
$post_type $recommended_replace_vars->determine_for_post$this->get_metabox_post() );

        return 
$recommended_replace_vars->get_recommended_replacevars_for$post_type );
    }

    
/**
     * Gets the custom replace variables for custom taxonomies and fields.
     *
     * @param WP_Post $post The post to check for custom taxonomies and fields.
     *
     * @return array Array containing all the replacement variables.
     */
    
protected function get_custom_replace_vars$post ) {
        return [
            
'custom_fields'     => $this->get_custom_fields_replace_vars$post ),
            
'custom_taxonomies' => $this->get_custom_taxonomies_replace_vars$post ),
        ];
    }

    
/**
     * Gets the custom replace variables for custom taxonomies.
     *
     * @param WP_Post $post The post to check for custom taxonomies.
     *
     * @return array Array containing all the replacement variables.
     */
    
protected function get_custom_taxonomies_replace_vars$post ) {
        
$taxonomies          = \get_object_taxonomies$post'objects' );
        
$custom_replace_vars = [];

        foreach ( 
$taxonomies as $taxonomy_name => $taxonomy ) {

            if ( 
is_string$taxonomy ) ) { // If attachment, see https://core.trac.wordpress.org/ticket/37368 .
                
$taxonomy_name $taxonomy;
                
$taxonomy      = \get_taxonomy$taxonomy_name );
            }

            if ( 
$taxonomy->_builtin && $taxonomy->public ) {
                continue;
            }

            
$custom_replace_vars$taxonomy_name ] = [
                
'name'        => $taxonomy->name,
                
'description' => $taxonomy->description,
            ];
        }

        return 
$custom_replace_vars;
    }

    
/**
     * Gets the custom replace variables for custom fields.
     *
     * @param WP_Post $post The post to check for custom fields.
     *
     * @return array Array containing all the replacement variables.
     */
    
protected function get_custom_fields_replace_vars$post ) {
        
$custom_replace_vars = [];

        
// If no post object is passed, return the empty custom_replace_vars array.
        
if ( ! \is_object$post ) ) {
            return 
$custom_replace_vars;
        }

        
$custom_fields = \get_post_custom$post->ID );

        foreach ( 
$custom_fields as $custom_field_name => $custom_field ) {
            
// Skip private custom fields.
            
if ( \substr$custom_field_name0) === '_' ) {
                continue;
            }

            
// Skip custom field values that are serialized.
            
if ( \is_serialized$custom_field[0] ) ) {
                continue;
            }

            
$custom_replace_vars$custom_field_name ] = $custom_field[0];
        }

        return 
$custom_replace_vars;
    }

    
/**
     * Determines the scope based on the post type.
     * This can be used by the replacevar plugin to determine if a replacement needs to be executed.
     *
     * @return string String describing the current scope.
     */
    
protected function determine_scope() {
        if ( 
$this->get_metabox_post()->post_type === 'page' ) {
            return 
'page';
        }

        return 
'post';
    }

    
/**
     * Determines whether or not the current post type has registered taxonomies.
     *
     * @return bool Whether the current post type has taxonomies.
     */
    
protected function current_post_type_has_taxonomies() {
        
$post_taxonomies = \get_object_taxonomies$this->get_metabox_post()->post_type );

        return ! empty( 
$post_taxonomies );
    }

    
/**
     * Returns an array with shortcode tags for all registered shortcodes.
     *
     * @return array
     */
    
protected function get_valid_shortcode_tags() {
        
$shortcode_tags = [];

        foreach ( 
$GLOBALS['shortcode_tags'] as $tag => $description ) {
            
$shortcode_tags[] = $tag;
        }

        return 
$shortcode_tags;
    }
}
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586