Edit File by line
/home/barbar84/www/wp-admin
File: import.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Import WordPress Administration Screen
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @subpackage Administration
[5] Fix | Delete
*/
[6] Fix | Delete
[7] Fix | Delete
define( 'WP_LOAD_IMPORTERS', true );
[8] Fix | Delete
[9] Fix | Delete
/** Load WordPress Bootstrap */
[10] Fix | Delete
require_once __DIR__ . '/admin.php';
[11] Fix | Delete
[12] Fix | Delete
if ( ! current_user_can( 'import' ) ) {
[13] Fix | Delete
wp_die( __( 'Sorry, you are not allowed to import content into this site.' ) );
[14] Fix | Delete
}
[15] Fix | Delete
[16] Fix | Delete
$title = __( 'Import' );
[17] Fix | Delete
[18] Fix | Delete
get_current_screen()->add_help_tab(
[19] Fix | Delete
array(
[20] Fix | Delete
'id' => 'overview',
[21] Fix | Delete
'title' => __( 'Overview' ),
[22] Fix | Delete
'content' => '<p>' . __( 'This screen lists links to plugins to import data from blogging/content management platforms. Choose the platform you want to import from, and click Install Now when you are prompted in the popup window. If your platform is not listed, click the link to search the plugin directory for other importer plugins to see if there is one for your platform.' ) . '</p>' .
[23] Fix | Delete
'<p>' . __( 'In previous versions of WordPress, all importers were built-in. They have been turned into plugins since most people only use them once or infrequently.' ) . '</p>',
[24] Fix | Delete
)
[25] Fix | Delete
);
[26] Fix | Delete
[27] Fix | Delete
get_current_screen()->set_help_sidebar(
[28] Fix | Delete
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
[29] Fix | Delete
'<p>' . __( '<a href="https://wordpress.org/support/article/tools-import-screen/">Documentation on Import</a>' ) . '</p>' .
[30] Fix | Delete
'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
[31] Fix | Delete
);
[32] Fix | Delete
[33] Fix | Delete
if ( current_user_can( 'install_plugins' ) ) {
[34] Fix | Delete
// List of popular importer plugins from the WordPress.org API.
[35] Fix | Delete
$popular_importers = wp_get_popular_importers();
[36] Fix | Delete
} else {
[37] Fix | Delete
$popular_importers = array();
[38] Fix | Delete
}
[39] Fix | Delete
[40] Fix | Delete
// Detect and redirect invalid importers like 'movabletype', which is registered as 'mt'.
[41] Fix | Delete
if ( ! empty( $_GET['invalid'] ) && isset( $popular_importers[ $_GET['invalid'] ] ) ) {
[42] Fix | Delete
$importer_id = $popular_importers[ $_GET['invalid'] ]['importer-id'];
[43] Fix | Delete
if ( $importer_id !== $_GET['invalid'] ) { // Prevent redirect loops.
[44] Fix | Delete
wp_redirect( admin_url( 'admin.php?import=' . $importer_id ) );
[45] Fix | Delete
exit;
[46] Fix | Delete
}
[47] Fix | Delete
unset( $importer_id );
[48] Fix | Delete
}
[49] Fix | Delete
[50] Fix | Delete
add_thickbox();
[51] Fix | Delete
wp_enqueue_script( 'plugin-install' );
[52] Fix | Delete
wp_enqueue_script( 'updates' );
[53] Fix | Delete
[54] Fix | Delete
require_once ABSPATH . 'wp-admin/admin-header.php';
[55] Fix | Delete
$parent_file = 'tools.php';
[56] Fix | Delete
?>
[57] Fix | Delete
[58] Fix | Delete
<div class="wrap">
[59] Fix | Delete
<h1><?php echo esc_html( $title ); ?></h1>
[60] Fix | Delete
<?php if ( ! empty( $_GET['invalid'] ) ) : ?>
[61] Fix | Delete
<div class="error">
[62] Fix | Delete
<p><strong><?php _e( 'Error:' ); ?></strong>
[63] Fix | Delete
<?php
[64] Fix | Delete
/* translators: %s: Importer slug. */
[65] Fix | Delete
printf( __( 'The %s importer is invalid or is not installed.' ), '<strong>' . esc_html( $_GET['invalid'] ) . '</strong>' );
[66] Fix | Delete
?>
[67] Fix | Delete
</p>
[68] Fix | Delete
</div>
[69] Fix | Delete
<?php endif; ?>
[70] Fix | Delete
<p><?php _e( 'If you have posts or comments in another system, WordPress can import those into this site. To get started, choose a system to import from below:' ); ?></p>
[71] Fix | Delete
[72] Fix | Delete
<?php
[73] Fix | Delete
// Registered (already installed) importers. They're stored in the global $wp_importers.
[74] Fix | Delete
$importers = get_importers();
[75] Fix | Delete
[76] Fix | Delete
// If a popular importer is not registered, create a dummy registration that links to the plugin installer.
[77] Fix | Delete
foreach ( $popular_importers as $pop_importer => $pop_data ) {
[78] Fix | Delete
if ( isset( $importers[ $pop_importer ] ) ) {
[79] Fix | Delete
continue;
[80] Fix | Delete
}
[81] Fix | Delete
if ( isset( $importers[ $pop_data['importer-id'] ] ) ) {
[82] Fix | Delete
continue;
[83] Fix | Delete
}
[84] Fix | Delete
[85] Fix | Delete
// Fill the array of registered (already installed) importers with data of the popular importers from the WordPress.org API.
[86] Fix | Delete
$importers[ $pop_data['importer-id'] ] = array(
[87] Fix | Delete
$pop_data['name'],
[88] Fix | Delete
$pop_data['description'],
[89] Fix | Delete
'install' => $pop_data['plugin-slug'],
[90] Fix | Delete
);
[91] Fix | Delete
}
[92] Fix | Delete
[93] Fix | Delete
if ( empty( $importers ) ) {
[94] Fix | Delete
echo '<p>' . __( 'No importers are available.' ) . '</p>'; // TODO: Make more helpful.
[95] Fix | Delete
} else {
[96] Fix | Delete
uasort( $importers, '_usort_by_first_member' );
[97] Fix | Delete
?>
[98] Fix | Delete
<table class="widefat importers striped">
[99] Fix | Delete
[100] Fix | Delete
<?php
[101] Fix | Delete
foreach ( $importers as $importer_id => $data ) {
[102] Fix | Delete
$plugin_slug = '';
[103] Fix | Delete
$action = '';
[104] Fix | Delete
$is_plugin_installed = false;
[105] Fix | Delete
[106] Fix | Delete
if ( isset( $data['install'] ) ) {
[107] Fix | Delete
$plugin_slug = $data['install'];
[108] Fix | Delete
[109] Fix | Delete
if ( file_exists( WP_PLUGIN_DIR . '/' . $plugin_slug ) ) {
[110] Fix | Delete
// Looks like an importer is installed, but not active.
[111] Fix | Delete
$plugins = get_plugins( '/' . $plugin_slug );
[112] Fix | Delete
if ( ! empty( $plugins ) ) {
[113] Fix | Delete
$keys = array_keys( $plugins );
[114] Fix | Delete
$plugin_file = $plugin_slug . '/' . $keys[0];
[115] Fix | Delete
$url = wp_nonce_url(
[116] Fix | Delete
add_query_arg(
[117] Fix | Delete
array(
[118] Fix | Delete
'action' => 'activate',
[119] Fix | Delete
'plugin' => $plugin_file,
[120] Fix | Delete
'from' => 'import',
[121] Fix | Delete
),
[122] Fix | Delete
admin_url( 'plugins.php' )
[123] Fix | Delete
),
[124] Fix | Delete
'activate-plugin_' . $plugin_file
[125] Fix | Delete
);
[126] Fix | Delete
$action = sprintf(
[127] Fix | Delete
'<a href="%s" aria-label="%s">%s</a>',
[128] Fix | Delete
esc_url( $url ),
[129] Fix | Delete
/* translators: %s: Importer name. */
[130] Fix | Delete
esc_attr( sprintf( __( 'Run %s' ), $data[0] ) ),
[131] Fix | Delete
__( 'Run Importer' )
[132] Fix | Delete
);
[133] Fix | Delete
[134] Fix | Delete
$is_plugin_installed = true;
[135] Fix | Delete
}
[136] Fix | Delete
}
[137] Fix | Delete
[138] Fix | Delete
if ( empty( $action ) ) {
[139] Fix | Delete
if ( is_main_site() ) {
[140] Fix | Delete
$url = wp_nonce_url(
[141] Fix | Delete
add_query_arg(
[142] Fix | Delete
array(
[143] Fix | Delete
'action' => 'install-plugin',
[144] Fix | Delete
'plugin' => $plugin_slug,
[145] Fix | Delete
'from' => 'import',
[146] Fix | Delete
),
[147] Fix | Delete
self_admin_url( 'update.php' )
[148] Fix | Delete
),
[149] Fix | Delete
'install-plugin_' . $plugin_slug
[150] Fix | Delete
);
[151] Fix | Delete
$action = sprintf(
[152] Fix | Delete
'<a href="%1$s" class="install-now" data-slug="%2$s" data-name="%3$s" aria-label="%4$s">%5$s</a>',
[153] Fix | Delete
esc_url( $url ),
[154] Fix | Delete
esc_attr( $plugin_slug ),
[155] Fix | Delete
esc_attr( $data[0] ),
[156] Fix | Delete
/* translators: %s: Importer name. */
[157] Fix | Delete
esc_attr( sprintf( _x( 'Install %s now', 'plugin' ), $data[0] ) ),
[158] Fix | Delete
__( 'Install Now' )
[159] Fix | Delete
);
[160] Fix | Delete
} else {
[161] Fix | Delete
$action = sprintf(
[162] Fix | Delete
/* translators: %s: URL to Import screen on the main site. */
[163] Fix | Delete
__( 'This importer is not installed. Please install importers from <a href="%s">the main site</a>.' ),
[164] Fix | Delete
get_admin_url( get_current_network_id(), 'import.php' )
[165] Fix | Delete
);
[166] Fix | Delete
}
[167] Fix | Delete
}
[168] Fix | Delete
} else {
[169] Fix | Delete
$url = add_query_arg(
[170] Fix | Delete
array(
[171] Fix | Delete
'import' => $importer_id,
[172] Fix | Delete
),
[173] Fix | Delete
self_admin_url( 'admin.php' )
[174] Fix | Delete
);
[175] Fix | Delete
$action = sprintf(
[176] Fix | Delete
'<a href="%1$s" aria-label="%2$s">%3$s</a>',
[177] Fix | Delete
esc_url( $url ),
[178] Fix | Delete
/* translators: %s: Importer name. */
[179] Fix | Delete
esc_attr( sprintf( __( 'Run %s' ), $data[0] ) ),
[180] Fix | Delete
__( 'Run Importer' )
[181] Fix | Delete
);
[182] Fix | Delete
[183] Fix | Delete
$is_plugin_installed = true;
[184] Fix | Delete
}
[185] Fix | Delete
[186] Fix | Delete
if ( ! $is_plugin_installed && is_main_site() ) {
[187] Fix | Delete
$url = add_query_arg(
[188] Fix | Delete
array(
[189] Fix | Delete
'tab' => 'plugin-information',
[190] Fix | Delete
'plugin' => $plugin_slug,
[191] Fix | Delete
'from' => 'import',
[192] Fix | Delete
'TB_iframe' => 'true',
[193] Fix | Delete
'width' => 600,
[194] Fix | Delete
'height' => 550,
[195] Fix | Delete
),
[196] Fix | Delete
network_admin_url( 'plugin-install.php' )
[197] Fix | Delete
);
[198] Fix | Delete
$action .= sprintf(
[199] Fix | Delete
' | <a href="%1$s" class="thickbox open-plugin-details-modal" aria-label="%2$s">%3$s</a>',
[200] Fix | Delete
esc_url( $url ),
[201] Fix | Delete
/* translators: %s: Importer name. */
[202] Fix | Delete
esc_attr( sprintf( __( 'More information about %s' ), $data[0] ) ),
[203] Fix | Delete
__( 'Details' )
[204] Fix | Delete
);
[205] Fix | Delete
}
[206] Fix | Delete
[207] Fix | Delete
echo "
[208] Fix | Delete
<tr class='importer-item'>
[209] Fix | Delete
<td class='import-system'>
[210] Fix | Delete
<span class='importer-title'>{$data[0]}</span>
[211] Fix | Delete
<span class='importer-action'>{$action}</span>
[212] Fix | Delete
</td>
[213] Fix | Delete
<td class='desc'>
[214] Fix | Delete
<span class='importer-desc'>{$data[1]}</span>
[215] Fix | Delete
</td>
[216] Fix | Delete
</tr>";
[217] Fix | Delete
}
[218] Fix | Delete
?>
[219] Fix | Delete
</table>
[220] Fix | Delete
<?php
[221] Fix | Delete
}
[222] Fix | Delete
[223] Fix | Delete
if ( current_user_can( 'install_plugins' ) ) {
[224] Fix | Delete
echo '<p>' . sprintf(
[225] Fix | Delete
/* translators: %s: URL to Add Plugins screen. */
[226] Fix | Delete
__( 'If the importer you need is not listed, <a href="%s">search the plugin directory</a> to see if an importer is available.' ),
[227] Fix | Delete
esc_url( network_admin_url( 'plugin-install.php?tab=search&type=tag&s=importer' ) )
[228] Fix | Delete
) . '</p>';
[229] Fix | Delete
}
[230] Fix | Delete
?>
[231] Fix | Delete
[232] Fix | Delete
</div>
[233] Fix | Delete
[234] Fix | Delete
<?php
[235] Fix | Delete
wp_print_request_filesystem_credentials_modal();
[236] Fix | Delete
wp_print_admin_notice_templates();
[237] Fix | Delete
[238] Fix | Delete
require_once ABSPATH . 'wp-admin/admin-footer.php';
[239] Fix | Delete
[240] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function