function yoast_seo_addon_import($post_id, $data, $import_options)
{
    global $yoast_addon;
    // all fields except for slider and image fields
    $fields = array('_yoast_wpseo_focuskw', '_yoast_wpseo_title', '_yoast_wpseo_metadesc', '_yoast_wpseo_meta-robots-noindex', '_yoast_wpseo_meta-robots-nofollow', '_yoast_wpseo_meta-robots-adv', '_yoast_wpseo_sitemap-include', '_yoast_wpseo_sitemap-prio', '_yoast_wpseo_canonical', '_yoast_wpseo_redirect', '_yoast_wpseo_opengraph-title', '_yoast_wpseo_opengraph-description', '_yoast_wpseo_twitter-title', '_yoast_wpseo_twitter-description');
    // image fields
    $image_fields = array('_yoast_wpseo_opengraph-image', '_yoast_wpseo_twitter-image');
    $fields = array_merge($fields, $image_fields);
    // update everything in fields arrays
    foreach ($fields as $field) {
        if ($yoast_addon->can_update_meta($field, $import_options)) {
            if (in_array($field, $image_fields)) {
                if ($yoast_addon->can_update_image($import_options)) {
                    $id = $data[$field]['attachment_id'];
                    $url = wp_get_attachment_url($id);
                    update_post_meta($post_id, $field, $url);
                }
            } else {
                update_post_meta($post_id, $field, $data[$field]);
            }
        }
    }
    // calculate _yoast_wpseo_linkdex
    if (class_exists('WPSEO_Metabox')) {
        wpseo_admin_init();
        $seo = new WPSEO_Metabox();
        $seo->calculate_results(get_post($post_id));
    }
}
 /**
  * Get the post list table rows for the searched term.
  *
  * Mimics admin/edit.php without all the chrome elements.
  *
  * @since 1.2.0
  * @todo Account for private status on media items?
  */
 public static function ajax_get_posts_list_table()
 {
     global $hook_suffix, $pagenow, $post_type, $post_type_object, $per_page, $mode, $wp_query;
     if (!isset($_REQUEST['nonce']) || !wp_verify_nonce($_REQUEST['nonce'], 'bils-posts-list-table-instant-search')) {
         echo '<tr class="no-items bils-error"><td class="colspanchange">Invalid nonce.</td></tr>';
         wp_die();
     }
     $post_type = $_REQUEST['post_type'];
     $post_type_object = get_post_type_object($post_type);
     // Determine the orderby argument.
     if (isset($_REQUEST['orderby']) && !empty($_REQUEST['orderby'])) {
         $orderby = $_REQUEST['orderby'];
     } else {
         $orderby = $post_type_object->hierarchical ? 'title' : 'post_date';
     }
     // Determine the order argument.
     if (isset($_REQUEST['order']) && !empty($_REQUEST['order'])) {
         $order = 'asc' == strtolower($_REQUEST['order']) ? 'asc' : 'desc';
     } else {
         $order = $post_type_object->hierarchical ? 'asc' : 'desc';
     }
     $args = array('s' => $_REQUEST['s'], 'post_type' => $post_type, 'post_status' => $_REQUEST['post_status'], 'orderby' => $orderby, 'order' => $order, 'posts_per_page' => 20);
     if ('attachment' == $post_type) {
         $args['post_status'] = 'inherit';
         $args['post_mime_type'] = $_REQUEST['post_mime_type'];
     }
     // WordPress SEO compatibility.
     if (function_exists('wpseo_admin_init')) {
         $pagenow = 'edit.php';
         wpseo_admin_init();
         if (class_exists('WPSEO_Metabox')) {
             $wpseo_metabox = new WPSEO_Metabox();
             $wpseo_metabox->setup_page_analysis();
         }
     }
     set_current_screen($_REQUEST['screen']);
     // Posts 2 Posts column compatibility.
     do_action('load-edit.php');
     add_filter('posts_search', array('Better_Internal_Link_Search', 'limit_search_to_title'), 10, 2);
     wp_edit_posts_query($args);
     if ('attachment' == $post_type) {
         $wp_list_table = _get_list_table('WP_Media_List_Table', array('screen' => $_REQUEST['screen']));
     } else {
         $wp_list_table = _get_list_table('WP_Posts_List_Table', array('screen' => $_REQUEST['screen']));
     }
     $wp_list_table->prepare_items();
     $wp_list_table->display_rows_or_placeholder();
     wp_die();
 }
示例#3
0
文件: curl.php 项目: shellygraham/tag
 function _initialize_yoast()
 {
     wpseo_init();
     wpseo_admin_init();
     wpseo_load_textdomain();
     $options = WPSEO_Options::get_all();
     new WPSEO_Metabox();
     WPSEO_Metabox::translate_meta_boxes();
     if ($options['opengraph'] === true || $options['twitter'] === true || $options['googleplus'] === true) {
         new WPSEO_Social_Admin();
         WPSEO_Social_Admin::translate_meta_boxes();
     }
 }