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