Edit File by line
/home/barbar84/www/wp-conte.../plugins/wordpres.../admin
File: class-customizer.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* WPSEO plugin file.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WPSEO\Admin\Customizer
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* Class with functionality to support WP SEO settings in WordPress Customizer.
[8] Fix | Delete
*/
[9] Fix | Delete
class WPSEO_Customizer {
[10] Fix | Delete
[11] Fix | Delete
/**
[12] Fix | Delete
* Holds the customize manager.
[13] Fix | Delete
*
[14] Fix | Delete
* @var WP_Customize_Manager
[15] Fix | Delete
*/
[16] Fix | Delete
protected $wp_customize;
[17] Fix | Delete
[18] Fix | Delete
/**
[19] Fix | Delete
* Template for the setting IDs used for the customizer.
[20] Fix | Delete
*
[21] Fix | Delete
* @var string
[22] Fix | Delete
*/
[23] Fix | Delete
private $setting_template = 'wpseo_titles[%s]';
[24] Fix | Delete
[25] Fix | Delete
/**
[26] Fix | Delete
* Default arguments for the breadcrumbs customizer settings object.
[27] Fix | Delete
*
[28] Fix | Delete
* @var array
[29] Fix | Delete
*/
[30] Fix | Delete
private $default_setting_args = [
[31] Fix | Delete
'default' => '',
[32] Fix | Delete
'type' => 'option',
[33] Fix | Delete
'transport' => 'refresh',
[34] Fix | Delete
];
[35] Fix | Delete
[36] Fix | Delete
/**
[37] Fix | Delete
* Default arguments for the breadcrumbs customizer control object.
[38] Fix | Delete
*
[39] Fix | Delete
* @var array
[40] Fix | Delete
*/
[41] Fix | Delete
private $default_control_args = [
[42] Fix | Delete
'label' => '',
[43] Fix | Delete
'type' => 'text',
[44] Fix | Delete
'section' => 'wpseo_breadcrumbs_customizer_section',
[45] Fix | Delete
'settings' => '',
[46] Fix | Delete
'context' => '',
[47] Fix | Delete
];
[48] Fix | Delete
[49] Fix | Delete
/**
[50] Fix | Delete
* Construct Method.
[51] Fix | Delete
*/
[52] Fix | Delete
public function __construct() {
[53] Fix | Delete
add_action( 'customize_register', [ $this, 'wpseo_customize_register' ] );
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
/**
[57] Fix | Delete
* Function to support WordPress Customizer.
[58] Fix | Delete
*
[59] Fix | Delete
* @param WP_Customize_Manager $wp_customize Manager class instance.
[60] Fix | Delete
*/
[61] Fix | Delete
public function wpseo_customize_register( $wp_customize ) {
[62] Fix | Delete
if ( ! WPSEO_Capability_Utils::current_user_can( 'wpseo_manage_options' ) ) {
[63] Fix | Delete
return;
[64] Fix | Delete
}
[65] Fix | Delete
[66] Fix | Delete
$this->wp_customize = $wp_customize;
[67] Fix | Delete
[68] Fix | Delete
$this->breadcrumbs_section();
[69] Fix | Delete
$this->breadcrumbs_blog_show_setting();
[70] Fix | Delete
$this->breadcrumbs_separator_setting();
[71] Fix | Delete
$this->breadcrumbs_home_setting();
[72] Fix | Delete
$this->breadcrumbs_prefix_setting();
[73] Fix | Delete
$this->breadcrumbs_archiveprefix_setting();
[74] Fix | Delete
$this->breadcrumbs_searchprefix_setting();
[75] Fix | Delete
$this->breadcrumbs_404_setting();
[76] Fix | Delete
}
[77] Fix | Delete
[78] Fix | Delete
/**
[79] Fix | Delete
* Add the breadcrumbs section to the customizer.
[80] Fix | Delete
*/
[81] Fix | Delete
private function breadcrumbs_section() {
[82] Fix | Delete
$section_args = [
[83] Fix | Delete
/* translators: %s is the name of the plugin */
[84] Fix | Delete
'title' => sprintf( __( '%s Breadcrumbs', 'wordpress-seo' ), 'Yoast SEO' ),
[85] Fix | Delete
'priority' => 999,
[86] Fix | Delete
'active_callback' => [ $this, 'breadcrumbs_active_callback' ],
[87] Fix | Delete
];
[88] Fix | Delete
[89] Fix | Delete
$this->wp_customize->add_section( 'wpseo_breadcrumbs_customizer_section', $section_args );
[90] Fix | Delete
}
[91] Fix | Delete
[92] Fix | Delete
/**
[93] Fix | Delete
* Returns whether or not the breadcrumbs are active.
[94] Fix | Delete
*
[95] Fix | Delete
* @return bool
[96] Fix | Delete
*/
[97] Fix | Delete
public function breadcrumbs_active_callback() {
[98] Fix | Delete
return current_theme_supports( 'yoast-seo-breadcrumbs' ) || WPSEO_Options::get( 'breadcrumbs-enable' );
[99] Fix | Delete
}
[100] Fix | Delete
[101] Fix | Delete
/**
[102] Fix | Delete
* Adds the breadcrumbs show blog checkbox.
[103] Fix | Delete
*/
[104] Fix | Delete
private function breadcrumbs_blog_show_setting() {
[105] Fix | Delete
$index = 'breadcrumbs-display-blog-page';
[106] Fix | Delete
$control_args = [
[107] Fix | Delete
'label' => __( 'Show blog page in breadcrumbs', 'wordpress-seo' ),
[108] Fix | Delete
'type' => 'checkbox',
[109] Fix | Delete
'active_callback' => [ $this, 'breadcrumbs_blog_show_active_cb' ],
[110] Fix | Delete
];
[111] Fix | Delete
[112] Fix | Delete
$this->add_setting_and_control( $index, $control_args );
[113] Fix | Delete
}
[114] Fix | Delete
[115] Fix | Delete
/**
[116] Fix | Delete
* Returns whether or not to show the breadcrumbs blog show option.
[117] Fix | Delete
*
[118] Fix | Delete
* @return bool
[119] Fix | Delete
*/
[120] Fix | Delete
public function breadcrumbs_blog_show_active_cb() {
[121] Fix | Delete
return get_option( 'show_on_front' ) === 'page';
[122] Fix | Delete
}
[123] Fix | Delete
[124] Fix | Delete
/**
[125] Fix | Delete
* Adds the breadcrumbs separator text field.
[126] Fix | Delete
*/
[127] Fix | Delete
private function breadcrumbs_separator_setting() {
[128] Fix | Delete
$index = 'breadcrumbs-sep';
[129] Fix | Delete
$control_args = [
[130] Fix | Delete
'label' => __( 'Breadcrumbs separator:', 'wordpress-seo' ),
[131] Fix | Delete
];
[132] Fix | Delete
$id = 'wpseo-breadcrumbs-separator';
[133] Fix | Delete
[134] Fix | Delete
$this->add_setting_and_control( $index, $control_args, $id );
[135] Fix | Delete
}
[136] Fix | Delete
[137] Fix | Delete
/**
[138] Fix | Delete
* Adds the breadcrumbs home anchor text field.
[139] Fix | Delete
*/
[140] Fix | Delete
private function breadcrumbs_home_setting() {
[141] Fix | Delete
$index = 'breadcrumbs-home';
[142] Fix | Delete
$control_args = [
[143] Fix | Delete
'label' => __( 'Anchor text for the homepage:', 'wordpress-seo' ),
[144] Fix | Delete
];
[145] Fix | Delete
[146] Fix | Delete
$this->add_setting_and_control( $index, $control_args );
[147] Fix | Delete
}
[148] Fix | Delete
[149] Fix | Delete
/**
[150] Fix | Delete
* Adds the breadcrumbs prefix text field.
[151] Fix | Delete
*/
[152] Fix | Delete
private function breadcrumbs_prefix_setting() {
[153] Fix | Delete
$index = 'breadcrumbs-prefix';
[154] Fix | Delete
$control_args = [
[155] Fix | Delete
'label' => __( 'Prefix for breadcrumbs:', 'wordpress-seo' ),
[156] Fix | Delete
];
[157] Fix | Delete
[158] Fix | Delete
$this->add_setting_and_control( $index, $control_args );
[159] Fix | Delete
}
[160] Fix | Delete
[161] Fix | Delete
/**
[162] Fix | Delete
* Adds the breadcrumbs archive prefix text field.
[163] Fix | Delete
*/
[164] Fix | Delete
private function breadcrumbs_archiveprefix_setting() {
[165] Fix | Delete
$index = 'breadcrumbs-archiveprefix';
[166] Fix | Delete
$control_args = [
[167] Fix | Delete
'label' => __( 'Prefix for archive pages:', 'wordpress-seo' ),
[168] Fix | Delete
];
[169] Fix | Delete
[170] Fix | Delete
$this->add_setting_and_control( $index, $control_args );
[171] Fix | Delete
}
[172] Fix | Delete
[173] Fix | Delete
/**
[174] Fix | Delete
* Adds the breadcrumbs search prefix text field.
[175] Fix | Delete
*/
[176] Fix | Delete
private function breadcrumbs_searchprefix_setting() {
[177] Fix | Delete
$index = 'breadcrumbs-searchprefix';
[178] Fix | Delete
$control_args = [
[179] Fix | Delete
'label' => __( 'Prefix for search result pages:', 'wordpress-seo' ),
[180] Fix | Delete
];
[181] Fix | Delete
[182] Fix | Delete
$this->add_setting_and_control( $index, $control_args );
[183] Fix | Delete
}
[184] Fix | Delete
[185] Fix | Delete
/**
[186] Fix | Delete
* Adds the breadcrumb 404 prefix text field.
[187] Fix | Delete
*/
[188] Fix | Delete
private function breadcrumbs_404_setting() {
[189] Fix | Delete
$index = 'breadcrumbs-404crumb';
[190] Fix | Delete
$control_args = [
[191] Fix | Delete
'label' => __( 'Breadcrumb for 404 pages:', 'wordpress-seo' ),
[192] Fix | Delete
];
[193] Fix | Delete
[194] Fix | Delete
$this->add_setting_and_control( $index, $control_args );
[195] Fix | Delete
}
[196] Fix | Delete
[197] Fix | Delete
/**
[198] Fix | Delete
* Adds the customizer setting and control.
[199] Fix | Delete
*
[200] Fix | Delete
* @param string $index Array key index to use for the customizer setting.
[201] Fix | Delete
* @param array $control_args Customizer control object arguments.
[202] Fix | Delete
* Only those different from the default need to be passed.
[203] Fix | Delete
* @param string|null $id Optional. Customizer control object ID.
[204] Fix | Delete
* Will default to 'wpseo-' . $index.
[205] Fix | Delete
* @param array $custom_settings Optional. Customizer setting arguments.
[206] Fix | Delete
* Only those different from the default need to be passed.
[207] Fix | Delete
*/
[208] Fix | Delete
private function add_setting_and_control( $index, $control_args, $id = null, $custom_settings = [] ) {
[209] Fix | Delete
$setting = sprintf( $this->setting_template, $index );
[210] Fix | Delete
$control_args = array_merge( $this->default_control_args, $control_args );
[211] Fix | Delete
$control_args['settings'] = $setting;
[212] Fix | Delete
[213] Fix | Delete
$settings_args = $this->default_setting_args;
[214] Fix | Delete
if ( ! empty( $custom_settings ) ) {
[215] Fix | Delete
$settings_args = array_merge( $settings_args, $custom_settings );
[216] Fix | Delete
}
[217] Fix | Delete
[218] Fix | Delete
if ( ! isset( $id ) ) {
[219] Fix | Delete
$id = 'wpseo-' . $index;
[220] Fix | Delete
}
[221] Fix | Delete
[222] Fix | Delete
$this->wp_customize->add_setting( $setting, $settings_args );
[223] Fix | Delete
[224] Fix | Delete
$control = new WP_Customize_Control( $this->wp_customize, $id, $control_args );
[225] Fix | Delete
$this->wp_customize->add_control( $control );
[226] Fix | Delete
}
[227] Fix | Delete
}
[228] Fix | Delete
[229] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function