@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | * |
| 82 | 82 | * @since 1.0.0 |
| 83 | 83 | */ |
| 84 | - public function __construct( $plugin_name, $version, $notice_service, $user_service ) { |
|
| 84 | + public function __construct($plugin_name, $version, $notice_service, $user_service) { |
|
| 85 | 85 | |
| 86 | 86 | $this->plugin_name = $plugin_name; |
| 87 | 87 | $this->version = $version; |
@@ -92,20 +92,20 @@ discard block |
||
| 92 | 92 | $dataset_uri = $configuration_service->get_dataset_uri(); |
| 93 | 93 | $key = $configuration_service->get_key(); |
| 94 | 94 | $features_registry = Features_Registry::get_instance(); |
| 95 | - if ( empty( $dataset_uri ) ) { |
|
| 95 | + if (empty($dataset_uri)) { |
|
| 96 | 96 | $settings_page = Wordlift_Admin_Settings_Page::get_instance(); |
| 97 | - if ( empty( $key ) ) { |
|
| 97 | + if (empty($key)) { |
|
| 98 | 98 | /* translators: %s: The link to the settings page. */ |
| 99 | - $error = sprintf( esc_html__( "WordLift's key isn't set, please open the %s to set WordLift's key.", 'wordlift' ), '<a href="' . $settings_page->get_url() . '">' . esc_html__( 'settings page', 'wordlift' ) . '</a>' ); |
|
| 99 | + $error = sprintf(esc_html__("WordLift's key isn't set, please open the %s to set WordLift's key.", 'wordlift'), '<a href="'.$settings_page->get_url().'">'.esc_html__('settings page', 'wordlift').'</a>'); |
|
| 100 | 100 | } else { |
| 101 | 101 | /* translators: %s: The link to the settings page. */ |
| 102 | - $error = sprintf( esc_html__( "WordLift's dataset URI is not configured: please open the %s to set WordLift's key again.", 'wordlift' ), '<a href="' . $settings_page->get_url() . '">' . esc_html__( 'settings page', 'wordlift' ) . '</a>' ); |
|
| 102 | + $error = sprintf(esc_html__("WordLift's dataset URI is not configured: please open the %s to set WordLift's key again.", 'wordlift'), '<a href="'.$settings_page->get_url().'">'.esc_html__('settings page', 'wordlift').'</a>'); |
|
| 103 | 103 | } |
| 104 | - $notice_service->add_error( $error ); |
|
| 104 | + $notice_service->add_error($error); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | // Load additional code if we're in the admin UI. |
| 108 | - if ( is_admin() ) { |
|
| 108 | + if (is_admin()) { |
|
| 109 | 109 | |
| 110 | 110 | // Require the PHP files for the next code fragment. |
| 111 | 111 | self::require_files(); |
@@ -129,13 +129,13 @@ discard block |
||
| 129 | 129 | * @see https://github.com/insideout10/wordlift-plugin/issues/835 |
| 130 | 130 | */ |
| 131 | 131 | // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
| 132 | - if ( apply_filters( 'wl_feature__enable__all-entity-types', WL_ALL_ENTITY_TYPES ) ) { |
|
| 132 | + if (apply_filters('wl_feature__enable__all-entity-types', WL_ALL_ENTITY_TYPES)) { |
|
| 133 | 133 | |
| 134 | - require_once plugin_dir_path( __DIR__ ) . 'admin/class-wordlift-admin-schemaorg-taxonomy-metabox.php'; |
|
| 134 | + require_once plugin_dir_path(__DIR__).'admin/class-wordlift-admin-schemaorg-taxonomy-metabox.php'; |
|
| 135 | 135 | /* |
| 136 | 136 | * The `Mappings` admin page. |
| 137 | 137 | */ |
| 138 | - require_once plugin_dir_path( __DIR__ ) . 'admin/class-wordlift-admin-mappings-page.php'; |
|
| 138 | + require_once plugin_dir_path(__DIR__).'admin/class-wordlift-admin-mappings-page.php'; |
|
| 139 | 139 | |
| 140 | 140 | new Wordlift_Admin_Mappings_Page(); |
| 141 | 141 | |
@@ -144,9 +144,9 @@ discard block |
||
| 144 | 144 | * |
| 145 | 145 | * @since 3.20.0 |
| 146 | 146 | */ |
| 147 | - require_once plugin_dir_path( __DIR__ ) . 'includes/schemaorg/class-wordlift-schemaorg-sync-batch-operation.php'; |
|
| 147 | + require_once plugin_dir_path(__DIR__).'includes/schemaorg/class-wordlift-schemaorg-sync-batch-operation.php'; |
|
| 148 | 148 | |
| 149 | - $this->sync_batch_operation_ajax_adapter = new Wordlift_Batch_Operation_Ajax_Adapter( new Wordlift_Schemaorg_Sync_Batch_Operation(), 'wl_schemaorg_sync' ); |
|
| 149 | + $this->sync_batch_operation_ajax_adapter = new Wordlift_Batch_Operation_Ajax_Adapter(new Wordlift_Schemaorg_Sync_Batch_Operation(), 'wl_schemaorg_sync'); |
|
| 150 | 150 | |
| 151 | 151 | } |
| 152 | 152 | |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | * |
| 156 | 156 | * @since 3.20.0 |
| 157 | 157 | */ |
| 158 | - require_once plugin_dir_path( __DIR__ ) . 'admin/class-wordlift-admin-term-adapter.php'; |
|
| 158 | + require_once plugin_dir_path(__DIR__).'admin/class-wordlift-admin-term-adapter.php'; |
|
| 159 | 159 | new Wordlift_Admin_Term_Adapter(); |
| 160 | 160 | |
| 161 | 161 | /* |
@@ -181,8 +181,8 @@ discard block |
||
| 181 | 181 | |
| 182 | 182 | $features_registry->register_feature_from_slug( |
| 183 | 183 | 'mappings', |
| 184 | - ( defined( 'WL_ENABLE_MAPPINGS' ) && WL_ENABLE_MAPPINGS ), |
|
| 185 | - array( $this, 'init_mappings' ) |
|
| 184 | + (defined('WL_ENABLE_MAPPINGS') && WL_ENABLE_MAPPINGS), |
|
| 185 | + array($this, 'init_mappings') |
|
| 186 | 186 | ); |
| 187 | 187 | |
| 188 | 188 | // Set the singleton instance. |
@@ -197,9 +197,9 @@ discard block |
||
| 197 | 197 | */ |
| 198 | 198 | private static function require_files() { |
| 199 | 199 | |
| 200 | - require_once plugin_dir_path( __DIR__ ) . 'admin/class-wordlift-dashboard-latest-news.php'; |
|
| 201 | - require_once plugin_dir_path( __DIR__ ) . 'admin/class-wordlift-admin-dashboard-v2.php'; |
|
| 202 | - require_once plugin_dir_path( __DIR__ ) . 'admin/class-wordlift-admin-not-enriched-filter.php'; |
|
| 200 | + require_once plugin_dir_path(__DIR__).'admin/class-wordlift-dashboard-latest-news.php'; |
|
| 201 | + require_once plugin_dir_path(__DIR__).'admin/class-wordlift-admin-dashboard-v2.php'; |
|
| 202 | + require_once plugin_dir_path(__DIR__).'admin/class-wordlift-admin-not-enriched-filter.php'; |
|
| 203 | 203 | |
| 204 | 204 | } |
| 205 | 205 | |
@@ -215,14 +215,14 @@ discard block |
||
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | public static function is_gutenberg() { |
| 218 | - if ( function_exists( 'is_gutenberg_page' ) && |
|
| 218 | + if (function_exists('is_gutenberg_page') && |
|
| 219 | 219 | is_gutenberg_page() |
| 220 | 220 | ) { |
| 221 | 221 | // The Gutenberg plugin is on. |
| 222 | 222 | return true; |
| 223 | 223 | } |
| 224 | 224 | $current_screen = get_current_screen(); |
| 225 | - if ( method_exists( $current_screen, 'is_block_editor' ) && |
|
| 225 | + if (method_exists($current_screen, 'is_block_editor') && |
|
| 226 | 226 | $current_screen->is_block_editor() |
| 227 | 227 | ) { |
| 228 | 228 | // Gutenberg page on 5+. |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | * class. |
| 252 | 252 | */ |
| 253 | 253 | |
| 254 | - wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wordlift-admin.css', array(), $this->version, 'all' ); |
|
| 254 | + wp_enqueue_style($this->plugin_name, plugin_dir_url(__FILE__).'css/wordlift-admin.css', array(), $this->version, 'all'); |
|
| 255 | 255 | |
| 256 | 256 | } |
| 257 | 257 | |
@@ -269,14 +269,14 @@ discard block |
||
| 269 | 269 | * @since 3.20.0 |
| 270 | 270 | */ |
| 271 | 271 | $screen = get_current_screen(); |
| 272 | - if ( is_a( $screen, 'WP_Screen' ) && 'filter-urls_page_filter_urls_form' === $screen->id ) { |
|
| 272 | + if (is_a($screen, 'WP_Screen') && 'filter-urls_page_filter_urls_form' === $screen->id) { |
|
| 273 | 273 | return; |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | // Enqueue the admin scripts. |
| 277 | 277 | wp_enqueue_script( |
| 278 | 278 | $this->plugin_name, |
| 279 | - plugin_dir_url( __FILE__ ) . 'js/1/admin.js', |
|
| 279 | + plugin_dir_url(__FILE__).'js/1/admin.js', |
|
| 280 | 280 | array( |
| 281 | 281 | 'jquery', |
| 282 | 282 | 'underscore', |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | $params = $this->get_params(); |
| 290 | 290 | |
| 291 | 291 | // Finally output the params as `wlSettings` for JavaScript code. |
| 292 | - wp_localize_script( $this->plugin_name, 'wlSettings', apply_filters( 'wl_admin_settings', $params ) ); |
|
| 292 | + wp_localize_script($this->plugin_name, 'wlSettings', apply_filters('wl_admin_settings', $params)); |
|
| 293 | 293 | |
| 294 | 294 | } |
| 295 | 295 | |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | * @return array |
| 300 | 300 | */ |
| 301 | 301 | public function get_params() { |
| 302 | - $can_edit_wordlift_entities = current_user_can( 'edit_wordlift_entities' ); |
|
| 302 | + $can_edit_wordlift_entities = current_user_can('edit_wordlift_entities'); |
|
| 303 | 303 | /* |
| 304 | 304 | * People that can create entities will see the scope set in the wp-config.php file (by default `cloud`). People |
| 305 | 305 | * that cannot edit create entities will always see the local entities. |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | // Set the basic params. |
| 312 | 312 | $params = array( |
| 313 | 313 | // @todo scripts in admin should use wp.post. |
| 314 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
| 314 | + 'ajax_url' => admin_url('admin-ajax.php'), |
|
| 315 | 315 | // @todo remove specific actions from settings. |
| 316 | 316 | 'action' => 'entity_by_title', |
| 317 | 317 | 'datasetUri' => Wordlift_Configuration_Service::get_instance()->get_dataset_uri(), |
@@ -321,20 +321,20 @@ discard block |
||
| 321 | 321 | // |
| 322 | 322 | // @see https://github.com/insideout10/wordlift-plugin/issues/561 |
| 323 | 323 | // @see https://github.com/insideout10/wordlift-plugin/issues/1267 |
| 324 | - 'can_create_entities' => apply_filters( 'wl_feature__enable__dataset', true ) ? ( $can_edit_wordlift_entities ? 'yes' : 'no' ) : 'no', |
|
| 324 | + 'can_create_entities' => apply_filters('wl_feature__enable__dataset', true) ? ($can_edit_wordlift_entities ? 'yes' : 'no') : 'no', |
|
| 325 | 325 | 'l10n' => array( |
| 326 | - 'You already published an entity with the same name' => __( 'You already published an entity with the same name: ', 'wordlift' ), |
|
| 327 | - 'logo_selection_title' => __( 'WordLift Choose Logo', 'wordlift' ), |
|
| 328 | - 'logo_selection_button' => array( 'text' => __( 'Choose Logo', 'wordlift' ) ), |
|
| 329 | - 'Type at least 3 characters to search...' => _x( 'Type at least 3 characters to search...', 'Autocomplete Select', 'wordlift' ), |
|
| 330 | - 'No results found for your search.' => _x( 'No results found: try changing or removing some words.', 'Autocomplete Select', 'wordlift' ), |
|
| 331 | - 'Please wait while we look for entities in the linked data cloud...' => _x( 'Please wait while we look for entities in the linked data cloud...', 'Autocomplete Select', 'wordlift' ), |
|
| 332 | - 'Please wait while we look for ingredients in the linked data cloud...' => _x( 'Please wait while we look for ingredients in the linked data cloud...', 'Autocomplete Select', 'wordlift' ), |
|
| 333 | - 'Add keywords to track' => __( 'Add Keywords to track', 'wordlift' ), |
|
| 326 | + 'You already published an entity with the same name' => __('You already published an entity with the same name: ', 'wordlift'), |
|
| 327 | + 'logo_selection_title' => __('WordLift Choose Logo', 'wordlift'), |
|
| 328 | + 'logo_selection_button' => array('text' => __('Choose Logo', 'wordlift')), |
|
| 329 | + 'Type at least 3 characters to search...' => _x('Type at least 3 characters to search...', 'Autocomplete Select', 'wordlift'), |
|
| 330 | + 'No results found for your search.' => _x('No results found: try changing or removing some words.', 'Autocomplete Select', 'wordlift'), |
|
| 331 | + 'Please wait while we look for entities in the linked data cloud...' => _x('Please wait while we look for entities in the linked data cloud...', 'Autocomplete Select', 'wordlift'), |
|
| 332 | + 'Please wait while we look for ingredients in the linked data cloud...' => _x('Please wait while we look for ingredients in the linked data cloud...', 'Autocomplete Select', 'wordlift'), |
|
| 333 | + 'Add keywords to track' => __('Add Keywords to track', 'wordlift'), |
|
| 334 | 334 | ), |
| 335 | - 'wl_autocomplete_nonce' => wp_create_nonce( 'wl_autocomplete' ), |
|
| 335 | + 'wl_autocomplete_nonce' => wp_create_nonce('wl_autocomplete'), |
|
| 336 | 336 | 'autocomplete_scope' => $autocomplete_scope, |
| 337 | - 'wl_video_api_nonce' => wp_create_nonce( 'wl_video_api_nonce' ), |
|
| 337 | + 'wl_video_api_nonce' => wp_create_nonce('wl_video_api_nonce'), |
|
| 338 | 338 | |
| 339 | 339 | /** |
| 340 | 340 | * Allow 3rd parties to define the default editor id. This turns useful if 3rd parties load |
@@ -348,21 +348,21 @@ discard block |
||
| 348 | 348 | * |
| 349 | 349 | * @since 3.19.4 |
| 350 | 350 | */ |
| 351 | - 'default_editor_id' => apply_filters( 'wl_default_editor_id', 'content' ), |
|
| 351 | + 'default_editor_id' => apply_filters('wl_default_editor_id', 'content'), |
|
| 352 | 352 | |
| 353 | - 'analysis' => array( '_wpnonce' => wp_create_nonce( 'wl_analyze' ) ), |
|
| 353 | + 'analysis' => array('_wpnonce' => wp_create_nonce('wl_analyze')), |
|
| 354 | 354 | /** |
| 355 | 355 | * Faceted search default limit |
| 356 | 356 | * |
| 357 | 357 | * @since 3.26.1 |
| 358 | 358 | */ |
| 359 | - 'faceted_search_default_limit' => apply_filters( 'wl_faceted_search_default_limit', 10 ), |
|
| 359 | + 'faceted_search_default_limit' => apply_filters('wl_faceted_search_default_limit', 10), |
|
| 360 | 360 | /** |
| 361 | 361 | * WL Root path, to access in JS |
| 362 | 362 | * |
| 363 | 363 | * @since 3.27.3 |
| 364 | 364 | */ |
| 365 | - 'wl_root' => plugin_dir_url( __DIR__ ), |
|
| 365 | + 'wl_root' => plugin_dir_url(__DIR__), |
|
| 366 | 366 | /** |
| 367 | 367 | * Enable synonyms, to access in JS |
| 368 | 368 | * Show classification sidebar, to access in JS |
@@ -370,27 +370,27 @@ discard block |
||
| 370 | 370 | * @since 3.30.0 |
| 371 | 371 | */ |
| 372 | 372 | // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
| 373 | - 'can_add_synonyms' => apply_filters( 'wl_feature__enable__add-synonyms', true ), |
|
| 373 | + 'can_add_synonyms' => apply_filters('wl_feature__enable__add-synonyms', true), |
|
| 374 | 374 | // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
| 375 | - 'show_classification_sidebar' => apply_filters( 'wl_feature__enable__classification-sidebar', true ), |
|
| 375 | + 'show_classification_sidebar' => apply_filters('wl_feature__enable__classification-sidebar', true), |
|
| 376 | 376 | // By default the videoobject should not show. |
| 377 | - 'show_videoobject' => apply_filters( 'wl_feature__enable__videoobject', false ), |
|
| 377 | + 'show_videoobject' => apply_filters('wl_feature__enable__videoobject', false), |
|
| 378 | 378 | ); |
| 379 | 379 | |
| 380 | 380 | // Set post-related values if there's a current post. |
| 381 | 381 | $entity_being_edited = get_post(); |
| 382 | 382 | $post = $entity_being_edited; |
| 383 | - if ( null !== $post ) { |
|
| 383 | + if (null !== $post) { |
|
| 384 | 384 | |
| 385 | 385 | $params['post_id'] = $entity_being_edited->ID; |
| 386 | 386 | $entity_service = Wordlift_Entity_Service::get_instance(); |
| 387 | - $params['entityBeingEdited'] = isset( $entity_being_edited->post_type ) && $entity_service->is_entity( $post->ID ) && is_numeric( get_the_ID() ); |
|
| 387 | + $params['entityBeingEdited'] = isset($entity_being_edited->post_type) && $entity_service->is_entity($post->ID) && is_numeric(get_the_ID()); |
|
| 388 | 388 | // We add the `itemId` here to give a chance to the analysis to use it in order to tell WLS to exclude it |
| 389 | 389 | // from the results, since we don't want the current entity to be discovered by the analysis. |
| 390 | 390 | // |
| 391 | 391 | // See https://github.com/insideout10/wordlift-plugin/issues/345 |
| 392 | - $params['itemId'] = $entity_service->get_uri( $entity_being_edited->ID ); |
|
| 393 | - $params['wl_schemaorg_property_nonce'] = wp_create_nonce( 'wl_schemaorg_property' ); |
|
| 392 | + $params['itemId'] = $entity_service->get_uri($entity_being_edited->ID); |
|
| 393 | + $params['wl_schemaorg_property_nonce'] = wp_create_nonce('wl_schemaorg_property'); |
|
| 394 | 394 | |
| 395 | 395 | /* |
| 396 | 396 | * Add the `properties` if `WL_ALL_ENTITY_TYPES` is enabled. |
@@ -398,8 +398,8 @@ discard block |
||
| 398 | 398 | * @see https://github.com/insideout10/wordlift-plugin/issues/835 |
| 399 | 399 | */ |
| 400 | 400 | // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
| 401 | - if ( apply_filters( 'wl_feature__enable__all-entity-types', WL_ALL_ENTITY_TYPES ) ) { |
|
| 402 | - $params['properties'] = Wordlift_Schemaorg_Property_Service::get_instance()->get_all( $post->ID ); |
|
| 401 | + if (apply_filters('wl_feature__enable__all-entity-types', WL_ALL_ENTITY_TYPES)) { |
|
| 402 | + $params['properties'] = Wordlift_Schemaorg_Property_Service::get_instance()->get_all($post->ID); |
|
| 403 | 403 | } |
| 404 | 404 | } |
| 405 | 405 | |
@@ -419,7 +419,7 @@ discard block |
||
| 419 | 419 | */ |
| 420 | 420 | $taxonomy_option = new Taxonomy_Option(); |
| 421 | 421 | $taxonomy_option->add_taxonomy_option(); |
| 422 | - new Edit_Mappings_Page( new Mappings_Transform_Functions_Registry() ); |
|
| 422 | + new Edit_Mappings_Page(new Mappings_Transform_Functions_Registry()); |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | public function __construct() { |
| 24 | 24 | // create ajax request to handle youtube and vimeo api key validation. |
| 25 | - add_action( 'wp_ajax_wl_validate_video_api_key', array( $this, 'validate_video_api_key' ) ); |
|
| 25 | + add_action('wp_ajax_wl_validate_video_api_key', array($this, 'validate_video_api_key')); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | /** |
@@ -32,10 +32,10 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | public function validate_video_api_key() { |
| 34 | 34 | // check nonce. |
| 35 | - check_ajax_referer( 'wl_video_api_nonce' ); |
|
| 35 | + check_ajax_referer('wl_video_api_nonce'); |
|
| 36 | 36 | |
| 37 | 37 | // Check if we have an API key and Type. |
| 38 | - if ( ! isset( $_POST['api_key'] ) || empty( $_POST['api_key'] ) || ! isset( $_POST['type'] ) ) { |
|
| 38 | + if ( ! isset($_POST['api_key']) || empty($_POST['api_key']) || ! isset($_POST['type'])) { |
|
| 39 | 39 | wp_send_json_error( |
| 40 | 40 | array( |
| 41 | 41 | 'valid' => false, |
@@ -43,11 +43,11 @@ discard block |
||
| 43 | 43 | ); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - $api_key = sanitize_text_field( wp_unslash( $_POST['api_key'] ) ); |
|
| 47 | - $type = sanitize_text_field( wp_unslash( $_POST['type'] ) ); |
|
| 46 | + $api_key = sanitize_text_field(wp_unslash($_POST['api_key'])); |
|
| 47 | + $type = sanitize_text_field(wp_unslash($_POST['type'])); |
|
| 48 | 48 | |
| 49 | 49 | // Check if we have a valid type. |
| 50 | - if ( ! in_array( $type, array( 'youtube', 'vimeo' ), true ) ) { |
|
| 50 | + if ( ! in_array($type, array('youtube', 'vimeo'), true)) { |
|
| 51 | 51 | wp_send_json_error( |
| 52 | 52 | array( |
| 53 | 53 | 'valid' => false, |
@@ -55,10 +55,10 @@ discard block |
||
| 55 | 55 | ); |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - if ( 'youtube' === $type ) { |
|
| 59 | - $this->validate_youtube_api_key( $api_key ); |
|
| 58 | + if ('youtube' === $type) { |
|
| 59 | + $this->validate_youtube_api_key($api_key); |
|
| 60 | 60 | } else { |
| 61 | - $this->validate_vimeo_api_key( $api_key ); |
|
| 61 | + $this->validate_vimeo_api_key($api_key); |
|
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * |
| 70 | 70 | * @return void |
| 71 | 71 | */ |
| 72 | - private function validate_youtube_api_key( $api_key ) { |
|
| 72 | + private function validate_youtube_api_key($api_key) { |
|
| 73 | 73 | $url = add_query_arg( |
| 74 | 74 | array( |
| 75 | 75 | 'part' => 'snippet', |
@@ -80,12 +80,12 @@ discard block |
||
| 80 | 80 | 'https://www.googleapis.com/youtube/v3/search' |
| 81 | 81 | ); |
| 82 | 82 | |
| 83 | - $response = wp_remote_get( $url ); |
|
| 83 | + $response = wp_remote_get($url); |
|
| 84 | 84 | |
| 85 | 85 | // Get response code. |
| 86 | - $response_code = wp_remote_retrieve_response_code( $response ); |
|
| 86 | + $response_code = wp_remote_retrieve_response_code($response); |
|
| 87 | 87 | |
| 88 | - if ( 200 === $response_code ) { |
|
| 88 | + if (200 === $response_code) { |
|
| 89 | 89 | wp_send_json_success( |
| 90 | 90 | array( |
| 91 | 91 | 'valid' => true, |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | * |
| 108 | 108 | * @return void |
| 109 | 109 | */ |
| 110 | - private function validate_vimeo_api_key( $api_key ) { |
|
| 110 | + private function validate_vimeo_api_key($api_key) { |
|
| 111 | 111 | $url = add_query_arg( |
| 112 | 112 | array( |
| 113 | 113 | 'query' => 'wordlift', |
@@ -121,15 +121,15 @@ discard block |
||
| 121 | 121 | $url, |
| 122 | 122 | array( |
| 123 | 123 | 'headers' => array( |
| 124 | - 'Authorization' => 'bearer ' . $api_key, |
|
| 124 | + 'Authorization' => 'bearer '.$api_key, |
|
| 125 | 125 | ), |
| 126 | 126 | ) |
| 127 | 127 | ); |
| 128 | 128 | |
| 129 | 129 | // Get response code. |
| 130 | - $response_code = wp_remote_retrieve_response_code( $response ); |
|
| 130 | + $response_code = wp_remote_retrieve_response_code($response); |
|
| 131 | 131 | |
| 132 | - if ( 200 === $response_code ) { |
|
| 132 | + if (200 === $response_code) { |
|
| 133 | 133 | wp_send_json_success( |
| 134 | 134 | array( |
| 135 | 135 | 'valid' => true, |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | * |
| 45 | 45 | * @return $this|Wordlift_Admin_Element |
| 46 | 46 | */ |
| 47 | - public function render( $args ) { |
|
| 47 | + public function render($args) { |
|
| 48 | 48 | |
| 49 | 49 | /* |
| 50 | 50 | * Parse the arguments and merge with default values. |
@@ -54,40 +54,40 @@ discard block |
||
| 54 | 54 | $pre_params = wp_parse_args( |
| 55 | 55 | $args, |
| 56 | 56 | array( |
| 57 | - 'id' => uniqid( 'wl-input-' ), |
|
| 57 | + 'id' => uniqid('wl-input-'), |
|
| 58 | 58 | 'value' => '', |
| 59 | 59 | 'readonly' => false, |
| 60 | 60 | 'css_class' => '', |
| 61 | 61 | 'description' => '', |
| 62 | 62 | ) |
| 63 | 63 | ); |
| 64 | - $params = apply_filters( 'wl_admin_input_element_params', $pre_params ); |
|
| 64 | + $params = apply_filters('wl_admin_input_element_params', $pre_params); |
|
| 65 | 65 | // allow different types of input - default to 'text'. |
| 66 | - $input_type = ! empty( $params['type'] ) ? $params['type'] : 'text'; |
|
| 66 | + $input_type = ! empty($params['type']) ? $params['type'] : 'text'; |
|
| 67 | 67 | ?> |
| 68 | 68 | |
| 69 | - <input type="<?php echo esc_attr( $input_type ); ?>" |
|
| 70 | - id="<?php echo esc_attr( $params['id'] ); ?>" |
|
| 71 | - name="<?php echo esc_attr( $params['name'] ); ?>" |
|
| 72 | - value="<?php echo esc_attr( $params['value'] ); ?>" |
|
| 69 | + <input type="<?php echo esc_attr($input_type); ?>" |
|
| 70 | + id="<?php echo esc_attr($params['id']); ?>" |
|
| 71 | + name="<?php echo esc_attr($params['name']); ?>" |
|
| 72 | + value="<?php echo esc_attr($params['value']); ?>" |
|
| 73 | 73 | <?php |
| 74 | - if ( ! empty( $params['data'] ) && is_array( $params['data'] ) ) { |
|
| 75 | - foreach ( $params['data'] as $key => $value ) { |
|
| 76 | - echo 'data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '" '; |
|
| 74 | + if ( ! empty($params['data']) && is_array($params['data'])) { |
|
| 75 | + foreach ($params['data'] as $key => $value) { |
|
| 76 | + echo 'data-'.esc_attr($key).'="'.esc_attr($value).'" '; |
|
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | - if ( ! empty( $params['readonly'] ) ) { |
|
| 79 | + if ( ! empty($params['readonly'])) { |
|
| 80 | 80 | ?> |
| 81 | 81 | readonly="readonly" <?php } ?> |
| 82 | 82 | <?php |
| 83 | - if ( ! empty( $params['css_class'] ) ) { |
|
| 83 | + if ( ! empty($params['css_class'])) { |
|
| 84 | 84 | ?> |
| 85 | - class="<?php echo esc_attr( $params['css_class'] ); ?>" <?php } ?> |
|
| 85 | + class="<?php echo esc_attr($params['css_class']); ?>" <?php } ?> |
|
| 86 | 86 | /> |
| 87 | 87 | <?php |
| 88 | - if ( ! empty( $params['description'] ) ) { |
|
| 88 | + if ( ! empty($params['description'])) { |
|
| 89 | 89 | ?> |
| 90 | - <p><?php echo wp_kses( $params['description'], array( 'a' => array( 'href' => array() ) ) ); ?></p><?php } ?> |
|
| 90 | + <p><?php echo wp_kses($params['description'], array('a' => array('href' => array()))); ?></p><?php } ?> |
|
| 91 | 91 | |
| 92 | 92 | <?php |
| 93 | 93 | |
@@ -3,43 +3,43 @@ discard block |
||
| 3 | 3 | use Wordlift\Videoobject\Provider\Client\Vimeo_Client; |
| 4 | 4 | use Wordlift\Videoobject\Provider\Client\Youtube_Client; |
| 5 | 5 | |
| 6 | -if ( isset( $_POST['wordlift_videoobject_settings_nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['wordlift_videoobject_settings_nonce'] ) ), 'wordlift_videoobject_settings' ) ) { |
|
| 6 | +if (isset($_POST['wordlift_videoobject_settings_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['wordlift_videoobject_settings_nonce'])), 'wordlift_videoobject_settings')) { |
|
| 7 | 7 | |
| 8 | - if ( isset( $_POST['wordlift_videoobject_youtube_api_key'] ) || isset( $_POST['wordlift_videoobject_vimeo_api_key'] ) ) { |
|
| 8 | + if (isset($_POST['wordlift_videoobject_youtube_api_key']) || 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['wl_enable_video_sitemap'] ) ) { |
|
| 26 | - update_option( '_wl_video_sitemap_generation', 1 ); |
|
| 25 | + if (isset($_POST['wl_enable_video_sitemap'])) { |
|
| 26 | + update_option('_wl_video_sitemap_generation', 1); |
|
| 27 | 27 | // flush the rewrite rules. |
| 28 | 28 | flush_rewrite_rules(); |
| 29 | 29 | } else { |
| 30 | - update_option( '_wl_video_sitemap_generation', 0 ); |
|
| 30 | + update_option('_wl_video_sitemap_generation', 0); |
|
| 31 | 31 | // flush the rewrite rules. |
| 32 | 32 | flush_rewrite_rules(); |
| 33 | 33 | } |
| 34 | 34 | } |
| 35 | 35 | ?> |
| 36 | -<h1><?php esc_html_e( 'API Settings', 'wordlift' ); ?></h1> |
|
| 37 | -<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> |
|
| 36 | +<h1><?php esc_html_e('API Settings', 'wordlift'); ?></h1> |
|
| 37 | +<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 | 38 | <form method="post"> |
| 39 | 39 | <table id="wl-settings-page__video-api"> |
| 40 | 40 | <tr> |
| 41 | 41 | <td> |
| 42 | - <?php esc_html_e( 'YouTube API Key', 'wordlift' ); ?> |
|
| 42 | + <?php esc_html_e('YouTube API Key', 'wordlift'); ?> |
|
| 43 | 43 | </td> |
| 44 | 44 | <td> |
| 45 | 45 | <?php |
@@ -49,20 +49,20 @@ discard block |
||
| 49 | 49 | 'id' => 'wordlift_videoobject_youtube_api_key', |
| 50 | 50 | 'name' => 'wordlift_videoobject_youtube_api_key', |
| 51 | 51 | 'value' => Youtube_Client::get_api_key(), |
| 52 | - 'data' => array( 'type' => 'youtube' ), |
|
| 52 | + 'data' => array('type' => 'youtube'), |
|
| 53 | 53 | ) |
| 54 | 54 | ); |
| 55 | 55 | ?> |
| 56 | 56 | </td> |
| 57 | 57 | <td> |
| 58 | - <a href="https://developers.google.com/youtube/registering_an_application"><?php esc_html_e( 'Click here', 'wordlift' ); ?></a> |
|
| 59 | - <?php esc_html_e( ' for instructions on getting your YouTube API Key', 'wordlift' ); ?> |
|
| 58 | + <a href="https://developers.google.com/youtube/registering_an_application"><?php esc_html_e('Click here', 'wordlift'); ?></a> |
|
| 59 | + <?php esc_html_e(' for instructions on getting your YouTube API Key', 'wordlift'); ?> |
|
| 60 | 60 | </td> |
| 61 | 61 | </tr> |
| 62 | 62 | |
| 63 | 63 | <tr> |
| 64 | 64 | <td> |
| 65 | - <?php esc_html_e( 'Vimeo API Key', 'wordlift' ); ?> |
|
| 65 | + <?php esc_html_e('Vimeo API Key', 'wordlift'); ?> |
|
| 66 | 66 | </td> |
| 67 | 67 | <td> |
| 68 | 68 | <?php |
@@ -72,36 +72,36 @@ discard block |
||
| 72 | 72 | 'id' => 'wordlift_videoobject_vimeo_api_key', |
| 73 | 73 | 'name' => 'wordlift_videoobject_vimeo_api_key', |
| 74 | 74 | 'value' => Vimeo_Client::get_api_key(), |
| 75 | - 'data' => array( 'type' => 'vimeo' ), |
|
| 75 | + 'data' => array('type' => 'vimeo'), |
|
| 76 | 76 | ) |
| 77 | 77 | ); |
| 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', 'wordlift' ); ?> |
|
| 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', 'wordlift'); ?> |
|
| 93 | 93 | <input type="checkbox" name="wl_enable_video_sitemap" |
| 94 | - value="1" <?php echo esc_html( $wl_is_sitemap_enabled ); ?> ></p> |
|
| 94 | + value="1" <?php echo esc_html($wl_is_sitemap_enabled); ?> ></p> |
|
| 95 | 95 | <p> |
| 96 | 96 | <?php |
| 97 | - if ( $wl_is_sitemap_enabled ) { |
|
| 98 | - $wl_sitemap_link = esc_attr( get_home_url( null, 'wl-video-sitemap.xml' ) ); |
|
| 97 | + if ($wl_is_sitemap_enabled) { |
|
| 98 | + $wl_sitemap_link = esc_attr(get_home_url(null, 'wl-video-sitemap.xml')); |
|
| 99 | 99 | /* translators: %s: The link to the Video Sitemap. */ |
| 100 | - 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() ) ) ); |
|
| 100 | + 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()))); |
|
| 101 | 101 | } |
| 102 | 102 | ?> |
| 103 | 103 | </p> |
| 104 | - <?php wp_nonce_field( 'wordlift_videoobject_settings', 'wordlift_videoobject_settings_nonce', false ); ?> |
|
| 104 | + <?php wp_nonce_field('wordlift_videoobject_settings', 'wordlift_videoobject_settings_nonce', false); ?> |
|
| 105 | 105 | <p class="submit"><input type="submit" name="submit" id="submit" class="button button-primary" |
| 106 | 106 | value="Save Changes"> |
| 107 | 107 | </p> |