@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | use Wordlift\Api\Default_Api_Service; |
| 14 | 14 | |
| 15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 15 | +if ( ! defined('ABSPATH')) { |
|
| 16 | 16 | exit; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -152,10 +152,10 @@ discard block |
||
| 152 | 152 | */ |
| 153 | 153 | protected function __construct() { |
| 154 | 154 | |
| 155 | - $this->log = Wordlift_Log_Service::get_logger( get_class() ); |
|
| 155 | + $this->log = Wordlift_Log_Service::get_logger(get_class()); |
|
| 156 | 156 | |
| 157 | 157 | // Sync some configuration properties when key is validated. |
| 158 | - add_action( 'wl_key_validation_response', array( $this, 'sync' ) ); |
|
| 158 | + add_action('wl_key_validation_response', array($this, 'sync')); |
|
| 159 | 159 | |
| 160 | 160 | } |
| 161 | 161 | |
@@ -164,15 +164,15 @@ discard block |
||
| 164 | 164 | * |
| 165 | 165 | * @return void |
| 166 | 166 | */ |
| 167 | - public function sync( $response ) { |
|
| 168 | - if ( ! $response->is_success() ) { |
|
| 167 | + public function sync($response) { |
|
| 168 | + if ( ! $response->is_success()) { |
|
| 169 | 169 | return; |
| 170 | 170 | } |
| 171 | - $data = json_decode( $response->get_body(), true ); |
|
| 172 | - if ( ! is_array( $data ) || ! array_key_exists( 'networkDatasetId', $data ) ) { |
|
| 171 | + $data = json_decode($response->get_body(), true); |
|
| 172 | + if ( ! is_array($data) || ! array_key_exists('networkDatasetId', $data)) { |
|
| 173 | 173 | return; |
| 174 | 174 | } |
| 175 | - $this->set_network_dataset_ids( $data['networkDatasetId'] ); |
|
| 175 | + $this->set_network_dataset_ids($data['networkDatasetId']); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | /** |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | */ |
| 194 | 194 | public static function get_instance() { |
| 195 | 195 | |
| 196 | - if ( ! isset( self::$instance ) ) { |
|
| 196 | + if ( ! isset(self::$instance)) { |
|
| 197 | 197 | self::$instance = new self(); |
| 198 | 198 | } |
| 199 | 199 | |
@@ -211,11 +211,11 @@ discard block |
||
| 211 | 211 | * @return mixed The configuration value or the default value if not found. |
| 212 | 212 | * @since 3.6.0 |
| 213 | 213 | */ |
| 214 | - private function get( $option, $key, $default = '' ) { |
|
| 214 | + private function get($option, $key, $default = '') { |
|
| 215 | 215 | |
| 216 | - $options = get_option( $option, array() ); |
|
| 216 | + $options = get_option($option, array()); |
|
| 217 | 217 | |
| 218 | - return isset( $options[ $key ] ) ? $options[ $key ] : $default; |
|
| 218 | + return isset($options[$key]) ? $options[$key] : $default; |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | /** |
@@ -227,12 +227,12 @@ discard block |
||
| 227 | 227 | * |
| 228 | 228 | * @since 3.9.0 |
| 229 | 229 | */ |
| 230 | - private function set( $option, $key, $value ) { |
|
| 230 | + private function set($option, $key, $value) { |
|
| 231 | 231 | |
| 232 | - $values = get_option( $option ); |
|
| 233 | - $values = isset( $values ) ? $values : array(); |
|
| 234 | - $values[ $key ] = $value; |
|
| 235 | - update_option( $option, $values ); |
|
| 232 | + $values = get_option($option); |
|
| 233 | + $values = isset($values) ? $values : array(); |
|
| 234 | + $values[$key] = $value; |
|
| 235 | + update_option($option, $values); |
|
| 236 | 236 | |
| 237 | 237 | } |
| 238 | 238 | |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | */ |
| 245 | 245 | public function get_entity_base_path() { |
| 246 | 246 | |
| 247 | - return $this->get( 'wl_general_settings', self::ENTITY_BASE_PATH_KEY, 'entity' ); |
|
| 247 | + return $this->get('wl_general_settings', self::ENTITY_BASE_PATH_KEY, 'entity'); |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | /** |
@@ -254,9 +254,9 @@ discard block |
||
| 254 | 254 | * |
| 255 | 255 | * @since 3.9.0 |
| 256 | 256 | */ |
| 257 | - public function set_entity_base_path( $value ) { |
|
| 257 | + public function set_entity_base_path($value) { |
|
| 258 | 258 | |
| 259 | - $this->set( 'wl_general_settings', self::ENTITY_BASE_PATH_KEY, $value ); |
|
| 259 | + $this->set('wl_general_settings', self::ENTITY_BASE_PATH_KEY, $value); |
|
| 260 | 260 | |
| 261 | 261 | } |
| 262 | 262 | |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | */ |
| 269 | 269 | public function is_skip_wizard() { |
| 270 | 270 | |
| 271 | - return $this->get( 'wl_general_settings', self::SKIP_WIZARD, false ); |
|
| 271 | + return $this->get('wl_general_settings', self::SKIP_WIZARD, false); |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | /** |
@@ -278,9 +278,9 @@ discard block |
||
| 278 | 278 | * |
| 279 | 279 | * @since 3.9.0 |
| 280 | 280 | */ |
| 281 | - public function set_skip_wizard( $value ) { |
|
| 281 | + public function set_skip_wizard($value) { |
|
| 282 | 282 | |
| 283 | - $this->set( 'wl_general_settings', self::SKIP_WIZARD, true === $value ); |
|
| 283 | + $this->set('wl_general_settings', self::SKIP_WIZARD, true === $value); |
|
| 284 | 284 | |
| 285 | 285 | } |
| 286 | 286 | |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | */ |
| 293 | 293 | public function get_key() { |
| 294 | 294 | |
| 295 | - return $this->get( 'wl_general_settings', self::KEY, '' ); |
|
| 295 | + return $this->get('wl_general_settings', self::KEY, ''); |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | /** |
@@ -302,9 +302,9 @@ discard block |
||
| 302 | 302 | * |
| 303 | 303 | * @since 3.9.0 |
| 304 | 304 | */ |
| 305 | - public function set_key( $value ) { |
|
| 305 | + public function set_key($value) { |
|
| 306 | 306 | |
| 307 | - $this->set( 'wl_general_settings', self::KEY, $value ); |
|
| 307 | + $this->set('wl_general_settings', self::KEY, $value); |
|
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | /** |
@@ -318,11 +318,11 @@ discard block |
||
| 318 | 318 | public function get_language_code() { |
| 319 | 319 | |
| 320 | 320 | $language = get_locale(); |
| 321 | - if ( ! $language ) { |
|
| 321 | + if ( ! $language) { |
|
| 322 | 322 | return 'en'; |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | - return substr( $language, 0, 2 ); |
|
| 325 | + return substr($language, 0, 2); |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | /** |
@@ -337,9 +337,9 @@ discard block |
||
| 337 | 337 | * |
| 338 | 338 | * @since 3.9.0 |
| 339 | 339 | */ |
| 340 | - public function set_language_code( $value ) { |
|
| 340 | + public function set_language_code($value) { |
|
| 341 | 341 | |
| 342 | - $this->set( 'wl_general_settings', self::LANGUAGE, $value ); |
|
| 342 | + $this->set('wl_general_settings', self::LANGUAGE, $value); |
|
| 343 | 343 | |
| 344 | 344 | } |
| 345 | 345 | |
@@ -350,9 +350,9 @@ discard block |
||
| 350 | 350 | * |
| 351 | 351 | * @since 3.19.0 |
| 352 | 352 | */ |
| 353 | - public function set_diagnostic_preferences( $value ) { |
|
| 353 | + public function set_diagnostic_preferences($value) { |
|
| 354 | 354 | |
| 355 | - $this->set( 'wl_general_settings', self::SEND_DIAGNOSTIC, $value ); |
|
| 355 | + $this->set('wl_general_settings', self::SEND_DIAGNOSTIC, $value); |
|
| 356 | 356 | |
| 357 | 357 | } |
| 358 | 358 | |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | */ |
| 364 | 364 | public function get_diagnostic_preferences() { |
| 365 | 365 | |
| 366 | - return $this->get( 'wl_general_settings', self::SEND_DIAGNOSTIC, 'no' ); |
|
| 366 | + return $this->get('wl_general_settings', self::SEND_DIAGNOSTIC, 'no'); |
|
| 367 | 367 | } |
| 368 | 368 | |
| 369 | 369 | /** |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | */ |
| 375 | 375 | public function get_country_code() { |
| 376 | 376 | |
| 377 | - return $this->get( 'wl_general_settings', self::COUNTRY_CODE, 'us' ); |
|
| 377 | + return $this->get('wl_general_settings', self::COUNTRY_CODE, 'us'); |
|
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | /** |
@@ -384,9 +384,9 @@ discard block |
||
| 384 | 384 | * |
| 385 | 385 | * @since 3.18.0 |
| 386 | 386 | */ |
| 387 | - public function set_country_code( $value ) { |
|
| 387 | + public function set_country_code($value) { |
|
| 388 | 388 | |
| 389 | - $this->set( 'wl_general_settings', self::COUNTRY_CODE, $value ); |
|
| 389 | + $this->set('wl_general_settings', self::COUNTRY_CODE, $value); |
|
| 390 | 390 | |
| 391 | 391 | } |
| 392 | 392 | |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | * @since 3.38.6 |
| 400 | 400 | */ |
| 401 | 401 | public function get_alternate_name() { |
| 402 | - return $this->get( 'wl_general_settings', self::ALTERNATE_NAME ); |
|
| 402 | + return $this->get('wl_general_settings', self::ALTERNATE_NAME); |
|
| 403 | 403 | } |
| 404 | 404 | |
| 405 | 405 | /** |
@@ -409,9 +409,9 @@ discard block |
||
| 409 | 409 | * |
| 410 | 410 | * @since 3.38.6 |
| 411 | 411 | */ |
| 412 | - public function set_alternate_name( $value ) { |
|
| 412 | + public function set_alternate_name($value) { |
|
| 413 | 413 | |
| 414 | - $this->set( 'wl_general_settings', self::ALTERNATE_NAME, wp_strip_all_tags( $value ) ); |
|
| 414 | + $this->set('wl_general_settings', self::ALTERNATE_NAME, wp_strip_all_tags($value)); |
|
| 415 | 415 | |
| 416 | 416 | } |
| 417 | 417 | |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | */ |
| 427 | 427 | public function get_publisher_id() { |
| 428 | 428 | |
| 429 | - return $this->get( 'wl_general_settings', self::PUBLISHER_ID, null ); |
|
| 429 | + return $this->get('wl_general_settings', self::PUBLISHER_ID, null); |
|
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | /** |
@@ -436,9 +436,9 @@ discard block |
||
| 436 | 436 | * |
| 437 | 437 | * @since 3.9.0 |
| 438 | 438 | */ |
| 439 | - public function set_publisher_id( $value ) { |
|
| 439 | + public function set_publisher_id($value) { |
|
| 440 | 440 | |
| 441 | - $this->set( 'wl_general_settings', self::PUBLISHER_ID, $value ); |
|
| 441 | + $this->set('wl_general_settings', self::PUBLISHER_ID, $value); |
|
| 442 | 442 | |
| 443 | 443 | } |
| 444 | 444 | |
@@ -451,8 +451,8 @@ discard block |
||
| 451 | 451 | */ |
| 452 | 452 | public function get_dataset_uri() { |
| 453 | 453 | |
| 454 | - if ( apply_filters( 'wl_feature__enable__dataset', true ) ) { |
|
| 455 | - return $this->get( 'wl_advanced_settings', self::DATASET_URI, null ); |
|
| 454 | + if (apply_filters('wl_feature__enable__dataset', true)) { |
|
| 455 | + return $this->get('wl_advanced_settings', self::DATASET_URI, null); |
|
| 456 | 456 | } else { |
| 457 | 457 | return null; |
| 458 | 458 | } |
@@ -465,9 +465,9 @@ discard block |
||
| 465 | 465 | * |
| 466 | 466 | * @since 3.10.0 |
| 467 | 467 | */ |
| 468 | - public function set_dataset_uri( $value ) { |
|
| 468 | + public function set_dataset_uri($value) { |
|
| 469 | 469 | |
| 470 | - $this->set( 'wl_advanced_settings', self::DATASET_URI, $value ); |
|
| 470 | + $this->set('wl_advanced_settings', self::DATASET_URI, $value); |
|
| 471 | 471 | } |
| 472 | 472 | |
| 473 | 473 | /** |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | */ |
| 479 | 479 | public function get_package_type() { |
| 480 | 480 | |
| 481 | - return $this->get( 'wl_advanced_settings', self::PACKAGE_TYPE, null ); |
|
| 481 | + return $this->get('wl_advanced_settings', self::PACKAGE_TYPE, null); |
|
| 482 | 482 | } |
| 483 | 483 | |
| 484 | 484 | /** |
@@ -488,8 +488,8 @@ discard block |
||
| 488 | 488 | * |
| 489 | 489 | * @since 3.20.0 |
| 490 | 490 | */ |
| 491 | - public function set_package_type( $value ) { |
|
| 492 | - $this->set( 'wl_advanced_settings', self::PACKAGE_TYPE, $value ); |
|
| 491 | + public function set_package_type($value) { |
|
| 492 | + $this->set('wl_advanced_settings', self::PACKAGE_TYPE, $value); |
|
| 493 | 493 | } |
| 494 | 494 | |
| 495 | 495 | /** |
@@ -504,11 +504,11 @@ discard block |
||
| 504 | 504 | * @param array $old_value The old settings. |
| 505 | 505 | * @param array $new_value The new settings. |
| 506 | 506 | */ |
| 507 | - public function update_key( $old_value, $new_value ) { |
|
| 507 | + public function update_key($old_value, $new_value) { |
|
| 508 | 508 | |
| 509 | 509 | // Check the old key value and the new one. We're going to ask for the dataset URI only if the key has changed. |
| 510 | 510 | // $old_key = isset( $old_value['key'] ) ? $old_value['key'] : ''; |
| 511 | - $new_key = isset( $new_value['key'] ) ? trim( $new_value['key'] ) : ''; |
|
| 511 | + $new_key = isset($new_value['key']) ? trim($new_value['key']) : ''; |
|
| 512 | 512 | |
| 513 | 513 | // If the key hasn't changed, don't do anything. |
| 514 | 514 | // WARN The 'update_option' hook is fired only if the new and old value are not equal. |
@@ -517,14 +517,14 @@ discard block |
||
| 517 | 517 | // } |
| 518 | 518 | |
| 519 | 519 | // If the key is empty, empty the dataset URI. |
| 520 | - if ( '' === $new_key ) { |
|
| 521 | - $this->set_dataset_uri( '' ); |
|
| 520 | + if ('' === $new_key) { |
|
| 521 | + $this->set_dataset_uri(''); |
|
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | // make the request to the remote server. |
| 525 | - $this->get_remote_dataset_uri( $new_key ); |
|
| 525 | + $this->get_remote_dataset_uri($new_key); |
|
| 526 | 526 | |
| 527 | - do_action( 'wl_key_updated' ); |
|
| 527 | + do_action('wl_key_updated'); |
|
| 528 | 528 | |
| 529 | 529 | } |
| 530 | 530 | |
@@ -540,15 +540,15 @@ discard block |
||
| 540 | 540 | * |
| 541 | 541 | * @since 3.17.0 send the site URL and get the dataset URI. |
| 542 | 542 | */ |
| 543 | - public function get_remote_dataset_uri( $key ) { |
|
| 543 | + public function get_remote_dataset_uri($key) { |
|
| 544 | 544 | |
| 545 | - $this->log->trace( 'Getting the remote dataset URI and package type...' ); |
|
| 545 | + $this->log->trace('Getting the remote dataset URI and package type...'); |
|
| 546 | 546 | |
| 547 | - if ( empty( $key ) ) { |
|
| 548 | - $this->log->warn( 'Key set to empty value.' ); |
|
| 547 | + if (empty($key)) { |
|
| 548 | + $this->log->warn('Key set to empty value.'); |
|
| 549 | 549 | |
| 550 | - $this->set_dataset_uri( '' ); |
|
| 551 | - $this->set_package_type( null ); |
|
| 550 | + $this->set_dataset_uri(''); |
|
| 551 | + $this->set_package_type(null); |
|
| 552 | 552 | |
| 553 | 553 | return; |
| 554 | 554 | } |
@@ -562,15 +562,15 @@ discard block |
||
| 562 | 562 | * |
| 563 | 563 | * @since 3.20.0 |
| 564 | 564 | */ |
| 565 | - $home_url = get_option( 'home' ); |
|
| 566 | - $site_url = apply_filters( 'wl_production_site_url', untrailingslashit( $home_url ) ); |
|
| 565 | + $home_url = get_option('home'); |
|
| 566 | + $site_url = apply_filters('wl_production_site_url', untrailingslashit($home_url)); |
|
| 567 | 567 | |
| 568 | 568 | // Build the URL. |
| 569 | 569 | $url = '/accounts' |
| 570 | - . '?key=' . rawurlencode( $key ) |
|
| 571 | - . '&url=' . rawurlencode( $site_url ) |
|
| 572 | - . '&country=' . $this->get_country_code() |
|
| 573 | - . '&language=' . $this->get_language_code(); |
|
| 570 | + . '?key='.rawurlencode($key) |
|
| 571 | + . '&url='.rawurlencode($site_url) |
|
| 572 | + . '&country='.$this->get_country_code() |
|
| 573 | + . '&language='.$this->get_language_code(); |
|
| 574 | 574 | |
| 575 | 575 | $api_service = Default_Api_Service::get_instance(); |
| 576 | 576 | /** |
@@ -580,32 +580,32 @@ discard block |
||
| 580 | 580 | $headers = array( |
| 581 | 581 | 'Authorization' => "Key $key", |
| 582 | 582 | ); |
| 583 | - $response = $api_service->request( 'PUT', $url, $headers )->get_response(); |
|
| 583 | + $response = $api_service->request('PUT', $url, $headers)->get_response(); |
|
| 584 | 584 | |
| 585 | 585 | // The response is an error. |
| 586 | - if ( is_wp_error( $response ) ) { |
|
| 587 | - $this->log->error( 'An error occurred setting the dataset URI: ' . $response->get_error_message() ); |
|
| 586 | + if (is_wp_error($response)) { |
|
| 587 | + $this->log->error('An error occurred setting the dataset URI: '.$response->get_error_message()); |
|
| 588 | 588 | |
| 589 | - $this->set_dataset_uri( '' ); |
|
| 590 | - $this->set_package_type( null ); |
|
| 589 | + $this->set_dataset_uri(''); |
|
| 590 | + $this->set_package_type(null); |
|
| 591 | 591 | |
| 592 | 592 | return; |
| 593 | 593 | } |
| 594 | 594 | |
| 595 | 595 | // The response is not OK. |
| 596 | - if ( ! is_array( $response ) || 200 !== (int) $response['response']['code'] ) { |
|
| 596 | + if ( ! is_array($response) || 200 !== (int) $response['response']['code']) { |
|
| 597 | 597 | $base_url = $api_service->get_base_url(); |
| 598 | 598 | |
| 599 | - if ( ! is_array( $response ) ) { |
|
| 599 | + if ( ! is_array($response)) { |
|
| 600 | 600 | // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_var_export |
| 601 | - $this->log->error( "Unexpected response when opening URL $base_url$url: " . var_export( $response, true ) ); |
|
| 601 | + $this->log->error("Unexpected response when opening URL $base_url$url: ".var_export($response, true)); |
|
| 602 | 602 | } else { |
| 603 | 603 | // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_var_export |
| 604 | - $this->log->error( "Unexpected status code when opening URL $base_url$url: " . $response['response']['code'] . "\n" . var_export( $response, true ) ); |
|
| 604 | + $this->log->error("Unexpected status code when opening URL $base_url$url: ".$response['response']['code']."\n".var_export($response, true)); |
|
| 605 | 605 | } |
| 606 | 606 | |
| 607 | - $this->set_dataset_uri( '' ); |
|
| 608 | - $this->set_package_type( null ); |
|
| 607 | + $this->set_dataset_uri(''); |
|
| 608 | + $this->set_package_type(null); |
|
| 609 | 609 | |
| 610 | 610 | return; |
| 611 | 611 | } |
@@ -615,20 +615,20 @@ discard block |
||
| 615 | 615 | * |
| 616 | 616 | * @since 3.20.0 |
| 617 | 617 | */ |
| 618 | - $json = json_decode( $response['body'] ); |
|
| 618 | + $json = json_decode($response['body']); |
|
| 619 | 619 | /** |
| 620 | 620 | * @since 3.27.7 |
| 621 | 621 | * Remove the trailing slash returned from the new platform api. |
| 622 | 622 | */ |
| 623 | 623 | // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase |
| 624 | - $dataset_uri = untrailingslashit( $json->datasetURI ); |
|
| 624 | + $dataset_uri = untrailingslashit($json->datasetURI); |
|
| 625 | 625 | // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase |
| 626 | - $package_type = isset( $json->packageType ) ? $json->packageType : null; |
|
| 626 | + $package_type = isset($json->packageType) ? $json->packageType : null; |
|
| 627 | 627 | |
| 628 | - $this->log->info( "Updating [ dataset uri :: $dataset_uri ][ package type :: $package_type ]..." ); |
|
| 628 | + $this->log->info("Updating [ dataset uri :: $dataset_uri ][ package type :: $package_type ]..."); |
|
| 629 | 629 | |
| 630 | - $this->set_dataset_uri( $dataset_uri ); |
|
| 631 | - $this->set_package_type( $package_type ); |
|
| 630 | + $this->set_dataset_uri($dataset_uri); |
|
| 631 | + $this->set_package_type($package_type); |
|
| 632 | 632 | } |
| 633 | 633 | |
| 634 | 634 | /** |
@@ -645,20 +645,20 @@ discard block |
||
| 645 | 645 | * @return mixed The same value in the $value parameter |
| 646 | 646 | * @since 3.12.0 |
| 647 | 647 | */ |
| 648 | - public function maybe_update_dataset_uri( $value, $old_value ) { |
|
| 648 | + public function maybe_update_dataset_uri($value, $old_value) { |
|
| 649 | 649 | |
| 650 | 650 | // Check the old key value and the new one. Here we're only handling the |
| 651 | 651 | // case where the key hasn't changed and the dataset URI isn't set. The |
| 652 | 652 | // other case, i.e. a new key is inserted, is handled at `update_key`. |
| 653 | - $old_key = isset( $old_value['key'] ) ? $old_value['key'] : ''; |
|
| 654 | - $new_key = isset( $value['key'] ) ? trim( $value['key'] ) : ''; |
|
| 653 | + $old_key = isset($old_value['key']) ? $old_value['key'] : ''; |
|
| 654 | + $new_key = isset($value['key']) ? trim($value['key']) : ''; |
|
| 655 | 655 | |
| 656 | 656 | $dataset_uri = $this->get_dataset_uri(); |
| 657 | 657 | |
| 658 | - if ( ! empty( $new_key ) && $new_key === $old_key && empty( $dataset_uri ) ) { |
|
| 658 | + if ( ! empty($new_key) && $new_key === $old_key && empty($dataset_uri)) { |
|
| 659 | 659 | |
| 660 | 660 | // make the request to the remote server to try to get the dataset uri. |
| 661 | - $this->get_remote_dataset_uri( $new_key ); |
|
| 661 | + $this->get_remote_dataset_uri($new_key); |
|
| 662 | 662 | } |
| 663 | 663 | |
| 664 | 664 | return $value; |
@@ -672,9 +672,9 @@ discard block |
||
| 672 | 672 | * @return string The API URI. |
| 673 | 673 | * @since 3.11.0 |
| 674 | 674 | */ |
| 675 | - public function get_accounts_by_key_dataset_uri( $key ) { |
|
| 675 | + public function get_accounts_by_key_dataset_uri($key) { |
|
| 676 | 676 | |
| 677 | - return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE . "accounts/key=$key/dataset_uri"; |
|
| 677 | + return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE."accounts/key=$key/dataset_uri"; |
|
| 678 | 678 | } |
| 679 | 679 | |
| 680 | 680 | /** |
@@ -685,7 +685,7 @@ discard block |
||
| 685 | 685 | */ |
| 686 | 686 | public function get_accounts() { |
| 687 | 687 | |
| 688 | - return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE . 'accounts'; |
|
| 688 | + return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE.'accounts'; |
|
| 689 | 689 | } |
| 690 | 690 | |
| 691 | 691 | /** |
@@ -696,7 +696,7 @@ discard block |
||
| 696 | 696 | */ |
| 697 | 697 | public function is_link_by_default() { |
| 698 | 698 | |
| 699 | - return 'yes' === $this->get( 'wl_general_settings', self::LINK_BY_DEFAULT, 'yes' ); |
|
| 699 | + return 'yes' === $this->get('wl_general_settings', self::LINK_BY_DEFAULT, 'yes'); |
|
| 700 | 700 | } |
| 701 | 701 | |
| 702 | 702 | /** |
@@ -706,9 +706,9 @@ discard block |
||
| 706 | 706 | * |
| 707 | 707 | * @since 3.13.0 |
| 708 | 708 | */ |
| 709 | - public function set_link_by_default( $value ) { |
|
| 709 | + public function set_link_by_default($value) { |
|
| 710 | 710 | |
| 711 | - $this->set( 'wl_general_settings', self::LINK_BY_DEFAULT, true === $value ? 'yes' : 'no' ); |
|
| 711 | + $this->set('wl_general_settings', self::LINK_BY_DEFAULT, true === $value ? 'yes' : 'no'); |
|
| 712 | 712 | } |
| 713 | 713 | |
| 714 | 714 | /** |
@@ -718,7 +718,7 @@ discard block |
||
| 718 | 718 | * @since 3.21.0 |
| 719 | 719 | */ |
| 720 | 720 | public function is_analytics_enable() { |
| 721 | - return 'yes' === $this->get( 'wl_analytics_settings', self::ANALYTICS_ENABLE, 'no' ); |
|
| 721 | + return 'yes' === $this->get('wl_analytics_settings', self::ANALYTICS_ENABLE, 'no'); |
|
| 722 | 722 | } |
| 723 | 723 | |
| 724 | 724 | /** |
@@ -728,9 +728,9 @@ discard block |
||
| 728 | 728 | * |
| 729 | 729 | * @since 3.21.0 |
| 730 | 730 | */ |
| 731 | - public function set_is_analytics_enable( $value ) { |
|
| 731 | + public function set_is_analytics_enable($value) { |
|
| 732 | 732 | |
| 733 | - $this->set( 'wl_general_settings', self::ANALYTICS_ENABLE, true === $value ? 'yes' : 'no' ); |
|
| 733 | + $this->set('wl_general_settings', self::ANALYTICS_ENABLE, true === $value ? 'yes' : 'no'); |
|
| 734 | 734 | } |
| 735 | 735 | |
| 736 | 736 | /** |
@@ -740,7 +740,7 @@ discard block |
||
| 740 | 740 | * @since 3.21.0 |
| 741 | 741 | */ |
| 742 | 742 | public function get_analytics_entity_uri_dimension() { |
| 743 | - return (int) $this->get( 'wl_analytics_settings', self::ANALYTICS_ENTITY_URI_DIMENSION, 1 ); |
|
| 743 | + return (int) $this->get('wl_analytics_settings', self::ANALYTICS_ENTITY_URI_DIMENSION, 1); |
|
| 744 | 744 | } |
| 745 | 745 | |
| 746 | 746 | /** |
@@ -750,7 +750,7 @@ discard block |
||
| 750 | 750 | * @since 3.21.0 |
| 751 | 751 | */ |
| 752 | 752 | public function get_analytics_entity_type_dimension() { |
| 753 | - return $this->get( 'wl_analytics_settings', self::ANALYTICS_ENTITY_TYPE_DIMENSION, 2 ); |
|
| 753 | + return $this->get('wl_analytics_settings', self::ANALYTICS_ENTITY_TYPE_DIMENSION, 2); |
|
| 754 | 754 | } |
| 755 | 755 | |
| 756 | 756 | /** |
@@ -761,7 +761,7 @@ discard block |
||
| 761 | 761 | */ |
| 762 | 762 | public function get_autocomplete_url() { |
| 763 | 763 | |
| 764 | - return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE . 'autocomplete'; |
|
| 764 | + return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE.'autocomplete'; |
|
| 765 | 765 | |
| 766 | 766 | } |
| 767 | 767 | |
@@ -773,7 +773,7 @@ discard block |
||
| 773 | 773 | */ |
| 774 | 774 | public function get_deactivation_feedback_url() { |
| 775 | 775 | |
| 776 | - return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE . 'feedbacks'; |
|
| 776 | + return WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE.'feedbacks'; |
|
| 777 | 777 | |
| 778 | 778 | } |
| 779 | 779 | |
@@ -789,21 +789,21 @@ discard block |
||
| 789 | 789 | } |
| 790 | 790 | |
| 791 | 791 | public function get_network_dataset_ids() { |
| 792 | - return $this->get( 'wl_advanced_settings', self::NETWORK_DATASET_IDS, array() ); |
|
| 792 | + return $this->get('wl_advanced_settings', self::NETWORK_DATASET_IDS, array()); |
|
| 793 | 793 | } |
| 794 | 794 | |
| 795 | - public function set_network_dataset_ids( $network_dataset_ids ) { |
|
| 796 | - $this->set( 'wl_advanced_settings', self::NETWORK_DATASET_IDS, $network_dataset_ids ); |
|
| 795 | + public function set_network_dataset_ids($network_dataset_ids) { |
|
| 796 | + $this->set('wl_advanced_settings', self::NETWORK_DATASET_IDS, $network_dataset_ids); |
|
| 797 | 797 | } |
| 798 | 798 | |
| 799 | 799 | public function get_skip_installation_notice() { |
| 800 | 800 | |
| 801 | - return $this->get( 'wl_general_settings', self::SKIP_INSTALLATION_NOTICE, false ); |
|
| 801 | + return $this->get('wl_general_settings', self::SKIP_INSTALLATION_NOTICE, false); |
|
| 802 | 802 | } |
| 803 | 803 | |
| 804 | - public function set_skip_installation_notice( $value ) { |
|
| 804 | + public function set_skip_installation_notice($value) { |
|
| 805 | 805 | |
| 806 | - $this->set( 'wl_general_settings', self::SKIP_INSTALLATION_NOTICE, $value ); |
|
| 806 | + $this->set('wl_general_settings', self::SKIP_INSTALLATION_NOTICE, $value); |
|
| 807 | 807 | |
| 808 | 808 | } |
| 809 | 809 | |
@@ -813,16 +813,16 @@ discard block |
||
| 813 | 813 | * @return false|string |
| 814 | 814 | */ |
| 815 | 815 | public function get_override_website_url() { |
| 816 | - $value = $this->get( 'wl_general_settings', self::OVERRIDE_WEBSITE_URL, false ); |
|
| 817 | - if ( empty( $value ) ) { |
|
| 816 | + $value = $this->get('wl_general_settings', self::OVERRIDE_WEBSITE_URL, false); |
|
| 817 | + if (empty($value)) { |
|
| 818 | 818 | return false; |
| 819 | 819 | } |
| 820 | 820 | |
| 821 | - return untrailingslashit( $value ); |
|
| 821 | + return untrailingslashit($value); |
|
| 822 | 822 | } |
| 823 | 823 | |
| 824 | - public function set_override_website_url( $value ) { |
|
| 825 | - $this->set( 'wl_general_settings', self::OVERRIDE_WEBSITE_URL, $value ); |
|
| 824 | + public function set_override_website_url($value) { |
|
| 825 | + $this->set('wl_general_settings', self::OVERRIDE_WEBSITE_URL, $value); |
|
| 826 | 826 | } |
| 827 | 827 | |
| 828 | 828 | } |
@@ -45,11 +45,11 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | protected function __construct() { |
| 47 | 47 | |
| 48 | - $this->log = Wordlift_Log_Service::get_logger( get_class() ); |
|
| 48 | + $this->log = Wordlift_Log_Service::get_logger(get_class()); |
|
| 49 | 49 | |
| 50 | 50 | // Add a filter to the `rest_post_dispatch` filter to add the wl_entity_url meta as `wl:entity_url`. |
| 51 | - add_filter( 'rest_post_dispatch', array( $this, 'rest_post_dispatch' ) ); |
|
| 52 | - add_filter( 'wl_content_service__post__not_found', array( $this, 'content_service__post__not_found' ), 10, 2 ); |
|
| 51 | + add_filter('rest_post_dispatch', array($this, 'rest_post_dispatch')); |
|
| 52 | + add_filter('wl_content_service__post__not_found', array($this, 'content_service__post__not_found'), 10, 2); |
|
| 53 | 53 | |
| 54 | 54 | } |
| 55 | 55 | |
@@ -70,9 +70,9 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | public static function get_instance() { |
| 72 | 72 | |
| 73 | - if ( ! isset( self::$instance ) ) { |
|
| 74 | - $entity_uri_cache_service = new Wordlift_File_Cache_Service( WL_TEMP_DIR . 'entity_uri/' ); |
|
| 75 | - self::$instance = new Wordlift_Cached_Entity_Uri_Service( $entity_uri_cache_service ); |
|
| 73 | + if ( ! isset(self::$instance)) { |
|
| 74 | + $entity_uri_cache_service = new Wordlift_File_Cache_Service(WL_TEMP_DIR.'entity_uri/'); |
|
| 75 | + self::$instance = new Wordlift_Cached_Entity_Uri_Service($entity_uri_cache_service); |
|
| 76 | 76 | |
| 77 | 77 | } |
| 78 | 78 | |
@@ -87,8 +87,8 @@ discard block |
||
| 87 | 87 | * |
| 88 | 88 | * @return false|int |
| 89 | 89 | */ |
| 90 | - public function content_service__post__not_found( $post, $uri ) { |
|
| 91 | - return $this->get_post_id_from_url( $uri ); |
|
| 90 | + public function content_service__post__not_found($post, $uri) { |
|
| 91 | + return $this->get_post_id_from_url($uri); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | /** |
@@ -101,18 +101,18 @@ discard block |
||
| 101 | 101 | * |
| 102 | 102 | * @since 3.16.3 |
| 103 | 103 | */ |
| 104 | - public function preload_uris( $uris ) { |
|
| 104 | + public function preload_uris($uris) { |
|
| 105 | 105 | |
| 106 | 106 | // Bail out if there are no URIs. |
| 107 | - if ( 0 === count( $uris ) ) { |
|
| 107 | + if (0 === count($uris)) { |
|
| 108 | 108 | return; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - $this->log->trace( 'Preloading ' . count( $uris ) . ' URI(s)...' ); |
|
| 111 | + $this->log->trace('Preloading '.count($uris).' URI(s)...'); |
|
| 112 | 112 | |
| 113 | 113 | global $wpdb; |
| 114 | - $in_post_types = implode( "','", array_map( 'esc_sql', Wordlift_Entity_Service::valid_entity_post_types() ) ); |
|
| 115 | - $in_entity_uris = implode( "','", array_map( 'esc_sql', $uris ) ); |
|
| 114 | + $in_post_types = implode("','", array_map('esc_sql', Wordlift_Entity_Service::valid_entity_post_types())); |
|
| 115 | + $in_entity_uris = implode("','", array_map('esc_sql', $uris)); |
|
| 116 | 116 | $sql = " |
| 117 | 117 | SELECT ID FROM $wpdb->posts p |
| 118 | 118 | INNER JOIN $wpdb->postmeta pm |
@@ -124,33 +124,33 @@ discard block |
||
| 124 | 124 | "; |
| 125 | 125 | |
| 126 | 126 | // Get the posts. |
| 127 | - $posts = $wpdb->get_col( $sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared |
|
| 127 | + $posts = $wpdb->get_col($sql); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared |
|
| 128 | 128 | |
| 129 | 129 | // Populate the array. We reinitialize the array on purpose because |
| 130 | 130 | // we don't want these data to long live. |
| 131 | 131 | $this->uri_to_post = array_reduce( |
| 132 | 132 | $posts, |
| 133 | - function ( $carry, $item ) { |
|
| 134 | - $uris = get_post_meta( $item, Wordlift_Schema_Service::FIELD_SAME_AS ); |
|
| 133 | + function($carry, $item) { |
|
| 134 | + $uris = get_post_meta($item, Wordlift_Schema_Service::FIELD_SAME_AS); |
|
| 135 | 135 | |
| 136 | 136 | $uri = Wordpress_Content_Service::get_instance() |
| 137 | - ->get_entity_id( Wordpress_Content_Id::create_post( $item ) ); |
|
| 137 | + ->get_entity_id(Wordpress_Content_Id::create_post($item)); |
|
| 138 | 138 | |
| 139 | - if ( isset( $uri ) ) { |
|
| 139 | + if (isset($uri)) { |
|
| 140 | 140 | $uris[] = $uri; |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | return $carry |
| 144 | 144 | // Get the URI related to the post and fill them with the item id. |
| 145 | - + array_fill_keys( $uris, $item ); |
|
| 145 | + + array_fill_keys($uris, $item); |
|
| 146 | 146 | }, |
| 147 | 147 | array() |
| 148 | 148 | ); |
| 149 | 149 | |
| 150 | 150 | // Add the not found URIs. |
| 151 | - $this->uri_to_post += array_fill_keys( $uris, null ); |
|
| 151 | + $this->uri_to_post += array_fill_keys($uris, null); |
|
| 152 | 152 | |
| 153 | - $this->log->debug( count( $this->uri_to_post ) . ' URI(s) preloaded.' ); |
|
| 153 | + $this->log->debug(count($this->uri_to_post).' URI(s) preloaded.'); |
|
| 154 | 154 | |
| 155 | 155 | } |
| 156 | 156 | |
@@ -173,17 +173,17 @@ discard block |
||
| 173 | 173 | * @return WP_Post|null A WP_Post instance or null if not found. |
| 174 | 174 | * @since 3.2.0 |
| 175 | 175 | */ |
| 176 | - public function get_entity( $uri ) { |
|
| 177 | - if ( ! isset( $uri ) ) { |
|
| 176 | + public function get_entity($uri) { |
|
| 177 | + if ( ! isset($uri)) { |
|
| 178 | 178 | return null; |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - $this->log->trace( "Getting an entity post for URI $uri..." ); |
|
| 181 | + $this->log->trace("Getting an entity post for URI $uri..."); |
|
| 182 | 182 | |
| 183 | - $content = Wordpress_Content_Service::get_instance()->get_by_entity_id_or_same_as( $uri ); |
|
| 183 | + $content = Wordpress_Content_Service::get_instance()->get_by_entity_id_or_same_as($uri); |
|
| 184 | 184 | |
| 185 | 185 | // Return null if the content isn't found or isn't a post. |
| 186 | - if ( ! isset( $content ) || ! is_a( $content->get_bag(), '\WP_Post' ) ) { |
|
| 186 | + if ( ! isset($content) || ! is_a($content->get_bag(), '\WP_Post')) { |
|
| 187 | 187 | return null; |
| 188 | 188 | } |
| 189 | 189 | |
@@ -198,9 +198,9 @@ discard block |
||
| 198 | 198 | * @return true if the uri internal to the current dataset otherwise false. |
| 199 | 199 | * @since 3.16.3 |
| 200 | 200 | */ |
| 201 | - public function is_internal( $uri ) { |
|
| 201 | + public function is_internal($uri) { |
|
| 202 | 202 | |
| 203 | - return ( 0 === strrpos( $uri, (string) Wordlift_Configuration_Service::get_instance()->get_dataset_uri() ) ); |
|
| 203 | + return (0 === strrpos($uri, (string) Wordlift_Configuration_Service::get_instance()->get_dataset_uri())); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | /** |
@@ -215,19 +215,19 @@ discard block |
||
| 215 | 215 | * |
| 216 | 216 | * @since 3.23.0 |
| 217 | 217 | */ |
| 218 | - public function rest_post_dispatch( $result ) { |
|
| 218 | + public function rest_post_dispatch($result) { |
|
| 219 | 219 | |
| 220 | 220 | // Get a reference to the actual data. |
| 221 | 221 | $data = &$result->data; |
| 222 | 222 | |
| 223 | 223 | // Bail out if we don't have the required parameters, or if the type is not a valid entity. |
| 224 | - if ( ! is_array( $data ) || ! isset( $data['id'] ) || ! isset( $data['type'] ) |
|
| 225 | - || ! Wordlift_Entity_Type_Service::is_valid_entity_post_type( $data['type'] ) ) { |
|
| 224 | + if ( ! is_array($data) || ! isset($data['id']) || ! isset($data['type']) |
|
| 225 | + || ! Wordlift_Entity_Type_Service::is_valid_entity_post_type($data['type'])) { |
|
| 226 | 226 | return $result; |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | // Add the `wl:entity_url`. |
| 230 | - $data['wl:entity_url'] = Wordlift_Entity_Service::get_instance()->get_uri( $data['id'] ); |
|
| 230 | + $data['wl:entity_url'] = Wordlift_Entity_Service::get_instance()->get_uri($data['id']); |
|
| 231 | 231 | |
| 232 | 232 | return $result; |
| 233 | 233 | } |
@@ -240,38 +240,38 @@ discard block |
||
| 240 | 240 | * |
| 241 | 241 | * @return int Post ID | bool false |
| 242 | 242 | */ |
| 243 | - public function get_post_id_from_url( $url ) { |
|
| 243 | + public function get_post_id_from_url($url) { |
|
| 244 | 244 | global $wp_rewrite; |
| 245 | 245 | |
| 246 | 246 | // We need to check that rewrite is available because the `url_to_postid` uses it and can raise an exception |
| 247 | 247 | // otherwise. |
| 248 | - if ( $wp_rewrite === null ) { |
|
| 248 | + if ($wp_rewrite === null) { |
|
| 249 | 249 | return false; |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | // Try url_to_postid |
| 253 | - $post_id = url_to_postid( htmlspecialchars_decode( $url ) ); |
|
| 254 | - if ( 0 !== $post_id ) { |
|
| 253 | + $post_id = url_to_postid(htmlspecialchars_decode($url)); |
|
| 254 | + if (0 !== $post_id) { |
|
| 255 | 255 | return $post_id; |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | - $parsed_url = wp_parse_url( $url ); |
|
| 258 | + $parsed_url = wp_parse_url($url); |
|
| 259 | 259 | |
| 260 | - if ( ! isset( $parsed_url['query'] ) ) { |
|
| 260 | + if ( ! isset($parsed_url['query'])) { |
|
| 261 | 261 | return false; |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | - parse_str( $parsed_url['query'], $parsed_query ); |
|
| 264 | + parse_str($parsed_url['query'], $parsed_query); |
|
| 265 | 265 | |
| 266 | 266 | // Try to parse WooCommerce non-pretty product URL |
| 267 | - if ( $parsed_query['product'] ) { |
|
| 267 | + if ($parsed_query['product']) { |
|
| 268 | 268 | $posts = get_posts( |
| 269 | 269 | array( |
| 270 | 270 | 'name' => $parsed_query['product'], |
| 271 | 271 | 'post_type' => 'product', |
| 272 | 272 | ) |
| 273 | 273 | ); |
| 274 | - if ( count( $posts ) > 0 ) { |
|
| 274 | + if (count($posts) > 0) { |
|
| 275 | 275 | return $posts[0]->ID; |
| 276 | 276 | } |
| 277 | 277 | } |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | * @return $this|Wordlift_Admin_Element |
| 44 | 44 | * @since 3.21.0 added the ability to use a $type arg. |
| 45 | 45 | */ |
| 46 | - public function render( $args ) { |
|
| 46 | + public function render($args) { |
|
| 47 | 47 | |
| 48 | 48 | /* |
| 49 | 49 | * Parse the arguments and merge with default values. |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | $pre_params = wp_parse_args( |
| 54 | 54 | $args, |
| 55 | 55 | array( |
| 56 | - 'id' => uniqid( 'wl-input-' ), |
|
| 56 | + 'id' => uniqid('wl-input-'), |
|
| 57 | 57 | 'value' => '', |
| 58 | 58 | 'readonly' => false, |
| 59 | 59 | 'css_class' => '', |
@@ -62,47 +62,47 @@ discard block |
||
| 62 | 62 | 'placeholder' => false, |
| 63 | 63 | ) |
| 64 | 64 | ); |
| 65 | - $params = apply_filters( 'wl_admin_input_element_params', $pre_params ); |
|
| 65 | + $params = apply_filters('wl_admin_input_element_params', $pre_params); |
|
| 66 | 66 | // allow different types of input - default to 'text'. |
| 67 | - $input_type = ! empty( $params['type'] ) ? $params['type'] : 'text'; |
|
| 67 | + $input_type = ! empty($params['type']) ? $params['type'] : 'text'; |
|
| 68 | 68 | ?> |
| 69 | 69 | |
| 70 | - <input type="<?php echo esc_attr( $input_type ); ?>" |
|
| 71 | - id="<?php echo esc_attr( $params['id'] ); ?>" |
|
| 72 | - name="<?php echo esc_attr( $params['name'] ); ?>" |
|
| 73 | - value="<?php echo esc_attr( $params['value'] ); ?>" |
|
| 70 | + <input type="<?php echo esc_attr($input_type); ?>" |
|
| 71 | + id="<?php echo esc_attr($params['id']); ?>" |
|
| 72 | + name="<?php echo esc_attr($params['name']); ?>" |
|
| 73 | + value="<?php echo esc_attr($params['value']); ?>" |
|
| 74 | 74 | <?php |
| 75 | - if ( $params['pattern'] ) { |
|
| 75 | + if ($params['pattern']) { |
|
| 76 | 76 | echo ' pattern="'; |
| 77 | - echo esc_attr( $params['pattern'] ); |
|
| 77 | + echo esc_attr($params['pattern']); |
|
| 78 | 78 | echo '"'; |
| 79 | 79 | } |
| 80 | 80 | ?> |
| 81 | 81 | <?php |
| 82 | - if ( $params['placeholder'] ) { |
|
| 82 | + if ($params['placeholder']) { |
|
| 83 | 83 | echo ' placeholder="'; |
| 84 | - echo esc_attr( $params['placeholder'] ); |
|
| 84 | + echo esc_attr($params['placeholder']); |
|
| 85 | 85 | echo '"'; |
| 86 | 86 | } |
| 87 | 87 | ?> |
| 88 | 88 | <?php |
| 89 | - if ( ! empty( $params['data'] ) && is_array( $params['data'] ) ) { |
|
| 90 | - foreach ( $params['data'] as $key => $value ) { |
|
| 91 | - echo 'data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '" '; |
|
| 89 | + if ( ! empty($params['data']) && is_array($params['data'])) { |
|
| 90 | + foreach ($params['data'] as $key => $value) { |
|
| 91 | + echo 'data-'.esc_attr($key).'="'.esc_attr($value).'" '; |
|
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | - if ( ! empty( $params['readonly'] ) ) { |
|
| 94 | + if ( ! empty($params['readonly'])) { |
|
| 95 | 95 | ?> |
| 96 | 96 | readonly="readonly" <?php } ?> |
| 97 | 97 | <?php |
| 98 | - if ( ! empty( $params['css_class'] ) ) { |
|
| 98 | + if ( ! empty($params['css_class'])) { |
|
| 99 | 99 | ?> |
| 100 | - class="<?php echo esc_attr( $params['css_class'] ); ?>" <?php } ?> |
|
| 100 | + class="<?php echo esc_attr($params['css_class']); ?>" <?php } ?> |
|
| 101 | 101 | /> |
| 102 | 102 | <?php |
| 103 | - if ( ! empty( $params['description'] ) ) { |
|
| 103 | + if ( ! empty($params['description'])) { |
|
| 104 | 104 | ?> |
| 105 | - <p><?php echo wp_kses( $params['description'], array( 'a' => array( 'href' => array() ) ) ); ?></p><?php } ?> |
|
| 105 | + <p><?php echo wp_kses($params['description'], array('a' => array('href' => array()))); ?></p><?php } ?> |
|
| 106 | 106 | |
| 107 | 107 | <?php |
| 108 | 108 | |
@@ -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://wordlift.io">WordLift Key</a> you received via email.', 'wordlift' ) |
|
| 222 | - . ' [' . apply_filters( 'wl_production_site_url', untrailingslashit( get_option( 'home' ) ) ) . ']', |
|
| 221 | + 'description' => __('Insert the <a href="https://wordlift.io">WordLift Key</a> you received via email.', 'wordlift') |
|
| 222 | + . ' ['.apply_filters('wl_production_site_url', untrailingslashit(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,59 +309,59 @@ discard block |
||
| 309 | 309 | // Add the override URL. |
| 310 | 310 | add_settings_field( |
| 311 | 311 | 'wl-override-website-url', |
| 312 | - __( 'Override Website URL', 'wordlift' ), |
|
| 313 | - array( $this->input_element, 'render' ), |
|
| 312 | + __('Override Website URL', 'wordlift'), |
|
| 313 | + array($this->input_element, 'render'), |
|
| 314 | 314 | 'wl_general_settings', |
| 315 | 315 | 'wl_general_settings_section', |
| 316 | 316 | array( |
| 317 | 317 | 'id' => 'wl-override-website-url', |
| 318 | - 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::OVERRIDE_WEBSITE_URL . ']', |
|
| 318 | + 'name' => 'wl_general_settings['.Wordlift_Configuration_Service::OVERRIDE_WEBSITE_URL.']', |
|
| 319 | 319 | 'value' => Wordlift_Configuration_Service::get_instance()->get_override_website_url(), |
| 320 | 320 | 'pattern' => '^https?://.+$', |
| 321 | - 'placeholder' => __( 'Optionally type a URL like https://...', 'wordlift' ), |
|
| 321 | + 'placeholder' => __('Optionally type a URL like https://...', 'wordlift'), |
|
| 322 | 322 | ) |
| 323 | 323 | ); |
| 324 | 324 | |
| 325 | 325 | // Add the `publisher` field. |
| 326 | 326 | add_settings_field( |
| 327 | 327 | 'wl-publisher-id', |
| 328 | - __( 'Publisher', 'wordlift' ), |
|
| 329 | - array( $this->publisher_element, 'render' ), |
|
| 328 | + __('Publisher', 'wordlift'), |
|
| 329 | + array($this->publisher_element, 'render'), |
|
| 330 | 330 | 'wl_general_settings', |
| 331 | 331 | 'wl_general_settings_section', |
| 332 | 332 | array( |
| 333 | 333 | 'id' => 'wl-publisher-id', |
| 334 | - 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::PUBLISHER_ID . ']', |
|
| 334 | + 'name' => 'wl_general_settings['.Wordlift_Configuration_Service::PUBLISHER_ID.']', |
|
| 335 | 335 | ) |
| 336 | 336 | ); |
| 337 | 337 | |
| 338 | 338 | // Add the `link by default` field. |
| 339 | 339 | add_settings_field( |
| 340 | 340 | 'wl-link-by-default', |
| 341 | - __( 'Link by Default', 'wordlift' ), |
|
| 342 | - array( $this->radio_input_element, 'render' ), |
|
| 341 | + __('Link by Default', 'wordlift'), |
|
| 342 | + array($this->radio_input_element, 'render'), |
|
| 343 | 343 | 'wl_general_settings', |
| 344 | 344 | 'wl_general_settings_section', |
| 345 | 345 | array( |
| 346 | 346 | 'id' => 'wl-link-by-default', |
| 347 | - 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::LINK_BY_DEFAULT . ']', |
|
| 347 | + 'name' => 'wl_general_settings['.Wordlift_Configuration_Service::LINK_BY_DEFAULT.']', |
|
| 348 | 348 | 'value' => Wordlift_Configuration_Service::get_instance()->is_link_by_default() ? 'yes' : 'no', |
| 349 | - 'description' => __( 'Whether to link entities by default or not. This setting applies to all the entities.', 'wordlift' ), |
|
| 349 | + 'description' => __('Whether to link entities by default or not. This setting applies to all the entities.', 'wordlift'), |
|
| 350 | 350 | ) |
| 351 | 351 | ); |
| 352 | 352 | |
| 353 | 353 | // Add the `diagnostic data` field. |
| 354 | 354 | add_settings_field( |
| 355 | 355 | 'wl-send-diagnostic', |
| 356 | - __( 'Send Diagnostic Data', 'wordlift' ), |
|
| 357 | - array( $this->radio_input_element, 'render' ), |
|
| 356 | + __('Send Diagnostic Data', 'wordlift'), |
|
| 357 | + array($this->radio_input_element, 'render'), |
|
| 358 | 358 | 'wl_general_settings', |
| 359 | 359 | 'wl_general_settings_section', |
| 360 | 360 | array( |
| 361 | 361 | 'id' => 'wl-send-diagnostic', |
| 362 | - 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::SEND_DIAGNOSTIC . ']', |
|
| 362 | + 'name' => 'wl_general_settings['.Wordlift_Configuration_Service::SEND_DIAGNOSTIC.']', |
|
| 363 | 363 | 'value' => 'yes' === Wordlift_Configuration_Service::get_instance()->get_diagnostic_preferences() ? 'yes' : 'no', |
| 364 | - 'description' => __( 'Whether to send diagnostic data or not.', 'wordlift' ), |
|
| 364 | + 'description' => __('Whether to send diagnostic data or not.', 'wordlift'), |
|
| 365 | 365 | ) |
| 366 | 366 | ); |
| 367 | 367 | |
@@ -376,10 +376,10 @@ discard block |
||
| 376 | 376 | * @return array The updated array. |
| 377 | 377 | * @since 3.17.0 |
| 378 | 378 | */ |
| 379 | - public function entity_path_input_element_params( $args ) { |
|
| 379 | + public function entity_path_input_element_params($args) { |
|
| 380 | 380 | |
| 381 | 381 | // Bail out if it's not the `wl-entity-base-path`). |
| 382 | - if ( 'wl-entity-base-path' !== $args['id'] ) { |
|
| 382 | + if ('wl-entity-base-path' !== $args['id']) { |
|
| 383 | 383 | return $args; |
| 384 | 384 | } |
| 385 | 385 | |
@@ -401,22 +401,22 @@ discard block |
||
| 401 | 401 | * @return array The sanitized input array. |
| 402 | 402 | * @since 3.11.0 |
| 403 | 403 | */ |
| 404 | - public function sanitize_callback( $input ) { |
|
| 404 | + public function sanitize_callback($input) { |
|
| 405 | 405 | // No nonce verification since this callback is handled by settings api. |
| 406 | 406 | // Check whether a publisher name has been set. |
| 407 | 407 | // phpcs:ignore Standard.Category.SniffName.ErrorCode |
| 408 | - if ( isset( $_POST['wl_publisher'] ) && ! empty( $_POST['wl_publisher']['name'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
| 409 | - $name = isset( $_POST['wl_publisher']['name'] ) ? sanitize_text_field( wp_unslash( (string) $_POST['wl_publisher']['name'] ) ) : ''; //phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
| 410 | - $type = isset( $_POST['wl_publisher']['type'] ) ? sanitize_text_field( wp_unslash( (string) $_POST['wl_publisher']['type'] ) ) : ''; //phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
| 408 | + if (isset($_POST['wl_publisher']) && ! empty($_POST['wl_publisher']['name'])) { //phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
| 409 | + $name = isset($_POST['wl_publisher']['name']) ? sanitize_text_field(wp_unslash((string) $_POST['wl_publisher']['name'])) : ''; //phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
| 410 | + $type = isset($_POST['wl_publisher']['type']) ? sanitize_text_field(wp_unslash((string) $_POST['wl_publisher']['type'])) : ''; //phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
| 411 | 411 | // phpcs:ignore Standard.Category.SniffName.ErrorCode |
| 412 | - $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 |
|
| 412 | + $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 |
|
| 413 | 413 | |
| 414 | 414 | // Set the type URI, either http://schema.org/Person or http://schema.org/Organization. |
| 415 | - $type_uri = sprintf( 'http://schema.org/%s', 'organization' === $type ? 'Organization' : 'Person' ); |
|
| 415 | + $type_uri = sprintf('http://schema.org/%s', 'organization' === $type ? 'Organization' : 'Person'); |
|
| 416 | 416 | |
| 417 | 417 | // Create an entity for the publisher and assign it to the input |
| 418 | 418 | // parameter which WordPress automatically saves into the settings. |
| 419 | - $input['publisher_id'] = $this->entity_service->create( $name, $type_uri, $thumbnail_id, 'publish' ); |
|
| 419 | + $input['publisher_id'] = $this->entity_service->create($name, $type_uri, $thumbnail_id, 'publish'); |
|
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | return $input; |
@@ -1,23 +1,23 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -function _wl_override_url__production_site_url( $value ) { |
|
| 3 | +function _wl_override_url__production_site_url($value) { |
|
| 4 | 4 | $override_website_url = Wordlift_Configuration_Service::get_instance()->get_override_website_url(); |
| 5 | 5 | |
| 6 | - return ! empty( $override_website_url ) ? $override_website_url : $value; |
|
| 6 | + return ! empty($override_website_url) ? $override_website_url : $value; |
|
| 7 | 7 | } |
| 8 | 8 | |
| 9 | -function _wl_override_url__wl_production_permalink( $value ) { |
|
| 9 | +function _wl_override_url__wl_production_permalink($value) { |
|
| 10 | 10 | $override_website_url = Wordlift_Configuration_Service::get_instance()->get_override_website_url(); |
| 11 | 11 | |
| 12 | - if ( empty( $override_website_url ) ) { |
|
| 12 | + if (empty($override_website_url)) { |
|
| 13 | 13 | return $value; |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | - $home_url = untrailingslashit( get_option( 'home' ) ); |
|
| 16 | + $home_url = untrailingslashit(get_option('home')); |
|
| 17 | 17 | |
| 18 | - return $override_website_url . substr( $value, strlen( $home_url ) ); |
|
| 18 | + return $override_website_url.substr($value, strlen($home_url)); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | -add_filter( 'wl_production_site_url', '_wl_override_url__production_site_url' ); |
|
| 21 | +add_filter('wl_production_site_url', '_wl_override_url__production_site_url'); |
|
| 22 | 22 | |
| 23 | -add_filter( 'wl_production_permalink', '_wl_override_url__wl_production_permalink' ); |
|
| 23 | +add_filter('wl_production_permalink', '_wl_override_url__wl_production_permalink'); |
|
@@ -31,26 +31,26 @@ discard block |
||
| 31 | 31 | use Wordlift\Features\Features_Registry; |
| 32 | 32 | use Wordlift\Post\Post_Adapter; |
| 33 | 33 | |
| 34 | -define( 'WORDLIFT_PLUGIN_FILE', __FILE__ ); |
|
| 35 | -define( 'WORDLIFT_VERSION', '3.52.0-0' ); |
|
| 34 | +define('WORDLIFT_PLUGIN_FILE', __FILE__); |
|
| 35 | +define('WORDLIFT_VERSION', '3.52.0-0'); |
|
| 36 | 36 | |
| 37 | 37 | // ## DO NOT REMOVE THIS LINE: WHITELABEL PLACEHOLDER ## |
| 38 | 38 | |
| 39 | -require_once plugin_dir_path( __FILE__ ) . '/libraries/action-scheduler/action-scheduler.php'; |
|
| 40 | -require_once __DIR__ . '/modules/common/load.php'; |
|
| 41 | -require_once __DIR__ . '/modules/app/load.php'; |
|
| 42 | -require_once __DIR__ . '/modules/include-exclude/load.php'; |
|
| 39 | +require_once plugin_dir_path(__FILE__).'/libraries/action-scheduler/action-scheduler.php'; |
|
| 40 | +require_once __DIR__.'/modules/common/load.php'; |
|
| 41 | +require_once __DIR__.'/modules/app/load.php'; |
|
| 42 | +require_once __DIR__.'/modules/include-exclude/load.php'; |
|
| 43 | 43 | |
| 44 | 44 | /** |
| 45 | 45 | * Filter to disable WLP on any request, defaults to true. |
| 46 | 46 | * |
| 47 | 47 | * @since 3.33.6 |
| 48 | 48 | */ |
| 49 | -if ( ! apply_filters( 'wl_is_enabled', true ) ) { |
|
| 49 | +if ( ! apply_filters('wl_is_enabled', true)) { |
|
| 50 | 50 | return; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | -require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php'; |
|
| 53 | +require_once plugin_dir_path(__FILE__).'vendor/autoload.php'; |
|
| 54 | 54 | |
| 55 | 55 | /* |
| 56 | 56 | * We introduce the WordLift autoloader, since we start using classes in namespaces, i.e. Wordlift\Http. |
@@ -60,15 +60,15 @@ discard block |
||
| 60 | 60 | wordlift_plugin_autoload_register(); |
| 61 | 61 | |
| 62 | 62 | // Include WordLift constants. |
| 63 | -require_once plugin_dir_path( __FILE__ ) . 'wordlift-constants.php'; |
|
| 63 | +require_once plugin_dir_path(__FILE__).'wordlift-constants.php'; |
|
| 64 | 64 | |
| 65 | 65 | // Load modules. |
| 66 | -require_once plugin_dir_path( __FILE__ ) . 'modules/core/wordlift-core.php'; |
|
| 66 | +require_once plugin_dir_path(__FILE__).'modules/core/wordlift-core.php'; |
|
| 67 | 67 | |
| 68 | -require_once plugin_dir_path( __FILE__ ) . 'deprecations.php'; |
|
| 68 | +require_once plugin_dir_path(__FILE__).'deprecations.php'; |
|
| 69 | 69 | |
| 70 | 70 | // Load early to enable/disable features. |
| 71 | -require_once plugin_dir_path( __FILE__ ) . 'classes/features/index.php'; |
|
| 71 | +require_once plugin_dir_path(__FILE__).'classes/features/index.php'; |
|
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | 74 | * The code that runs during plugin activation. |
@@ -76,11 +76,11 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | function activate_wordlift() { |
| 78 | 78 | |
| 79 | - $log = Wordlift_Log_Service::get_logger( 'activate_wordlift' ); |
|
| 79 | + $log = Wordlift_Log_Service::get_logger('activate_wordlift'); |
|
| 80 | 80 | |
| 81 | - $log->info( 'Activating WordLift...' ); |
|
| 81 | + $log->info('Activating WordLift...'); |
|
| 82 | 82 | |
| 83 | - require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php'; |
|
| 83 | + require_once plugin_dir_path(__FILE__).'includes/class-wordlift-activator.php'; |
|
| 84 | 84 | Wordlift_Activator::activate(); |
| 85 | 85 | |
| 86 | 86 | /** |
@@ -100,8 +100,8 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | Top_Entities::activate(); |
| 102 | 102 | |
| 103 | - if ( ! wp_next_scheduled( 'wl_daily_cron' ) ) { |
|
| 104 | - wp_schedule_event( time(), 'daily', 'wl_daily_cron' ); |
|
| 103 | + if ( ! wp_next_scheduled('wl_daily_cron')) { |
|
| 104 | + wp_schedule_event(time(), 'daily', 'wl_daily_cron'); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | } |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | */ |
| 113 | 113 | function deactivate_wordlift() { |
| 114 | 114 | |
| 115 | - require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php'; |
|
| 115 | + require_once plugin_dir_path(__FILE__).'includes/class-wordlift-deactivator.php'; |
|
| 116 | 116 | Wordlift_Deactivator::deactivate(); |
| 117 | 117 | Wordlift_Http_Api::deactivate(); |
| 118 | 118 | Ttl_Cache_Cleaner::deactivate(); |
@@ -128,18 +128,18 @@ discard block |
||
| 128 | 128 | Key_Validation_Notice::remove_notification_flag(); |
| 129 | 129 | flush_rewrite_rules(); |
| 130 | 130 | |
| 131 | - wp_clear_scheduled_hook( 'wl_daily_cron' ); |
|
| 131 | + wp_clear_scheduled_hook('wl_daily_cron'); |
|
| 132 | 132 | |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | -register_activation_hook( __FILE__, 'activate_wordlift' ); |
|
| 136 | -register_deactivation_hook( __FILE__, 'deactivate_wordlift' ); |
|
| 135 | +register_activation_hook(__FILE__, 'activate_wordlift'); |
|
| 136 | +register_deactivation_hook(__FILE__, 'deactivate_wordlift'); |
|
| 137 | 137 | |
| 138 | 138 | /** |
| 139 | 139 | * The core plugin class that is used to define internationalization, |
| 140 | 140 | * admin-specific hooks, and public-facing site hooks. |
| 141 | 141 | */ |
| 142 | -require plugin_dir_path( __FILE__ ) . 'includes/class-wordlift.php'; |
|
| 142 | +require plugin_dir_path(__FILE__).'includes/class-wordlift.php'; |
|
| 143 | 143 | |
| 144 | 144 | /** |
| 145 | 145 | * Begins execution of the plugin. |
@@ -159,12 +159,12 @@ discard block |
||
| 159 | 159 | * @return bool |
| 160 | 160 | * @since 3.27.6 |
| 161 | 161 | */ |
| 162 | - if ( apply_filters( 'wl_feature__enable__widgets', true ) ) { |
|
| 163 | - add_action( 'widgets_init', 'wl_register_chord_widget' ); |
|
| 164 | - add_action( 'widgets_init', 'wl_register_geo_widget' ); |
|
| 165 | - add_action( 'widgets_init', 'wl_register_timeline_widget' ); |
|
| 162 | + if (apply_filters('wl_feature__enable__widgets', true)) { |
|
| 163 | + add_action('widgets_init', 'wl_register_chord_widget'); |
|
| 164 | + add_action('widgets_init', 'wl_register_geo_widget'); |
|
| 165 | + add_action('widgets_init', 'wl_register_timeline_widget'); |
|
| 166 | 166 | } |
| 167 | - add_filter( 'widget_text', 'do_shortcode' ); |
|
| 167 | + add_filter('widget_text', 'do_shortcode'); |
|
| 168 | 168 | |
| 169 | 169 | /** |
| 170 | 170 | * Filter: wl_feature__enable__analysis |
@@ -174,10 +174,10 @@ discard block |
||
| 174 | 174 | * @return bool |
| 175 | 175 | * @since 3.27.6 |
| 176 | 176 | */ |
| 177 | - if ( apply_filters( 'wl_feature__enable__analysis', true ) ) { |
|
| 178 | - add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_action' ); |
|
| 177 | + if (apply_filters('wl_feature__enable__analysis', true)) { |
|
| 178 | + add_action('wp_ajax_wl_analyze', 'wl_ajax_analyze_action'); |
|
| 179 | 179 | } else { |
| 180 | - add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_disabled_action' ); |
|
| 180 | + add_action('wp_ajax_wl_analyze', 'wl_ajax_analyze_disabled_action'); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | $plugin = new Wordlift(); |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | |
| 195 | 195 | add_action( |
| 196 | 196 | 'plugins_loaded', |
| 197 | - function () { |
|
| 197 | + function() { |
|
| 198 | 198 | // All features from registry should be initialized here. |
| 199 | 199 | $features_registry = Features_Registry::get_instance(); |
| 200 | 200 | $features_registry->initialize_all_features(); |
@@ -205,27 +205,27 @@ discard block |
||
| 205 | 205 | add_action( |
| 206 | 206 | 'plugins_loaded', |
| 207 | 207 | // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
| 208 | - function () use ( $plugin ) { |
|
| 208 | + function() use ($plugin) { |
|
| 209 | 209 | |
| 210 | 210 | new Wordlift_Products_Navigator_Shortcode_REST(); |
| 211 | 211 | |
| 212 | 212 | // Register the Dataset module, requires `$api_service`. |
| 213 | - require_once plugin_dir_path( __FILE__ ) . 'classes/dataset/index.php'; |
|
| 214 | - require_once plugin_dir_path( __FILE__ ) . 'classes/shipping-data/index.php'; |
|
| 213 | + require_once plugin_dir_path(__FILE__).'classes/dataset/index.php'; |
|
| 214 | + require_once plugin_dir_path(__FILE__).'classes/shipping-data/index.php'; |
|
| 215 | 215 | |
| 216 | 216 | /* |
| 217 | 217 | * Require the Entity annotation cleanup module. |
| 218 | 218 | * |
| 219 | 219 | * @since 3.34.6 |
| 220 | 220 | */ |
| 221 | - require_once plugin_dir_path( __FILE__ ) . 'classes/cleanup/index.php'; |
|
| 221 | + require_once plugin_dir_path(__FILE__).'classes/cleanup/index.php'; |
|
| 222 | 222 | |
| 223 | 223 | /* |
| 224 | 224 | * Import LOD entities. |
| 225 | 225 | * |
| 226 | 226 | * @since 3.35.0 |
| 227 | 227 | */ |
| 228 | - require_once plugin_dir_path( __FILE__ ) . 'classes/lod-import/index.php'; |
|
| 228 | + require_once plugin_dir_path(__FILE__).'classes/lod-import/index.php'; |
|
| 229 | 229 | |
| 230 | 230 | } |
| 231 | 231 | ); |
@@ -243,31 +243,31 @@ discard block |
||
| 243 | 243 | function wordlift_plugin_autoload_register() { |
| 244 | 244 | |
| 245 | 245 | spl_autoload_register( |
| 246 | - function ( $class_name ) { |
|
| 246 | + function($class_name) { |
|
| 247 | 247 | |
| 248 | 248 | // Bail out if these are not our classes. |
| 249 | - if ( 0 !== strpos( $class_name, 'Wordlift\\' ) ) { |
|
| 249 | + if (0 !== strpos($class_name, 'Wordlift\\')) { |
|
| 250 | 250 | return false; |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | - $class_name_lc = strtolower( str_replace( '_', '-', $class_name ) ); |
|
| 253 | + $class_name_lc = strtolower(str_replace('_', '-', $class_name)); |
|
| 254 | 254 | |
| 255 | - preg_match( '|^wordlift\\\\(?:(.*)\\\\)?(.+?)$|', $class_name_lc, $matches ); |
|
| 255 | + preg_match('|^wordlift\\\\(?:(.*)\\\\)?(.+?)$|', $class_name_lc, $matches); |
|
| 256 | 256 | |
| 257 | - $path = str_replace( '\\', DIRECTORY_SEPARATOR, $matches[1] ); |
|
| 258 | - $file = 'class-' . $matches[2] . '.php'; |
|
| 257 | + $path = str_replace('\\', DIRECTORY_SEPARATOR, $matches[1]); |
|
| 258 | + $file = 'class-'.$matches[2].'.php'; |
|
| 259 | 259 | |
| 260 | - $full_path = plugin_dir_path( __FILE__ ) . 'classes' . DIRECTORY_SEPARATOR . $path . DIRECTORY_SEPARATOR . $file; |
|
| 260 | + $full_path = plugin_dir_path(__FILE__).'classes'.DIRECTORY_SEPARATOR.$path.DIRECTORY_SEPARATOR.$file; |
|
| 261 | 261 | |
| 262 | - if ( ! file_exists( $full_path ) ) { |
|
| 262 | + if ( ! file_exists($full_path)) { |
|
| 263 | 263 | return false; |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | try { |
| 267 | 267 | require_once $full_path; |
| 268 | - } catch ( Exception $e ) { |
|
| 268 | + } catch (Exception $e) { |
|
| 269 | 269 | // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log |
| 270 | - error_log( "[WordLift] $full_path not found, cannot include." ); |
|
| 270 | + error_log("[WordLift] $full_path not found, cannot include."); |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | return true; |
@@ -276,13 +276,13 @@ discard block |
||
| 276 | 276 | |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | -function wl_block_categories( $categories ) { |
|
| 279 | +function wl_block_categories($categories) { |
|
| 280 | 280 | return array_merge( |
| 281 | 281 | $categories, |
| 282 | 282 | array( |
| 283 | 283 | array( |
| 284 | 284 | 'slug' => 'wordlift', |
| 285 | - 'title' => __( 'WordLift', 'wordlift' ), |
|
| 285 | + 'title' => __('WordLift', 'wordlift'), |
|
| 286 | 286 | ), |
| 287 | 287 | ) |
| 288 | 288 | ); |
@@ -292,51 +292,51 @@ discard block |
||
| 292 | 292 | * This function is created temporarily to handle the legacy library, |
| 293 | 293 | * this has to be removed when removing the legacy fields from the ui. |
| 294 | 294 | */ |
| 295 | -function wl_enqueue_leaflet( $in_footer = false ) { |
|
| 295 | +function wl_enqueue_leaflet($in_footer = false) { |
|
| 296 | 296 | // Leaflet. |
| 297 | - wp_enqueue_style( 'wl-leaflet', plugin_dir_url( __FILE__ ) . 'js/leaflet/leaflet.css', array(), '1.6.0' ); |
|
| 298 | - wp_enqueue_script( 'wl-leaflet', plugin_dir_url( __FILE__ ) . 'js/leaflet/leaflet.js', array(), '1.6.0', $in_footer ); |
|
| 297 | + wp_enqueue_style('wl-leaflet', plugin_dir_url(__FILE__).'js/leaflet/leaflet.css', array(), '1.6.0'); |
|
| 298 | + wp_enqueue_script('wl-leaflet', plugin_dir_url(__FILE__).'js/leaflet/leaflet.js', array(), '1.6.0', $in_footer); |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | -add_filter( 'block_categories', 'wl_block_categories', 10 ); |
|
| 301 | +add_filter('block_categories', 'wl_block_categories', 10); |
|
| 302 | 302 | |
| 303 | 303 | // Temporary fix for a typo in WooCommerce Extension. |
| 304 | 304 | add_filter( |
| 305 | 305 | 'wl_feature__enable__dataset', |
| 306 | - function ( $value ) { |
|
| 307 | - return apply_filters( 'wl_features__enable__dataset', $value ); |
|
| 306 | + function($value) { |
|
| 307 | + return apply_filters('wl_features__enable__dataset', $value); |
|
| 308 | 308 | } |
| 309 | 309 | ); |
| 310 | 310 | |
| 311 | -require_once __DIR__ . '/modules/food-kg/load.php'; |
|
| 312 | -require_once __DIR__ . '/modules/gardening-kg/load.php'; |
|
| 313 | -require_once __DIR__ . '/modules/acf4so/load.php'; |
|
| 314 | -require_once __DIR__ . '/modules/dashboard/load.php'; |
|
| 315 | -require_once __DIR__ . '/modules/pods/load.php'; |
|
| 316 | -require_once __DIR__ . '/modules/include-exclude-push-config/load.php'; |
|
| 317 | -require_once __DIR__ . '/modules/super-resolution/load.php'; |
|
| 318 | -require_once __DIR__ . '/modules/redeem-code/load.php'; |
|
| 319 | -require_once __DIR__ . '/modules/raptive-setup/load.php'; |
|
| 320 | -require_once __DIR__ . '/modules/events/load.php'; |
|
| 321 | -require_once __DIR__ . '/modules/plugin-diagnostics/load.php'; |
|
| 322 | -require_once __DIR__ . '/modules/override-url/load.php'; |
|
| 323 | - |
|
| 324 | -function _wl_update_plugins_raptive_domain( $update, $plugin_data, $plugin_file ) { |
|
| 311 | +require_once __DIR__.'/modules/food-kg/load.php'; |
|
| 312 | +require_once __DIR__.'/modules/gardening-kg/load.php'; |
|
| 313 | +require_once __DIR__.'/modules/acf4so/load.php'; |
|
| 314 | +require_once __DIR__.'/modules/dashboard/load.php'; |
|
| 315 | +require_once __DIR__.'/modules/pods/load.php'; |
|
| 316 | +require_once __DIR__.'/modules/include-exclude-push-config/load.php'; |
|
| 317 | +require_once __DIR__.'/modules/super-resolution/load.php'; |
|
| 318 | +require_once __DIR__.'/modules/redeem-code/load.php'; |
|
| 319 | +require_once __DIR__.'/modules/raptive-setup/load.php'; |
|
| 320 | +require_once __DIR__.'/modules/events/load.php'; |
|
| 321 | +require_once __DIR__.'/modules/plugin-diagnostics/load.php'; |
|
| 322 | +require_once __DIR__.'/modules/override-url/load.php'; |
|
| 323 | + |
|
| 324 | +function _wl_update_plugins_raptive_domain($update, $plugin_data, $plugin_file) { |
|
| 325 | 325 | // Bail out if it's not our plugin. |
| 326 | 326 | $update_uri = $plugin_data['UpdateURI']; |
| 327 | - if ( 'wordlift/wordlift.php' !== $plugin_file || ! isset( $update_uri ) ) { |
|
| 327 | + if ('wordlift/wordlift.php' !== $plugin_file || ! isset($update_uri)) { |
|
| 328 | 328 | return $update; |
| 329 | 329 | } |
| 330 | 330 | |
| 331 | - $response = wp_remote_get( "$update_uri?nocache=" . time() ); |
|
| 331 | + $response = wp_remote_get("$update_uri?nocache=".time()); |
|
| 332 | 332 | |
| 333 | - if ( is_wp_error( $response ) ) { |
|
| 333 | + if (is_wp_error($response)) { |
|
| 334 | 334 | return $update; |
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | try { |
| 338 | - return json_decode( wp_remote_retrieve_body( $response ) ); |
|
| 339 | - } catch ( Exception $e ) { |
|
| 338 | + return json_decode(wp_remote_retrieve_body($response)); |
|
| 339 | + } catch (Exception $e) { |
|
| 340 | 340 | return $update; |
| 341 | 341 | } |
| 342 | 342 | } |