aiosp_seometa_post_meta_analyze

Analyze two platforms to find shared and compatible elements.

Description

aiosp_seometa_post_meta_analyze( (string) $old_platform = '', (string) $new_platform = 'All in One SEO Pack' ); 

See what data can be converted from one to the other.

Parameters (2)

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

Usage

  1. if ( !function_exists( 'aiosp_seometa_post_meta_analyze' ) ) { 
  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. // NOTICE! Understand what this does before running. 
  11. $result = aiosp_seometa_post_meta_analyze($old_platform, $new_platform); 
  12.  

Defined (1)

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

/admin/meta_import.php  
  1. function aiosp_seometa_post_meta_analyze( $old_platform = '', $new_platform = 'All in One SEO Pack' ) { 
  2. // TODO Figure out which elements to ignore. 
  3. do_action( 'pre_aiosp_seometa_post_meta_analyze', $old_platform, $new_platform ); 
  4.  
  5. global $wpdb, $_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->update = 0; 
  15. $output->ignore = 0; 
  16. $output->elements = ''; 
  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. $elements[] = $label; 
  25.  
  26. // See which records to ignore, if any. 
  27. $ignore = 0; 
  28. // $ignore = $wpdb->get_results( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = %s", $meta_key ) ); 
  29.  
  30. // See which records to update, if any. 
  31. $update = $wpdb->get_results( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = %s", $meta_key ) ); 
  32.  
  33. // Count items in returned arrays. 
  34. // $ignore = count( (array)$ignore ); 
  35. $update = count( (array) $update ); 
  36.  
  37. // Calculate update/ignore by comparison. 
  38. // $update = ( (int)$update > (int)$ignore ) ? ( (int)$update - (int)$ignore ) : 0; 
  39.  
  40. // update output numbers 
  41. $output->update += (int) $update; 
  42. $output->ignore += (int) $ignore; 
  43.  
  44.  
  45. $output->elements = $elements; 
  46.  
  47. do_action( 'aiosp_seometa_post_meta_analyze', $output, $old_platform, $new_platform ); 
  48.  
  49. return $output; 
  50.