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
}
[1000] Fix | Delete
[1001] Fix | Delete
return $post_id;
[1002] Fix | Delete
}
[1003] Fix | Delete
[1004] Fix | Delete
/**
[1005] Fix | Delete
* Attempt to download a remote file attachment
[1006] Fix | Delete
*
[1007] Fix | Delete
* @param string $url URL of item to fetch
[1008] Fix | Delete
* @param array $post Attachment details
[1009] Fix | Delete
* @return array|WP_Error Local file location details on success, WP_Error otherwise
[1010] Fix | Delete
*/
[1011] Fix | Delete
public function fetch_remote_file($url, $post)
[1012] Fix | Delete
{
[1013] Fix | Delete
// extract the file name and extension from the url
[1014] Fix | Delete
$file_name = basename($url);
[1015] Fix | Delete
[1016] Fix | Delete
// get placeholder file in the upload dir with a unique, sanitized filename
[1017] Fix | Delete
$upload = wp_upload_bits($file_name, null, '', $post['upload_date']);
[1018] Fix | Delete
if ($upload['error']) {
[1019] Fix | Delete
return new \WP_Error('upload_dir_error', $upload['error']);
[1020] Fix | Delete
}
[1021] Fix | Delete
[1022] Fix | Delete
// fetch the remote url and write it to the placeholder file
[1023] Fix | Delete
$remote_response = wp_safe_remote_get($url, array(
[1024] Fix | Delete
'timeout' => 300,
[1025] Fix | Delete
'stream' => true,
[1026] Fix | Delete
'filename' => $upload['file'],
[1027] Fix | Delete
));
[1028] Fix | Delete
[1029] Fix | Delete
$headers = wp_remote_retrieve_headers($remote_response);
[1030] Fix | Delete
[1031] Fix | Delete
// request failed
[1032] Fix | Delete
if (!$headers) {
[1033] Fix | Delete
wp_delete_file($upload['file']);
[1034] Fix | Delete
return new \WP_Error('import_file_error', __('Remote server did not respond', 'popup-builder'));
[1035] Fix | Delete
}
[1036] Fix | Delete
[1037] Fix | Delete
$remote_response_code = wp_remote_retrieve_response_code($remote_response);
[1038] Fix | Delete
[1039] Fix | Delete
// make sure the fetch was successful
[1040] Fix | Delete
if ($remote_response_code != '200') {
[1041] Fix | Delete
wp_delete_file($upload['file']);
[1042] Fix | Delete
/* translators: remote response code, status header description */
[1043] Fix | Delete
return new \WP_Error('import_file_error', sprintf(__('Remote server returned error response %1$d %2$s', 'popup-builder'), esc_html($remote_response_code), get_status_header_desc($remote_response_code)));
[1044] Fix | Delete
}
[1045] Fix | Delete
[1046] Fix | Delete
$filesize = filesize($upload['file']);
[1047] Fix | Delete
[1048] Fix | Delete
if (isset($headers['content-length']) && $filesize != $headers['content-length']) {
[1049] Fix | Delete
wp_delete_file($upload['file']);
[1050] Fix | Delete
return new \WP_Error('import_file_error', __('Remote file is incorrect size', 'popup-builder'));
[1051] Fix | Delete
}
[1052] Fix | Delete
[1053] Fix | Delete
if (0 == $filesize) {
[1054] Fix | Delete
wp_delete_file($upload['file']);
[1055] Fix | Delete
return new \WP_Error('import_file_error', __('Zero size file downloaded', 'popup-builder'));
[1056] Fix | Delete
}
[1057] Fix | Delete
[1058] Fix | Delete
$max_size = (int) $this->max_attachment_size();
[1059] Fix | Delete
if (!empty($max_size) && $filesize > $max_size) {
[1060] Fix | Delete
wp_delete_file($upload['file']);
[1061] Fix | Delete
/* translators: max size */
[1062] Fix | Delete
return new \WP_Error('import_file_error', sprintf(__('Remote file is too large, limit is %s', 'popup-builder'), size_format($max_size)));
[1063] Fix | Delete
}
[1064] Fix | Delete
[1065] Fix | Delete
// keep track of the old and new urls so we can substitute them later
[1066] Fix | Delete
$this->url_remap[$url] = $upload['url'];
[1067] Fix | Delete
$this->url_remap[$post['guid']] = $upload['url']; // r13735, really needed?
[1068] Fix | Delete
// keep track of the destination if the remote url is redirected somewhere else
[1069] Fix | Delete
if (isset($headers['x-final-location']) && $headers['x-final-location'] != $url) {
[1070] Fix | Delete
$this->url_remap[$headers['x-final-location']] = $upload['url'];
[1071] Fix | Delete
}
[1072] Fix | Delete
[1073] Fix | Delete
return $upload;
[1074] Fix | Delete
}
[1075] Fix | Delete
[1076] Fix | Delete
/**
[1077] Fix | Delete
* Attempt to associate posts and menu items with previously missing parents
[1078] Fix | Delete
*
[1079] Fix | Delete
* An imported post's parent may not have been imported when it was first created
[1080] Fix | Delete
* so try again. Similarly for child menu items and menu items which were missing
[1081] Fix | Delete
* the object (e.g. post) they represent in the menu
[1082] Fix | Delete
*/
[1083] Fix | Delete
public function backfill_parents()
[1084] Fix | Delete
{
[1085] Fix | Delete
global $wpdb;
[1086] Fix | Delete
[1087] Fix | Delete
// find parents for post orphans
[1088] Fix | Delete
foreach ($this->post_orphans as $child_id => $parent_id) {
[1089] Fix | Delete
$local_child_id = $local_parent_id = false;
[1090] Fix | Delete
if (isset($this->processed_posts[$child_id]))
[1091] Fix | Delete
$local_child_id = $this->processed_posts[$child_id];
[1092] Fix | Delete
if (isset($this->processed_posts[$parent_id]))
[1093] Fix | Delete
$local_parent_id = $this->processed_posts[$parent_id];
[1094] Fix | Delete
[1095] Fix | Delete
if ($local_child_id && $local_parent_id) {
[1096] Fix | Delete
$wpdb->update($wpdb->posts, array('post_parent' => $local_parent_id), array('ID' => $local_child_id), '%d', '%d');
[1097] Fix | Delete
clean_post_cache($local_child_id);
[1098] Fix | Delete
}
[1099] Fix | Delete
}
[1100] Fix | Delete
[1101] Fix | Delete
// all other posts/terms are imported, retry menu items with missing associated object
[1102] Fix | Delete
$missing_menu_items = $this->missing_menu_items;
[1103] Fix | Delete
foreach ($missing_menu_items as $item)
[1104] Fix | Delete
$this->process_menu_item($item);
[1105] Fix | Delete
[1106] Fix | Delete
// find parents for menu item orphans
[1107] Fix | Delete
foreach ($this->menu_item_orphans as $child_id => $parent_id) {
[1108] Fix | Delete
$local_child_id = $local_parent_id = 0;
[1109] Fix | Delete
if (isset($this->processed_menu_items[$child_id])) {
[1110] Fix | Delete
$local_child_id = $this->processed_menu_items[$child_id];
[1111] Fix | Delete
}
[1112] Fix | Delete
if (isset($this->processed_menu_items[$parent_id])) {
[1113] Fix | Delete
$local_parent_id = $this->processed_menu_items[$parent_id];
[1114] Fix | Delete
}
[1115] Fix | Delete
[1116] Fix | Delete
if ($local_child_id && $local_parent_id) {
[1117] Fix | Delete
update_post_meta($local_child_id, '_menu_item_menu_item_parent', (int) $local_parent_id);
[1118] Fix | Delete
}
[1119] Fix | Delete
}
[1120] Fix | Delete
}
[1121] Fix | Delete
[1122] Fix | Delete
/**
[1123] Fix | Delete
* Use stored mapping information to update old attachment URLs
[1124] Fix | Delete
*/
[1125] Fix | Delete
public function backfill_attachment_urls()
[1126] Fix | Delete
{
[1127] Fix | Delete
global $wpdb;
[1128] Fix | Delete
// make sure we do the longest urls first, in case one is a substring of another
[1129] Fix | Delete
uksort($this->url_remap, array(&$this, 'cmpr_strlen'));
[1130] Fix | Delete
[1131] Fix | Delete
foreach ($this->url_remap as $from_url => $to_url) {
[1132] Fix | Delete
// remap urls in post_content
[1133] Fix | Delete
$wpdb->query($wpdb->prepare("UPDATE {$wpdb->posts} SET post_content = REPLACE(post_content, %s, %s)", $from_url, $to_url));
[1134] Fix | Delete
// remap enclosure urls
[1135] Fix | Delete
$result = $wpdb->query($wpdb->prepare("UPDATE {$wpdb->postmeta} SET meta_value = REPLACE(meta_value, %s, %s) WHERE meta_key='enclosure'", $from_url, $to_url));
[1136] Fix | Delete
}
[1137] Fix | Delete
}
[1138] Fix | Delete
[1139] Fix | Delete
/**
[1140] Fix | Delete
* Update _thumbnail_id meta to new, imported attachment IDs
[1141] Fix | Delete
*/
[1142] Fix | Delete
public function remap_featured_images()
[1143] Fix | Delete
{
[1144] Fix | Delete
// cycle through posts that have a featured image
[1145] Fix | Delete
foreach ($this->featured_images as $post_id => $value) {
[1146] Fix | Delete
if (isset($this->processed_posts[$value])) {
[1147] Fix | Delete
$new_id = $this->processed_posts[$value];
[1148] Fix | Delete
// only update if there's a difference
[1149] Fix | Delete
if ($new_id != $value) {
[1150] Fix | Delete
update_post_meta($post_id, '_thumbnail_id', $new_id);
[1151] Fix | Delete
}
[1152] Fix | Delete
}
[1153] Fix | Delete
}
[1154] Fix | Delete
}
[1155] Fix | Delete
[1156] Fix | Delete
/**
[1157] Fix | Delete
* Parse a WXR file
[1158] Fix | Delete
*
[1159] Fix | Delete
* @param string $file Path to WXR file for parsing
[1160] Fix | Delete
* @return array Information gathered from the WXR file
[1161] Fix | Delete
*/
[1162] Fix | Delete
public function parse($file)
[1163] Fix | Delete
{
[1164] Fix | Delete
$parser = new WXR_Parser();
[1165] Fix | Delete
return $parser->parse($file);
[1166] Fix | Delete
}
[1167] Fix | Delete
[1168] Fix | Delete
// Display import page title
[1169] Fix | Delete
public function header()
[1170] Fix | Delete
{
[1171] Fix | Delete
echo '<div class="wrap">';
[1172] Fix | Delete
echo '<h2>' . esc_html( __('Import WordPress', 'popup-builder') ). '</h2>';
[1173] Fix | Delete
[1174] Fix | Delete
$updates = get_plugin_updates();
[1175] Fix | Delete
$basename = plugin_basename(__FILE__);
[1176] Fix | Delete
if (isset($updates[$basename])) {
[1177] Fix | Delete
$update = $updates[$basename];
[1178] Fix | Delete
echo '<div class="error"><p><strong>';
[1179] Fix | Delete
/* translators: new version */
[1180] Fix | Delete
printf(wp_kses_post(__('A new version of this importer is available. Please update to version %s to ensure compatibility with newer export files.', 'popup-builder')), esc_html( $update->update->new_version) );
[1181] Fix | Delete
echo '</strong></p></div>';
[1182] Fix | Delete
}
[1183] Fix | Delete
}
[1184] Fix | Delete
[1185] Fix | Delete
// Close div.wrap
[1186] Fix | Delete
public function footer()
[1187] Fix | Delete
{
[1188] Fix | Delete
echo '</div>';
[1189] Fix | Delete
}
[1190] Fix | Delete
[1191] Fix | Delete
/**
[1192] Fix | Delete
* Display introductory text and file upload form
[1193] Fix | Delete
*/
[1194] Fix | Delete
public function greet()
[1195] Fix | Delete
{
[1196] Fix | Delete
echo '<div class="narrow">';
[1197] Fix | Delete
echo '<p>'. esc_html( __('Howdy!Upload your WordPress eXtended RSS (WXR) file and we&#8217;ll import the posts, pages, comments, custom fields, categories, and tags into this site.', 'popup-builder') ).'</p>';
[1198] Fix | Delete
echo '<p>'. esc_html( __('Choose a WXR (.xml) file to upload, then click Upload file and import.', 'popup-builder') ).'</p>';
[1199] Fix | Delete
wp_import_upload_form('admin.php?import=wordpress&amp;step=1');
[1200] Fix | Delete
echo '</div>';
[1201] Fix | Delete
}
[1202] Fix | Delete
[1203] Fix | Delete
/**
[1204] Fix | Delete
* Decide if the given meta key maps to information we will want to import
[1205] Fix | Delete
*
[1206] Fix | Delete
* @param string $key The meta key to check
[1207] Fix | Delete
* @return string|bool The key if we do want to import, false if not
[1208] Fix | Delete
*/
[1209] Fix | Delete
public function is_valid_meta_key($key)
[1210] Fix | Delete
{
[1211] Fix | Delete
// skip attachment metadata since we'll regenerate it from scratch
[1212] Fix | Delete
// skip _edit_lock as not relevant for import
[1213] Fix | Delete
if (in_array($key, array('_wp_attached_file', '_wp_attachment_metadata', '_edit_lock')))
[1214] Fix | Delete
return false;
[1215] Fix | Delete
return $key;
[1216] Fix | Delete
}
[1217] Fix | Delete
[1218] Fix | Delete
/**
[1219] Fix | Delete
* Decide whether or not the importer is allowed to create users.
[1220] Fix | Delete
* Default is true, can be filtered via import_allow_create_users
[1221] Fix | Delete
*
[1222] Fix | Delete
* @return bool True if creating users is allowed
[1223] Fix | Delete
*/
[1224] Fix | Delete
public function allow_create_users()
[1225] Fix | Delete
{
[1226] Fix | Delete
return apply_filters('import_allow_create_users', true);
[1227] Fix | Delete
}
[1228] Fix | Delete
[1229] Fix | Delete
/**
[1230] Fix | Delete
* Decide whether or not the importer should attempt to download attachment files.
[1231] Fix | Delete
* Default is true, can be filtered via import_allow_fetch_attachments. The choice
[1232] Fix | Delete
* made at the import options screen must also be true, false here hides that checkbox.
[1233] Fix | Delete
*
[1234] Fix | Delete
* @return bool True if downloading attachments is allowed
[1235] Fix | Delete
*/
[1236] Fix | Delete
public function allow_fetch_attachments()
[1237] Fix | Delete
{
[1238] Fix | Delete
return apply_filters('import_allow_fetch_attachments', true);
[1239] Fix | Delete
}
[1240] Fix | Delete
[1241] Fix | Delete
/**
[1242] Fix | Delete
* Decide what the maximum file size for downloaded attachments is.
[1243] Fix | Delete
* Default is 0 (unlimited), can be filtered via import_attachment_size_limit
[1244] Fix | Delete
*
[1245] Fix | Delete
* @return int Maximum attachment file size to import
[1246] Fix | Delete
*/
[1247] Fix | Delete
public function max_attachment_size()
[1248] Fix | Delete
{
[1249] Fix | Delete
return apply_filters('import_attachment_size_limit', 0);
[1250] Fix | Delete
}
[1251] Fix | Delete
[1252] Fix | Delete
/**
[1253] Fix | Delete
* Added to http_request_timeout filter to force timeout at 60 seconds during import
[1254] Fix | Delete
* @return int 60
[1255] Fix | Delete
*/
[1256] Fix | Delete
public function bump_request_timeout($val)
[1257] Fix | Delete
{
[1258] Fix | Delete
return 60;
[1259] Fix | Delete
}
[1260] Fix | Delete
[1261] Fix | Delete
// return the difference in length between two strings
[1262] Fix | Delete
public function cmpr_strlen($a, $b)
[1263] Fix | Delete
{
[1264] Fix | Delete
return strlen($b) - strlen($a);
[1265] Fix | Delete
}
[1266] Fix | Delete
}
[1267] Fix | Delete
[1268] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function