PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 18.6
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v18.6
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / src / actions / importing / aioseo / aioseo-posts-importing-action.php

aioseo-posts-importing-action.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 18.6, at src/actions/importing/aioseo/aioseo-posts-importing-action.php

626 lines 22.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Given it's a very specific case.
4 namespace Yoast\WP\SEO\Actions\Importing\Aioseo;
5
6 use wpdb;
7 use Yoast\WP\SEO\Actions\Importing\Abstract_Aioseo_Importing_Action;
8 use Yoast\WP\SEO\Helpers\Image_Helper;
9 use Yoast\WP\SEO\Helpers\Import_Cursor_Helper;
10 use Yoast\WP\SEO\Helpers\Indexable_Helper;
11 use Yoast\WP\SEO\Helpers\Indexable_To_Postmeta_Helper;
12 use Yoast\WP\SEO\Helpers\Options_Helper;
13 use Yoast\WP\SEO\Helpers\Sanitization_Helper;
14 use Yoast\WP\SEO\Models\Indexable;
15 use Yoast\WP\SEO\Repositories\Indexable_Repository;
16 use Yoast\WP\SEO\Services\Importing\Aioseo\Aioseo_Replacevar_Service;
17 use Yoast\WP\SEO\Services\Importing\Aioseo\Aioseo_Robots_Provider_Service;
18 use Yoast\WP\SEO\Services\Importing\Aioseo\Aioseo_Robots_Transformer_Service;
19 use Yoast\WP\SEO\Services\Importing\Aioseo\Aioseo_Social_Images_Provider_Service;
20
21 /**
22 * Importing action for AIOSEO post data.
23 *
24 * @phpcs:disable Yoast.NamingConventions.ObjectNameDepth.MaxExceeded
25 */
26 class Aioseo_Posts_Importing_Action extends Abstract_Aioseo_Importing_Action {
27
28 /**
29 * The plugin of the action.
30 */
31 const PLUGIN = 'aioseo';
32
33 /**
34 * The type of the action.
35 */
36 const TYPE = 'posts';
37
38 /**
39 * The map of aioseo to yoast meta.
40 *
41 * @var array
42 */
43 protected $aioseo_to_yoast_map = [
44 'title' => [
45 'yoast_name' => 'title',
46 'transform_method' => 'simple_import_post',
47 ],
48 'description' => [
49 'yoast_name' => 'description',
50 'transform_method' => 'simple_import_post',
51 ],
52 'og_title' => [
53 'yoast_name' => 'open_graph_title',
54 'transform_method' => 'simple_import_post',
55 ],
56 'og_description' => [
57 'yoast_name' => 'open_graph_description',
58 'transform_method' => 'simple_import_post',
59 ],
60 'twitter_title' => [
61 'yoast_name' => 'twitter_title',
62 'transform_method' => 'simple_import_post',
63 'twitter_import' => true,
64 ],
65 'twitter_description' => [
66 'yoast_name' => 'twitter_description',
67 'transform_method' => 'simple_import_post',
68 'twitter_import' => true,
69 ],
70 'canonical_url' => [
71 'yoast_name' => 'canonical',
72 'transform_method' => 'url_import_post',
73 ],
74 'keyphrases' => [
75 'yoast_name' => 'primary_focus_keyword',
76 'transform_method' => 'keyphrase_import',
77 ],
78 'og_image_url' => [
79 'yoast_name' => 'open_graph_image',
80 'social_image_import' => true,
81 'social_setting_prefix_aioseo' => 'og_',
82 'social_setting_prefix_yoast' => 'open_graph_',
83 'transform_method' => 'social_image_url_import',
84 ],
85 'twitter_image_url' => [
86 'yoast_name' => 'twitter_image',
87 'social_image_import' => true,
88 'social_setting_prefix_aioseo' => 'twitter_',
89 'social_setting_prefix_yoast' => 'twitter_',
90 'transform_method' => 'social_image_url_import',
91 ],
92 'robots_noindex' => [
93 'yoast_name' => 'is_robots_noindex',
94 'transform_method' => 'post_robots_noindex_import',
95 'robots_import' => true,
96 ],
97 'robots_nofollow' => [
98 'yoast_name' => 'is_robots_nofollow',
99 'transform_method' => 'post_general_robots_import',
100 'robots_import' => true,
101 'robot_type' => 'nofollow',
102 ],
103 'robots_noarchive' => [
104 'yoast_name' => 'is_robots_noarchive',
105 'transform_method' => 'post_general_robots_import',
106 'robots_import' => true,
107 'robot_type' => 'noarchive',
108 ],
109 'robots_nosnippet' => [
110 'yoast_name' => 'is_robots_nosnippet',
111 'transform_method' => 'post_general_robots_import',
112 'robots_import' => true,
113 'robot_type' => 'nosnippet',
114 ],
115 'robots_noimageindex' => [
116 'yoast_name' => 'is_robots_noimageindex',
117 'transform_method' => 'post_general_robots_import',
118 'robots_import' => true,
119 'robot_type' => 'noimageindex',
120 ],
121 ];
122
123 /**
124 * Represents the indexables repository.
125 *
126 * @var Indexable_Repository
127 */
128 protected $indexable_repository;
129
130 /**
131 * The WordPress database instance.
132 *
133 * @var wpdb
134 */
135 protected $wpdb;
136
137 /**
138 * The image helper.
139 *
140 * @var Image_Helper
141 */
142 protected $image;
143
144 /**
145 * The indexable_to_postmeta helper.
146 *
147 * @var Indexable_To_Postmeta_Helper
148 */
149 protected $indexable_to_postmeta;
150
151 /**
152 * The indexable helper.
153 *
154 * @var Indexable_Helper
155 */
156 protected $indexable_helper;
157
158 /**
159 * The social images provider service.
160 *
161 * @var Aioseo_Social_Images_Provider_Service
162 */
163 protected $social_images_provider;
164
165 /**
166 * Class constructor.
167 *
168 * @param Indexable_Repository $indexable_repository The indexables repository.
169 * @param wpdb $wpdb The WordPress database instance.
170 * @param Import_Cursor_Helper $import_cursor The import cursor helper.
171 * @param Indexable_Helper $indexable_helper The indexable helper.
172 * @param Indexable_To_Postmeta_Helper $indexable_to_postmeta The indexable_to_postmeta helper.
173 * @param Options_Helper $options The options helper.
174 * @param Image_Helper $image The image helper.
175 * @param Sanitization_Helper $sanitization The sanitization helper.
176 * @param Aioseo_Replacevar_Service $replacevar_handler The replacevar handler.
177 * @param Aioseo_Robots_Provider_Service $robots_provider The robots provider service.
178 * @param Aioseo_Robots_Transformer_Service $robots_transformer The robots transfomer service.
179 * @param Aioseo_Social_Images_Provider_Service $social_images_provider The social images provider service.
180 */
181 public function __construct(
182 Indexable_Repository $indexable_repository,
183 wpdb $wpdb,
184 Import_Cursor_Helper $import_cursor,
185 Indexable_Helper $indexable_helper,
186 Indexable_To_Postmeta_Helper $indexable_to_postmeta,
187 Options_Helper $options,
188 Image_Helper $image,
189 Sanitization_Helper $sanitization,
190 Aioseo_Replacevar_Service $replacevar_handler,
191 Aioseo_Robots_Provider_Service $robots_provider,
192 Aioseo_Robots_Transformer_Service $robots_transformer,
193 Aioseo_Social_Images_Provider_Service $social_images_provider ) {
194 parent::__construct( $import_cursor, $options, $sanitization, $replacevar_handler, $robots_provider, $robots_transformer );
195
196 $this->indexable_repository = $indexable_repository;
197 $this->wpdb = $wpdb;
198 $this->image = $image;
199 $this->indexable_helper = $indexable_helper;
200 $this->indexable_to_postmeta = $indexable_to_postmeta;
201 $this->social_images_provider = $social_images_provider;
202 }
203
204 // phpcs:disable WordPress.DB.PreparedSQL.NotPrepared -- Reason: They are already prepared.
205
206 /**
207 * Returns the total number of unimported objects.
208 *
209 * @return int The total number of unimported objects.
210 */
211 public function get_total_unindexed() {
212 if ( ! $this->aioseo_helper->aioseo_exists() ) {
213 return 0;
214 }
215
216 $limit = false;
217 $just_detect = true;
218 $indexables_to_create = $this->wpdb->get_col( $this->query( $limit, $just_detect ) );
219
220 $number_of_indexables_to_create = \count( $indexables_to_create );
221 $completed = $number_of_indexables_to_create === 0;
222 $this->set_completed( $completed );
223
224 return $number_of_indexables_to_create;
225 }
226
227 /**
228 * Returns the limited number of unimported objects.
229 *
230 * @param int $limit The maximum number of unimported objects to be returned.
231 *
232 * @return int|false The limited number of unindexed posts. False if the query fails.
233 */
234 public function get_limited_unindexed_count( $limit ) {
235 if ( ! $this->aioseo_helper->aioseo_exists() ) {
236 return 0;
237 }
238
239 $just_detect = true;
240 $indexables_to_create = $this->wpdb->get_col( $this->query( $limit, $just_detect ) );
241
242 $number_of_indexables_to_create = \count( $indexables_to_create );
243 $completed = $number_of_indexables_to_create === 0;
244 $this->set_completed( $completed );
245
246 return $number_of_indexables_to_create;
247 }
248
249 /**
250 * Imports AIOSEO meta data and creates the respective Yoast indexables and postmeta.
251 *
252 * @return Indexable[]|false An array of created indexables or false if aioseo data was not found.
253 */
254 public function index() {
255 if ( ! $this->aioseo_helper->aioseo_exists() ) {
256 return false;
257 }
258
259 $limit = $this->get_limit();
260 $aioseo_indexables = $this->wpdb->get_results( $this->query( $limit ), \ARRAY_A );
261 $created_indexables = [];
262
263 $completed = \count( $aioseo_indexables ) === 0;
264 $this->set_completed( $completed );
265
266 // Let's build the list of fields to check their defaults, to identify whether we're gonna import AIOSEO data in the indexable or not.
267 $check_defaults_fields = [];
268 foreach ( $this->aioseo_to_yoast_map as $yoast_mapping ) {
269 // We don't want to check all the imported fields.
270 if ( ! \in_array( $yoast_mapping['yoast_name'], [ 'open_graph_image', 'twitter_image' ], true ) ) {
271 $check_defaults_fields[] = $yoast_mapping['yoast_name'];
272 }
273 }
274
275 $last_indexed_aioseo_id = 0;
276 foreach ( $aioseo_indexables as $aioseo_indexable ) {
277 $last_indexed_aioseo_id = $aioseo_indexable['id'];
278
279 $indexable = $this->indexable_repository->find_by_id_and_type( $aioseo_indexable['post_id'], 'post' );
280
281 // Let's ensure that the current post id represents something that we want to index (eg. *not* shop_order).
282 if ( ! \is_a( $indexable, 'Yoast\WP\SEO\Models\Indexable' ) ) {
283 continue;
284 }
285
286 if ( $this->indexable_helper->check_if_default_indexable( $indexable, $check_defaults_fields ) ) {
287 $indexable = $this->map( $indexable, $aioseo_indexable );
288 $indexable->save();
289
290 // To ensure that indexables can be rebuild after a reset, we have to store the data in the postmeta table too.
291 $this->indexable_to_postmeta->map_to_postmeta( $indexable );
292 }
293
294 $last_indexed_aioseo_id = $aioseo_indexable['id'];
295
296 $created_indexables[] = $indexable;
297 }
298
299 $cursor_id = $this->get_cursor_id();
300 $this->import_cursor->set_cursor( $cursor_id, $last_indexed_aioseo_id );
301
302 return $created_indexables;
303 }
304
305 // phpcs:enable WordPress.DB.PreparedSQL.NotPrepared
306
307 /**
308 * Maps AIOSEO meta data to Yoast meta data.
309 *
310 * @param Indexable $indexable The Yoast indexable.
311 * @param array $aioseo_indexable The AIOSEO indexable.
312 *
313 * @return Indexable The created indexables.
314 */
315 public function map( $indexable, $aioseo_indexable ) {
316 foreach ( $this->aioseo_to_yoast_map as $aioseo_key => $yoast_mapping ) {
317 // For robots import.
318 if ( isset( $yoast_mapping['robots_import'] ) && $yoast_mapping['robots_import'] ) {
319 $yoast_mapping['subtype'] = $indexable->object_sub_type;
320 $indexable->{$yoast_mapping['yoast_name']} = $this->transform_import_data( $yoast_mapping['transform_method'], $aioseo_indexable, $aioseo_key, $yoast_mapping, $indexable );
321
322 continue;
323 }
324
325 // For social images, like open graph and twitter image.
326 if ( isset( $yoast_mapping['social_image_import'] ) && $yoast_mapping['social_image_import'] ) {
327 $image_url = $this->transform_import_data( $yoast_mapping['transform_method'], $aioseo_indexable, $aioseo_key, $yoast_mapping, $indexable );
328
329 // Update the indexable's social image only where there's actually a url to import, so as not to lose the social images that we came up with when we originally built the indexable.
330 if ( ! empty( $image_url ) ) {
331 $indexable->{$yoast_mapping['yoast_name']} = $image_url;
332
333 $image_source_key = $yoast_mapping['social_setting_prefix_yoast'] . 'image_source';
334 $indexable->$image_source_key = 'imported';
335
336 $image_id_key = $yoast_mapping['social_setting_prefix_yoast'] . 'image_id';
337 $indexable->$image_id_key = $this->image->get_attachment_by_url( $image_url );
338
339 if ( $yoast_mapping['yoast_name'] === 'open_graph_image' ) {
340 $indexable->open_graph_image_meta = null;
341 }
342 }
343 continue;
344 }
345
346 // For twitter import, take the respective open graph data if the appropriate setting is enabled.
347 if ( isset( $yoast_mapping['twitter_import'] ) && $yoast_mapping['twitter_import'] && $aioseo_indexable['twitter_use_og'] ) {
348 $aioseo_indexable['twitter_title'] = $aioseo_indexable['og_title'];
349 $aioseo_indexable['twitter_description'] = $aioseo_indexable['og_description'];
350 }
351
352 if ( ! empty( $aioseo_indexable[ $aioseo_key ] ) ) {
353 $indexable->{$yoast_mapping['yoast_name']} = $this->transform_import_data( $yoast_mapping['transform_method'], $aioseo_indexable, $aioseo_key, $yoast_mapping, $indexable );
354 }
355 }
356
357 return $indexable;
358 }
359
360 /**
361 * Transforms the data to be imported.
362 *
363 * @param string $transform_method The method that is going to be used for transforming the data.
364 * @param array $aioseo_indexable The data of the AIOSEO indexable data that is being imported.
365 * @param string $aioseo_key The name of the specific set of data that is going to be transformed.
366 * @param array $yoast_mapping Extra details for the import of the specific data that is going to be transformed.
367 * @param Indexable $indexable The Yoast indexable that we are going to import the transformed data into.
368 *
369 * @return string|bool|null The transformed data to be imported.
370 */
371 protected function transform_import_data( $transform_method, $aioseo_indexable, $aioseo_key, $yoast_mapping, $indexable ) {
372 return \call_user_func( [ $this, $transform_method ], $aioseo_indexable, $aioseo_key, $yoast_mapping, $indexable );
373 }
374
375 /**
376 * Returns the number of objects that will be imported in a single importing pass.
377 *
378 * @return int The limit.
379 */
380 public function get_limit() {
381 /**
382 * Filter 'wpseo_aioseo_post_indexation_limit' - Allow filtering the number of posts indexed during each indexing pass.
383 *
384 * @api int The maximum number of posts indexed.
385 */
386 $limit = \apply_filters( 'wpseo_aioseo_post_indexation_limit', 25 );
387
388 if ( ! \is_int( $limit ) || $limit < 1 ) {
389 $limit = 25;
390 }
391
392 return $limit;
393 }
394
395 /**
396 * Populates the needed data array based on which columns we use from the AIOSEO indexable table.
397 *
398 * @return array The needed data array that contains all the needed columns.
399 */
400 public function get_needed_data() {
401 $needed_data = \array_keys( $this->aioseo_to_yoast_map );
402 \array_push( $needed_data, 'id', 'post_id', 'robots_default', 'og_image_custom_url', 'og_image_type', 'twitter_image_custom_url', 'twitter_image_type', 'twitter_use_og' );
403
404 return $needed_data;
405 }
406
407 /**
408 * Populates the needed robot data array to be used in validating against its structure.
409 *
410 * @return array The needed data array that contains all the needed columns.
411 */
412 public function get_needed_robot_data() {
413 $needed_robot_data = [];
414
415 foreach ( $this->aioseo_to_yoast_map as $yoast_mapping ) {
416 if ( isset( $yoast_mapping['robot_type'] ) ) {
417 $needed_robot_data[] = $yoast_mapping['robot_type'];
418 }
419 }
420
421 return $needed_robot_data;
422 }
423
424 /**
425 * Creates a query for gathering AiOSEO data from the database.
426 *
427 * @param int $limit The maximum number of unimported objects to be returned.
428 * @param bool $just_detect Whether we want to just detect if there are unimported objects. If false, we want to actually import them too.
429 *
430 * @return string The query to use for importing or counting the number of items to import.
431 */
432 public function query( $limit = false, $just_detect = false ) {
433 $table = $this->aioseo_helper->get_table();
434
435 $select_statement = 'id';
436 if ( ! $just_detect ) {
437 // If we want to import too, we need the actual needed data from AIOSEO indexables.
438 $needed_data = $this->get_needed_data();
439
440 $select_statement = \implode( ', ', $needed_data );
441 }
442
443 $cursor_id = $this->get_cursor_id();
444 $cursor = $this->import_cursor->get_cursor( $cursor_id );
445
446 /**
447 * Filter 'wpseo_aioseo_post_cursor' - Allow filtering the value of the aioseo post import cursor.
448 *
449 * @api int The value of the aioseo post import cursor.
450 */
451 $cursor = \apply_filters( 'wpseo_aioseo_post_import_cursor', $cursor );
452
453 $replacements = [ $cursor ];
454
455 $limit_statement = '';
456 if ( ! empty( $limit ) ) {
457 $replacements[] = $limit;
458 $limit_statement = ' LIMIT %d';
459 }
460
461 // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Reason: There is no unescaped user input.
462 return $this->wpdb->prepare(
463 "SELECT {$select_statement} FROM {$table} WHERE id > %d ORDER BY id{$limit_statement}",
464 $replacements
465 );
466 // phpcs:enable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
467 }
468
469 /**
470 * Minimally transforms data to be imported.
471 *
472 * @param array $aioseo_data All of the AIOSEO data to be imported.
473 * @param string $aioseo_key The AIOSEO key that contains the setting we're working with.
474 *
475 * @return string The transformed meta data.
476 */
477 public function simple_import_post( $aioseo_data, $aioseo_key ) {
478 return $this->simple_import( $aioseo_data[ $aioseo_key ] );
479 }
480
481 /**
482 * Transforms URL to be imported.
483 *
484 * @param array $aioseo_data All of the AIOSEO data to be imported.
485 * @param string $aioseo_key The AIOSEO key that contains the setting we're working with.
486 *
487 * @return string The transformed URL.
488 */
489 public function url_import_post( $aioseo_data, $aioseo_key ) {
490 return $this->url_import( $aioseo_data[ $aioseo_key ] );
491 }
492
493 /**
494 * Plucks the keyphrase to be imported from the AIOSEO array of keyphrase meta data.
495 *
496 * @param array $aioseo_data All of the AIOSEO data to be imported.
497 * @param string $aioseo_key The AIOSEO key that contains the setting we're working with, aka keyphrases.
498 *
499 * @return string|null The plucked keyphrase.
500 */
501 public function keyphrase_import( $aioseo_data, $aioseo_key ) {
502 $meta_data = \json_decode( $aioseo_data[ $aioseo_key ], true );
503 if ( ! isset( $meta_data['focus']['keyphrase'] ) ) {
504 return null;
505 }
506
507 return $this->sanitization->sanitize_text_field( $meta_data['focus']['keyphrase'] );
508 }
509
510 /**
511 * Imports the post's noindex setting.
512 *
513 * @param bool $aioseo_robots_settings AIOSEO's set of robot settings for the post.
514 *
515 * @return bool|null The value of Yoast's noindex setting for the post.
516 */
517 public function post_robots_noindex_import( $aioseo_robots_settings ) {
518 // If robot settings defer to default settings, we have null in the is_robots_noindex field.
519 if ( $aioseo_robots_settings['robots_default'] ) {
520 return null;
521 }
522
523 return $aioseo_robots_settings['robots_noindex'];
524 }
525
526 /**
527 * Imports the post's robots setting.
528 *
529 * @param bool $aioseo_robots_settings AIOSEO's set of robot settings for the post.
530 * @param string $aioseo_key The AIOSEO key that contains the robot setting we're working with.
531 * @param array $mapping The mapping of the setting we're working with.
532 *
533 * @return bool|null The value of Yoast's noindex setting for the post.
534 */
535 public function post_general_robots_import( $aioseo_robots_settings, $aioseo_key, $mapping ) {
536 $mapping = $this->enhance_mapping( $mapping );
537
538 if ( $aioseo_robots_settings['robots_default'] ) {
539 // Let's first get the subtype's setting value and then transform it taking into consideration whether it defers to global defaults.
540 $subtype_setting = $this->robots_provider->get_subtype_robot_setting( $mapping );
541 return $this->robots_transformer->transform_robot_setting( $mapping['robot_type'], $subtype_setting, $mapping );
542 }
543
544 return $aioseo_robots_settings[ $aioseo_key ];
545 }
546
547 /**
548 * Enhances the mapping of the setting we're working with, with type and the option name, so that we can retrieve the settings for the object we're working with.
549 *
550 * @param array $mapping The mapping of the setting we're working with.
551 *
552 * @return array The enhanced mapping.
553 */
554 public function enhance_mapping( $mapping = [] ) {
555 $mapping['type'] = 'postTypes';
556 $mapping['option_name'] = 'aioseo_options_dynamic';
557
558 return $mapping;
559 }
560
561 /**
562 * Imports the og and twitter image url.
563 *
564 * @param bool $aioseo_social_image_settings AIOSEO's set of social image settings for the post.
565 * @param string $aioseo_key The AIOSEO key that contains the robot setting we're working with.
566 * @param array $mapping The mapping of the setting we're working with.
567 * @param Indexable $indexable The Yoast indexable we're importing into.
568 *
569 * @return bool|null The url of the social image we're importing, null if there's none.
570 */
571 public function social_image_url_import( $aioseo_social_image_settings, $aioseo_key, $mapping, $indexable ) {
572 if ( $mapping['social_setting_prefix_aioseo'] === 'twitter_' && $aioseo_social_image_settings['twitter_use_og'] ) {
573 $mapping['social_setting_prefix_aioseo'] = 'og_';
574 }
575
576 $social_setting = \rtrim( $mapping['social_setting_prefix_aioseo'], '_' );
577
578 $image_type = $aioseo_social_image_settings[ $mapping['social_setting_prefix_aioseo'] . 'image_type' ];
579
580 if ( $image_type === 'default' ) {
581 $image_type = $this->social_images_provider->get_default_social_image_source( $social_setting );
582 }
583
584 switch ( $image_type ) {
585 case 'attach':
586 $image_url = $this->social_images_provider->get_first_attached_image( $indexable->object_id );
587 break;
588 case 'auto':
589 if ( $this->social_images_provider->get_featured_image( $indexable->object_id ) ) {
590 // If there's a featured image, lets not import it, as our indexable calculation has already set that as active social image. That way we achieve dynamicality.
591 return null;
592 }
593 $image_url = $this->social_images_provider->get_auto_image( $indexable->object_id );
594 break;
595 case 'content':
596 $image_url = $this->social_images_provider->get_first_image_in_content( $indexable->object_id );
597 break;
598 case 'custom_image':
599 $image_url = $aioseo_social_image_settings[ $mapping['social_setting_prefix_aioseo'] . 'image_custom_url' ];
600 break;
601 case 'featured':
602 return null; // Our auto-calculation when the indexable was built/updated has taken care of it, so it's not needed to transfer any data now.
603 case 'author':
604 return null;
605 case 'custom':
606 return null;
607 case 'default':
608 $image_url = $this->social_images_provider->get_default_custom_social_image( $social_setting );
609 break;
610 default:
611 $image_url = $aioseo_social_image_settings[ $mapping['social_setting_prefix_aioseo'] . 'image_url' ];
612 break;
613 }
614
615 if ( empty( $image_url ) ) {
616 $image_url = $this->social_images_provider->get_default_custom_social_image( $social_setting );
617 }
618
619 if ( empty( $image_url ) ) {
620 return null;
621 }
622
623 return $this->sanitization->sanitize_url( $image_url, null );
624 }
625 }
626