aiosp_seometa_post_meta_convert

Convert old to new postmeta.

Description

aiosp_seometa_post_meta_convert( (string) $old_platform = '', (string) $new_platform = 'All in One SEO Pack', (bool) $delete_old = false ); 

Cycle through all compatible SEO entries of two platforms and aiosp_seometa_meta_key_convert conversion for each key.

Parameters (3)

0. $old_platform — Optional. (string) => ''
The old platform.
1. $new_platform — Optional. (string) => 'All in One SEO Pack'
The new platform.
2. $delete_old — Optional. (bool) => false
The delete old.

Usage

  1. if ( !function_exists( 'aiosp_seometa_post_meta_convert' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'all-in-one-seo-pack/admin/meta_import.php'; 
  3.  
  4. // The old platform. 
  5. $old_platform = ''; 
  6.  
  7. // The new platform. 
  8. $new_platform = 'All in One SEO Pack'; 
  9.  
  10. // The delete old. 
  11. $delete_old = false; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = aiosp_seometa_post_meta_convert($old_platform, $new_platform, $delete_old); 
  15.  

Defined (1)

The function is defined in the following location(s).

/admin/meta_import.php  
  1. function aiosp_seometa_post_meta_convert( $old_platform = '', $new_platform = 'All in One SEO Pack', $delete_old = false ) { 
  2.  
  3. do_action( 'pre_aiosp_seometa_post_meta_convert', $old_platform, $new_platform, $delete_old ); 
  4.  
  5. global $_aiosp_seometa_platforms; 
  6.  
  7. $output = new stdClass; 
  8.  
  9. if ( empty( $_aiosp_seometa_platforms[ $old_platform ] ) || empty( $_aiosp_seometa_platforms[ $new_platform ] ) ) { 
  10. $output->WP_Error = 1; 
  11.  
  12. return $output; 
  13.  
  14. $output->updated = 0; 
  15. $output->deleted = 0; 
  16. $output->ignored = 0; 
  17.  
  18. foreach ( (array) $_aiosp_seometa_platforms[ $old_platform ] as $label => $meta_key ) { 
  19.  
  20. // Skip iterations where no $new analog exists. 
  21. if ( empty( $_aiosp_seometa_platforms[ $new_platform ][ $label ] ) ) { 
  22. continue; 
  23.  
  24. // Set $old and $new meta_key values. 
  25. $old = $_aiosp_seometa_platforms[ $old_platform ][ $label ]; 
  26. $new = $_aiosp_seometa_platforms[ $new_platform ][ $label ]; 
  27.  
  28. // Convert. 
  29. $result = aiosp_seometa_meta_key_convert( $old, $new, $delete_old ); 
  30.  
  31. // Error check. 
  32. if ( is_wp_error( $result ) ) { 
  33. continue; 
  34.  
  35. // Update total updated/ignored count. 
  36. $output->updated += (int) $result->updated; 
  37. $output->ignored += (int) $result->ignored; 
  38.  
  39.  
  40. do_action( 'aiosp_seometa_post_meta_convert', $output, $old_platform, $new_platform, $delete_old ); 
  41.  
  42. return $output; 
  43.