class-indexable-provider.php 890 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /**
  3. * WPSEO plugin file.
  4. *
  5. * @package WPSEO\Admin\Services
  6. */
  7. /**
  8. * Represents the indexable service.
  9. */
  10. abstract class WPSEO_Indexable_Provider implements WPSEO_Indexable_Service_Provider {
  11. /**
  12. * List of fields that need to be renamed.
  13. *
  14. * @var array
  15. */
  16. protected $renameable_fields = [];
  17. /**
  18. * Renames and converts some of the indexable data to its database variant.
  19. *
  20. * @param array $indexable_data The indexable data to rename and convert.
  21. *
  22. * @return array The renamed and converted indexable data.
  23. */
  24. protected function rename_indexable_data( &$indexable_data ) {
  25. foreach ( $this->renameable_fields as $old_key => $new_key ) {
  26. if ( WPSEO_Validator::key_exists( $indexable_data, $old_key ) ) {
  27. $indexable_data[ $new_key ] = $indexable_data[ $old_key ];
  28. unset( $indexable_data[ $old_key ] );
  29. }
  30. }
  31. return $indexable_data;
  32. }
  33. }