@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | if ( ! defined( 'ABSPATH' ) ) { |
15 | - exit; |
|
15 | + exit; |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | // Get a list of tabs filtered in by the classes that want to add them. |
@@ -20,12 +20,12 @@ discard block |
||
20 | 20 | // Generate a list of valid tabs that we could have to validate the input against. |
21 | 21 | $valid_tabs = array(); |
22 | 22 | foreach ( $admin_tabs as $admin_tab ) { |
23 | - $valid_tabs[] = $admin_tab['slug']; |
|
23 | + $valid_tabs[] = $admin_tab['slug']; |
|
24 | 24 | } |
25 | 25 | $input_tab = filter_input( INPUT_GET, 'tab' ); |
26 | 26 | $current_tab = ( in_array( $input_tab, $valid_tabs, true ) ) |
27 | - ? $input_tab |
|
28 | - : 'general'; |
|
27 | + ? $input_tab |
|
28 | + : 'general'; |
|
29 | 29 | |
30 | 30 | ?> |
31 | 31 | |
@@ -35,13 +35,13 @@ discard block |
||
35 | 35 | <a class="nav-tab<?php echo 'general' === $current_tab ? ' nav-tab-active' : ''; ?>" |
36 | 36 | href="<?php echo esc_html( admin_url( 'admin.php?page=wl_configuration_admin_menu' ) ); ?>"><?php echo esc_html( __( 'General', 'wordlift' ) ); ?></a> |
37 | 37 | <?php |
38 | - foreach ( $admin_tabs as $admin_tab ) { |
|
39 | - ?> |
|
38 | + foreach ( $admin_tabs as $admin_tab ) { |
|
39 | + ?> |
|
40 | 40 | <a class="nav-tab<?php echo esc_attr( $admin_tab['slug'] === $current_tab ? ' nav-tab-active' : '' ); ?>" |
41 | 41 | href="<?php echo esc_url( admin_url( 'admin.php?page=wl_configuration_admin_menu&tab=' . $admin_tab['slug'] ) ); ?>"><?php echo esc_html( $admin_tab['title'] ); ?></a> |
42 | 42 | <?php |
43 | - } |
|
44 | - ?> |
|
43 | + } |
|
44 | + ?> |
|
45 | 45 | </h2> |
46 | 46 | |
47 | 47 | <?php require plugin_dir_path( __DIR__ ) . "partials/wordlift-admin-settings-$current_tab-page.php"; ?> |
@@ -11,39 +11,39 @@ |
||
11 | 11 | * @package Wordlift/admin |
12 | 12 | */ |
13 | 13 | |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
18 | 18 | // Get a list of tabs filtered in by the classes that want to add them. |
19 | -$admin_tabs = apply_filters( 'wl_admin_page_tabs', array() ); |
|
19 | +$admin_tabs = apply_filters('wl_admin_page_tabs', array()); |
|
20 | 20 | // Generate a list of valid tabs that we could have to validate the input against. |
21 | 21 | $valid_tabs = array(); |
22 | -foreach ( $admin_tabs as $admin_tab ) { |
|
22 | +foreach ($admin_tabs as $admin_tab) { |
|
23 | 23 | $valid_tabs[] = $admin_tab['slug']; |
24 | 24 | } |
25 | -$input_tab = filter_input( INPUT_GET, 'tab' ); |
|
26 | -$current_tab = ( in_array( $input_tab, $valid_tabs, true ) ) |
|
25 | +$input_tab = filter_input(INPUT_GET, 'tab'); |
|
26 | +$current_tab = (in_array($input_tab, $valid_tabs, true)) |
|
27 | 27 | ? $input_tab |
28 | 28 | : 'general'; |
29 | 29 | |
30 | 30 | ?> |
31 | 31 | |
32 | 32 | <div class="wrap" id="wl-settings-page"> |
33 | - <h2><?php esc_html_e( 'WordLift Settings', 'wordlift' ); ?></h2> |
|
33 | + <h2><?php esc_html_e('WordLift Settings', 'wordlift'); ?></h2> |
|
34 | 34 | <h2 class="nav-tab-wrapper"> |
35 | 35 | <a class="nav-tab<?php echo 'general' === $current_tab ? ' nav-tab-active' : ''; ?>" |
36 | - href="<?php echo esc_html( admin_url( 'admin.php?page=wl_configuration_admin_menu' ) ); ?>"><?php echo esc_html( __( 'General', 'wordlift' ) ); ?></a> |
|
36 | + href="<?php echo esc_html(admin_url('admin.php?page=wl_configuration_admin_menu')); ?>"><?php echo esc_html(__('General', 'wordlift')); ?></a> |
|
37 | 37 | <?php |
38 | - foreach ( $admin_tabs as $admin_tab ) { |
|
38 | + foreach ($admin_tabs as $admin_tab) { |
|
39 | 39 | ?> |
40 | - <a class="nav-tab<?php echo esc_attr( $admin_tab['slug'] === $current_tab ? ' nav-tab-active' : '' ); ?>" |
|
41 | - href="<?php echo esc_url( admin_url( 'admin.php?page=wl_configuration_admin_menu&tab=' . $admin_tab['slug'] ) ); ?>"><?php echo esc_html( $admin_tab['title'] ); ?></a> |
|
40 | + <a class="nav-tab<?php echo esc_attr($admin_tab['slug'] === $current_tab ? ' nav-tab-active' : ''); ?>" |
|
41 | + href="<?php echo esc_url(admin_url('admin.php?page=wl_configuration_admin_menu&tab='.$admin_tab['slug'])); ?>"><?php echo esc_html($admin_tab['title']); ?></a> |
|
42 | 42 | <?php |
43 | 43 | } |
44 | 44 | ?> |
45 | 45 | </h2> |
46 | 46 | |
47 | - <?php require plugin_dir_path( __DIR__ ) . "partials/wordlift-admin-settings-$current_tab-page.php"; ?> |
|
47 | + <?php require plugin_dir_path(__DIR__)."partials/wordlift-admin-settings-$current_tab-page.php"; ?> |
|
48 | 48 | |
49 | 49 | </div> |
@@ -16,49 +16,49 @@ discard block |
||
16 | 16 | |
17 | 17 | <?php |
18 | 18 | |
19 | - // Enqueue wp.media functions. |
|
20 | - wp_enqueue_media(); |
|
19 | + // Enqueue wp.media functions. |
|
20 | + wp_enqueue_media(); |
|
21 | 21 | |
22 | - // Enqueue styles and scripts. |
|
23 | - wp_enqueue_style( 'wl-font-awesome', plugin_dir_url( dirname( __DIR__ ) ) . 'css/font-awesome.min.css', array(), WORDLIFT_VERSION ); |
|
24 | - wp_enqueue_style( |
|
25 | - 'wordlift-admin-setup', |
|
26 | - plugin_dir_url( __DIR__ ) . 'css/wordlift-admin-setup.css', |
|
27 | - array( |
|
28 | - 'wp-admin', |
|
29 | - 'wl-font-awesome', |
|
30 | - ), |
|
31 | - WORDLIFT_VERSION |
|
32 | - ); |
|
33 | - wp_enqueue_script( 'wordlift-admin-setup', plugin_dir_url( __DIR__ ) . 'js/1/setup.js', array( 'jquery' ), WORDLIFT_VERSION, false ); |
|
22 | + // Enqueue styles and scripts. |
|
23 | + wp_enqueue_style( 'wl-font-awesome', plugin_dir_url( dirname( __DIR__ ) ) . 'css/font-awesome.min.css', array(), WORDLIFT_VERSION ); |
|
24 | + wp_enqueue_style( |
|
25 | + 'wordlift-admin-setup', |
|
26 | + plugin_dir_url( __DIR__ ) . 'css/wordlift-admin-setup.css', |
|
27 | + array( |
|
28 | + 'wp-admin', |
|
29 | + 'wl-font-awesome', |
|
30 | + ), |
|
31 | + WORDLIFT_VERSION |
|
32 | + ); |
|
33 | + wp_enqueue_script( 'wordlift-admin-setup', plugin_dir_url( __DIR__ ) . 'js/1/setup.js', array( 'jquery' ), WORDLIFT_VERSION, false ); |
|
34 | 34 | |
35 | - // Get wp_permalink structure |
|
36 | - $permalink_structure = get_option( 'permalink_structure' ); |
|
35 | + // Get wp_permalink structure |
|
36 | + $permalink_structure = get_option( 'permalink_structure' ); |
|
37 | 37 | |
38 | - // Set configuration settings. |
|
39 | - wp_localize_script( |
|
40 | - 'wordlift-admin-setup', |
|
41 | - '_wlAdminSetup', |
|
42 | - array( |
|
43 | - 'ajaxUrl' => wp_parse_url( self_admin_url( 'admin-ajax.php' ), PHP_URL_PATH ), |
|
44 | - 'action' => 'wl_validate_key', |
|
45 | - 'permalink' => $permalink_structure, |
|
46 | - 'media' => array( |
|
47 | - 'title' => __( 'WordLift Choose Logo', 'wordlift' ), |
|
48 | - 'button' => array( 'text' => __( 'Choose Logo', 'wordlift' ) ), |
|
49 | - ), |
|
50 | - ) |
|
51 | - ); |
|
38 | + // Set configuration settings. |
|
39 | + wp_localize_script( |
|
40 | + 'wordlift-admin-setup', |
|
41 | + '_wlAdminSetup', |
|
42 | + array( |
|
43 | + 'ajaxUrl' => wp_parse_url( self_admin_url( 'admin-ajax.php' ), PHP_URL_PATH ), |
|
44 | + 'action' => 'wl_validate_key', |
|
45 | + 'permalink' => $permalink_structure, |
|
46 | + 'media' => array( |
|
47 | + 'title' => __( 'WordLift Choose Logo', 'wordlift' ), |
|
48 | + 'button' => array( 'text' => __( 'Choose Logo', 'wordlift' ) ), |
|
49 | + ), |
|
50 | + ) |
|
51 | + ); |
|
52 | 52 | |
53 | - // Finally print styles and scripts. |
|
54 | - do_action( 'admin_print_scripts' ); |
|
55 | - wp_print_styles(); |
|
56 | - wp_print_scripts(); |
|
53 | + // Finally print styles and scripts. |
|
54 | + do_action( 'admin_print_scripts' ); |
|
55 | + wp_print_styles(); |
|
56 | + wp_print_scripts(); |
|
57 | 57 | |
58 | - for ( $i = 1; $i <= 6; $i ++ ) { |
|
59 | - include 'admin-setup/step-' . $i . '.php'; |
|
60 | - } |
|
61 | - ?> |
|
58 | + for ( $i = 1; $i <= 6; $i ++ ) { |
|
59 | + include 'admin-setup/step-' . $i . '.php'; |
|
60 | + } |
|
61 | + ?> |
|
62 | 62 | </head> |
63 | 63 | <body> |
64 | 64 | |
@@ -82,10 +82,10 @@ discard block |
||
82 | 82 | <div class="viewport"></div> |
83 | 83 | </form> |
84 | 84 | <?php |
85 | - if ( function_exists( 'wp_print_media_templates' ) ) { |
|
86 | - wp_print_media_templates(); |
|
87 | - } |
|
88 | - ?> |
|
85 | + if ( function_exists( 'wp_print_media_templates' ) ) { |
|
86 | + wp_print_media_templates(); |
|
87 | + } |
|
88 | + ?> |
|
89 | 89 | </div> |
90 | 90 | |
91 | 91 | </body> |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | <!-- Defining responsive ambient. --> |
13 | 13 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
14 | 14 | |
15 | - <title><?php esc_html_e( 'WordLift Setup', 'wordlift' ); ?></title> |
|
15 | + <title><?php esc_html_e('WordLift Setup', 'wordlift'); ?></title> |
|
16 | 16 | |
17 | 17 | <?php |
18 | 18 | |
@@ -20,43 +20,43 @@ discard block |
||
20 | 20 | wp_enqueue_media(); |
21 | 21 | |
22 | 22 | // Enqueue styles and scripts. |
23 | - wp_enqueue_style( 'wl-font-awesome', plugin_dir_url( dirname( __DIR__ ) ) . 'css/font-awesome.min.css', array(), WORDLIFT_VERSION ); |
|
23 | + wp_enqueue_style('wl-font-awesome', plugin_dir_url(dirname(__DIR__)).'css/font-awesome.min.css', array(), WORDLIFT_VERSION); |
|
24 | 24 | wp_enqueue_style( |
25 | 25 | 'wordlift-admin-setup', |
26 | - plugin_dir_url( __DIR__ ) . 'css/wordlift-admin-setup.css', |
|
26 | + plugin_dir_url(__DIR__).'css/wordlift-admin-setup.css', |
|
27 | 27 | array( |
28 | 28 | 'wp-admin', |
29 | 29 | 'wl-font-awesome', |
30 | 30 | ), |
31 | 31 | WORDLIFT_VERSION |
32 | 32 | ); |
33 | - wp_enqueue_script( 'wordlift-admin-setup', plugin_dir_url( __DIR__ ) . 'js/1/setup.js', array( 'jquery' ), WORDLIFT_VERSION, false ); |
|
33 | + wp_enqueue_script('wordlift-admin-setup', plugin_dir_url(__DIR__).'js/1/setup.js', array('jquery'), WORDLIFT_VERSION, false); |
|
34 | 34 | |
35 | 35 | // Get wp_permalink structure |
36 | - $permalink_structure = get_option( 'permalink_structure' ); |
|
36 | + $permalink_structure = get_option('permalink_structure'); |
|
37 | 37 | |
38 | 38 | // Set configuration settings. |
39 | 39 | wp_localize_script( |
40 | 40 | 'wordlift-admin-setup', |
41 | 41 | '_wlAdminSetup', |
42 | 42 | array( |
43 | - 'ajaxUrl' => wp_parse_url( self_admin_url( 'admin-ajax.php' ), PHP_URL_PATH ), |
|
43 | + 'ajaxUrl' => wp_parse_url(self_admin_url('admin-ajax.php'), PHP_URL_PATH), |
|
44 | 44 | 'action' => 'wl_validate_key', |
45 | 45 | 'permalink' => $permalink_structure, |
46 | 46 | 'media' => array( |
47 | - 'title' => __( 'WordLift Choose Logo', 'wordlift' ), |
|
48 | - 'button' => array( 'text' => __( 'Choose Logo', 'wordlift' ) ), |
|
47 | + 'title' => __('WordLift Choose Logo', 'wordlift'), |
|
48 | + 'button' => array('text' => __('Choose Logo', 'wordlift')), |
|
49 | 49 | ), |
50 | 50 | ) |
51 | 51 | ); |
52 | 52 | |
53 | 53 | // Finally print styles and scripts. |
54 | - do_action( 'admin_print_scripts' ); |
|
54 | + do_action('admin_print_scripts'); |
|
55 | 55 | wp_print_styles(); |
56 | 56 | wp_print_scripts(); |
57 | 57 | |
58 | - for ( $i = 1; $i <= 6; $i ++ ) { |
|
59 | - include 'admin-setup/step-' . $i . '.php'; |
|
58 | + for ($i = 1; $i <= 6; $i++) { |
|
59 | + include 'admin-setup/step-'.$i.'.php'; |
|
60 | 60 | } |
61 | 61 | ?> |
62 | 62 | </head> |
@@ -64,25 +64,25 @@ discard block |
||
64 | 64 | |
65 | 65 | <div class="wl-container"> |
66 | 66 | |
67 | - <a href="<?php echo esc_url( admin_url() ); ?>" |
|
67 | + <a href="<?php echo esc_url(admin_url()); ?>" |
|
68 | 68 | class="fa fa-times wl-close"></a> |
69 | 69 | |
70 | 70 | <header> |
71 | 71 | <h1><img class="wizard-logo" |
72 | - src="<?php echo esc_attr( plugin_dir_url( dirname( __DIR__ ) ) . 'images/logo-wl-transparent-240x90.png' ); ?>"/> |
|
72 | + src="<?php echo esc_attr(plugin_dir_url(dirname(__DIR__)).'images/logo-wl-transparent-240x90.png'); ?>"/> |
|
73 | 73 | </h1> |
74 | 74 | <img class="shapes" |
75 | - src="<?php echo esc_attr( plugin_dir_url( dirname( __DIR__ ) ) . 'images/shapes.png' ); ?>"/> |
|
75 | + src="<?php echo esc_attr(plugin_dir_url(dirname(__DIR__)).'images/shapes.png'); ?>"/> |
|
76 | 76 | </header> |
77 | 77 | |
78 | 78 | |
79 | 79 | <form method="post"> |
80 | - <?php wp_nonce_field( 'wl-save-configuration' ); ?> |
|
80 | + <?php wp_nonce_field('wl-save-configuration'); ?> |
|
81 | 81 | <input type="hidden" name="action" value="wl-save-configuration"/> |
82 | 82 | <div class="viewport"></div> |
83 | 83 | </form> |
84 | 84 | <?php |
85 | - if ( function_exists( 'wp_print_media_templates' ) ) { |
|
85 | + if (function_exists('wp_print_media_templates')) { |
|
86 | 86 | wp_print_media_templates(); |
87 | 87 | } |
88 | 88 | ?> |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | if ( ! defined( 'ABSPATH' ) ) { |
14 | - exit; |
|
14 | + exit; |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable |
@@ -19,8 +19,8 @@ discard block |
||
19 | 19 | |
20 | 20 | // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable |
21 | 21 | $term_settings = $settings !== null ? $settings : array( |
22 | - 'title' => '', |
|
23 | - 'description' => '', |
|
22 | + 'title' => '', |
|
23 | + 'description' => '', |
|
24 | 24 | ); |
25 | 25 | |
26 | 26 | ?> |
@@ -33,36 +33,36 @@ discard block |
||
33 | 33 | <input type="hidden" name="tag_ID" |
34 | 34 | value=" |
35 | 35 | <?php |
36 | - // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable |
|
37 | - echo esc_attr( $term_id ); |
|
38 | - ?> |
|
36 | + // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable |
|
37 | + echo esc_attr( $term_id ); |
|
38 | + ?> |
|
39 | 39 | " /> |
40 | 40 | <input type="hidden" name="action" value="wl_edit_entity_type_term" /> |
41 | 41 | <?php |
42 | - // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable |
|
43 | - wp_nonce_field( 'update-entity_type_term_' . $term_id ); |
|
44 | - ?> |
|
42 | + // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable |
|
43 | + wp_nonce_field( 'update-entity_type_term_' . $term_id ); |
|
44 | + ?> |
|
45 | 45 | <table class="form-table"> |
46 | 46 | <tr class="form-field form-required term-name-wrap"> |
47 | 47 | <th scope="row"> |
48 | 48 | <label> |
49 | 49 | <?php |
50 | - esc_html_e( 'Name', 'wordlift' ); |
|
51 | - ?> |
|
50 | + esc_html_e( 'Name', 'wordlift' ); |
|
51 | + ?> |
|
52 | 52 | </label> |
53 | 53 | </th> |
54 | 54 | <td> |
55 | 55 | <?php |
56 | - echo esc_html( $current_term->name ) |
|
57 | - ?> |
|
56 | + echo esc_html( $current_term->name ) |
|
57 | + ?> |
|
58 | 58 | </td> |
59 | 59 | </tr> |
60 | 60 | <tr class="form-field form-required term-name-wrap"> |
61 | 61 | <th scope="row"> |
62 | 62 | <label for="title"> |
63 | 63 | <?php |
64 | - esc_html_e( 'Title', 'wordlift' ); |
|
65 | - ?> |
|
64 | + esc_html_e( 'Title', 'wordlift' ); |
|
65 | + ?> |
|
66 | 66 | </label> |
67 | 67 | </th> |
68 | 68 | <td><input name="title" id="title" type="text" |
@@ -70,24 +70,24 @@ discard block |
||
70 | 70 | size="40" /> |
71 | 71 | <p class="description"> |
72 | 72 | <?php |
73 | - esc_html_e( 'The HTML title to be used in the entity type archive page.', 'wordlift' ); |
|
74 | - ?> |
|
73 | + esc_html_e( 'The HTML title to be used in the entity type archive page.', 'wordlift' ); |
|
74 | + ?> |
|
75 | 75 | </p> |
76 | 76 | </td> |
77 | 77 | </tr> |
78 | 78 | <tr class="form-field term-description-wrap"> |
79 | 79 | <th scope="row"><label for="description"> |
80 | 80 | <?php |
81 | - esc_html_e( 'Description', 'wordlift' ); |
|
82 | - ?> |
|
81 | + esc_html_e( 'Description', 'wordlift' ); |
|
82 | + ?> |
|
83 | 83 | </label> |
84 | 84 | </th> |
85 | 85 | <td><textarea name="description" id="description" rows="5" |
86 | 86 | cols="50" class="large-text"><?php echo esc_html( $term_settings['description'] ); ?></textarea> |
87 | 87 | <p class="description"> |
88 | 88 | <?php |
89 | - esc_html_e( 'The description to be used in the entity type archive page.', 'wordlift' ); |
|
90 | - ?> |
|
89 | + esc_html_e( 'The description to be used in the entity type archive page.', 'wordlift' ); |
|
90 | + ?> |
|
91 | 91 | </p> |
92 | 92 | </td> |
93 | 93 | </tr> |
@@ -10,12 +10,12 @@ discard block |
||
10 | 10 | * @subpackage Wordlift/admin/partials |
11 | 11 | */ |
12 | 12 | |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
17 | 17 | // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable |
18 | -$current_term = get_term( $term_id, 'wl_entity_type' ); |
|
18 | +$current_term = get_term($term_id, 'wl_entity_type'); |
|
19 | 19 | |
20 | 20 | // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable |
21 | 21 | $term_settings = $settings !== null ? $settings : array( |
@@ -25,35 +25,35 @@ discard block |
||
25 | 25 | |
26 | 26 | ?> |
27 | 27 | <div class="wrap"> |
28 | - <h1><?php esc_html_e( 'Edit Entity Type', 'wordlift' ); ?></h1> |
|
28 | + <h1><?php esc_html_e('Edit Entity Type', 'wordlift'); ?></h1> |
|
29 | 29 | |
30 | 30 | <form name="edittag" id="edittag" method="post" |
31 | - action="<?php echo esc_html( admin_url( 'admin.php?page=wl_entity_type_settings' ) ); ?>" |
|
31 | + action="<?php echo esc_html(admin_url('admin.php?page=wl_entity_type_settings')); ?>" |
|
32 | 32 | class="validate"> |
33 | 33 | <input type="hidden" name="tag_ID" |
34 | 34 | value=" |
35 | 35 | <?php |
36 | 36 | // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable |
37 | - echo esc_attr( $term_id ); |
|
37 | + echo esc_attr($term_id); |
|
38 | 38 | ?> |
39 | 39 | " /> |
40 | 40 | <input type="hidden" name="action" value="wl_edit_entity_type_term" /> |
41 | 41 | <?php |
42 | 42 | // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable |
43 | - wp_nonce_field( 'update-entity_type_term_' . $term_id ); |
|
43 | + wp_nonce_field('update-entity_type_term_'.$term_id); |
|
44 | 44 | ?> |
45 | 45 | <table class="form-table"> |
46 | 46 | <tr class="form-field form-required term-name-wrap"> |
47 | 47 | <th scope="row"> |
48 | 48 | <label> |
49 | 49 | <?php |
50 | - esc_html_e( 'Name', 'wordlift' ); |
|
50 | + esc_html_e('Name', 'wordlift'); |
|
51 | 51 | ?> |
52 | 52 | </label> |
53 | 53 | </th> |
54 | 54 | <td> |
55 | 55 | <?php |
56 | - echo esc_html( $current_term->name ) |
|
56 | + echo esc_html($current_term->name) |
|
57 | 57 | ?> |
58 | 58 | </td> |
59 | 59 | </tr> |
@@ -61,16 +61,16 @@ discard block |
||
61 | 61 | <th scope="row"> |
62 | 62 | <label for="title"> |
63 | 63 | <?php |
64 | - esc_html_e( 'Title', 'wordlift' ); |
|
64 | + esc_html_e('Title', 'wordlift'); |
|
65 | 65 | ?> |
66 | 66 | </label> |
67 | 67 | </th> |
68 | 68 | <td><input name="title" id="title" type="text" |
69 | - value="<?php echo esc_attr( $term_settings['title'] ); ?>" |
|
69 | + value="<?php echo esc_attr($term_settings['title']); ?>" |
|
70 | 70 | size="40" /> |
71 | 71 | <p class="description"> |
72 | 72 | <?php |
73 | - esc_html_e( 'The HTML title to be used in the entity type archive page.', 'wordlift' ); |
|
73 | + esc_html_e('The HTML title to be used in the entity type archive page.', 'wordlift'); |
|
74 | 74 | ?> |
75 | 75 | </p> |
76 | 76 | </td> |
@@ -78,20 +78,20 @@ discard block |
||
78 | 78 | <tr class="form-field term-description-wrap"> |
79 | 79 | <th scope="row"><label for="description"> |
80 | 80 | <?php |
81 | - esc_html_e( 'Description', 'wordlift' ); |
|
81 | + esc_html_e('Description', 'wordlift'); |
|
82 | 82 | ?> |
83 | 83 | </label> |
84 | 84 | </th> |
85 | 85 | <td><textarea name="description" id="description" rows="5" |
86 | - cols="50" class="large-text"><?php echo esc_html( $term_settings['description'] ); ?></textarea> |
|
86 | + cols="50" class="large-text"><?php echo esc_html($term_settings['description']); ?></textarea> |
|
87 | 87 | <p class="description"> |
88 | 88 | <?php |
89 | - esc_html_e( 'The description to be used in the entity type archive page.', 'wordlift' ); |
|
89 | + esc_html_e('The description to be used in the entity type archive page.', 'wordlift'); |
|
90 | 90 | ?> |
91 | 91 | </p> |
92 | 92 | </td> |
93 | 93 | </tr> |
94 | 94 | </table> |
95 | - <?php submit_button( __( 'Update', 'default' ) ); ?> |
|
95 | + <?php submit_button(__('Update', 'default')); ?> |
|
96 | 96 | </form> |
97 | 97 | </div> |
@@ -9,8 +9,8 @@ discard block |
||
9 | 9 | * @package Wordlift |
10 | 10 | * @subpackage Wordlift/includes |
11 | 11 | */ |
12 | -if ( ! class_exists( 'Walker_Category_Checklist' ) ) { |
|
13 | - require_once ABSPATH . 'wp-admin/includes/template.php'; |
|
12 | +if ( ! class_exists('Walker_Category_Checklist')) { |
|
13 | + require_once ABSPATH.'wp-admin/includes/template.php'; |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | /** |
@@ -36,9 +36,9 @@ discard block |
||
36 | 36 | * |
37 | 37 | * @return array An array of arguments, with this walker in case the taxonomy is the Entity Type taxonomy. |
38 | 38 | */ |
39 | - public function terms_checklist_args( $args ) { |
|
39 | + public function terms_checklist_args($args) { |
|
40 | 40 | |
41 | - if ( ! isset( $args['taxonomy'] ) || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) { |
|
41 | + if ( ! isset($args['taxonomy']) || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy']) { |
|
42 | 42 | return $args; |
43 | 43 | } |
44 | 44 | |
@@ -66,16 +66,16 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @return string The hierarchical item output. |
68 | 68 | */ |
69 | - public function walk( $elements, $max_depth, ...$args ) { |
|
69 | + public function walk($elements, $max_depth, ...$args) { |
|
70 | 70 | |
71 | 71 | // `max_depth` force to -1 to display a flat taxonomy. |
72 | 72 | // |
73 | 73 | // See https://github.com/insideout10/wordlift-plugin/issues/305 |
74 | - $output = parent::walk( $elements, - 1, ...$args ); |
|
74 | + $output = parent::walk($elements, - 1, ...$args); |
|
75 | 75 | |
76 | 76 | $output = str_replace( |
77 | - array( 'type="checkbox"', "type='checkbox'" ), |
|
78 | - array( 'type="radio"', "type='radio'" ), |
|
77 | + array('type="checkbox"', "type='checkbox'"), |
|
78 | + array('type="radio"', "type='radio'"), |
|
79 | 79 | $output |
80 | 80 | ); |
81 | 81 | |
@@ -93,17 +93,17 @@ discard block |
||
93 | 93 | * @param array $args An array of arguments. @see wp_terms_checklist() |
94 | 94 | * @param int $id ID of the current term. |
95 | 95 | */ |
96 | - public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) { |
|
96 | + public function start_el(&$output, $category, $depth = 0, $args = array(), $id = 0) { |
|
97 | 97 | global $post; |
98 | 98 | |
99 | - if ( ! isset( $post ) ) { |
|
99 | + if ( ! isset($post)) { |
|
100 | 100 | return; |
101 | 101 | } |
102 | 102 | |
103 | - if ( Wordlift_Entity_Service::TYPE_NAME !== $post->post_type |
|
103 | + if (Wordlift_Entity_Service::TYPE_NAME !== $post->post_type |
|
104 | 104 | || 'article' !== $category->slug |
105 | - || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) { |
|
106 | - parent::start_el( $output, $category, $depth, $args, $id ); |
|
105 | + || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy']) { |
|
106 | + parent::start_el($output, $category, $depth, $args, $id); |
|
107 | 107 | } |
108 | 108 | } |
109 | 109 | |
@@ -117,17 +117,17 @@ discard block |
||
117 | 117 | * @param int $depth Depth of the term in reference to parents. Default 0. |
118 | 118 | * @param array $args An array of arguments. @see wp_terms_checklist() |
119 | 119 | */ |
120 | - public function end_el( &$output, $category, $depth = 0, $args = array() ) { |
|
120 | + public function end_el(&$output, $category, $depth = 0, $args = array()) { |
|
121 | 121 | global $post; |
122 | 122 | |
123 | - if ( ! isset( $post ) ) { |
|
123 | + if ( ! isset($post)) { |
|
124 | 124 | return; |
125 | 125 | } |
126 | 126 | |
127 | - if ( Wordlift_Entity_Service::TYPE_NAME !== $post->post_type |
|
127 | + if (Wordlift_Entity_Service::TYPE_NAME !== $post->post_type |
|
128 | 128 | || 'article' !== $category->slug |
129 | - || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) { |
|
130 | - parent::end_el( $output, $category, $depth, $args ); |
|
129 | + || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy']) { |
|
130 | + parent::end_el($output, $category, $depth, $args); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @subpackage Wordlift/includes |
11 | 11 | */ |
12 | 12 | if ( ! class_exists( 'Walker_Category_Checklist' ) ) { |
13 | - require_once ABSPATH . 'wp-admin/includes/template.php'; |
|
13 | + require_once ABSPATH . 'wp-admin/includes/template.php'; |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | /** |
@@ -24,113 +24,113 @@ discard block |
||
24 | 24 | // phpcs:ignore Generic.Classes.DuplicateClassName.Found |
25 | 25 | class Wordlift_Entity_Types_Taxonomy_Walker extends Walker_Category_Checklist { |
26 | 26 | |
27 | - /** |
|
28 | - * Entity taxonomy metabox must show exclusive options, no checkboxes. |
|
29 | - * |
|
30 | - * @since 3.1.0 |
|
31 | - * |
|
32 | - * @param $args { |
|
33 | - * An array of arguments. |
|
34 | - * |
|
35 | - * @type string $taxonomy The taxonomy name. |
|
36 | - * } |
|
37 | - * |
|
38 | - * @return array An array of arguments, with this walker in case the taxonomy is the Entity Type taxonomy. |
|
39 | - */ |
|
40 | - public function terms_checklist_args( $args ) { |
|
41 | - |
|
42 | - if ( ! isset( $args['taxonomy'] ) || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) { |
|
43 | - return $args; |
|
44 | - } |
|
45 | - |
|
46 | - // We override the way WP prints the taxonomy metabox HTML. |
|
47 | - $args['walker'] = $this; |
|
48 | - $args['checked_ontop'] = false; |
|
49 | - |
|
50 | - return $args; |
|
51 | - |
|
52 | - } |
|
53 | - |
|
54 | - /** |
|
55 | - * Change checkboxes to radios. |
|
56 | - * |
|
57 | - * $max_depth = -1 means flatly display every element. |
|
58 | - * $max_depth = 0 means display all levels. |
|
59 | - * $max_depth > 0 specifies the number of display levels. |
|
60 | - * |
|
61 | - * @since 3.1.0 |
|
62 | - * |
|
63 | - * @param array $elements An array of elements. |
|
64 | - * @param int $max_depth The maximum hierarchical depth. |
|
65 | - * |
|
66 | - * @param array $args Additional arguments. |
|
67 | - * |
|
68 | - * @return string The hierarchical item output. |
|
69 | - */ |
|
70 | - public function walk( $elements, $max_depth, ...$args ) { |
|
71 | - |
|
72 | - // `max_depth` force to -1 to display a flat taxonomy. |
|
73 | - // |
|
74 | - // See https://github.com/insideout10/wordlift-plugin/issues/305 |
|
75 | - $output = parent::walk( $elements, - 1, ...$args ); |
|
76 | - |
|
77 | - $output = str_replace( |
|
78 | - array( 'type="checkbox"', "type='checkbox'" ), |
|
79 | - array( 'type="radio"', "type='radio'" ), |
|
80 | - $output |
|
81 | - ); |
|
82 | - |
|
83 | - return $output; |
|
84 | - } |
|
85 | - |
|
86 | - /** |
|
87 | - * Start the element output, output nothing in case of article term. |
|
88 | - * |
|
89 | - * @since 3.15.0 |
|
90 | - * |
|
91 | - * @param string $output Passed by reference. Used to append additional content. |
|
92 | - * @param object $category The current term object. |
|
93 | - * @param int $depth Depth of the term in reference to parents. Default 0. |
|
94 | - * @param array $args An array of arguments. @see wp_terms_checklist() |
|
95 | - * @param int $id ID of the current term. |
|
96 | - */ |
|
97 | - public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) { |
|
98 | - global $post; |
|
99 | - |
|
100 | - if ( ! isset( $post ) ) { |
|
101 | - return; |
|
102 | - } |
|
103 | - |
|
104 | - if ( Wordlift_Entity_Service::TYPE_NAME !== $post->post_type |
|
105 | - || 'article' !== $category->slug |
|
106 | - || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) { |
|
107 | - parent::start_el( $output, $category, $depth, $args, $id ); |
|
108 | - } |
|
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * End the element output, output nothing in case of article term. |
|
113 | - * |
|
114 | - * @since 3.15.0 |
|
115 | - * |
|
116 | - * @param string $output Passed by reference. Used to append additional content. |
|
117 | - * @param object $category The current term object. |
|
118 | - * @param int $depth Depth of the term in reference to parents. Default 0. |
|
119 | - * @param array $args An array of arguments. @see wp_terms_checklist() |
|
120 | - */ |
|
121 | - public function end_el( &$output, $category, $depth = 0, $args = array() ) { |
|
122 | - global $post; |
|
123 | - |
|
124 | - if ( ! isset( $post ) ) { |
|
125 | - return; |
|
126 | - } |
|
127 | - |
|
128 | - if ( Wordlift_Entity_Service::TYPE_NAME !== $post->post_type |
|
129 | - || 'article' !== $category->slug |
|
130 | - || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) { |
|
131 | - parent::end_el( $output, $category, $depth, $args ); |
|
132 | - } |
|
133 | - |
|
134 | - } |
|
27 | + /** |
|
28 | + * Entity taxonomy metabox must show exclusive options, no checkboxes. |
|
29 | + * |
|
30 | + * @since 3.1.0 |
|
31 | + * |
|
32 | + * @param $args { |
|
33 | + * An array of arguments. |
|
34 | + * |
|
35 | + * @type string $taxonomy The taxonomy name. |
|
36 | + * } |
|
37 | + * |
|
38 | + * @return array An array of arguments, with this walker in case the taxonomy is the Entity Type taxonomy. |
|
39 | + */ |
|
40 | + public function terms_checklist_args( $args ) { |
|
41 | + |
|
42 | + if ( ! isset( $args['taxonomy'] ) || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) { |
|
43 | + return $args; |
|
44 | + } |
|
45 | + |
|
46 | + // We override the way WP prints the taxonomy metabox HTML. |
|
47 | + $args['walker'] = $this; |
|
48 | + $args['checked_ontop'] = false; |
|
49 | + |
|
50 | + return $args; |
|
51 | + |
|
52 | + } |
|
53 | + |
|
54 | + /** |
|
55 | + * Change checkboxes to radios. |
|
56 | + * |
|
57 | + * $max_depth = -1 means flatly display every element. |
|
58 | + * $max_depth = 0 means display all levels. |
|
59 | + * $max_depth > 0 specifies the number of display levels. |
|
60 | + * |
|
61 | + * @since 3.1.0 |
|
62 | + * |
|
63 | + * @param array $elements An array of elements. |
|
64 | + * @param int $max_depth The maximum hierarchical depth. |
|
65 | + * |
|
66 | + * @param array $args Additional arguments. |
|
67 | + * |
|
68 | + * @return string The hierarchical item output. |
|
69 | + */ |
|
70 | + public function walk( $elements, $max_depth, ...$args ) { |
|
71 | + |
|
72 | + // `max_depth` force to -1 to display a flat taxonomy. |
|
73 | + // |
|
74 | + // See https://github.com/insideout10/wordlift-plugin/issues/305 |
|
75 | + $output = parent::walk( $elements, - 1, ...$args ); |
|
76 | + |
|
77 | + $output = str_replace( |
|
78 | + array( 'type="checkbox"', "type='checkbox'" ), |
|
79 | + array( 'type="radio"', "type='radio'" ), |
|
80 | + $output |
|
81 | + ); |
|
82 | + |
|
83 | + return $output; |
|
84 | + } |
|
85 | + |
|
86 | + /** |
|
87 | + * Start the element output, output nothing in case of article term. |
|
88 | + * |
|
89 | + * @since 3.15.0 |
|
90 | + * |
|
91 | + * @param string $output Passed by reference. Used to append additional content. |
|
92 | + * @param object $category The current term object. |
|
93 | + * @param int $depth Depth of the term in reference to parents. Default 0. |
|
94 | + * @param array $args An array of arguments. @see wp_terms_checklist() |
|
95 | + * @param int $id ID of the current term. |
|
96 | + */ |
|
97 | + public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) { |
|
98 | + global $post; |
|
99 | + |
|
100 | + if ( ! isset( $post ) ) { |
|
101 | + return; |
|
102 | + } |
|
103 | + |
|
104 | + if ( Wordlift_Entity_Service::TYPE_NAME !== $post->post_type |
|
105 | + || 'article' !== $category->slug |
|
106 | + || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) { |
|
107 | + parent::start_el( $output, $category, $depth, $args, $id ); |
|
108 | + } |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * End the element output, output nothing in case of article term. |
|
113 | + * |
|
114 | + * @since 3.15.0 |
|
115 | + * |
|
116 | + * @param string $output Passed by reference. Used to append additional content. |
|
117 | + * @param object $category The current term object. |
|
118 | + * @param int $depth Depth of the term in reference to parents. Default 0. |
|
119 | + * @param array $args An array of arguments. @see wp_terms_checklist() |
|
120 | + */ |
|
121 | + public function end_el( &$output, $category, $depth = 0, $args = array() ) { |
|
122 | + global $post; |
|
123 | + |
|
124 | + if ( ! isset( $post ) ) { |
|
125 | + return; |
|
126 | + } |
|
127 | + |
|
128 | + if ( Wordlift_Entity_Service::TYPE_NAME !== $post->post_type |
|
129 | + || 'article' !== $category->slug |
|
130 | + || Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME !== $args['taxonomy'] ) { |
|
131 | + parent::end_el( $output, $category, $depth, $args ); |
|
132 | + } |
|
133 | + |
|
134 | + } |
|
135 | 135 | |
136 | 136 | } |
@@ -17,28 +17,28 @@ discard block |
||
17 | 17 | */ |
18 | 18 | function wl_serialize_entity( $entity ) { |
19 | 19 | |
20 | - $entity = ( is_numeric( $entity ) ) ? get_post( $entity ) : $entity; |
|
20 | + $entity = ( is_numeric( $entity ) ) ? get_post( $entity ) : $entity; |
|
21 | 21 | |
22 | - // Bail if the entity doesn't exists. |
|
23 | - // In some cases we have `wl_topic` meta |
|
24 | - // pointing to an entity that has been deleted. |
|
25 | - if ( empty( $entity ) ) { |
|
26 | - return; |
|
27 | - } |
|
22 | + // Bail if the entity doesn't exists. |
|
23 | + // In some cases we have `wl_topic` meta |
|
24 | + // pointing to an entity that has been deleted. |
|
25 | + if ( empty( $entity ) ) { |
|
26 | + return; |
|
27 | + } |
|
28 | 28 | |
29 | - $type = Wordlift_Entity_Type_Service::get_instance()->get( $entity->ID ); |
|
30 | - $images = wl_get_image_urls( $entity->ID ); |
|
29 | + $type = Wordlift_Entity_Type_Service::get_instance()->get( $entity->ID ); |
|
30 | + $images = wl_get_image_urls( $entity->ID ); |
|
31 | 31 | |
32 | - return array( |
|
33 | - 'id' => wl_get_entity_uri( $entity->ID ), |
|
34 | - 'label' => $entity->post_title, |
|
35 | - 'description' => $entity->post_content, |
|
36 | - 'sameAs' => wl_schema_get_value( $entity->ID, 'sameAs' ), |
|
37 | - 'mainType' => str_replace( 'wl-', '', $type['css_class'] ), |
|
38 | - 'types' => wl_get_entity_rdf_types( $entity->ID ), |
|
39 | - 'images' => $images, |
|
32 | + return array( |
|
33 | + 'id' => wl_get_entity_uri( $entity->ID ), |
|
34 | + 'label' => $entity->post_title, |
|
35 | + 'description' => $entity->post_content, |
|
36 | + 'sameAs' => wl_schema_get_value( $entity->ID, 'sameAs' ), |
|
37 | + 'mainType' => str_replace( 'wl-', '', $type['css_class'] ), |
|
38 | + 'types' => wl_get_entity_rdf_types( $entity->ID ), |
|
39 | + 'images' => $images, |
|
40 | 40 | |
41 | - ); |
|
41 | + ); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -51,29 +51,29 @@ discard block |
||
51 | 51 | */ |
52 | 52 | function wl_remove_text_annotations( $data ) { |
53 | 53 | |
54 | - // Remove blank elements that can interfere with annotations removing |
|
55 | - // See https://github.com/insideout10/wordlift-plugin/issues/234 |
|
56 | - // Just blank span tags without any attributes are cleaned up. |
|
57 | - // Restrict removal to empty spans only as we may impact valid empty elements like: <th> |
|
58 | - $pattern = '/<span><\/span>/im'; |
|
59 | - // Remove the pattern while it is found (match nested annotations). |
|
60 | - while ( 1 === preg_match( $pattern, $data['post_content'] ) ) { |
|
61 | - $data['post_content'] = preg_replace( $pattern, '$2', $data['post_content'], - 1, $count ); |
|
62 | - } |
|
63 | - // Remove text annotations |
|
64 | - // <span class="textannotation" id="urn:enhancement-777cbed4-b131-00fb-54a4-ed9b26ae57ea">. |
|
54 | + // Remove blank elements that can interfere with annotations removing |
|
55 | + // See https://github.com/insideout10/wordlift-plugin/issues/234 |
|
56 | + // Just blank span tags without any attributes are cleaned up. |
|
57 | + // Restrict removal to empty spans only as we may impact valid empty elements like: <th> |
|
58 | + $pattern = '/<span><\/span>/im'; |
|
59 | + // Remove the pattern while it is found (match nested annotations). |
|
60 | + while ( 1 === preg_match( $pattern, $data['post_content'] ) ) { |
|
61 | + $data['post_content'] = preg_replace( $pattern, '$2', $data['post_content'], - 1, $count ); |
|
62 | + } |
|
63 | + // Remove text annotations |
|
64 | + // <span class="textannotation" id="urn:enhancement-777cbed4-b131-00fb-54a4-ed9b26ae57ea">. |
|
65 | 65 | |
66 | - // @see https://github.com/insideout10/wordlift-plugin/issues/771 |
|
67 | - // Changing this: |
|
68 | - // $pattern = '/<(\w+)[^>]*\sclass=\\\"textannotation(?![^\\"]*\sdisambiguated)[^\\"]*\\\"[^>]*>([^<]+)<\/\1>/im'; |
|
69 | - // to: |
|
70 | - $pattern = '/<(\w+)[^>]*\sclass=\\\"textannotation(?![^\\"]*\sdisambiguated)[^\\"]*\\\"[^>]*>(.*?)<\/\1>/im'; |
|
71 | - // Remove the pattern while it is found (match nested annotations). |
|
72 | - while ( 1 === preg_match( $pattern, $data['post_content'] ) ) { |
|
73 | - $data['post_content'] = preg_replace( $pattern, '$2', $data['post_content'], - 1, $count ); |
|
74 | - } |
|
66 | + // @see https://github.com/insideout10/wordlift-plugin/issues/771 |
|
67 | + // Changing this: |
|
68 | + // $pattern = '/<(\w+)[^>]*\sclass=\\\"textannotation(?![^\\"]*\sdisambiguated)[^\\"]*\\\"[^>]*>([^<]+)<\/\1>/im'; |
|
69 | + // to: |
|
70 | + $pattern = '/<(\w+)[^>]*\sclass=\\\"textannotation(?![^\\"]*\sdisambiguated)[^\\"]*\\\"[^>]*>(.*?)<\/\1>/im'; |
|
71 | + // Remove the pattern while it is found (match nested annotations). |
|
72 | + while ( 1 === preg_match( $pattern, $data['post_content'] ) ) { |
|
73 | + $data['post_content'] = preg_replace( $pattern, '$2', $data['post_content'], - 1, $count ); |
|
74 | + } |
|
75 | 75 | |
76 | - return $data; |
|
76 | + return $data; |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | add_filter( 'wp_insert_post_data', 'wl_remove_text_annotations', '98', 1 ); |
@@ -88,5 +88,5 @@ discard block |
||
88 | 88 | */ |
89 | 89 | function wl_admin_metaboxes_add_css_class( $classes = array() ) { |
90 | 90 | |
91 | - return array_merge( $classes, array( 'wl-metabox' ) ); |
|
91 | + return array_merge( $classes, array( 'wl-metabox' ) ); |
|
92 | 92 | } |
@@ -15,27 +15,27 @@ discard block |
||
15 | 15 | * |
16 | 16 | * @return array mixed The entity data array. |
17 | 17 | */ |
18 | -function wl_serialize_entity( $entity ) { |
|
18 | +function wl_serialize_entity($entity) { |
|
19 | 19 | |
20 | - $entity = ( is_numeric( $entity ) ) ? get_post( $entity ) : $entity; |
|
20 | + $entity = (is_numeric($entity)) ? get_post($entity) : $entity; |
|
21 | 21 | |
22 | 22 | // Bail if the entity doesn't exists. |
23 | 23 | // In some cases we have `wl_topic` meta |
24 | 24 | // pointing to an entity that has been deleted. |
25 | - if ( empty( $entity ) ) { |
|
25 | + if (empty($entity)) { |
|
26 | 26 | return; |
27 | 27 | } |
28 | 28 | |
29 | - $type = Wordlift_Entity_Type_Service::get_instance()->get( $entity->ID ); |
|
30 | - $images = wl_get_image_urls( $entity->ID ); |
|
29 | + $type = Wordlift_Entity_Type_Service::get_instance()->get($entity->ID); |
|
30 | + $images = wl_get_image_urls($entity->ID); |
|
31 | 31 | |
32 | 32 | return array( |
33 | - 'id' => wl_get_entity_uri( $entity->ID ), |
|
33 | + 'id' => wl_get_entity_uri($entity->ID), |
|
34 | 34 | 'label' => $entity->post_title, |
35 | 35 | 'description' => $entity->post_content, |
36 | - 'sameAs' => wl_schema_get_value( $entity->ID, 'sameAs' ), |
|
37 | - 'mainType' => str_replace( 'wl-', '', $type['css_class'] ), |
|
38 | - 'types' => wl_get_entity_rdf_types( $entity->ID ), |
|
36 | + 'sameAs' => wl_schema_get_value($entity->ID, 'sameAs'), |
|
37 | + 'mainType' => str_replace('wl-', '', $type['css_class']), |
|
38 | + 'types' => wl_get_entity_rdf_types($entity->ID), |
|
39 | 39 | 'images' => $images, |
40 | 40 | |
41 | 41 | ); |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @return array mixed The post data array. |
50 | 50 | * @since 1.0.0 |
51 | 51 | */ |
52 | -function wl_remove_text_annotations( $data ) { |
|
52 | +function wl_remove_text_annotations($data) { |
|
53 | 53 | |
54 | 54 | // Remove blank elements that can interfere with annotations removing |
55 | 55 | // See https://github.com/insideout10/wordlift-plugin/issues/234 |
@@ -57,8 +57,8 @@ discard block |
||
57 | 57 | // Restrict removal to empty spans only as we may impact valid empty elements like: <th> |
58 | 58 | $pattern = '/<span><\/span>/im'; |
59 | 59 | // Remove the pattern while it is found (match nested annotations). |
60 | - while ( 1 === preg_match( $pattern, $data['post_content'] ) ) { |
|
61 | - $data['post_content'] = preg_replace( $pattern, '$2', $data['post_content'], - 1, $count ); |
|
60 | + while (1 === preg_match($pattern, $data['post_content'])) { |
|
61 | + $data['post_content'] = preg_replace($pattern, '$2', $data['post_content'], - 1, $count); |
|
62 | 62 | } |
63 | 63 | // Remove text annotations |
64 | 64 | // <span class="textannotation" id="urn:enhancement-777cbed4-b131-00fb-54a4-ed9b26ae57ea">. |
@@ -69,14 +69,14 @@ discard block |
||
69 | 69 | // to: |
70 | 70 | $pattern = '/<(\w+)[^>]*\sclass=\\\"textannotation(?![^\\"]*\sdisambiguated)[^\\"]*\\\"[^>]*>(.*?)<\/\1>/im'; |
71 | 71 | // Remove the pattern while it is found (match nested annotations). |
72 | - while ( 1 === preg_match( $pattern, $data['post_content'] ) ) { |
|
73 | - $data['post_content'] = preg_replace( $pattern, '$2', $data['post_content'], - 1, $count ); |
|
72 | + while (1 === preg_match($pattern, $data['post_content'])) { |
|
73 | + $data['post_content'] = preg_replace($pattern, '$2', $data['post_content'], - 1, $count); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | return $data; |
77 | 77 | } |
78 | 78 | |
79 | -add_filter( 'wp_insert_post_data', 'wl_remove_text_annotations', '98', 1 ); |
|
79 | +add_filter('wp_insert_post_data', 'wl_remove_text_annotations', '98', 1); |
|
80 | 80 | |
81 | 81 | /** |
82 | 82 | * Adds wl-metabox CSS class to a metabox. |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @return array The updated list of CSS classes. |
87 | 87 | * @since 3.2.0 |
88 | 88 | */ |
89 | -function wl_admin_metaboxes_add_css_class( $classes = array() ) { |
|
89 | +function wl_admin_metaboxes_add_css_class($classes = array()) { |
|
90 | 90 | |
91 | - return array_merge( $classes, array( 'wl-metabox' ) ); |
|
91 | + return array_merge($classes, array('wl-metabox')); |
|
92 | 92 | } |
@@ -17,43 +17,43 @@ discard block |
||
17 | 17 | */ |
18 | 18 | class Wordlift_Admin_Schemaorg_Taxonomy_Metabox { |
19 | 19 | |
20 | - /** |
|
21 | - * Render the metabox. |
|
22 | - * |
|
23 | - * @since 3.20.0 |
|
24 | - */ |
|
25 | - public static function render() { |
|
20 | + /** |
|
21 | + * Render the metabox. |
|
22 | + * |
|
23 | + * @since 3.20.0 |
|
24 | + */ |
|
25 | + public static function render() { |
|
26 | 26 | |
27 | - self::post_categories_meta_box( |
|
28 | - get_post(), |
|
29 | - array( |
|
30 | - 'args' => |
|
31 | - array( 'taxonomy' => Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ), |
|
32 | - ) |
|
33 | - ); |
|
27 | + self::post_categories_meta_box( |
|
28 | + get_post(), |
|
29 | + array( |
|
30 | + 'args' => |
|
31 | + array( 'taxonomy' => Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ), |
|
32 | + ) |
|
33 | + ); |
|
34 | 34 | |
35 | - } |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * A function which resembles WordPress' own to display a metabox, but which customizes the output |
|
39 | - * to display the Schema.org classes tree. |
|
40 | - * |
|
41 | - * @param WP_Post $post The {@link WP_Post} being edited. |
|
42 | - * @param array $box An array of arguments. |
|
43 | - * |
|
44 | - * @since 3.20.0 |
|
45 | - */ |
|
46 | - private static function post_categories_meta_box( $post, $box ) { |
|
47 | - $defaults = array( 'taxonomy' => 'category' ); |
|
48 | - if ( ! isset( $box['args'] ) || ! is_array( $box['args'] ) ) { |
|
49 | - $args = array(); |
|
50 | - } else { |
|
51 | - $args = $box['args']; |
|
52 | - } |
|
53 | - $r = wp_parse_args( $args, $defaults ); |
|
54 | - $tax_name = esc_attr( $r['taxonomy'] ); |
|
55 | - $taxonomy = get_taxonomy( $r['taxonomy'] ); |
|
56 | - ?> |
|
37 | + /** |
|
38 | + * A function which resembles WordPress' own to display a metabox, but which customizes the output |
|
39 | + * to display the Schema.org classes tree. |
|
40 | + * |
|
41 | + * @param WP_Post $post The {@link WP_Post} being edited. |
|
42 | + * @param array $box An array of arguments. |
|
43 | + * |
|
44 | + * @since 3.20.0 |
|
45 | + */ |
|
46 | + private static function post_categories_meta_box( $post, $box ) { |
|
47 | + $defaults = array( 'taxonomy' => 'category' ); |
|
48 | + if ( ! isset( $box['args'] ) || ! is_array( $box['args'] ) ) { |
|
49 | + $args = array(); |
|
50 | + } else { |
|
51 | + $args = $box['args']; |
|
52 | + } |
|
53 | + $r = wp_parse_args( $args, $defaults ); |
|
54 | + $tax_name = esc_attr( $r['taxonomy'] ); |
|
55 | + $taxonomy = get_taxonomy( $r['taxonomy'] ); |
|
56 | + ?> |
|
57 | 57 | <div id="taxonomy-<?php echo esc_attr( $tax_name ); ?>" class="categorydiv"> |
58 | 58 | <ul id="<?php echo esc_attr( $tax_name ); ?>-tabs" class="category-tabs"> |
59 | 59 | <li class="tabs"><a |
@@ -79,34 +79,34 @@ discard block |
||
79 | 79 | |
80 | 80 | <div id="<?php echo esc_attr( $tax_name ); ?>-legacy" class="tabs-panel" style="display: none;"> |
81 | 81 | <?php |
82 | - $name = ( 'category' === $tax_name ) ? 'post_category' : 'tax_input[' . $tax_name . ']'; |
|
83 | - echo wp_kses( |
|
84 | - sprintf( |
|
85 | - "<input type='hidden' name='%s[]' value='0' />", |
|
86 | - esc_attr( $name ) |
|
87 | - ), |
|
88 | - array( |
|
89 | - 'input' => |
|
90 | - array( |
|
91 | - 'type' => array(), |
|
92 | - 'name' => array(), |
|
93 | - 'value' => array(), |
|
94 | - ), |
|
95 | - ) |
|
96 | - ); // Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks. |
|
97 | - ?> |
|
82 | + $name = ( 'category' === $tax_name ) ? 'post_category' : 'tax_input[' . $tax_name . ']'; |
|
83 | + echo wp_kses( |
|
84 | + sprintf( |
|
85 | + "<input type='hidden' name='%s[]' value='0' />", |
|
86 | + esc_attr( $name ) |
|
87 | + ), |
|
88 | + array( |
|
89 | + 'input' => |
|
90 | + array( |
|
91 | + 'type' => array(), |
|
92 | + 'name' => array(), |
|
93 | + 'value' => array(), |
|
94 | + ), |
|
95 | + ) |
|
96 | + ); // Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks. |
|
97 | + ?> |
|
98 | 98 | <ul id="<?php echo esc_attr( $tax_name ); ?>checklist" |
99 | 99 | data-wp-lists="list:<?php echo esc_attr( $tax_name ); ?>" |
100 | 100 | class="categorychecklist form-no-clear"> |
101 | 101 | <?php |
102 | - wp_terms_checklist( |
|
103 | - $post->ID, |
|
104 | - array( |
|
105 | - 'taxonomy' => $tax_name, |
|
106 | - 'popular_cats' => $popular_ids, |
|
107 | - ) |
|
108 | - ); |
|
109 | - ?> |
|
102 | + wp_terms_checklist( |
|
103 | + $post->ID, |
|
104 | + array( |
|
105 | + 'taxonomy' => $tax_name, |
|
106 | + 'popular_cats' => $popular_ids, |
|
107 | + ) |
|
108 | + ); |
|
109 | + ?> |
|
110 | 110 | </ul> |
111 | 111 | </div> |
112 | 112 | <?php if ( current_user_can( $taxonomy->cap->edit_terms ) ) : ?> |
@@ -115,9 +115,9 @@ discard block |
||
115 | 115 | href="#<?php echo esc_attr( $tax_name ); ?>-add" |
116 | 116 | class="taxonomy-add-new"> |
117 | 117 | <?php |
118 | - /* translators: %s: add new taxonomy label */ |
|
119 | - echo esc_html( sprintf( __( '+ %s', 'default' ), $taxonomy->labels->add_new_item ) ); |
|
120 | - ?> |
|
118 | + /* translators: %s: add new taxonomy label */ |
|
119 | + echo esc_html( sprintf( __( '+ %s', 'default' ), $taxonomy->labels->add_new_item ) ); |
|
120 | + ?> |
|
121 | 121 | </a> |
122 | 122 | <p id="<?php echo esc_attr( $tax_name ); ?>-add" class="category-add wp-hidden-child"> |
123 | 123 | <label class="screen-reader-text" |
@@ -131,42 +131,42 @@ discard block |
||
131 | 131 | <?php echo esc_html( $taxonomy->labels->parent_item_colon ); ?> |
132 | 132 | </label> |
133 | 133 | <?php |
134 | - $parent_dropdown_args = array( |
|
135 | - 'taxonomy' => $tax_name, |
|
136 | - 'hide_empty' => 0, |
|
137 | - 'name' => 'new' . $tax_name . '_parent', |
|
138 | - 'orderby' => 'name', |
|
139 | - 'hierarchical' => 1, |
|
140 | - 'show_option_none' => '— ' . $taxonomy->labels->parent_item . ' —', |
|
141 | - ); |
|
134 | + $parent_dropdown_args = array( |
|
135 | + 'taxonomy' => $tax_name, |
|
136 | + 'hide_empty' => 0, |
|
137 | + 'name' => 'new' . $tax_name . '_parent', |
|
138 | + 'orderby' => 'name', |
|
139 | + 'hierarchical' => 1, |
|
140 | + 'show_option_none' => '— ' . $taxonomy->labels->parent_item . ' —', |
|
141 | + ); |
|
142 | 142 | |
143 | - /** |
|
144 | - * Filters the arguments for the taxonomy parent dropdown on the Post Edit page. |
|
145 | - * |
|
146 | - * @param array $parent_dropdown_args { |
|
147 | - * Optional. Array of arguments to generate parent dropdown. |
|
148 | - * |
|
149 | - * @type string $taxonomy Name of the taxonomy to retrieve. |
|
150 | - * @type bool $hide_if_empty True to skip generating markup if no |
|
151 | - * categories are found. Default 0. |
|
152 | - * @type string $name Value for the 'name' attribute |
|
153 | - * of the select element. |
|
154 | - * Default "new{$tax_name}_parent". |
|
155 | - * @type string $orderby Which column to use for ordering |
|
156 | - * terms. Default 'name'. |
|
157 | - * @type bool|int $hierarchical Whether to traverse the taxonomy |
|
158 | - * hierarchy. Default 1. |
|
159 | - * @type string $show_option_none Text to display for the "none" option. |
|
160 | - * Default "— {$parent} —", |
|
161 | - * where `$parent` is 'parent_item' |
|
162 | - * taxonomy label. |
|
163 | - * } |
|
164 | - * @since 4.4.0 |
|
165 | - */ |
|
166 | - $parent_dropdown_args = apply_filters( 'post_edit_category_parent_dropdown_args', $parent_dropdown_args ); |
|
143 | + /** |
|
144 | + * Filters the arguments for the taxonomy parent dropdown on the Post Edit page. |
|
145 | + * |
|
146 | + * @param array $parent_dropdown_args { |
|
147 | + * Optional. Array of arguments to generate parent dropdown. |
|
148 | + * |
|
149 | + * @type string $taxonomy Name of the taxonomy to retrieve. |
|
150 | + * @type bool $hide_if_empty True to skip generating markup if no |
|
151 | + * categories are found. Default 0. |
|
152 | + * @type string $name Value for the 'name' attribute |
|
153 | + * of the select element. |
|
154 | + * Default "new{$tax_name}_parent". |
|
155 | + * @type string $orderby Which column to use for ordering |
|
156 | + * terms. Default 'name'. |
|
157 | + * @type bool|int $hierarchical Whether to traverse the taxonomy |
|
158 | + * hierarchy. Default 1. |
|
159 | + * @type string $show_option_none Text to display for the "none" option. |
|
160 | + * Default "— {$parent} —", |
|
161 | + * where `$parent` is 'parent_item' |
|
162 | + * taxonomy label. |
|
163 | + * } |
|
164 | + * @since 4.4.0 |
|
165 | + */ |
|
166 | + $parent_dropdown_args = apply_filters( 'post_edit_category_parent_dropdown_args', $parent_dropdown_args ); |
|
167 | 167 | |
168 | - wp_dropdown_categories( $parent_dropdown_args ); |
|
169 | - ?> |
|
168 | + wp_dropdown_categories( $parent_dropdown_args ); |
|
169 | + ?> |
|
170 | 170 | <input type="button" id="<?php echo esc_attr( $tax_name ); ?>-add-submit" |
171 | 171 | data-wp-lists="add:<?php echo esc_html( $tax_name ); ?>checklist:<?php echo esc_attr( $tax_name ); ?>-add" |
172 | 172 | class="button category-add-submit" |
@@ -178,6 +178,6 @@ discard block |
||
178 | 178 | <?php endif; ?> |
179 | 179 | </div> |
180 | 180 | <?php |
181 | - } |
|
181 | + } |
|
182 | 182 | |
183 | 183 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | get_post(), |
29 | 29 | array( |
30 | 30 | 'args' => |
31 | - array( 'taxonomy' => Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ), |
|
31 | + array('taxonomy' => Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME), |
|
32 | 32 | ) |
33 | 33 | ); |
34 | 34 | |
@@ -43,47 +43,47 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @since 3.20.0 |
45 | 45 | */ |
46 | - private static function post_categories_meta_box( $post, $box ) { |
|
47 | - $defaults = array( 'taxonomy' => 'category' ); |
|
48 | - if ( ! isset( $box['args'] ) || ! is_array( $box['args'] ) ) { |
|
46 | + private static function post_categories_meta_box($post, $box) { |
|
47 | + $defaults = array('taxonomy' => 'category'); |
|
48 | + if ( ! isset($box['args']) || ! is_array($box['args'])) { |
|
49 | 49 | $args = array(); |
50 | 50 | } else { |
51 | 51 | $args = $box['args']; |
52 | 52 | } |
53 | - $r = wp_parse_args( $args, $defaults ); |
|
54 | - $tax_name = esc_attr( $r['taxonomy'] ); |
|
55 | - $taxonomy = get_taxonomy( $r['taxonomy'] ); |
|
53 | + $r = wp_parse_args($args, $defaults); |
|
54 | + $tax_name = esc_attr($r['taxonomy']); |
|
55 | + $taxonomy = get_taxonomy($r['taxonomy']); |
|
56 | 56 | ?> |
57 | - <div id="taxonomy-<?php echo esc_attr( $tax_name ); ?>" class="categorydiv"> |
|
58 | - <ul id="<?php echo esc_attr( $tax_name ); ?>-tabs" class="category-tabs"> |
|
57 | + <div id="taxonomy-<?php echo esc_attr($tax_name); ?>" class="categorydiv"> |
|
58 | + <ul id="<?php echo esc_attr($tax_name); ?>-tabs" class="category-tabs"> |
|
59 | 59 | <li class="tabs"><a |
60 | - href="#<?php echo esc_attr( $tax_name ); ?>-all"><?php echo esc_html( $taxonomy->labels->all_items ); ?></a> |
|
60 | + href="#<?php echo esc_attr($tax_name); ?>-all"><?php echo esc_html($taxonomy->labels->all_items); ?></a> |
|
61 | 61 | </li> |
62 | 62 | <li> |
63 | - <a href="#<?php echo esc_attr( $tax_name ); ?>-pop"><?php echo esc_html__( 'Most Used', 'wordlift' ); ?></a> |
|
63 | + <a href="#<?php echo esc_attr($tax_name); ?>-pop"><?php echo esc_html__('Most Used', 'wordlift'); ?></a> |
|
64 | 64 | </li> |
65 | - <li><a href="#<?php echo esc_attr( $tax_name ); ?>-legacy"> |
|
66 | - <?php echo esc_html_x( 'A-Z', 'Entity Types metabox', 'wordlift' ); ?></a> |
|
65 | + <li><a href="#<?php echo esc_attr($tax_name); ?>-legacy"> |
|
66 | + <?php echo esc_html_x('A-Z', 'Entity Types metabox', 'wordlift'); ?></a> |
|
67 | 67 | </li> |
68 | 68 | </ul> |
69 | 69 | |
70 | - <div id="<?php echo esc_attr( $tax_name ); ?>-all" class="tabs-panel"> |
|
70 | + <div id="<?php echo esc_attr($tax_name); ?>-all" class="tabs-panel"> |
|
71 | 71 | <div id="wl-schema-class-tree"></div> |
72 | 72 | </div> |
73 | 73 | |
74 | - <div id="<?php echo esc_attr( $tax_name ); ?>-pop" class="tabs-panel" style="display: none;"> |
|
75 | - <ul id="<?php echo esc_attr( $tax_name ); ?>checklist-pop" class="categorychecklist form-no-clear"> |
|
76 | - <?php $popular_ids = wp_popular_terms_checklist( $tax_name ); ?> |
|
74 | + <div id="<?php echo esc_attr($tax_name); ?>-pop" class="tabs-panel" style="display: none;"> |
|
75 | + <ul id="<?php echo esc_attr($tax_name); ?>checklist-pop" class="categorychecklist form-no-clear"> |
|
76 | + <?php $popular_ids = wp_popular_terms_checklist($tax_name); ?> |
|
77 | 77 | </ul> |
78 | 78 | </div> |
79 | 79 | |
80 | - <div id="<?php echo esc_attr( $tax_name ); ?>-legacy" class="tabs-panel" style="display: none;"> |
|
80 | + <div id="<?php echo esc_attr($tax_name); ?>-legacy" class="tabs-panel" style="display: none;"> |
|
81 | 81 | <?php |
82 | - $name = ( 'category' === $tax_name ) ? 'post_category' : 'tax_input[' . $tax_name . ']'; |
|
82 | + $name = ('category' === $tax_name) ? 'post_category' : 'tax_input['.$tax_name.']'; |
|
83 | 83 | echo wp_kses( |
84 | 84 | sprintf( |
85 | 85 | "<input type='hidden' name='%s[]' value='0' />", |
86 | - esc_attr( $name ) |
|
86 | + esc_attr($name) |
|
87 | 87 | ), |
88 | 88 | array( |
89 | 89 | 'input' => |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | ) |
96 | 96 | ); // Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks. |
97 | 97 | ?> |
98 | - <ul id="<?php echo esc_attr( $tax_name ); ?>checklist" |
|
99 | - data-wp-lists="list:<?php echo esc_attr( $tax_name ); ?>" |
|
98 | + <ul id="<?php echo esc_attr($tax_name); ?>checklist" |
|
99 | + data-wp-lists="list:<?php echo esc_attr($tax_name); ?>" |
|
100 | 100 | class="categorychecklist form-no-clear"> |
101 | 101 | <?php |
102 | 102 | wp_terms_checklist( |
@@ -109,35 +109,35 @@ discard block |
||
109 | 109 | ?> |
110 | 110 | </ul> |
111 | 111 | </div> |
112 | - <?php if ( current_user_can( $taxonomy->cap->edit_terms ) ) : ?> |
|
113 | - <div id="<?php echo esc_attr( $tax_name ); ?>-adder" class="wp-hidden-children"> |
|
114 | - <a id="<?php echo esc_attr( $tax_name ); ?>-add-toggle" |
|
115 | - href="#<?php echo esc_attr( $tax_name ); ?>-add" |
|
112 | + <?php if (current_user_can($taxonomy->cap->edit_terms)) : ?> |
|
113 | + <div id="<?php echo esc_attr($tax_name); ?>-adder" class="wp-hidden-children"> |
|
114 | + <a id="<?php echo esc_attr($tax_name); ?>-add-toggle" |
|
115 | + href="#<?php echo esc_attr($tax_name); ?>-add" |
|
116 | 116 | class="taxonomy-add-new"> |
117 | 117 | <?php |
118 | 118 | /* translators: %s: add new taxonomy label */ |
119 | - echo esc_html( sprintf( __( '+ %s', 'default' ), $taxonomy->labels->add_new_item ) ); |
|
119 | + echo esc_html(sprintf(__('+ %s', 'default'), $taxonomy->labels->add_new_item)); |
|
120 | 120 | ?> |
121 | 121 | </a> |
122 | - <p id="<?php echo esc_attr( $tax_name ); ?>-add" class="category-add wp-hidden-child"> |
|
122 | + <p id="<?php echo esc_attr($tax_name); ?>-add" class="category-add wp-hidden-child"> |
|
123 | 123 | <label class="screen-reader-text" |
124 | - for="new<?php echo esc_attr( $tax_name ); ?>"><?php echo esc_html( $taxonomy->labels->add_new_item ); ?></label> |
|
125 | - <input type="text" name="new<?php echo esc_html( $tax_name ); ?>" |
|
126 | - id="new<?php echo esc_attr( $tax_name ); ?>" |
|
124 | + for="new<?php echo esc_attr($tax_name); ?>"><?php echo esc_html($taxonomy->labels->add_new_item); ?></label> |
|
125 | + <input type="text" name="new<?php echo esc_html($tax_name); ?>" |
|
126 | + id="new<?php echo esc_attr($tax_name); ?>" |
|
127 | 127 | class="form-required form-input-tip" |
128 | - value="<?php echo esc_attr( $taxonomy->labels->new_item_name ); ?>" |
|
128 | + value="<?php echo esc_attr($taxonomy->labels->new_item_name); ?>" |
|
129 | 129 | aria-required="true"/> |
130 | - <label class="screen-reader-text" for="new<?php echo esc_attr( $tax_name ); ?>_parent"> |
|
131 | - <?php echo esc_html( $taxonomy->labels->parent_item_colon ); ?> |
|
130 | + <label class="screen-reader-text" for="new<?php echo esc_attr($tax_name); ?>_parent"> |
|
131 | + <?php echo esc_html($taxonomy->labels->parent_item_colon); ?> |
|
132 | 132 | </label> |
133 | 133 | <?php |
134 | 134 | $parent_dropdown_args = array( |
135 | 135 | 'taxonomy' => $tax_name, |
136 | 136 | 'hide_empty' => 0, |
137 | - 'name' => 'new' . $tax_name . '_parent', |
|
137 | + 'name' => 'new'.$tax_name.'_parent', |
|
138 | 138 | 'orderby' => 'name', |
139 | 139 | 'hierarchical' => 1, |
140 | - 'show_option_none' => '— ' . $taxonomy->labels->parent_item . ' —', |
|
140 | + 'show_option_none' => '— '.$taxonomy->labels->parent_item.' —', |
|
141 | 141 | ); |
142 | 142 | |
143 | 143 | /** |
@@ -163,16 +163,16 @@ discard block |
||
163 | 163 | * } |
164 | 164 | * @since 4.4.0 |
165 | 165 | */ |
166 | - $parent_dropdown_args = apply_filters( 'post_edit_category_parent_dropdown_args', $parent_dropdown_args ); |
|
166 | + $parent_dropdown_args = apply_filters('post_edit_category_parent_dropdown_args', $parent_dropdown_args); |
|
167 | 167 | |
168 | - wp_dropdown_categories( $parent_dropdown_args ); |
|
168 | + wp_dropdown_categories($parent_dropdown_args); |
|
169 | 169 | ?> |
170 | - <input type="button" id="<?php echo esc_attr( $tax_name ); ?>-add-submit" |
|
171 | - data-wp-lists="add:<?php echo esc_html( $tax_name ); ?>checklist:<?php echo esc_attr( $tax_name ); ?>-add" |
|
170 | + <input type="button" id="<?php echo esc_attr($tax_name); ?>-add-submit" |
|
171 | + data-wp-lists="add:<?php echo esc_html($tax_name); ?>checklist:<?php echo esc_attr($tax_name); ?>-add" |
|
172 | 172 | class="button category-add-submit" |
173 | - value="<?php echo esc_attr( $taxonomy->labels->add_new_item ); ?>"/> |
|
174 | - <?php wp_nonce_field( 'add-' . $tax_name, '_ajax_nonce-add-' . $tax_name, false ); ?> |
|
175 | - <span id="<?php echo esc_attr( $tax_name ); ?>-ajax-response"></span> |
|
173 | + value="<?php echo esc_attr($taxonomy->labels->add_new_item); ?>"/> |
|
174 | + <?php wp_nonce_field('add-'.$tax_name, '_ajax_nonce-add-'.$tax_name, false); ?> |
|
175 | + <span id="<?php echo esc_attr($tax_name); ?>-ajax-response"></span> |
|
176 | 176 | </p> |
177 | 177 | </div> |
178 | 178 | <?php endif; ?> |
@@ -4,95 +4,95 @@ discard block |
||
4 | 4 | |
5 | 5 | class Wordlift_Admin_Dashboard_V2 { |
6 | 6 | |
7 | - const TODAYS_TIP = 'wl_todays_tip_data'; |
|
8 | - const AVERAGE_POSITION = 'wl_search_rankings_average_position'; |
|
9 | - |
|
10 | - /** |
|
11 | - * @var \Wordlift_Entity_Service $entity_service |
|
12 | - */ |
|
13 | - private $entity_service; |
|
14 | - |
|
15 | - /** |
|
16 | - * Wordlift_Admin_Dashboard_V2 constructor. |
|
17 | - * |
|
18 | - * @since 3.20.0 |
|
19 | - */ |
|
20 | - public function __construct( $entity_service ) { |
|
21 | - |
|
22 | - add_action( 'wp_dashboard_setup', array( $this, 'dashboard_setup' ) ); |
|
23 | - |
|
24 | - // Define where to access the tip. |
|
25 | - defined( 'WL_TODAYS_TIP_JSON_URL' ) || define( 'WL_TODAYS_TIP_JSON_URL', 'https://wordlift.io/blog' ); |
|
26 | - defined( 'WL_TODAYS_TIP_JSON_URL_IT' ) || define( 'WL_TODAYS_TIP_JSON_URL_IT', '/it/wp-json/wp/v2/posts?context=embed&per_page=1&categories=27' ); |
|
27 | - defined( 'WL_TODAYS_TIP_JSON_URL_EN' ) || define( 'WL_TODAYS_TIP_JSON_URL_EN', '/en/wp-json/wp/v2/posts?context=embed&per_page=1&categories=38' ); |
|
28 | - $this->entity_service = $entity_service; |
|
29 | - |
|
30 | - } |
|
31 | - |
|
32 | - /** |
|
33 | - * Set up the dashboard metabox. |
|
34 | - * |
|
35 | - * @since 3.20.0 |
|
36 | - */ |
|
37 | - public function dashboard_setup() { |
|
38 | - /** |
|
39 | - * Filter name: wl_feature__enable__wordlift-dashboard |
|
40 | - * Feature flag to enable / disable dashboard |
|
41 | - * |
|
42 | - * @since 3.30.0 |
|
43 | - */ |
|
7 | + const TODAYS_TIP = 'wl_todays_tip_data'; |
|
8 | + const AVERAGE_POSITION = 'wl_search_rankings_average_position'; |
|
9 | + |
|
10 | + /** |
|
11 | + * @var \Wordlift_Entity_Service $entity_service |
|
12 | + */ |
|
13 | + private $entity_service; |
|
14 | + |
|
15 | + /** |
|
16 | + * Wordlift_Admin_Dashboard_V2 constructor. |
|
17 | + * |
|
18 | + * @since 3.20.0 |
|
19 | + */ |
|
20 | + public function __construct( $entity_service ) { |
|
21 | + |
|
22 | + add_action( 'wp_dashboard_setup', array( $this, 'dashboard_setup' ) ); |
|
23 | + |
|
24 | + // Define where to access the tip. |
|
25 | + defined( 'WL_TODAYS_TIP_JSON_URL' ) || define( 'WL_TODAYS_TIP_JSON_URL', 'https://wordlift.io/blog' ); |
|
26 | + defined( 'WL_TODAYS_TIP_JSON_URL_IT' ) || define( 'WL_TODAYS_TIP_JSON_URL_IT', '/it/wp-json/wp/v2/posts?context=embed&per_page=1&categories=27' ); |
|
27 | + defined( 'WL_TODAYS_TIP_JSON_URL_EN' ) || define( 'WL_TODAYS_TIP_JSON_URL_EN', '/en/wp-json/wp/v2/posts?context=embed&per_page=1&categories=38' ); |
|
28 | + $this->entity_service = $entity_service; |
|
29 | + |
|
30 | + } |
|
31 | + |
|
32 | + /** |
|
33 | + * Set up the dashboard metabox. |
|
34 | + * |
|
35 | + * @since 3.20.0 |
|
36 | + */ |
|
37 | + public function dashboard_setup() { |
|
38 | + /** |
|
39 | + * Filter name: wl_feature__enable__wordlift-dashboard |
|
40 | + * Feature flag to enable / disable dashboard |
|
41 | + * |
|
42 | + * @since 3.30.0 |
|
43 | + */ |
|
44 | 44 | // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
45 | - if ( apply_filters( 'wl_feature__enable__wordlift-dashboard', true ) ) { |
|
46 | - wp_add_dashboard_widget( |
|
47 | - 'wl-dashboard-v2', |
|
48 | - __( 'WordLift Dashboard', 'wordlift' ), |
|
49 | - array( $this, 'dashboard_setup_callback' ) |
|
50 | - ); |
|
51 | - } |
|
52 | - |
|
53 | - } |
|
54 | - |
|
55 | - /** |
|
56 | - * The dashboard setup callback. |
|
57 | - * |
|
58 | - * @since 3.20.0 |
|
59 | - */ |
|
60 | - public function dashboard_setup_callback() { |
|
61 | - |
|
62 | - require_once plugin_dir_path( __DIR__ ) . 'admin/partials/wordlift-admin-dashboard-v2.php'; |
|
63 | - |
|
64 | - } |
|
65 | - |
|
66 | - /** |
|
67 | - * Get the top entities. |
|
68 | - * |
|
69 | - * @return array|object|null An array of top entities. |
|
70 | - * @since 3.20.0 |
|
71 | - */ |
|
72 | - private function get_top_entities() { |
|
73 | - /** |
|
74 | - * @since 3.27.7 |
|
75 | - * @see https://github.com/insideout10/wordlift-plugin/issues/1214 |
|
76 | - * Top entities are generated by cron now. |
|
77 | - */ |
|
78 | - return get_option( Top_Entities::OPTION_KEY, array() ); |
|
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * Get the today's tip block. |
|
83 | - * |
|
84 | - * @since 3.20.0 |
|
85 | - */ |
|
86 | - public static function get_todays_tip_block() { |
|
45 | + if ( apply_filters( 'wl_feature__enable__wordlift-dashboard', true ) ) { |
|
46 | + wp_add_dashboard_widget( |
|
47 | + 'wl-dashboard-v2', |
|
48 | + __( 'WordLift Dashboard', 'wordlift' ), |
|
49 | + array( $this, 'dashboard_setup_callback' ) |
|
50 | + ); |
|
51 | + } |
|
52 | + |
|
53 | + } |
|
54 | + |
|
55 | + /** |
|
56 | + * The dashboard setup callback. |
|
57 | + * |
|
58 | + * @since 3.20.0 |
|
59 | + */ |
|
60 | + public function dashboard_setup_callback() { |
|
61 | + |
|
62 | + require_once plugin_dir_path( __DIR__ ) . 'admin/partials/wordlift-admin-dashboard-v2.php'; |
|
63 | + |
|
64 | + } |
|
65 | + |
|
66 | + /** |
|
67 | + * Get the top entities. |
|
68 | + * |
|
69 | + * @return array|object|null An array of top entities. |
|
70 | + * @since 3.20.0 |
|
71 | + */ |
|
72 | + private function get_top_entities() { |
|
73 | + /** |
|
74 | + * @since 3.27.7 |
|
75 | + * @see https://github.com/insideout10/wordlift-plugin/issues/1214 |
|
76 | + * Top entities are generated by cron now. |
|
77 | + */ |
|
78 | + return get_option( Top_Entities::OPTION_KEY, array() ); |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * Get the today's tip block. |
|
83 | + * |
|
84 | + * @since 3.20.0 |
|
85 | + */ |
|
86 | + public static function get_todays_tip_block() { |
|
87 | 87 | |
88 | 88 | // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged |
89 | - $data = @self::get_todays_tip_data(); |
|
89 | + $data = @self::get_todays_tip_data(); |
|
90 | 90 | |
91 | - // Unable to get data from the local cache, nor from the remote URL. |
|
92 | - if ( false === $data ) { |
|
93 | - return; |
|
94 | - } |
|
95 | - ?> |
|
91 | + // Unable to get data from the local cache, nor from the remote URL. |
|
92 | + if ( false === $data ) { |
|
93 | + return; |
|
94 | + } |
|
95 | + ?> |
|
96 | 96 | |
97 | 97 | <div id="wl-todays-tip" class="wl-dashboard__block wl-dashboard__block--todays-tip"> |
98 | 98 | <header> |
@@ -107,52 +107,52 @@ discard block |
||
107 | 107 | </div> |
108 | 108 | <?php |
109 | 109 | |
110 | - } |
|
111 | - |
|
112 | - /** |
|
113 | - * Get the today's tip data. |
|
114 | - * |
|
115 | - * @return array|false The today's tip data or false in case of error. |
|
116 | - * @since 3.20.0 |
|
117 | - */ |
|
118 | - private static function get_todays_tip_data() { |
|
119 | - |
|
120 | - // Return the transient. |
|
121 | - if ( false !== get_transient( self::TODAYS_TIP ) ) { |
|
122 | - return get_transient( self::TODAYS_TIP ); |
|
123 | - } |
|
124 | - |
|
125 | - // If the transient isn't available, query the remote web site. |
|
126 | - $url = WL_TODAYS_TIP_JSON_URL |
|
127 | - . ( 'it' === get_bloginfo( 'language' ) ? WL_TODAYS_TIP_JSON_URL_IT : WL_TODAYS_TIP_JSON_URL_EN ); |
|
128 | - |
|
129 | - $response = wp_remote_get( $url ); |
|
130 | - |
|
131 | - if ( is_wp_error( $response ) |
|
132 | - || ! isset( $response['response']['code'] ) |
|
133 | - || 2 !== (int) $response['response']['code'] / 100 ) { |
|
134 | - return false; |
|
135 | - } |
|
136 | - |
|
137 | - $json = json_decode( $response['body'], true ); |
|
138 | - |
|
139 | - if ( empty( $json ) |
|
140 | - || ! isset( $json[0]['title']['rendered'] ) |
|
141 | - || ! isset( $json[0]['excerpt']['rendered'] ) |
|
142 | - || ! isset( $json[0]['link'] ) ) { |
|
143 | - return false; |
|
144 | - } |
|
145 | - |
|
146 | - $value = array( |
|
147 | - 'title' => $json[0]['title']['rendered'], |
|
148 | - 'excerpt' => '<!-- cached -->' . $json[0]['excerpt']['rendered'], |
|
149 | - 'link' => $json[0]['link'], |
|
150 | - ); |
|
151 | - |
|
152 | - // Store the results for one day. |
|
153 | - set_transient( self::TODAYS_TIP, $value, 86400 ); |
|
154 | - |
|
155 | - return $value; |
|
156 | - } |
|
110 | + } |
|
111 | + |
|
112 | + /** |
|
113 | + * Get the today's tip data. |
|
114 | + * |
|
115 | + * @return array|false The today's tip data or false in case of error. |
|
116 | + * @since 3.20.0 |
|
117 | + */ |
|
118 | + private static function get_todays_tip_data() { |
|
119 | + |
|
120 | + // Return the transient. |
|
121 | + if ( false !== get_transient( self::TODAYS_TIP ) ) { |
|
122 | + return get_transient( self::TODAYS_TIP ); |
|
123 | + } |
|
124 | + |
|
125 | + // If the transient isn't available, query the remote web site. |
|
126 | + $url = WL_TODAYS_TIP_JSON_URL |
|
127 | + . ( 'it' === get_bloginfo( 'language' ) ? WL_TODAYS_TIP_JSON_URL_IT : WL_TODAYS_TIP_JSON_URL_EN ); |
|
128 | + |
|
129 | + $response = wp_remote_get( $url ); |
|
130 | + |
|
131 | + if ( is_wp_error( $response ) |
|
132 | + || ! isset( $response['response']['code'] ) |
|
133 | + || 2 !== (int) $response['response']['code'] / 100 ) { |
|
134 | + return false; |
|
135 | + } |
|
136 | + |
|
137 | + $json = json_decode( $response['body'], true ); |
|
138 | + |
|
139 | + if ( empty( $json ) |
|
140 | + || ! isset( $json[0]['title']['rendered'] ) |
|
141 | + || ! isset( $json[0]['excerpt']['rendered'] ) |
|
142 | + || ! isset( $json[0]['link'] ) ) { |
|
143 | + return false; |
|
144 | + } |
|
145 | + |
|
146 | + $value = array( |
|
147 | + 'title' => $json[0]['title']['rendered'], |
|
148 | + 'excerpt' => '<!-- cached -->' . $json[0]['excerpt']['rendered'], |
|
149 | + 'link' => $json[0]['link'], |
|
150 | + ); |
|
151 | + |
|
152 | + // Store the results for one day. |
|
153 | + set_transient( self::TODAYS_TIP, $value, 86400 ); |
|
154 | + |
|
155 | + return $value; |
|
156 | + } |
|
157 | 157 | |
158 | 158 | } |
@@ -17,14 +17,14 @@ discard block |
||
17 | 17 | * |
18 | 18 | * @since 3.20.0 |
19 | 19 | */ |
20 | - public function __construct( $entity_service ) { |
|
20 | + public function __construct($entity_service) { |
|
21 | 21 | |
22 | - add_action( 'wp_dashboard_setup', array( $this, 'dashboard_setup' ) ); |
|
22 | + add_action('wp_dashboard_setup', array($this, 'dashboard_setup')); |
|
23 | 23 | |
24 | 24 | // Define where to access the tip. |
25 | - defined( 'WL_TODAYS_TIP_JSON_URL' ) || define( 'WL_TODAYS_TIP_JSON_URL', 'https://wordlift.io/blog' ); |
|
26 | - defined( 'WL_TODAYS_TIP_JSON_URL_IT' ) || define( 'WL_TODAYS_TIP_JSON_URL_IT', '/it/wp-json/wp/v2/posts?context=embed&per_page=1&categories=27' ); |
|
27 | - defined( 'WL_TODAYS_TIP_JSON_URL_EN' ) || define( 'WL_TODAYS_TIP_JSON_URL_EN', '/en/wp-json/wp/v2/posts?context=embed&per_page=1&categories=38' ); |
|
25 | + defined('WL_TODAYS_TIP_JSON_URL') || define('WL_TODAYS_TIP_JSON_URL', 'https://wordlift.io/blog'); |
|
26 | + defined('WL_TODAYS_TIP_JSON_URL_IT') || define('WL_TODAYS_TIP_JSON_URL_IT', '/it/wp-json/wp/v2/posts?context=embed&per_page=1&categories=27'); |
|
27 | + defined('WL_TODAYS_TIP_JSON_URL_EN') || define('WL_TODAYS_TIP_JSON_URL_EN', '/en/wp-json/wp/v2/posts?context=embed&per_page=1&categories=38'); |
|
28 | 28 | $this->entity_service = $entity_service; |
29 | 29 | |
30 | 30 | } |
@@ -42,11 +42,11 @@ discard block |
||
42 | 42 | * @since 3.30.0 |
43 | 43 | */ |
44 | 44 | // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
45 | - if ( apply_filters( 'wl_feature__enable__wordlift-dashboard', true ) ) { |
|
45 | + if (apply_filters('wl_feature__enable__wordlift-dashboard', true)) { |
|
46 | 46 | wp_add_dashboard_widget( |
47 | 47 | 'wl-dashboard-v2', |
48 | - __( 'WordLift Dashboard', 'wordlift' ), |
|
49 | - array( $this, 'dashboard_setup_callback' ) |
|
48 | + __('WordLift Dashboard', 'wordlift'), |
|
49 | + array($this, 'dashboard_setup_callback') |
|
50 | 50 | ); |
51 | 51 | } |
52 | 52 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function dashboard_setup_callback() { |
61 | 61 | |
62 | - require_once plugin_dir_path( __DIR__ ) . 'admin/partials/wordlift-admin-dashboard-v2.php'; |
|
62 | + require_once plugin_dir_path(__DIR__).'admin/partials/wordlift-admin-dashboard-v2.php'; |
|
63 | 63 | |
64 | 64 | } |
65 | 65 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * @see https://github.com/insideout10/wordlift-plugin/issues/1214 |
76 | 76 | * Top entities are generated by cron now. |
77 | 77 | */ |
78 | - return get_option( Top_Entities::OPTION_KEY, array() ); |
|
78 | + return get_option(Top_Entities::OPTION_KEY, array()); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -89,20 +89,20 @@ discard block |
||
89 | 89 | $data = @self::get_todays_tip_data(); |
90 | 90 | |
91 | 91 | // Unable to get data from the local cache, nor from the remote URL. |
92 | - if ( false === $data ) { |
|
92 | + if (false === $data) { |
|
93 | 93 | return; |
94 | 94 | } |
95 | 95 | ?> |
96 | 96 | |
97 | 97 | <div id="wl-todays-tip" class="wl-dashboard__block wl-dashboard__block--todays-tip"> |
98 | 98 | <header> |
99 | - <h3><?php esc_html_e( "Today's Tip", 'wordlift' ); ?></h3> |
|
99 | + <h3><?php esc_html_e("Today's Tip", 'wordlift'); ?></h3> |
|
100 | 100 | </header> |
101 | 101 | <article> |
102 | - <p><strong><?php echo esc_html( wp_strip_all_tags( $data['title'] ) ); ?></strong> |
|
103 | - <?php echo esc_html( wp_strip_all_tags( $data['excerpt'] ) ); ?> |
|
102 | + <p><strong><?php echo esc_html(wp_strip_all_tags($data['title'])); ?></strong> |
|
103 | + <?php echo esc_html(wp_strip_all_tags($data['excerpt'])); ?> |
|
104 | 104 | <a target="_blank" |
105 | - href="<?php echo esc_attr( $data['link'] ); ?>"><?php echo esc_html( __( 'Read more', 'wordlift' ) ); ?></a> |
|
105 | + href="<?php echo esc_attr($data['link']); ?>"><?php echo esc_html(__('Read more', 'wordlift')); ?></a> |
|
106 | 106 | </p> |
107 | 107 | </div> |
108 | 108 | <?php |
@@ -118,39 +118,39 @@ discard block |
||
118 | 118 | private static function get_todays_tip_data() { |
119 | 119 | |
120 | 120 | // Return the transient. |
121 | - if ( false !== get_transient( self::TODAYS_TIP ) ) { |
|
122 | - return get_transient( self::TODAYS_TIP ); |
|
121 | + if (false !== get_transient(self::TODAYS_TIP)) { |
|
122 | + return get_transient(self::TODAYS_TIP); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | // If the transient isn't available, query the remote web site. |
126 | 126 | $url = WL_TODAYS_TIP_JSON_URL |
127 | - . ( 'it' === get_bloginfo( 'language' ) ? WL_TODAYS_TIP_JSON_URL_IT : WL_TODAYS_TIP_JSON_URL_EN ); |
|
127 | + . ('it' === get_bloginfo('language') ? WL_TODAYS_TIP_JSON_URL_IT : WL_TODAYS_TIP_JSON_URL_EN); |
|
128 | 128 | |
129 | - $response = wp_remote_get( $url ); |
|
129 | + $response = wp_remote_get($url); |
|
130 | 130 | |
131 | - if ( is_wp_error( $response ) |
|
132 | - || ! isset( $response['response']['code'] ) |
|
133 | - || 2 !== (int) $response['response']['code'] / 100 ) { |
|
131 | + if (is_wp_error($response) |
|
132 | + || ! isset($response['response']['code']) |
|
133 | + || 2 !== (int) $response['response']['code'] / 100) { |
|
134 | 134 | return false; |
135 | 135 | } |
136 | 136 | |
137 | - $json = json_decode( $response['body'], true ); |
|
137 | + $json = json_decode($response['body'], true); |
|
138 | 138 | |
139 | - if ( empty( $json ) |
|
140 | - || ! isset( $json[0]['title']['rendered'] ) |
|
141 | - || ! isset( $json[0]['excerpt']['rendered'] ) |
|
142 | - || ! isset( $json[0]['link'] ) ) { |
|
139 | + if (empty($json) |
|
140 | + || ! isset($json[0]['title']['rendered']) |
|
141 | + || ! isset($json[0]['excerpt']['rendered']) |
|
142 | + || ! isset($json[0]['link'])) { |
|
143 | 143 | return false; |
144 | 144 | } |
145 | 145 | |
146 | 146 | $value = array( |
147 | 147 | 'title' => $json[0]['title']['rendered'], |
148 | - 'excerpt' => '<!-- cached -->' . $json[0]['excerpt']['rendered'], |
|
148 | + 'excerpt' => '<!-- cached -->'.$json[0]['excerpt']['rendered'], |
|
149 | 149 | 'link' => $json[0]['link'], |
150 | 150 | ); |
151 | 151 | |
152 | 152 | // Store the results for one day. |
153 | - set_transient( self::TODAYS_TIP, $value, 86400 ); |
|
153 | + set_transient(self::TODAYS_TIP, $value, 86400); |
|
154 | 154 | |
155 | 155 | return $value; |
156 | 156 | } |
@@ -11,36 +11,36 @@ |
||
11 | 11 | */ |
12 | 12 | function wl_shortcode_field( $atts ) { |
13 | 13 | |
14 | - // Extract attributes and set default values. |
|
15 | - $field_atts = shortcode_atts( |
|
16 | - array( |
|
17 | - 'id' => null, |
|
18 | - 'name' => null, |
|
19 | - ), |
|
20 | - $atts |
|
21 | - ); |
|
22 | - |
|
23 | - // Get id of the post |
|
24 | - $entity_id = $field_atts['id']; |
|
25 | - if ( $field_atts['id'] === null || ! is_numeric( $field_atts['id'] ) ) { |
|
26 | - $entity_id = get_the_ID(); |
|
27 | - } |
|
28 | - |
|
29 | - $property_name = $field_atts['name']; |
|
30 | - if ( $property_name !== null ) { |
|
31 | - $values = wl_schema_get_value( $entity_id, $property_name ); |
|
32 | - } |
|
33 | - |
|
34 | - // Return |
|
35 | - if ( is_array( $values ) ) { |
|
36 | - return implode( ', ', $values ); |
|
37 | - } else { |
|
38 | - return null; |
|
39 | - } |
|
14 | + // Extract attributes and set default values. |
|
15 | + $field_atts = shortcode_atts( |
|
16 | + array( |
|
17 | + 'id' => null, |
|
18 | + 'name' => null, |
|
19 | + ), |
|
20 | + $atts |
|
21 | + ); |
|
22 | + |
|
23 | + // Get id of the post |
|
24 | + $entity_id = $field_atts['id']; |
|
25 | + if ( $field_atts['id'] === null || ! is_numeric( $field_atts['id'] ) ) { |
|
26 | + $entity_id = get_the_ID(); |
|
27 | + } |
|
28 | + |
|
29 | + $property_name = $field_atts['name']; |
|
30 | + if ( $property_name !== null ) { |
|
31 | + $values = wl_schema_get_value( $entity_id, $property_name ); |
|
32 | + } |
|
33 | + |
|
34 | + // Return |
|
35 | + if ( is_array( $values ) ) { |
|
36 | + return implode( ', ', $values ); |
|
37 | + } else { |
|
38 | + return null; |
|
39 | + } |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | function wl_register_shortcode_field() { |
43 | - add_shortcode( 'wl_field', 'wl_shortcode_field' ); |
|
43 | + add_shortcode( 'wl_field', 'wl_shortcode_field' ); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | add_action( 'init', 'wl_register_shortcode_field' ); |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @param array $atts An array of shortcode attributes. |
10 | 10 | * @return string A dom element with requested property value(s). |
11 | 11 | */ |
12 | -function wl_shortcode_field( $atts ) { |
|
12 | +function wl_shortcode_field($atts) { |
|
13 | 13 | |
14 | 14 | // Extract attributes and set default values. |
15 | 15 | $field_atts = shortcode_atts( |
@@ -22,26 +22,26 @@ discard block |
||
22 | 22 | |
23 | 23 | // Get id of the post |
24 | 24 | $entity_id = $field_atts['id']; |
25 | - if ( $field_atts['id'] === null || ! is_numeric( $field_atts['id'] ) ) { |
|
25 | + if ($field_atts['id'] === null || ! is_numeric($field_atts['id'])) { |
|
26 | 26 | $entity_id = get_the_ID(); |
27 | 27 | } |
28 | 28 | |
29 | 29 | $property_name = $field_atts['name']; |
30 | - if ( $property_name !== null ) { |
|
31 | - $values = wl_schema_get_value( $entity_id, $property_name ); |
|
30 | + if ($property_name !== null) { |
|
31 | + $values = wl_schema_get_value($entity_id, $property_name); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | // Return |
35 | - if ( is_array( $values ) ) { |
|
36 | - return implode( ', ', $values ); |
|
35 | + if (is_array($values)) { |
|
36 | + return implode(', ', $values); |
|
37 | 37 | } else { |
38 | 38 | return null; |
39 | 39 | } |
40 | 40 | } |
41 | 41 | |
42 | 42 | function wl_register_shortcode_field() { |
43 | - add_shortcode( 'wl_field', 'wl_shortcode_field' ); |
|
43 | + add_shortcode('wl_field', 'wl_shortcode_field'); |
|
44 | 44 | } |
45 | 45 | |
46 | -add_action( 'init', 'wl_register_shortcode_field' ); |
|
46 | +add_action('init', 'wl_register_shortcode_field'); |
|
47 | 47 |
@@ -10,131 +10,131 @@ |
||
10 | 10 | */ |
11 | 11 | abstract class Wordlift_Shortcode_REST { |
12 | 12 | |
13 | - /** |
|
14 | - * The cache_ttl, set by extending classes. |
|
15 | - */ |
|
16 | - const CACHE_TTL = 86400; // 24 hours |
|
17 | - |
|
18 | - public function __construct( $endpoint, $args ) { |
|
19 | - |
|
20 | - $scope = $this; |
|
21 | - $this->endpoint = $endpoint; |
|
22 | - $this->args = $args; |
|
23 | - |
|
24 | - // Register rest route with callback |
|
25 | - add_action( |
|
26 | - 'rest_api_init', |
|
27 | - function () use ( $scope ) { |
|
28 | - register_rest_route( |
|
29 | - WL_REST_ROUTE_DEFAULT_NAMESPACE, |
|
30 | - $scope->endpoint, |
|
31 | - array( |
|
32 | - 'methods' => WP_REST_Server::READABLE, |
|
33 | - 'permission_callback' => '__return_true', |
|
34 | - 'callback' => array( $scope, 'rest_callback' ), |
|
35 | - 'args' => $scope->args, |
|
36 | - ) |
|
37 | - ); |
|
38 | - } |
|
39 | - ); |
|
40 | - |
|
41 | - // Optimizations: disable unneeded plugins on this specific REST call. WPSeo is slowing down the responses quite a bit. |
|
42 | - add_action( |
|
43 | - 'plugins_loaded', |
|
44 | - function () use ( $scope ) { |
|
45 | - |
|
46 | - if ( ! defined( 'REST_REQUEST' ) || ! REST_REQUEST || ! $scope->is_endpoint() ) { |
|
47 | - return; |
|
48 | - } |
|
49 | - |
|
50 | - remove_action( 'plugins_loaded', 'rocket_init' ); |
|
51 | - remove_action( 'plugins_loaded', 'wpseo_premium_init', 14 ); |
|
52 | - remove_action( 'plugins_loaded', 'wpseo_init', 14 ); |
|
53 | - }, |
|
54 | - 0 |
|
55 | - ); |
|
56 | - |
|
57 | - add_action( |
|
58 | - 'init', |
|
59 | - function () use ( $scope ) { |
|
60 | - |
|
61 | - if ( ! defined( 'REST_REQUEST' ) || ! REST_REQUEST || ! $scope->is_endpoint() ) { |
|
62 | - return; |
|
63 | - } |
|
64 | - |
|
65 | - remove_action( 'init', 'wp_widgets_init', 1 ); |
|
66 | - remove_action( 'init', 'gglcptch_init' ); |
|
67 | - }, |
|
68 | - 0 |
|
69 | - ); |
|
70 | - |
|
71 | - } |
|
72 | - |
|
73 | - abstract public function get_data( $request ); |
|
74 | - |
|
75 | - public function rest_callback( WP_REST_Request $request ) { |
|
76 | - |
|
77 | - // Respond from origin if TTL is 0 |
|
78 | - if ( static::CACHE_TTL === 0 ) { |
|
79 | - |
|
80 | - $data = $this->get_data( $request ); |
|
81 | - $response = rest_ensure_response( $data ); |
|
82 | - if ( is_wp_error( $data ) ) { |
|
83 | - return $response; |
|
84 | - } |
|
85 | - $response->header( 'Access-Control-Allow-Origin', '*' ); |
|
86 | - $response->header( 'X-WordLift-Cache', 'MISS' ); |
|
87 | - |
|
88 | - return $response; |
|
89 | - } |
|
90 | - |
|
91 | - // Create the cache key. |
|
92 | - $cache_key_params = $request->get_params(); |
|
93 | - unset( $cache_key_params['uniqid'] ); |
|
94 | - unset( $cache_key_params['rest_route'] ); |
|
95 | - $cache_key = array( 'request_params' => $cache_key_params ); |
|
96 | - |
|
97 | - // Create the TTL cache and try to get the results. |
|
98 | - $cache = new Ttl_Cache( $this->endpoint, static::CACHE_TTL ); |
|
99 | - $cache_results = $cache->get( $cache_key ); |
|
100 | - |
|
101 | - if ( isset( $cache_results ) ) { |
|
102 | - |
|
103 | - $response = rest_ensure_response( $cache_results ); |
|
104 | - $response->header( 'Access-Control-Allow-Origin', '*' ); |
|
105 | - $response->header( 'X-WordLift-Cache', 'HIT' ); |
|
106 | - |
|
107 | - return $response; |
|
108 | - } |
|
109 | - |
|
110 | - $data = $this->get_data( $request ); |
|
111 | - $response = rest_ensure_response( $data ); |
|
112 | - if ( is_wp_error( $data ) ) { |
|
113 | - return $response; |
|
114 | - } |
|
115 | - $response->header( 'Access-Control-Allow-Origin', '*' ); |
|
116 | - $response->header( 'X-WordLift-Cache', 'MISS' ); |
|
117 | - |
|
118 | - // Put the result before sending the json to the client, since sending the json will terminate us. |
|
119 | - $cache->put( $cache_key, $data ); |
|
120 | - |
|
121 | - return $response; |
|
122 | - |
|
123 | - } |
|
124 | - |
|
125 | - private function is_endpoint() { |
|
126 | - $compare_route = WL_REST_ROUTE_DEFAULT_NAMESPACE . $this->endpoint; |
|
127 | - |
|
128 | - // Directly accessing $_SERVER['REQUEST_URI'] or $_GET['rest_route'] here as it's too early to use global $wp reliably |
|
129 | - |
|
130 | - if ( isset( $_SERVER['REQUEST_URI'] ) && strpos( esc_url_raw( wp_unslash( (string) $_SERVER['REQUEST_URI'] ) ), $compare_route ) ) { |
|
131 | - return true; |
|
132 | - } |
|
133 | - if ( ! empty( $_GET['rest_route'] ) && strpos( esc_url_raw( wp_unslash( (string) $_GET['rest_route'] ) ), $compare_route ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
134 | - return true; |
|
135 | - } |
|
13 | + /** |
|
14 | + * The cache_ttl, set by extending classes. |
|
15 | + */ |
|
16 | + const CACHE_TTL = 86400; // 24 hours |
|
17 | + |
|
18 | + public function __construct( $endpoint, $args ) { |
|
19 | + |
|
20 | + $scope = $this; |
|
21 | + $this->endpoint = $endpoint; |
|
22 | + $this->args = $args; |
|
23 | + |
|
24 | + // Register rest route with callback |
|
25 | + add_action( |
|
26 | + 'rest_api_init', |
|
27 | + function () use ( $scope ) { |
|
28 | + register_rest_route( |
|
29 | + WL_REST_ROUTE_DEFAULT_NAMESPACE, |
|
30 | + $scope->endpoint, |
|
31 | + array( |
|
32 | + 'methods' => WP_REST_Server::READABLE, |
|
33 | + 'permission_callback' => '__return_true', |
|
34 | + 'callback' => array( $scope, 'rest_callback' ), |
|
35 | + 'args' => $scope->args, |
|
36 | + ) |
|
37 | + ); |
|
38 | + } |
|
39 | + ); |
|
40 | + |
|
41 | + // Optimizations: disable unneeded plugins on this specific REST call. WPSeo is slowing down the responses quite a bit. |
|
42 | + add_action( |
|
43 | + 'plugins_loaded', |
|
44 | + function () use ( $scope ) { |
|
45 | + |
|
46 | + if ( ! defined( 'REST_REQUEST' ) || ! REST_REQUEST || ! $scope->is_endpoint() ) { |
|
47 | + return; |
|
48 | + } |
|
49 | + |
|
50 | + remove_action( 'plugins_loaded', 'rocket_init' ); |
|
51 | + remove_action( 'plugins_loaded', 'wpseo_premium_init', 14 ); |
|
52 | + remove_action( 'plugins_loaded', 'wpseo_init', 14 ); |
|
53 | + }, |
|
54 | + 0 |
|
55 | + ); |
|
56 | + |
|
57 | + add_action( |
|
58 | + 'init', |
|
59 | + function () use ( $scope ) { |
|
60 | + |
|
61 | + if ( ! defined( 'REST_REQUEST' ) || ! REST_REQUEST || ! $scope->is_endpoint() ) { |
|
62 | + return; |
|
63 | + } |
|
64 | + |
|
65 | + remove_action( 'init', 'wp_widgets_init', 1 ); |
|
66 | + remove_action( 'init', 'gglcptch_init' ); |
|
67 | + }, |
|
68 | + 0 |
|
69 | + ); |
|
70 | + |
|
71 | + } |
|
72 | + |
|
73 | + abstract public function get_data( $request ); |
|
74 | + |
|
75 | + public function rest_callback( WP_REST_Request $request ) { |
|
76 | + |
|
77 | + // Respond from origin if TTL is 0 |
|
78 | + if ( static::CACHE_TTL === 0 ) { |
|
79 | + |
|
80 | + $data = $this->get_data( $request ); |
|
81 | + $response = rest_ensure_response( $data ); |
|
82 | + if ( is_wp_error( $data ) ) { |
|
83 | + return $response; |
|
84 | + } |
|
85 | + $response->header( 'Access-Control-Allow-Origin', '*' ); |
|
86 | + $response->header( 'X-WordLift-Cache', 'MISS' ); |
|
87 | + |
|
88 | + return $response; |
|
89 | + } |
|
90 | + |
|
91 | + // Create the cache key. |
|
92 | + $cache_key_params = $request->get_params(); |
|
93 | + unset( $cache_key_params['uniqid'] ); |
|
94 | + unset( $cache_key_params['rest_route'] ); |
|
95 | + $cache_key = array( 'request_params' => $cache_key_params ); |
|
96 | + |
|
97 | + // Create the TTL cache and try to get the results. |
|
98 | + $cache = new Ttl_Cache( $this->endpoint, static::CACHE_TTL ); |
|
99 | + $cache_results = $cache->get( $cache_key ); |
|
100 | + |
|
101 | + if ( isset( $cache_results ) ) { |
|
102 | + |
|
103 | + $response = rest_ensure_response( $cache_results ); |
|
104 | + $response->header( 'Access-Control-Allow-Origin', '*' ); |
|
105 | + $response->header( 'X-WordLift-Cache', 'HIT' ); |
|
106 | + |
|
107 | + return $response; |
|
108 | + } |
|
109 | + |
|
110 | + $data = $this->get_data( $request ); |
|
111 | + $response = rest_ensure_response( $data ); |
|
112 | + if ( is_wp_error( $data ) ) { |
|
113 | + return $response; |
|
114 | + } |
|
115 | + $response->header( 'Access-Control-Allow-Origin', '*' ); |
|
116 | + $response->header( 'X-WordLift-Cache', 'MISS' ); |
|
117 | + |
|
118 | + // Put the result before sending the json to the client, since sending the json will terminate us. |
|
119 | + $cache->put( $cache_key, $data ); |
|
120 | + |
|
121 | + return $response; |
|
122 | + |
|
123 | + } |
|
124 | + |
|
125 | + private function is_endpoint() { |
|
126 | + $compare_route = WL_REST_ROUTE_DEFAULT_NAMESPACE . $this->endpoint; |
|
127 | + |
|
128 | + // Directly accessing $_SERVER['REQUEST_URI'] or $_GET['rest_route'] here as it's too early to use global $wp reliably |
|
129 | + |
|
130 | + if ( isset( $_SERVER['REQUEST_URI'] ) && strpos( esc_url_raw( wp_unslash( (string) $_SERVER['REQUEST_URI'] ) ), $compare_route ) ) { |
|
131 | + return true; |
|
132 | + } |
|
133 | + if ( ! empty( $_GET['rest_route'] ) && strpos( esc_url_raw( wp_unslash( (string) $_GET['rest_route'] ) ), $compare_route ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
134 | + return true; |
|
135 | + } |
|
136 | 136 | |
137 | - return false; |
|
138 | - } |
|
137 | + return false; |
|
138 | + } |
|
139 | 139 | |
140 | 140 | } |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | */ |
16 | 16 | const CACHE_TTL = 86400; // 24 hours |
17 | 17 | |
18 | - public function __construct( $endpoint, $args ) { |
|
18 | + public function __construct($endpoint, $args) { |
|
19 | 19 | |
20 | 20 | $scope = $this; |
21 | 21 | $this->endpoint = $endpoint; |
@@ -24,14 +24,14 @@ discard block |
||
24 | 24 | // Register rest route with callback |
25 | 25 | add_action( |
26 | 26 | 'rest_api_init', |
27 | - function () use ( $scope ) { |
|
27 | + function() use ($scope) { |
|
28 | 28 | register_rest_route( |
29 | 29 | WL_REST_ROUTE_DEFAULT_NAMESPACE, |
30 | 30 | $scope->endpoint, |
31 | 31 | array( |
32 | 32 | 'methods' => WP_REST_Server::READABLE, |
33 | 33 | 'permission_callback' => '__return_true', |
34 | - 'callback' => array( $scope, 'rest_callback' ), |
|
34 | + 'callback' => array($scope, 'rest_callback'), |
|
35 | 35 | 'args' => $scope->args, |
36 | 36 | ) |
37 | 37 | ); |
@@ -41,96 +41,96 @@ discard block |
||
41 | 41 | // Optimizations: disable unneeded plugins on this specific REST call. WPSeo is slowing down the responses quite a bit. |
42 | 42 | add_action( |
43 | 43 | 'plugins_loaded', |
44 | - function () use ( $scope ) { |
|
44 | + function() use ($scope) { |
|
45 | 45 | |
46 | - if ( ! defined( 'REST_REQUEST' ) || ! REST_REQUEST || ! $scope->is_endpoint() ) { |
|
46 | + if ( ! defined('REST_REQUEST') || ! REST_REQUEST || ! $scope->is_endpoint()) { |
|
47 | 47 | return; |
48 | 48 | } |
49 | 49 | |
50 | - remove_action( 'plugins_loaded', 'rocket_init' ); |
|
51 | - remove_action( 'plugins_loaded', 'wpseo_premium_init', 14 ); |
|
52 | - remove_action( 'plugins_loaded', 'wpseo_init', 14 ); |
|
50 | + remove_action('plugins_loaded', 'rocket_init'); |
|
51 | + remove_action('plugins_loaded', 'wpseo_premium_init', 14); |
|
52 | + remove_action('plugins_loaded', 'wpseo_init', 14); |
|
53 | 53 | }, |
54 | 54 | 0 |
55 | 55 | ); |
56 | 56 | |
57 | 57 | add_action( |
58 | 58 | 'init', |
59 | - function () use ( $scope ) { |
|
59 | + function() use ($scope) { |
|
60 | 60 | |
61 | - if ( ! defined( 'REST_REQUEST' ) || ! REST_REQUEST || ! $scope->is_endpoint() ) { |
|
61 | + if ( ! defined('REST_REQUEST') || ! REST_REQUEST || ! $scope->is_endpoint()) { |
|
62 | 62 | return; |
63 | 63 | } |
64 | 64 | |
65 | - remove_action( 'init', 'wp_widgets_init', 1 ); |
|
66 | - remove_action( 'init', 'gglcptch_init' ); |
|
65 | + remove_action('init', 'wp_widgets_init', 1); |
|
66 | + remove_action('init', 'gglcptch_init'); |
|
67 | 67 | }, |
68 | 68 | 0 |
69 | 69 | ); |
70 | 70 | |
71 | 71 | } |
72 | 72 | |
73 | - abstract public function get_data( $request ); |
|
73 | + abstract public function get_data($request); |
|
74 | 74 | |
75 | - public function rest_callback( WP_REST_Request $request ) { |
|
75 | + public function rest_callback(WP_REST_Request $request) { |
|
76 | 76 | |
77 | 77 | // Respond from origin if TTL is 0 |
78 | - if ( static::CACHE_TTL === 0 ) { |
|
78 | + if (static::CACHE_TTL === 0) { |
|
79 | 79 | |
80 | - $data = $this->get_data( $request ); |
|
81 | - $response = rest_ensure_response( $data ); |
|
82 | - if ( is_wp_error( $data ) ) { |
|
80 | + $data = $this->get_data($request); |
|
81 | + $response = rest_ensure_response($data); |
|
82 | + if (is_wp_error($data)) { |
|
83 | 83 | return $response; |
84 | 84 | } |
85 | - $response->header( 'Access-Control-Allow-Origin', '*' ); |
|
86 | - $response->header( 'X-WordLift-Cache', 'MISS' ); |
|
85 | + $response->header('Access-Control-Allow-Origin', '*'); |
|
86 | + $response->header('X-WordLift-Cache', 'MISS'); |
|
87 | 87 | |
88 | 88 | return $response; |
89 | 89 | } |
90 | 90 | |
91 | 91 | // Create the cache key. |
92 | 92 | $cache_key_params = $request->get_params(); |
93 | - unset( $cache_key_params['uniqid'] ); |
|
94 | - unset( $cache_key_params['rest_route'] ); |
|
95 | - $cache_key = array( 'request_params' => $cache_key_params ); |
|
93 | + unset($cache_key_params['uniqid']); |
|
94 | + unset($cache_key_params['rest_route']); |
|
95 | + $cache_key = array('request_params' => $cache_key_params); |
|
96 | 96 | |
97 | 97 | // Create the TTL cache and try to get the results. |
98 | - $cache = new Ttl_Cache( $this->endpoint, static::CACHE_TTL ); |
|
99 | - $cache_results = $cache->get( $cache_key ); |
|
98 | + $cache = new Ttl_Cache($this->endpoint, static::CACHE_TTL); |
|
99 | + $cache_results = $cache->get($cache_key); |
|
100 | 100 | |
101 | - if ( isset( $cache_results ) ) { |
|
101 | + if (isset($cache_results)) { |
|
102 | 102 | |
103 | - $response = rest_ensure_response( $cache_results ); |
|
104 | - $response->header( 'Access-Control-Allow-Origin', '*' ); |
|
105 | - $response->header( 'X-WordLift-Cache', 'HIT' ); |
|
103 | + $response = rest_ensure_response($cache_results); |
|
104 | + $response->header('Access-Control-Allow-Origin', '*'); |
|
105 | + $response->header('X-WordLift-Cache', 'HIT'); |
|
106 | 106 | |
107 | 107 | return $response; |
108 | 108 | } |
109 | 109 | |
110 | - $data = $this->get_data( $request ); |
|
111 | - $response = rest_ensure_response( $data ); |
|
112 | - if ( is_wp_error( $data ) ) { |
|
110 | + $data = $this->get_data($request); |
|
111 | + $response = rest_ensure_response($data); |
|
112 | + if (is_wp_error($data)) { |
|
113 | 113 | return $response; |
114 | 114 | } |
115 | - $response->header( 'Access-Control-Allow-Origin', '*' ); |
|
116 | - $response->header( 'X-WordLift-Cache', 'MISS' ); |
|
115 | + $response->header('Access-Control-Allow-Origin', '*'); |
|
116 | + $response->header('X-WordLift-Cache', 'MISS'); |
|
117 | 117 | |
118 | 118 | // Put the result before sending the json to the client, since sending the json will terminate us. |
119 | - $cache->put( $cache_key, $data ); |
|
119 | + $cache->put($cache_key, $data); |
|
120 | 120 | |
121 | 121 | return $response; |
122 | 122 | |
123 | 123 | } |
124 | 124 | |
125 | 125 | private function is_endpoint() { |
126 | - $compare_route = WL_REST_ROUTE_DEFAULT_NAMESPACE . $this->endpoint; |
|
126 | + $compare_route = WL_REST_ROUTE_DEFAULT_NAMESPACE.$this->endpoint; |
|
127 | 127 | |
128 | 128 | // Directly accessing $_SERVER['REQUEST_URI'] or $_GET['rest_route'] here as it's too early to use global $wp reliably |
129 | 129 | |
130 | - if ( isset( $_SERVER['REQUEST_URI'] ) && strpos( esc_url_raw( wp_unslash( (string) $_SERVER['REQUEST_URI'] ) ), $compare_route ) ) { |
|
130 | + if (isset($_SERVER['REQUEST_URI']) && strpos(esc_url_raw(wp_unslash((string) $_SERVER['REQUEST_URI'])), $compare_route)) { |
|
131 | 131 | return true; |
132 | 132 | } |
133 | - if ( ! empty( $_GET['rest_route'] ) && strpos( esc_url_raw( wp_unslash( (string) $_GET['rest_route'] ) ), $compare_route ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
133 | + if ( ! empty($_GET['rest_route']) && strpos(esc_url_raw(wp_unslash((string) $_GET['rest_route'])), $compare_route)) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
134 | 134 | return true; |
135 | 135 | } |
136 | 136 |