PluginProbe ʕ •ᴥ•ʔ
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 22.0
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v22.0
27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 19.1 19.10 19.11 19.12 19.13 19.14 19.2 19.3 19.4 19.5 19.5.1 19.6 19.6.1 19.7 19.7.1 19.7.2 19.8 19.9 20.0 20.1 20.10 20.11 20.12 20.13 20.2 20.2.1 20.3 20.4 20.5 20.6 20.7 20.8 20.9 21.0 21.1 21.2 21.3 21.4 21.5 21.6 21.7 21.8 21.8.1 21.9 21.9.1 22.0 22.1 22.2 22.3 22.4 22.5 22.6 22.7 22.8 22.9 23.0 23.1 23.2 23.3 23.4 23.5 23.6 23.7 23.8 23.9 24.0 24.1 24.2 24.3 24.4 24.5 24.6 24.7 24.8 24.8.1 24.9 25.0 25.1 25.2 25.3 25.3.1 25.4 25.5 25.6 25.7 25.8 25.9 26.0 26.1 26.1.1 26.2 26.3 26.4 26.5 26.6 26.7 26.8 26.9 27.0 27.1 27.1.1 27.2 27.3 27.4
wordpress-seo / admin / class-customizer.php
wordpress-seo / admin Last commit date
ajax 2 years ago capabilities 2 years ago endpoints 2 years ago exceptions 7 years ago filters 2 years ago formatter 2 years ago google_search_console 2 years ago import 2 years ago listeners 8 years ago menu 2 years ago metabox 2 years ago notifiers 3 years ago pages 2 years ago roles 2 years ago services 5 years ago statistics 2 years ago taxonomy 2 years ago tracking 2 years ago views 2 years ago watchers 2 years ago admin-settings-changed-listener.php 2 years ago ajax.php 2 years ago class-admin-asset-analysis-worker-location.php 5 years ago class-admin-asset-dev-server-location.php 2 years ago class-admin-asset-location.php 8 years ago class-admin-asset-manager.php 2 years ago class-admin-asset-seo-location.php 4 years ago class-admin-editor-specific-replace-vars.php 2 years ago class-admin-gutenberg-compatibility-notification.php 2 years ago class-admin-help-panel.php 5 years ago class-admin-init.php 2 years ago class-admin-recommended-replace-vars.php 2 years ago class-admin-user-profile.php 2 years ago class-admin-utils.php 2 years ago class-admin.php 2 years ago class-asset.php 2 years ago class-bulk-description-editor-list-table.php 5 years ago class-bulk-editor-list-table.php 2 years ago class-bulk-title-editor-list-table.php 6 years ago class-collector.php 2 years ago class-config.php 2 years ago class-customizer.php 2 years ago class-database-proxy.php 2 years ago class-export.php 2 years ago class-expose-shortlinks.php 2 years ago class-gutenberg-compatibility.php 2 years ago class-meta-columns.php 2 years ago class-my-yoast-proxy.php 2 years ago class-option-tab.php 4 years ago class-option-tabs-formatter.php 2 years ago class-option-tabs.php 2 years ago class-paper-presenter.php 5 years ago class-plugin-availability.php 2 years ago class-plugin-conflict.php 2 years ago class-premium-popup.php 2 years ago class-premium-upsell-admin-block.php 2 years ago class-primary-term-admin.php 2 years ago class-product-upsell-notice.php 2 years ago class-remote-request.php 2 years ago class-schema-person-upgrade-notification.php 2 years ago class-suggested-plugins.php 2 years ago class-wincher-dashboard-widget.php 2 years ago class-yoast-columns.php 2 years ago class-yoast-dashboard-widget.php 2 years ago class-yoast-form.php 2 years ago class-yoast-input-validation.php 2 years ago class-yoast-network-admin.php 2 years ago class-yoast-network-settings-api.php 4 years ago class-yoast-notification-center.php 2 years ago class-yoast-notification.php 2 years ago class-yoast-notifications.php 2 years ago class-yoast-plugin-conflict.php 2 years ago index.php 10 years ago interface-collection.php 7 years ago interface-installable.php 8 years ago
class-customizer.php
250 lines
1 <?php
2 /**
3 * WPSEO plugin file.
4 *
5 * @package WPSEO\Admin\Customizer
6 */
7
8 /**
9 * Class with functionality to support WP SEO settings in WordPress Customizer.
10 */
11 class WPSEO_Customizer {
12
13 /**
14 * Holds the customize manager.
15 *
16 * @var WP_Customize_Manager
17 */
18 protected $wp_customize;
19
20 /**
21 * Template for the setting IDs used for the customizer.
22 *
23 * @var string
24 */
25 private $setting_template = 'wpseo_titles[%s]';
26
27 /**
28 * Default arguments for the breadcrumbs customizer settings object.
29 *
30 * @var array
31 */
32 private $default_setting_args = [
33 'default' => '',
34 'type' => 'option',
35 'transport' => 'refresh',
36 ];
37
38 /**
39 * Default arguments for the breadcrumbs customizer control object.
40 *
41 * @var array
42 */
43 private $default_control_args = [
44 'label' => '',
45 'type' => 'text',
46 'section' => 'wpseo_breadcrumbs_customizer_section',
47 'settings' => '',
48 'context' => '',
49 ];
50
51 /**
52 * Construct Method.
53 */
54 public function __construct() {
55 add_action( 'customize_register', [ $this, 'wpseo_customize_register' ] );
56 }
57
58 /**
59 * Function to support WordPress Customizer.
60 *
61 * @param WP_Customize_Manager $wp_customize Manager class instance.
62 *
63 * @return void
64 */
65 public function wpseo_customize_register( $wp_customize ) {
66 if ( ! WPSEO_Capability_Utils::current_user_can( 'wpseo_manage_options' ) ) {
67 return;
68 }
69
70 $this->wp_customize = $wp_customize;
71
72 $this->breadcrumbs_section();
73 $this->breadcrumbs_blog_show_setting();
74 $this->breadcrumbs_separator_setting();
75 $this->breadcrumbs_home_setting();
76 $this->breadcrumbs_prefix_setting();
77 $this->breadcrumbs_archiveprefix_setting();
78 $this->breadcrumbs_searchprefix_setting();
79 $this->breadcrumbs_404_setting();
80 }
81
82 /**
83 * Add the breadcrumbs section to the customizer.
84 *
85 * @return void
86 */
87 private function breadcrumbs_section() {
88 $section_args = [
89 /* translators: %s is the name of the plugin */
90 'title' => sprintf( __( '%s Breadcrumbs', 'wordpress-seo' ), 'Yoast SEO' ),
91 'priority' => 999,
92 'active_callback' => [ $this, 'breadcrumbs_active_callback' ],
93 ];
94
95 $this->wp_customize->add_section( 'wpseo_breadcrumbs_customizer_section', $section_args );
96 }
97
98 /**
99 * Returns whether or not the breadcrumbs are active.
100 *
101 * @return bool
102 */
103 public function breadcrumbs_active_callback() {
104 return current_theme_supports( 'yoast-seo-breadcrumbs' ) || WPSEO_Options::get( 'breadcrumbs-enable' );
105 }
106
107 /**
108 * Adds the breadcrumbs show blog checkbox.
109 *
110 * @return void
111 */
112 private function breadcrumbs_blog_show_setting() {
113 $index = 'breadcrumbs-display-blog-page';
114 $control_args = [
115 'label' => __( 'Show blog page in breadcrumbs', 'wordpress-seo' ),
116 'type' => 'checkbox',
117 'active_callback' => [ $this, 'breadcrumbs_blog_show_active_cb' ],
118 ];
119
120 $this->add_setting_and_control( $index, $control_args );
121 }
122
123 /**
124 * Returns whether or not to show the breadcrumbs blog show option.
125 *
126 * @return bool
127 */
128 public function breadcrumbs_blog_show_active_cb() {
129 return get_option( 'show_on_front' ) === 'page';
130 }
131
132 /**
133 * Adds the breadcrumbs separator text field.
134 *
135 * @return void
136 */
137 private function breadcrumbs_separator_setting() {
138 $index = 'breadcrumbs-sep';
139 $control_args = [
140 'label' => __( 'Breadcrumbs separator:', 'wordpress-seo' ),
141 ];
142 $id = 'wpseo-breadcrumbs-separator';
143
144 $this->add_setting_and_control( $index, $control_args, $id );
145 }
146
147 /**
148 * Adds the breadcrumbs home anchor text field.
149 *
150 * @return void
151 */
152 private function breadcrumbs_home_setting() {
153 $index = 'breadcrumbs-home';
154 $control_args = [
155 'label' => __( 'Anchor text for the homepage:', 'wordpress-seo' ),
156 ];
157
158 $this->add_setting_and_control( $index, $control_args );
159 }
160
161 /**
162 * Adds the breadcrumbs prefix text field.
163 *
164 * @return void
165 */
166 private function breadcrumbs_prefix_setting() {
167 $index = 'breadcrumbs-prefix';
168 $control_args = [
169 'label' => __( 'Prefix for breadcrumbs:', 'wordpress-seo' ),
170 ];
171
172 $this->add_setting_and_control( $index, $control_args );
173 }
174
175 /**
176 * Adds the breadcrumbs archive prefix text field.
177 *
178 * @return void
179 */
180 private function breadcrumbs_archiveprefix_setting() {
181 $index = 'breadcrumbs-archiveprefix';
182 $control_args = [
183 'label' => __( 'Prefix for archive pages:', 'wordpress-seo' ),
184 ];
185
186 $this->add_setting_and_control( $index, $control_args );
187 }
188
189 /**
190 * Adds the breadcrumbs search prefix text field.
191 *
192 * @return void
193 */
194 private function breadcrumbs_searchprefix_setting() {
195 $index = 'breadcrumbs-searchprefix';
196 $control_args = [
197 'label' => __( 'Prefix for search result pages:', 'wordpress-seo' ),
198 ];
199
200 $this->add_setting_and_control( $index, $control_args );
201 }
202
203 /**
204 * Adds the breadcrumb 404 prefix text field.
205 *
206 * @return void
207 */
208 private function breadcrumbs_404_setting() {
209 $index = 'breadcrumbs-404crumb';
210 $control_args = [
211 'label' => __( 'Breadcrumb for 404 pages:', 'wordpress-seo' ),
212 ];
213
214 $this->add_setting_and_control( $index, $control_args );
215 }
216
217 /**
218 * Adds the customizer setting and control.
219 *
220 * @param string $index Array key index to use for the customizer setting.
221 * @param array $control_args Customizer control object arguments.
222 * Only those different from the default need to be passed.
223 * @param string|null $id Optional. Customizer control object ID.
224 * Will default to 'wpseo-' . $index.
225 * @param array $custom_settings Optional. Customizer setting arguments.
226 * Only those different from the default need to be passed.
227 *
228 * @return void
229 */
230 private function add_setting_and_control( $index, $control_args, $id = null, $custom_settings = [] ) {
231 $setting = sprintf( $this->setting_template, $index );
232 $control_args = array_merge( $this->default_control_args, $control_args );
233 $control_args['settings'] = $setting;
234
235 $settings_args = $this->default_setting_args;
236 if ( ! empty( $custom_settings ) ) {
237 $settings_args = array_merge( $settings_args, $custom_settings );
238 }
239
240 if ( ! isset( $id ) ) {
241 $id = 'wpseo-' . $index;
242 }
243
244 $this->wp_customize->add_setting( $setting, $settings_args );
245
246 $control = new WP_Customize_Control( $this->wp_customize, $id, $control_args );
247 $this->wp_customize->add_control( $control );
248 }
249 }
250