@@ -7,6 +7,6 @@ |
||
7 | 7 | exit(1); |
8 | 8 | } |
9 | 9 | |
10 | -require_once __DIR__ . '/composer/autoload_real.php'; |
|
10 | +require_once __DIR__.'/composer/autoload_real.php'; |
|
11 | 11 | |
12 | 12 | return ComposerAutoloaderInitce8393fe837d1222bf35cfeea65d9876::getLoader(); |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | 'version' => 'dev-develop', |
6 | 6 | 'reference' => '4318cca4abfea06968be19ff0dd526bab3e1d8c4', |
7 | 7 | 'type' => 'wordpress-plugin', |
8 | - 'install_path' => __DIR__ . '/../../', |
|
8 | + 'install_path' => __DIR__.'/../../', |
|
9 | 9 | 'aliases' => array(), |
10 | 10 | 'dev' => true, |
11 | 11 | ), |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | 'version' => 'dev-develop', |
16 | 16 | 'reference' => '4318cca4abfea06968be19ff0dd526bab3e1d8c4', |
17 | 17 | 'type' => 'wordpress-plugin', |
18 | - 'install_path' => __DIR__ . '/../../', |
|
18 | + 'install_path' => __DIR__.'/../../', |
|
19 | 19 | 'aliases' => array(), |
20 | 20 | 'dev_requirement' => false, |
21 | 21 | ), |
@@ -6,27 +6,27 @@ |
||
6 | 6 | |
7 | 7 | class ComposerStaticInitce8393fe837d1222bf35cfeea65d9876 |
8 | 8 | { |
9 | - public static $prefixLengthsPsr4 = array ( |
|
9 | + public static $prefixLengthsPsr4 = array( |
|
10 | 10 | 'W' => |
11 | - array ( |
|
11 | + array( |
|
12 | 12 | 'Wordlift\\Modules\\Include_Exclude\\' => 33, |
13 | 13 | ), |
14 | 14 | ); |
15 | 15 | |
16 | - public static $prefixDirsPsr4 = array ( |
|
16 | + public static $prefixDirsPsr4 = array( |
|
17 | 17 | 'Wordlift\\Modules\\Include_Exclude\\' => |
18 | - array ( |
|
19 | - 0 => __DIR__ . '/../..' . '/includes', |
|
18 | + array( |
|
19 | + 0 => __DIR__.'/../..'.'/includes', |
|
20 | 20 | ), |
21 | 21 | ); |
22 | 22 | |
23 | - public static $classMap = array ( |
|
24 | - 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', |
|
23 | + public static $classMap = array( |
|
24 | + 'Composer\\InstalledVersions' => __DIR__.'/..'.'/composer/InstalledVersions.php', |
|
25 | 25 | ); |
26 | 26 | |
27 | 27 | public static function getInitializer(ClassLoader $loader) |
28 | 28 | { |
29 | - return \Closure::bind(function () use ($loader) { |
|
29 | + return \Closure::bind(function() use ($loader) { |
|
30 | 30 | $loader->prefixLengthsPsr4 = ComposerStaticInitce8393fe837d1222bf35cfeea65d9876::$prefixLengthsPsr4; |
31 | 31 | $loader->prefixDirsPsr4 = ComposerStaticInitce8393fe837d1222bf35cfeea65d9876::$prefixDirsPsr4; |
32 | 32 | $loader->classMap = ComposerStaticInitce8393fe837d1222bf35cfeea65d9876::$classMap; |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | public static function loadClassLoader($class) |
10 | 10 | { |
11 | 11 | if ('Composer\Autoload\ClassLoader' === $class) { |
12 | - require __DIR__ . '/ClassLoader.php'; |
|
12 | + require __DIR__.'/ClassLoader.php'; |
|
13 | 13 | } |
14 | 14 | } |
15 | 15 | |
@@ -22,13 +22,13 @@ discard block |
||
22 | 22 | return self::$loader; |
23 | 23 | } |
24 | 24 | |
25 | - require __DIR__ . '/platform_check.php'; |
|
25 | + require __DIR__.'/platform_check.php'; |
|
26 | 26 | |
27 | 27 | spl_autoload_register(array('ComposerAutoloaderInitce8393fe837d1222bf35cfeea65d9876', 'loadClassLoader'), true, true); |
28 | 28 | self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); |
29 | 29 | spl_autoload_unregister(array('ComposerAutoloaderInitce8393fe837d1222bf35cfeea65d9876', 'loadClassLoader')); |
30 | 30 | |
31 | - require __DIR__ . '/autoload_static.php'; |
|
31 | + require __DIR__.'/autoload_static.php'; |
|
32 | 32 | call_user_func(\Composer\Autoload\ComposerStaticInitce8393fe837d1222bf35cfeea65d9876::getInitializer($loader)); |
33 | 33 | |
34 | 34 | $loader->register(true); |
@@ -1,12 +1,12 @@ |
||
1 | 1 | <p> |
2 | 2 | <label for="wl_exclude_include_urls_settings_urls"> |
3 | 3 | <?php |
4 | - echo sprintf( |
|
5 | - '%s <code>%s</code>', |
|
6 | - esc_html__( 'One relative or absolute URL per line. Relative URLs will be converted to absolute in context of', 'wordlift' ), |
|
7 | - esc_url( site_url() ) |
|
8 | - ); |
|
9 | - ?> |
|
4 | + echo sprintf( |
|
5 | + '%s <code>%s</code>', |
|
6 | + esc_html__( 'One relative or absolute URL per line. Relative URLs will be converted to absolute in context of', 'wordlift' ), |
|
7 | + esc_url( site_url() ) |
|
8 | + ); |
|
9 | + ?> |
|
10 | 10 | </label> |
11 | 11 | </p> |
12 | 12 | <p> |
@@ -3,8 +3,8 @@ discard block |
||
3 | 3 | <?php |
4 | 4 | echo sprintf( |
5 | 5 | '%s <code>%s</code>', |
6 | - esc_html__( 'One relative or absolute URL per line. Relative URLs will be converted to absolute in context of', 'wordlift' ), |
|
7 | - esc_url( site_url() ) |
|
6 | + esc_html__('One relative or absolute URL per line. Relative URLs will be converted to absolute in context of', 'wordlift'), |
|
7 | + esc_url(site_url()) |
|
8 | 8 | ); |
9 | 9 | ?> |
10 | 10 | </label> |
@@ -12,5 +12,5 @@ discard block |
||
12 | 12 | <p> |
13 | 13 | <textarea id="wl_exclude_include_urls_settings_urls" name='wl_exclude_include_urls_settings[urls]' |
14 | 14 | class="large-text code" |
15 | - rows="10"><?php echo esc_textarea( isset( $options['urls'] ) ? $options['urls'] : '' ); // phpcs:ignore ?></textarea> |
|
15 | + rows="10"><?php echo esc_textarea(isset($options['urls']) ? $options['urls'] : ''); // phpcs:ignore ?></textarea> |
|
16 | 16 | </p> |
@@ -2,9 +2,9 @@ |
||
2 | 2 | <h2><?php echo esc_html__( 'Exclude / Include URLs', 'wordlift' ); ?></h2> |
3 | 3 | <form action='options.php' method='post'> |
4 | 4 | <?php |
5 | - settings_fields( 'wl_exclude_include_urls_settings_group' ); |
|
6 | - do_settings_sections( 'wl_exclude_include_urls_settings_page' ); |
|
7 | - submit_button(); |
|
8 | - ?> |
|
5 | + settings_fields( 'wl_exclude_include_urls_settings_group' ); |
|
6 | + do_settings_sections( 'wl_exclude_include_urls_settings_page' ); |
|
7 | + submit_button(); |
|
8 | + ?> |
|
9 | 9 | </form> |
10 | 10 | </div> |
@@ -1,9 +1,9 @@ |
||
1 | 1 | <div class="wrap" id="wl-settings-page"> |
2 | - <h2><?php echo esc_html__( 'Exclude / Include URLs', 'wordlift' ); ?></h2> |
|
2 | + <h2><?php echo esc_html__('Exclude / Include URLs', 'wordlift'); ?></h2> |
|
3 | 3 | <form action='options.php' method='post'> |
4 | 4 | <?php |
5 | - settings_fields( 'wl_exclude_include_urls_settings_group' ); |
|
6 | - do_settings_sections( 'wl_exclude_include_urls_settings_page' ); |
|
5 | + settings_fields('wl_exclude_include_urls_settings_group'); |
|
6 | + do_settings_sections('wl_exclude_include_urls_settings_page'); |
|
7 | 7 | submit_button(); |
8 | 8 | ?> |
9 | 9 | </form> |
@@ -18,392 +18,392 @@ |
||
18 | 18 | */ |
19 | 19 | class Wordlift_Admin_Settings_Page extends Wordlift_Admin_Page { |
20 | 20 | |
21 | - /** |
|
22 | - * A {@link Wordlift_Entity_Service} instance. |
|
23 | - * |
|
24 | - * @since 3.11.0 |
|
25 | - * @access private |
|
26 | - * @var \Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance. |
|
27 | - */ |
|
28 | - private $entity_service; |
|
29 | - |
|
30 | - /** |
|
31 | - * A {@link Wordlift_Admin_Input_Element} element renderer. |
|
32 | - * |
|
33 | - * @since 3.11.0 |
|
34 | - * @access private |
|
35 | - * @var \Wordlift_Admin_Input_Element $input_element An {@link Wordlift_Admin_Input_Element} element renderer. |
|
36 | - */ |
|
37 | - private $input_element; |
|
38 | - |
|
39 | - /** |
|
40 | - * A {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
41 | - * |
|
42 | - * @since 3.13.0 |
|
43 | - * @access protected |
|
44 | - * @var \Wordlift_Admin_Radio_Input_Element $radio_input_element A {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
45 | - */ |
|
46 | - private $radio_input_element; |
|
47 | - |
|
48 | - /** |
|
49 | - * A {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
50 | - * |
|
51 | - * @since 3.11.0 |
|
52 | - * @access private |
|
53 | - * @var \Wordlift_Admin_Language_Select_Element $language_select_element A {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
54 | - */ |
|
55 | - private $language_select_element; |
|
56 | - |
|
57 | - /** |
|
58 | - * A {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
59 | - * |
|
60 | - * @since 3.18.0 |
|
61 | - * @access private |
|
62 | - * @var \Wordlift_Admin_Country_Select_Element $country_select_element A {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
63 | - */ |
|
64 | - private $country_select_element; |
|
65 | - |
|
66 | - /** |
|
67 | - * A {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
68 | - * |
|
69 | - * @since 3.11.0 |
|
70 | - * @access private |
|
71 | - * @var \Wordlift_Admin_Publisher_Element $publisher_element A {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
72 | - */ |
|
73 | - private $publisher_element; |
|
74 | - |
|
75 | - /** |
|
76 | - * Create a {@link Wordlift_Admin_Settings_Page} instance. |
|
77 | - * |
|
78 | - * @param \Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance. |
|
79 | - * @param \Wordlift_Admin_Input_Element $input_element A {@link Wordlift_Admin_Input_Element} element renderer. |
|
80 | - * @param \Wordlift_Admin_Language_Select_Element $language_select_element A {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
81 | - * @param \Wordlift_Admin_Country_Select_Element $country_select_element A {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
82 | - * @param \Wordlift_Admin_Publisher_Element $publisher_element A {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
83 | - * @param \Wordlift_Admin_Radio_Input_Element $radio_input_element A {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
84 | - * |
|
85 | - * @since 3.11.0 |
|
86 | - */ |
|
87 | - public function __construct( $entity_service, $input_element, $language_select_element, $country_select_element, $publisher_element, $radio_input_element ) { |
|
88 | - |
|
89 | - $this->entity_service = $entity_service; |
|
90 | - |
|
91 | - // Set a reference to the UI elements. |
|
92 | - $this->input_element = $input_element; |
|
93 | - $this->radio_input_element = $radio_input_element; |
|
94 | - $this->language_select_element = $language_select_element; |
|
95 | - $this->country_select_element = $country_select_element; |
|
96 | - $this->publisher_element = $publisher_element; |
|
97 | - |
|
98 | - } |
|
99 | - |
|
100 | - private static $instance; |
|
101 | - |
|
102 | - /** |
|
103 | - * Get the singleton instance of the Notice service. |
|
104 | - * |
|
105 | - * @return \Wordlift_Admin_Settings_Page The singleton instance of the settings page service. |
|
106 | - * @since 3.14.0 |
|
107 | - */ |
|
108 | - public static function get_instance() { |
|
109 | - |
|
110 | - if ( ! isset( self::$instance ) ) { |
|
111 | - $publisher_element = new Wordlift_Admin_Publisher_Element( |
|
112 | - Wordlift_Publisher_Service::get_instance(), |
|
113 | - new Wordlift_Admin_Tabs_Element(), |
|
114 | - new Wordlift_Admin_Select2_Element() |
|
115 | - ); |
|
116 | - |
|
117 | - self::$instance = new self( |
|
118 | - Wordlift_Entity_Service::get_instance(), |
|
119 | - new Wordlift_Admin_Input_Element(), |
|
120 | - new Wordlift_Admin_Language_Select_Element(), |
|
121 | - new Wordlift_Admin_Country_Select_Element(), |
|
122 | - $publisher_element, |
|
123 | - new Wordlift_Admin_Radio_Input_Element() |
|
124 | - ); |
|
125 | - } |
|
126 | - |
|
127 | - return self::$instance; |
|
128 | - } |
|
129 | - |
|
130 | - /** |
|
131 | - * @inheritdoc |
|
132 | - */ |
|
133 | - public function get_parent_slug() { |
|
134 | - |
|
135 | - return 'wl_admin_menu'; |
|
136 | - } |
|
137 | - |
|
138 | - /** |
|
139 | - * @inheritdoc |
|
140 | - */ |
|
141 | - public function get_capability() { |
|
142 | - |
|
143 | - return 'manage_options'; |
|
144 | - } |
|
145 | - |
|
146 | - /** |
|
147 | - * @inheritdoc |
|
148 | - */ |
|
149 | - public function get_page_title() { |
|
150 | - |
|
151 | - return __( 'WordLift Settings', 'wordlift' ); |
|
152 | - } |
|
153 | - |
|
154 | - /** |
|
155 | - * @inheritdoc |
|
156 | - */ |
|
157 | - public function get_menu_title() { |
|
158 | - |
|
159 | - return __( 'Settings', 'wordlift' ); |
|
160 | - } |
|
161 | - |
|
162 | - /** |
|
163 | - * @inheritdoc |
|
164 | - */ |
|
165 | - public function get_menu_slug() { |
|
166 | - |
|
167 | - return 'wl_configuration_admin_menu'; |
|
168 | - } |
|
169 | - |
|
170 | - /** |
|
171 | - * @inheritdoc |
|
172 | - */ |
|
173 | - public function get_partial_name() { |
|
174 | - |
|
175 | - return 'wordlift-admin-settings-page.php'; |
|
176 | - } |
|
177 | - |
|
178 | - /** |
|
179 | - * @inheritdoc |
|
180 | - */ |
|
181 | - public function enqueue_scripts() { |
|
182 | - |
|
183 | - // Enqueue the media scripts to be used for the publisher's logo selection. |
|
184 | - wp_enqueue_media(); |
|
185 | - |
|
186 | - // JavaScript required for the settings page. |
|
187 | - // @todo: try to move to the `wordlift-admin.bundle.js`. |
|
188 | - wp_enqueue_script( 'wordlift-admin-settings-page', plugin_dir_url( __DIR__ ) . 'admin/js/1/settings.js', array( 'wp-util' ), WORDLIFT_VERSION, false ); |
|
189 | - wp_enqueue_style( 'wordlift-admin-settings-page', plugin_dir_url( __DIR__ ) . 'admin/js/1/settings.css', array(), WORDLIFT_VERSION ); |
|
190 | - |
|
191 | - } |
|
192 | - |
|
193 | - /** |
|
194 | - * Configure all the configuration parameters. |
|
195 | - * |
|
196 | - * Called by the *admin_init* hook. |
|
197 | - * |
|
198 | - * @since 3.11.0 |
|
199 | - */ |
|
200 | - public function admin_init() { |
|
201 | - // Register WordLift's general settings, providing our own sanitize callback |
|
202 | - // which will also check whether the user filled the WL Publisher form. |
|
203 | - register_setting( |
|
204 | - 'wl_general_settings', |
|
205 | - 'wl_general_settings', |
|
206 | - array( $this, 'sanitize_callback' ) |
|
207 | - ); |
|
208 | - |
|
209 | - // Add the general settings section. |
|
210 | - add_settings_section( |
|
211 | - 'wl_general_settings_section', // ID used to identify this section and with which to register options. |
|
212 | - '', // Section header. |
|
213 | - '', // Callback used to render the description of the section. |
|
214 | - 'wl_general_settings' // Page on which to add this section of options. |
|
215 | - ); |
|
216 | - |
|
217 | - $key_args = array( |
|
218 | - 'id' => 'wl-key', |
|
219 | - 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::KEY . ']', |
|
220 | - 'value' => Wordlift_Configuration_Service::get_instance()->get_key(), |
|
221 | - 'description' => __( 'Insert the <a href="https://www.wordlift.io/blogger">WordLift Key</a> you received via email.', 'wordlift' ) |
|
222 | - . ' [' . get_option( 'home' ) . ']', |
|
223 | - ); |
|
224 | - |
|
225 | - // Before we were used to validate the key beforehand, but this means |
|
226 | - // an http call whenever a page is opened in the admin area. Therefore |
|
227 | - // we now leave the input `untouched`, leaving to the client to update |
|
228 | - // the `css_class`. |
|
229 | - // |
|
230 | - // See https://github.com/insideout10/wordlift-plugin/issues/669. |
|
231 | - $key_args['css_class'] = 'untouched'; |
|
232 | - |
|
233 | - // Add the `key` field. |
|
234 | - add_settings_field( |
|
235 | - 'wl-key', // Element id used to identify the field throughout the theme. |
|
236 | - __( 'WordLift Key', 'wordlift' ), // The label to the left of the option interface element. |
|
237 | - // The name of the function responsible for rendering the option interface. |
|
238 | - array( $this->input_element, 'render' ), |
|
239 | - 'wl_general_settings', // The page on which this option will be displayed. |
|
240 | - 'wl_general_settings_section', // The name of the section to which this field belongs. |
|
241 | - $key_args // The array of arguments to pass to the callback. In this case, just a description. |
|
242 | - ); |
|
243 | - |
|
244 | - // Entity Base Path input. |
|
245 | - $entity_base_path_args = array( |
|
246 | - // The array of arguments to pass to the callback. In this case, just a description. |
|
247 | - 'id' => 'wl-entity-base-path', |
|
248 | - 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::ENTITY_BASE_PATH_KEY . ']', |
|
249 | - 'value' => Wordlift_Configuration_Service::get_instance()->get_entity_base_path(), |
|
250 | - /* translators: Placeholders: %s - a link to FAQ's page. */ |
|
251 | - 'description' => sprintf( __( 'All new pages created with WordLift, will be stored inside your internal vocabulary. You can customize the url pattern of these pages in the field above. Check our <a href="%s">FAQs</a> if you need more info.', 'wordlift' ), 'https://wordlift.io/wordlift-user-faqs/#10-why-and-how-should-i-customize-the-url-of-the-entity-pages-created-in-my-vocabulary' ), |
|
252 | - ); |
|
253 | - |
|
254 | - // The following call is very heavy on large web sites and is always run |
|
255 | - // also when not needed: |
|
256 | - // $entity_base_path_args['readonly'] = 0 < $this->entity_service->count(); |
|
257 | - // |
|
258 | - // It is now replaced by a filter to add the `readonly` flag to the |
|
259 | - // input element when this is actually rendered. |
|
260 | - add_filter( |
|
261 | - 'wl_admin_input_element_params', |
|
262 | - array( |
|
263 | - $this, |
|
264 | - 'entity_path_input_element_params', |
|
265 | - ) |
|
266 | - ); |
|
267 | - |
|
268 | - // Add the `wl_entity_base_path` field. |
|
269 | - add_settings_field( |
|
270 | - 'wl-entity-base-path', // ID used to identify the field throughout the theme |
|
271 | - __( 'Entity Base Path', 'wordlift' ), // The label to the left of the option interface element |
|
272 | - // The name of the function responsible for rendering the option interface |
|
273 | - array( $this->input_element, 'render' ), |
|
274 | - 'wl_general_settings', // The page on which this option will be displayed |
|
275 | - 'wl_general_settings_section', // The name of the section to which this field belongs |
|
276 | - $entity_base_path_args |
|
277 | - ); |
|
278 | - |
|
279 | - // Add the `country_code` field. |
|
280 | - add_settings_field( |
|
281 | - 'wl-country-code', |
|
282 | - __( 'Country', 'wordlift' ), |
|
283 | - array( $this->country_select_element, 'render' ), |
|
284 | - 'wl_general_settings', |
|
285 | - 'wl_general_settings_section', |
|
286 | - array( |
|
287 | - 'id' => 'wl-country-code', |
|
288 | - 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::COUNTRY_CODE . ']', |
|
289 | - 'value' => Wordlift_Configuration_Service::get_instance()->get_country_code(), |
|
290 | - 'description' => __( 'Please select a country.', 'wordlift' ), |
|
291 | - 'notice' => __( 'The selected language is not supported in this country.</br>Please choose another country or language.', 'wordlift' ), |
|
292 | - ) |
|
293 | - ); |
|
294 | - |
|
295 | - // Add the `alternateName` field. |
|
296 | - add_settings_field( |
|
297 | - 'wl-alternate-name', |
|
298 | - __( 'Website Alternate Name', 'wordlift' ), |
|
299 | - array( $this->input_element, 'render' ), |
|
300 | - 'wl_general_settings', |
|
301 | - 'wl_general_settings_section', |
|
302 | - array( |
|
303 | - 'id' => 'wl-alternate-name', |
|
304 | - 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::ALTERNATE_NAME . ']', |
|
305 | - 'value' => Wordlift_Configuration_Service::get_instance()->get_alternate_name(), |
|
306 | - ) |
|
307 | - ); |
|
308 | - |
|
309 | - // Add the `publisher` field. |
|
310 | - add_settings_field( |
|
311 | - 'wl-publisher-id', |
|
312 | - __( 'Publisher', 'wordlift' ), |
|
313 | - array( $this->publisher_element, 'render' ), |
|
314 | - 'wl_general_settings', |
|
315 | - 'wl_general_settings_section', |
|
316 | - array( |
|
317 | - 'id' => 'wl-publisher-id', |
|
318 | - 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::PUBLISHER_ID . ']', |
|
319 | - ) |
|
320 | - ); |
|
321 | - |
|
322 | - // Add the `link by default` field. |
|
323 | - add_settings_field( |
|
324 | - 'wl-link-by-default', |
|
325 | - __( 'Link by Default', 'wordlift' ), |
|
326 | - array( $this->radio_input_element, 'render' ), |
|
327 | - 'wl_general_settings', |
|
328 | - 'wl_general_settings_section', |
|
329 | - array( |
|
330 | - 'id' => 'wl-link-by-default', |
|
331 | - 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::LINK_BY_DEFAULT . ']', |
|
332 | - 'value' => Wordlift_Configuration_Service::get_instance()->is_link_by_default() ? 'yes' : 'no', |
|
333 | - 'description' => __( 'Whether to link entities by default or not. This setting applies to all the entities.', 'wordlift' ), |
|
334 | - ) |
|
335 | - ); |
|
336 | - |
|
337 | - // Add the `diagnostic data` field. |
|
338 | - add_settings_field( |
|
339 | - 'wl-send-diagnostic', |
|
340 | - __( 'Send Diagnostic Data', 'wordlift' ), |
|
341 | - array( $this->radio_input_element, 'render' ), |
|
342 | - 'wl_general_settings', |
|
343 | - 'wl_general_settings_section', |
|
344 | - array( |
|
345 | - 'id' => 'wl-send-diagnostic', |
|
346 | - 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::SEND_DIAGNOSTIC . ']', |
|
347 | - 'value' => 'yes' === Wordlift_Configuration_Service::get_instance()->get_diagnostic_preferences() ? 'yes' : 'no', |
|
348 | - 'description' => __( 'Whether to send diagnostic data or not.', 'wordlift' ), |
|
349 | - ) |
|
350 | - ); |
|
351 | - |
|
352 | - } |
|
353 | - |
|
354 | - /** |
|
355 | - * Filter the {@link Wordlift_Admin_Input_Element} in order to add the |
|
356 | - * `readonly` flag to the `wl-entity-base-path` input. |
|
357 | - * |
|
358 | - * @param array $args An array of {@link Wordlift_Admin_Input_Element} parameters. |
|
359 | - * |
|
360 | - * @return array The updated array. |
|
361 | - * @since 3.17.0 |
|
362 | - */ |
|
363 | - public function entity_path_input_element_params( $args ) { |
|
364 | - |
|
365 | - // Bail out if it's not the `wl-entity-base-path`). |
|
366 | - if ( 'wl-entity-base-path' !== $args['id'] ) { |
|
367 | - return $args; |
|
368 | - } |
|
369 | - |
|
370 | - // Set the readonly flag according to the entities count. |
|
371 | - $args['readonly'] = 0 < $this->entity_service->count(); |
|
372 | - |
|
373 | - // Return the updated args. |
|
374 | - return $args; |
|
375 | - } |
|
376 | - |
|
377 | - /** |
|
378 | - * Sanitize the configuration settings to be stored. |
|
379 | - * |
|
380 | - * If a new entity is being created for the publisher, create it and set The |
|
381 | - * publisher setting. |
|
382 | - * |
|
383 | - * @param array $input The configuration settings array. |
|
384 | - * |
|
385 | - * @return array The sanitized input array. |
|
386 | - * @since 3.11.0 |
|
387 | - */ |
|
388 | - public function sanitize_callback( $input ) { |
|
389 | - // No nonce verification since this callback is handled by settings api. |
|
390 | - // Check whether a publisher name has been set. |
|
391 | - // phpcs:ignore Standard.Category.SniffName.ErrorCode |
|
392 | - if ( isset( $_POST['wl_publisher'] ) && ! empty( $_POST['wl_publisher']['name'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
393 | - $name = isset( $_POST['wl_publisher']['name'] ) ? sanitize_text_field( wp_unslash( (string) $_POST['wl_publisher']['name'] ) ) : ''; //phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
394 | - $type = isset( $_POST['wl_publisher']['type'] ) ? sanitize_text_field( wp_unslash( (string) $_POST['wl_publisher']['type'] ) ) : ''; //phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
395 | - // phpcs:ignore Standard.Category.SniffName.ErrorCode |
|
396 | - $thumbnail_id = isset( $_POST['wl_publisher']['thumbnail_id'] ) ? sanitize_text_field( wp_unslash( $_POST['wl_publisher']['thumbnail_id'] ) ) : null; //phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
397 | - |
|
398 | - // Set the type URI, either http://schema.org/Person or http://schema.org/Organization. |
|
399 | - $type_uri = sprintf( 'http://schema.org/%s', 'organization' === $type ? 'Organization' : 'Person' ); |
|
400 | - |
|
401 | - // Create an entity for the publisher and assign it to the input |
|
402 | - // parameter which WordPress automatically saves into the settings. |
|
403 | - $input['publisher_id'] = $this->entity_service->create( $name, $type_uri, $thumbnail_id, 'publish' ); |
|
404 | - } |
|
405 | - |
|
406 | - return $input; |
|
407 | - } |
|
21 | + /** |
|
22 | + * A {@link Wordlift_Entity_Service} instance. |
|
23 | + * |
|
24 | + * @since 3.11.0 |
|
25 | + * @access private |
|
26 | + * @var \Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance. |
|
27 | + */ |
|
28 | + private $entity_service; |
|
29 | + |
|
30 | + /** |
|
31 | + * A {@link Wordlift_Admin_Input_Element} element renderer. |
|
32 | + * |
|
33 | + * @since 3.11.0 |
|
34 | + * @access private |
|
35 | + * @var \Wordlift_Admin_Input_Element $input_element An {@link Wordlift_Admin_Input_Element} element renderer. |
|
36 | + */ |
|
37 | + private $input_element; |
|
38 | + |
|
39 | + /** |
|
40 | + * A {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
41 | + * |
|
42 | + * @since 3.13.0 |
|
43 | + * @access protected |
|
44 | + * @var \Wordlift_Admin_Radio_Input_Element $radio_input_element A {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
45 | + */ |
|
46 | + private $radio_input_element; |
|
47 | + |
|
48 | + /** |
|
49 | + * A {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
50 | + * |
|
51 | + * @since 3.11.0 |
|
52 | + * @access private |
|
53 | + * @var \Wordlift_Admin_Language_Select_Element $language_select_element A {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
54 | + */ |
|
55 | + private $language_select_element; |
|
56 | + |
|
57 | + /** |
|
58 | + * A {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
59 | + * |
|
60 | + * @since 3.18.0 |
|
61 | + * @access private |
|
62 | + * @var \Wordlift_Admin_Country_Select_Element $country_select_element A {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
63 | + */ |
|
64 | + private $country_select_element; |
|
65 | + |
|
66 | + /** |
|
67 | + * A {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
68 | + * |
|
69 | + * @since 3.11.0 |
|
70 | + * @access private |
|
71 | + * @var \Wordlift_Admin_Publisher_Element $publisher_element A {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
72 | + */ |
|
73 | + private $publisher_element; |
|
74 | + |
|
75 | + /** |
|
76 | + * Create a {@link Wordlift_Admin_Settings_Page} instance. |
|
77 | + * |
|
78 | + * @param \Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance. |
|
79 | + * @param \Wordlift_Admin_Input_Element $input_element A {@link Wordlift_Admin_Input_Element} element renderer. |
|
80 | + * @param \Wordlift_Admin_Language_Select_Element $language_select_element A {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
81 | + * @param \Wordlift_Admin_Country_Select_Element $country_select_element A {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
82 | + * @param \Wordlift_Admin_Publisher_Element $publisher_element A {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
83 | + * @param \Wordlift_Admin_Radio_Input_Element $radio_input_element A {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
84 | + * |
|
85 | + * @since 3.11.0 |
|
86 | + */ |
|
87 | + public function __construct( $entity_service, $input_element, $language_select_element, $country_select_element, $publisher_element, $radio_input_element ) { |
|
88 | + |
|
89 | + $this->entity_service = $entity_service; |
|
90 | + |
|
91 | + // Set a reference to the UI elements. |
|
92 | + $this->input_element = $input_element; |
|
93 | + $this->radio_input_element = $radio_input_element; |
|
94 | + $this->language_select_element = $language_select_element; |
|
95 | + $this->country_select_element = $country_select_element; |
|
96 | + $this->publisher_element = $publisher_element; |
|
97 | + |
|
98 | + } |
|
99 | + |
|
100 | + private static $instance; |
|
101 | + |
|
102 | + /** |
|
103 | + * Get the singleton instance of the Notice service. |
|
104 | + * |
|
105 | + * @return \Wordlift_Admin_Settings_Page The singleton instance of the settings page service. |
|
106 | + * @since 3.14.0 |
|
107 | + */ |
|
108 | + public static function get_instance() { |
|
109 | + |
|
110 | + if ( ! isset( self::$instance ) ) { |
|
111 | + $publisher_element = new Wordlift_Admin_Publisher_Element( |
|
112 | + Wordlift_Publisher_Service::get_instance(), |
|
113 | + new Wordlift_Admin_Tabs_Element(), |
|
114 | + new Wordlift_Admin_Select2_Element() |
|
115 | + ); |
|
116 | + |
|
117 | + self::$instance = new self( |
|
118 | + Wordlift_Entity_Service::get_instance(), |
|
119 | + new Wordlift_Admin_Input_Element(), |
|
120 | + new Wordlift_Admin_Language_Select_Element(), |
|
121 | + new Wordlift_Admin_Country_Select_Element(), |
|
122 | + $publisher_element, |
|
123 | + new Wordlift_Admin_Radio_Input_Element() |
|
124 | + ); |
|
125 | + } |
|
126 | + |
|
127 | + return self::$instance; |
|
128 | + } |
|
129 | + |
|
130 | + /** |
|
131 | + * @inheritdoc |
|
132 | + */ |
|
133 | + public function get_parent_slug() { |
|
134 | + |
|
135 | + return 'wl_admin_menu'; |
|
136 | + } |
|
137 | + |
|
138 | + /** |
|
139 | + * @inheritdoc |
|
140 | + */ |
|
141 | + public function get_capability() { |
|
142 | + |
|
143 | + return 'manage_options'; |
|
144 | + } |
|
145 | + |
|
146 | + /** |
|
147 | + * @inheritdoc |
|
148 | + */ |
|
149 | + public function get_page_title() { |
|
150 | + |
|
151 | + return __( 'WordLift Settings', 'wordlift' ); |
|
152 | + } |
|
153 | + |
|
154 | + /** |
|
155 | + * @inheritdoc |
|
156 | + */ |
|
157 | + public function get_menu_title() { |
|
158 | + |
|
159 | + return __( 'Settings', 'wordlift' ); |
|
160 | + } |
|
161 | + |
|
162 | + /** |
|
163 | + * @inheritdoc |
|
164 | + */ |
|
165 | + public function get_menu_slug() { |
|
166 | + |
|
167 | + return 'wl_configuration_admin_menu'; |
|
168 | + } |
|
169 | + |
|
170 | + /** |
|
171 | + * @inheritdoc |
|
172 | + */ |
|
173 | + public function get_partial_name() { |
|
174 | + |
|
175 | + return 'wordlift-admin-settings-page.php'; |
|
176 | + } |
|
177 | + |
|
178 | + /** |
|
179 | + * @inheritdoc |
|
180 | + */ |
|
181 | + public function enqueue_scripts() { |
|
182 | + |
|
183 | + // Enqueue the media scripts to be used for the publisher's logo selection. |
|
184 | + wp_enqueue_media(); |
|
185 | + |
|
186 | + // JavaScript required for the settings page. |
|
187 | + // @todo: try to move to the `wordlift-admin.bundle.js`. |
|
188 | + wp_enqueue_script( 'wordlift-admin-settings-page', plugin_dir_url( __DIR__ ) . 'admin/js/1/settings.js', array( 'wp-util' ), WORDLIFT_VERSION, false ); |
|
189 | + wp_enqueue_style( 'wordlift-admin-settings-page', plugin_dir_url( __DIR__ ) . 'admin/js/1/settings.css', array(), WORDLIFT_VERSION ); |
|
190 | + |
|
191 | + } |
|
192 | + |
|
193 | + /** |
|
194 | + * Configure all the configuration parameters. |
|
195 | + * |
|
196 | + * Called by the *admin_init* hook. |
|
197 | + * |
|
198 | + * @since 3.11.0 |
|
199 | + */ |
|
200 | + public function admin_init() { |
|
201 | + // Register WordLift's general settings, providing our own sanitize callback |
|
202 | + // which will also check whether the user filled the WL Publisher form. |
|
203 | + register_setting( |
|
204 | + 'wl_general_settings', |
|
205 | + 'wl_general_settings', |
|
206 | + array( $this, 'sanitize_callback' ) |
|
207 | + ); |
|
208 | + |
|
209 | + // Add the general settings section. |
|
210 | + add_settings_section( |
|
211 | + 'wl_general_settings_section', // ID used to identify this section and with which to register options. |
|
212 | + '', // Section header. |
|
213 | + '', // Callback used to render the description of the section. |
|
214 | + 'wl_general_settings' // Page on which to add this section of options. |
|
215 | + ); |
|
216 | + |
|
217 | + $key_args = array( |
|
218 | + 'id' => 'wl-key', |
|
219 | + 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::KEY . ']', |
|
220 | + 'value' => Wordlift_Configuration_Service::get_instance()->get_key(), |
|
221 | + 'description' => __( 'Insert the <a href="https://www.wordlift.io/blogger">WordLift Key</a> you received via email.', 'wordlift' ) |
|
222 | + . ' [' . get_option( 'home' ) . ']', |
|
223 | + ); |
|
224 | + |
|
225 | + // Before we were used to validate the key beforehand, but this means |
|
226 | + // an http call whenever a page is opened in the admin area. Therefore |
|
227 | + // we now leave the input `untouched`, leaving to the client to update |
|
228 | + // the `css_class`. |
|
229 | + // |
|
230 | + // See https://github.com/insideout10/wordlift-plugin/issues/669. |
|
231 | + $key_args['css_class'] = 'untouched'; |
|
232 | + |
|
233 | + // Add the `key` field. |
|
234 | + add_settings_field( |
|
235 | + 'wl-key', // Element id used to identify the field throughout the theme. |
|
236 | + __( 'WordLift Key', 'wordlift' ), // The label to the left of the option interface element. |
|
237 | + // The name of the function responsible for rendering the option interface. |
|
238 | + array( $this->input_element, 'render' ), |
|
239 | + 'wl_general_settings', // The page on which this option will be displayed. |
|
240 | + 'wl_general_settings_section', // The name of the section to which this field belongs. |
|
241 | + $key_args // The array of arguments to pass to the callback. In this case, just a description. |
|
242 | + ); |
|
243 | + |
|
244 | + // Entity Base Path input. |
|
245 | + $entity_base_path_args = array( |
|
246 | + // The array of arguments to pass to the callback. In this case, just a description. |
|
247 | + 'id' => 'wl-entity-base-path', |
|
248 | + 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::ENTITY_BASE_PATH_KEY . ']', |
|
249 | + 'value' => Wordlift_Configuration_Service::get_instance()->get_entity_base_path(), |
|
250 | + /* translators: Placeholders: %s - a link to FAQ's page. */ |
|
251 | + 'description' => sprintf( __( 'All new pages created with WordLift, will be stored inside your internal vocabulary. You can customize the url pattern of these pages in the field above. Check our <a href="%s">FAQs</a> if you need more info.', 'wordlift' ), 'https://wordlift.io/wordlift-user-faqs/#10-why-and-how-should-i-customize-the-url-of-the-entity-pages-created-in-my-vocabulary' ), |
|
252 | + ); |
|
253 | + |
|
254 | + // The following call is very heavy on large web sites and is always run |
|
255 | + // also when not needed: |
|
256 | + // $entity_base_path_args['readonly'] = 0 < $this->entity_service->count(); |
|
257 | + // |
|
258 | + // It is now replaced by a filter to add the `readonly` flag to the |
|
259 | + // input element when this is actually rendered. |
|
260 | + add_filter( |
|
261 | + 'wl_admin_input_element_params', |
|
262 | + array( |
|
263 | + $this, |
|
264 | + 'entity_path_input_element_params', |
|
265 | + ) |
|
266 | + ); |
|
267 | + |
|
268 | + // Add the `wl_entity_base_path` field. |
|
269 | + add_settings_field( |
|
270 | + 'wl-entity-base-path', // ID used to identify the field throughout the theme |
|
271 | + __( 'Entity Base Path', 'wordlift' ), // The label to the left of the option interface element |
|
272 | + // The name of the function responsible for rendering the option interface |
|
273 | + array( $this->input_element, 'render' ), |
|
274 | + 'wl_general_settings', // The page on which this option will be displayed |
|
275 | + 'wl_general_settings_section', // The name of the section to which this field belongs |
|
276 | + $entity_base_path_args |
|
277 | + ); |
|
278 | + |
|
279 | + // Add the `country_code` field. |
|
280 | + add_settings_field( |
|
281 | + 'wl-country-code', |
|
282 | + __( 'Country', 'wordlift' ), |
|
283 | + array( $this->country_select_element, 'render' ), |
|
284 | + 'wl_general_settings', |
|
285 | + 'wl_general_settings_section', |
|
286 | + array( |
|
287 | + 'id' => 'wl-country-code', |
|
288 | + 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::COUNTRY_CODE . ']', |
|
289 | + 'value' => Wordlift_Configuration_Service::get_instance()->get_country_code(), |
|
290 | + 'description' => __( 'Please select a country.', 'wordlift' ), |
|
291 | + 'notice' => __( 'The selected language is not supported in this country.</br>Please choose another country or language.', 'wordlift' ), |
|
292 | + ) |
|
293 | + ); |
|
294 | + |
|
295 | + // Add the `alternateName` field. |
|
296 | + add_settings_field( |
|
297 | + 'wl-alternate-name', |
|
298 | + __( 'Website Alternate Name', 'wordlift' ), |
|
299 | + array( $this->input_element, 'render' ), |
|
300 | + 'wl_general_settings', |
|
301 | + 'wl_general_settings_section', |
|
302 | + array( |
|
303 | + 'id' => 'wl-alternate-name', |
|
304 | + 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::ALTERNATE_NAME . ']', |
|
305 | + 'value' => Wordlift_Configuration_Service::get_instance()->get_alternate_name(), |
|
306 | + ) |
|
307 | + ); |
|
308 | + |
|
309 | + // Add the `publisher` field. |
|
310 | + add_settings_field( |
|
311 | + 'wl-publisher-id', |
|
312 | + __( 'Publisher', 'wordlift' ), |
|
313 | + array( $this->publisher_element, 'render' ), |
|
314 | + 'wl_general_settings', |
|
315 | + 'wl_general_settings_section', |
|
316 | + array( |
|
317 | + 'id' => 'wl-publisher-id', |
|
318 | + 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::PUBLISHER_ID . ']', |
|
319 | + ) |
|
320 | + ); |
|
321 | + |
|
322 | + // Add the `link by default` field. |
|
323 | + add_settings_field( |
|
324 | + 'wl-link-by-default', |
|
325 | + __( 'Link by Default', 'wordlift' ), |
|
326 | + array( $this->radio_input_element, 'render' ), |
|
327 | + 'wl_general_settings', |
|
328 | + 'wl_general_settings_section', |
|
329 | + array( |
|
330 | + 'id' => 'wl-link-by-default', |
|
331 | + 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::LINK_BY_DEFAULT . ']', |
|
332 | + 'value' => Wordlift_Configuration_Service::get_instance()->is_link_by_default() ? 'yes' : 'no', |
|
333 | + 'description' => __( 'Whether to link entities by default or not. This setting applies to all the entities.', 'wordlift' ), |
|
334 | + ) |
|
335 | + ); |
|
336 | + |
|
337 | + // Add the `diagnostic data` field. |
|
338 | + add_settings_field( |
|
339 | + 'wl-send-diagnostic', |
|
340 | + __( 'Send Diagnostic Data', 'wordlift' ), |
|
341 | + array( $this->radio_input_element, 'render' ), |
|
342 | + 'wl_general_settings', |
|
343 | + 'wl_general_settings_section', |
|
344 | + array( |
|
345 | + 'id' => 'wl-send-diagnostic', |
|
346 | + 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::SEND_DIAGNOSTIC . ']', |
|
347 | + 'value' => 'yes' === Wordlift_Configuration_Service::get_instance()->get_diagnostic_preferences() ? 'yes' : 'no', |
|
348 | + 'description' => __( 'Whether to send diagnostic data or not.', 'wordlift' ), |
|
349 | + ) |
|
350 | + ); |
|
351 | + |
|
352 | + } |
|
353 | + |
|
354 | + /** |
|
355 | + * Filter the {@link Wordlift_Admin_Input_Element} in order to add the |
|
356 | + * `readonly` flag to the `wl-entity-base-path` input. |
|
357 | + * |
|
358 | + * @param array $args An array of {@link Wordlift_Admin_Input_Element} parameters. |
|
359 | + * |
|
360 | + * @return array The updated array. |
|
361 | + * @since 3.17.0 |
|
362 | + */ |
|
363 | + public function entity_path_input_element_params( $args ) { |
|
364 | + |
|
365 | + // Bail out if it's not the `wl-entity-base-path`). |
|
366 | + if ( 'wl-entity-base-path' !== $args['id'] ) { |
|
367 | + return $args; |
|
368 | + } |
|
369 | + |
|
370 | + // Set the readonly flag according to the entities count. |
|
371 | + $args['readonly'] = 0 < $this->entity_service->count(); |
|
372 | + |
|
373 | + // Return the updated args. |
|
374 | + return $args; |
|
375 | + } |
|
376 | + |
|
377 | + /** |
|
378 | + * Sanitize the configuration settings to be stored. |
|
379 | + * |
|
380 | + * If a new entity is being created for the publisher, create it and set The |
|
381 | + * publisher setting. |
|
382 | + * |
|
383 | + * @param array $input The configuration settings array. |
|
384 | + * |
|
385 | + * @return array The sanitized input array. |
|
386 | + * @since 3.11.0 |
|
387 | + */ |
|
388 | + public function sanitize_callback( $input ) { |
|
389 | + // No nonce verification since this callback is handled by settings api. |
|
390 | + // Check whether a publisher name has been set. |
|
391 | + // phpcs:ignore Standard.Category.SniffName.ErrorCode |
|
392 | + if ( isset( $_POST['wl_publisher'] ) && ! empty( $_POST['wl_publisher']['name'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
393 | + $name = isset( $_POST['wl_publisher']['name'] ) ? sanitize_text_field( wp_unslash( (string) $_POST['wl_publisher']['name'] ) ) : ''; //phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
394 | + $type = isset( $_POST['wl_publisher']['type'] ) ? sanitize_text_field( wp_unslash( (string) $_POST['wl_publisher']['type'] ) ) : ''; //phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
395 | + // phpcs:ignore Standard.Category.SniffName.ErrorCode |
|
396 | + $thumbnail_id = isset( $_POST['wl_publisher']['thumbnail_id'] ) ? sanitize_text_field( wp_unslash( $_POST['wl_publisher']['thumbnail_id'] ) ) : null; //phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
397 | + |
|
398 | + // Set the type URI, either http://schema.org/Person or http://schema.org/Organization. |
|
399 | + $type_uri = sprintf( 'http://schema.org/%s', 'organization' === $type ? 'Organization' : 'Person' ); |
|
400 | + |
|
401 | + // Create an entity for the publisher and assign it to the input |
|
402 | + // parameter which WordPress automatically saves into the settings. |
|
403 | + $input['publisher_id'] = $this->entity_service->create( $name, $type_uri, $thumbnail_id, 'publish' ); |
|
404 | + } |
|
405 | + |
|
406 | + return $input; |
|
407 | + } |
|
408 | 408 | |
409 | 409 | } |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @since 3.11.0 |
86 | 86 | */ |
87 | - public function __construct( $entity_service, $input_element, $language_select_element, $country_select_element, $publisher_element, $radio_input_element ) { |
|
87 | + public function __construct($entity_service, $input_element, $language_select_element, $country_select_element, $publisher_element, $radio_input_element) { |
|
88 | 88 | |
89 | 89 | $this->entity_service = $entity_service; |
90 | 90 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | */ |
108 | 108 | public static function get_instance() { |
109 | 109 | |
110 | - if ( ! isset( self::$instance ) ) { |
|
110 | + if ( ! isset(self::$instance)) { |
|
111 | 111 | $publisher_element = new Wordlift_Admin_Publisher_Element( |
112 | 112 | Wordlift_Publisher_Service::get_instance(), |
113 | 113 | new Wordlift_Admin_Tabs_Element(), |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | */ |
149 | 149 | public function get_page_title() { |
150 | 150 | |
151 | - return __( 'WordLift Settings', 'wordlift' ); |
|
151 | + return __('WordLift Settings', 'wordlift'); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | */ |
157 | 157 | public function get_menu_title() { |
158 | 158 | |
159 | - return __( 'Settings', 'wordlift' ); |
|
159 | + return __('Settings', 'wordlift'); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
@@ -185,8 +185,8 @@ discard block |
||
185 | 185 | |
186 | 186 | // JavaScript required for the settings page. |
187 | 187 | // @todo: try to move to the `wordlift-admin.bundle.js`. |
188 | - wp_enqueue_script( 'wordlift-admin-settings-page', plugin_dir_url( __DIR__ ) . 'admin/js/1/settings.js', array( 'wp-util' ), WORDLIFT_VERSION, false ); |
|
189 | - wp_enqueue_style( 'wordlift-admin-settings-page', plugin_dir_url( __DIR__ ) . 'admin/js/1/settings.css', array(), WORDLIFT_VERSION ); |
|
188 | + wp_enqueue_script('wordlift-admin-settings-page', plugin_dir_url(__DIR__).'admin/js/1/settings.js', array('wp-util'), WORDLIFT_VERSION, false); |
|
189 | + wp_enqueue_style('wordlift-admin-settings-page', plugin_dir_url(__DIR__).'admin/js/1/settings.css', array(), WORDLIFT_VERSION); |
|
190 | 190 | |
191 | 191 | } |
192 | 192 | |
@@ -203,23 +203,23 @@ discard block |
||
203 | 203 | register_setting( |
204 | 204 | 'wl_general_settings', |
205 | 205 | 'wl_general_settings', |
206 | - array( $this, 'sanitize_callback' ) |
|
206 | + array($this, 'sanitize_callback') |
|
207 | 207 | ); |
208 | 208 | |
209 | 209 | // Add the general settings section. |
210 | 210 | add_settings_section( |
211 | 211 | 'wl_general_settings_section', // ID used to identify this section and with which to register options. |
212 | - '', // Section header. |
|
213 | - '', // Callback used to render the description of the section. |
|
212 | + '', // Section header. |
|
213 | + '', // Callback used to render the description of the section. |
|
214 | 214 | 'wl_general_settings' // Page on which to add this section of options. |
215 | 215 | ); |
216 | 216 | |
217 | 217 | $key_args = array( |
218 | 218 | 'id' => 'wl-key', |
219 | - 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::KEY . ']', |
|
219 | + 'name' => 'wl_general_settings['.Wordlift_Configuration_Service::KEY.']', |
|
220 | 220 | 'value' => Wordlift_Configuration_Service::get_instance()->get_key(), |
221 | - 'description' => __( 'Insert the <a href="https://www.wordlift.io/blogger">WordLift Key</a> you received via email.', 'wordlift' ) |
|
222 | - . ' [' . get_option( 'home' ) . ']', |
|
221 | + 'description' => __('Insert the <a href="https://www.wordlift.io/blogger">WordLift Key</a> you received via email.', 'wordlift') |
|
222 | + . ' ['.get_option('home').']', |
|
223 | 223 | ); |
224 | 224 | |
225 | 225 | // Before we were used to validate the key beforehand, but this means |
@@ -232,12 +232,12 @@ discard block |
||
232 | 232 | |
233 | 233 | // Add the `key` field. |
234 | 234 | add_settings_field( |
235 | - 'wl-key', // Element id used to identify the field throughout the theme. |
|
236 | - __( 'WordLift Key', 'wordlift' ), // The label to the left of the option interface element. |
|
235 | + 'wl-key', // Element id used to identify the field throughout the theme. |
|
236 | + __('WordLift Key', 'wordlift'), // The label to the left of the option interface element. |
|
237 | 237 | // The name of the function responsible for rendering the option interface. |
238 | - array( $this->input_element, 'render' ), |
|
239 | - 'wl_general_settings', // The page on which this option will be displayed. |
|
240 | - 'wl_general_settings_section', // The name of the section to which this field belongs. |
|
238 | + array($this->input_element, 'render'), |
|
239 | + 'wl_general_settings', // The page on which this option will be displayed. |
|
240 | + 'wl_general_settings_section', // The name of the section to which this field belongs. |
|
241 | 241 | $key_args // The array of arguments to pass to the callback. In this case, just a description. |
242 | 242 | ); |
243 | 243 | |
@@ -245,10 +245,10 @@ discard block |
||
245 | 245 | $entity_base_path_args = array( |
246 | 246 | // The array of arguments to pass to the callback. In this case, just a description. |
247 | 247 | 'id' => 'wl-entity-base-path', |
248 | - 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::ENTITY_BASE_PATH_KEY . ']', |
|
248 | + 'name' => 'wl_general_settings['.Wordlift_Configuration_Service::ENTITY_BASE_PATH_KEY.']', |
|
249 | 249 | 'value' => Wordlift_Configuration_Service::get_instance()->get_entity_base_path(), |
250 | 250 | /* translators: Placeholders: %s - a link to FAQ's page. */ |
251 | - 'description' => sprintf( __( 'All new pages created with WordLift, will be stored inside your internal vocabulary. You can customize the url pattern of these pages in the field above. Check our <a href="%s">FAQs</a> if you need more info.', 'wordlift' ), 'https://wordlift.io/wordlift-user-faqs/#10-why-and-how-should-i-customize-the-url-of-the-entity-pages-created-in-my-vocabulary' ), |
|
251 | + 'description' => sprintf(__('All new pages created with WordLift, will be stored inside your internal vocabulary. You can customize the url pattern of these pages in the field above. Check our <a href="%s">FAQs</a> if you need more info.', 'wordlift'), 'https://wordlift.io/wordlift-user-faqs/#10-why-and-how-should-i-customize-the-url-of-the-entity-pages-created-in-my-vocabulary'), |
|
252 | 252 | ); |
253 | 253 | |
254 | 254 | // The following call is very heavy on large web sites and is always run |
@@ -267,41 +267,41 @@ discard block |
||
267 | 267 | |
268 | 268 | // Add the `wl_entity_base_path` field. |
269 | 269 | add_settings_field( |
270 | - 'wl-entity-base-path', // ID used to identify the field throughout the theme |
|
271 | - __( 'Entity Base Path', 'wordlift' ), // The label to the left of the option interface element |
|
270 | + 'wl-entity-base-path', // ID used to identify the field throughout the theme |
|
271 | + __('Entity Base Path', 'wordlift'), // The label to the left of the option interface element |
|
272 | 272 | // The name of the function responsible for rendering the option interface |
273 | - array( $this->input_element, 'render' ), |
|
274 | - 'wl_general_settings', // The page on which this option will be displayed |
|
275 | - 'wl_general_settings_section', // The name of the section to which this field belongs |
|
273 | + array($this->input_element, 'render'), |
|
274 | + 'wl_general_settings', // The page on which this option will be displayed |
|
275 | + 'wl_general_settings_section', // The name of the section to which this field belongs |
|
276 | 276 | $entity_base_path_args |
277 | 277 | ); |
278 | 278 | |
279 | 279 | // Add the `country_code` field. |
280 | 280 | add_settings_field( |
281 | 281 | 'wl-country-code', |
282 | - __( 'Country', 'wordlift' ), |
|
283 | - array( $this->country_select_element, 'render' ), |
|
282 | + __('Country', 'wordlift'), |
|
283 | + array($this->country_select_element, 'render'), |
|
284 | 284 | 'wl_general_settings', |
285 | 285 | 'wl_general_settings_section', |
286 | 286 | array( |
287 | 287 | 'id' => 'wl-country-code', |
288 | - 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::COUNTRY_CODE . ']', |
|
288 | + 'name' => 'wl_general_settings['.Wordlift_Configuration_Service::COUNTRY_CODE.']', |
|
289 | 289 | 'value' => Wordlift_Configuration_Service::get_instance()->get_country_code(), |
290 | - 'description' => __( 'Please select a country.', 'wordlift' ), |
|
291 | - 'notice' => __( 'The selected language is not supported in this country.</br>Please choose another country or language.', 'wordlift' ), |
|
290 | + 'description' => __('Please select a country.', 'wordlift'), |
|
291 | + 'notice' => __('The selected language is not supported in this country.</br>Please choose another country or language.', 'wordlift'), |
|
292 | 292 | ) |
293 | 293 | ); |
294 | 294 | |
295 | 295 | // Add the `alternateName` field. |
296 | 296 | add_settings_field( |
297 | 297 | 'wl-alternate-name', |
298 | - __( 'Website Alternate Name', 'wordlift' ), |
|
299 | - array( $this->input_element, 'render' ), |
|
298 | + __('Website Alternate Name', 'wordlift'), |
|
299 | + array($this->input_element, 'render'), |
|
300 | 300 | 'wl_general_settings', |
301 | 301 | 'wl_general_settings_section', |
302 | 302 | array( |
303 | 303 | 'id' => 'wl-alternate-name', |
304 | - 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::ALTERNATE_NAME . ']', |
|
304 | + 'name' => 'wl_general_settings['.Wordlift_Configuration_Service::ALTERNATE_NAME.']', |
|
305 | 305 | 'value' => Wordlift_Configuration_Service::get_instance()->get_alternate_name(), |
306 | 306 | ) |
307 | 307 | ); |
@@ -309,43 +309,43 @@ discard block |
||
309 | 309 | // Add the `publisher` field. |
310 | 310 | add_settings_field( |
311 | 311 | 'wl-publisher-id', |
312 | - __( 'Publisher', 'wordlift' ), |
|
313 | - array( $this->publisher_element, 'render' ), |
|
312 | + __('Publisher', 'wordlift'), |
|
313 | + array($this->publisher_element, 'render'), |
|
314 | 314 | 'wl_general_settings', |
315 | 315 | 'wl_general_settings_section', |
316 | 316 | array( |
317 | 317 | 'id' => 'wl-publisher-id', |
318 | - 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::PUBLISHER_ID . ']', |
|
318 | + 'name' => 'wl_general_settings['.Wordlift_Configuration_Service::PUBLISHER_ID.']', |
|
319 | 319 | ) |
320 | 320 | ); |
321 | 321 | |
322 | 322 | // Add the `link by default` field. |
323 | 323 | add_settings_field( |
324 | 324 | 'wl-link-by-default', |
325 | - __( 'Link by Default', 'wordlift' ), |
|
326 | - array( $this->radio_input_element, 'render' ), |
|
325 | + __('Link by Default', 'wordlift'), |
|
326 | + array($this->radio_input_element, 'render'), |
|
327 | 327 | 'wl_general_settings', |
328 | 328 | 'wl_general_settings_section', |
329 | 329 | array( |
330 | 330 | 'id' => 'wl-link-by-default', |
331 | - 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::LINK_BY_DEFAULT . ']', |
|
331 | + 'name' => 'wl_general_settings['.Wordlift_Configuration_Service::LINK_BY_DEFAULT.']', |
|
332 | 332 | 'value' => Wordlift_Configuration_Service::get_instance()->is_link_by_default() ? 'yes' : 'no', |
333 | - 'description' => __( 'Whether to link entities by default or not. This setting applies to all the entities.', 'wordlift' ), |
|
333 | + 'description' => __('Whether to link entities by default or not. This setting applies to all the entities.', 'wordlift'), |
|
334 | 334 | ) |
335 | 335 | ); |
336 | 336 | |
337 | 337 | // Add the `diagnostic data` field. |
338 | 338 | add_settings_field( |
339 | 339 | 'wl-send-diagnostic', |
340 | - __( 'Send Diagnostic Data', 'wordlift' ), |
|
341 | - array( $this->radio_input_element, 'render' ), |
|
340 | + __('Send Diagnostic Data', 'wordlift'), |
|
341 | + array($this->radio_input_element, 'render'), |
|
342 | 342 | 'wl_general_settings', |
343 | 343 | 'wl_general_settings_section', |
344 | 344 | array( |
345 | 345 | 'id' => 'wl-send-diagnostic', |
346 | - 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::SEND_DIAGNOSTIC . ']', |
|
346 | + 'name' => 'wl_general_settings['.Wordlift_Configuration_Service::SEND_DIAGNOSTIC.']', |
|
347 | 347 | 'value' => 'yes' === Wordlift_Configuration_Service::get_instance()->get_diagnostic_preferences() ? 'yes' : 'no', |
348 | - 'description' => __( 'Whether to send diagnostic data or not.', 'wordlift' ), |
|
348 | + 'description' => __('Whether to send diagnostic data or not.', 'wordlift'), |
|
349 | 349 | ) |
350 | 350 | ); |
351 | 351 | |
@@ -360,10 +360,10 @@ discard block |
||
360 | 360 | * @return array The updated array. |
361 | 361 | * @since 3.17.0 |
362 | 362 | */ |
363 | - public function entity_path_input_element_params( $args ) { |
|
363 | + public function entity_path_input_element_params($args) { |
|
364 | 364 | |
365 | 365 | // Bail out if it's not the `wl-entity-base-path`). |
366 | - if ( 'wl-entity-base-path' !== $args['id'] ) { |
|
366 | + if ('wl-entity-base-path' !== $args['id']) { |
|
367 | 367 | return $args; |
368 | 368 | } |
369 | 369 | |
@@ -385,22 +385,22 @@ discard block |
||
385 | 385 | * @return array The sanitized input array. |
386 | 386 | * @since 3.11.0 |
387 | 387 | */ |
388 | - public function sanitize_callback( $input ) { |
|
388 | + public function sanitize_callback($input) { |
|
389 | 389 | // No nonce verification since this callback is handled by settings api. |
390 | 390 | // Check whether a publisher name has been set. |
391 | 391 | // phpcs:ignore Standard.Category.SniffName.ErrorCode |
392 | - if ( isset( $_POST['wl_publisher'] ) && ! empty( $_POST['wl_publisher']['name'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
393 | - $name = isset( $_POST['wl_publisher']['name'] ) ? sanitize_text_field( wp_unslash( (string) $_POST['wl_publisher']['name'] ) ) : ''; //phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
394 | - $type = isset( $_POST['wl_publisher']['type'] ) ? sanitize_text_field( wp_unslash( (string) $_POST['wl_publisher']['type'] ) ) : ''; //phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
392 | + if (isset($_POST['wl_publisher']) && ! empty($_POST['wl_publisher']['name'])) { //phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
393 | + $name = isset($_POST['wl_publisher']['name']) ? sanitize_text_field(wp_unslash((string) $_POST['wl_publisher']['name'])) : ''; //phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
394 | + $type = isset($_POST['wl_publisher']['type']) ? sanitize_text_field(wp_unslash((string) $_POST['wl_publisher']['type'])) : ''; //phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
395 | 395 | // phpcs:ignore Standard.Category.SniffName.ErrorCode |
396 | - $thumbnail_id = isset( $_POST['wl_publisher']['thumbnail_id'] ) ? sanitize_text_field( wp_unslash( $_POST['wl_publisher']['thumbnail_id'] ) ) : null; //phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
396 | + $thumbnail_id = isset($_POST['wl_publisher']['thumbnail_id']) ? sanitize_text_field(wp_unslash($_POST['wl_publisher']['thumbnail_id'])) : null; //phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
397 | 397 | |
398 | 398 | // Set the type URI, either http://schema.org/Person or http://schema.org/Organization. |
399 | - $type_uri = sprintf( 'http://schema.org/%s', 'organization' === $type ? 'Organization' : 'Person' ); |
|
399 | + $type_uri = sprintf('http://schema.org/%s', 'organization' === $type ? 'Organization' : 'Person'); |
|
400 | 400 | |
401 | 401 | // Create an entity for the publisher and assign it to the input |
402 | 402 | // parameter which WordPress automatically saves into the settings. |
403 | - $input['publisher_id'] = $this->entity_service->create( $name, $type_uri, $thumbnail_id, 'publish' ); |
|
403 | + $input['publisher_id'] = $this->entity_service->create($name, $type_uri, $thumbnail_id, 'publish'); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | return $input; |
@@ -4,58 +4,58 @@ |
||
4 | 4 | |
5 | 5 | class Ingredients_Taxonomy_Recipe_Lift_Strategy implements Recipe_Lift_Strategy { |
6 | 6 | |
7 | - /** |
|
8 | - * @var Ingredients_Client |
|
9 | - */ |
|
10 | - private $ingredients_client; |
|
11 | - |
|
12 | - /** |
|
13 | - * @var Notices |
|
14 | - */ |
|
15 | - private $notices; |
|
16 | - |
|
17 | - public function __construct( Ingredients_Client $ingredients_client, Notices $notices ) { |
|
18 | - $this->ingredients_client = $ingredients_client; |
|
19 | - $this->notices = $notices; |
|
20 | - } |
|
21 | - |
|
22 | - public function run() { |
|
23 | - $this->notices->queue( 'info', __( 'WordLift detected WP Recipe Maker and, it is lifting the ingredients...', 'wordlift' ) ); |
|
24 | - |
|
25 | - /** |
|
26 | - * @var string[] $terms |
|
27 | - */ |
|
28 | - $terms = get_terms( |
|
29 | - array( |
|
30 | - 'taxonomy' => 'wprm_ingredient', |
|
31 | - 'fields' => 'names', |
|
32 | - 'hide_empty' => false, |
|
33 | - ) |
|
34 | - ); |
|
35 | - $ingredients = $this->ingredients_client->ingredients( $terms ); |
|
36 | - |
|
37 | - foreach ( $ingredients as $key => $value ) { |
|
38 | - $term = get_term_by( 'name', $key, 'wprm_ingredient' ); |
|
39 | - if ( ! isset( $term ) ) { |
|
40 | - continue; |
|
41 | - } |
|
42 | - update_term_meta( $term->term_id, '_wl_jsonld', wp_slash( $value ) ); |
|
43 | - |
|
44 | - /** |
|
45 | - * @@todo update notification with progress |
|
46 | - */ |
|
47 | - } |
|
48 | - |
|
49 | - // Clean up caches. |
|
50 | - do_action( 'wl_ttl_cache_cleaner__flush' ); |
|
51 | - |
|
52 | - /** |
|
53 | - * @@todo add notification that procedure is complete, with information about the number of processed items vs |
|
54 | - * total items |
|
55 | - */ |
|
56 | - $count_terms = count( $terms ); |
|
57 | - $count_lifted_terms = count( $ingredients ); |
|
58 | - /* translators: 1: The number of lifted ingredients, 2: The total number of ingredients. */ |
|
59 | - $this->notices->queue( 'info', sprintf( __( 'WordLift detected WP Recipe Maker and, it lifted %1$d of %2$d ingredient(s).', 'wordlift' ), $count_lifted_terms, $count_terms ) ); |
|
60 | - } |
|
7 | + /** |
|
8 | + * @var Ingredients_Client |
|
9 | + */ |
|
10 | + private $ingredients_client; |
|
11 | + |
|
12 | + /** |
|
13 | + * @var Notices |
|
14 | + */ |
|
15 | + private $notices; |
|
16 | + |
|
17 | + public function __construct( Ingredients_Client $ingredients_client, Notices $notices ) { |
|
18 | + $this->ingredients_client = $ingredients_client; |
|
19 | + $this->notices = $notices; |
|
20 | + } |
|
21 | + |
|
22 | + public function run() { |
|
23 | + $this->notices->queue( 'info', __( 'WordLift detected WP Recipe Maker and, it is lifting the ingredients...', 'wordlift' ) ); |
|
24 | + |
|
25 | + /** |
|
26 | + * @var string[] $terms |
|
27 | + */ |
|
28 | + $terms = get_terms( |
|
29 | + array( |
|
30 | + 'taxonomy' => 'wprm_ingredient', |
|
31 | + 'fields' => 'names', |
|
32 | + 'hide_empty' => false, |
|
33 | + ) |
|
34 | + ); |
|
35 | + $ingredients = $this->ingredients_client->ingredients( $terms ); |
|
36 | + |
|
37 | + foreach ( $ingredients as $key => $value ) { |
|
38 | + $term = get_term_by( 'name', $key, 'wprm_ingredient' ); |
|
39 | + if ( ! isset( $term ) ) { |
|
40 | + continue; |
|
41 | + } |
|
42 | + update_term_meta( $term->term_id, '_wl_jsonld', wp_slash( $value ) ); |
|
43 | + |
|
44 | + /** |
|
45 | + * @@todo update notification with progress |
|
46 | + */ |
|
47 | + } |
|
48 | + |
|
49 | + // Clean up caches. |
|
50 | + do_action( 'wl_ttl_cache_cleaner__flush' ); |
|
51 | + |
|
52 | + /** |
|
53 | + * @@todo add notification that procedure is complete, with information about the number of processed items vs |
|
54 | + * total items |
|
55 | + */ |
|
56 | + $count_terms = count( $terms ); |
|
57 | + $count_lifted_terms = count( $ingredients ); |
|
58 | + /* translators: 1: The number of lifted ingredients, 2: The total number of ingredients. */ |
|
59 | + $this->notices->queue( 'info', sprintf( __( 'WordLift detected WP Recipe Maker and, it lifted %1$d of %2$d ingredient(s).', 'wordlift' ), $count_lifted_terms, $count_terms ) ); |
|
60 | + } |
|
61 | 61 | } |
@@ -14,32 +14,32 @@ discard block |
||
14 | 14 | */ |
15 | 15 | private $notices; |
16 | 16 | |
17 | - public function __construct( Ingredients_Client $ingredients_client, Notices $notices ) { |
|
17 | + public function __construct(Ingredients_Client $ingredients_client, Notices $notices) { |
|
18 | 18 | $this->ingredients_client = $ingredients_client; |
19 | 19 | $this->notices = $notices; |
20 | 20 | } |
21 | 21 | |
22 | 22 | public function run() { |
23 | - $this->notices->queue( 'info', __( 'WordLift detected WP Recipe Maker and, it is lifting the ingredients...', 'wordlift' ) ); |
|
23 | + $this->notices->queue('info', __('WordLift detected WP Recipe Maker and, it is lifting the ingredients...', 'wordlift')); |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * @var string[] $terms |
27 | 27 | */ |
28 | - $terms = get_terms( |
|
28 | + $terms = get_terms( |
|
29 | 29 | array( |
30 | 30 | 'taxonomy' => 'wprm_ingredient', |
31 | 31 | 'fields' => 'names', |
32 | 32 | 'hide_empty' => false, |
33 | 33 | ) |
34 | 34 | ); |
35 | - $ingredients = $this->ingredients_client->ingredients( $terms ); |
|
35 | + $ingredients = $this->ingredients_client->ingredients($terms); |
|
36 | 36 | |
37 | - foreach ( $ingredients as $key => $value ) { |
|
38 | - $term = get_term_by( 'name', $key, 'wprm_ingredient' ); |
|
39 | - if ( ! isset( $term ) ) { |
|
37 | + foreach ($ingredients as $key => $value) { |
|
38 | + $term = get_term_by('name', $key, 'wprm_ingredient'); |
|
39 | + if ( ! isset($term)) { |
|
40 | 40 | continue; |
41 | 41 | } |
42 | - update_term_meta( $term->term_id, '_wl_jsonld', wp_slash( $value ) ); |
|
42 | + update_term_meta($term->term_id, '_wl_jsonld', wp_slash($value)); |
|
43 | 43 | |
44 | 44 | /** |
45 | 45 | * @@todo update notification with progress |
@@ -47,15 +47,15 @@ discard block |
||
47 | 47 | } |
48 | 48 | |
49 | 49 | // Clean up caches. |
50 | - do_action( 'wl_ttl_cache_cleaner__flush' ); |
|
50 | + do_action('wl_ttl_cache_cleaner__flush'); |
|
51 | 51 | |
52 | 52 | /** |
53 | 53 | * @@todo add notification that procedure is complete, with information about the number of processed items vs |
54 | 54 | * total items |
55 | 55 | */ |
56 | - $count_terms = count( $terms ); |
|
57 | - $count_lifted_terms = count( $ingredients ); |
|
56 | + $count_terms = count($terms); |
|
57 | + $count_lifted_terms = count($ingredients); |
|
58 | 58 | /* translators: 1: The number of lifted ingredients, 2: The total number of ingredients. */ |
59 | - $this->notices->queue( 'info', sprintf( __( 'WordLift detected WP Recipe Maker and, it lifted %1$d of %2$d ingredient(s).', 'wordlift' ), $count_lifted_terms, $count_terms ) ); |
|
59 | + $this->notices->queue('info', sprintf(__('WordLift detected WP Recipe Maker and, it lifted %1$d of %2$d ingredient(s).', 'wordlift'), $count_lifted_terms, $count_terms)); |
|
60 | 60 | } |
61 | 61 | } |
@@ -15,67 +15,67 @@ |
||
15 | 15 | */ |
16 | 16 | class Wordlift_Website_Jsonld_Converter extends Wordlift_Post_To_Jsonld_Converter { |
17 | 17 | |
18 | - /** |
|
19 | - * Convert the home/blog page to a JSON-LD array. |
|
20 | - * |
|
21 | - * @return array A JSON-LD array. |
|
22 | - * @since 3.14.0 |
|
23 | - */ |
|
24 | - public function create_schema() { |
|
18 | + /** |
|
19 | + * Convert the home/blog page to a JSON-LD array. |
|
20 | + * |
|
21 | + * @return array A JSON-LD array. |
|
22 | + * @since 3.14.0 |
|
23 | + */ |
|
24 | + public function create_schema() { |
|
25 | 25 | |
26 | - // Create new jsonld. |
|
27 | - $home_url = home_url( '/' ); |
|
26 | + // Create new jsonld. |
|
27 | + $home_url = home_url( '/' ); |
|
28 | 28 | |
29 | - $jsonld = array( |
|
30 | - '@context' => 'http://schema.org', |
|
31 | - '@type' => 'WebSite', |
|
32 | - '@id' => "$home_url#website", |
|
33 | - 'name' => html_entity_decode( get_bloginfo( 'name' ), ENT_QUOTES ), |
|
34 | - 'alternateName' => Wordlift_Configuration_Service::get_instance()->get_alternate_name(), |
|
35 | - 'url' => $home_url, |
|
36 | - ); |
|
29 | + $jsonld = array( |
|
30 | + '@context' => 'http://schema.org', |
|
31 | + '@type' => 'WebSite', |
|
32 | + '@id' => "$home_url#website", |
|
33 | + 'name' => html_entity_decode( get_bloginfo( 'name' ), ENT_QUOTES ), |
|
34 | + 'alternateName' => Wordlift_Configuration_Service::get_instance()->get_alternate_name(), |
|
35 | + 'url' => $home_url, |
|
36 | + ); |
|
37 | 37 | |
38 | - // Add publisher information. |
|
39 | - $this->set_publisher( $jsonld ); |
|
38 | + // Add publisher information. |
|
39 | + $this->set_publisher( $jsonld ); |
|
40 | 40 | |
41 | - // Add search action. |
|
42 | - $this->set_search_action( $jsonld ); |
|
41 | + // Add search action. |
|
42 | + $this->set_search_action( $jsonld ); |
|
43 | 43 | |
44 | - /** |
|
45 | - * Call the `wl_website_jsonld` filter. |
|
46 | - * |
|
47 | - * @param array $jsonld The JSON-LD structure. |
|
48 | - * |
|
49 | - * @since 3.14.0 |
|
50 | - * |
|
51 | - * @api |
|
52 | - */ |
|
53 | - return apply_filters( 'wl_website_jsonld', $jsonld ); |
|
54 | - } |
|
44 | + /** |
|
45 | + * Call the `wl_website_jsonld` filter. |
|
46 | + * |
|
47 | + * @param array $jsonld The JSON-LD structure. |
|
48 | + * |
|
49 | + * @since 3.14.0 |
|
50 | + * |
|
51 | + * @api |
|
52 | + */ |
|
53 | + return apply_filters( 'wl_website_jsonld', $jsonld ); |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * Add SearchAction part to the schema |
|
58 | - * |
|
59 | - * @param array $params The parameters array. |
|
60 | - * |
|
61 | - * @since 3.14.0 |
|
62 | - */ |
|
63 | - private function set_search_action( &$params ) { |
|
64 | - /** |
|
65 | - * Filter: 'wl_jsonld_search_url' - Allows filtering of the search URL. |
|
66 | - * |
|
67 | - * @since 3.14.0 |
|
68 | - * @api string $search_url The search URL for this site with a `{search_term_string}` variable. |
|
69 | - */ |
|
70 | - $search_url = apply_filters( 'wl_jsonld_search_url', home_url( '/' ) . '?s={search_term_string}' ); |
|
56 | + /** |
|
57 | + * Add SearchAction part to the schema |
|
58 | + * |
|
59 | + * @param array $params The parameters array. |
|
60 | + * |
|
61 | + * @since 3.14.0 |
|
62 | + */ |
|
63 | + private function set_search_action( &$params ) { |
|
64 | + /** |
|
65 | + * Filter: 'wl_jsonld_search_url' - Allows filtering of the search URL. |
|
66 | + * |
|
67 | + * @since 3.14.0 |
|
68 | + * @api string $search_url The search URL for this site with a `{search_term_string}` variable. |
|
69 | + */ |
|
70 | + $search_url = apply_filters( 'wl_jsonld_search_url', home_url( '/' ) . '?s={search_term_string}' ); |
|
71 | 71 | |
72 | - // Add search action |
|
73 | - $params['potentialAction'] = array( |
|
74 | - '@type' => 'SearchAction', |
|
75 | - 'target' => $search_url, |
|
76 | - 'query-input' => 'required name=search_term_string', |
|
77 | - ); |
|
72 | + // Add search action |
|
73 | + $params['potentialAction'] = array( |
|
74 | + '@type' => 'SearchAction', |
|
75 | + 'target' => $search_url, |
|
76 | + 'query-input' => 'required name=search_term_string', |
|
77 | + ); |
|
78 | 78 | |
79 | - } |
|
79 | + } |
|
80 | 80 | |
81 | 81 | } |
@@ -24,22 +24,22 @@ discard block |
||
24 | 24 | public function create_schema() { |
25 | 25 | |
26 | 26 | // Create new jsonld. |
27 | - $home_url = home_url( '/' ); |
|
27 | + $home_url = home_url('/'); |
|
28 | 28 | |
29 | 29 | $jsonld = array( |
30 | 30 | '@context' => 'http://schema.org', |
31 | 31 | '@type' => 'WebSite', |
32 | 32 | '@id' => "$home_url#website", |
33 | - 'name' => html_entity_decode( get_bloginfo( 'name' ), ENT_QUOTES ), |
|
33 | + 'name' => html_entity_decode(get_bloginfo('name'), ENT_QUOTES), |
|
34 | 34 | 'alternateName' => Wordlift_Configuration_Service::get_instance()->get_alternate_name(), |
35 | 35 | 'url' => $home_url, |
36 | 36 | ); |
37 | 37 | |
38 | 38 | // Add publisher information. |
39 | - $this->set_publisher( $jsonld ); |
|
39 | + $this->set_publisher($jsonld); |
|
40 | 40 | |
41 | 41 | // Add search action. |
42 | - $this->set_search_action( $jsonld ); |
|
42 | + $this->set_search_action($jsonld); |
|
43 | 43 | |
44 | 44 | /** |
45 | 45 | * Call the `wl_website_jsonld` filter. |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * |
51 | 51 | * @api |
52 | 52 | */ |
53 | - return apply_filters( 'wl_website_jsonld', $jsonld ); |
|
53 | + return apply_filters('wl_website_jsonld', $jsonld); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -60,14 +60,14 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @since 3.14.0 |
62 | 62 | */ |
63 | - private function set_search_action( &$params ) { |
|
63 | + private function set_search_action(&$params) { |
|
64 | 64 | /** |
65 | 65 | * Filter: 'wl_jsonld_search_url' - Allows filtering of the search URL. |
66 | 66 | * |
67 | 67 | * @since 3.14.0 |
68 | 68 | * @api string $search_url The search URL for this site with a `{search_term_string}` variable. |
69 | 69 | */ |
70 | - $search_url = apply_filters( 'wl_jsonld_search_url', home_url( '/' ) . '?s={search_term_string}' ); |
|
70 | + $search_url = apply_filters('wl_jsonld_search_url', home_url('/').'?s={search_term_string}'); |
|
71 | 71 | |
72 | 72 | // Add search action |
73 | 73 | $params['potentialAction'] = array( |