aioseop_ajax_save_meta

The All In One SEO Pack aioseop ajax save meta function.

Description

aioseop_ajax_save_meta(); 

Usage

  1. if ( !function_exists( 'aioseop_ajax_save_meta' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'all-in-one-seo-pack/inc/aioseop_functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = aioseop_ajax_save_meta(); 
  7.  

Defined (1)

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

/inc/aioseop_functions.php  
  1. function aioseop_ajax_save_meta() { 
  2. if ( ! empty( $_POST['_inline_edit'] ) && ( $_POST['_inline_edit'] !== 'undefined' ) ) { 
  3. check_ajax_referer( 'inlineeditnonce', '_inline_edit' ); 
  4. $post_id = intval( $_POST['post_id'] ); 
  5. $new_meta = strip_tags( $_POST['new_meta'] ); 
  6. $target = $_POST['target_meta']; 
  7. check_ajax_referer( 'aioseop_meta_' . $target . '_' . $post_id, '_nonce' ); 
  8. $result = ''; 
  9. if ( in_array( $target, Array( 
  10. 'title',  
  11. 'description',  
  12. 'keywords',  
  13. ) ) && current_user_can( 'edit_post', $post_id ) 
  14. ) { 
  15. update_post_meta( $post_id, '_aioseop_' . $target, esc_attr( $new_meta ) ); 
  16. $result = get_post_meta( $post_id, '_aioseop_' . $target, true ); 
  17. } else { 
  18. die(); 
  19. if ( $result != '' ): 
  20. $label = "<label id='aioseop_label_{$target}_{$post_id}'><span style='width: 20px;display: inline-block;'></span>" . $result . '</label>'; 
  21. else: 
  22. $label = "<label id='aioseop_label_{$target}_{$post_id}'></label><span style='width: 20px;display: inline-block;'></span><strong><i>" . __( 'No', 'all-in-one-seo-pack' ) . ' ' . $target . '</i></strong>'; 
  23. endif; 
  24. $nonce = wp_create_nonce( "aioseop_meta_{$target}_{$post_id}" ); 
  25. $output = '<a id="' . $target . 'editlink' . $post_id . '" class="aioseop_edit_link" href="javascript:void(0);"' 
  26. . 'onclick=\'aioseop_ajax_edit_meta_form(' . $post_id . ', "' . $target . '", "' . $nonce . '");return false;\' title="' . __( 'Edit' ) . '">' 
  27. . '<img class="aioseop_edit_button" id="aioseop_edit_id" src="' . AIOSEOP_PLUGIN_IMAGES_URL . '/cog_edit.png" /></a> ' . $label; 
  28. die( "jQuery('div#aioseop_" . $target . '_' . $post_id . "').fadeOut('fast', function() { var my_label = " . json_encode( $output ) . "; 
  29. jQuery('div#aioseop_" . $target . '_' . $post_id . "').html(my_label).fadeIn('fast'); 
  30. });" );