@@ -32,25 +32,25 @@ discard block |
||
| 32 | 32 | use Wordlift\Post\Post_Adapter; |
| 33 | 33 | |
| 34 | 34 | // If this file is called directly, abort. |
| 35 | -if ( ! defined( 'WPINC' ) ) { |
|
| 35 | +if ( ! defined('WPINC')) { |
|
| 36 | 36 | die; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | -define( 'WORDLIFT_VERSION', '3.40.1' ); |
|
| 39 | +define('WORDLIFT_VERSION', '3.40.1'); |
|
| 40 | 40 | |
| 41 | -require_once __DIR__ . '/modules/common/load.php'; |
|
| 42 | -require_once __DIR__ . '/modules/include-exclude/load.php'; |
|
| 41 | +require_once __DIR__.'/modules/common/load.php'; |
|
| 42 | +require_once __DIR__.'/modules/include-exclude/load.php'; |
|
| 43 | 43 | |
| 44 | 44 | /** |
| 45 | 45 | * Filter to disable WLP on any request, defaults to true. |
| 46 | 46 | * |
| 47 | 47 | * @since 3.33.6 |
| 48 | 48 | */ |
| 49 | -if ( ! apply_filters( 'wl_is_enabled', true ) ) { |
|
| 49 | +if ( ! apply_filters('wl_is_enabled', true)) { |
|
| 50 | 50 | return; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | -require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php'; |
|
| 53 | +require_once plugin_dir_path(__FILE__).'vendor/autoload.php'; |
|
| 54 | 54 | |
| 55 | 55 | /* |
| 56 | 56 | * We introduce the WordLift autoloader, since we start using classes in namespaces, i.e. Wordlift\Http. |
@@ -60,15 +60,15 @@ discard block |
||
| 60 | 60 | wordlift_plugin_autoload_register(); |
| 61 | 61 | |
| 62 | 62 | // Include WordLift constants. |
| 63 | -require_once plugin_dir_path( __FILE__ ) . 'wordlift-constants.php'; |
|
| 63 | +require_once plugin_dir_path(__FILE__).'wordlift-constants.php'; |
|
| 64 | 64 | |
| 65 | 65 | // Load modules. |
| 66 | -require_once plugin_dir_path( __FILE__ ) . 'modules/core/wordlift-core.php'; |
|
| 66 | +require_once plugin_dir_path(__FILE__).'modules/core/wordlift-core.php'; |
|
| 67 | 67 | |
| 68 | -require_once plugin_dir_path( __FILE__ ) . 'deprecations.php'; |
|
| 68 | +require_once plugin_dir_path(__FILE__).'deprecations.php'; |
|
| 69 | 69 | |
| 70 | 70 | // Load early to enable/disable features. |
| 71 | -require_once plugin_dir_path( __FILE__ ) . 'wordlift/features/index.php'; |
|
| 71 | +require_once plugin_dir_path(__FILE__).'wordlift/features/index.php'; |
|
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | 74 | * The code that runs during plugin activation. |
@@ -76,11 +76,11 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | function activate_wordlift() { |
| 78 | 78 | |
| 79 | - $log = Wordlift_Log_Service::get_logger( 'activate_wordlift' ); |
|
| 79 | + $log = Wordlift_Log_Service::get_logger('activate_wordlift'); |
|
| 80 | 80 | |
| 81 | - $log->info( 'Activating WordLift...' ); |
|
| 81 | + $log->info('Activating WordLift...'); |
|
| 82 | 82 | |
| 83 | - require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php'; |
|
| 83 | + require_once plugin_dir_path(__FILE__).'includes/class-wordlift-activator.php'; |
|
| 84 | 84 | Wordlift_Activator::activate(); |
| 85 | 85 | |
| 86 | 86 | /** |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | */ |
| 108 | 108 | function deactivate_wordlift() { |
| 109 | 109 | |
| 110 | - require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php'; |
|
| 110 | + require_once plugin_dir_path(__FILE__).'includes/class-wordlift-deactivator.php'; |
|
| 111 | 111 | Wordlift_Deactivator::deactivate(); |
| 112 | 112 | Wordlift_Http_Api::deactivate(); |
| 113 | 113 | Ttl_Cache_Cleaner::deactivate(); |
@@ -125,14 +125,14 @@ discard block |
||
| 125 | 125 | |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | -register_activation_hook( __FILE__, 'activate_wordlift' ); |
|
| 129 | -register_deactivation_hook( __FILE__, 'deactivate_wordlift' ); |
|
| 128 | +register_activation_hook(__FILE__, 'activate_wordlift'); |
|
| 129 | +register_deactivation_hook(__FILE__, 'deactivate_wordlift'); |
|
| 130 | 130 | |
| 131 | 131 | /** |
| 132 | 132 | * The core plugin class that is used to define internationalization, |
| 133 | 133 | * admin-specific hooks, and public-facing site hooks. |
| 134 | 134 | */ |
| 135 | -require plugin_dir_path( __FILE__ ) . 'includes/class-wordlift.php'; |
|
| 135 | +require plugin_dir_path(__FILE__).'includes/class-wordlift.php'; |
|
| 136 | 136 | |
| 137 | 137 | /** |
| 138 | 138 | * Begins execution of the plugin. |
@@ -152,12 +152,12 @@ discard block |
||
| 152 | 152 | * @return bool |
| 153 | 153 | * @since 3.27.6 |
| 154 | 154 | */ |
| 155 | - if ( apply_filters( 'wl_feature__enable__widgets', true ) ) { |
|
| 156 | - add_action( 'widgets_init', 'wl_register_chord_widget' ); |
|
| 157 | - add_action( 'widgets_init', 'wl_register_geo_widget' ); |
|
| 158 | - add_action( 'widgets_init', 'wl_register_timeline_widget' ); |
|
| 155 | + if (apply_filters('wl_feature__enable__widgets', true)) { |
|
| 156 | + add_action('widgets_init', 'wl_register_chord_widget'); |
|
| 157 | + add_action('widgets_init', 'wl_register_geo_widget'); |
|
| 158 | + add_action('widgets_init', 'wl_register_timeline_widget'); |
|
| 159 | 159 | } |
| 160 | - add_filter( 'widget_text', 'do_shortcode' ); |
|
| 160 | + add_filter('widget_text', 'do_shortcode'); |
|
| 161 | 161 | |
| 162 | 162 | /** |
| 163 | 163 | * Filter: wl_feature__enable__analysis |
@@ -167,10 +167,10 @@ discard block |
||
| 167 | 167 | * @return bool |
| 168 | 168 | * @since 3.27.6 |
| 169 | 169 | */ |
| 170 | - if ( apply_filters( 'wl_feature__enable__analysis', true ) ) { |
|
| 171 | - add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_action' ); |
|
| 170 | + if (apply_filters('wl_feature__enable__analysis', true)) { |
|
| 171 | + add_action('wp_ajax_wl_analyze', 'wl_ajax_analyze_action'); |
|
| 172 | 172 | } else { |
| 173 | - add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_disabled_action' ); |
|
| 173 | + add_action('wp_ajax_wl_analyze', 'wl_ajax_analyze_disabled_action'); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | $plugin = new Wordlift(); |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | |
| 188 | 188 | add_action( |
| 189 | 189 | 'plugins_loaded', |
| 190 | - function () { |
|
| 190 | + function() { |
|
| 191 | 191 | // All features from registry should be initialized here. |
| 192 | 192 | $features_registry = Features_Registry::get_instance(); |
| 193 | 193 | $features_registry->initialize_all_features(); |
@@ -198,27 +198,27 @@ discard block |
||
| 198 | 198 | add_action( |
| 199 | 199 | 'plugins_loaded', |
| 200 | 200 | // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
| 201 | - function () use ( $plugin ) { |
|
| 201 | + function() use ($plugin) { |
|
| 202 | 202 | |
| 203 | 203 | new Wordlift_Products_Navigator_Shortcode_REST(); |
| 204 | 204 | |
| 205 | 205 | // Register the Dataset module, requires `$api_service`. |
| 206 | - require_once plugin_dir_path( __FILE__ ) . 'wordlift/dataset/index.php'; |
|
| 207 | - require_once plugin_dir_path( __FILE__ ) . 'wordlift/shipping-data/index.php'; |
|
| 206 | + require_once plugin_dir_path(__FILE__).'wordlift/dataset/index.php'; |
|
| 207 | + require_once plugin_dir_path(__FILE__).'wordlift/shipping-data/index.php'; |
|
| 208 | 208 | |
| 209 | 209 | /* |
| 210 | 210 | * Require the Entity annotation cleanup module. |
| 211 | 211 | * |
| 212 | 212 | * @since 3.34.6 |
| 213 | 213 | */ |
| 214 | - require_once plugin_dir_path( __FILE__ ) . 'wordlift/cleanup/index.php'; |
|
| 214 | + require_once plugin_dir_path(__FILE__).'wordlift/cleanup/index.php'; |
|
| 215 | 215 | |
| 216 | 216 | /* |
| 217 | 217 | * Import LOD entities. |
| 218 | 218 | * |
| 219 | 219 | * @since 3.35.0 |
| 220 | 220 | */ |
| 221 | - require_once plugin_dir_path( __FILE__ ) . 'wordlift/lod-import/index.php'; |
|
| 221 | + require_once plugin_dir_path(__FILE__).'wordlift/lod-import/index.php'; |
|
| 222 | 222 | |
| 223 | 223 | } |
| 224 | 224 | ); |
@@ -236,23 +236,23 @@ discard block |
||
| 236 | 236 | function wordlift_plugin_autoload_register() { |
| 237 | 237 | |
| 238 | 238 | spl_autoload_register( |
| 239 | - function ( $class_name ) { |
|
| 239 | + function($class_name) { |
|
| 240 | 240 | |
| 241 | 241 | // Bail out if these are not our classes. |
| 242 | - if ( 0 !== strpos( $class_name, 'Wordlift\\' ) ) { |
|
| 242 | + if (0 !== strpos($class_name, 'Wordlift\\')) { |
|
| 243 | 243 | return false; |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | - $class_name_lc = strtolower( str_replace( '_', '-', $class_name ) ); |
|
| 246 | + $class_name_lc = strtolower(str_replace('_', '-', $class_name)); |
|
| 247 | 247 | |
| 248 | - preg_match( '|^(?:(.*)\\\\)?(.+?)$|', $class_name_lc, $matches ); |
|
| 248 | + preg_match('|^(?:(.*)\\\\)?(.+?)$|', $class_name_lc, $matches); |
|
| 249 | 249 | |
| 250 | - $path = str_replace( '\\', DIRECTORY_SEPARATOR, $matches[1] ); |
|
| 251 | - $file = 'class-' . $matches[2] . '.php'; |
|
| 250 | + $path = str_replace('\\', DIRECTORY_SEPARATOR, $matches[1]); |
|
| 251 | + $file = 'class-'.$matches[2].'.php'; |
|
| 252 | 252 | |
| 253 | - $full_path = plugin_dir_path( __FILE__ ) . $path . DIRECTORY_SEPARATOR . $file; |
|
| 253 | + $full_path = plugin_dir_path(__FILE__).$path.DIRECTORY_SEPARATOR.$file; |
|
| 254 | 254 | |
| 255 | - if ( ! file_exists( $full_path ) ) { |
|
| 255 | + if ( ! file_exists($full_path)) { |
|
| 256 | 256 | return false; |
| 257 | 257 | } |
| 258 | 258 | |
@@ -264,13 +264,13 @@ discard block |
||
| 264 | 264 | |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | -function wl_block_categories( $categories ) { |
|
| 267 | +function wl_block_categories($categories) { |
|
| 268 | 268 | return array_merge( |
| 269 | 269 | $categories, |
| 270 | 270 | array( |
| 271 | 271 | array( |
| 272 | 272 | 'slug' => 'wordlift', |
| 273 | - 'title' => __( 'WordLift', 'wordlift' ), |
|
| 273 | + 'title' => __('WordLift', 'wordlift'), |
|
| 274 | 274 | ), |
| 275 | 275 | ) |
| 276 | 276 | ); |
@@ -280,22 +280,22 @@ discard block |
||
| 280 | 280 | * This function is created temporarily to handle the legacy library, |
| 281 | 281 | * this has to be removed when removing the legacy fields from the ui. |
| 282 | 282 | */ |
| 283 | -function wl_enqueue_leaflet( $in_footer = false ) { |
|
| 283 | +function wl_enqueue_leaflet($in_footer = false) { |
|
| 284 | 284 | // Leaflet. |
| 285 | - wp_enqueue_style( 'wl-leaflet', plugin_dir_url( __FILE__ ) . 'js/leaflet/leaflet.css', array(), '1.6.0' ); |
|
| 286 | - wp_enqueue_script( 'wl-leaflet', plugin_dir_url( __FILE__ ) . 'js/leaflet/leaflet.js', array(), '1.6.0', $in_footer ); |
|
| 285 | + wp_enqueue_style('wl-leaflet', plugin_dir_url(__FILE__).'js/leaflet/leaflet.css', array(), '1.6.0'); |
|
| 286 | + wp_enqueue_script('wl-leaflet', plugin_dir_url(__FILE__).'js/leaflet/leaflet.js', array(), '1.6.0', $in_footer); |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | -add_filter( 'block_categories', 'wl_block_categories', 10 ); |
|
| 289 | +add_filter('block_categories', 'wl_block_categories', 10); |
|
| 290 | 290 | |
| 291 | 291 | // Temporary fix for a typo in WooCommerce Extension. |
| 292 | 292 | add_filter( |
| 293 | 293 | 'wl_feature__enable__dataset', |
| 294 | - function ( $value ) { |
|
| 295 | - return apply_filters( 'wl_features__enable__dataset', $value ); |
|
| 294 | + function($value) { |
|
| 295 | + return apply_filters('wl_features__enable__dataset', $value); |
|
| 296 | 296 | } |
| 297 | 297 | ); |
| 298 | 298 | |
| 299 | -require_once __DIR__ . '/modules/food-kg/load.php'; |
|
| 300 | -require_once __DIR__ . '/modules/acf4so/load.php'; |
|
| 301 | -require_once __DIR__ . '/modules/pods/load.php'; |
|
| 299 | +require_once __DIR__.'/modules/food-kg/load.php'; |
|
| 300 | +require_once __DIR__.'/modules/acf4so/load.php'; |
|
| 301 | +require_once __DIR__.'/modules/pods/load.php'; |
|
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | * |
| 73 | 73 | * @since 3.10.0 |
| 74 | 74 | */ |
| 75 | - public function __construct( $entity_type_service, $user_service, $attachment_service, $property_getter ) { |
|
| 75 | + public function __construct($entity_type_service, $user_service, $attachment_service, $property_getter) { |
|
| 76 | 76 | $this->entity_type_service = $entity_type_service; |
| 77 | 77 | $this->user_service = $user_service; |
| 78 | 78 | $this->attachment_service = $attachment_service; |
@@ -91,19 +91,19 @@ discard block |
||
| 91 | 91 | * @since 3.10.0 |
| 92 | 92 | */ |
| 93 | 93 | // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
| 94 | - public function convert( $post_id, &$references = array(), &$references_infos = array() ) { |
|
| 94 | + public function convert($post_id, &$references = array(), &$references_infos = array()) { |
|
| 95 | 95 | |
| 96 | 96 | // Get the post instance. |
| 97 | - $post = get_post( $post_id ); |
|
| 98 | - if ( null === $post ) { |
|
| 97 | + $post = get_post($post_id); |
|
| 98 | + if (null === $post) { |
|
| 99 | 99 | // Post not found. |
| 100 | 100 | return null; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | // Get the post URI @id. |
| 104 | - $id = Wordlift_Entity_Service::get_instance()->get_uri( $post->ID ); |
|
| 105 | - if ( $id === null ) { |
|
| 106 | - $id = 'get_uri returned null, dataset is ' . wl_configuration_get_redlink_dataset_uri(); |
|
| 104 | + $id = Wordlift_Entity_Service::get_instance()->get_uri($post->ID); |
|
| 105 | + if ($id === null) { |
|
| 106 | + $id = 'get_uri returned null, dataset is '.wl_configuration_get_redlink_dataset_uri(); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /* |
@@ -115,8 +115,8 @@ discard block |
||
| 115 | 115 | */ |
| 116 | 116 | // Get the entity @type. We consider `post` BlogPostings. |
| 117 | 117 | // $type = $this->entity_type_service->get( $post_id ); |
| 118 | - $types = $this->entity_type_service->get_names( $post_id ); |
|
| 119 | - $type = self::make_one( $types ); |
|
| 118 | + $types = $this->entity_type_service->get_names($post_id); |
|
| 119 | + $type = self::make_one($types); |
|
| 120 | 120 | |
| 121 | 121 | // Prepare the response. |
| 122 | 122 | $jsonld = array( |
@@ -125,8 +125,8 @@ discard block |
||
| 125 | 125 | '@type' => $type, |
| 126 | 126 | ); |
| 127 | 127 | |
| 128 | - if ( post_type_supports( $post->post_type, 'excerpt' ) ) { |
|
| 129 | - $jsonld['description'] = Wordlift_Post_Excerpt_Helper::get_text_excerpt( $post ); |
|
| 128 | + if (post_type_supports($post->post_type, 'excerpt')) { |
|
| 129 | + $jsonld['description'] = Wordlift_Post_Excerpt_Helper::get_text_excerpt($post); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | // Set the `mainEntityOfPage` property if the post has some contents. |
@@ -136,8 +136,8 @@ discard block |
||
| 136 | 136 | * |
| 137 | 137 | * @since 3.20.0 |
| 138 | 138 | */ |
| 139 | - $post_content = apply_filters( 'wl_post_content', $post->post_content, $post ); |
|
| 140 | - if ( ! empty( $post_content ) ) { |
|
| 139 | + $post_content = apply_filters('wl_post_content', $post->post_content, $post); |
|
| 140 | + if ( ! empty($post_content)) { |
|
| 141 | 141 | // We're setting the `mainEntityOfPage` to signal which one is the |
| 142 | 142 | // main entity for the specified URL. It might be however that the |
| 143 | 143 | // post/page is actually about another specific entity. How WL deals |
@@ -148,28 +148,28 @@ discard block |
||
| 148 | 148 | // No need to specify `'@type' => 'WebPage'. |
| 149 | 149 | // |
| 150 | 150 | // See https://github.com/insideout10/wordlift-plugin/issues/451. |
| 151 | - $jsonld['mainEntityOfPage'] = get_the_permalink( $post->ID ); |
|
| 151 | + $jsonld['mainEntityOfPage'] = get_the_permalink($post->ID); |
|
| 152 | 152 | |
| 153 | 153 | /** |
| 154 | 154 | * @see https://github.com/insideout10/wordlift-plugin/issues/1207 |
| 155 | 155 | * |
| 156 | 156 | * @since 3.27.7 |
| 157 | 157 | */ |
| 158 | - if ( in_array( $type, array( 'Occupation', 'OccupationAggregationByEmployer' ), true ) ) { |
|
| 158 | + if (in_array($type, array('Occupation', 'OccupationAggregationByEmployer'), true)) { |
|
| 159 | 159 | $jsonld['mainEntityOfPage'] = array( |
| 160 | 160 | '@type' => 'WebPage', |
| 161 | - 'lastReviewed' => get_post_time( 'Y-m-d\TH:i:sP', true, $post, false ), |
|
| 161 | + 'lastReviewed' => get_post_time('Y-m-d\TH:i:sP', true, $post, false), |
|
| 162 | 162 | ); |
| 163 | 163 | } |
| 164 | 164 | }; |
| 165 | 165 | |
| 166 | - $this->set_images( $this->attachment_service, $post, $jsonld ); |
|
| 166 | + $this->set_images($this->attachment_service, $post, $jsonld); |
|
| 167 | 167 | |
| 168 | 168 | // Get the entities referenced by this post and set it to the `references` |
| 169 | 169 | // array so that the caller can do further processing, such as printing out |
| 170 | 170 | // more of those references. |
| 171 | 171 | $references_without_locations = Object_Relation_Service::get_instance() |
| 172 | - ->get_references( $post_id, Object_Type_Enum::POST ); |
|
| 172 | + ->get_references($post_id, Object_Type_Enum::POST); |
|
| 173 | 173 | |
| 174 | 174 | /* |
| 175 | 175 | * Add the locations to the references. |
@@ -182,33 +182,33 @@ discard block |
||
| 182 | 182 | $entity_type_service = $this->entity_type_service; |
| 183 | 183 | $locations = array_reduce( |
| 184 | 184 | $references_without_locations, |
| 185 | - function ( $carry, $reference ) use ( $entity_type_service ) { |
|
| 185 | + function($carry, $reference) use ($entity_type_service) { |
|
| 186 | 186 | /** |
| 187 | 187 | * @var $reference Reference |
| 188 | 188 | */ |
| 189 | 189 | // @see https://schema.org/location for the schema.org types using the `location` property. |
| 190 | - if ( ! $entity_type_service->has_entity_type( $reference->get_id(), 'http://schema.org/Action' ) |
|
| 191 | - && ! $entity_type_service->has_entity_type( $reference->get_id(), 'http://schema.org/Event' ) |
|
| 192 | - && ! $entity_type_service->has_entity_type( $reference->get_id(), 'http://schema.org/Organization' ) ) { |
|
| 190 | + if ( ! $entity_type_service->has_entity_type($reference->get_id(), 'http://schema.org/Action') |
|
| 191 | + && ! $entity_type_service->has_entity_type($reference->get_id(), 'http://schema.org/Event') |
|
| 192 | + && ! $entity_type_service->has_entity_type($reference->get_id(), 'http://schema.org/Organization')) { |
|
| 193 | 193 | |
| 194 | 194 | return $carry; |
| 195 | 195 | } |
| 196 | - $post_location_ids = get_post_meta( $reference->get_id(), Wordlift_Schema_Service::FIELD_LOCATION ); |
|
| 196 | + $post_location_ids = get_post_meta($reference->get_id(), Wordlift_Schema_Service::FIELD_LOCATION); |
|
| 197 | 197 | $post_location_references = array_map( |
| 198 | - function ( $post_id ) { |
|
| 199 | - return new Post_Reference( $post_id ); |
|
| 198 | + function($post_id) { |
|
| 199 | + return new Post_Reference($post_id); |
|
| 200 | 200 | }, |
| 201 | 201 | $post_location_ids |
| 202 | 202 | ); |
| 203 | 203 | |
| 204 | - return array_merge( $carry, $post_location_references ); |
|
| 204 | + return array_merge($carry, $post_location_references); |
|
| 205 | 205 | }, |
| 206 | 206 | array() |
| 207 | 207 | ); |
| 208 | 208 | |
| 209 | 209 | // Merge the references with the referenced locations if any. |
| 210 | 210 | // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
| 211 | - $references = array_merge( $references_without_locations, $locations ); |
|
| 211 | + $references = array_merge($references_without_locations, $locations); |
|
| 212 | 212 | |
| 213 | 213 | return $jsonld; |
| 214 | 214 | } |
@@ -222,8 +222,8 @@ discard block |
||
| 222 | 222 | * @return string The property value without the context. |
| 223 | 223 | * @since 3.10.0 |
| 224 | 224 | */ |
| 225 | - public function relative_to_context( $value ) { |
|
| 226 | - return ! is_array( $value ) && 0 === strpos( $value, self::CONTEXT . '/' ) ? substr( $value, strlen( self::CONTEXT ) + 1 ) : $value; |
|
| 225 | + public function relative_to_context($value) { |
|
| 226 | + return ! is_array($value) && 0 === strpos($value, self::CONTEXT.'/') ? substr($value, strlen(self::CONTEXT) + 1) : $value; |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | /** |
@@ -238,14 +238,14 @@ discard block |
||
| 238 | 238 | * |
| 239 | 239 | * @since 3.10.0 |
| 240 | 240 | */ |
| 241 | - public static function set_images( $attachment_service, $post, &$jsonld ) { |
|
| 241 | + public static function set_images($attachment_service, $post, &$jsonld) { |
|
| 242 | 242 | |
| 243 | 243 | // Prepare the attachment ids array. |
| 244 | 244 | $ids = array(); |
| 245 | 245 | |
| 246 | 246 | // Set the thumbnail id as first attachment id, if any. |
| 247 | - $thumbnail_id = get_post_thumbnail_id( $post->ID ); |
|
| 248 | - if ( '' !== $thumbnail_id && 0 !== $thumbnail_id ) { |
|
| 247 | + $thumbnail_id = get_post_thumbnail_id($post->ID); |
|
| 248 | + if ('' !== $thumbnail_id && 0 !== $thumbnail_id) { |
|
| 249 | 249 | $ids[] = $thumbnail_id; |
| 250 | 250 | } |
| 251 | 251 | |
@@ -256,34 +256,34 @@ discard block |
||
| 256 | 256 | // |
| 257 | 257 | // Get the embeds, removing existing ids. |
| 258 | 258 | // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
| 259 | - if ( apply_filters( 'wl_feature__enable__image-embeds', false ) ) { |
|
| 260 | - $embeds = array_diff( $attachment_service->get_image_embeds( $post->post_content ), $ids ); |
|
| 259 | + if (apply_filters('wl_feature__enable__image-embeds', false)) { |
|
| 260 | + $embeds = array_diff($attachment_service->get_image_embeds($post->post_content), $ids); |
|
| 261 | 261 | } else { |
| 262 | 262 | $embeds = array(); |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | // Get the gallery, removing existing ids. |
| 266 | - $gallery = array_diff( $attachment_service->get_gallery( $post ), $ids, $embeds ); |
|
| 266 | + $gallery = array_diff($attachment_service->get_gallery($post), $ids, $embeds); |
|
| 267 | 267 | |
| 268 | 268 | // Map the attachment ids to images' data structured for schema.org use. |
| 269 | 269 | $images_with_sizes = array_filter( |
| 270 | 270 | array_reduce( |
| 271 | - array_merge( $ids, $embeds, $gallery ), |
|
| 272 | - function ( $carry, $item ) { |
|
| 271 | + array_merge($ids, $embeds, $gallery), |
|
| 272 | + function($carry, $item) { |
|
| 273 | 273 | /* |
| 274 | 274 | * @todo: we're not sure that we're getting attachment data here, we |
| 275 | 275 | * should filter `false`s. |
| 276 | 276 | */ |
| 277 | 277 | |
| 278 | 278 | $sources = array_merge( |
| 279 | - Wordlift_Image_Service::get_sources( $item ), |
|
| 280 | - array( wp_get_attachment_image_src( $item, 'full' ) ) |
|
| 279 | + Wordlift_Image_Service::get_sources($item), |
|
| 280 | + array(wp_get_attachment_image_src($item, 'full')) |
|
| 281 | 281 | ); |
| 282 | 282 | |
| 283 | 283 | $sources_with_image = array_filter( |
| 284 | 284 | $sources, |
| 285 | - function ( $source ) { |
|
| 286 | - return ! empty( $source[0] ); |
|
| 285 | + function($source) { |
|
| 286 | + return ! empty($source[0]); |
|
| 287 | 287 | } |
| 288 | 288 | ); |
| 289 | 289 | |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | // or from uploads dir, but the image id still exists as featured image |
| 298 | 298 | // or in [gallery] shortcode. |
| 299 | 299 | // if ( empty( $attachment[0] ) ) { |
| 300 | - if ( empty( $sources_with_image ) ) { |
|
| 300 | + if (empty($sources_with_image)) { |
|
| 301 | 301 | return $carry; |
| 302 | 302 | } |
| 303 | 303 | |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | |
| 316 | 316 | // Refactor data as per schema.org specifications. |
| 317 | 317 | $images = array_map( |
| 318 | - function ( $attachment ) { |
|
| 318 | + function($attachment) { |
|
| 319 | 319 | return Wordlift_Abstract_Post_To_Jsonld_Converter::set_image_size( |
| 320 | 320 | array( |
| 321 | 321 | '@type' => 'ImageObject', |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | ); |
| 329 | 329 | |
| 330 | 330 | // Add images if present. |
| 331 | - if ( 0 < count( $images ) ) { |
|
| 331 | + if (0 < count($images)) { |
|
| 332 | 332 | $jsonld['image'] = $images; |
| 333 | 333 | } |
| 334 | 334 | |
@@ -346,9 +346,9 @@ discard block |
||
| 346 | 346 | * @since 3.8.0 |
| 347 | 347 | * @access private |
| 348 | 348 | */ |
| 349 | - protected static function make_one( $value ) { |
|
| 349 | + protected static function make_one($value) { |
|
| 350 | 350 | |
| 351 | - return 1 === count( $value ) ? $value[0] : $value; |
|
| 351 | + return 1 === count($value) ? $value[0] : $value; |
|
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | /** |
@@ -361,17 +361,17 @@ discard block |
||
| 361 | 361 | * @return array The enriched `ImageObject` array. |
| 362 | 362 | * @since 3.14.0 |
| 363 | 363 | */ |
| 364 | - public static function set_image_size( $image, $attachment ) { |
|
| 364 | + public static function set_image_size($image, $attachment) { |
|
| 365 | 365 | |
| 366 | 366 | // If you specify a "width" or "height" value you should leave out |
| 367 | 367 | // 'px'. For example: "width":"4608px" should be "width":"4608". |
| 368 | 368 | // |
| 369 | 369 | // See https://github.com/insideout10/wordlift-plugin/issues/451. |
| 370 | - if ( isset( $attachment[1] ) && is_numeric( $attachment[1] ) && 0 < $attachment[1] ) { |
|
| 370 | + if (isset($attachment[1]) && is_numeric($attachment[1]) && 0 < $attachment[1]) { |
|
| 371 | 371 | $image['width'] = $attachment[1]; |
| 372 | 372 | } |
| 373 | 373 | |
| 374 | - if ( isset( $attachment[2] ) && is_numeric( $attachment[2] ) && 0 < $attachment[2] ) { |
|
| 374 | + if (isset($attachment[2]) && is_numeric($attachment[2]) && 0 < $attachment[2]) { |
|
| 375 | 375 | $image['height'] = $attachment[2]; |
| 376 | 376 | } |
| 377 | 377 | |
@@ -390,33 +390,33 @@ discard block |
||
| 390 | 390 | * @since 3.20.0 This code moved from the above function `convert`, used for entity types defined in |
| 391 | 391 | * the {@link Wordlift_Schema_Service} class. |
| 392 | 392 | */ |
| 393 | - protected function process_type_custom_fields( &$jsonld, $fields, $post, &$references, &$references_infos ) { |
|
| 393 | + protected function process_type_custom_fields(&$jsonld, $fields, $post, &$references, &$references_infos) { |
|
| 394 | 394 | |
| 395 | 395 | // Set a reference to use in closures. |
| 396 | 396 | $converter = $this; |
| 397 | 397 | |
| 398 | 398 | // Try each field on the entity. |
| 399 | - foreach ( $fields as $key => $value ) { |
|
| 399 | + foreach ($fields as $key => $value) { |
|
| 400 | 400 | |
| 401 | 401 | // Get the predicate. |
| 402 | - $name = $this->relative_to_context( $value['predicate'] ); |
|
| 402 | + $name = $this->relative_to_context($value['predicate']); |
|
| 403 | 403 | |
| 404 | 404 | // Get the value, the property service will get the right extractor |
| 405 | 405 | // for that property. |
| 406 | - $value = $this->property_getter->get( $post->ID, $key, Object_Type_Enum::POST ); |
|
| 406 | + $value = $this->property_getter->get($post->ID, $key, Object_Type_Enum::POST); |
|
| 407 | 407 | |
| 408 | - if ( empty( $value ) ) { |
|
| 408 | + if (empty($value)) { |
|
| 409 | 409 | continue; |
| 410 | 410 | } |
| 411 | 411 | |
| 412 | 412 | // Map the value to the property name. |
| 413 | 413 | // If we got an array with just one value, we return that one value. |
| 414 | 414 | // If we got a Wordlift_Property_Entity_Reference we get the URL. |
| 415 | - $jsonld[ $name ] = self::make_one( |
|
| 415 | + $jsonld[$name] = self::make_one( |
|
| 416 | 416 | array_map( |
| 417 | - function ( $item ) use ( $converter, &$references, &$references_infos ) { |
|
| 417 | + function($item) use ($converter, &$references, &$references_infos) { |
|
| 418 | 418 | |
| 419 | - if ( $item instanceof Wordlift_Property_Entity_Reference ) { |
|
| 419 | + if ($item instanceof Wordlift_Property_Entity_Reference) { |
|
| 420 | 420 | |
| 421 | 421 | $url = $item->get_url(); |
| 422 | 422 | |
@@ -425,12 +425,12 @@ discard block |
||
| 425 | 425 | $references[] = $item->to_reference(); |
| 426 | 426 | |
| 427 | 427 | // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable |
| 428 | - $references_infos[] = array( 'reference' => $item ); |
|
| 428 | + $references_infos[] = array('reference' => $item); |
|
| 429 | 429 | |
| 430 | - return array( '@id' => $url ); |
|
| 430 | + return array('@id' => $url); |
|
| 431 | 431 | } |
| 432 | 432 | |
| 433 | - return $converter->relative_to_context( $item ); |
|
| 433 | + return $converter->relative_to_context($item); |
|
| 434 | 434 | }, |
| 435 | 435 | $value |
| 436 | 436 | ) |
@@ -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 |
@@ -54,14 +54,14 @@ discard block |
||
| 54 | 54 | ?> |
| 55 | 55 | </td> |
| 56 | 56 | <td> |
| 57 | - <a href="https://developers.google.com/youtube/registering_an_application"><?php esc_html_e( 'Click here', 'wordlift' ); ?></a> |
|
| 58 | - <?php esc_html_e( ' for instructions on getting your YouTube API Key', 'wordlift' ); ?> |
|
| 57 | + <a href="https://developers.google.com/youtube/registering_an_application"><?php esc_html_e('Click here', 'wordlift'); ?></a> |
|
| 58 | + <?php esc_html_e(' for instructions on getting your YouTube API Key', 'wordlift'); ?> |
|
| 59 | 59 | </td> |
| 60 | 60 | </tr> |
| 61 | 61 | |
| 62 | 62 | <tr> |
| 63 | 63 | <td> |
| 64 | - <?php esc_html_e( 'Vimeo API Key', 'wordlift' ); ?> |
|
| 64 | + <?php esc_html_e('Vimeo API Key', 'wordlift'); ?> |
|
| 65 | 65 | </td> |
| 66 | 66 | <td> |
| 67 | 67 | <?php |
@@ -76,30 +76,30 @@ discard block |
||
| 76 | 76 | ?> |
| 77 | 77 | </td> |
| 78 | 78 | <td> |
| 79 | - <a href="https://developer.vimeo.com/api/guides/start"><?php esc_html_e( 'Click here', 'wordlift' ); ?></a> |
|
| 80 | - <?php esc_html_e( ' for instructions on getting your Vimeo API Key', 'wordlift' ); ?> |
|
| 79 | + <a href="https://developer.vimeo.com/api/guides/start"><?php esc_html_e('Click here', 'wordlift'); ?></a> |
|
| 80 | + <?php esc_html_e(' for instructions on getting your Vimeo API Key', 'wordlift'); ?> |
|
| 81 | 81 | </td> |
| 82 | 82 | </tr> |
| 83 | 83 | |
| 84 | 84 | </table> |
| 85 | - <h1><?php esc_html_e( 'Video Sitemap', 'wordlift' ); ?></h1> |
|
| 85 | + <h1><?php esc_html_e('Video Sitemap', 'wordlift'); ?></h1> |
|
| 86 | 86 | <p> |
| 87 | - <?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' ); ?> |
|
| 87 | + <?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'); ?> |
|
| 88 | 88 | </p> |
| 89 | - <?php $wl_is_sitemap_enabled = esc_attr( get_option( '_wl_video_sitemap_generation', false ) ? 'checked' : '' ); ?> |
|
| 90 | - <p> <?php esc_html_e( 'Enable Video Sitemap', 'wordlift' ); ?> |
|
| 89 | + <?php $wl_is_sitemap_enabled = esc_attr(get_option('_wl_video_sitemap_generation', false) ? 'checked' : ''); ?> |
|
| 90 | + <p> <?php esc_html_e('Enable Video Sitemap', 'wordlift'); ?> |
|
| 91 | 91 | <input type="checkbox" name="wl_enable_video_sitemap" |
| 92 | - value="1" <?php echo esc_html( $wl_is_sitemap_enabled ); ?> ></p> |
|
| 92 | + value="1" <?php echo esc_html($wl_is_sitemap_enabled); ?> ></p> |
|
| 93 | 93 | <p> |
| 94 | 94 | <?php |
| 95 | - if ( $wl_is_sitemap_enabled ) { |
|
| 96 | - $wl_sitemap_link = esc_attr( get_home_url( null, 'wl-video-sitemap.xml' ) ); |
|
| 95 | + if ($wl_is_sitemap_enabled) { |
|
| 96 | + $wl_sitemap_link = esc_attr(get_home_url(null, 'wl-video-sitemap.xml')); |
|
| 97 | 97 | /* translators: %s: The link to the Video Sitemap. */ |
| 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() ) ) ); |
|
| 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> |
| 102 | - <?php wp_nonce_field( 'wordlift_videoobject_settings', 'wordlift_videoobject_settings_nonce', false ); ?> |
|
| 102 | + <?php wp_nonce_field('wordlift_videoobject_settings', 'wordlift_videoobject_settings_nonce', false); ?> |
|
| 103 | 103 | <p class="submit"><input type="submit" name="submit" id="submit" class="button button-primary" |
| 104 | 104 | value="Save Changes"> |
| 105 | 105 | </p> |
@@ -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-type'] ) ) { |
|
| 74 | + if ( ! empty($params['data-type'])) { |
|
| 75 | 75 | ?> |
| 76 | - data-type="<?php echo esc_attr( $params['data-type'] ); ?>" |
|
| 76 | + data-type="<?php echo esc_attr($params['data-type']); ?>" |
|
| 77 | 77 | <?php } ?> |
| 78 | 78 | <?php |
| 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 | |
@@ -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, |