Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/wp-conte.../plugins/wordpres...
File: class-wp-import.php
*/
[500] Fix | Delete
function process_terms() {
[501] Fix | Delete
$this->terms = apply_filters( 'wp_import_terms', $this->terms );
[502] Fix | Delete
[503] Fix | Delete
if ( empty( $this->terms ) ) {
[504] Fix | Delete
return;
[505] Fix | Delete
}
[506] Fix | Delete
[507] Fix | Delete
foreach ( $this->terms as $term ) {
[508] Fix | Delete
// if the term already exists in the correct taxonomy leave it alone
[509] Fix | Delete
$term_id = term_exists( $term['slug'], $term['term_taxonomy'] );
[510] Fix | Delete
if ( $term_id ) {
[511] Fix | Delete
if ( is_array( $term_id ) ) {
[512] Fix | Delete
$term_id = $term_id['term_id'];
[513] Fix | Delete
}
[514] Fix | Delete
if ( isset( $term['term_id'] ) ) {
[515] Fix | Delete
$this->processed_terms[ intval( $term['term_id'] ) ] = (int) $term_id;
[516] Fix | Delete
}
[517] Fix | Delete
continue;
[518] Fix | Delete
}
[519] Fix | Delete
[520] Fix | Delete
if ( empty( $term['term_parent'] ) ) {
[521] Fix | Delete
$parent = 0;
[522] Fix | Delete
} else {
[523] Fix | Delete
$parent = term_exists( $term['term_parent'], $term['term_taxonomy'] );
[524] Fix | Delete
if ( is_array( $parent ) ) {
[525] Fix | Delete
$parent = $parent['term_id'];
[526] Fix | Delete
}
[527] Fix | Delete
}
[528] Fix | Delete
[529] Fix | Delete
$description = isset( $term['term_description'] ) ? $term['term_description'] : '';
[530] Fix | Delete
$args = array(
[531] Fix | Delete
'slug' => $term['slug'],
[532] Fix | Delete
'description' => wp_slash( $description ),
[533] Fix | Delete
'parent' => (int) $parent,
[534] Fix | Delete
);
[535] Fix | Delete
[536] Fix | Delete
$id = wp_insert_term( wp_slash( $term['term_name'] ), $term['term_taxonomy'], $args );
[537] Fix | Delete
if ( ! is_wp_error( $id ) ) {
[538] Fix | Delete
if ( isset( $term['term_id'] ) ) {
[539] Fix | Delete
$this->processed_terms[ intval( $term['term_id'] ) ] = $id['term_id'];
[540] Fix | Delete
}
[541] Fix | Delete
} else {
[542] Fix | Delete
printf( __( 'Failed to import %1$s %2$s', 'wordpress-importer' ), esc_html( $term['term_taxonomy'] ), esc_html( $term['term_name'] ) );
[543] Fix | Delete
if ( defined( 'IMPORT_DEBUG' ) && IMPORT_DEBUG ) {
[544] Fix | Delete
echo ': ' . $id->get_error_message();
[545] Fix | Delete
}
[546] Fix | Delete
echo '<br />';
[547] Fix | Delete
continue;
[548] Fix | Delete
}
[549] Fix | Delete
[550] Fix | Delete
$this->process_termmeta( $term, $id['term_id'] );
[551] Fix | Delete
}
[552] Fix | Delete
[553] Fix | Delete
unset( $this->terms );
[554] Fix | Delete
}
[555] Fix | Delete
[556] Fix | Delete
/**
[557] Fix | Delete
* Add metadata to imported term.
[558] Fix | Delete
*
[559] Fix | Delete
* @since 0.6.2
[560] Fix | Delete
*
[561] Fix | Delete
* @param array $term Term data from WXR import.
[562] Fix | Delete
* @param int $term_id ID of the newly created term.
[563] Fix | Delete
*/
[564] Fix | Delete
protected function process_termmeta( $term, $term_id ) {
[565] Fix | Delete
if ( ! isset( $term['termmeta'] ) ) {
[566] Fix | Delete
$term['termmeta'] = array();
[567] Fix | Delete
}
[568] Fix | Delete
[569] Fix | Delete
/**
[570] Fix | Delete
* Filters the metadata attached to an imported term.
[571] Fix | Delete
*
[572] Fix | Delete
* @since 0.6.2
[573] Fix | Delete
*
[574] Fix | Delete
* @param array $termmeta Array of term meta.
[575] Fix | Delete
* @param int $term_id ID of the newly created term.
[576] Fix | Delete
* @param array $term Term data from the WXR import.
[577] Fix | Delete
*/
[578] Fix | Delete
$term['termmeta'] = apply_filters( 'wp_import_term_meta', $term['termmeta'], $term_id, $term );
[579] Fix | Delete
[580] Fix | Delete
if ( empty( $term['termmeta'] ) ) {
[581] Fix | Delete
return;
[582] Fix | Delete
}
[583] Fix | Delete
[584] Fix | Delete
foreach ( $term['termmeta'] as $meta ) {
[585] Fix | Delete
/**
[586] Fix | Delete
* Filters the meta key for an imported piece of term meta.
[587] Fix | Delete
*
[588] Fix | Delete
* @since 0.6.2
[589] Fix | Delete
*
[590] Fix | Delete
* @param string $meta_key Meta key.
[591] Fix | Delete
* @param int $term_id ID of the newly created term.
[592] Fix | Delete
* @param array $term Term data from the WXR import.
[593] Fix | Delete
*/
[594] Fix | Delete
$key = apply_filters( 'import_term_meta_key', $meta['key'], $term_id, $term );
[595] Fix | Delete
if ( ! $key ) {
[596] Fix | Delete
continue;
[597] Fix | Delete
}
[598] Fix | Delete
[599] Fix | Delete
// Export gets meta straight from the DB so could have a serialized string
[600] Fix | Delete
$value = maybe_unserialize( $meta['value'] );
[601] Fix | Delete
[602] Fix | Delete
add_term_meta( $term_id, wp_slash( $key ), wp_slash_strings_only( $value ) );
[603] Fix | Delete
[604] Fix | Delete
/**
[605] Fix | Delete
* Fires after term meta is imported.
[606] Fix | Delete
*
[607] Fix | Delete
* @since 0.6.2
[608] Fix | Delete
*
[609] Fix | Delete
* @param int $term_id ID of the newly created term.
[610] Fix | Delete
* @param string $key Meta key.
[611] Fix | Delete
* @param mixed $value Meta value.
[612] Fix | Delete
*/
[613] Fix | Delete
do_action( 'import_term_meta', $term_id, $key, $value );
[614] Fix | Delete
}
[615] Fix | Delete
}
[616] Fix | Delete
[617] Fix | Delete
/**
[618] Fix | Delete
* Create new posts based on import information
[619] Fix | Delete
*
[620] Fix | Delete
* Posts marked as having a parent which doesn't exist will become top level items.
[621] Fix | Delete
* Doesn't create a new post if: the post type doesn't exist, the given post ID
[622] Fix | Delete
* is already noted as imported or a post with the same title and date already exists.
[623] Fix | Delete
* Note that new/updated terms, comments and meta are imported for the last of the above.
[624] Fix | Delete
*/
[625] Fix | Delete
function process_posts() {
[626] Fix | Delete
$this->posts = apply_filters( 'wp_import_posts', $this->posts );
[627] Fix | Delete
[628] Fix | Delete
foreach ( $this->posts as $post ) {
[629] Fix | Delete
$post = apply_filters( 'wp_import_post_data_raw', $post );
[630] Fix | Delete
[631] Fix | Delete
if ( ! post_type_exists( $post['post_type'] ) ) {
[632] Fix | Delete
printf(
[633] Fix | Delete
__( 'Failed to import &#8220;%1$s&#8221;: Invalid post type %2$s', 'wordpress-importer' ),
[634] Fix | Delete
esc_html( $post['post_title'] ),
[635] Fix | Delete
esc_html( $post['post_type'] )
[636] Fix | Delete
);
[637] Fix | Delete
echo '<br />';
[638] Fix | Delete
do_action( 'wp_import_post_exists', $post );
[639] Fix | Delete
continue;
[640] Fix | Delete
}
[641] Fix | Delete
[642] Fix | Delete
if ( isset( $this->processed_posts[ $post['post_id'] ] ) && ! empty( $post['post_id'] ) ) {
[643] Fix | Delete
continue;
[644] Fix | Delete
}
[645] Fix | Delete
[646] Fix | Delete
if ( 'auto-draft' == $post['status'] ) {
[647] Fix | Delete
continue;
[648] Fix | Delete
}
[649] Fix | Delete
[650] Fix | Delete
if ( 'nav_menu_item' == $post['post_type'] ) {
[651] Fix | Delete
$this->process_menu_item( $post );
[652] Fix | Delete
continue;
[653] Fix | Delete
}
[654] Fix | Delete
[655] Fix | Delete
$post_type_object = get_post_type_object( $post['post_type'] );
[656] Fix | Delete
[657] Fix | Delete
$post_exists = post_exists( $post['post_title'], '', $post['post_date'] );
[658] Fix | Delete
[659] Fix | Delete
/**
[660] Fix | Delete
* Filter ID of the existing post corresponding to post currently importing.
[661] Fix | Delete
*
[662] Fix | Delete
* Return 0 to force the post to be imported. Filter the ID to be something else
[663] Fix | Delete
* to override which existing post is mapped to the imported post.
[664] Fix | Delete
*
[665] Fix | Delete
* @see post_exists()
[666] Fix | Delete
* @since 0.6.2
[667] Fix | Delete
*
[668] Fix | Delete
* @param int $post_exists Post ID, or 0 if post did not exist.
[669] Fix | Delete
* @param array $post The post array to be inserted.
[670] Fix | Delete
*/
[671] Fix | Delete
$post_exists = apply_filters( 'wp_import_existing_post', $post_exists, $post );
[672] Fix | Delete
[673] Fix | Delete
if ( $post_exists && get_post_type( $post_exists ) == $post['post_type'] ) {
[674] Fix | Delete
printf( __( '%1$s &#8220;%2$s&#8221; already exists.', 'wordpress-importer' ), $post_type_object->labels->singular_name, esc_html( $post['post_title'] ) );
[675] Fix | Delete
echo '<br />';
[676] Fix | Delete
$comment_post_id = $post_exists;
[677] Fix | Delete
$post_id = $post_exists;
[678] Fix | Delete
$this->processed_posts[ intval( $post['post_id'] ) ] = intval( $post_exists );
[679] Fix | Delete
} else {
[680] Fix | Delete
$post_parent = (int) $post['post_parent'];
[681] Fix | Delete
if ( $post_parent ) {
[682] Fix | Delete
// if we already know the parent, map it to the new local ID
[683] Fix | Delete
if ( isset( $this->processed_posts[ $post_parent ] ) ) {
[684] Fix | Delete
$post_parent = $this->processed_posts[ $post_parent ];
[685] Fix | Delete
// otherwise record the parent for later
[686] Fix | Delete
} else {
[687] Fix | Delete
$this->post_orphans[ intval( $post['post_id'] ) ] = $post_parent;
[688] Fix | Delete
$post_parent = 0;
[689] Fix | Delete
}
[690] Fix | Delete
}
[691] Fix | Delete
[692] Fix | Delete
// map the post author
[693] Fix | Delete
$author = sanitize_user( $post['post_author'], true );
[694] Fix | Delete
if ( isset( $this->author_mapping[ $author ] ) ) {
[695] Fix | Delete
$author = $this->author_mapping[ $author ];
[696] Fix | Delete
} else {
[697] Fix | Delete
$author = (int) get_current_user_id();
[698] Fix | Delete
}
[699] Fix | Delete
[700] Fix | Delete
$postdata = array(
[701] Fix | Delete
'import_id' => $post['post_id'],
[702] Fix | Delete
'post_author' => $author,
[703] Fix | Delete
'post_date' => $post['post_date'],
[704] Fix | Delete
'post_date_gmt' => $post['post_date_gmt'],
[705] Fix | Delete
'post_content' => $post['post_content'],
[706] Fix | Delete
'post_excerpt' => $post['post_excerpt'],
[707] Fix | Delete
'post_title' => $post['post_title'],
[708] Fix | Delete
'post_status' => $post['status'],
[709] Fix | Delete
'post_name' => $post['post_name'],
[710] Fix | Delete
'comment_status' => $post['comment_status'],
[711] Fix | Delete
'ping_status' => $post['ping_status'],
[712] Fix | Delete
'guid' => $post['guid'],
[713] Fix | Delete
'post_parent' => $post_parent,
[714] Fix | Delete
'menu_order' => $post['menu_order'],
[715] Fix | Delete
'post_type' => $post['post_type'],
[716] Fix | Delete
'post_password' => $post['post_password'],
[717] Fix | Delete
);
[718] Fix | Delete
[719] Fix | Delete
$original_post_id = $post['post_id'];
[720] Fix | Delete
$postdata = apply_filters( 'wp_import_post_data_processed', $postdata, $post );
[721] Fix | Delete
[722] Fix | Delete
$postdata = wp_slash( $postdata );
[723] Fix | Delete
[724] Fix | Delete
if ( 'attachment' == $postdata['post_type'] ) {
[725] Fix | Delete
$remote_url = ! empty( $post['attachment_url'] ) ? $post['attachment_url'] : $post['guid'];
[726] Fix | Delete
[727] Fix | Delete
// try to use _wp_attached file for upload folder placement to ensure the same location as the export site
[728] Fix | Delete
// e.g. location is 2003/05/image.jpg but the attachment post_date is 2010/09, see media_handle_upload()
[729] Fix | Delete
$postdata['upload_date'] = $post['post_date'];
[730] Fix | Delete
if ( isset( $post['postmeta'] ) ) {
[731] Fix | Delete
foreach ( $post['postmeta'] as $meta ) {
[732] Fix | Delete
if ( '_wp_attached_file' == $meta['key'] ) {
[733] Fix | Delete
if ( preg_match( '%^[0-9]{4}/[0-9]{2}%', $meta['value'], $matches ) ) {
[734] Fix | Delete
$postdata['upload_date'] = $matches[0];
[735] Fix | Delete
}
[736] Fix | Delete
break;
[737] Fix | Delete
}
[738] Fix | Delete
}
[739] Fix | Delete
}
[740] Fix | Delete
[741] Fix | Delete
$comment_post_id = $this->process_attachment( $postdata, $remote_url );
[742] Fix | Delete
$post_id = $comment_post_id;
[743] Fix | Delete
} else {
[744] Fix | Delete
$comment_post_id = wp_insert_post( $postdata, true );
[745] Fix | Delete
$post_id = $comment_post_id;
[746] Fix | Delete
do_action( 'wp_import_insert_post', $post_id, $original_post_id, $postdata, $post );
[747] Fix | Delete
}
[748] Fix | Delete
[749] Fix | Delete
if ( is_wp_error( $post_id ) ) {
[750] Fix | Delete
printf(
[751] Fix | Delete
__( 'Failed to import %1$s &#8220;%2$s&#8221;', 'wordpress-importer' ),
[752] Fix | Delete
$post_type_object->labels->singular_name,
[753] Fix | Delete
esc_html( $post['post_title'] )
[754] Fix | Delete
);
[755] Fix | Delete
if ( defined( 'IMPORT_DEBUG' ) && IMPORT_DEBUG ) {
[756] Fix | Delete
echo ': ' . $post_id->get_error_message();
[757] Fix | Delete
}
[758] Fix | Delete
echo '<br />';
[759] Fix | Delete
continue;
[760] Fix | Delete
}
[761] Fix | Delete
[762] Fix | Delete
if ( 1 == $post['is_sticky'] ) {
[763] Fix | Delete
stick_post( $post_id );
[764] Fix | Delete
}
[765] Fix | Delete
}
[766] Fix | Delete
[767] Fix | Delete
// map pre-import ID to local ID
[768] Fix | Delete
$this->processed_posts[ intval( $post['post_id'] ) ] = (int) $post_id;
[769] Fix | Delete
[770] Fix | Delete
if ( ! isset( $post['terms'] ) ) {
[771] Fix | Delete
$post['terms'] = array();
[772] Fix | Delete
}
[773] Fix | Delete
[774] Fix | Delete
$post['terms'] = apply_filters( 'wp_import_post_terms', $post['terms'], $post_id, $post );
[775] Fix | Delete
[776] Fix | Delete
// add categories, tags and other terms
[777] Fix | Delete
if ( ! empty( $post['terms'] ) ) {
[778] Fix | Delete
$terms_to_set = array();
[779] Fix | Delete
foreach ( $post['terms'] as $term ) {
[780] Fix | Delete
// back compat with WXR 1.0 map 'tag' to 'post_tag'
[781] Fix | Delete
$taxonomy = ( 'tag' == $term['domain'] ) ? 'post_tag' : $term['domain'];
[782] Fix | Delete
$term_exists = term_exists( $term['slug'], $taxonomy );
[783] Fix | Delete
$term_id = is_array( $term_exists ) ? $term_exists['term_id'] : $term_exists;
[784] Fix | Delete
if ( ! $term_id ) {
[785] Fix | Delete
$t = wp_insert_term( $term['name'], $taxonomy, array( 'slug' => $term['slug'] ) );
[786] Fix | Delete
if ( ! is_wp_error( $t ) ) {
[787] Fix | Delete
$term_id = $t['term_id'];
[788] Fix | Delete
do_action( 'wp_import_insert_term', $t, $term, $post_id, $post );
[789] Fix | Delete
} else {
[790] Fix | Delete
printf( __( 'Failed to import %1$s %2$s', 'wordpress-importer' ), esc_html( $taxonomy ), esc_html( $term['name'] ) );
[791] Fix | Delete
if ( defined( 'IMPORT_DEBUG' ) && IMPORT_DEBUG ) {
[792] Fix | Delete
echo ': ' . $t->get_error_message();
[793] Fix | Delete
}
[794] Fix | Delete
echo '<br />';
[795] Fix | Delete
do_action( 'wp_import_insert_term_failed', $t, $term, $post_id, $post );
[796] Fix | Delete
continue;
[797] Fix | Delete
}
[798] Fix | Delete
}
[799] Fix | Delete
$terms_to_set[ $taxonomy ][] = intval( $term_id );
[800] Fix | Delete
}
[801] Fix | Delete
[802] Fix | Delete
foreach ( $terms_to_set as $tax => $ids ) {
[803] Fix | Delete
$tt_ids = wp_set_post_terms( $post_id, $ids, $tax );
[804] Fix | Delete
do_action( 'wp_import_set_post_terms', $tt_ids, $ids, $tax, $post_id, $post );
[805] Fix | Delete
}
[806] Fix | Delete
unset( $post['terms'], $terms_to_set );
[807] Fix | Delete
}
[808] Fix | Delete
[809] Fix | Delete
if ( ! isset( $post['comments'] ) ) {
[810] Fix | Delete
$post['comments'] = array();
[811] Fix | Delete
}
[812] Fix | Delete
[813] Fix | Delete
$post['comments'] = apply_filters( 'wp_import_post_comments', $post['comments'], $post_id, $post );
[814] Fix | Delete
[815] Fix | Delete
// add/update comments
[816] Fix | Delete
if ( ! empty( $post['comments'] ) ) {
[817] Fix | Delete
$num_comments = 0;
[818] Fix | Delete
$inserted_comments = array();
[819] Fix | Delete
foreach ( $post['comments'] as $comment ) {
[820] Fix | Delete
$comment_id = $comment['comment_id'];
[821] Fix | Delete
$newcomments[ $comment_id ]['comment_post_ID'] = $comment_post_id;
[822] Fix | Delete
$newcomments[ $comment_id ]['comment_author'] = $comment['comment_author'];
[823] Fix | Delete
$newcomments[ $comment_id ]['comment_author_email'] = $comment['comment_author_email'];
[824] Fix | Delete
$newcomments[ $comment_id ]['comment_author_IP'] = $comment['comment_author_IP'];
[825] Fix | Delete
$newcomments[ $comment_id ]['comment_author_url'] = $comment['comment_author_url'];
[826] Fix | Delete
$newcomments[ $comment_id ]['comment_date'] = $comment['comment_date'];
[827] Fix | Delete
$newcomments[ $comment_id ]['comment_date_gmt'] = $comment['comment_date_gmt'];
[828] Fix | Delete
$newcomments[ $comment_id ]['comment_content'] = $comment['comment_content'];
[829] Fix | Delete
$newcomments[ $comment_id ]['comment_approved'] = $comment['comment_approved'];
[830] Fix | Delete
$newcomments[ $comment_id ]['comment_type'] = $comment['comment_type'];
[831] Fix | Delete
$newcomments[ $comment_id ]['comment_parent'] = $comment['comment_parent'];
[832] Fix | Delete
$newcomments[ $comment_id ]['commentmeta'] = isset( $comment['commentmeta'] ) ? $comment['commentmeta'] : array();
[833] Fix | Delete
if ( isset( $this->processed_authors[ $comment['comment_user_id'] ] ) ) {
[834] Fix | Delete
$newcomments[ $comment_id ]['user_id'] = $this->processed_authors[ $comment['comment_user_id'] ];
[835] Fix | Delete
}
[836] Fix | Delete
}
[837] Fix | Delete
ksort( $newcomments );
[838] Fix | Delete
[839] Fix | Delete
foreach ( $newcomments as $key => $comment ) {
[840] Fix | Delete
// if this is a new post we can skip the comment_exists() check
[841] Fix | Delete
if ( ! $post_exists || ! comment_exists( $comment['comment_author'], $comment['comment_date'] ) ) {
[842] Fix | Delete
if ( isset( $inserted_comments[ $comment['comment_parent'] ] ) ) {
[843] Fix | Delete
$comment['comment_parent'] = $inserted_comments[ $comment['comment_parent'] ];
[844] Fix | Delete
}
[845] Fix | Delete
[846] Fix | Delete
$comment_data = wp_slash( $comment );
[847] Fix | Delete
unset( $comment_data['commentmeta'] ); // Handled separately, wp_insert_comment() also expects `comment_meta`.
[848] Fix | Delete
$comment_data = wp_filter_comment( $comment_data );
[849] Fix | Delete
[850] Fix | Delete
$inserted_comments[ $key ] = wp_insert_comment( $comment_data );
[851] Fix | Delete
[852] Fix | Delete
do_action( 'wp_import_insert_comment', $inserted_comments[ $key ], $comment, $comment_post_id, $post );
[853] Fix | Delete
[854] Fix | Delete
foreach ( $comment['commentmeta'] as $meta ) {
[855] Fix | Delete
$value = maybe_unserialize( $meta['value'] );
[856] Fix | Delete
[857] Fix | Delete
add_comment_meta( $inserted_comments[ $key ], wp_slash( $meta['key'] ), wp_slash_strings_only( $value ) );
[858] Fix | Delete
}
[859] Fix | Delete
[860] Fix | Delete
$num_comments++;
[861] Fix | Delete
}
[862] Fix | Delete
}
[863] Fix | Delete
unset( $newcomments, $inserted_comments, $post['comments'] );
[864] Fix | Delete
}
[865] Fix | Delete
[866] Fix | Delete
if ( ! isset( $post['postmeta'] ) ) {
[867] Fix | Delete
$post['postmeta'] = array();
[868] Fix | Delete
}
[869] Fix | Delete
[870] Fix | Delete
$post['postmeta'] = apply_filters( 'wp_import_post_meta', $post['postmeta'], $post_id, $post );
[871] Fix | Delete
[872] Fix | Delete
// add/update post meta
[873] Fix | Delete
if ( ! empty( $post['postmeta'] ) ) {
[874] Fix | Delete
foreach ( $post['postmeta'] as $meta ) {
[875] Fix | Delete
$key = apply_filters( 'import_post_meta_key', $meta['key'], $post_id, $post );
[876] Fix | Delete
$value = false;
[877] Fix | Delete
[878] Fix | Delete
if ( '_edit_last' == $key ) {
[879] Fix | Delete
if ( isset( $this->processed_authors[ intval( $meta['value'] ) ] ) ) {
[880] Fix | Delete
$value = $this->processed_authors[ intval( $meta['value'] ) ];
[881] Fix | Delete
} else {
[882] Fix | Delete
$key = false;
[883] Fix | Delete
}
[884] Fix | Delete
}
[885] Fix | Delete
[886] Fix | Delete
if ( $key ) {
[887] Fix | Delete
// export gets meta straight from the DB so could have a serialized string
[888] Fix | Delete
if ( ! $value ) {
[889] Fix | Delete
$value = maybe_unserialize( $meta['value'] );
[890] Fix | Delete
}
[891] Fix | Delete
[892] Fix | Delete
add_post_meta( $post_id, wp_slash( $key ), wp_slash_strings_only( $value ) );
[893] Fix | Delete
[894] Fix | Delete
do_action( 'import_post_meta', $post_id, $key, $value );
[895] Fix | Delete
[896] Fix | Delete
// if the post has a featured image, take note of this in case of remap
[897] Fix | Delete
if ( '_thumbnail_id' == $key ) {
[898] Fix | Delete
$this->featured_images[ $post_id ] = (int) $value;
[899] Fix | Delete
}
[900] Fix | Delete
}
[901] Fix | Delete
}
[902] Fix | Delete
}
[903] Fix | Delete
}
[904] Fix | Delete
[905] Fix | Delete
unset( $this->posts );
[906] Fix | Delete
}
[907] Fix | Delete
[908] Fix | Delete
/**
[909] Fix | Delete
* Attempt to create a new menu item from import data
[910] Fix | Delete
*
[911] Fix | Delete
* Fails for draft, orphaned menu items and those without an associated nav_menu
[912] Fix | Delete
* or an invalid nav_menu term. If the post type or term object which the menu item
[913] Fix | Delete
* represents doesn't exist then the menu item will not be imported (waits until the
[914] Fix | Delete
* end of the import to retry again before discarding).
[915] Fix | Delete
*
[916] Fix | Delete
* @param array $item Menu item details from WXR file
[917] Fix | Delete
*/
[918] Fix | Delete
function process_menu_item( $item ) {
[919] Fix | Delete
// skip draft, orphaned menu items
[920] Fix | Delete
if ( 'draft' == $item['status'] ) {
[921] Fix | Delete
return;
[922] Fix | Delete
}
[923] Fix | Delete
[924] Fix | Delete
$menu_slug = false;
[925] Fix | Delete
if ( isset( $item['terms'] ) ) {
[926] Fix | Delete
// loop through terms, assume first nav_menu term is correct menu
[927] Fix | Delete
foreach ( $item['terms'] as $term ) {
[928] Fix | Delete
if ( 'nav_menu' == $term['domain'] ) {
[929] Fix | Delete
$menu_slug = $term['slug'];
[930] Fix | Delete
break;
[931] Fix | Delete
}
[932] Fix | Delete
}
[933] Fix | Delete
}
[934] Fix | Delete
[935] Fix | Delete
// no nav_menu term associated with this menu item
[936] Fix | Delete
if ( ! $menu_slug ) {
[937] Fix | Delete
_e( 'Menu item skipped due to missing menu slug', 'wordpress-importer' );
[938] Fix | Delete
echo '<br />';
[939] Fix | Delete
return;
[940] Fix | Delete
}
[941] Fix | Delete
[942] Fix | Delete
$menu_id = term_exists( $menu_slug, 'nav_menu' );
[943] Fix | Delete
if ( ! $menu_id ) {
[944] Fix | Delete
printf( __( 'Menu item skipped due to invalid menu slug: %s', 'wordpress-importer' ), esc_html( $menu_slug ) );
[945] Fix | Delete
echo '<br />';
[946] Fix | Delete
return;
[947] Fix | Delete
} else {
[948] Fix | Delete
$menu_id = is_array( $menu_id ) ? $menu_id['term_id'] : $menu_id;
[949] Fix | Delete
}
[950] Fix | Delete
[951] Fix | Delete
foreach ( $item['postmeta'] as $meta ) {
[952] Fix | Delete
${$meta['key']} = $meta['value'];
[953] Fix | Delete
}
[954] Fix | Delete
[955] Fix | Delete
if ( 'taxonomy' == $_menu_item_type && isset( $this->processed_terms[ intval( $_menu_item_object_id ) ] ) ) {
[956] Fix | Delete
$_menu_item_object_id = $this->processed_terms[ intval( $_menu_item_object_id ) ];
[957] Fix | Delete
} elseif ( 'post_type' == $_menu_item_type && isset( $this->processed_posts[ intval( $_menu_item_object_id ) ] ) ) {
[958] Fix | Delete
$_menu_item_object_id = $this->processed_posts[ intval( $_menu_item_object_id ) ];
[959] Fix | Delete
} elseif ( 'custom' != $_menu_item_type ) {
[960] Fix | Delete
// associated object is missing or not imported yet, we'll retry later
[961] Fix | Delete
$this->missing_menu_items[] = $item;
[962] Fix | Delete
return;
[963] Fix | Delete
}
[964] Fix | Delete
[965] Fix | Delete
if ( isset( $this->processed_menu_items[ intval( $_menu_item_menu_item_parent ) ] ) ) {
[966] Fix | Delete
$_menu_item_menu_item_parent = $this->processed_menu_items[ intval( $_menu_item_menu_item_parent ) ];
[967] Fix | Delete
} elseif ( $_menu_item_menu_item_parent ) {
[968] Fix | Delete
$this->menu_item_orphans[ intval( $item['post_id'] ) ] = (int) $_menu_item_menu_item_parent;
[969] Fix | Delete
$_menu_item_menu_item_parent = 0;
[970] Fix | Delete
}
[971] Fix | Delete
[972] Fix | Delete
// wp_update_nav_menu_item expects CSS classes as a space separated string
[973] Fix | Delete
$_menu_item_classes = maybe_unserialize( $_menu_item_classes );
[974] Fix | Delete
if ( is_array( $_menu_item_classes ) ) {
[975] Fix | Delete
$_menu_item_classes = implode( ' ', $_menu_item_classes );
[976] Fix | Delete
}
[977] Fix | Delete
[978] Fix | Delete
$args = array(
[979] Fix | Delete
'menu-item-object-id' => $_menu_item_object_id,
[980] Fix | Delete
'menu-item-object' => $_menu_item_object,
[981] Fix | Delete
'menu-item-parent-id' => $_menu_item_menu_item_parent,
[982] Fix | Delete
'menu-item-position' => intval( $item['menu_order'] ),
[983] Fix | Delete
'menu-item-type' => $_menu_item_type,
[984] Fix | Delete
'menu-item-title' => $item['post_title'],
[985] Fix | Delete
'menu-item-url' => $_menu_item_url,
[986] Fix | Delete
'menu-item-description' => $item['post_content'],
[987] Fix | Delete
'menu-item-attr-title' => $item['post_excerpt'],
[988] Fix | Delete
'menu-item-target' => $_menu_item_target,
[989] Fix | Delete
'menu-item-classes' => $_menu_item_classes,
[990] Fix | Delete
'menu-item-xfn' => $_menu_item_xfn,
[991] Fix | Delete
'menu-item-status' => $item['status'],
[992] Fix | Delete
);
[993] Fix | Delete
[994] Fix | Delete
$id = wp_update_nav_menu_item( $menu_id, 0, $args );
[995] Fix | Delete
if ( $id && ! is_wp_error( $id ) ) {
[996] Fix | Delete
$this->processed_menu_items[ intval( $item['post_id'] ) ] = (int) $id;
[997] Fix | Delete
}
[998] Fix | Delete
}
[999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function