@@ -16,78 +16,78 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | class Wordlift_Admin_Term_Adapter { |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * The meta key holding the entity id. |
|
| 21 | - * |
|
| 22 | - * @since 3.20.0 |
|
| 23 | - */ |
|
| 24 | - const META_KEY = '_wl_entity_id'; |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * Create a Wordlift_Admin_Term_Adapter instance. |
|
| 28 | - * |
|
| 29 | - * @since 3.20.0 |
|
| 30 | - */ |
|
| 31 | - public function __construct() { |
|
| 32 | - |
|
| 33 | - add_action( 'registered_taxonomy', array( $this, 'add_action', ) ); |
|
| 34 | - add_action( 'edit_term', array( $this, 'edit_term', ), 10, 3 ); |
|
| 35 | - $this->add_settings(); |
|
| 36 | - |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * Hook in to WordLift admin settings and add the term page specific |
|
| 41 | - * settings. |
|
| 42 | - * @since 3.26.1 |
|
| 43 | - */ |
|
| 44 | - public function add_settings() { |
|
| 45 | - add_filter( 'wl_admin_settings', function ( $params ) { |
|
| 46 | - $params['show_local_entities'] = true; |
|
| 47 | - return $params; |
|
| 48 | - } ); |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * Add the form fields to the entity edit screen. |
|
| 53 | - * |
|
| 54 | - * @param object $tag Current taxonomy term object. |
|
| 55 | - * @param string $taxonomy Current taxonomy slug. |
|
| 56 | - * |
|
| 57 | - * @since 3.20.0 |
|
| 58 | - * |
|
| 59 | - */ |
|
| 60 | - public function edit_form_fields( $tag, $taxonomy ) { |
|
| 61 | - |
|
| 62 | - // If disabled via filter, return; |
|
| 63 | - if ( ! apply_filters( 'wl_feature__enable__term-entity', true ) ) { |
|
| 64 | - return; |
|
| 19 | + /** |
|
| 20 | + * The meta key holding the entity id. |
|
| 21 | + * |
|
| 22 | + * @since 3.20.0 |
|
| 23 | + */ |
|
| 24 | + const META_KEY = '_wl_entity_id'; |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * Create a Wordlift_Admin_Term_Adapter instance. |
|
| 28 | + * |
|
| 29 | + * @since 3.20.0 |
|
| 30 | + */ |
|
| 31 | + public function __construct() { |
|
| 32 | + |
|
| 33 | + add_action( 'registered_taxonomy', array( $this, 'add_action', ) ); |
|
| 34 | + add_action( 'edit_term', array( $this, 'edit_term', ), 10, 3 ); |
|
| 35 | + $this->add_settings(); |
|
| 36 | + |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * Hook in to WordLift admin settings and add the term page specific |
|
| 41 | + * settings. |
|
| 42 | + * @since 3.26.1 |
|
| 43 | + */ |
|
| 44 | + public function add_settings() { |
|
| 45 | + add_filter( 'wl_admin_settings', function ( $params ) { |
|
| 46 | + $params['show_local_entities'] = true; |
|
| 47 | + return $params; |
|
| 48 | + } ); |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * Add the form fields to the entity edit screen. |
|
| 53 | + * |
|
| 54 | + * @param object $tag Current taxonomy term object. |
|
| 55 | + * @param string $taxonomy Current taxonomy slug. |
|
| 56 | + * |
|
| 57 | + * @since 3.20.0 |
|
| 58 | + * |
|
| 59 | + */ |
|
| 60 | + public function edit_form_fields( $tag, $taxonomy ) { |
|
| 61 | + |
|
| 62 | + // If disabled via filter, return; |
|
| 63 | + if ( ! apply_filters( 'wl_feature__enable__term-entity', true ) ) { |
|
| 64 | + return; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - global $wp_version; |
|
| 67 | + global $wp_version; |
|
| 68 | 68 | |
| 69 | - // Enqueue the JavaScript app. |
|
| 70 | - if ( version_compare( $wp_version, '5.0', '>=' ) ) { |
|
| 71 | - $term_asset = include plugin_dir_path( dirname( __FILE__ ) ) . 'js/dist/term.asset.php'; |
|
| 72 | - wp_enqueue_script( 'wl-term', plugin_dir_url( dirname( __FILE__ ) ) . 'js/dist/term.js', array_merge( array( 'wp-util' ), $term_asset['dependencies'] ), Wordlift::get_instance()->get_version(), true ); |
|
| 73 | - } else { |
|
| 74 | - wp_enqueue_script( 'wl-term', plugin_dir_url( dirname( __FILE__ ) ) . 'js/dist/term.full.js', array( 'wp-util' ), Wordlift::get_instance()->get_version(), true ); |
|
| 75 | - } |
|
| 69 | + // Enqueue the JavaScript app. |
|
| 70 | + if ( version_compare( $wp_version, '5.0', '>=' ) ) { |
|
| 71 | + $term_asset = include plugin_dir_path( dirname( __FILE__ ) ) . 'js/dist/term.asset.php'; |
|
| 72 | + wp_enqueue_script( 'wl-term', plugin_dir_url( dirname( __FILE__ ) ) . 'js/dist/term.js', array_merge( array( 'wp-util' ), $term_asset['dependencies'] ), Wordlift::get_instance()->get_version(), true ); |
|
| 73 | + } else { |
|
| 74 | + wp_enqueue_script( 'wl-term', plugin_dir_url( dirname( __FILE__ ) ) . 'js/dist/term.full.js', array( 'wp-util' ), Wordlift::get_instance()->get_version(), true ); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - wp_enqueue_style( 'wl-term', plugin_dir_url( dirname( __FILE__ ) ) . 'js/dist/term.css', array(), Wordlift::get_instance()->get_version() ); |
|
| 77 | + wp_enqueue_style( 'wl-term', plugin_dir_url( dirname( __FILE__ ) ) . 'js/dist/term.css', array(), Wordlift::get_instance()->get_version() ); |
|
| 78 | 78 | |
| 79 | - $values = get_term_meta( $tag->term_id, self::META_KEY ); |
|
| 79 | + $values = get_term_meta( $tag->term_id, self::META_KEY ); |
|
| 80 | 80 | |
| 81 | - /** |
|
| 82 | - * @since 3.31.3 |
|
| 81 | + /** |
|
| 82 | + * @since 3.31.3 |
|
| 83 | 83 | * @see https://github.com/insideout10/wordlift-plugin/issues/1446 |
| 84 | 84 | * This field should be hidden by default |
| 85 | - */ |
|
| 86 | - if ( ! $values ) { |
|
| 87 | - return; |
|
| 85 | + */ |
|
| 86 | + if ( ! $values ) { |
|
| 87 | + return; |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - ?> |
|
| 90 | + ?> |
|
| 91 | 91 | <tr class="form-field term-name-wrap"> |
| 92 | 92 | <th scope="row"><label for="wl-entity-id"><?php esc_html_e( 'Entity', 'term entity', 'wordlift' ); ?></label></th> |
| 93 | 93 | <td> |
@@ -99,69 +99,69 @@ discard block |
||
| 99 | 99 | </td> |
| 100 | 100 | </tr> |
| 101 | 101 | <?php |
| 102 | - } |
|
| 103 | - |
|
| 104 | - /** |
|
| 105 | - * Bind the new fields to the edit term screen. |
|
| 106 | - * |
|
| 107 | - * @since 3.20.0 |
|
| 108 | - * |
|
| 109 | - * @param string $taxonomy The taxonomy name. |
|
| 110 | - */ |
|
| 111 | - public function add_action( $taxonomy ) { |
|
| 112 | - /** |
|
| 113 | - * Filter wl_feature__enable__taxonomy_term_entity_mapping renamed to wl_feature__enable__term-entity. |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + /** |
|
| 105 | + * Bind the new fields to the edit term screen. |
|
| 106 | + * |
|
| 107 | + * @since 3.20.0 |
|
| 108 | + * |
|
| 109 | + * @param string $taxonomy The taxonomy name. |
|
| 110 | + */ |
|
| 111 | + public function add_action( $taxonomy ) { |
|
| 112 | + /** |
|
| 113 | + * Filter wl_feature__enable__taxonomy_term_entity_mapping renamed to wl_feature__enable__term-entity. |
|
| 114 | 114 | **/ |
| 115 | 115 | |
| 116 | - add_action( "{$taxonomy}_edit_form_fields", array( $this, 'edit_form_fields' ), 10, 2 ); |
|
| 117 | - |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - /** |
|
| 121 | - * Hook to the edit term to handle our own custom fields. |
|
| 122 | - * |
|
| 123 | - * @since 3.20.0 |
|
| 124 | - * |
|
| 125 | - * @param int $term_id The term id. |
|
| 126 | - * @param int $tt_id The term taxonomy id. |
|
| 127 | - * @param string $taxonomy The taxonomy. |
|
| 128 | - */ |
|
| 129 | - public function edit_term( $term_id, $tt_id, $taxonomy ) { |
|
| 130 | - |
|
| 131 | - // Bail if the action isn't related to the term currently being edited. |
|
| 132 | - if ( ! isset( $_POST['tag_ID'] ) || $term_id !== (int) $_POST['tag_ID'] ) { |
|
| 133 | - return; |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - // Delete. |
|
| 137 | - if ( ! isset( $_POST['wl_entity_id'] ) || ! is_array( $_POST['wl_entity_id'] ) || empty( $_POST['wl_entity_id'] ) ) { |
|
| 138 | - delete_term_meta( $term_id, self::META_KEY ); |
|
| 139 | - |
|
| 140 | - return; |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - // Update. |
|
| 144 | - // |
|
| 145 | - // Only use mb_* functions when mbstring is available. |
|
| 146 | - // |
|
| 147 | - // See https://github.com/insideout10/wordlift-plugin/issues/693. |
|
| 148 | - if ( extension_loaded( 'mbstring' ) ) { |
|
| 149 | - mb_regex_encoding( 'UTF-8' ); |
|
| 150 | - |
|
| 151 | - $merged = array_reduce( (array) $_POST['wl_entity_id'], function ( $carry, $item ) { |
|
| 152 | - return array_merge( $carry, mb_split( "\x{2063}", wp_unslash( $item ) ) ); |
|
| 153 | - }, array() ); |
|
| 154 | - } else { |
|
| 155 | - $merged = array_reduce( (array) $_POST['wl_entity_id'], function ( $carry, $item ) { |
|
| 156 | - return array_merge( $carry, preg_split( "/\x{2063}/u", wp_unslash( $item ) ) ); |
|
| 157 | - }, array() ); |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - delete_term_meta( $term_id, self::META_KEY ); |
|
| 161 | - foreach ( array_unique( array_filter( $merged ) ) as $single ) { |
|
| 162 | - add_term_meta( $term_id, self::META_KEY, $single ); |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - } |
|
| 116 | + add_action( "{$taxonomy}_edit_form_fields", array( $this, 'edit_form_fields' ), 10, 2 ); |
|
| 117 | + |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + /** |
|
| 121 | + * Hook to the edit term to handle our own custom fields. |
|
| 122 | + * |
|
| 123 | + * @since 3.20.0 |
|
| 124 | + * |
|
| 125 | + * @param int $term_id The term id. |
|
| 126 | + * @param int $tt_id The term taxonomy id. |
|
| 127 | + * @param string $taxonomy The taxonomy. |
|
| 128 | + */ |
|
| 129 | + public function edit_term( $term_id, $tt_id, $taxonomy ) { |
|
| 130 | + |
|
| 131 | + // Bail if the action isn't related to the term currently being edited. |
|
| 132 | + if ( ! isset( $_POST['tag_ID'] ) || $term_id !== (int) $_POST['tag_ID'] ) { |
|
| 133 | + return; |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + // Delete. |
|
| 137 | + if ( ! isset( $_POST['wl_entity_id'] ) || ! is_array( $_POST['wl_entity_id'] ) || empty( $_POST['wl_entity_id'] ) ) { |
|
| 138 | + delete_term_meta( $term_id, self::META_KEY ); |
|
| 139 | + |
|
| 140 | + return; |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + // Update. |
|
| 144 | + // |
|
| 145 | + // Only use mb_* functions when mbstring is available. |
|
| 146 | + // |
|
| 147 | + // See https://github.com/insideout10/wordlift-plugin/issues/693. |
|
| 148 | + if ( extension_loaded( 'mbstring' ) ) { |
|
| 149 | + mb_regex_encoding( 'UTF-8' ); |
|
| 150 | + |
|
| 151 | + $merged = array_reduce( (array) $_POST['wl_entity_id'], function ( $carry, $item ) { |
|
| 152 | + return array_merge( $carry, mb_split( "\x{2063}", wp_unslash( $item ) ) ); |
|
| 153 | + }, array() ); |
|
| 154 | + } else { |
|
| 155 | + $merged = array_reduce( (array) $_POST['wl_entity_id'], function ( $carry, $item ) { |
|
| 156 | + return array_merge( $carry, preg_split( "/\x{2063}/u", wp_unslash( $item ) ) ); |
|
| 157 | + }, array() ); |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + delete_term_meta( $term_id, self::META_KEY ); |
|
| 161 | + foreach ( array_unique( array_filter( $merged ) ) as $single ) { |
|
| 162 | + add_term_meta( $term_id, self::META_KEY, $single ); |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | 167 | } |
@@ -30,8 +30,8 @@ discard block |
||
| 30 | 30 | */ |
| 31 | 31 | public function __construct() { |
| 32 | 32 | |
| 33 | - add_action( 'registered_taxonomy', array( $this, 'add_action', ) ); |
|
| 34 | - add_action( 'edit_term', array( $this, 'edit_term', ), 10, 3 ); |
|
| 33 | + add_action('registered_taxonomy', array($this, 'add_action',)); |
|
| 34 | + add_action('edit_term', array($this, 'edit_term',), 10, 3); |
|
| 35 | 35 | $this->add_settings(); |
| 36 | 36 | |
| 37 | 37 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * @since 3.26.1 |
| 43 | 43 | */ |
| 44 | 44 | public function add_settings() { |
| 45 | - add_filter( 'wl_admin_settings', function ( $params ) { |
|
| 45 | + add_filter('wl_admin_settings', function($params) { |
|
| 46 | 46 | $params['show_local_entities'] = true; |
| 47 | 47 | return $params; |
| 48 | 48 | } ); |
@@ -57,45 +57,45 @@ discard block |
||
| 57 | 57 | * @since 3.20.0 |
| 58 | 58 | * |
| 59 | 59 | */ |
| 60 | - public function edit_form_fields( $tag, $taxonomy ) { |
|
| 60 | + public function edit_form_fields($tag, $taxonomy) { |
|
| 61 | 61 | |
| 62 | 62 | // If disabled via filter, return; |
| 63 | - if ( ! apply_filters( 'wl_feature__enable__term-entity', true ) ) { |
|
| 63 | + if ( ! apply_filters('wl_feature__enable__term-entity', true)) { |
|
| 64 | 64 | return; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | global $wp_version; |
| 68 | 68 | |
| 69 | 69 | // Enqueue the JavaScript app. |
| 70 | - if ( version_compare( $wp_version, '5.0', '>=' ) ) { |
|
| 71 | - $term_asset = include plugin_dir_path( dirname( __FILE__ ) ) . 'js/dist/term.asset.php'; |
|
| 72 | - wp_enqueue_script( 'wl-term', plugin_dir_url( dirname( __FILE__ ) ) . 'js/dist/term.js', array_merge( array( 'wp-util' ), $term_asset['dependencies'] ), Wordlift::get_instance()->get_version(), true ); |
|
| 70 | + if (version_compare($wp_version, '5.0', '>=')) { |
|
| 71 | + $term_asset = include plugin_dir_path(dirname(__FILE__)).'js/dist/term.asset.php'; |
|
| 72 | + wp_enqueue_script('wl-term', plugin_dir_url(dirname(__FILE__)).'js/dist/term.js', array_merge(array('wp-util'), $term_asset['dependencies']), Wordlift::get_instance()->get_version(), true); |
|
| 73 | 73 | } else { |
| 74 | - wp_enqueue_script( 'wl-term', plugin_dir_url( dirname( __FILE__ ) ) . 'js/dist/term.full.js', array( 'wp-util' ), Wordlift::get_instance()->get_version(), true ); |
|
| 74 | + wp_enqueue_script('wl-term', plugin_dir_url(dirname(__FILE__)).'js/dist/term.full.js', array('wp-util'), Wordlift::get_instance()->get_version(), true); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - wp_enqueue_style( 'wl-term', plugin_dir_url( dirname( __FILE__ ) ) . 'js/dist/term.css', array(), Wordlift::get_instance()->get_version() ); |
|
| 77 | + wp_enqueue_style('wl-term', plugin_dir_url(dirname(__FILE__)).'js/dist/term.css', array(), Wordlift::get_instance()->get_version()); |
|
| 78 | 78 | |
| 79 | - $values = get_term_meta( $tag->term_id, self::META_KEY ); |
|
| 79 | + $values = get_term_meta($tag->term_id, self::META_KEY); |
|
| 80 | 80 | |
| 81 | 81 | /** |
| 82 | 82 | * @since 3.31.3 |
| 83 | 83 | * @see https://github.com/insideout10/wordlift-plugin/issues/1446 |
| 84 | 84 | * This field should be hidden by default |
| 85 | 85 | */ |
| 86 | - if ( ! $values ) { |
|
| 86 | + if ( ! $values) { |
|
| 87 | 87 | return; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | ?> |
| 91 | 91 | <tr class="form-field term-name-wrap"> |
| 92 | - <th scope="row"><label for="wl-entity-id"><?php esc_html_e( 'Entity', 'term entity', 'wordlift' ); ?></label></th> |
|
| 92 | + <th scope="row"><label for="wl-entity-id"><?php esc_html_e('Entity', 'term entity', 'wordlift'); ?></label></th> |
|
| 93 | 93 | <td> |
| 94 | - <?php foreach ( $values as $value ) { ?> |
|
| 95 | - <input type="text" name="wl_entity_id[]" value="<?php echo esc_attr( $value ); ?>"/> |
|
| 94 | + <?php foreach ($values as $value) { ?> |
|
| 95 | + <input type="text" name="wl_entity_id[]" value="<?php echo esc_attr($value); ?>"/> |
|
| 96 | 96 | <?php } ?> |
| 97 | 97 | <div id="wl-term-entity-id"></div> |
| 98 | - <p class="description"><?php esc_html_e( 'The entity bound to the term.', 'wordlift' ); ?></p> |
|
| 98 | + <p class="description"><?php esc_html_e('The entity bound to the term.', 'wordlift'); ?></p> |
|
| 99 | 99 | </td> |
| 100 | 100 | </tr> |
| 101 | 101 | <?php |
@@ -108,12 +108,12 @@ discard block |
||
| 108 | 108 | * |
| 109 | 109 | * @param string $taxonomy The taxonomy name. |
| 110 | 110 | */ |
| 111 | - public function add_action( $taxonomy ) { |
|
| 111 | + public function add_action($taxonomy) { |
|
| 112 | 112 | /** |
| 113 | 113 | * Filter wl_feature__enable__taxonomy_term_entity_mapping renamed to wl_feature__enable__term-entity. |
| 114 | 114 | **/ |
| 115 | 115 | |
| 116 | - add_action( "{$taxonomy}_edit_form_fields", array( $this, 'edit_form_fields' ), 10, 2 ); |
|
| 116 | + add_action("{$taxonomy}_edit_form_fields", array($this, 'edit_form_fields'), 10, 2); |
|
| 117 | 117 | |
| 118 | 118 | } |
| 119 | 119 | |
@@ -126,16 +126,16 @@ discard block |
||
| 126 | 126 | * @param int $tt_id The term taxonomy id. |
| 127 | 127 | * @param string $taxonomy The taxonomy. |
| 128 | 128 | */ |
| 129 | - public function edit_term( $term_id, $tt_id, $taxonomy ) { |
|
| 129 | + public function edit_term($term_id, $tt_id, $taxonomy) { |
|
| 130 | 130 | |
| 131 | 131 | // Bail if the action isn't related to the term currently being edited. |
| 132 | - if ( ! isset( $_POST['tag_ID'] ) || $term_id !== (int) $_POST['tag_ID'] ) { |
|
| 132 | + if ( ! isset($_POST['tag_ID']) || $term_id !== (int) $_POST['tag_ID']) { |
|
| 133 | 133 | return; |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | // Delete. |
| 137 | - if ( ! isset( $_POST['wl_entity_id'] ) || ! is_array( $_POST['wl_entity_id'] ) || empty( $_POST['wl_entity_id'] ) ) { |
|
| 138 | - delete_term_meta( $term_id, self::META_KEY ); |
|
| 137 | + if ( ! isset($_POST['wl_entity_id']) || ! is_array($_POST['wl_entity_id']) || empty($_POST['wl_entity_id'])) { |
|
| 138 | + delete_term_meta($term_id, self::META_KEY); |
|
| 139 | 139 | |
| 140 | 140 | return; |
| 141 | 141 | } |
@@ -145,21 +145,21 @@ discard block |
||
| 145 | 145 | // Only use mb_* functions when mbstring is available. |
| 146 | 146 | // |
| 147 | 147 | // See https://github.com/insideout10/wordlift-plugin/issues/693. |
| 148 | - if ( extension_loaded( 'mbstring' ) ) { |
|
| 149 | - mb_regex_encoding( 'UTF-8' ); |
|
| 148 | + if (extension_loaded('mbstring')) { |
|
| 149 | + mb_regex_encoding('UTF-8'); |
|
| 150 | 150 | |
| 151 | - $merged = array_reduce( (array) $_POST['wl_entity_id'], function ( $carry, $item ) { |
|
| 152 | - return array_merge( $carry, mb_split( "\x{2063}", wp_unslash( $item ) ) ); |
|
| 153 | - }, array() ); |
|
| 151 | + $merged = array_reduce((array) $_POST['wl_entity_id'], function($carry, $item) { |
|
| 152 | + return array_merge($carry, mb_split("\x{2063}", wp_unslash($item))); |
|
| 153 | + }, array()); |
|
| 154 | 154 | } else { |
| 155 | - $merged = array_reduce( (array) $_POST['wl_entity_id'], function ( $carry, $item ) { |
|
| 156 | - return array_merge( $carry, preg_split( "/\x{2063}/u", wp_unslash( $item ) ) ); |
|
| 157 | - }, array() ); |
|
| 155 | + $merged = array_reduce((array) $_POST['wl_entity_id'], function($carry, $item) { |
|
| 156 | + return array_merge($carry, preg_split("/\x{2063}/u", wp_unslash($item))); |
|
| 157 | + }, array()); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - delete_term_meta( $term_id, self::META_KEY ); |
|
| 161 | - foreach ( array_unique( array_filter( $merged ) ) as $single ) { |
|
| 162 | - add_term_meta( $term_id, self::META_KEY, $single ); |
|
| 160 | + delete_term_meta($term_id, self::META_KEY); |
|
| 161 | + foreach (array_unique(array_filter($merged)) as $single) { |
|
| 162 | + add_term_meta($term_id, self::META_KEY, $single); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | } |
@@ -18,100 +18,100 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | class Wordlift_Dashboard_Service { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Transient Name |
|
| 23 | - * |
|
| 24 | - * @since 3.4.0 |
|
| 25 | - */ |
|
| 26 | - const TRANSIENT_NAME = 'wl_dashboard_stats'; |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * Transient Expiration (in seconds) |
|
| 30 | - * |
|
| 31 | - * @since 3.4.0 |
|
| 32 | - */ |
|
| 33 | - const TRANSIENT_EXPIRATION = 86400; |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * A {@link Wordlift_Rating_Service} instance. |
|
| 37 | - * |
|
| 38 | - * @since 3.10.0 |
|
| 39 | - * @access private |
|
| 40 | - * @var \Wordlift_Rating_Service $rating_service A {@link Wordlift_Rating_Service} instance. |
|
| 41 | - */ |
|
| 42 | - private $rating_service; |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * The {@link Wordlift_Entity_Service} instance. |
|
| 46 | - * |
|
| 47 | - * @since 3.15.0 |
|
| 48 | - * @access private |
|
| 49 | - * @var \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance. |
|
| 50 | - */ |
|
| 51 | - private $entity_service; |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * Create a Wordlift_Entity_List_Service. |
|
| 55 | - * |
|
| 56 | - * @since 3.4.0 |
|
| 57 | - * |
|
| 58 | - */ |
|
| 59 | - protected function __construct() { |
|
| 60 | - |
|
| 61 | - $this->rating_service = Wordlift_Rating_Service::get_instance(); |
|
| 62 | - $this->entity_service = Wordlift_Entity_Service::get_instance(); |
|
| 63 | - |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - private static $instance; |
|
| 67 | - |
|
| 68 | - public static function get_instance() { |
|
| 69 | - if ( ! isset( self::$instance ) ) { |
|
| 70 | - self::$instance = new self(); |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - return self::$instance; |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * Return stats layout |
|
| 78 | - * |
|
| 79 | - * @return string Dashboard widget html markup |
|
| 80 | - * @since 3.4.0 |
|
| 81 | - * |
|
| 82 | - */ |
|
| 83 | - public function dashboard_widget_callback( $post ) { |
|
| 21 | + /** |
|
| 22 | + * Transient Name |
|
| 23 | + * |
|
| 24 | + * @since 3.4.0 |
|
| 25 | + */ |
|
| 26 | + const TRANSIENT_NAME = 'wl_dashboard_stats'; |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * Transient Expiration (in seconds) |
|
| 30 | + * |
|
| 31 | + * @since 3.4.0 |
|
| 32 | + */ |
|
| 33 | + const TRANSIENT_EXPIRATION = 86400; |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * A {@link Wordlift_Rating_Service} instance. |
|
| 37 | + * |
|
| 38 | + * @since 3.10.0 |
|
| 39 | + * @access private |
|
| 40 | + * @var \Wordlift_Rating_Service $rating_service A {@link Wordlift_Rating_Service} instance. |
|
| 41 | + */ |
|
| 42 | + private $rating_service; |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * The {@link Wordlift_Entity_Service} instance. |
|
| 46 | + * |
|
| 47 | + * @since 3.15.0 |
|
| 48 | + * @access private |
|
| 49 | + * @var \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance. |
|
| 50 | + */ |
|
| 51 | + private $entity_service; |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * Create a Wordlift_Entity_List_Service. |
|
| 55 | + * |
|
| 56 | + * @since 3.4.0 |
|
| 57 | + * |
|
| 58 | + */ |
|
| 59 | + protected function __construct() { |
|
| 60 | + |
|
| 61 | + $this->rating_service = Wordlift_Rating_Service::get_instance(); |
|
| 62 | + $this->entity_service = Wordlift_Entity_Service::get_instance(); |
|
| 63 | + |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + private static $instance; |
|
| 67 | + |
|
| 68 | + public static function get_instance() { |
|
| 69 | + if ( ! isset( self::$instance ) ) { |
|
| 70 | + self::$instance = new self(); |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + return self::$instance; |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * Return stats layout |
|
| 78 | + * |
|
| 79 | + * @return string Dashboard widget html markup |
|
| 80 | + * @since 3.4.0 |
|
| 81 | + * |
|
| 82 | + */ |
|
| 83 | + public function dashboard_widget_callback( $post ) { |
|
| 84 | 84 | $caption_kses = array( 'a' => array( 'href' => array() ) ); |
| 85 | - $enriched_posts_title = __( 'enriched posts', 'wordlift' ); |
|
| 86 | - $enriched_posts_caption = sprintf( wp_kses( |
|
| 87 | - __( '%1$s, of your <a href="%2$s">posts</a> are annotated. This means %3$s annotated posts on %4$s.', 'wordlift' ), |
|
| 88 | - array( 'a' => array( 'href' => array() ) ) ), |
|
| 89 | - $this->render_stat_param( 'annotatedPostsPercentage' ), |
|
| 90 | - esc_url( admin_url( 'edit.php' ) ), |
|
| 91 | - $this->render_stat_param( 'annotated_posts' ), |
|
| 92 | - $this->render_stat_param( 'posts' ) |
|
| 93 | - ); |
|
| 94 | - |
|
| 95 | - $rating_title = __( 'average entity rating', 'wordlift' ); |
|
| 96 | - $rating_caption = sprintf( wp_kses( |
|
| 97 | - __( 'You have %1$s entities in your <a href="%2$s">vocabulary</a> with an average rating of %3$s.', 'wordlift' ), |
|
| 98 | - array( 'a' => array( 'href' => array() ) ) ), |
|
| 99 | - $this->render_stat_param( 'entities' ), |
|
| 100 | - esc_url( admin_url( 'edit.php?post_type=entity' ) ), |
|
| 101 | - $this->render_stat_param( 'rating' ) |
|
| 102 | - ); |
|
| 103 | - |
|
| 104 | - $graph_title = __( 'triples in your graph', 'wordlift' ); |
|
| 105 | - $graph_caption = sprintf( wp_kses( |
|
| 106 | - __( 'Your graphs size corresponds to %1$s of <a href="%2$s">Wikidata</a>.', 'wordlift' ), |
|
| 107 | - array( 'a' => array( 'href' => array() ) ) ), |
|
| 108 | - $this->render_stat_param( 'wikidata' ), |
|
| 109 | - esc_url( 'https://www.wikidata.org/' ) |
|
| 110 | - ); |
|
| 111 | - |
|
| 112 | - $triples_label = __( 'triples', 'wordlift' ); |
|
| 113 | - |
|
| 114 | - ?> |
|
| 85 | + $enriched_posts_title = __( 'enriched posts', 'wordlift' ); |
|
| 86 | + $enriched_posts_caption = sprintf( wp_kses( |
|
| 87 | + __( '%1$s, of your <a href="%2$s">posts</a> are annotated. This means %3$s annotated posts on %4$s.', 'wordlift' ), |
|
| 88 | + array( 'a' => array( 'href' => array() ) ) ), |
|
| 89 | + $this->render_stat_param( 'annotatedPostsPercentage' ), |
|
| 90 | + esc_url( admin_url( 'edit.php' ) ), |
|
| 91 | + $this->render_stat_param( 'annotated_posts' ), |
|
| 92 | + $this->render_stat_param( 'posts' ) |
|
| 93 | + ); |
|
| 94 | + |
|
| 95 | + $rating_title = __( 'average entity rating', 'wordlift' ); |
|
| 96 | + $rating_caption = sprintf( wp_kses( |
|
| 97 | + __( 'You have %1$s entities in your <a href="%2$s">vocabulary</a> with an average rating of %3$s.', 'wordlift' ), |
|
| 98 | + array( 'a' => array( 'href' => array() ) ) ), |
|
| 99 | + $this->render_stat_param( 'entities' ), |
|
| 100 | + esc_url( admin_url( 'edit.php?post_type=entity' ) ), |
|
| 101 | + $this->render_stat_param( 'rating' ) |
|
| 102 | + ); |
|
| 103 | + |
|
| 104 | + $graph_title = __( 'triples in your graph', 'wordlift' ); |
|
| 105 | + $graph_caption = sprintf( wp_kses( |
|
| 106 | + __( 'Your graphs size corresponds to %1$s of <a href="%2$s">Wikidata</a>.', 'wordlift' ), |
|
| 107 | + array( 'a' => array( 'href' => array() ) ) ), |
|
| 108 | + $this->render_stat_param( 'wikidata' ), |
|
| 109 | + esc_url( 'https://www.wikidata.org/' ) |
|
| 110 | + ); |
|
| 111 | + |
|
| 112 | + $triples_label = __( 'triples', 'wordlift' ); |
|
| 113 | + |
|
| 114 | + ?> |
|
| 115 | 115 | <div id="wl-dashboard-widget-inner-wrapper"> |
| 116 | 116 | <div class="wl-stat-card"> |
| 117 | 117 | <div class="wl-stat-graph-wrapper"> |
@@ -150,109 +150,109 @@ discard block |
||
| 150 | 150 | </div> |
| 151 | 151 | <?php |
| 152 | 152 | |
| 153 | - } |
|
| 154 | - |
|
| 155 | - /** |
|
| 156 | - * Return stats |
|
| 157 | - * |
|
| 158 | - * @return string markup |
|
| 159 | - * @since 3.4.0 |
|
| 160 | - * |
|
| 161 | - */ |
|
| 162 | - public function add_dashboard_widgets() { |
|
| 163 | - wp_add_dashboard_widget( 'wordlift-dashboard-widget', 'WordLift Dashboard', array( |
|
| 164 | - $this, |
|
| 165 | - 'dashboard_widget_callback', |
|
| 166 | - ) ); |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - /** |
|
| 170 | - * Return stats |
|
| 171 | - * @uses https://codex.wordpress.org/Function_Reference/set_transient |
|
| 172 | - * |
|
| 173 | - * @since 3.4.0 |
|
| 174 | - * |
|
| 175 | - * @return string JSON obj with all available stats. |
|
| 176 | - */ |
|
| 177 | - public function ajax_get_stats() { |
|
| 178 | - |
|
| 179 | - // If needed, the transient is force to reloaded. |
|
| 180 | - if ( isset( $_GET['force_reload'] ) ) { |
|
| 181 | - delete_transient( self::TRANSIENT_NAME ); |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - // Try to retrieve the transient |
|
| 185 | - $stats = get_transient( self::TRANSIENT_NAME ); |
|
| 186 | - |
|
| 187 | - if ( ! $stats ) { |
|
| 188 | - // Calculate stats |
|
| 189 | - $stats = array( |
|
| 190 | - 'entities' => $this->entity_service->count(), |
|
| 191 | - 'posts' => $this->count_posts(), |
|
| 192 | - 'annotated_posts' => $this->count_annotated_posts(), |
|
| 193 | - 'triples' => $this->count_triples() ?: '-', |
|
| 194 | - 'rating' => $this->average_entities_rating(), |
|
| 195 | - ); |
|
| 196 | - // Cache stats results trough transient |
|
| 197 | - set_transient( self::TRANSIENT_NAME, $stats, self::TRANSIENT_EXPIRATION ); |
|
| 198 | - } |
|
| 199 | - // Return stats as json object |
|
| 200 | - wl_core_send_json( $stats ); |
|
| 201 | - } |
|
| 202 | - |
|
| 203 | - /** |
|
| 204 | - * Calculate total number of published posts |
|
| 205 | - * @uses https://codex.wordpress.org/it:Riferimento_funzioni/wp_count_posts |
|
| 206 | - * @since 3.4.0 |
|
| 207 | - * |
|
| 208 | - * @return int Total number of published posts. |
|
| 209 | - */ |
|
| 210 | - public function count_posts() { |
|
| 211 | - |
|
| 212 | - return (int) wp_count_posts()->publish; |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - /** |
|
| 216 | - * Calculate total number of annotated published posts |
|
| 217 | - * @return int Total number of annotated published posts. |
|
| 218 | - * @since 3.4.0 |
|
| 219 | - * |
|
| 220 | - */ |
|
| 221 | - public function count_annotated_posts() { |
|
| 222 | - |
|
| 223 | - // Prepare interaction with db |
|
| 224 | - global $wpdb; |
|
| 225 | - // Retrieve Wordlift relation instances table name |
|
| 226 | - $table_name = wl_core_get_relation_instances_table_name(); |
|
| 227 | - // Calculate sql statement |
|
| 228 | - $sql_statement = <<<EOF |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + /** |
|
| 156 | + * Return stats |
|
| 157 | + * |
|
| 158 | + * @return string markup |
|
| 159 | + * @since 3.4.0 |
|
| 160 | + * |
|
| 161 | + */ |
|
| 162 | + public function add_dashboard_widgets() { |
|
| 163 | + wp_add_dashboard_widget( 'wordlift-dashboard-widget', 'WordLift Dashboard', array( |
|
| 164 | + $this, |
|
| 165 | + 'dashboard_widget_callback', |
|
| 166 | + ) ); |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + /** |
|
| 170 | + * Return stats |
|
| 171 | + * @uses https://codex.wordpress.org/Function_Reference/set_transient |
|
| 172 | + * |
|
| 173 | + * @since 3.4.0 |
|
| 174 | + * |
|
| 175 | + * @return string JSON obj with all available stats. |
|
| 176 | + */ |
|
| 177 | + public function ajax_get_stats() { |
|
| 178 | + |
|
| 179 | + // If needed, the transient is force to reloaded. |
|
| 180 | + if ( isset( $_GET['force_reload'] ) ) { |
|
| 181 | + delete_transient( self::TRANSIENT_NAME ); |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + // Try to retrieve the transient |
|
| 185 | + $stats = get_transient( self::TRANSIENT_NAME ); |
|
| 186 | + |
|
| 187 | + if ( ! $stats ) { |
|
| 188 | + // Calculate stats |
|
| 189 | + $stats = array( |
|
| 190 | + 'entities' => $this->entity_service->count(), |
|
| 191 | + 'posts' => $this->count_posts(), |
|
| 192 | + 'annotated_posts' => $this->count_annotated_posts(), |
|
| 193 | + 'triples' => $this->count_triples() ?: '-', |
|
| 194 | + 'rating' => $this->average_entities_rating(), |
|
| 195 | + ); |
|
| 196 | + // Cache stats results trough transient |
|
| 197 | + set_transient( self::TRANSIENT_NAME, $stats, self::TRANSIENT_EXPIRATION ); |
|
| 198 | + } |
|
| 199 | + // Return stats as json object |
|
| 200 | + wl_core_send_json( $stats ); |
|
| 201 | + } |
|
| 202 | + |
|
| 203 | + /** |
|
| 204 | + * Calculate total number of published posts |
|
| 205 | + * @uses https://codex.wordpress.org/it:Riferimento_funzioni/wp_count_posts |
|
| 206 | + * @since 3.4.0 |
|
| 207 | + * |
|
| 208 | + * @return int Total number of published posts. |
|
| 209 | + */ |
|
| 210 | + public function count_posts() { |
|
| 211 | + |
|
| 212 | + return (int) wp_count_posts()->publish; |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + /** |
|
| 216 | + * Calculate total number of annotated published posts |
|
| 217 | + * @return int Total number of annotated published posts. |
|
| 218 | + * @since 3.4.0 |
|
| 219 | + * |
|
| 220 | + */ |
|
| 221 | + public function count_annotated_posts() { |
|
| 222 | + |
|
| 223 | + // Prepare interaction with db |
|
| 224 | + global $wpdb; |
|
| 225 | + // Retrieve Wordlift relation instances table name |
|
| 226 | + $table_name = wl_core_get_relation_instances_table_name(); |
|
| 227 | + // Calculate sql statement |
|
| 228 | + $sql_statement = <<<EOF |
|
| 229 | 229 | SELECT COUNT(distinct(p.id)) FROM $wpdb->posts as p JOIN $table_name as r ON p.id = r.subject_id AND p.post_type = 'post' AND p.post_status = 'publish'; |
| 230 | 230 | EOF; |
| 231 | 231 | |
| 232 | - // Perform the query |
|
| 233 | - return (int) $wpdb->get_var( $sql_statement ); |
|
| 234 | - |
|
| 235 | - } |
|
| 236 | - |
|
| 237 | - /** |
|
| 238 | - * Calculate the average entities rating. |
|
| 239 | - * |
|
| 240 | - * @return int Average entities rating. |
|
| 241 | - * @since 3.4.0 |
|
| 242 | - * |
|
| 243 | - * @since 3.20.0 this method is public. |
|
| 244 | - */ |
|
| 245 | - public function average_entities_rating() { |
|
| 246 | - |
|
| 247 | - // Prepare interaction with db |
|
| 248 | - global $wpdb; |
|
| 249 | - $query = $wpdb->prepare( |
|
| 250 | - "SELECT AVG(meta_value) FROM $wpdb->postmeta where meta_key = %s", |
|
| 251 | - Wordlift_Rating_Service::RATING_RAW_SCORE_META_KEY |
|
| 252 | - ); |
|
| 253 | - |
|
| 254 | - // Perform the query. |
|
| 255 | - return $this->rating_service->convert_raw_score_to_percentage( $wpdb->get_var( $query ) ); |
|
| 256 | - } |
|
| 232 | + // Perform the query |
|
| 233 | + return (int) $wpdb->get_var( $sql_statement ); |
|
| 234 | + |
|
| 235 | + } |
|
| 236 | + |
|
| 237 | + /** |
|
| 238 | + * Calculate the average entities rating. |
|
| 239 | + * |
|
| 240 | + * @return int Average entities rating. |
|
| 241 | + * @since 3.4.0 |
|
| 242 | + * |
|
| 243 | + * @since 3.20.0 this method is public. |
|
| 244 | + */ |
|
| 245 | + public function average_entities_rating() { |
|
| 246 | + |
|
| 247 | + // Prepare interaction with db |
|
| 248 | + global $wpdb; |
|
| 249 | + $query = $wpdb->prepare( |
|
| 250 | + "SELECT AVG(meta_value) FROM $wpdb->postmeta where meta_key = %s", |
|
| 251 | + Wordlift_Rating_Service::RATING_RAW_SCORE_META_KEY |
|
| 252 | + ); |
|
| 253 | + |
|
| 254 | + // Perform the query. |
|
| 255 | + return $this->rating_service->convert_raw_score_to_percentage( $wpdb->get_var( $query ) ); |
|
| 256 | + } |
|
| 257 | 257 | |
| 258 | 258 | } |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | private static $instance; |
| 67 | 67 | |
| 68 | 68 | public static function get_instance() { |
| 69 | - if ( ! isset( self::$instance ) ) { |
|
| 69 | + if ( ! isset(self::$instance)) { |
|
| 70 | 70 | self::$instance = new self(); |
| 71 | 71 | } |
| 72 | 72 | |
@@ -80,53 +80,53 @@ discard block |
||
| 80 | 80 | * @since 3.4.0 |
| 81 | 81 | * |
| 82 | 82 | */ |
| 83 | - public function dashboard_widget_callback( $post ) { |
|
| 84 | - $caption_kses = array( 'a' => array( 'href' => array() ) ); |
|
| 85 | - $enriched_posts_title = __( 'enriched posts', 'wordlift' ); |
|
| 86 | - $enriched_posts_caption = sprintf( wp_kses( |
|
| 87 | - __( '%1$s, of your <a href="%2$s">posts</a> are annotated. This means %3$s annotated posts on %4$s.', 'wordlift' ), |
|
| 88 | - array( 'a' => array( 'href' => array() ) ) ), |
|
| 89 | - $this->render_stat_param( 'annotatedPostsPercentage' ), |
|
| 90 | - esc_url( admin_url( 'edit.php' ) ), |
|
| 91 | - $this->render_stat_param( 'annotated_posts' ), |
|
| 92 | - $this->render_stat_param( 'posts' ) |
|
| 83 | + public function dashboard_widget_callback($post) { |
|
| 84 | + $caption_kses = array('a' => array('href' => array())); |
|
| 85 | + $enriched_posts_title = __('enriched posts', 'wordlift'); |
|
| 86 | + $enriched_posts_caption = sprintf(wp_kses( |
|
| 87 | + __('%1$s, of your <a href="%2$s">posts</a> are annotated. This means %3$s annotated posts on %4$s.', 'wordlift'), |
|
| 88 | + array('a' => array('href' => array())) ), |
|
| 89 | + $this->render_stat_param('annotatedPostsPercentage'), |
|
| 90 | + esc_url(admin_url('edit.php')), |
|
| 91 | + $this->render_stat_param('annotated_posts'), |
|
| 92 | + $this->render_stat_param('posts') |
|
| 93 | 93 | ); |
| 94 | 94 | |
| 95 | - $rating_title = __( 'average entity rating', 'wordlift' ); |
|
| 96 | - $rating_caption = sprintf( wp_kses( |
|
| 97 | - __( 'You have %1$s entities in your <a href="%2$s">vocabulary</a> with an average rating of %3$s.', 'wordlift' ), |
|
| 98 | - array( 'a' => array( 'href' => array() ) ) ), |
|
| 99 | - $this->render_stat_param( 'entities' ), |
|
| 100 | - esc_url( admin_url( 'edit.php?post_type=entity' ) ), |
|
| 101 | - $this->render_stat_param( 'rating' ) |
|
| 95 | + $rating_title = __('average entity rating', 'wordlift'); |
|
| 96 | + $rating_caption = sprintf(wp_kses( |
|
| 97 | + __('You have %1$s entities in your <a href="%2$s">vocabulary</a> with an average rating of %3$s.', 'wordlift'), |
|
| 98 | + array('a' => array('href' => array())) ), |
|
| 99 | + $this->render_stat_param('entities'), |
|
| 100 | + esc_url(admin_url('edit.php?post_type=entity')), |
|
| 101 | + $this->render_stat_param('rating') |
|
| 102 | 102 | ); |
| 103 | 103 | |
| 104 | - $graph_title = __( 'triples in your graph', 'wordlift' ); |
|
| 105 | - $graph_caption = sprintf( wp_kses( |
|
| 106 | - __( 'Your graphs size corresponds to %1$s of <a href="%2$s">Wikidata</a>.', 'wordlift' ), |
|
| 107 | - array( 'a' => array( 'href' => array() ) ) ), |
|
| 108 | - $this->render_stat_param( 'wikidata' ), |
|
| 109 | - esc_url( 'https://www.wikidata.org/' ) |
|
| 104 | + $graph_title = __('triples in your graph', 'wordlift'); |
|
| 105 | + $graph_caption = sprintf(wp_kses( |
|
| 106 | + __('Your graphs size corresponds to %1$s of <a href="%2$s">Wikidata</a>.', 'wordlift'), |
|
| 107 | + array('a' => array('href' => array())) ), |
|
| 108 | + $this->render_stat_param('wikidata'), |
|
| 109 | + esc_url('https://www.wikidata.org/') |
|
| 110 | 110 | ); |
| 111 | 111 | |
| 112 | - $triples_label = __( 'triples', 'wordlift' ); |
|
| 112 | + $triples_label = __('triples', 'wordlift'); |
|
| 113 | 113 | |
| 114 | 114 | ?> |
| 115 | 115 | <div id="wl-dashboard-widget-inner-wrapper"> |
| 116 | 116 | <div class="wl-stat-card"> |
| 117 | 117 | <div class="wl-stat-graph-wrapper"> |
| 118 | - <h4><?php echo esc_html( $enriched_posts_title ); ?> <a |
|
| 118 | + <h4><?php echo esc_html($enriched_posts_title); ?> <a |
|
| 119 | 119 | href="http://docs.wordlift.it/en/latest/faq.html#what-is-content-enrichment" |
| 120 | 120 | target="_blank"><i class="wl-info"></i></a></h4> |
| 121 | 121 | <svg id="wl-posts-pie-chart" viewBox="0 0 32 32"> |
| 122 | 122 | <circle r="16" cx="16" cy="16"/> |
| 123 | 123 | </svg> |
| 124 | 124 | </div> |
| 125 | - <p><?php echo wp_kses( $enriched_posts_caption, $caption_kses ); ?> </p> |
|
| 125 | + <p><?php echo wp_kses($enriched_posts_caption, $caption_kses); ?> </p> |
|
| 126 | 126 | </div> |
| 127 | 127 | <div class="wl-stat-card"> |
| 128 | 128 | <div class="wl-stat-graph-wrapper"> |
| 129 | - <h4><?php echo esc_html( $rating_title ); ?> <a |
|
| 129 | + <h4><?php echo esc_html($rating_title); ?> <a |
|
| 130 | 130 | href="http://docs.wordlift.it/en/latest/faq.html#what-factors-determine-the-rating-of-an-entity" |
| 131 | 131 | target="_blank"><i class="wl-info"></i></a></h4> |
| 132 | 132 | <svg id="wl-entities-gauge-chart" viewBox="0 0 32 32"> |
@@ -134,18 +134,18 @@ discard block |
||
| 134 | 134 | <circle r="16" cx="16" cy="16" class="stat"/> |
| 135 | 135 | </svg> |
| 136 | 136 | </div> |
| 137 | - <p><?php echo wp_kses( $rating_caption, $caption_kses ); ?></p> |
|
| 137 | + <p><?php echo wp_kses($rating_caption, $caption_kses); ?></p> |
|
| 138 | 138 | </div> |
| 139 | 139 | <div class="wl-stat-card"> |
| 140 | 140 | <div class="wl-stat-graph-wrapper"> |
| 141 | - <h4><?php echo esc_html( $graph_title ); ?><a href="http://docs.wordlift.it/en/latest/faq.html#what-is-a-triple" |
|
| 141 | + <h4><?php echo esc_html($graph_title); ?><a href="http://docs.wordlift.it/en/latest/faq.html#what-is-a-triple" |
|
| 142 | 142 | target="_blank"><i class="wl-info"></i></a></h4> |
| 143 | 143 | <div class="wl-triples"> |
| 144 | 144 | <span id="wl-dashboard-widget-triples"></span> |
| 145 | - <span class="wl-triples-label"><?php echo esc_html( $triples_label ); ?></span> |
|
| 145 | + <span class="wl-triples-label"><?php echo esc_html($triples_label); ?></span> |
|
| 146 | 146 | </div> |
| 147 | 147 | </div> |
| 148 | - <p><?php echo wp_kses( $graph_caption, $caption_kses ); ?></p> |
|
| 148 | + <p><?php echo wp_kses($graph_caption, $caption_kses); ?></p> |
|
| 149 | 149 | </div> |
| 150 | 150 | </div> |
| 151 | 151 | <?php |
@@ -160,10 +160,10 @@ discard block |
||
| 160 | 160 | * |
| 161 | 161 | */ |
| 162 | 162 | public function add_dashboard_widgets() { |
| 163 | - wp_add_dashboard_widget( 'wordlift-dashboard-widget', 'WordLift Dashboard', array( |
|
| 163 | + wp_add_dashboard_widget('wordlift-dashboard-widget', 'WordLift Dashboard', array( |
|
| 164 | 164 | $this, |
| 165 | 165 | 'dashboard_widget_callback', |
| 166 | - ) ); |
|
| 166 | + )); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | /** |
@@ -177,14 +177,14 @@ discard block |
||
| 177 | 177 | public function ajax_get_stats() { |
| 178 | 178 | |
| 179 | 179 | // If needed, the transient is force to reloaded. |
| 180 | - if ( isset( $_GET['force_reload'] ) ) { |
|
| 181 | - delete_transient( self::TRANSIENT_NAME ); |
|
| 180 | + if (isset($_GET['force_reload'])) { |
|
| 181 | + delete_transient(self::TRANSIENT_NAME); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | // Try to retrieve the transient |
| 185 | - $stats = get_transient( self::TRANSIENT_NAME ); |
|
| 185 | + $stats = get_transient(self::TRANSIENT_NAME); |
|
| 186 | 186 | |
| 187 | - if ( ! $stats ) { |
|
| 187 | + if ( ! $stats) { |
|
| 188 | 188 | // Calculate stats |
| 189 | 189 | $stats = array( |
| 190 | 190 | 'entities' => $this->entity_service->count(), |
@@ -194,10 +194,10 @@ discard block |
||
| 194 | 194 | 'rating' => $this->average_entities_rating(), |
| 195 | 195 | ); |
| 196 | 196 | // Cache stats results trough transient |
| 197 | - set_transient( self::TRANSIENT_NAME, $stats, self::TRANSIENT_EXPIRATION ); |
|
| 197 | + set_transient(self::TRANSIENT_NAME, $stats, self::TRANSIENT_EXPIRATION); |
|
| 198 | 198 | } |
| 199 | 199 | // Return stats as json object |
| 200 | - wl_core_send_json( $stats ); |
|
| 200 | + wl_core_send_json($stats); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /** |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | EOF; |
| 231 | 231 | |
| 232 | 232 | // Perform the query |
| 233 | - return (int) $wpdb->get_var( $sql_statement ); |
|
| 233 | + return (int) $wpdb->get_var($sql_statement); |
|
| 234 | 234 | |
| 235 | 235 | } |
| 236 | 236 | |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | ); |
| 253 | 253 | |
| 254 | 254 | // Perform the query. |
| 255 | - return $this->rating_service->convert_raw_score_to_percentage( $wpdb->get_var( $query ) ); |
|
| 255 | + return $this->rating_service->convert_raw_score_to_percentage($wpdb->get_var($query)); |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | } |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | |
| 15 | 15 | if ( ! defined( 'ABSPATH' ) ) { |
| 16 | - exit; |
|
| 16 | + exit; |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | /** |
@@ -28,127 +28,127 @@ discard block |
||
| 28 | 28 | */ |
| 29 | 29 | class Wordlift_Admin_Setup { |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * A {@link Wordlift_Key_Validation_Service} instance. |
|
| 33 | - * |
|
| 34 | - * @since 3.9.0 |
|
| 35 | - * @access private |
|
| 36 | - * @var Wordlift_Key_Validation_Service A {@link Wordlift_Key_Validation_Service} instance. |
|
| 37 | - */ |
|
| 38 | - private $key_validation_service; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * A {@link Wordlift_Entity_Service} instance. |
|
| 42 | - * |
|
| 43 | - * @since 3.9.0 |
|
| 44 | - * @access private |
|
| 45 | - * @var Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance. |
|
| 46 | - */ |
|
| 47 | - private $entity_service; |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * A {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 51 | - * |
|
| 52 | - * @since 3.20.0 |
|
| 53 | - * @access private |
|
| 54 | - * @var \Wordlift_Admin_Language_Select_Element $language_select_element A {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 55 | - */ |
|
| 56 | - private $language_select_element; |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * A {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 60 | - * |
|
| 61 | - * @since 3.20.0 |
|
| 62 | - * @access private |
|
| 63 | - * @var \Wordlift_Admin_Country_Select_Element $country_select_element A {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 64 | - */ |
|
| 65 | - private $country_select_element; |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * Initialize the class and set its properties. |
|
| 69 | - * |
|
| 70 | - * @param \Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance. |
|
| 71 | - * @param \Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance. |
|
| 72 | - * @param \Wordlift_Admin_Language_Select_Element $language_select_element A {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 73 | - * @param \Wordlift_Admin_Country_Select_Element $country_select_element A {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 74 | - * |
|
| 75 | - * @since 3.9.0 |
|
| 76 | - * |
|
| 77 | - */ |
|
| 78 | - public function __construct( $key_validation_service, $entity_service, $language_select_element, $country_select_element ) { |
|
| 79 | - |
|
| 80 | - // Set a reference to the key validation service. |
|
| 81 | - $this->key_validation_service = $key_validation_service; |
|
| 82 | - |
|
| 83 | - // Set a reference to the entity service. |
|
| 84 | - $this->entity_service = $entity_service; |
|
| 85 | - |
|
| 86 | - // Set a reference to the UI elements language and country. |
|
| 87 | - $this->language_select_element = $language_select_element; |
|
| 88 | - $this->country_select_element = $country_select_element; |
|
| 89 | - |
|
| 90 | - // Hook to some WP's events: |
|
| 91 | - // When WP is loaded check whether the user decided to skip the set-up, i.e. don't show us even if WL is not set up. |
|
| 92 | - add_action( 'wp_loaded', array( $this, 'hide_notices' ) ); |
|
| 93 | - |
|
| 94 | - // Hook to `admin_menu` in order to add our own setup wizard page. |
|
| 95 | - add_action( 'admin_menu', array( $this, 'admin_menu' ) ); |
|
| 96 | - |
|
| 97 | - // Triggered when the user accesses the admin area, we decide whether to show our own wizard. |
|
| 98 | - add_action( 'admin_init', array( $this, 'show_page' ) ); |
|
| 99 | - |
|
| 100 | - /** |
|
| 101 | - * Filter: wl_feature__enable__notices. |
|
| 102 | - * |
|
| 103 | - * @param bool whether the notices needs to be enabled or not. |
|
| 104 | - * |
|
| 105 | - * @return bool |
|
| 106 | - * @since 3.27.6 |
|
| 107 | - */ |
|
| 108 | - if ( apply_filters( 'wl_feature__enable__notices', true ) ) { |
|
| 109 | - // Hook to `admin_notices` to display our notices. |
|
| 110 | - add_action( 'admin_notices', array( $this, 'admin_notices' ) ); |
|
| 111 | - } |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * Hook to `admin_init` and redirect to WordLift's setup page if the `_wl_activation_redirect` transient flag is set. |
|
| 116 | - * |
|
| 117 | - * @since 3.9.0 |
|
| 118 | - */ |
|
| 119 | - public function admin_init() { |
|
| 120 | - |
|
| 121 | - // If the `_wl_activation_redirect` is set, the redirect to the setup page. |
|
| 122 | - if ( get_transient( '_wl_activation_redirect' ) ) { |
|
| 123 | - delete_transient( '_wl_activation_redirect' ); |
|
| 124 | - |
|
| 125 | - // If the user asked to skip the wizard then comply. |
|
| 126 | - if ( Wordlift_Configuration_Service::get_instance()->is_skip_wizard() ) { |
|
| 127 | - return; |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - // If we're already on the page or the user doesn't have permissions, return. |
|
| 131 | - if ( ( ! empty( $_GET['page'] ) && 'wl-setup' === $_GET['page'] ) || is_network_admin() || isset( $_GET['activate-multi'] ) || ! current_user_can( 'manage_options' ) ) { |
|
| 132 | - return; |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - // Finally redirect to the setup page. |
|
| 136 | - wp_safe_redirect( admin_url( 'index.php?page=wl-setup' ) ); |
|
| 137 | - |
|
| 138 | - exit; |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - /** |
|
| 144 | - * Generate an admin notice suggesting to start the wizard if there is no configuration. |
|
| 145 | - * |
|
| 146 | - * @since 3.9.0 |
|
| 147 | - */ |
|
| 148 | - public function admin_notices() { |
|
| 149 | - |
|
| 150 | - // Use `wl_configuration_get_key` to check whether WL's key is set and that the user didn't disable the wizard. |
|
| 151 | - if ( '' === Wordlift_Configuration_Service::get_instance()->get_key() && ! Wordlift_Configuration_Service::get_instance()->is_skip_wizard() ) { ?> |
|
| 31 | + /** |
|
| 32 | + * A {@link Wordlift_Key_Validation_Service} instance. |
|
| 33 | + * |
|
| 34 | + * @since 3.9.0 |
|
| 35 | + * @access private |
|
| 36 | + * @var Wordlift_Key_Validation_Service A {@link Wordlift_Key_Validation_Service} instance. |
|
| 37 | + */ |
|
| 38 | + private $key_validation_service; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * A {@link Wordlift_Entity_Service} instance. |
|
| 42 | + * |
|
| 43 | + * @since 3.9.0 |
|
| 44 | + * @access private |
|
| 45 | + * @var Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance. |
|
| 46 | + */ |
|
| 47 | + private $entity_service; |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * A {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 51 | + * |
|
| 52 | + * @since 3.20.0 |
|
| 53 | + * @access private |
|
| 54 | + * @var \Wordlift_Admin_Language_Select_Element $language_select_element A {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 55 | + */ |
|
| 56 | + private $language_select_element; |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * A {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 60 | + * |
|
| 61 | + * @since 3.20.0 |
|
| 62 | + * @access private |
|
| 63 | + * @var \Wordlift_Admin_Country_Select_Element $country_select_element A {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 64 | + */ |
|
| 65 | + private $country_select_element; |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * Initialize the class and set its properties. |
|
| 69 | + * |
|
| 70 | + * @param \Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance. |
|
| 71 | + * @param \Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance. |
|
| 72 | + * @param \Wordlift_Admin_Language_Select_Element $language_select_element A {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 73 | + * @param \Wordlift_Admin_Country_Select_Element $country_select_element A {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 74 | + * |
|
| 75 | + * @since 3.9.0 |
|
| 76 | + * |
|
| 77 | + */ |
|
| 78 | + public function __construct( $key_validation_service, $entity_service, $language_select_element, $country_select_element ) { |
|
| 79 | + |
|
| 80 | + // Set a reference to the key validation service. |
|
| 81 | + $this->key_validation_service = $key_validation_service; |
|
| 82 | + |
|
| 83 | + // Set a reference to the entity service. |
|
| 84 | + $this->entity_service = $entity_service; |
|
| 85 | + |
|
| 86 | + // Set a reference to the UI elements language and country. |
|
| 87 | + $this->language_select_element = $language_select_element; |
|
| 88 | + $this->country_select_element = $country_select_element; |
|
| 89 | + |
|
| 90 | + // Hook to some WP's events: |
|
| 91 | + // When WP is loaded check whether the user decided to skip the set-up, i.e. don't show us even if WL is not set up. |
|
| 92 | + add_action( 'wp_loaded', array( $this, 'hide_notices' ) ); |
|
| 93 | + |
|
| 94 | + // Hook to `admin_menu` in order to add our own setup wizard page. |
|
| 95 | + add_action( 'admin_menu', array( $this, 'admin_menu' ) ); |
|
| 96 | + |
|
| 97 | + // Triggered when the user accesses the admin area, we decide whether to show our own wizard. |
|
| 98 | + add_action( 'admin_init', array( $this, 'show_page' ) ); |
|
| 99 | + |
|
| 100 | + /** |
|
| 101 | + * Filter: wl_feature__enable__notices. |
|
| 102 | + * |
|
| 103 | + * @param bool whether the notices needs to be enabled or not. |
|
| 104 | + * |
|
| 105 | + * @return bool |
|
| 106 | + * @since 3.27.6 |
|
| 107 | + */ |
|
| 108 | + if ( apply_filters( 'wl_feature__enable__notices', true ) ) { |
|
| 109 | + // Hook to `admin_notices` to display our notices. |
|
| 110 | + add_action( 'admin_notices', array( $this, 'admin_notices' ) ); |
|
| 111 | + } |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + /** |
|
| 115 | + * Hook to `admin_init` and redirect to WordLift's setup page if the `_wl_activation_redirect` transient flag is set. |
|
| 116 | + * |
|
| 117 | + * @since 3.9.0 |
|
| 118 | + */ |
|
| 119 | + public function admin_init() { |
|
| 120 | + |
|
| 121 | + // If the `_wl_activation_redirect` is set, the redirect to the setup page. |
|
| 122 | + if ( get_transient( '_wl_activation_redirect' ) ) { |
|
| 123 | + delete_transient( '_wl_activation_redirect' ); |
|
| 124 | + |
|
| 125 | + // If the user asked to skip the wizard then comply. |
|
| 126 | + if ( Wordlift_Configuration_Service::get_instance()->is_skip_wizard() ) { |
|
| 127 | + return; |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + // If we're already on the page or the user doesn't have permissions, return. |
|
| 131 | + if ( ( ! empty( $_GET['page'] ) && 'wl-setup' === $_GET['page'] ) || is_network_admin() || isset( $_GET['activate-multi'] ) || ! current_user_can( 'manage_options' ) ) { |
|
| 132 | + return; |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + // Finally redirect to the setup page. |
|
| 136 | + wp_safe_redirect( admin_url( 'index.php?page=wl-setup' ) ); |
|
| 137 | + |
|
| 138 | + exit; |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + /** |
|
| 144 | + * Generate an admin notice suggesting to start the wizard if there is no configuration. |
|
| 145 | + * |
|
| 146 | + * @since 3.9.0 |
|
| 147 | + */ |
|
| 148 | + public function admin_notices() { |
|
| 149 | + |
|
| 150 | + // Use `wl_configuration_get_key` to check whether WL's key is set and that the user didn't disable the wizard. |
|
| 151 | + if ( '' === Wordlift_Configuration_Service::get_instance()->get_key() && ! Wordlift_Configuration_Service::get_instance()->is_skip_wizard() ) { ?> |
|
| 152 | 152 | <div id="wl-message" class="updated"> |
| 153 | 153 | <p><?php esc_html_e( 'Welcome to WordLift – You‘re almost ready to start', 'wordlift' ); ?></p> |
| 154 | 154 | <p class="submit"> |
@@ -160,136 +160,136 @@ discard block |
||
| 160 | 160 | </div> |
| 161 | 161 | <?php } |
| 162 | 162 | |
| 163 | - } |
|
| 164 | - |
|
| 165 | - /** |
|
| 166 | - * Handle hiding the wizard notices by user request. |
|
| 167 | - * |
|
| 168 | - * @since 3.9.0 |
|
| 169 | - */ |
|
| 170 | - public function hide_notices() { |
|
| 171 | - |
|
| 172 | - // If it's not a `wl-hide-notice` or the nonce is not set, return. |
|
| 173 | - if ( ! isset( $_GET['wl-hide-notice'], $_GET['_wl_notice_nonce'] ) ) { |
|
| 174 | - return; |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - // If the nonce is invalid, return an error. |
|
| 178 | - if ( ! wp_verify_nonce( $_GET['_wl_notice_nonce'], 'wordlift_hide_notices_nonce' ) ) { |
|
| 179 | - wp_die( esc_html__( 'Action failed. Please refresh the page and retry.', 'wordlift' ) ); |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - // If the user doesn't have the right privileges, return an error. |
|
| 183 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 184 | - wp_die( esc_html__( 'Cheatin’ huh?', 'wordlift' ) ); |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - // Store a flag telling to skip the wizard. |
|
| 188 | - Wordlift_Configuration_Service::get_instance()->set_skip_wizard( true ); |
|
| 189 | - |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - /** |
|
| 193 | - * Register the wizard page to be able to access it. |
|
| 194 | - * |
|
| 195 | - * @since 3.9.0 |
|
| 196 | - */ |
|
| 197 | - public function admin_menu() { |
|
| 198 | - /** |
|
| 199 | - * |
|
| 200 | - * @see https://github.com/insideout10/wordlift-plugin/issues/1209 |
|
| 201 | - * @since 3.27.7 |
|
| 202 | - */ |
|
| 203 | - // @todo: find another way to do this, since this is adding an empty space in WP's dashboard menu. |
|
| 204 | - add_dashboard_page( '', '', 'manage_options', 'wl-setup', '' ); |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - /** |
|
| 208 | - * Displays the wizard page. |
|
| 209 | - * |
|
| 210 | - * @since 3.9.0 |
|
| 211 | - */ |
|
| 212 | - public function show_page() { |
|
| 213 | - |
|
| 214 | - // First check if we are in the wizard page at all, if not do nothing. |
|
| 215 | - if ( empty( $_GET['page'] ) || 'wl-setup' !== $_GET['page'] ) { |
|
| 216 | - return; |
|
| 217 | - } |
|
| 218 | - |
|
| 219 | - // If it's a POST and the `wl-save-configuration` action is set, save the configuration. |
|
| 220 | - if ( isset( $_POST['action'] ) && 'wl-save-configuration' === $_POST['action'] ) { |
|
| 221 | - |
|
| 222 | - // Check the nonce and the user capabilities. |
|
| 223 | - check_admin_referer( 'wl-save-configuration' ); |
|
| 224 | - |
|
| 225 | - // Check if the user has the right privileges. |
|
| 226 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 227 | - wp_die( esc_html__( 'Sorry, you do not have a permission to save the settings', 'wordlift' ) ); |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - // Save the configuration. |
|
| 231 | - $this->save_configuration( $_POST ); |
|
| 232 | - |
|
| 233 | - // Redirect to the admin's page. |
|
| 234 | - wp_redirect( admin_url() ); |
|
| 235 | - |
|
| 236 | - exit; |
|
| 237 | - } |
|
| 238 | - |
|
| 239 | - $language_select = $this->language_select_element; |
|
| 240 | - $country_select = $this->country_select_element; |
|
| 241 | - |
|
| 242 | - include plugin_dir_path( dirname( __FILE__ ) ) . 'admin/partials/wordlift-admin-setup.php'; |
|
| 243 | - |
|
| 244 | - exit; |
|
| 245 | - } |
|
| 246 | - |
|
| 247 | - /** |
|
| 248 | - * Save WordLift's configuration using the provided parameters. |
|
| 249 | - * |
|
| 250 | - * @param array $params An array of configuration parameters. |
|
| 251 | - * |
|
| 252 | - * @since 3.9.0 |
|
| 253 | - * |
|
| 254 | - */ |
|
| 255 | - public function save_configuration( $params ) { |
|
| 256 | - |
|
| 257 | - // We have the following parameters: |
|
| 258 | - // `key`, holding WL's key, |
|
| 259 | - // `vocabulary`, holding the vocabulary path, |
|
| 260 | - // `wl-country-code` with the country code (e.g. `us`), |
|
| 261 | - // `share-diagnostic`, the user preferences about sharing data with us. |
|
| 262 | - // `user_type`, the user type either `personal` or `company`, |
|
| 263 | - // `name`, with the `personal` or `company`'s name, |
|
| 264 | - // `logo`, the attachment id for the `personal` or `company` entity. |
|
| 265 | - |
|
| 266 | - // Store the key: |
|
| 267 | - Wordlift_Configuration_Service::get_instance()->set_key( $params['key'] ); |
|
| 268 | - |
|
| 269 | - // Store the vocabulary path: |
|
| 270 | - Wordlift_Configuration_Service::get_instance()->set_entity_base_path( $params['vocabulary'] ); |
|
| 271 | - |
|
| 272 | - // Store the site's country: |
|
| 273 | - Wordlift_Configuration_Service::get_instance()->set_country_code( $params['wl-country-code'] ); |
|
| 274 | - |
|
| 275 | - // Store the preferences in variable, because if the checkbox is not checked |
|
| 276 | - // the `share-diagnostic` will not exists in `$params` array. |
|
| 277 | - $share_diagnostic_preferences = empty( $params['share-diagnostic'] ) ? 'no' : 'yes'; |
|
| 278 | - |
|
| 279 | - // Store the diagnostic preferences: |
|
| 280 | - Wordlift_Configuration_Service::get_instance()->set_diagnostic_preferences( $share_diagnostic_preferences ); |
|
| 281 | - |
|
| 282 | - // Set the type URI, either http://schema.org/Person or http://schema.org/Organization. |
|
| 283 | - $type_uri = sprintf( 'http://schema.org/%s', 'organization' === $params['user_type'] ? 'Organization' : 'Person' ); |
|
| 284 | - |
|
| 285 | - // Create an entity for the publisher. |
|
| 286 | - $publisher_post_id = $this->entity_service->create( $params['name'], $type_uri, $params['logo'], 'publish' ); |
|
| 287 | - |
|
| 288 | - // Store the publisher entity post id in the configuration. |
|
| 289 | - Wordlift_Configuration_Service::get_instance()->set_publisher_id( $publisher_post_id ); |
|
| 290 | - |
|
| 291 | - flush_rewrite_rules(); // Needed because of possible change to the entity base path. |
|
| 292 | - |
|
| 293 | - } |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + /** |
|
| 166 | + * Handle hiding the wizard notices by user request. |
|
| 167 | + * |
|
| 168 | + * @since 3.9.0 |
|
| 169 | + */ |
|
| 170 | + public function hide_notices() { |
|
| 171 | + |
|
| 172 | + // If it's not a `wl-hide-notice` or the nonce is not set, return. |
|
| 173 | + if ( ! isset( $_GET['wl-hide-notice'], $_GET['_wl_notice_nonce'] ) ) { |
|
| 174 | + return; |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + // If the nonce is invalid, return an error. |
|
| 178 | + if ( ! wp_verify_nonce( $_GET['_wl_notice_nonce'], 'wordlift_hide_notices_nonce' ) ) { |
|
| 179 | + wp_die( esc_html__( 'Action failed. Please refresh the page and retry.', 'wordlift' ) ); |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + // If the user doesn't have the right privileges, return an error. |
|
| 183 | + if ( ! current_user_can( 'manage_options' ) ) { |
|
| 184 | + wp_die( esc_html__( 'Cheatin’ huh?', 'wordlift' ) ); |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + // Store a flag telling to skip the wizard. |
|
| 188 | + Wordlift_Configuration_Service::get_instance()->set_skip_wizard( true ); |
|
| 189 | + |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + /** |
|
| 193 | + * Register the wizard page to be able to access it. |
|
| 194 | + * |
|
| 195 | + * @since 3.9.0 |
|
| 196 | + */ |
|
| 197 | + public function admin_menu() { |
|
| 198 | + /** |
|
| 199 | + * |
|
| 200 | + * @see https://github.com/insideout10/wordlift-plugin/issues/1209 |
|
| 201 | + * @since 3.27.7 |
|
| 202 | + */ |
|
| 203 | + // @todo: find another way to do this, since this is adding an empty space in WP's dashboard menu. |
|
| 204 | + add_dashboard_page( '', '', 'manage_options', 'wl-setup', '' ); |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + /** |
|
| 208 | + * Displays the wizard page. |
|
| 209 | + * |
|
| 210 | + * @since 3.9.0 |
|
| 211 | + */ |
|
| 212 | + public function show_page() { |
|
| 213 | + |
|
| 214 | + // First check if we are in the wizard page at all, if not do nothing. |
|
| 215 | + if ( empty( $_GET['page'] ) || 'wl-setup' !== $_GET['page'] ) { |
|
| 216 | + return; |
|
| 217 | + } |
|
| 218 | + |
|
| 219 | + // If it's a POST and the `wl-save-configuration` action is set, save the configuration. |
|
| 220 | + if ( isset( $_POST['action'] ) && 'wl-save-configuration' === $_POST['action'] ) { |
|
| 221 | + |
|
| 222 | + // Check the nonce and the user capabilities. |
|
| 223 | + check_admin_referer( 'wl-save-configuration' ); |
|
| 224 | + |
|
| 225 | + // Check if the user has the right privileges. |
|
| 226 | + if ( ! current_user_can( 'manage_options' ) ) { |
|
| 227 | + wp_die( esc_html__( 'Sorry, you do not have a permission to save the settings', 'wordlift' ) ); |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + // Save the configuration. |
|
| 231 | + $this->save_configuration( $_POST ); |
|
| 232 | + |
|
| 233 | + // Redirect to the admin's page. |
|
| 234 | + wp_redirect( admin_url() ); |
|
| 235 | + |
|
| 236 | + exit; |
|
| 237 | + } |
|
| 238 | + |
|
| 239 | + $language_select = $this->language_select_element; |
|
| 240 | + $country_select = $this->country_select_element; |
|
| 241 | + |
|
| 242 | + include plugin_dir_path( dirname( __FILE__ ) ) . 'admin/partials/wordlift-admin-setup.php'; |
|
| 243 | + |
|
| 244 | + exit; |
|
| 245 | + } |
|
| 246 | + |
|
| 247 | + /** |
|
| 248 | + * Save WordLift's configuration using the provided parameters. |
|
| 249 | + * |
|
| 250 | + * @param array $params An array of configuration parameters. |
|
| 251 | + * |
|
| 252 | + * @since 3.9.0 |
|
| 253 | + * |
|
| 254 | + */ |
|
| 255 | + public function save_configuration( $params ) { |
|
| 256 | + |
|
| 257 | + // We have the following parameters: |
|
| 258 | + // `key`, holding WL's key, |
|
| 259 | + // `vocabulary`, holding the vocabulary path, |
|
| 260 | + // `wl-country-code` with the country code (e.g. `us`), |
|
| 261 | + // `share-diagnostic`, the user preferences about sharing data with us. |
|
| 262 | + // `user_type`, the user type either `personal` or `company`, |
|
| 263 | + // `name`, with the `personal` or `company`'s name, |
|
| 264 | + // `logo`, the attachment id for the `personal` or `company` entity. |
|
| 265 | + |
|
| 266 | + // Store the key: |
|
| 267 | + Wordlift_Configuration_Service::get_instance()->set_key( $params['key'] ); |
|
| 268 | + |
|
| 269 | + // Store the vocabulary path: |
|
| 270 | + Wordlift_Configuration_Service::get_instance()->set_entity_base_path( $params['vocabulary'] ); |
|
| 271 | + |
|
| 272 | + // Store the site's country: |
|
| 273 | + Wordlift_Configuration_Service::get_instance()->set_country_code( $params['wl-country-code'] ); |
|
| 274 | + |
|
| 275 | + // Store the preferences in variable, because if the checkbox is not checked |
|
| 276 | + // the `share-diagnostic` will not exists in `$params` array. |
|
| 277 | + $share_diagnostic_preferences = empty( $params['share-diagnostic'] ) ? 'no' : 'yes'; |
|
| 278 | + |
|
| 279 | + // Store the diagnostic preferences: |
|
| 280 | + Wordlift_Configuration_Service::get_instance()->set_diagnostic_preferences( $share_diagnostic_preferences ); |
|
| 281 | + |
|
| 282 | + // Set the type URI, either http://schema.org/Person or http://schema.org/Organization. |
|
| 283 | + $type_uri = sprintf( 'http://schema.org/%s', 'organization' === $params['user_type'] ? 'Organization' : 'Person' ); |
|
| 284 | + |
|
| 285 | + // Create an entity for the publisher. |
|
| 286 | + $publisher_post_id = $this->entity_service->create( $params['name'], $type_uri, $params['logo'], 'publish' ); |
|
| 287 | + |
|
| 288 | + // Store the publisher entity post id in the configuration. |
|
| 289 | + Wordlift_Configuration_Service::get_instance()->set_publisher_id( $publisher_post_id ); |
|
| 290 | + |
|
| 291 | + flush_rewrite_rules(); // Needed because of possible change to the entity base path. |
|
| 292 | + |
|
| 293 | + } |
|
| 294 | 294 | |
| 295 | 295 | } |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | * @since 3.9.0 |
| 13 | 13 | */ |
| 14 | 14 | |
| 15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 15 | +if ( ! defined('ABSPATH')) { |
|
| 16 | 16 | exit; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | * @since 3.9.0 |
| 76 | 76 | * |
| 77 | 77 | */ |
| 78 | - public function __construct( $key_validation_service, $entity_service, $language_select_element, $country_select_element ) { |
|
| 78 | + public function __construct($key_validation_service, $entity_service, $language_select_element, $country_select_element) { |
|
| 79 | 79 | |
| 80 | 80 | // Set a reference to the key validation service. |
| 81 | 81 | $this->key_validation_service = $key_validation_service; |
@@ -89,13 +89,13 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | // Hook to some WP's events: |
| 91 | 91 | // When WP is loaded check whether the user decided to skip the set-up, i.e. don't show us even if WL is not set up. |
| 92 | - add_action( 'wp_loaded', array( $this, 'hide_notices' ) ); |
|
| 92 | + add_action('wp_loaded', array($this, 'hide_notices')); |
|
| 93 | 93 | |
| 94 | 94 | // Hook to `admin_menu` in order to add our own setup wizard page. |
| 95 | - add_action( 'admin_menu', array( $this, 'admin_menu' ) ); |
|
| 95 | + add_action('admin_menu', array($this, 'admin_menu')); |
|
| 96 | 96 | |
| 97 | 97 | // Triggered when the user accesses the admin area, we decide whether to show our own wizard. |
| 98 | - add_action( 'admin_init', array( $this, 'show_page' ) ); |
|
| 98 | + add_action('admin_init', array($this, 'show_page')); |
|
| 99 | 99 | |
| 100 | 100 | /** |
| 101 | 101 | * Filter: wl_feature__enable__notices. |
@@ -105,9 +105,9 @@ discard block |
||
| 105 | 105 | * @return bool |
| 106 | 106 | * @since 3.27.6 |
| 107 | 107 | */ |
| 108 | - if ( apply_filters( 'wl_feature__enable__notices', true ) ) { |
|
| 108 | + if (apply_filters('wl_feature__enable__notices', true)) { |
|
| 109 | 109 | // Hook to `admin_notices` to display our notices. |
| 110 | - add_action( 'admin_notices', array( $this, 'admin_notices' ) ); |
|
| 110 | + add_action('admin_notices', array($this, 'admin_notices')); |
|
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | 113 | |
@@ -119,21 +119,21 @@ discard block |
||
| 119 | 119 | public function admin_init() { |
| 120 | 120 | |
| 121 | 121 | // If the `_wl_activation_redirect` is set, the redirect to the setup page. |
| 122 | - if ( get_transient( '_wl_activation_redirect' ) ) { |
|
| 123 | - delete_transient( '_wl_activation_redirect' ); |
|
| 122 | + if (get_transient('_wl_activation_redirect')) { |
|
| 123 | + delete_transient('_wl_activation_redirect'); |
|
| 124 | 124 | |
| 125 | 125 | // If the user asked to skip the wizard then comply. |
| 126 | - if ( Wordlift_Configuration_Service::get_instance()->is_skip_wizard() ) { |
|
| 126 | + if (Wordlift_Configuration_Service::get_instance()->is_skip_wizard()) { |
|
| 127 | 127 | return; |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | // If we're already on the page or the user doesn't have permissions, return. |
| 131 | - if ( ( ! empty( $_GET['page'] ) && 'wl-setup' === $_GET['page'] ) || is_network_admin() || isset( $_GET['activate-multi'] ) || ! current_user_can( 'manage_options' ) ) { |
|
| 131 | + if (( ! empty($_GET['page']) && 'wl-setup' === $_GET['page']) || is_network_admin() || isset($_GET['activate-multi']) || ! current_user_can('manage_options')) { |
|
| 132 | 132 | return; |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | // Finally redirect to the setup page. |
| 136 | - wp_safe_redirect( admin_url( 'index.php?page=wl-setup' ) ); |
|
| 136 | + wp_safe_redirect(admin_url('index.php?page=wl-setup')); |
|
| 137 | 137 | |
| 138 | 138 | exit; |
| 139 | 139 | } |
@@ -148,14 +148,14 @@ discard block |
||
| 148 | 148 | public function admin_notices() { |
| 149 | 149 | |
| 150 | 150 | // Use `wl_configuration_get_key` to check whether WL's key is set and that the user didn't disable the wizard. |
| 151 | - if ( '' === Wordlift_Configuration_Service::get_instance()->get_key() && ! Wordlift_Configuration_Service::get_instance()->is_skip_wizard() ) { ?> |
|
| 151 | + if ('' === Wordlift_Configuration_Service::get_instance()->get_key() && ! Wordlift_Configuration_Service::get_instance()->is_skip_wizard()) { ?> |
|
| 152 | 152 | <div id="wl-message" class="updated"> |
| 153 | - <p><?php esc_html_e( 'Welcome to WordLift – You‘re almost ready to start', 'wordlift' ); ?></p> |
|
| 153 | + <p><?php esc_html_e('Welcome to WordLift – You‘re almost ready to start', 'wordlift'); ?></p> |
|
| 154 | 154 | <p class="submit"> |
| 155 | - <a href="<?php echo esc_url( admin_url( 'admin.php?page=wl-setup' ) ); ?>" |
|
| 156 | - class="button-primary"><?php esc_html_e( 'Run the Setup Wizard', 'wordlift' ); ?></a> |
|
| 155 | + <a href="<?php echo esc_url(admin_url('admin.php?page=wl-setup')); ?>" |
|
| 156 | + class="button-primary"><?php esc_html_e('Run the Setup Wizard', 'wordlift'); ?></a> |
|
| 157 | 157 | <a class="button-secondary skip" |
| 158 | - href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wl-hide-notice', 'install' ), 'wordlift_hide_notices_nonce', '_wl_notice_nonce' ) ); ?>"><?php esc_html_e( 'Skip Setup', 'wordlift' ); ?></a> |
|
| 158 | + href="<?php echo esc_url(wp_nonce_url(add_query_arg('wl-hide-notice', 'install'), 'wordlift_hide_notices_nonce', '_wl_notice_nonce')); ?>"><?php esc_html_e('Skip Setup', 'wordlift'); ?></a> |
|
| 159 | 159 | </p> |
| 160 | 160 | </div> |
| 161 | 161 | <?php } |
@@ -170,22 +170,22 @@ discard block |
||
| 170 | 170 | public function hide_notices() { |
| 171 | 171 | |
| 172 | 172 | // If it's not a `wl-hide-notice` or the nonce is not set, return. |
| 173 | - if ( ! isset( $_GET['wl-hide-notice'], $_GET['_wl_notice_nonce'] ) ) { |
|
| 173 | + if ( ! isset($_GET['wl-hide-notice'], $_GET['_wl_notice_nonce'])) { |
|
| 174 | 174 | return; |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | // If the nonce is invalid, return an error. |
| 178 | - if ( ! wp_verify_nonce( $_GET['_wl_notice_nonce'], 'wordlift_hide_notices_nonce' ) ) { |
|
| 179 | - wp_die( esc_html__( 'Action failed. Please refresh the page and retry.', 'wordlift' ) ); |
|
| 178 | + if ( ! wp_verify_nonce($_GET['_wl_notice_nonce'], 'wordlift_hide_notices_nonce')) { |
|
| 179 | + wp_die(esc_html__('Action failed. Please refresh the page and retry.', 'wordlift')); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | // If the user doesn't have the right privileges, return an error. |
| 183 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 184 | - wp_die( esc_html__( 'Cheatin’ huh?', 'wordlift' ) ); |
|
| 183 | + if ( ! current_user_can('manage_options')) { |
|
| 184 | + wp_die(esc_html__('Cheatin’ huh?', 'wordlift')); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | // Store a flag telling to skip the wizard. |
| 188 | - Wordlift_Configuration_Service::get_instance()->set_skip_wizard( true ); |
|
| 188 | + Wordlift_Configuration_Service::get_instance()->set_skip_wizard(true); |
|
| 189 | 189 | |
| 190 | 190 | } |
| 191 | 191 | |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | * @since 3.27.7 |
| 202 | 202 | */ |
| 203 | 203 | // @todo: find another way to do this, since this is adding an empty space in WP's dashboard menu. |
| 204 | - add_dashboard_page( '', '', 'manage_options', 'wl-setup', '' ); |
|
| 204 | + add_dashboard_page('', '', 'manage_options', 'wl-setup', ''); |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | /** |
@@ -212,26 +212,26 @@ discard block |
||
| 212 | 212 | public function show_page() { |
| 213 | 213 | |
| 214 | 214 | // First check if we are in the wizard page at all, if not do nothing. |
| 215 | - if ( empty( $_GET['page'] ) || 'wl-setup' !== $_GET['page'] ) { |
|
| 215 | + if (empty($_GET['page']) || 'wl-setup' !== $_GET['page']) { |
|
| 216 | 216 | return; |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | // If it's a POST and the `wl-save-configuration` action is set, save the configuration. |
| 220 | - if ( isset( $_POST['action'] ) && 'wl-save-configuration' === $_POST['action'] ) { |
|
| 220 | + if (isset($_POST['action']) && 'wl-save-configuration' === $_POST['action']) { |
|
| 221 | 221 | |
| 222 | 222 | // Check the nonce and the user capabilities. |
| 223 | - check_admin_referer( 'wl-save-configuration' ); |
|
| 223 | + check_admin_referer('wl-save-configuration'); |
|
| 224 | 224 | |
| 225 | 225 | // Check if the user has the right privileges. |
| 226 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 227 | - wp_die( esc_html__( 'Sorry, you do not have a permission to save the settings', 'wordlift' ) ); |
|
| 226 | + if ( ! current_user_can('manage_options')) { |
|
| 227 | + wp_die(esc_html__('Sorry, you do not have a permission to save the settings', 'wordlift')); |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | // Save the configuration. |
| 231 | - $this->save_configuration( $_POST ); |
|
| 231 | + $this->save_configuration($_POST); |
|
| 232 | 232 | |
| 233 | 233 | // Redirect to the admin's page. |
| 234 | - wp_redirect( admin_url() ); |
|
| 234 | + wp_redirect(admin_url()); |
|
| 235 | 235 | |
| 236 | 236 | exit; |
| 237 | 237 | } |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | $language_select = $this->language_select_element; |
| 240 | 240 | $country_select = $this->country_select_element; |
| 241 | 241 | |
| 242 | - include plugin_dir_path( dirname( __FILE__ ) ) . 'admin/partials/wordlift-admin-setup.php'; |
|
| 242 | + include plugin_dir_path(dirname(__FILE__)).'admin/partials/wordlift-admin-setup.php'; |
|
| 243 | 243 | |
| 244 | 244 | exit; |
| 245 | 245 | } |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | * @since 3.9.0 |
| 253 | 253 | * |
| 254 | 254 | */ |
| 255 | - public function save_configuration( $params ) { |
|
| 255 | + public function save_configuration($params) { |
|
| 256 | 256 | |
| 257 | 257 | // We have the following parameters: |
| 258 | 258 | // `key`, holding WL's key, |
@@ -264,29 +264,29 @@ discard block |
||
| 264 | 264 | // `logo`, the attachment id for the `personal` or `company` entity. |
| 265 | 265 | |
| 266 | 266 | // Store the key: |
| 267 | - Wordlift_Configuration_Service::get_instance()->set_key( $params['key'] ); |
|
| 267 | + Wordlift_Configuration_Service::get_instance()->set_key($params['key']); |
|
| 268 | 268 | |
| 269 | 269 | // Store the vocabulary path: |
| 270 | - Wordlift_Configuration_Service::get_instance()->set_entity_base_path( $params['vocabulary'] ); |
|
| 270 | + Wordlift_Configuration_Service::get_instance()->set_entity_base_path($params['vocabulary']); |
|
| 271 | 271 | |
| 272 | 272 | // Store the site's country: |
| 273 | - Wordlift_Configuration_Service::get_instance()->set_country_code( $params['wl-country-code'] ); |
|
| 273 | + Wordlift_Configuration_Service::get_instance()->set_country_code($params['wl-country-code']); |
|
| 274 | 274 | |
| 275 | 275 | // Store the preferences in variable, because if the checkbox is not checked |
| 276 | 276 | // the `share-diagnostic` will not exists in `$params` array. |
| 277 | - $share_diagnostic_preferences = empty( $params['share-diagnostic'] ) ? 'no' : 'yes'; |
|
| 277 | + $share_diagnostic_preferences = empty($params['share-diagnostic']) ? 'no' : 'yes'; |
|
| 278 | 278 | |
| 279 | 279 | // Store the diagnostic preferences: |
| 280 | - Wordlift_Configuration_Service::get_instance()->set_diagnostic_preferences( $share_diagnostic_preferences ); |
|
| 280 | + Wordlift_Configuration_Service::get_instance()->set_diagnostic_preferences($share_diagnostic_preferences); |
|
| 281 | 281 | |
| 282 | 282 | // Set the type URI, either http://schema.org/Person or http://schema.org/Organization. |
| 283 | - $type_uri = sprintf( 'http://schema.org/%s', 'organization' === $params['user_type'] ? 'Organization' : 'Person' ); |
|
| 283 | + $type_uri = sprintf('http://schema.org/%s', 'organization' === $params['user_type'] ? 'Organization' : 'Person'); |
|
| 284 | 284 | |
| 285 | 285 | // Create an entity for the publisher. |
| 286 | - $publisher_post_id = $this->entity_service->create( $params['name'], $type_uri, $params['logo'], 'publish' ); |
|
| 286 | + $publisher_post_id = $this->entity_service->create($params['name'], $type_uri, $params['logo'], 'publish'); |
|
| 287 | 287 | |
| 288 | 288 | // Store the publisher entity post id in the configuration. |
| 289 | - Wordlift_Configuration_Service::get_instance()->set_publisher_id( $publisher_post_id ); |
|
| 289 | + Wordlift_Configuration_Service::get_instance()->set_publisher_id($publisher_post_id); |
|
| 290 | 290 | |
| 291 | 291 | flush_rewrite_rules(); // Needed because of possible change to the entity base path. |
| 292 | 292 | |
@@ -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 |
@@ -78,21 +78,21 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | <div id="<?php echo esc_attr( $tax_name ); ?>-legacy" class="tabs-panel" style="display: none;"> |
| 80 | 80 | <?php |
| 81 | - $name = ( $tax_name == 'category' ) ? 'post_category' : 'tax_input[' . $tax_name . ']'; |
|
| 82 | - echo "<input type='hidden' name='{$name}[]' value='0' />"; // Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks. |
|
| 83 | - ?> |
|
| 81 | + $name = ( $tax_name == 'category' ) ? 'post_category' : 'tax_input[' . $tax_name . ']'; |
|
| 82 | + echo "<input type='hidden' name='{$name}[]' value='0' />"; // Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks. |
|
| 83 | + ?> |
|
| 84 | 84 | <ul id="<?php echo esc_attr( $tax_name ); ?>checklist" |
| 85 | 85 | data-wp-lists="list:<?php echo esc_attr( $tax_name ); ?>" |
| 86 | 86 | class="categorychecklist form-no-clear"> |
| 87 | 87 | <?php |
| 88 | - wp_terms_checklist( |
|
| 89 | - $post->ID, |
|
| 90 | - array( |
|
| 91 | - 'taxonomy' => $tax_name, |
|
| 92 | - 'popular_cats' => $popular_ids, |
|
| 93 | - ) |
|
| 94 | - ); |
|
| 95 | - ?> |
|
| 88 | + wp_terms_checklist( |
|
| 89 | + $post->ID, |
|
| 90 | + array( |
|
| 91 | + 'taxonomy' => $tax_name, |
|
| 92 | + 'popular_cats' => $popular_ids, |
|
| 93 | + ) |
|
| 94 | + ); |
|
| 95 | + ?> |
|
| 96 | 96 | </ul> |
| 97 | 97 | </div> |
| 98 | 98 | <?php if ( current_user_can( $taxonomy->cap->edit_terms ) ) : ?> |
@@ -101,9 +101,9 @@ discard block |
||
| 101 | 101 | href="#<?php echo esc_attr( $tax_name ); ?>-add" |
| 102 | 102 | class="taxonomy-add-new"> |
| 103 | 103 | <?php |
| 104 | - /* translators: %s: add new taxonomy label */ |
|
| 105 | - echo esc_html( sprintf( __( '+ %s' ), $taxonomy->labels->add_new_item ) ); |
|
| 106 | - ?> |
|
| 104 | + /* translators: %s: add new taxonomy label */ |
|
| 105 | + echo esc_html( sprintf( __( '+ %s' ), $taxonomy->labels->add_new_item ) ); |
|
| 106 | + ?> |
|
| 107 | 107 | </a> |
| 108 | 108 | <p id="<?php echo esc_attr( $tax_name ); ?>-add" class="category-add wp-hidden-child"> |
| 109 | 109 | <label class="screen-reader-text" |
@@ -117,42 +117,42 @@ discard block |
||
| 117 | 117 | <?php echo esc_html( $taxonomy->labels->parent_item_colon ); ?> |
| 118 | 118 | </label> |
| 119 | 119 | <?php |
| 120 | - $parent_dropdown_args = array( |
|
| 121 | - 'taxonomy' => $tax_name, |
|
| 122 | - 'hide_empty' => 0, |
|
| 123 | - 'name' => 'new' . $tax_name . '_parent', |
|
| 124 | - 'orderby' => 'name', |
|
| 125 | - 'hierarchical' => 1, |
|
| 126 | - 'show_option_none' => '— ' . $taxonomy->labels->parent_item . ' —', |
|
| 127 | - ); |
|
| 120 | + $parent_dropdown_args = array( |
|
| 121 | + 'taxonomy' => $tax_name, |
|
| 122 | + 'hide_empty' => 0, |
|
| 123 | + 'name' => 'new' . $tax_name . '_parent', |
|
| 124 | + 'orderby' => 'name', |
|
| 125 | + 'hierarchical' => 1, |
|
| 126 | + 'show_option_none' => '— ' . $taxonomy->labels->parent_item . ' —', |
|
| 127 | + ); |
|
| 128 | 128 | |
| 129 | - /** |
|
| 130 | - * Filters the arguments for the taxonomy parent dropdown on the Post Edit page. |
|
| 131 | - * |
|
| 132 | - * @param array $parent_dropdown_args { |
|
| 133 | - * Optional. Array of arguments to generate parent dropdown. |
|
| 134 | - * |
|
| 135 | - * @type string $taxonomy Name of the taxonomy to retrieve. |
|
| 136 | - * @type bool $hide_if_empty True to skip generating markup if no |
|
| 137 | - * categories are found. Default 0. |
|
| 138 | - * @type string $name Value for the 'name' attribute |
|
| 139 | - * of the select element. |
|
| 140 | - * Default "new{$tax_name}_parent". |
|
| 141 | - * @type string $orderby Which column to use for ordering |
|
| 142 | - * terms. Default 'name'. |
|
| 143 | - * @type bool|int $hierarchical Whether to traverse the taxonomy |
|
| 144 | - * hierarchy. Default 1. |
|
| 145 | - * @type string $show_option_none Text to display for the "none" option. |
|
| 146 | - * Default "— {$parent} —", |
|
| 147 | - * where `$parent` is 'parent_item' |
|
| 148 | - * taxonomy label. |
|
| 149 | - * } |
|
| 150 | - * @since 4.4.0 |
|
| 151 | - */ |
|
| 152 | - $parent_dropdown_args = apply_filters( 'post_edit_category_parent_dropdown_args', $parent_dropdown_args ); |
|
| 129 | + /** |
|
| 130 | + * Filters the arguments for the taxonomy parent dropdown on the Post Edit page. |
|
| 131 | + * |
|
| 132 | + * @param array $parent_dropdown_args { |
|
| 133 | + * Optional. Array of arguments to generate parent dropdown. |
|
| 134 | + * |
|
| 135 | + * @type string $taxonomy Name of the taxonomy to retrieve. |
|
| 136 | + * @type bool $hide_if_empty True to skip generating markup if no |
|
| 137 | + * categories are found. Default 0. |
|
| 138 | + * @type string $name Value for the 'name' attribute |
|
| 139 | + * of the select element. |
|
| 140 | + * Default "new{$tax_name}_parent". |
|
| 141 | + * @type string $orderby Which column to use for ordering |
|
| 142 | + * terms. Default 'name'. |
|
| 143 | + * @type bool|int $hierarchical Whether to traverse the taxonomy |
|
| 144 | + * hierarchy. Default 1. |
|
| 145 | + * @type string $show_option_none Text to display for the "none" option. |
|
| 146 | + * Default "— {$parent} —", |
|
| 147 | + * where `$parent` is 'parent_item' |
|
| 148 | + * taxonomy label. |
|
| 149 | + * } |
|
| 150 | + * @since 4.4.0 |
|
| 151 | + */ |
|
| 152 | + $parent_dropdown_args = apply_filters( 'post_edit_category_parent_dropdown_args', $parent_dropdown_args ); |
|
| 153 | 153 | |
| 154 | - wp_dropdown_categories( $parent_dropdown_args ); |
|
| 155 | - ?> |
|
| 154 | + wp_dropdown_categories( $parent_dropdown_args ); |
|
| 155 | + ?> |
|
| 156 | 156 | <input type="button" id="<?php echo esc_attr( $tax_name ); ?>-add-submit" |
| 157 | 157 | data-wp-lists="add:<?php echo esc_html( $tax_name ); ?>checklist:<?php echo esc_attr( $tax_name ); ?>-add" |
| 158 | 158 | class="button category-add-submit" |
@@ -164,6 +164,6 @@ discard block |
||
| 164 | 164 | <?php endif; ?> |
| 165 | 165 | </div> |
| 166 | 166 | <?php |
| 167 | - } |
|
| 167 | + } |
|
| 168 | 168 | |
| 169 | 169 | } |
@@ -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,46 +43,46 @@ 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 | - <li><a href="#<?php echo esc_attr( $tax_name ); ?>-pop"><?php echo esc_html__( 'Most Used' , 'wordlift' ); ?></a> |
|
| 62 | + <li><a href="#<?php echo esc_attr($tax_name); ?>-pop"><?php echo esc_html__('Most Used', 'wordlift'); ?></a> |
|
| 63 | 63 | </li> |
| 64 | - <li><a href="#<?php echo esc_attr( $tax_name ); ?>-legacy"> |
|
| 65 | - <?php echo esc_html_x( 'A-Z', 'Entity Types metabox', 'wordlift' ); ?></a> |
|
| 64 | + <li><a href="#<?php echo esc_attr($tax_name); ?>-legacy"> |
|
| 65 | + <?php echo esc_html_x('A-Z', 'Entity Types metabox', 'wordlift'); ?></a> |
|
| 66 | 66 | </li> |
| 67 | 67 | </ul> |
| 68 | 68 | |
| 69 | - <div id="<?php echo esc_attr( $tax_name ); ?>-all" class="tabs-panel"> |
|
| 69 | + <div id="<?php echo esc_attr($tax_name); ?>-all" class="tabs-panel"> |
|
| 70 | 70 | <div id="wl-schema-class-tree"></div> |
| 71 | 71 | </div> |
| 72 | 72 | |
| 73 | - <div id="<?php echo esc_attr( $tax_name ); ?>-pop" class="tabs-panel" style="display: none;"> |
|
| 74 | - <ul id="<?php echo esc_attr( $tax_name ); ?>checklist-pop" class="categorychecklist form-no-clear"> |
|
| 75 | - <?php $popular_ids = wp_popular_terms_checklist( $tax_name ); ?> |
|
| 73 | + <div id="<?php echo esc_attr($tax_name); ?>-pop" class="tabs-panel" style="display: none;"> |
|
| 74 | + <ul id="<?php echo esc_attr($tax_name); ?>checklist-pop" class="categorychecklist form-no-clear"> |
|
| 75 | + <?php $popular_ids = wp_popular_terms_checklist($tax_name); ?> |
|
| 76 | 76 | </ul> |
| 77 | 77 | </div> |
| 78 | 78 | |
| 79 | - <div id="<?php echo esc_attr( $tax_name ); ?>-legacy" class="tabs-panel" style="display: none;"> |
|
| 79 | + <div id="<?php echo esc_attr($tax_name); ?>-legacy" class="tabs-panel" style="display: none;"> |
|
| 80 | 80 | <?php |
| 81 | - $name = ( $tax_name == 'category' ) ? 'post_category' : 'tax_input[' . $tax_name . ']'; |
|
| 81 | + $name = ($tax_name == 'category') ? 'post_category' : 'tax_input['.$tax_name.']'; |
|
| 82 | 82 | echo "<input type='hidden' name='{$name}[]' value='0' />"; // Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks. |
| 83 | 83 | ?> |
| 84 | - <ul id="<?php echo esc_attr( $tax_name ); ?>checklist" |
|
| 85 | - data-wp-lists="list:<?php echo esc_attr( $tax_name ); ?>" |
|
| 84 | + <ul id="<?php echo esc_attr($tax_name); ?>checklist" |
|
| 85 | + data-wp-lists="list:<?php echo esc_attr($tax_name); ?>" |
|
| 86 | 86 | class="categorychecklist form-no-clear"> |
| 87 | 87 | <?php |
| 88 | 88 | wp_terms_checklist( |
@@ -95,35 +95,35 @@ discard block |
||
| 95 | 95 | ?> |
| 96 | 96 | </ul> |
| 97 | 97 | </div> |
| 98 | - <?php if ( current_user_can( $taxonomy->cap->edit_terms ) ) : ?> |
|
| 99 | - <div id="<?php echo esc_attr( $tax_name ); ?>-adder" class="wp-hidden-children"> |
|
| 100 | - <a id="<?php echo esc_attr( $tax_name ); ?>-add-toggle" |
|
| 101 | - href="#<?php echo esc_attr( $tax_name ); ?>-add" |
|
| 98 | + <?php if (current_user_can($taxonomy->cap->edit_terms)) : ?> |
|
| 99 | + <div id="<?php echo esc_attr($tax_name); ?>-adder" class="wp-hidden-children"> |
|
| 100 | + <a id="<?php echo esc_attr($tax_name); ?>-add-toggle" |
|
| 101 | + href="#<?php echo esc_attr($tax_name); ?>-add" |
|
| 102 | 102 | class="taxonomy-add-new"> |
| 103 | 103 | <?php |
| 104 | 104 | /* translators: %s: add new taxonomy label */ |
| 105 | - echo esc_html( sprintf( __( '+ %s' ), $taxonomy->labels->add_new_item ) ); |
|
| 105 | + echo esc_html(sprintf(__('+ %s'), $taxonomy->labels->add_new_item)); |
|
| 106 | 106 | ?> |
| 107 | 107 | </a> |
| 108 | - <p id="<?php echo esc_attr( $tax_name ); ?>-add" class="category-add wp-hidden-child"> |
|
| 108 | + <p id="<?php echo esc_attr($tax_name); ?>-add" class="category-add wp-hidden-child"> |
|
| 109 | 109 | <label class="screen-reader-text" |
| 110 | - for="new<?php echo esc_attr( $tax_name ); ?>"><?php echo esc_html( $taxonomy->labels->add_new_item ); ?></label> |
|
| 110 | + for="new<?php echo esc_attr($tax_name); ?>"><?php echo esc_html($taxonomy->labels->add_new_item); ?></label> |
|
| 111 | 111 | <input type="text" name="new<?php echo esc_html($tax_name); ?>" |
| 112 | - id="new<?php echo esc_attr( $tax_name ); ?>" |
|
| 112 | + id="new<?php echo esc_attr($tax_name); ?>" |
|
| 113 | 113 | class="form-required form-input-tip" |
| 114 | - value="<?php echo esc_attr( $taxonomy->labels->new_item_name ); ?>" |
|
| 114 | + value="<?php echo esc_attr($taxonomy->labels->new_item_name); ?>" |
|
| 115 | 115 | aria-required="true"/> |
| 116 | - <label class="screen-reader-text" for="new<?php echo esc_attr( $tax_name ); ?>_parent"> |
|
| 117 | - <?php echo esc_html( $taxonomy->labels->parent_item_colon ); ?> |
|
| 116 | + <label class="screen-reader-text" for="new<?php echo esc_attr($tax_name); ?>_parent"> |
|
| 117 | + <?php echo esc_html($taxonomy->labels->parent_item_colon); ?> |
|
| 118 | 118 | </label> |
| 119 | 119 | <?php |
| 120 | 120 | $parent_dropdown_args = array( |
| 121 | 121 | 'taxonomy' => $tax_name, |
| 122 | 122 | 'hide_empty' => 0, |
| 123 | - 'name' => 'new' . $tax_name . '_parent', |
|
| 123 | + 'name' => 'new'.$tax_name.'_parent', |
|
| 124 | 124 | 'orderby' => 'name', |
| 125 | 125 | 'hierarchical' => 1, |
| 126 | - 'show_option_none' => '— ' . $taxonomy->labels->parent_item . ' —', |
|
| 126 | + 'show_option_none' => '— '.$taxonomy->labels->parent_item.' —', |
|
| 127 | 127 | ); |
| 128 | 128 | |
| 129 | 129 | /** |
@@ -149,16 +149,16 @@ discard block |
||
| 149 | 149 | * } |
| 150 | 150 | * @since 4.4.0 |
| 151 | 151 | */ |
| 152 | - $parent_dropdown_args = apply_filters( 'post_edit_category_parent_dropdown_args', $parent_dropdown_args ); |
|
| 152 | + $parent_dropdown_args = apply_filters('post_edit_category_parent_dropdown_args', $parent_dropdown_args); |
|
| 153 | 153 | |
| 154 | - wp_dropdown_categories( $parent_dropdown_args ); |
|
| 154 | + wp_dropdown_categories($parent_dropdown_args); |
|
| 155 | 155 | ?> |
| 156 | - <input type="button" id="<?php echo esc_attr( $tax_name ); ?>-add-submit" |
|
| 157 | - data-wp-lists="add:<?php echo esc_html( $tax_name ); ?>checklist:<?php echo esc_attr( $tax_name ); ?>-add" |
|
| 156 | + <input type="button" id="<?php echo esc_attr($tax_name); ?>-add-submit" |
|
| 157 | + data-wp-lists="add:<?php echo esc_html($tax_name); ?>checklist:<?php echo esc_attr($tax_name); ?>-add" |
|
| 158 | 158 | class="button category-add-submit" |
| 159 | - value="<?php echo esc_attr( $taxonomy->labels->add_new_item ); ?>"/> |
|
| 160 | - <?php wp_nonce_field( 'add-' . $tax_name, '_ajax_nonce-add-' . $tax_name, false ); ?> |
|
| 161 | - <span id="<?php echo esc_attr( $tax_name ); ?>-ajax-response"></span> |
|
| 159 | + value="<?php echo esc_attr($taxonomy->labels->add_new_item); ?>"/> |
|
| 160 | + <?php wp_nonce_field('add-'.$tax_name, '_ajax_nonce-add-'.$tax_name, false); ?> |
|
| 161 | + <span id="<?php echo esc_attr($tax_name); ?>-ajax-response"></span> |
|
| 162 | 162 | </p> |
| 163 | 163 | </div> |
| 164 | 164 | <?php endif; ?> |
@@ -1,16 +1,16 @@ |
||
| 1 | 1 | <?php $articles = $this->get_last_wordlift_articles(); ?> |
| 2 | 2 | <div id='news_container'> |
| 3 | - <?php if ( ! empty( $articles['posts_data'] ) ) { ?> |
|
| 4 | - <?php foreach ( $articles['posts_data'] as $key => $item ) { ?> |
|
| 3 | + <?php if ( ! empty($articles['posts_data'])) { ?> |
|
| 4 | + <?php foreach ($articles['posts_data'] as $key => $item) { ?> |
|
| 5 | 5 | <div> |
| 6 | 6 | <a target="_blank" |
| 7 | - href="<?php echo esc_url( $item['post_url'] ); ?>"><?php echo esc_html( $item['post_title'] ); ?></a> |
|
| 8 | - <p><?php echo wp_kses( $item['post_description'], wp_kses_allowed_html('post') ); ?></p> |
|
| 7 | + href="<?php echo esc_url($item['post_url']); ?>"><?php echo esc_html($item['post_title']); ?></a> |
|
| 8 | + <p><?php echo wp_kses($item['post_description'], wp_kses_allowed_html('post')); ?></p> |
|
| 9 | 9 | </div> |
| 10 | 10 | <?php } ?> |
| 11 | 11 | <?php } ?> |
| 12 | 12 | <div> |
| 13 | 13 | <a href="#" id="max_posts_count_3" |
| 14 | - class="wl_more_posts"><?php echo esc_html__( 'More posts', 'wordlift' ); ?></a> |
|
| 14 | + class="wl_more_posts"><?php echo esc_html__('More posts', 'wordlift'); ?></a> |
|
| 15 | 15 | </div> |
| 16 | 16 | </div> |
@@ -119,11 +119,11 @@ discard block |
||
| 119 | 119 | white-space: nowrap; |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - <?php $blu_dot_url = plugin_dir_url( dirname( dirname( __FILE__ ) ) ) . 'images/blu-dot.gif'; ?> |
|
| 122 | + <?php $blu_dot_url = plugin_dir_url(dirname(dirname(__FILE__))).'images/blu-dot.gif'; ?> |
|
| 123 | 123 | #wl-dashboard-v2 .wl-dashboard__block--top-entities .wl-dashboard__block__body > div:nth-child(even) { |
| 124 | 124 | flex: calc(100% - 120px); |
| 125 | 125 | background-color: #ebf6ff; |
| 126 | - background-image: url('<?php echo esc_url( $blu_dot_url ); ?>'), url('<?php echo esc_url( $blu_dot_url ); ?>'), url('<?php echo esc_url( $blu_dot_url ); ?>'); |
|
| 126 | + background-image: url('<?php echo esc_url($blu_dot_url); ?>'), url('<?php echo esc_url($blu_dot_url); ?>'), url('<?php echo esc_url($blu_dot_url); ?>'); |
|
| 127 | 127 | background-position: 25% center, 50%, 75%; |
| 128 | 128 | background-size: 1px 4px; |
| 129 | 129 | background-repeat: repeat-y; |
@@ -220,55 +220,55 @@ discard block |
||
| 220 | 220 | $country_code = $configuration_service->get_country_code(); |
| 221 | 221 | |
| 222 | 222 | $top_entities = $this->get_top_entities(); |
| 223 | -if ( ! empty( $top_entities ) ) { |
|
| 223 | +if ( ! empty($top_entities)) { |
|
| 224 | 224 | ?> |
| 225 | 225 | <div class="wl-dashboard__block wl-dashboard__block--top-entities"> |
| 226 | 226 | <header> |
| 227 | 227 | <span class="dashicons dashicons-editor-help"></span> |
| 228 | - <h3><?php esc_html_e( 'Top entities', 'wordlift' ); ?></h3> |
|
| 229 | - <span class="wl-dashboard__legend wl-dashboard__legend--entities"><?php echo esc_html( _x( 'Links with entities', 'Dashboard', 'wordlift' ) ); ?></span> |
|
| 230 | - <span class="wl-dashboard__legend wl-dashboard__legend--posts"><?php echo esc_html( _x( 'Post with entities', 'Dashboard', 'wordlift' ) ); ?></span> |
|
| 228 | + <h3><?php esc_html_e('Top entities', 'wordlift'); ?></h3> |
|
| 229 | + <span class="wl-dashboard__legend wl-dashboard__legend--entities"><?php echo esc_html(_x('Links with entities', 'Dashboard', 'wordlift')); ?></span> |
|
| 230 | + <span class="wl-dashboard__legend wl-dashboard__legend--posts"><?php echo esc_html(_x('Post with entities', 'Dashboard', 'wordlift')); ?></span> |
|
| 231 | 231 | </header> |
| 232 | 232 | <div class="wl-dashboard__block__body"> |
| 233 | 233 | <?php |
| 234 | 234 | $max = $top_entities[0]->total; |
| 235 | - $unit = intval( '1' . str_repeat( '0', strlen( $max ) - 1 ) ); |
|
| 236 | - $max_value = ceil( (float) $max / $unit ) * $unit; |
|
| 235 | + $unit = intval('1'.str_repeat('0', strlen($max) - 1)); |
|
| 236 | + $max_value = ceil((float) $max / $unit) * $unit; |
|
| 237 | 237 | $chunk_value = $max_value / 4; |
| 238 | 238 | ?> |
| 239 | 239 | <div></div> |
| 240 | 240 | <div class="wl-dashboard__block__body__table-header"> |
| 241 | - <?php for ( $i = 0; $i <= $max_value; $i += $chunk_value ) { ?> |
|
| 242 | - <span><?php echo esc_html( $i ); ?></span><?php } ?> |
|
| 241 | + <?php for ($i = 0; $i <= $max_value; $i += $chunk_value) { ?> |
|
| 242 | + <span><?php echo esc_html($i); ?></span><?php } ?> |
|
| 243 | 243 | </div> |
| 244 | 244 | <?php |
| 245 | 245 | $i = 0; |
| 246 | - foreach ( $this->get_top_entities() as $post ) { |
|
| 247 | - $permalink = get_permalink( $post->ID ); |
|
| 246 | + foreach ($this->get_top_entities() as $post) { |
|
| 247 | + $permalink = get_permalink($post->ID); |
|
| 248 | 248 | $title = $post->post_title; |
| 249 | 249 | $entities_100 = 100 * $post->entities / $max_value; |
| 250 | 250 | $posts_100 = 100 * $post->posts / $max_value; |
| 251 | 251 | |
| 252 | 252 | ?> |
| 253 | - <div><a href="<?php echo esc_attr( $permalink ); ?>"><?php echo esc_html( $title ); ?></a></div> |
|
| 253 | + <div><a href="<?php echo esc_attr($permalink); ?>"><?php echo esc_html($title); ?></a></div> |
|
| 254 | 254 | <div> |
| 255 | 255 | <div class="wl-dashboard__bar wl-dashboard__bar--posts" |
| 256 | - style="width: <?php echo esc_attr( $posts_100 ); ?>%;"> |
|
| 256 | + style="width: <?php echo esc_attr($posts_100); ?>%;"> |
|
| 257 | 257 | </div> |
| 258 | 258 | <div class="wl-dashboard__bar wl-dashboard__bar--entities" |
| 259 | - style="width: <?php echo esc_attr( $entities_100 ); ?>%;"> |
|
| 259 | + style="width: <?php echo esc_attr($entities_100); ?>%;"> |
|
| 260 | 260 | </div> |
| 261 | 261 | </div> |
| 262 | 262 | <?php |
| 263 | - if ( 4 === $i ++ ) { |
|
| 263 | + if (4 === $i++) { |
|
| 264 | 264 | ?> |
| 265 | 265 | <input id="wl-dashboard__show-more" type="checkbox"> |
| 266 | 266 | <label for="wl-dashboard__show-more"> |
| 267 | 267 | <span> |
| 268 | - <?php echo esc_html( __( 'Show more', 'wordlift' ) ); ?> |
|
| 268 | + <?php echo esc_html(__('Show more', 'wordlift')); ?> |
|
| 269 | 269 | </span> |
| 270 | 270 | <span> |
| 271 | - <?php echo esc_html( __( 'Hide', 'wordlift' ) ); ?> |
|
| 271 | + <?php echo esc_html(__('Hide', 'wordlift')); ?> |
|
| 272 | 272 | </span> |
| 273 | 273 | </label> |
| 274 | 274 | <?php |
@@ -280,41 +280,41 @@ discard block |
||
| 280 | 280 | <?php |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | -$not_enriched_url = admin_url( 'edit.php?post_type=post&wl_enriched=no' ); |
|
| 283 | +$not_enriched_url = admin_url('edit.php?post_type=post&wl_enriched=no'); |
|
| 284 | 284 | $dashboard_service = Wordlift_Dashboard_Service::get_instance(); |
| 285 | 285 | ?> |
| 286 | 286 | <div class="wl-dashboard__block wl-dashboard__block--enriched-posts"> |
| 287 | 287 | <header> |
| 288 | 288 | <span class="dashicons dashicons-editor-help"></span> |
| 289 | - <h3><?php echo esc_html__( 'Enriched posts', 'wordlift' ); ?></h3> |
|
| 289 | + <h3><?php echo esc_html__('Enriched posts', 'wordlift'); ?></h3> |
|
| 290 | 290 | </header> |
| 291 | 291 | <div class="wl-dashboard__block__body"> |
| 292 | - <a href="<?php echo esc_url( $not_enriched_url ); ?>"><?php echo esc_html( $dashboard_service->count_annotated_posts() ); ?></a> |
|
| 293 | - / <?php echo esc_html( $dashboard_service->count_posts() ); ?> |
|
| 294 | - <a href="<?php echo esc_url( $not_enriched_url ); ?>"><?php echo esc_html( _x( 'Enrich', 'Dashboard', 'wordlift' ) ); ?></a> |
|
| 292 | + <a href="<?php echo esc_url($not_enriched_url); ?>"><?php echo esc_html($dashboard_service->count_annotated_posts()); ?></a> |
|
| 293 | + / <?php echo esc_html($dashboard_service->count_posts()); ?> |
|
| 294 | + <a href="<?php echo esc_url($not_enriched_url); ?>"><?php echo esc_html(_x('Enrich', 'Dashboard', 'wordlift')); ?></a> |
|
| 295 | 295 | </div> |
| 296 | 296 | </div> |
| 297 | 297 | |
| 298 | -<?php $vocabulary_url = admin_url( 'edit.php?post_type=entity' ); ?> |
|
| 298 | +<?php $vocabulary_url = admin_url('edit.php?post_type=entity'); ?> |
|
| 299 | 299 | <div class="wl-dashboard__block wl-dashboard__block--created-entities"> |
| 300 | 300 | <header> |
| 301 | 301 | <span class="dashicons dashicons-editor-help"></span> |
| 302 | - <h3><?php esc_html_e( 'Created entities', 'wordlift' ); ?></h3> |
|
| 302 | + <h3><?php esc_html_e('Created entities', 'wordlift'); ?></h3> |
|
| 303 | 303 | </header> |
| 304 | 304 | <div class="wl-dashboard__block__body"> |
| 305 | - <a href="<?php echo esc_url( $vocabulary_url ); ?>"><?php echo esc_html( $this->entity_service->count() ); ?></a> |
|
| 306 | - <a href="<?php echo esc_url( $vocabulary_url ); ?>"><?php echo esc_html( _x( 'Vocabulary', 'Dashboard', 'wordlift' ) ); ?></a> |
|
| 305 | + <a href="<?php echo esc_url($vocabulary_url); ?>"><?php echo esc_html($this->entity_service->count()); ?></a> |
|
| 306 | + <a href="<?php echo esc_url($vocabulary_url); ?>"><?php echo esc_html(_x('Vocabulary', 'Dashboard', 'wordlift')); ?></a> |
|
| 307 | 307 | </div> |
| 308 | 308 | </div> |
| 309 | 309 | |
| 310 | 310 | <div class="wl-dashboard__block wl-dashboard__block--average-entity-rating"> |
| 311 | 311 | <header> |
| 312 | 312 | <span class="dashicons dashicons-editor-help"></span> |
| 313 | - <h3><?php echo esc_html__( 'Average entity rating', 'wordlift' ); ?></h3> |
|
| 313 | + <h3><?php echo esc_html__('Average entity rating', 'wordlift'); ?></h3> |
|
| 314 | 314 | </header> |
| 315 | 315 | <div class="wl-dashboard__block__body"> |
| 316 | - <?php echo esc_html( $dashboard_service->average_entities_rating() ); ?> |
|
| 317 | - <?php echo esc_html( _x( 'Boost', 'Dashboard', 'wordlift' ) ); ?> |
|
| 316 | + <?php echo esc_html($dashboard_service->average_entities_rating()); ?> |
|
| 317 | + <?php echo esc_html(_x('Boost', 'Dashboard', 'wordlift')); ?> |
|
| 318 | 318 | </div> |
| 319 | 319 | </div> |
| 320 | 320 | <?php |
@@ -325,4 +325,4 @@ discard block |
||
| 325 | 325 | * @author Naveen Muthusamy <[email protected]> |
| 326 | 326 | * Action name : wl_admin_dashboard_widgets |
| 327 | 327 | */ |
| 328 | -do_action( 'wl_admin_dashboard_widgets' ); |
|
| 328 | +do_action('wl_admin_dashboard_widgets'); |
|
@@ -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( dirname( __FILE__ ) ) . "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( dirname( __FILE__ ) ) . "partials/wordlift-admin-settings-$current_tab-page.php"; ?> |
|
| 47 | + <?php require plugin_dir_path(dirname(__FILE__))."partials/wordlift-admin-settings-$current_tab-page.php"; ?> |
|
| 48 | 48 | |
| 49 | 49 | </div> |
@@ -6,22 +6,22 @@ |
||
| 6 | 6 | |
| 7 | 7 | <p class="page-txt"> |
| 8 | 8 | <?php |
| 9 | - $grab_a_key_link_html = sprintf( |
|
| 10 | - '<a target="_blank" href="%s">%s</a>', |
|
| 11 | - esc_attr__( 'https://wordlift.io/pricing/?utm_campaign=wl_activation_grab_the_key', 'wordlift' ), |
|
| 12 | - esc_html__( 'grab a key', 'wordlift' ) |
|
| 13 | - ); |
|
| 9 | + $grab_a_key_link_html = sprintf( |
|
| 10 | + '<a target="_blank" href="%s">%s</a>', |
|
| 11 | + esc_attr__( 'https://wordlift.io/pricing/?utm_campaign=wl_activation_grab_the_key', 'wordlift' ), |
|
| 12 | + esc_html__( 'grab a key', 'wordlift' ) |
|
| 13 | + ); |
|
| 14 | 14 | |
| 15 | - echo wp_kses( sprintf( |
|
| 16 | - esc_html__( |
|
| 17 | - 'If you already purchased a plan, check your email, get the' |
|
| 18 | - . ' activation key from your inbox and insert it in the' |
|
| 19 | - . ' field below. Otherwise %s!', |
|
| 20 | - 'wordlift' |
|
| 21 | - ), |
|
| 15 | + echo wp_kses( sprintf( |
|
| 16 | + esc_html__( |
|
| 17 | + 'If you already purchased a plan, check your email, get the' |
|
| 18 | + . ' activation key from your inbox and insert it in the' |
|
| 19 | + . ' field below. Otherwise %s!', |
|
| 20 | + 'wordlift' |
|
| 21 | + ), |
|
| 22 | 22 | $grab_a_key_link_html |
| 23 | - ), array( 'a' => array( 'href' => array() ) ) ); |
|
| 24 | - ?> |
|
| 23 | + ), array( 'a' => array( 'href' => array() ) ) ); |
|
| 24 | + ?> |
|
| 25 | 25 | </p> |
| 26 | 26 | <input |
| 27 | 27 | type="text" |
@@ -1,18 +1,18 @@ discard block |
||
| 1 | 1 | <!-- Pane 3 content --> |
| 2 | 2 | <script type="text/html" id="page-2"> |
| 3 | 3 | <h2 class="page-title"> |
| 4 | - <?php esc_html_e( 'License Key', 'wordlift' ); ?> |
|
| 4 | + <?php esc_html_e('License Key', 'wordlift'); ?> |
|
| 5 | 5 | </h2> |
| 6 | 6 | |
| 7 | 7 | <p class="page-txt"> |
| 8 | 8 | <?php |
| 9 | 9 | $grab_a_key_link_html = sprintf( |
| 10 | 10 | '<a target="_blank" href="%s">%s</a>', |
| 11 | - esc_attr__( 'https://wordlift.io/pricing/?utm_campaign=wl_activation_grab_the_key', 'wordlift' ), |
|
| 12 | - esc_html__( 'grab a key', 'wordlift' ) |
|
| 11 | + esc_attr__('https://wordlift.io/pricing/?utm_campaign=wl_activation_grab_the_key', 'wordlift'), |
|
| 12 | + esc_html__('grab a key', 'wordlift') |
|
| 13 | 13 | ); |
| 14 | 14 | |
| 15 | - echo wp_kses( sprintf( |
|
| 15 | + echo wp_kses(sprintf( |
|
| 16 | 16 | esc_html__( |
| 17 | 17 | 'If you already purchased a plan, check your email, get the' |
| 18 | 18 | . ' activation key from your inbox and insert it in the' |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | 'wordlift' |
| 21 | 21 | ), |
| 22 | 22 | $grab_a_key_link_html |
| 23 | - ), array( 'a' => array( 'href' => array() ) ) ); |
|
| 23 | + ), array('a' => array('href' => array()))); |
|
| 24 | 24 | ?> |
| 25 | 25 | </p> |
| 26 | 26 | <input |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | name="key" |
| 32 | 32 | value="" |
| 33 | 33 | autocomplete="off" |
| 34 | - placeholder="<?php echo esc_attr_x( 'License Key', 'Input text placeholder', 'wordlift' ); ?>" |
|
| 34 | + placeholder="<?php echo esc_attr_x('License Key', 'Input text placeholder', 'wordlift'); ?>" |
|
| 35 | 35 | > |
| 36 | 36 | <div> |
| 37 | 37 | <p class="wl-val-key-error"> |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | target="_tab" |
| 45 | 45 | class="button wl-default-action" |
| 46 | 46 | > |
| 47 | - <?php esc_html_e( 'Grab a Key!', 'wordlift' ); ?> |
|
| 47 | + <?php esc_html_e('Grab a Key!', 'wordlift'); ?> |
|
| 48 | 48 | </a> |
| 49 | 49 | |
| 50 | 50 | <input |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | type="button" |
| 53 | 53 | data-wl-next="wl-next" |
| 54 | 54 | class="button" |
| 55 | - value="<?php esc_attr_e( 'Next', 'wordlift' ); ?>" |
|
| 55 | + value="<?php esc_attr_e('Next', 'wordlift'); ?>" |
|
| 56 | 56 | > |
| 57 | 57 | </div> |
| 58 | 58 | </script> |
@@ -7,31 +7,31 @@ discard block |
||
| 7 | 7 | if ( isset( $_POST['wordlift_videoobject_youtube_api_key'] ) |
| 8 | 8 | || isset( $_POST['wordlift_videoobject_vimeo_api_key'] ) ) { |
| 9 | 9 | |
| 10 | - /** |
|
| 11 | - * @todo: does this fields need to be encrypted before saving ? |
|
| 12 | - */ |
|
| 13 | - $youtube_api_key = sanitize_text_field( wp_unslash( (string) $_POST['wordlift_videoobject_youtube_api_key'] ) ); |
|
| 14 | - $vimeo_api_key = sanitize_text_field( wp_unslash( (string) $_POST['wordlift_videoobject_vimeo_api_key'] ) ); |
|
| 10 | + /** |
|
| 11 | + * @todo: does this fields need to be encrypted before saving ? |
|
| 12 | + */ |
|
| 13 | + $youtube_api_key = sanitize_text_field( wp_unslash( (string) $_POST['wordlift_videoobject_youtube_api_key'] ) ); |
|
| 14 | + $vimeo_api_key = sanitize_text_field( wp_unslash( (string) $_POST['wordlift_videoobject_vimeo_api_key'] ) ); |
|
| 15 | 15 | |
| 16 | - if ( $youtube_api_key ) { |
|
| 17 | - update_option( Youtube_Client::get_api_key_option_name(), $youtube_api_key ); |
|
| 18 | - } |
|
| 16 | + if ( $youtube_api_key ) { |
|
| 17 | + update_option( Youtube_Client::get_api_key_option_name(), $youtube_api_key ); |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | - if ( $vimeo_api_key ) { |
|
| 21 | - update_option( Vimeo_Client::get_api_key_option_name(), $vimeo_api_key ); |
|
| 22 | - } |
|
| 20 | + if ( $vimeo_api_key ) { |
|
| 21 | + update_option( Vimeo_Client::get_api_key_option_name(), $vimeo_api_key ); |
|
| 22 | + } |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | if ( isset( $_POST['submit'] ) ) { |
| 26 | - if ( isset( $_POST['wl_enable_video_sitemap'] ) ) { |
|
| 27 | - update_option( '_wl_video_sitemap_generation', 1 ); |
|
| 28 | - // flush the rewrite rules. |
|
| 29 | - flush_rewrite_rules(); |
|
| 30 | - } else { |
|
| 31 | - update_option( '_wl_video_sitemap_generation', 0 ); |
|
| 32 | - // flush the rewrite rules. |
|
| 33 | - flush_rewrite_rules(); |
|
| 34 | - } |
|
| 26 | + if ( isset( $_POST['wl_enable_video_sitemap'] ) ) { |
|
| 27 | + update_option( '_wl_video_sitemap_generation', 1 ); |
|
| 28 | + // flush the rewrite rules. |
|
| 29 | + flush_rewrite_rules(); |
|
| 30 | + } else { |
|
| 31 | + update_option( '_wl_video_sitemap_generation', 0 ); |
|
| 32 | + // flush the rewrite rules. |
|
| 33 | + flush_rewrite_rules(); |
|
| 34 | + } |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | ?> |
@@ -45,15 +45,15 @@ discard block |
||
| 45 | 45 | </td> |
| 46 | 46 | <td> |
| 47 | 47 | <?php |
| 48 | - $element = new Wordlift_Admin_Input_Element(); |
|
| 49 | - $element->render( |
|
| 50 | - array( |
|
| 51 | - 'id' => 'wordlift_videoobject_youtube_api_key', |
|
| 52 | - 'name' => 'wordlift_videoobject_youtube_api_key', |
|
| 53 | - 'value' => Youtube_Client::get_api_key(), |
|
| 54 | - ) |
|
| 55 | - ); |
|
| 56 | - ?> |
|
| 48 | + $element = new Wordlift_Admin_Input_Element(); |
|
| 49 | + $element->render( |
|
| 50 | + array( |
|
| 51 | + 'id' => 'wordlift_videoobject_youtube_api_key', |
|
| 52 | + 'name' => 'wordlift_videoobject_youtube_api_key', |
|
| 53 | + 'value' => Youtube_Client::get_api_key(), |
|
| 54 | + ) |
|
| 55 | + ); |
|
| 56 | + ?> |
|
| 57 | 57 | </td> |
| 58 | 58 | <td> |
| 59 | 59 | <a href="https://developers.google.com/youtube/registering_an_application"><?php esc_html_e( 'Click here', 'wordlift' ); ?></a> |
@@ -67,15 +67,15 @@ discard block |
||
| 67 | 67 | </td> |
| 68 | 68 | <td> |
| 69 | 69 | <?php |
| 70 | - $element = new Wordlift_Admin_Input_Element(); |
|
| 71 | - $element->render( |
|
| 72 | - array( |
|
| 73 | - 'id' => 'wordlift_videoobject_vimeo_api_key', |
|
| 74 | - 'name' => 'wordlift_videoobject_vimeo_api_key', |
|
| 75 | - 'value' => Vimeo_Client::get_api_key(), |
|
| 76 | - ) |
|
| 77 | - ); |
|
| 78 | - ?> |
|
| 70 | + $element = new Wordlift_Admin_Input_Element(); |
|
| 71 | + $element->render( |
|
| 72 | + array( |
|
| 73 | + 'id' => 'wordlift_videoobject_vimeo_api_key', |
|
| 74 | + 'name' => 'wordlift_videoobject_vimeo_api_key', |
|
| 75 | + 'value' => Vimeo_Client::get_api_key(), |
|
| 76 | + ) |
|
| 77 | + ); |
|
| 78 | + ?> |
|
| 79 | 79 | </td> |
| 80 | 80 | <td> |
| 81 | 81 | <a href="https://developer.vimeo.com/api/guides/start"><?php esc_html_e( 'Click here', 'wordlift' ); ?></a> |
@@ -93,11 +93,11 @@ discard block |
||
| 93 | 93 | <input type="checkbox" name="wl_enable_video_sitemap" value="1" <?php echo esc_html( $wl_is_sitemap_enabled ); ?> ></p> |
| 94 | 94 | <p> |
| 95 | 95 | <?php |
| 96 | - if ( $wl_is_sitemap_enabled ) { |
|
| 97 | - $wl_sitemap_link = esc_attr( get_home_url( null, 'wl-video-sitemap.xml' ) ); |
|
| 98 | - echo wp_kses( sprintf( __( 'Here is <a href="%s">link</a> to your Video Sitemap. Add it now, to Google Search Console.', 'wordlift' ), $wl_sitemap_link ), array( 'a' => array( 'href' => array() ) ) ); |
|
| 99 | - } |
|
| 100 | - ?> |
|
| 96 | + if ( $wl_is_sitemap_enabled ) { |
|
| 97 | + $wl_sitemap_link = esc_attr( get_home_url( null, 'wl-video-sitemap.xml' ) ); |
|
| 98 | + echo wp_kses( sprintf( __( 'Here is <a href="%s">link</a> to your Video Sitemap. Add it now, to Google Search Console.', 'wordlift' ), $wl_sitemap_link ), array( 'a' => array( 'href' => array() ) ) ); |
|
| 99 | + } |
|
| 100 | + ?> |
|
| 101 | 101 | </p> |
| 102 | 102 | |
| 103 | 103 | <p class="submit"><input type="submit" name="submit" id="submit" class="button button-primary" |
@@ -4,44 +4,44 @@ discard block |
||
| 4 | 4 | use Wordlift\Videoobject\Provider\Client\Youtube_Client; |
| 5 | 5 | |
| 6 | 6 | |
| 7 | -if ( isset( $_POST['wordlift_videoobject_youtube_api_key'] ) |
|
| 8 | - || isset( $_POST['wordlift_videoobject_vimeo_api_key'] ) ) { |
|
| 7 | +if (isset($_POST['wordlift_videoobject_youtube_api_key']) |
|
| 8 | + || isset($_POST['wordlift_videoobject_vimeo_api_key'])) { |
|
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * @todo: does this fields need to be encrypted before saving ? |
| 12 | 12 | */ |
| 13 | - $youtube_api_key = sanitize_text_field( wp_unslash( (string) $_POST['wordlift_videoobject_youtube_api_key'] ) ); |
|
| 14 | - $vimeo_api_key = sanitize_text_field( wp_unslash( (string) $_POST['wordlift_videoobject_vimeo_api_key'] ) ); |
|
| 13 | + $youtube_api_key = sanitize_text_field(wp_unslash((string) $_POST['wordlift_videoobject_youtube_api_key'])); |
|
| 14 | + $vimeo_api_key = sanitize_text_field(wp_unslash((string) $_POST['wordlift_videoobject_vimeo_api_key'])); |
|
| 15 | 15 | |
| 16 | - if ( $youtube_api_key ) { |
|
| 17 | - update_option( Youtube_Client::get_api_key_option_name(), $youtube_api_key ); |
|
| 16 | + if ($youtube_api_key) { |
|
| 17 | + update_option(Youtube_Client::get_api_key_option_name(), $youtube_api_key); |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | - if ( $vimeo_api_key ) { |
|
| 21 | - update_option( Vimeo_Client::get_api_key_option_name(), $vimeo_api_key ); |
|
| 20 | + if ($vimeo_api_key) { |
|
| 21 | + update_option(Vimeo_Client::get_api_key_option_name(), $vimeo_api_key); |
|
| 22 | 22 | } |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | -if ( isset( $_POST['submit'] ) ) { |
|
| 26 | - if ( isset( $_POST['wl_enable_video_sitemap'] ) ) { |
|
| 27 | - update_option( '_wl_video_sitemap_generation', 1 ); |
|
| 25 | +if (isset($_POST['submit'])) { |
|
| 26 | + if (isset($_POST['wl_enable_video_sitemap'])) { |
|
| 27 | + update_option('_wl_video_sitemap_generation', 1); |
|
| 28 | 28 | // flush the rewrite rules. |
| 29 | 29 | flush_rewrite_rules(); |
| 30 | 30 | } else { |
| 31 | - update_option( '_wl_video_sitemap_generation', 0 ); |
|
| 31 | + update_option('_wl_video_sitemap_generation', 0); |
|
| 32 | 32 | // flush the rewrite rules. |
| 33 | 33 | flush_rewrite_rules(); |
| 34 | 34 | } |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | ?> |
| 38 | -<h1><?php esc_html_e( 'API Settings', 'wordlift' ); ?></h1> |
|
| 39 | -<p><?php esc_html_e( 'To let WordLift access metadata from YouTube or Vimeo you will need to add here your API Key.', 'wordlift' ); ?></p> |
|
| 38 | +<h1><?php esc_html_e('API Settings', 'wordlift'); ?></h1> |
|
| 39 | +<p><?php esc_html_e('To let WordLift access metadata from YouTube or Vimeo you will need to add here your API Key.', 'wordlift'); ?></p> |
|
| 40 | 40 | <form method="post"> |
| 41 | 41 | <table> |
| 42 | 42 | <tr> |
| 43 | 43 | <td> |
| 44 | - <?php esc_html_e( 'YouTube API Key', 'wordlift' ); ?> |
|
| 44 | + <?php esc_html_e('YouTube API Key', 'wordlift'); ?> |
|
| 45 | 45 | </td> |
| 46 | 46 | <td> |
| 47 | 47 | <?php |
@@ -56,14 +56,14 @@ discard block |
||
| 56 | 56 | ?> |
| 57 | 57 | </td> |
| 58 | 58 | <td> |
| 59 | - <a href="https://developers.google.com/youtube/registering_an_application"><?php esc_html_e( 'Click here', 'wordlift' ); ?></a> |
|
| 60 | - <?php esc_html_e( ' for instructions on getting your YouTube API Key', 'wordlift' ); ?> |
|
| 59 | + <a href="https://developers.google.com/youtube/registering_an_application"><?php esc_html_e('Click here', 'wordlift'); ?></a> |
|
| 60 | + <?php esc_html_e(' for instructions on getting your YouTube API Key', 'wordlift'); ?> |
|
| 61 | 61 | </td> |
| 62 | 62 | </tr> |
| 63 | 63 | |
| 64 | 64 | <tr> |
| 65 | 65 | <td> |
| 66 | - <?php esc_html_e( 'Vimeo API Key', 'wordlift' ); ?> |
|
| 66 | + <?php esc_html_e('Vimeo API Key', 'wordlift'); ?> |
|
| 67 | 67 | </td> |
| 68 | 68 | <td> |
| 69 | 69 | <?php |
@@ -78,24 +78,24 @@ discard block |
||
| 78 | 78 | ?> |
| 79 | 79 | </td> |
| 80 | 80 | <td> |
| 81 | - <a href="https://developer.vimeo.com/api/guides/start"><?php esc_html_e( 'Click here', 'wordlift' ); ?></a> |
|
| 82 | - <?php esc_html_e( ' for instructions on getting your Vimeo API Key', 'wordlift' ); ?> |
|
| 81 | + <a href="https://developer.vimeo.com/api/guides/start"><?php esc_html_e('Click here', 'wordlift'); ?></a> |
|
| 82 | + <?php esc_html_e(' for instructions on getting your Vimeo API Key', 'wordlift'); ?> |
|
| 83 | 83 | </td> |
| 84 | 84 | </tr> |
| 85 | 85 | |
| 86 | 86 | </table> |
| 87 | - <h1><?php esc_html_e( 'Video Sitemap', 'wordlift' ); ?></h1> |
|
| 87 | + <h1><?php esc_html_e('Video Sitemap', 'wordlift'); ?></h1> |
|
| 88 | 88 | <p> |
| 89 | - <?php esc_html_e( 'The Video Sitemap works like any other XML Sitemap. Search engines will use it to display rich snippets in result pages.', 'wordlift' ); ?> |
|
| 89 | + <?php esc_html_e('The Video Sitemap works like any other XML Sitemap. Search engines will use it to display rich snippets in result pages.', 'wordlift'); ?> |
|
| 90 | 90 | </p> |
| 91 | - <?php $wl_is_sitemap_enabled = esc_attr( get_option( '_wl_video_sitemap_generation', false ) ? 'checked' : '' ); ?> |
|
| 92 | - <p> <?php esc_html_e( 'Enable Video Sitemap' ); ?> |
|
| 93 | - <input type="checkbox" name="wl_enable_video_sitemap" value="1" <?php echo esc_html( $wl_is_sitemap_enabled ); ?> ></p> |
|
| 91 | + <?php $wl_is_sitemap_enabled = esc_attr(get_option('_wl_video_sitemap_generation', false) ? 'checked' : ''); ?> |
|
| 92 | + <p> <?php esc_html_e('Enable Video Sitemap'); ?> |
|
| 93 | + <input type="checkbox" name="wl_enable_video_sitemap" value="1" <?php echo esc_html($wl_is_sitemap_enabled); ?> ></p> |
|
| 94 | 94 | <p> |
| 95 | 95 | <?php |
| 96 | - if ( $wl_is_sitemap_enabled ) { |
|
| 97 | - $wl_sitemap_link = esc_attr( get_home_url( null, 'wl-video-sitemap.xml' ) ); |
|
| 98 | - echo wp_kses( sprintf( __( 'Here is <a href="%s">link</a> to your Video Sitemap. Add it now, to Google Search Console.', 'wordlift' ), $wl_sitemap_link ), array( 'a' => array( 'href' => array() ) ) ); |
|
| 96 | + if ($wl_is_sitemap_enabled) { |
|
| 97 | + $wl_sitemap_link = esc_attr(get_home_url(null, 'wl-video-sitemap.xml')); |
|
| 98 | + echo wp_kses(sprintf(__('Here is <a href="%s">link</a> to your Video Sitemap. Add it now, to Google Search Console.', 'wordlift'), $wl_sitemap_link), array('a' => array('href' => array()))); |
|
| 99 | 99 | } |
| 100 | 100 | ?> |
| 101 | 101 | </p> |