/dist/wp-config-sample.php
*/
__( 'put your unique phrase here' ),
)
);
$missing_key = false;
$duplicated_keys = array();
foreach ( array( 'AUTH_KEY', 'SECURE_AUTH_KEY', 'LOGGED_IN_KEY', 'NONCE_KEY', 'AUTH_SALT', 'SECURE_AUTH_SALT', 'LOGGED_IN_SALT', 'NONCE_SALT' ) as $key ) {
if ( defined( $key ) ) {
// Check for unique values of each key.
$duplicated_keys[ constant( $key ) ] = isset( $duplicated_keys[ constant( $key ) ] );
} else {
// If a constant is not defined, it's missing.
$missing_key = true;
}
}
// If at least one key uses a default value, consider it duplicated.
foreach ( $default_keys as $default_key ) {
if ( isset( $duplicated_keys[ $default_key ] ) ) {
$duplicated_keys[ $default_key ] = true;
}
}
// Weed out all unique, non-default values.
$duplicated_keys = array_filter( $duplicated_keys );
if ( $duplicated_keys || $missing_key ) {
echo '' .
/* translators: Hidden accessibility text. */
__( 'Check secret keys' ) .
'
';
/* translators: 1: wp-config.php, 2: Secret key service URL. */
echo '' . sprintf( __( 'While you are editing your %1$s file, take a moment to make sure you have all 8 keys and that they are unique. You can generate these using the WordPress.org secret key service.' ), 'wp-config.php
', 'https://api.wordpress.org/secret-key/1.1/salt/' ) . '
';
}
} elseif ( isset( $_GET['repair'] ) ) {
echo '' .
/* translators: Hidden accessibility text. */
__( 'Database repair results' ) .
'
';
$optimize = '2' === $_GET['repair'];
$okay = true;
$problems = array();
$tables = $wpdb->tables();
/**
* Filters additional database tables to repair.
*
* @since 3.0.0
*
* @param string[] $tables Array of prefixed table names to be repaired.
*/
$tables = array_merge( $tables, (array) apply_filters( 'tables_to_repair', array() ) );
// Loop over the tables, checking and repairing as needed.
foreach ( $tables as $table ) {
$check = $wpdb->get_row( "CHECK TABLE $table" );
echo '';
if ( 'OK' === $check->Msg_text ) {
/* translators: %s: Table name. */
printf( __( 'The %s table is okay.' ), "$table
" );
} else {
/* translators: 1: Table name, 2: Error message. */
printf( __( 'The %1$s table is not okay. It is reporting the following error: %2$s. WordPress will attempt to repair this table…' ), "$table
", "$check->Msg_text
" );
$repair = $wpdb->get_row( "REPAIR TABLE $table" );
echo '
';
if ( 'OK' === $repair->Msg_text ) {
/* translators: %s: Table name. */
printf( __( 'Successfully repaired the %s table.' ), "$table
" );
} else {
/* translators: 1: Table name, 2: Error message. */
printf( __( 'Failed to repair the %1$s table. Error: %2$s' ), "$table
", "$repair->Msg_text
" ) . '
';
$problems[ $table ] = $repair->Msg_text;
$okay = false;
}
}
if ( $okay && $optimize ) {
$analyze = $wpdb->get_row( "ANALYZE TABLE $table" );
echo '
';
if ( 'Table is already up to date' === $analyze->Msg_text ) {
/* translators: %s: Table name. */
printf( __( 'The %s table is already optimized.' ), "$table
" );
} else {
$optimize = $wpdb->get_row( "OPTIMIZE TABLE $table" );
echo '
';
if ( 'OK' === $optimize->Msg_text || 'Table is already up to date' === $optimize->Msg_text ) {
/* translators: %s: Table name. */
printf( __( 'Successfully optimized the %s table.' ), "$table
" );
} else {
/* translators: 1: Table name. 2: Error message. */
printf( __( 'Failed to optimize the %1$s table. Error: %2$s' ), "$table
", "$optimize->Msg_text
" );
}
}
}
echo '
';
}
if ( $problems ) {
printf(
/* translators: %s: URL to "Fixing WordPress" forum. */
'' . __( 'Some database problems could not be repaired. Please copy-and-paste the following list of errors to the WordPress support forums to get additional assistance.' ) . '
',
__( 'https://wordpress.org/support/forum/how-to-and-troubleshooting' )
);
$problem_output = '';
foreach ( $problems as $table => $problem ) {
$problem_output .= "$table: $problem\n";
}
echo '';
} else {
echo '' . __( 'Repairs complete. Please remove the following line from wp-config.php to prevent this page from being used by unauthorized users.' ) . "
define('WP_ALLOW_REPAIR', true);
";
}
} else {
echo '' .
/* translators: Hidden accessibility text. */
__( 'WordPress database repair' ) .
'
';
if ( isset( $_GET['referrer'] ) && 'is_blog_installed' === $_GET['referrer'] ) {
echo '' . __( 'One or more database tables are unavailable. To allow WordPress to attempt to repair these tables, press the “Repair Database” button. Repairing can take a while, so please be patient.' ) . '
';
} else {
echo '' . __( 'WordPress can automatically look for some common database problems and repair them. Repairing can take a while, so please be patient.' ) . '
';
}
?>
user/contribute.php 0000755 00000000413 14744541145 0010423 0 ustar 00 domain, $current_site->domain ) || 0 !== strcasecmp( $current_blog->path, $current_site->path ) );
/**
* Filters whether to redirect the request to the User Admin in Multisite.
*
* @since 3.2.0
*
* @param bool $redirect_user_admin_request Whether the request should be redirected.
*/
$redirect_user_admin_request = apply_filters( 'redirect_user_admin_request', $redirect_user_admin_request );
if ( $redirect_user_admin_request ) {
wp_redirect( user_admin_url() );
exit;
}
unset( $redirect_user_admin_request );
user/user-edit.php 0000755 00000000372 14744541145 0010152 0 ustar 00 1 ) {
$_POST['allusers'] = array( $id ); // confirm_delete_users() can only handle arrays.
// Used in the HTML title tag.
$title = __( 'Users' );
$parent_file = 'users.php';
require_once ABSPATH . 'wp-admin/admin-header.php';
echo '';
confirm_delete_users( $_POST['allusers'] );
echo '
';
require_once ABSPATH . 'wp-admin/admin-footer.php';
} else {
wp_redirect( network_admin_url( 'users.php' ) );
}
exit;
case 'allusers':
if ( ! current_user_can( 'manage_network_users' ) ) {
wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
}
if ( isset( $_POST['action'] ) && isset( $_POST['allusers'] ) ) {
check_admin_referer( 'bulk-users-network' );
$doaction = $_POST['action'];
$userfunction = '';
foreach ( (array) $_POST['allusers'] as $user_id ) {
if ( ! empty( $user_id ) ) {
switch ( $doaction ) {
case 'delete':
if ( ! current_user_can( 'delete_users' ) ) {
wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
}
// Used in the HTML title tag.
$title = __( 'Users' );
$parent_file = 'users.php';
require_once ABSPATH . 'wp-admin/admin-header.php';
echo '';
confirm_delete_users( $_POST['allusers'] );
echo '
';
require_once ABSPATH . 'wp-admin/admin-footer.php';
exit;
case 'spam':
$user = get_userdata( $user_id );
if ( is_super_admin( $user->ID ) ) {
wp_die(
sprintf(
/* translators: %s: User login. */
__( 'Warning! User cannot be modified. The user %s is a network administrator.' ),
esc_html( $user->user_login )
)
);
}
$userfunction = 'all_spam';
$blogs = get_blogs_of_user( $user_id, true );
foreach ( (array) $blogs as $details ) {
if ( ! is_main_site( $details->userblog_id ) ) { // Main site is not a spam!
update_blog_status( $details->userblog_id, 'spam', '1' );
}
}
$user_data = $user->to_array();
$user_data['spam'] = '1';
wp_update_user( $user_data );
break;
case 'notspam':
$user = get_userdata( $user_id );
$userfunction = 'all_notspam';
$blogs = get_blogs_of_user( $user_id, true );
foreach ( (array) $blogs as $details ) {
update_blog_status( $details->userblog_id, 'spam', '0' );
}
$user_data = $user->to_array();
$user_data['spam'] = '0';
wp_update_user( $user_data );
break;
}
}
}
if ( ! in_array( $doaction, array( 'delete', 'spam', 'notspam' ), true ) ) {
$sendback = wp_get_referer();
$user_ids = (array) $_POST['allusers'];
/** This action is documented in wp-admin/network/site-themes.php */
$sendback = apply_filters( 'handle_network_bulk_actions-' . get_current_screen()->id, $sendback, $doaction, $user_ids ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
wp_safe_redirect( $sendback );
exit;
}
wp_safe_redirect(
add_query_arg(
array(
'updated' => 'true',
'action' => $userfunction,
),
wp_get_referer()
)
);
} else {
$location = network_admin_url( 'users.php' );
if ( ! empty( $_REQUEST['paged'] ) ) {
$location = add_query_arg( 'paged', (int) $_REQUEST['paged'], $location );
}
wp_redirect( $location );
}
exit;
case 'dodelete':
check_admin_referer( 'ms-users-delete' );
if ( ! ( current_user_can( 'manage_network_users' ) && current_user_can( 'delete_users' ) ) ) {
wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
}
if ( ! empty( $_POST['blog'] ) && is_array( $_POST['blog'] ) ) {
foreach ( $_POST['blog'] as $id => $users ) {
foreach ( $users as $blogid => $user_id ) {
if ( ! current_user_can( 'delete_user', $id ) ) {
continue;
}
if ( ! empty( $_POST['delete'] ) && 'reassign' === $_POST['delete'][ $blogid ][ $id ] ) {
remove_user_from_blog( $id, $blogid, (int) $user_id );
} else {
remove_user_from_blog( $id, $blogid );
}
}
}
}
$i = 0;
if ( is_array( $_POST['user'] ) && ! empty( $_POST['user'] ) ) {
foreach ( $_POST['user'] as $id ) {
if ( ! current_user_can( 'delete_user', $id ) ) {
continue;
}
wpmu_delete_user( $id );
++$i;
}
}
if ( 1 === $i ) {
$deletefunction = 'delete';
} else {
$deletefunction = 'all_delete';
}
wp_redirect(
add_query_arg(
array(
'updated' => 'true',
'action' => $deletefunction,
),
network_admin_url( 'users.php' )
)
);
exit;
}
}
$wp_list_table = _get_list_table( 'WP_MS_Users_List_Table' );
$pagenum = $wp_list_table->get_pagenum();
$wp_list_table->prepare_items();
$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
if ( $pagenum > $total_pages && $total_pages > 0 ) {
wp_redirect( add_query_arg( 'paged', $total_pages ) );
exit;
}
// Used in the HTML title tag.
$title = __( 'Users' );
$parent_file = 'users.php';
add_screen_option( 'per_page' );
get_current_screen()->add_help_tab(
array(
'id' => 'overview',
'title' => __( 'Overview' ),
'content' =>
'' . __( 'This table shows all users across the network and the sites to which they are assigned.' ) . '
' .
'' . __( 'Hover over any user on the list to make the edit links appear. The Edit link on the left will take you to their Edit User profile page; the Edit link on the right by any site name goes to an Edit Site screen for that site.' ) . '
' .
'' . __( 'You can also go to the user’s profile page by clicking on the individual username.' ) . '
' .
'' . __( 'You can sort the table by clicking on any of the table headings and switch between list and excerpt views by using the icons above the users list.' ) . '
' .
'' . __( 'The bulk action will permanently delete selected users, or mark/unmark those selected as spam. Spam users will have posts removed and will be unable to sign up again with the same email addresses.' ) . '
' .
'' . __( 'You can make an existing user an additional super admin by going to the Edit User profile page and checking the box to grant that privilege.' ) . '
',
)
);
get_current_screen()->set_help_sidebar(
'' . __( 'For more information:' ) . '
' .
'' . __( 'Documentation on Network Users' ) . '
' .
'' . __( 'Support forums' ) . '
'
);
get_current_screen()->set_screen_reader_content(
array(
'heading_views' => __( 'Filter users list' ),
'heading_pagination' => __( 'Users list navigation' ),
'heading_list' => __( 'Users list' ),
)
);
require_once ABSPATH . 'wp-admin/admin-header.php';
if ( isset( $_REQUEST['updated'] ) && 'true' === $_REQUEST['updated'] && ! empty( $_REQUEST['action'] ) ) {
$message = '';
switch ( $_REQUEST['action'] ) {
case 'delete':
$message = __( 'User deleted.' );
break;
case 'all_spam':
$message = __( 'Users marked as spam.' );
break;
case 'all_notspam':
$message = __( 'Users removed from spam.' );
break;
case 'all_delete':
$message = __( 'Users deleted.' );
break;
case 'add':
$message = __( 'User added.' );
break;
}
wp_admin_notice(
$message,
array(
'type' => 'success',
'dismissible' => true,
'id' => 'message',
)
);
}
?>
';
printf(
/* translators: %s: Search query. */
__( 'Search results for: %s' ),
'
' . esc_html( $usersearch ) . ''
);
echo '';
}
?>
views(); ?>
network/about.php 0000755 00000000365 14744541145 0010100 0 ustar 00 get_pagenum();
$action = $wp_list_table->current_action();
$s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
// Clean up request URI from temporary args for screen options/paging uri's to work as expected.
$temp_args = array(
'enabled',
'disabled',
'deleted',
'error',
'enabled-auto-update',
'disabled-auto-update',
);
$_SERVER['REQUEST_URI'] = remove_query_arg( $temp_args, $_SERVER['REQUEST_URI'] );
$referer = remove_query_arg( $temp_args, wp_get_referer() );
if ( $action ) {
switch ( $action ) {
case 'enable':
check_admin_referer( 'enable-theme_' . $_GET['theme'] );
WP_Theme::network_enable_theme( $_GET['theme'] );
if ( ! str_contains( $referer, '/network/themes.php' ) ) {
wp_redirect( network_admin_url( 'themes.php?enabled=1' ) );
} else {
wp_safe_redirect( add_query_arg( 'enabled', 1, $referer ) );
}
exit;
case 'disable':
check_admin_referer( 'disable-theme_' . $_GET['theme'] );
WP_Theme::network_disable_theme( $_GET['theme'] );
wp_safe_redirect( add_query_arg( 'disabled', '1', $referer ) );
exit;
case 'enable-selected':
check_admin_referer( 'bulk-themes' );
$themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
if ( empty( $themes ) ) {
wp_safe_redirect( add_query_arg( 'error', 'none', $referer ) );
exit;
}
WP_Theme::network_enable_theme( (array) $themes );
wp_safe_redirect( add_query_arg( 'enabled', count( $themes ), $referer ) );
exit;
case 'disable-selected':
check_admin_referer( 'bulk-themes' );
$themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
if ( empty( $themes ) ) {
wp_safe_redirect( add_query_arg( 'error', 'none', $referer ) );
exit;
}
WP_Theme::network_disable_theme( (array) $themes );
wp_safe_redirect( add_query_arg( 'disabled', count( $themes ), $referer ) );
exit;
case 'update-selected':
check_admin_referer( 'bulk-themes' );
if ( isset( $_GET['themes'] ) ) {
$themes = explode( ',', $_GET['themes'] );
} elseif ( isset( $_POST['checked'] ) ) {
$themes = (array) $_POST['checked'];
} else {
$themes = array();
}
// Used in the HTML title tag.
$title = __( 'Update Themes' );
$parent_file = 'themes.php';
require_once ABSPATH . 'wp-admin/admin-header.php';
echo '';
echo '
' . esc_html( $title ) . '
';
$url = self_admin_url( 'update.php?action=update-selected-themes&themes=' . urlencode( implode( ',', $themes ) ) );
$url = wp_nonce_url( $url, 'bulk-update-themes' );
echo "";
echo '';
require_once ABSPATH . 'wp-admin/admin-footer.php';
exit;
case 'delete-selected':
if ( ! current_user_can( 'delete_themes' ) ) {
wp_die( __( 'Sorry, you are not allowed to delete themes for this site.' ) );
}
check_admin_referer( 'bulk-themes' );
$themes = isset( $_REQUEST['checked'] ) ? (array) $_REQUEST['checked'] : array();
if ( empty( $themes ) ) {
wp_safe_redirect( add_query_arg( 'error', 'none', $referer ) );
exit;
}
$themes = array_diff( $themes, array( get_option( 'stylesheet' ), get_option( 'template' ) ) );
if ( empty( $themes ) ) {
wp_safe_redirect( add_query_arg( 'error', 'main', $referer ) );
exit;
}
$theme_info = array();
foreach ( $themes as $key => $theme ) {
$theme_info[ $theme ] = wp_get_theme( $theme );
}
require ABSPATH . 'wp-admin/update.php';
$parent_file = 'themes.php';
if ( ! isset( $_REQUEST['verify-delete'] ) ) {
wp_enqueue_script( 'jquery' );
require_once ABSPATH . 'wp-admin/admin-header.php';
$themes_to_delete = count( $themes );
?>
' . __( 'Caution:' ) . ' ' . __( 'This theme may be active on other sites in the network.' ),
array(
'additional_classes' => array( 'error' ),
)
);
?>
' . __( 'Caution:' ) . ' ' . __( 'These themes may be active on other sites in the network.' ),
array(
'additional_classes' => array( 'error' ),
)
);
?>
' . sprintf(
/* translators: 1: Theme name, 2: Theme author. */
_x( '%1$s by %2$s', 'theme' ),
'' . $theme->display( 'Name' ) . '',
'' . $theme->display( 'Author' ) . ''
) . '';
}
?>
1,
'action' => 'delete-selected',
'checked' => $_REQUEST['checked'],
'_wpnonce' => $_REQUEST['_wpnonce'],
),
network_admin_url( 'themes.php' )
)
)
);
}
$paged = ( $_REQUEST['paged'] ) ? $_REQUEST['paged'] : 1;
wp_redirect(
add_query_arg(
array(
'deleted' => count( $themes ),
'paged' => $paged,
's' => $s,
),
network_admin_url( 'themes.php' )
)
);
exit;
case 'enable-auto-update':
case 'disable-auto-update':
case 'enable-auto-update-selected':
case 'disable-auto-update-selected':
if ( ! ( current_user_can( 'update_themes' ) && wp_is_auto_update_enabled_for_type( 'theme' ) ) ) {
wp_die( __( 'Sorry, you are not allowed to change themes automatic update settings.' ) );
}
if ( 'enable-auto-update' === $action || 'disable-auto-update' === $action ) {
check_admin_referer( 'updates' );
} else {
if ( empty( $_POST['checked'] ) ) {
// Nothing to do.
wp_safe_redirect( add_query_arg( 'error', 'none', $referer ) );
exit;
}
check_admin_referer( 'bulk-themes' );
}
$auto_updates = (array) get_site_option( 'auto_update_themes', array() );
if ( 'enable-auto-update' === $action ) {
$auto_updates[] = $_GET['theme'];
$auto_updates = array_unique( $auto_updates );
$referer = add_query_arg( 'enabled-auto-update', 1, $referer );
} elseif ( 'disable-auto-update' === $action ) {
$auto_updates = array_diff( $auto_updates, array( $_GET['theme'] ) );
$referer = add_query_arg( 'disabled-auto-update', 1, $referer );
} else {
// Bulk enable/disable.
$themes = (array) wp_unslash( $_POST['checked'] );
if ( 'enable-auto-update-selected' === $action ) {
$auto_updates = array_merge( $auto_updates, $themes );
$auto_updates = array_unique( $auto_updates );
$referer = add_query_arg( 'enabled-auto-update', count( $themes ), $referer );
} else {
$auto_updates = array_diff( $auto_updates, $themes );
$referer = add_query_arg( 'disabled-auto-update', count( $themes ), $referer );
}
}
$all_items = wp_get_themes();
// Remove themes that don't exist or have been deleted since the option was last updated.
$auto_updates = array_intersect( $auto_updates, array_keys( $all_items ) );
update_site_option( 'auto_update_themes', $auto_updates );
wp_safe_redirect( $referer );
exit;
default:
$themes = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
if ( empty( $themes ) ) {
wp_safe_redirect( add_query_arg( 'error', 'none', $referer ) );
exit;
}
check_admin_referer( 'bulk-themes' );
/** This action is documented in wp-admin/network/site-themes.php */
$referer = apply_filters( 'handle_network_bulk_actions-' . get_current_screen()->id, $referer, $action, $themes ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
wp_safe_redirect( $referer );
exit;
}
}
$wp_list_table->prepare_items();
add_thickbox();
add_screen_option( 'per_page' );
get_current_screen()->add_help_tab(
array(
'id' => 'overview',
'title' => __( 'Overview' ),
'content' =>
'' . __( 'This screen enables and disables the inclusion of themes available to choose in the Appearance menu for each site. It does not activate or deactivate which theme a site is currently using.' ) . '
' .
'' . __( 'If the network admin disables a theme that is in use, it can still remain selected on that site. If another theme is chosen, the disabled theme will not appear in the site’s Appearance > Themes screen.' ) . '
' .
'' . __( 'Themes can be enabled on a site by site basis by the network admin on the Edit Site screen (which has a Themes tab); get there via the Edit action link on the All Sites screen. Only network admins are able to install or edit themes.' ) . '
',
)
);
$help_sidebar_autoupdates = '';
if ( current_user_can( 'update_themes' ) && wp_is_auto_update_enabled_for_type( 'theme' ) ) {
get_current_screen()->add_help_tab(
array(
'id' => 'plugins-themes-auto-updates',
'title' => __( 'Auto-updates' ),
'content' =>
'' . __( 'Auto-updates can be enabled or disabled for each individual theme. Themes with auto-updates enabled will display the estimated date of the next auto-update. Auto-updates depends on the WP-Cron task scheduling system.' ) . '
' .
'' . __( 'Please note: Third-party themes and plugins, or custom code, may override WordPress scheduling.' ) . '
',
)
);
$help_sidebar_autoupdates = '' . __( 'Documentation on Auto-updates' ) . '
';
}
get_current_screen()->set_help_sidebar(
'' . __( 'For more information:' ) . '
' .
'' . __( 'Documentation on Network Themes' ) . '
' .
$help_sidebar_autoupdates .
'' . __( 'Support forums' ) . '
'
);
get_current_screen()->set_screen_reader_content(
array(
'heading_views' => __( 'Filter themes list' ),
'heading_pagination' => __( 'Themes list navigation' ),
'heading_list' => __( 'Themes list' ),
)
);
// Used in the HTML title tag.
$title = __( 'Themes' );
$parent_file = 'themes.php';
wp_enqueue_script( 'updates' );
wp_enqueue_script( 'theme-preview' );
require_once ABSPATH . 'wp-admin/admin-header.php';
?>
';
printf(
/* translators: %s: Search query. */
__( 'Search results for: %s' ),
'
' . esc_html( $s ) . ''
);
echo '';
}
?>
$type,
'dismissible' => true,
'id' => 'message',
)
);
}
?>
views();
if ( 'broken' === $status ) {
echo '
' . __( 'The following themes are installed but incomplete.' ) . '
';
}
?>
add_help_tab( get_site_screen_help_tab_args() );
get_current_screen()->set_help_sidebar( get_site_screen_help_sidebar_content() );
get_current_screen()->set_screen_reader_content(
array(
'heading_views' => __( 'Filter site themes list' ),
'heading_pagination' => __( 'Site themes list navigation' ),
'heading_list' => __( 'Site themes list' ),
)
);
$wp_list_table = _get_list_table( 'WP_MS_Themes_List_Table' );
$action = $wp_list_table->current_action();
$s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
// Clean up request URI from temporary args for screen options/paging uri's to work as expected.
$temp_args = array( 'enabled', 'disabled', 'error' );
$_SERVER['REQUEST_URI'] = remove_query_arg( $temp_args, $_SERVER['REQUEST_URI'] );
$referer = remove_query_arg( $temp_args, wp_get_referer() );
if ( ! empty( $_REQUEST['paged'] ) ) {
$referer = add_query_arg( 'paged', (int) $_REQUEST['paged'], $referer );
}
$id = isset( $_REQUEST['id'] ) ? (int) $_REQUEST['id'] : 0;
if ( ! $id ) {
wp_die( __( 'Invalid site ID.' ) );
}
$wp_list_table->prepare_items();
$details = get_site( $id );
if ( ! $details ) {
wp_die( __( 'The requested site does not exist.' ) );
}
if ( ! can_edit_network( $details->site_id ) ) {
wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
}
$is_main_site = is_main_site( $id );
if ( $action ) {
switch_to_blog( $id );
$allowed_themes = get_option( 'allowedthemes' );
switch ( $action ) {
case 'enable':
check_admin_referer( 'enable-theme_' . $_GET['theme'] );
$theme = $_GET['theme'];
$action = 'enabled';
$n = 1;
if ( ! $allowed_themes ) {
$allowed_themes = array( $theme => true );
} else {
$allowed_themes[ $theme ] = true;
}
break;
case 'disable':
check_admin_referer( 'disable-theme_' . $_GET['theme'] );
$theme = $_GET['theme'];
$action = 'disabled';
$n = 1;
if ( ! $allowed_themes ) {
$allowed_themes = array();
} else {
unset( $allowed_themes[ $theme ] );
}
break;
case 'enable-selected':
check_admin_referer( 'bulk-themes' );
if ( isset( $_POST['checked'] ) ) {
$themes = (array) $_POST['checked'];
$action = 'enabled';
$n = count( $themes );
foreach ( (array) $themes as $theme ) {
$allowed_themes[ $theme ] = true;
}
} else {
$action = 'error';
$n = 'none';
}
break;
case 'disable-selected':
check_admin_referer( 'bulk-themes' );
if ( isset( $_POST['checked'] ) ) {
$themes = (array) $_POST['checked'];
$action = 'disabled';
$n = count( $themes );
foreach ( (array) $themes as $theme ) {
unset( $allowed_themes[ $theme ] );
}
} else {
$action = 'error';
$n = 'none';
}
break;
default:
if ( isset( $_POST['checked'] ) ) {
check_admin_referer( 'bulk-themes' );
$themes = (array) $_POST['checked'];
$n = count( $themes );
$screen = get_current_screen()->id;
/**
* Fires when a custom bulk action should be handled.
*
* The redirect link should be modified with success or failure feedback
* from the action to be used to display feedback to the user.
*
* The dynamic portion of the hook name, `$screen`, refers to the current screen ID.
*
* @since 4.7.0
*
* @param string $redirect_url The redirect URL.
* @param string $action The action being taken.
* @param array $items The items to take the action on.
* @param int $site_id The site ID.
*/
$referer = apply_filters( "handle_network_bulk_actions-{$screen}", $referer, $action, $themes, $id ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
} else {
$action = 'error';
$n = 'none';
}
}
update_option( 'allowedthemes', $allowed_themes, false );
restore_current_blog();
wp_safe_redirect(
add_query_arg(
array(
'id' => $id,
$action => $n,
),
$referer
)
);
exit;
}
if ( isset( $_GET['action'] ) && 'update-site' === $_GET['action'] ) {
wp_safe_redirect( $referer );
exit;
}
add_thickbox();
add_screen_option( 'per_page' );
// Used in the HTML title tag.
/* translators: %s: Site title. */
$title = sprintf( __( 'Edit Site: %s' ), esc_html( $details->blogname ) );
$parent_file = 'sites.php';
$submenu_file = 'sites.php';
require_once ABSPATH . 'wp-admin/admin-header.php';
?>
|
$id,
'selected' => 'site-themes',
)
);
if ( isset( $_GET['enabled'] ) ) {
$enabled = absint( $_GET['enabled'] );
if ( 1 === $enabled ) {
$message = __( 'Theme enabled.' );
} else {
/* translators: %s: Number of themes. */
$message = _n( '%s theme enabled.', '%s themes enabled.', $enabled );
}
wp_admin_notice(
sprintf( $message, number_format_i18n( $enabled ) ),
array(
'type' => 'success',
'dismissible' => true,
'id' => 'message',
)
);
} elseif ( isset( $_GET['disabled'] ) ) {
$disabled = absint( $_GET['disabled'] );
if ( 1 === $disabled ) {
$message = __( 'Theme disabled.' );
} else {
/* translators: %s: Number of themes. */
$message = _n( '%s theme disabled.', '%s themes disabled.', $disabled );
}
wp_admin_notice(
sprintf( $message, number_format_i18n( $disabled ) ),
array(
'type' => 'success',
'dismissible' => true,
'id' => 'message',
)
);
} elseif ( isset( $_GET['error'] ) && 'none' === $_GET['error'] ) {
wp_admin_notice(
__( 'No theme selected.' ),
array(
'type' => 'error',
'dismissible' => true,
'id' => 'message',
)
);
}
?>
views(); ?>
network/site-users.php 0000755 00000025511 14744541145 0011071 0 ustar 00 prepare_items();
get_current_screen()->add_help_tab( get_site_screen_help_tab_args() );
get_current_screen()->set_help_sidebar( get_site_screen_help_sidebar_content() );
get_current_screen()->set_screen_reader_content(
array(
'heading_views' => __( 'Filter site users list' ),
'heading_pagination' => __( 'Site users list navigation' ),
'heading_list' => __( 'Site users list' ),
)
);
$_SERVER['REQUEST_URI'] = remove_query_arg( 'update', $_SERVER['REQUEST_URI'] );
$referer = remove_query_arg( 'update', wp_get_referer() );
if ( ! empty( $_REQUEST['paged'] ) ) {
$referer = add_query_arg( 'paged', (int) $_REQUEST['paged'], $referer );
}
$id = isset( $_REQUEST['id'] ) ? (int) $_REQUEST['id'] : 0;
if ( ! $id ) {
wp_die( __( 'Invalid site ID.' ) );
}
$details = get_site( $id );
if ( ! $details ) {
wp_die( __( 'The requested site does not exist.' ) );
}
if ( ! can_edit_network( $details->site_id ) ) {
wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
}
$is_main_site = is_main_site( $id );
switch_to_blog( $id );
$action = $wp_list_table->current_action();
if ( $action ) {
switch ( $action ) {
case 'newuser':
check_admin_referer( 'add-user', '_wpnonce_add-new-user' );
$user = $_POST['user'];
if ( ! is_array( $_POST['user'] ) || empty( $user['username'] ) || empty( $user['email'] ) ) {
$update = 'err_new';
} else {
$password = wp_generate_password( 12, false );
$user_id = wpmu_create_user( esc_html( strtolower( $user['username'] ) ), $password, esc_html( $user['email'] ) );
if ( false === $user_id ) {
$update = 'err_new_dup';
} else {
$result = add_user_to_blog( $id, $user_id, $_POST['new_role'] );
if ( is_wp_error( $result ) ) {
$update = 'err_add_fail';
} else {
$update = 'newuser';
/**
* Fires after a user has been created via the network site-users.php page.
*
* @since 4.4.0
*
* @param int $user_id ID of the newly created user.
*/
do_action( 'network_site_users_created_user', $user_id );
}
}
}
break;
case 'adduser':
check_admin_referer( 'add-user', '_wpnonce_add-user' );
if ( ! empty( $_POST['newuser'] ) ) {
$update = 'adduser';
$newuser = $_POST['newuser'];
$user = get_user_by( 'login', $newuser );
if ( $user && $user->exists() ) {
if ( ! is_user_member_of_blog( $user->ID, $id ) ) {
$result = add_user_to_blog( $id, $user->ID, $_POST['new_role'] );
if ( is_wp_error( $result ) ) {
$update = 'err_add_fail';
}
} else {
$update = 'err_add_member';
}
} else {
$update = 'err_add_notfound';
}
} else {
$update = 'err_add_notfound';
}
break;
case 'remove':
if ( ! current_user_can( 'remove_users' ) ) {
wp_die( __( 'Sorry, you are not allowed to remove users.' ), 403 );
}
check_admin_referer( 'bulk-users' );
$update = 'remove';
if ( isset( $_REQUEST['users'] ) ) {
$userids = $_REQUEST['users'];
foreach ( $userids as $user_id ) {
$user_id = (int) $user_id;
remove_user_from_blog( $user_id, $id );
}
} elseif ( isset( $_GET['user'] ) ) {
remove_user_from_blog( $_GET['user'] );
} else {
$update = 'err_remove';
}
break;
case 'promote':
check_admin_referer( 'bulk-users' );
$editable_roles = get_editable_roles();
$role = $_REQUEST['new_role'];
if ( empty( $editable_roles[ $role ] ) ) {
wp_die( __( 'Sorry, you are not allowed to give users that role.' ), 403 );
}
if ( isset( $_REQUEST['users'] ) ) {
$userids = $_REQUEST['users'];
$update = 'promote';
foreach ( $userids as $user_id ) {
$user_id = (int) $user_id;
// If the user doesn't already belong to the blog, bail.
if ( ! is_user_member_of_blog( $user_id ) ) {
wp_die(
'' . __( 'Something went wrong.' ) . '
' .
'' . __( 'One of the selected users is not a member of this site.' ) . '
',
403
);
}
$user = get_userdata( $user_id );
$user->set_role( $role );
}
} else {
$update = 'err_promote';
}
break;
default:
if ( ! isset( $_REQUEST['users'] ) ) {
break;
}
check_admin_referer( 'bulk-users' );
$userids = $_REQUEST['users'];
/** This action is documented in wp-admin/network/site-themes.php */
$referer = apply_filters( 'handle_network_bulk_actions-' . get_current_screen()->id, $referer, $action, $userids, $id ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
$update = $action;
break;
}
wp_safe_redirect( add_query_arg( 'update', $update, $referer ) );
exit;
}
restore_current_blog();
if ( isset( $_GET['action'] ) && 'update-site' === $_GET['action'] ) {
wp_safe_redirect( $referer );
exit;
}
add_screen_option( 'per_page' );
// Used in the HTML title tag.
/* translators: %s: Site title. */
$title = sprintf( __( 'Edit Site: %s' ), esc_html( $details->blogname ) );
$parent_file = 'sites.php';
$submenu_file = 'sites.php';
/**
* Filters whether to show the Add Existing User form on the Multisite Users screen.
*
* @since 3.1.0
*
* @param bool $bool Whether to show the Add Existing User form. Default true.
*/
if ( ! wp_is_large_network( 'users' ) && apply_filters( 'show_network_site_users_add_existing_form', true ) ) {
wp_enqueue_script( 'user-suggest' );
}
require_once ABSPATH . 'wp-admin/admin-header.php';
?>
|
$id,
'selected' => 'site-users',
)
);
if ( isset( $_GET['update'] ) ) :
$message = '';
$type = 'error';
switch ( $_GET['update'] ) {
case 'adduser':
$type = 'success';
$message = __( 'User added.' );
break;
case 'err_add_member':
$message = __( 'User is already a member of this site.' );
break;
case 'err_add_fail':
$message = __( 'User could not be added to this site.' );
break;
case 'err_add_notfound':
$message = __( 'Enter the username of an existing user.' );
break;
case 'promote':
$type = 'success';
$message = __( 'Changed roles.' );
break;
case 'err_promote':
$message = __( 'Select a user to change role.' );
break;
case 'remove':
$type = 'success';
$message = __( 'User removed from this site.' );
break;
case 'err_remove':
$message = __( 'Select a user to remove.' );
break;
case 'newuser':
$type = 'success';
$message = __( 'User created.' );
break;
case 'err_new':
$message = __( 'Enter the username and email.' );
break;
case 'err_new_dup':
$message = __( 'Duplicated username or email address.' );
break;
}
wp_admin_notice(
$message,
array(
'type' => $type,
'dismissible' => true,
'id' => 'message',
)
);
endif;
?>
views(); ?>
domain, $current_site->domain ) || 0 !== strcasecmp( $current_blog->path, $current_site->path ) );
/**
* Filters whether to redirect the request to the Network Admin.
*
* @since 3.2.0
*
* @param bool $redirect_network_admin_request Whether the request should be redirected.
*/
$redirect_network_admin_request = apply_filters( 'redirect_network_admin_request', $redirect_network_admin_request );
if ( $redirect_network_admin_request ) {
wp_redirect( network_admin_url() );
exit;
}
unset( $redirect_network_admin_request );
network/user-edit.php 0000755 00000000375 14744541145 0010670 0 ustar 00 add_help_tab(
array(
'id' => 'overview',
'title' => __( 'Overview' ),
'content' =>
'' . __( 'Add User will set up a new user account on the network and send that person an email with username and password.' ) . '
' .
'' . __( 'Users who are signed up to the network without a site are added as subscribers to the main or primary dashboard site, giving them profile pages to manage their accounts. These users will only see Dashboard and My Sites in the main navigation until a site is created for them.' ) . '
',
)
);
get_current_screen()->set_help_sidebar(
'' . __( 'For more information:' ) . '
' .
'' . __( 'Documentation on Network Users' ) . '
' .
'' . __( 'Support forums' ) . '
'
);
if ( isset( $_REQUEST['action'] ) && 'add-user' === $_REQUEST['action'] ) {
check_admin_referer( 'add-user', '_wpnonce_add-user' );
if ( ! current_user_can( 'manage_network_users' ) ) {
wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
}
if ( ! is_array( $_POST['user'] ) ) {
wp_die( __( 'Cannot create an empty user.' ) );
}
$user = wp_unslash( $_POST['user'] );
$user_details = wpmu_validate_user_signup( $user['username'], $user['email'] );
if ( is_wp_error( $user_details['errors'] ) && $user_details['errors']->has_errors() ) {
$add_user_errors = $user_details['errors'];
} else {
$password = wp_generate_password( 12, false );
$user_id = wpmu_create_user( esc_html( strtolower( $user['username'] ) ), $password, sanitize_email( $user['email'] ) );
if ( ! $user_id ) {
$add_user_errors = new WP_Error( 'add_user_fail', __( 'Cannot add user.' ) );
} else {
/**
* Fires after a new user has been created via the network user-new.php page.
*
* @since 4.4.0
*
* @param int $user_id ID of the newly created user.
*/
do_action( 'network_user_new_created_user', $user_id );
wp_redirect(
add_query_arg(
array(
'update' => 'added',
'user_id' => $user_id,
),
'user-new.php'
)
);
exit;
}
}
}
$message = '';
if ( isset( $_GET['update'] ) ) {
if ( 'added' === $_GET['update'] ) {
$edit_link = '';
if ( isset( $_GET['user_id'] ) ) {
$user_id_new = absint( $_GET['user_id'] );
if ( $user_id_new ) {
$edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user_id_new ) ) );
}
}
$message = __( 'User added.' );
if ( $edit_link ) {
$message .= sprintf( ' %s', $edit_link, __( 'Edit user' ) );
}
}
}
// Used in the HTML title tag.
$title = __( 'Add New User' );
$parent_file = 'users.php';
require_once ABSPATH . 'wp-admin/admin-header.php';
?>
'success',
'dismissible' => true,
'id' => 'message',
)
);
}
if ( isset( $add_user_errors ) && is_wp_error( $add_user_errors ) ) {
$error_messages = '';
foreach ( $add_user_errors->get_error_messages() as $error ) {
$error_messages .= "
$error
";
}
wp_admin_notice(
$error_messages,
array(
'type' => 'error',
'dismissible' => true,
'id' => 'message',
'paragraph_wrap' => false,
)
);
}
?>
add_help_tab(
array(
'id' => 'overview',
'title' => __( 'Overview' ),
'content' =>
'' . __( 'Only use this screen once you have updated to a new version of WordPress through Updates/Available Updates (via the Network Administration navigation menu or the Toolbar). Clicking the Upgrade Network button will step through each site in the network, five at a time, and make sure any database updates are applied.' ) . '
' .
'' . __( 'If a version update to core has not happened, clicking this button will not affect anything.' ) . '
' .
'' . __( 'If this process fails for any reason, users logging in to their sites will force the same update.' ) . '
',
)
);
get_current_screen()->set_help_sidebar(
'' . __( 'For more information:' ) . '
' .
'' . __( 'Documentation on Upgrade Network' ) . '
' .
'' . __( 'Support forums' ) . '
'
);
require_once ABSPATH . 'wp-admin/admin-header.php';
if ( ! current_user_can( 'upgrade_network' ) ) {
wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
}
echo '';
echo '
' . __( 'Upgrade Network' ) . '
';
$action = isset( $_GET['action'] ) ? $_GET['action'] : 'show';
switch ( $action ) {
case 'upgrade':
$n = ( isset( $_GET['n'] ) ) ? (int) $_GET['n'] : 0;
if ( $n < 5 ) {
/**
* @global int $wp_db_version WordPress database version.
*/
global $wp_db_version;
update_site_option( 'wpmu_upgrade_site', $wp_db_version );
}
$site_ids = get_sites(
array(
'spam' => 0,
'deleted' => 0,
'archived' => 0,
'network_id' => get_current_network_id(),
'number' => 5,
'offset' => $n,
'fields' => 'ids',
'order' => 'DESC',
'orderby' => 'id',
'update_site_meta_cache' => false,
)
);
if ( empty( $site_ids ) ) {
echo '
' . __( 'All done!' ) . '
';
break;
}
echo '
';
foreach ( (array) $site_ids as $site_id ) {
switch_to_blog( $site_id );
$siteurl = site_url();
$upgrade_url = admin_url( 'upgrade.php?step=upgrade_db' );
restore_current_blog();
echo "- $siteurl
";
$response = wp_remote_get(
$upgrade_url,
array(
'timeout' => 120,
'httpversion' => '1.1',
'sslverify' => false,
)
);
if ( is_wp_error( $response ) ) {
wp_die(
sprintf(
/* translators: 1: Site URL, 2: Server error message. */
__( 'Warning! Problem updating %1$s. Your server may not be able to connect to sites running on it. Error message: %2$s' ),
$siteurl,
'' . $response->get_error_message() . ''
)
);
}
/**
* Fires after the Multisite DB upgrade for each site is complete.
*
* @since MU (3.0.0)
*
* @param array $response The upgrade response array.
*/
do_action( 'after_mu_upgrade', $response );
/**
* Fires after each site has been upgraded.
*
* @since MU (3.0.0)
*
* @param int $site_id The Site ID.
*/
do_action( 'wpmu_upgrade_site', $site_id );
}
echo '
';
?>
network/settings.php 0000755 00000052727 14744541145 0010637 0 ustar 00 add_help_tab(
array(
'id' => 'overview',
'title' => __( 'Overview' ),
'content' =>
'' . __( 'This screen sets and changes options for the network as a whole. The first site is the main site in the network and network options are pulled from that original site’s options.' ) . '
' .
'' . __( 'Operational settings has fields for the network’s name and admin email.' ) . '
' .
'' . __( 'Registration settings can disable/enable public signups. If you let others sign up for a site, install spam plugins. Spaces, not commas, should separate names banned as sites for this network.' ) . '
' .
'' . __( 'New site settings are defaults applied when a new site is created in the network. These include welcome email for when a new site or user account is registered, and what᾿s put in the first post, page, comment, comment author, and comment URL.' ) . '
' .
'' . __( 'Upload settings control the size of the uploaded files and the amount of available upload space for each site. You can change the default value for specific sites when you edit a particular site. Allowed file types are also listed (space separated only).' ) . '
' .
'' . __( 'You can set the language, and WordPress will automatically download and install the translation files (available if your filesystem is writable).' ) . '
' .
'' . __( 'Menu setting enables/disables the plugin menus from appearing for non super admins, so that only super admins, not site admins, have access to activate plugins.' ) . '
' .
'' . __( 'Super admins can no longer be added on the Options screen. You must now go to the list of existing users on Network Admin > Users and click on Username or the Edit action link below that name. This goes to an Edit User page where you can check a box to grant super admin privileges.' ) . '
',
)
);
get_current_screen()->set_help_sidebar(
'' . __( 'For more information:' ) . '
' .
'' . __( 'Documentation on Network Settings' ) . '
' .
'' . __( 'Support forums' ) . '
'
);
if ( $_POST ) {
/** This action is documented in wp-admin/network/edit.php */
do_action( 'wpmuadminedit' );
check_admin_referer( 'siteoptions' );
$checked_options = array(
'menu_items' => array(),
'registrationnotification' => 'no',
'upload_space_check_disabled' => 1,
'add_new_users' => 0,
);
foreach ( $checked_options as $option_name => $option_unchecked_value ) {
if ( ! isset( $_POST[ $option_name ] ) ) {
$_POST[ $option_name ] = $option_unchecked_value;
}
}
$options = array(
'registrationnotification',
'registration',
'add_new_users',
'menu_items',
'upload_space_check_disabled',
'blog_upload_space',
'upload_filetypes',
'site_name',
'first_post',
'first_page',
'first_comment',
'first_comment_url',
'first_comment_author',
'welcome_email',
'welcome_user_email',
'fileupload_maxk',
'illegal_names',
'limited_email_domains',
'banned_email_domains',
'WPLANG',
'new_admin_email',
'first_comment_email',
);
// Handle translation installation.
if ( ! empty( $_POST['WPLANG'] ) && current_user_can( 'install_languages' ) && wp_can_install_language_pack() ) {
$language = wp_download_language_pack( $_POST['WPLANG'] );
if ( $language ) {
$_POST['WPLANG'] = $language;
}
}
foreach ( $options as $option_name ) {
if ( ! isset( $_POST[ $option_name ] ) ) {
continue;
}
$value = wp_unslash( $_POST[ $option_name ] );
update_site_option( $option_name, $value );
}
/**
* Fires after the network options are updated.
*
* @since MU (3.0.0)
*/
do_action( 'update_wpmu_options' );
wp_redirect( add_query_arg( 'updated', 'true', network_admin_url( 'settings.php' ) ) );
exit;
}
require_once ABSPATH . 'wp-admin/admin-header.php';
if ( isset( $_GET['updated'] ) ) {
wp_admin_notice(
__( 'Settings saved.' ),
array(
'type' => 'success',
'dismissible' => true,
'id' => 'message',
)
);
}
?>
network/theme-install.php 0000755 00000000566 14744541145 0011537 0 ustar 00 ' . __( 'Welcome to your Network Admin. This area of the Administration Screens is used for managing all aspects of your Multisite Network.' ) . '';
$overview .= '' . __( 'From here you can:' ) . '
';
$overview .= '- ' . __( 'Add and manage sites or users' ) . '
';
$overview .= '- ' . __( 'Install and activate themes or plugins' ) . '
';
$overview .= '- ' . __( 'Update your network' ) . '
';
$overview .= '- ' . __( 'Modify global network settings' ) . '
';
get_current_screen()->add_help_tab(
array(
'id' => 'overview',
'title' => __( 'Overview' ),
'content' => $overview,
)
);
$quick_tasks = '' . __( 'The Right Now widget on this screen provides current user and site counts on your network.' ) . '
';
$quick_tasks .= '- ' . __( 'To add a new user, click Create a New User.' ) . '
';
$quick_tasks .= '- ' . __( 'To add a new site, click Create a New Site.' ) . '
';
$quick_tasks .= '' . __( 'To search for a user or site, use the search boxes.' ) . '
';
$quick_tasks .= '- ' . __( 'To search for a user, enter an email address or username. Use a wildcard to search for a partial username, such as user*.' ) . '
';
$quick_tasks .= '- ' . __( 'To search for a site, enter the path or domain.' ) . '
';
get_current_screen()->add_help_tab(
array(
'id' => 'quick-tasks',
'title' => __( 'Quick Tasks' ),
'content' => $quick_tasks,
)
);
get_current_screen()->set_help_sidebar(
'' . __( 'For more information:' ) . '
' .
'' . __( 'Documentation on the Network Admin' ) . '
' .
'' . __( 'Support forums' ) . '
'
);
wp_dashboard_setup();
wp_enqueue_script( 'dashboard' );
wp_enqueue_script( 'plugin-install' );
add_thickbox();
require_once ABSPATH . 'wp-admin/admin-header.php';
?>
get_pagenum();
// Used in the HTML title tag.
$title = __( 'Sites' );
$parent_file = 'sites.php';
add_screen_option( 'per_page' );
get_current_screen()->add_help_tab(
array(
'id' => 'overview',
'title' => __( 'Overview' ),
'content' =>
'' . __( 'Add New Site takes you to the screen for adding a new site to the network. You can search for a site by Name, ID number, or IP address. Screen Options allows you to choose how many sites to display on one page.' ) . '
' .
'' . __( 'This is the main table of all sites on this network. Switch between list and excerpt views by using the icons above the right side of the table.' ) . '
' .
'' . __( 'Hovering over each site reveals seven options (three for the primary site):' ) . '
' .
'- ' . __( 'An Edit link to a separate Edit Site screen.' ) . '
' .
'- ' . __( 'Dashboard leads to the Dashboard for that site.' ) . '
' .
'- ' . __( 'Deactivate, Archive, and Spam which lead to confirmation screens. These actions can be reversed later.' ) . '
' .
'- ' . __( 'Delete which is a permanent action after the confirmation screen.' ) . '
' .
'- ' . __( 'Visit to go to the front-end of the live site.' ) . '
',
)
);
get_current_screen()->set_help_sidebar(
'' . __( 'For more information:' ) . '
' .
'' . __( 'Documentation on Site Management' ) . '
' .
'' . __( 'Support forums' ) . '
'
);
get_current_screen()->set_screen_reader_content(
array(
'heading_pagination' => __( 'Sites list navigation' ),
'heading_list' => __( 'Sites list' ),
)
);
$id = isset( $_REQUEST['id'] ) ? (int) $_REQUEST['id'] : 0;
if ( isset( $_GET['action'] ) ) {
/** This action is documented in wp-admin/network/edit.php */
do_action( 'wpmuadminedit' );
// A list of valid actions and their associated messaging for confirmation output.
$manage_actions = array(
/* translators: %s: Site URL. */
'activateblog' => __( 'You are about to activate the site %s.' ),
/* translators: %s: Site URL. */
'deactivateblog' => __( 'You are about to deactivate the site %s.' ),
/* translators: %s: Site URL. */
'unarchiveblog' => __( 'You are about to unarchive the site %s.' ),
/* translators: %s: Site URL. */
'archiveblog' => __( 'You are about to archive the site %s.' ),
/* translators: %s: Site URL. */
'unspamblog' => __( 'You are about to unspam the site %s.' ),
/* translators: %s: Site URL. */
'spamblog' => __( 'You are about to mark the site %s as spam.' ),
/* translators: %s: Site URL. */
'deleteblog' => __( 'You are about to delete the site %s.' ),
/* translators: %s: Site URL. */
'unmatureblog' => __( 'You are about to mark the site %s as mature.' ),
/* translators: %s: Site URL. */
'matureblog' => __( 'You are about to mark the site %s as not mature.' ),
);
if ( 'confirm' === $_GET['action'] ) {
// The action2 parameter contains the action being taken on the site.
$site_action = $_GET['action2'];
if ( ! array_key_exists( $site_action, $manage_actions ) ) {
wp_die( __( 'The requested action is not valid.' ) );
}
// The mature/unmature UI exists only as external code. Check the "confirm" nonce for backward compatibility.
if ( 'matureblog' === $site_action || 'unmatureblog' === $site_action ) {
check_admin_referer( 'confirm' );
} else {
check_admin_referer( $site_action . '_' . $id );
}
if ( ! headers_sent() ) {
nocache_headers();
header( 'Content-Type: text/html; charset=utf-8' );
}
if ( is_main_site( $id ) ) {
wp_die( __( 'Sorry, you are not allowed to change the current site.' ) );
}
$site_details = get_site( $id );
$site_address = untrailingslashit( $site_details->domain . $site_details->path );
require_once ABSPATH . 'wp-admin/admin-header.php';
?>
403 ) );
}
$updated_action = 'not_deleted';
if ( 0 !== $id && ! is_main_site( $id ) && current_user_can( 'delete_site', $id ) ) {
wpmu_delete_blog( $id, true );
$updated_action = 'delete';
}
break;
case 'delete_sites':
check_admin_referer( 'ms-delete-sites' );
foreach ( (array) $_POST['site_ids'] as $site_id ) {
$site_id = (int) $site_id;
if ( is_main_site( $site_id ) ) {
continue;
}
if ( ! current_user_can( 'delete_site', $site_id ) ) {
$site = get_site( $site_id );
$site_address = untrailingslashit( $site->domain . $site->path );
wp_die(
sprintf(
/* translators: %s: Site URL. */
__( 'Sorry, you are not allowed to delete the site %s.' ),
$site_address
),
403
);
}
$updated_action = 'all_delete';
wpmu_delete_blog( $site_id, true );
}
break;
case 'allblogs':
if ( isset( $_POST['action'] ) && isset( $_POST['allblogs'] ) ) {
$doaction = $_POST['action'];
foreach ( (array) $_POST['allblogs'] as $site_id ) {
$site_id = (int) $site_id;
if ( 0 !== $site_id && ! is_main_site( $site_id ) ) {
switch ( $doaction ) {
case 'delete':
require_once ABSPATH . 'wp-admin/admin-header.php';
?>
id, $redirect_to, $doaction, $blogs, $id ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
wp_safe_redirect( $redirect_to );
exit;
}
} else {
// Process query defined by WP_MS_Site_List_Table::extra_table_nav().
$location = remove_query_arg(
array( '_wp_http_referer', '_wpnonce' ),
add_query_arg( $_POST, network_admin_url( 'sites.php' ) )
);
wp_redirect( $location );
exit;
}
break;
case 'archiveblog':
case 'unarchiveblog':
update_blog_status( $id, 'archived', ( 'archiveblog' === $_GET['action'] ) ? '1' : '0' );
break;
case 'activateblog':
update_blog_status( $id, 'deleted', '0' );
/**
* Fires after a network site is activated.
*
* @since MU (3.0.0)
*
* @param int $id The ID of the activated site.
*/
do_action( 'activate_blog', $id );
break;
case 'deactivateblog':
/**
* Fires before a network site is deactivated.
*
* @since MU (3.0.0)
*
* @param int $id The ID of the site being deactivated.
*/
do_action( 'deactivate_blog', $id );
update_blog_status( $id, 'deleted', '1' );
break;
case 'unspamblog':
case 'spamblog':
update_blog_status( $id, 'spam', ( 'spamblog' === $_GET['action'] ) ? '1' : '0' );
break;
case 'unmatureblog':
case 'matureblog':
update_blog_status( $id, 'mature', ( 'matureblog' === $_GET['action'] ) ? '1' : '0' );
break;
}
if ( empty( $updated_action ) && array_key_exists( $_GET['action'], $manage_actions ) ) {
$updated_action = $_GET['action'];
}
if ( ! empty( $updated_action ) ) {
wp_safe_redirect( add_query_arg( array( 'updated' => $updated_action ), wp_get_referer() ) );
exit;
}
}
$msg = '';
if ( isset( $_GET['updated'] ) ) {
$action = $_GET['updated'];
switch ( $action ) {
case 'all_notspam':
$msg = __( 'Sites removed from spam.' );
break;
case 'all_spam':
$msg = __( 'Sites marked as spam.' );
break;
case 'all_delete':
$msg = __( 'Sites deleted.' );
break;
case 'delete':
$msg = __( 'Site deleted.' );
break;
case 'not_deleted':
$msg = __( 'Sorry, you are not allowed to delete that site.' );
break;
case 'archiveblog':
$msg = __( 'Site archived.' );
break;
case 'unarchiveblog':
$msg = __( 'Site unarchived.' );
break;
case 'activateblog':
$msg = __( 'Site activated.' );
break;
case 'deactivateblog':
$msg = __( 'Site deactivated.' );
break;
case 'unspamblog':
$msg = __( 'Site removed from spam.' );
break;
case 'spamblog':
$msg = __( 'Site marked as spam.' );
break;
default:
/**
* Filters a specific, non-default, site-updated message in the Network admin.
*
* The dynamic portion of the hook name, `$action`, refers to the non-default
* site update action.
*
* @since 3.1.0
*
* @param string $msg The update message. Default 'Settings saved'.
*/
$msg = apply_filters( "network_sites_updated_message_{$action}", __( 'Settings saved.' ) );
break;
}
if ( ! empty( $msg ) ) {
$msg = wp_get_admin_notice(
$msg,
array(
'type' => 'success',
'dismissible' => true,
'id' => 'message',
)
);
}
}
$wp_list_table->prepare_items();
require_once ABSPATH . 'wp-admin/admin-header.php';
?>
';
printf(
/* translators: %s: Search query. */
__( 'Search results for: %s' ),
'
' . esc_html( $s ) . ''
);
echo '';
}
?>
views(); ?>
network/plugin-install.php 0000755 00000000571 14744541145 0011727 0 ustar 00 add_help_tab(
array(
'id' => 'overview',
'title' => __( 'Overview' ),
'content' =>
'' . __( 'This screen is for Super Admins to add new sites to the network. This is not affected by the registration settings.' ) . '
' .
'' . __( 'If the admin email for the new site does not exist in the database, a new user will also be created.' ) . '
',
)
);
get_current_screen()->set_help_sidebar(
'' . __( 'For more information:' ) . '
' .
'' . __( 'Documentation on Site Management' ) . '
' .
'' . __( 'Support forums' ) . '
'
);
if ( isset( $_REQUEST['action'] ) && 'add-site' === $_REQUEST['action'] ) {
check_admin_referer( 'add-blog', '_wpnonce_add-blog' );
if ( ! is_array( $_POST['blog'] ) ) {
wp_die( __( 'Cannot create an empty site.' ) );
}
$blog = $_POST['blog'];
$domain = '';
$blog['domain'] = trim( $blog['domain'] );
if ( preg_match( '|^([a-zA-Z0-9-])+$|', $blog['domain'] ) ) {
$domain = strtolower( $blog['domain'] );
}
// If not a subdomain installation, make sure the domain isn't a reserved word.
if ( ! is_subdomain_install() ) {
$subdirectory_reserved_names = get_subdirectory_reserved_names();
if ( in_array( $domain, $subdirectory_reserved_names, true ) ) {
wp_die(
sprintf(
/* translators: %s: Reserved names list. */
__( 'The following words are reserved for use by WordPress functions and cannot be used as site names: %s' ),
'' . implode( '
, ', $subdirectory_reserved_names ) . '
'
)
);
}
}
$title = $blog['title'];
$meta = array(
'public' => 1,
);
// Handle translation installation for the new site.
if ( isset( $_POST['WPLANG'] ) ) {
if ( '' === $_POST['WPLANG'] ) {
$meta['WPLANG'] = ''; // en_US
} elseif ( in_array( $_POST['WPLANG'], get_available_languages(), true ) ) {
$meta['WPLANG'] = $_POST['WPLANG'];
} elseif ( current_user_can( 'install_languages' ) && wp_can_install_language_pack() ) {
$language = wp_download_language_pack( wp_unslash( $_POST['WPLANG'] ) );
if ( $language ) {
$meta['WPLANG'] = $language;
}
}
}
if ( empty( $title ) ) {
wp_die( __( 'Missing site title.' ) );
}
if ( empty( $domain ) ) {
wp_die( __( 'Missing or invalid site address.' ) );
}
if ( isset( $blog['email'] ) && '' === trim( $blog['email'] ) ) {
wp_die( __( 'Missing email address.' ) );
}
$email = sanitize_email( $blog['email'] );
if ( ! is_email( $email ) ) {
wp_die( __( 'Invalid email address.' ) );
}
if ( is_subdomain_install() ) {
$newdomain = $domain . '.' . preg_replace( '|^www\.|', '', get_network()->domain );
$path = get_network()->path;
} else {
$newdomain = get_network()->domain;
$path = get_network()->path . $domain . '/';
}
$password = 'N/A';
$user_id = email_exists( $email );
if ( ! $user_id ) { // Create a new user with a random password.
/**
* Fires immediately before a new user is created via the network site-new.php page.
*
* @since 4.5.0
*
* @param string $email Email of the non-existent user.
*/
do_action( 'pre_network_site_new_created_user', $email );
$user_id = username_exists( $domain );
if ( $user_id ) {
wp_die( __( 'The domain or path entered conflicts with an existing username.' ) );
}
$password = wp_generate_password( 12, false );
$user_id = wpmu_create_user( $domain, $password, $email );
if ( false === $user_id ) {
wp_die( __( 'There was an error creating the user.' ) );
}
/**
* Fires after a new user has been created via the network site-new.php page.
*
* @since 4.4.0
*
* @param int $user_id ID of the newly created user.
*/
do_action( 'network_site_new_created_user', $user_id );
}
$wpdb->hide_errors();
$id = wpmu_create_blog( $newdomain, $path, $title, $user_id, $meta, get_current_network_id() );
$wpdb->show_errors();
if ( ! is_wp_error( $id ) ) {
if ( ! is_super_admin( $user_id ) && ! get_user_option( 'primary_blog', $user_id ) ) {
update_user_option( $user_id, 'primary_blog', $id, true );
}
wpmu_new_site_admin_notification( $id, $user_id );
wpmu_welcome_notification( $id, $user_id, $password, $title, array( 'public' => 1 ) );
wp_redirect(
add_query_arg(
array(
'update' => 'added',
'id' => $id,
),
'site-new.php'
)
);
exit;
} else {
wp_die( $id->get_error_message() );
}
}
if ( isset( $_GET['update'] ) ) {
$messages = array();
if ( 'added' === $_GET['update'] ) {
$messages[] = sprintf(
/* translators: 1: Dashboard URL, 2: Network admin edit URL. */
__( 'Site added. Visit Dashboard or Edit Site' ),
esc_url( get_admin_url( absint( $_GET['id'] ) ) ),
network_admin_url( 'site-info.php?id=' . absint( $_GET['id'] ) )
);
}
}
// Used in the HTML title tag.
$title = __( 'Add New Site' );
$parent_file = 'sites.php';
wp_enqueue_script( 'user-suggest' );
require_once ABSPATH . 'wp-admin/admin-header.php';
?>
'success',
'dismissible' => true,
'id' => 'message',
);
foreach ( $messages as $msg ) {
wp_admin_notice( $msg, $notice_args );
}
}
?>
add_help_tab( get_site_screen_help_tab_args() );
get_current_screen()->set_help_sidebar( get_site_screen_help_sidebar_content() );
$id = isset( $_REQUEST['id'] ) ? (int) $_REQUEST['id'] : 0;
if ( ! $id ) {
wp_die( __( 'Invalid site ID.' ) );
}
$details = get_site( $id );
if ( ! $details ) {
wp_die( __( 'The requested site does not exist.' ) );
}
if ( ! can_edit_network( $details->site_id ) ) {
wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
}
$parsed_scheme = parse_url( $details->siteurl, PHP_URL_SCHEME );
$is_main_site = is_main_site( $id );
if ( isset( $_REQUEST['action'] ) && 'update-site' === $_REQUEST['action'] ) {
check_admin_referer( 'edit-site' );
switch_to_blog( $id );
// Rewrite rules can't be flushed during switch to blog.
delete_option( 'rewrite_rules' );
$blog_data = wp_unslash( $_POST['blog'] );
$blog_data['scheme'] = $parsed_scheme;
if ( $is_main_site ) {
// On the network's main site, don't allow the domain or path to change.
$blog_data['domain'] = $details->domain;
$blog_data['path'] = $details->path;
} else {
// For any other site, the scheme, domain, and path can all be changed. We first
// need to ensure a scheme has been provided, otherwise fallback to the existing.
$new_url_scheme = parse_url( $blog_data['url'], PHP_URL_SCHEME );
if ( ! $new_url_scheme ) {
$blog_data['url'] = esc_url( $parsed_scheme . '://' . $blog_data['url'] );
}
$update_parsed_url = parse_url( $blog_data['url'] );
// If a path is not provided, use the default of `/`.
if ( ! isset( $update_parsed_url['path'] ) ) {
$update_parsed_url['path'] = '/';
}
$blog_data['scheme'] = $update_parsed_url['scheme'];
// Make sure to not lose the port if it was provided.
$blog_data['domain'] = $update_parsed_url['host'];
if ( isset( $update_parsed_url['port'] ) ) {
$blog_data['domain'] .= ':' . $update_parsed_url['port'];
}
$blog_data['path'] = $update_parsed_url['path'];
}
$existing_details = get_site( $id );
$blog_data_checkboxes = array( 'public', 'archived', 'spam', 'mature', 'deleted' );
foreach ( $blog_data_checkboxes as $c ) {
if ( ! in_array( (int) $existing_details->$c, array( 0, 1 ), true ) ) {
$blog_data[ $c ] = $existing_details->$c;
} else {
$blog_data[ $c ] = isset( $_POST['blog'][ $c ] ) ? 1 : 0;
}
}
update_blog_details( $id, $blog_data );
// Maybe update home and siteurl options.
$new_details = get_site( $id );
$old_home_url = trailingslashit( esc_url( get_option( 'home' ) ) );
$old_home_parsed = parse_url( $old_home_url );
$old_home_host = $old_home_parsed['host'] . ( isset( $old_home_parsed['port'] ) ? ':' . $old_home_parsed['port'] : '' );
if ( $old_home_host === $existing_details->domain && $old_home_parsed['path'] === $existing_details->path ) {
$new_home_url = untrailingslashit( sanitize_url( $blog_data['scheme'] . '://' . $new_details->domain . $new_details->path ) );
update_option( 'home', $new_home_url );
}
$old_site_url = trailingslashit( esc_url( get_option( 'siteurl' ) ) );
$old_site_parsed = parse_url( $old_site_url );
$old_site_host = $old_site_parsed['host'] . ( isset( $old_site_parsed['port'] ) ? ':' . $old_site_parsed['port'] : '' );
if ( $old_site_host === $existing_details->domain && $old_site_parsed['path'] === $existing_details->path ) {
$new_site_url = untrailingslashit( sanitize_url( $blog_data['scheme'] . '://' . $new_details->domain . $new_details->path ) );
update_option( 'siteurl', $new_site_url );
}
restore_current_blog();
wp_redirect(
add_query_arg(
array(
'update' => 'updated',
'id' => $id,
),
'site-info.php'
)
);
exit;
}
if ( isset( $_GET['update'] ) ) {
$messages = array();
if ( 'updated' === $_GET['update'] ) {
$messages[] = __( 'Site info updated.' );
}
}
// Used in the HTML title tag.
/* translators: %s: Site title. */
$title = sprintf( __( 'Edit Site: %s' ), esc_html( $details->blogname ) );
$parent_file = 'sites.php';
$submenu_file = 'sites.php';
require_once ABSPATH . 'wp-admin/admin-header.php';
?>
|
$id,
'selected' => 'site-info',
)
);
if ( ! empty( $messages ) ) {
$notice_args = array(
'type' => 'success',
'dismissible' => true,
'id' => 'message',
);
foreach ( $messages as $msg ) {
wp_admin_notice( $msg, $notice_args );
}
}
?>
add_help_tab( get_site_screen_help_tab_args() );
get_current_screen()->set_help_sidebar( get_site_screen_help_sidebar_content() );
$id = isset( $_REQUEST['id'] ) ? (int) $_REQUEST['id'] : 0;
if ( ! $id ) {
wp_die( __( 'Invalid site ID.' ) );
}
$details = get_site( $id );
if ( ! $details ) {
wp_die( __( 'The requested site does not exist.' ) );
}
if ( ! can_edit_network( $details->site_id ) ) {
wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
}
$is_main_site = is_main_site( $id );
if ( isset( $_REQUEST['action'] ) && 'update-site' === $_REQUEST['action'] && is_array( $_POST['option'] ) ) {
check_admin_referer( 'edit-site' );
switch_to_blog( $id );
$skip_options = array( 'allowedthemes' ); // Don't update these options since they are handled elsewhere in the form.
foreach ( (array) $_POST['option'] as $key => $val ) {
$key = wp_unslash( $key );
$val = wp_unslash( $val );
if ( 0 === $key || is_array( $val ) || in_array( $key, $skip_options, true ) ) {
continue; // Avoids "0 is a protected WP option and may not be modified" error when editing blog options.
}
update_option( $key, $val );
}
/**
* Fires after the site options are updated.
*
* @since 3.0.0
* @since 4.4.0 Added `$id` parameter.
*
* @param int $id The ID of the site being updated.
*/
do_action( 'wpmu_update_blog_options', $id );
restore_current_blog();
wp_redirect(
add_query_arg(
array(
'update' => 'updated',
'id' => $id,
),
'site-settings.php'
)
);
exit;
}
if ( isset( $_GET['update'] ) ) {
$messages = array();
if ( 'updated' === $_GET['update'] ) {
$messages[] = __( 'Site options updated.' );
}
}
// Used in the HTML title tag.
/* translators: %s: Site title. */
$title = sprintf( __( 'Edit Site: %s' ), esc_html( $details->blogname ) );
$parent_file = 'sites.php';
$submenu_file = 'sites.php';
require_once ABSPATH . 'wp-admin/admin-header.php';
?>
|
$id,
'selected' => 'site-settings',
)
);
if ( ! empty( $messages ) ) {
$notice_args = array(
'type' => 'success',
'dismissible' => true,
'id' => 'message',
);
foreach ( $messages as $msg ) {
wp_admin_notice( $msg, $notice_args );
}
}
?>
%s',
$update_data['counts']['total'],
number_format_i18n( $update_data['counts']['total'] )
)
),
$cap,
'update-core.php',
);
} else {
$submenu['index.php'][10] = array( __( 'Updates' ), $cap, 'update-core.php' );
}
unset( $cap );
$submenu['index.php'][15] = array( __( 'Upgrade Network' ), 'upgrade_network', 'upgrade.php' );
$menu[4] = array( '', 'read', 'separator1', '', 'wp-menu-separator' );
/* translators: Sites menu item. */
$menu[5] = array( __( 'Sites' ), 'manage_sites', 'sites.php', '', 'menu-top menu-icon-site', 'menu-site', 'dashicons-admin-multisite' );
$submenu['sites.php'][5] = array( __( 'All Sites' ), 'manage_sites', 'sites.php' );
$submenu['sites.php'][10] = array( __( 'Add New Site' ), 'create_sites', 'site-new.php' );
$menu[10] = array( __( 'Users' ), 'manage_network_users', 'users.php', '', 'menu-top menu-icon-users', 'menu-users', 'dashicons-admin-users' );
$submenu['users.php'][5] = array( __( 'All Users' ), 'manage_network_users', 'users.php' );
$submenu['users.php'][10] = array( __( 'Add New User' ), 'create_users', 'user-new.php' );
if ( current_user_can( 'update_themes' ) && $update_data['counts']['themes'] ) {
$menu[15] = array(
sprintf(
/* translators: %s: Number of available theme updates. */
__( 'Themes %s' ),
sprintf(
'%s',
$update_data['counts']['themes'],
number_format_i18n( $update_data['counts']['themes'] )
)
),
'manage_network_themes',
'themes.php',
'',
'menu-top menu-icon-appearance',
'menu-appearance',
'dashicons-admin-appearance',
);
} else {
$menu[15] = array( __( 'Themes' ), 'manage_network_themes', 'themes.php', '', 'menu-top menu-icon-appearance', 'menu-appearance', 'dashicons-admin-appearance' );
}
$submenu['themes.php'][5] = array( __( 'Installed Themes' ), 'manage_network_themes', 'themes.php' );
$submenu['themes.php'][10] = array( __( 'Add New Theme' ), 'install_themes', 'theme-install.php' );
$submenu['themes.php'][15] = array( __( 'Theme File Editor' ), 'edit_themes', 'theme-editor.php' );
if ( current_user_can( 'update_plugins' ) && $update_data['counts']['plugins'] ) {
$menu[20] = array(
sprintf(
/* translators: %s: Number of available plugin updates. */
__( 'Plugins %s' ),
sprintf(
'%s',
$update_data['counts']['plugins'],
number_format_i18n( $update_data['counts']['plugins'] )
)
),
'manage_network_plugins',
'plugins.php',
'',
'menu-top menu-icon-plugins',
'menu-plugins',
'dashicons-admin-plugins',
);
} else {
$menu[20] = array( __( 'Plugins' ), 'manage_network_plugins', 'plugins.php', '', 'menu-top menu-icon-plugins', 'menu-plugins', 'dashicons-admin-plugins' );
}
$submenu['plugins.php'][5] = array( __( 'Installed Plugins' ), 'manage_network_plugins', 'plugins.php' );
$submenu['plugins.php'][10] = array( __( 'Add New Plugin' ), 'install_plugins', 'plugin-install.php' );
$submenu['plugins.php'][15] = array( __( 'Plugin File Editor' ), 'edit_plugins', 'plugin-editor.php' );
$menu[25] = array( __( 'Settings' ), 'manage_network_options', 'settings.php', '', 'menu-top menu-icon-settings', 'menu-settings', 'dashicons-admin-settings' );
if ( defined( 'MULTISITE' ) && defined( 'WP_ALLOW_MULTISITE' ) && WP_ALLOW_MULTISITE ) {
$submenu['settings.php'][5] = array( __( 'Network Settings' ), 'manage_network_options', 'settings.php' );
$submenu['settings.php'][10] = array( __( 'Network Setup' ), 'setup_network', 'setup.php' );
}
unset( $update_data );
$menu[99] = array( '', 'exist', 'separator-last', '', 'wp-menu-separator' );
require_once ABSPATH . 'wp-admin/includes/menu.php';
network/theme-editor.php 0000755 00000000410 14744541145 0011343 0 ustar 00 add_help_tab(
array(
'id' => 'overview',
'title' => __( 'Overview' ),
'content' =>
'' . __( 'The Privacy screen lets you either build a new privacy-policy page or choose one you already have to show.' ) . '
' .
'' . __( 'This screen includes suggestions to help you write your own privacy policy. However, it is your responsibility to use these resources correctly, to provide the information required by your privacy policy, and to keep this information current and accurate.' ) . '
',
)
);
get_current_screen()->set_help_sidebar(
'' . __( 'For more information:' ) . '
' .
'' . __( 'Documentation on Privacy Settings' ) . '
'
);
if ( ! empty( $action ) ) {
check_admin_referer( $action );
if ( 'set-privacy-page' === $action ) {
$privacy_policy_page_id = isset( $_POST['page_for_privacy_policy'] ) ? (int) $_POST['page_for_privacy_policy'] : 0;
update_option( 'wp_page_for_privacy_policy', $privacy_policy_page_id );
$privacy_page_updated_message = __( 'Privacy Policy page updated successfully.' );
if ( $privacy_policy_page_id ) {
/*
* Don't always link to the menu customizer:
*
* - Unpublished pages can't be selected by default.
* - `WP_Customize_Nav_Menus::__construct()` checks the user's capabilities.
* - Themes might not "officially" support menus.
*/
if (
'publish' === get_post_status( $privacy_policy_page_id )
&& current_user_can( 'edit_theme_options' )
&& current_theme_supports( 'menus' )
) {
$privacy_page_updated_message = sprintf(
/* translators: %s: URL to Customizer -> Menus. */
__( 'Privacy Policy page setting updated successfully. Remember to update your menus!' ),
esc_url( add_query_arg( 'autofocus[panel]', 'nav_menus', admin_url( 'customize.php' ) ) )
);
}
}
add_settings_error( 'page_for_privacy_policy', 'page_for_privacy_policy', $privacy_page_updated_message, 'success' );
} elseif ( 'create-privacy-page' === $action ) {
if ( ! class_exists( 'WP_Privacy_Policy_Content' ) ) {
require_once ABSPATH . 'wp-admin/includes/class-wp-privacy-policy-content.php';
}
$privacy_policy_page_content = WP_Privacy_Policy_Content::get_default_content();
$privacy_policy_page_id = wp_insert_post(
array(
'post_title' => __( 'Privacy Policy' ),
'post_status' => 'draft',
'post_type' => 'page',
'post_content' => $privacy_policy_page_content,
),
true
);
if ( is_wp_error( $privacy_policy_page_id ) ) {
add_settings_error(
'page_for_privacy_policy',
'page_for_privacy_policy',
__( 'Unable to create a Privacy Policy page.' ),
'error'
);
} else {
update_option( 'wp_page_for_privacy_policy', $privacy_policy_page_id );
wp_redirect( admin_url( 'post.php?post=' . $privacy_policy_page_id . '&action=edit' ) );
exit;
}
}
}
// If a Privacy Policy page ID is available, make sure the page actually exists. If not, display an error.
$privacy_policy_page_exists = false;
$privacy_policy_page_id = (int) get_option( 'wp_page_for_privacy_policy' );
if ( ! empty( $privacy_policy_page_id ) ) {
$privacy_policy_page = get_post( $privacy_policy_page_id );
if ( ! $privacy_policy_page instanceof WP_Post ) {
add_settings_error(
'page_for_privacy_policy',
'page_for_privacy_policy',
__( 'The currently selected Privacy Policy page does not exist. Please create or select a new page.' ),
'error'
);
} else {
if ( 'trash' === $privacy_policy_page->post_status ) {
add_settings_error(
'page_for_privacy_policy',
'page_for_privacy_policy',
sprintf(
/* translators: %s: URL to Pages Trash. */
__( 'The currently selected Privacy Policy page is in the Trash. Please create or select a new Privacy Policy page or restore the current page.' ),
'edit.php?post_status=trash&post_type=page'
),
'error'
);
} else {
$privacy_policy_page_exists = true;
}
}
}
$parent_file = 'options-general.php';
wp_enqueue_script( 'privacy-tools' );
require_once ABSPATH . 'wp-admin/admin-header.php';
?>
'error',
'additional_classes' => array( 'hide-if-js' ),
)
);
?>
$privacy_policy_page_id,
'action' => 'edit',
),
admin_url( 'post.php' )
);
$view_href = get_permalink( $privacy_policy_page_id );
?>
Edit or view your Privacy Policy page content.' ),
esc_url( $edit_href ),
esc_url( $view_href )
);
} else {
printf(
/* translators: 1: URL to edit Privacy Policy page, 2: URL to preview Privacy Policy page. */
__( 'Edit or preview your Privacy Policy page content.' ),
esc_url( $edit_href ),
esc_url( $view_href )
);
}
?>
Check out our privacy policy guide%3$s for recommendations on what content to include, along with policies suggested by your plugins and theme.' ),
esc_url( admin_url( 'options-privacy.php?tab=policyguide' ) ),
'',
''
);
?>
'page',
'posts_per_page' => 1,
'post_status' => array(
'publish',
'draft',
),
)
);
?>
|
|
|
|
50 && mt_rand( 0, (int) ( $c / 50 ) ) === 1 ) ) {
require_once ABSPATH . WPINC . '/http.php';
$response = wp_remote_get(
admin_url( 'upgrade.php?step=1' ),
array(
'timeout' => 120,
'httpversion' => '1.1',
)
);
/** This action is documented in wp-admin/network/upgrade.php */
do_action( 'after_mu_upgrade', $response );
unset( $response );
}
unset( $c );
}
}
require_once ABSPATH . 'wp-admin/includes/admin.php';
auth_redirect();
// Schedule Trash collection.
if ( ! wp_next_scheduled( 'wp_scheduled_delete' ) && ! wp_installing() ) {
wp_schedule_event( time(), 'daily', 'wp_scheduled_delete' );
}
// Schedule transient cleanup.
if ( ! wp_next_scheduled( 'delete_expired_transients' ) && ! wp_installing() ) {
wp_schedule_event( time(), 'daily', 'delete_expired_transients' );
}
set_screen_options();
$date_format = __( 'F j, Y' );
$time_format = __( 'g:i a' );
wp_enqueue_script( 'common' );
/**
* $pagenow is set in vars.php.
* $wp_importers is sometimes set in wp-admin/includes/import.php.
* The remaining variables are imported as globals elsewhere, declared as globals here.
*
* @global string $pagenow The filename of the current screen.
* @global array $wp_importers
* @global string $hook_suffix
* @global string $plugin_page
* @global string $typenow The post type of the current screen.
* @global string $taxnow The taxonomy of the current screen.
*/
global $pagenow, $wp_importers, $hook_suffix, $plugin_page, $typenow, $taxnow;
$page_hook = null;
$editing = false;
if ( isset( $_GET['page'] ) ) {
$plugin_page = wp_unslash( $_GET['page'] );
$plugin_page = plugin_basename( $plugin_page );
}
if ( isset( $_REQUEST['post_type'] ) && post_type_exists( $_REQUEST['post_type'] ) ) {
$typenow = $_REQUEST['post_type'];
} else {
$typenow = '';
}
if ( isset( $_REQUEST['taxonomy'] ) && taxonomy_exists( $_REQUEST['taxonomy'] ) ) {
$taxnow = $_REQUEST['taxonomy'];
} else {
$taxnow = '';
}
if ( WP_NETWORK_ADMIN ) {
require ABSPATH . 'wp-admin/network/menu.php';
} elseif ( WP_USER_ADMIN ) {
require ABSPATH . 'wp-admin/user/menu.php';
} else {
require ABSPATH . 'wp-admin/menu.php';
}
if ( current_user_can( 'manage_options' ) ) {
wp_raise_memory_limit( 'admin' );
}
/**
* Fires as an admin screen or script is being initialized.
*
* Note, this does not just run on user-facing admin screens.
* It runs on admin-ajax.php and admin-post.php as well.
*
* This is roughly analogous to the more general {@see 'init'} hook, which fires earlier.
*
* @since 2.5.0
*/
do_action( 'admin_init' );
if ( isset( $plugin_page ) ) {
if ( ! empty( $typenow ) ) {
$the_parent = $pagenow . '?post_type=' . $typenow;
} else {
$the_parent = $pagenow;
}
$page_hook = get_plugin_page_hook( $plugin_page, $the_parent );
if ( ! $page_hook ) {
$page_hook = get_plugin_page_hook( $plugin_page, $plugin_page );
// Back-compat for plugins using add_management_page().
if ( empty( $page_hook ) && 'edit.php' === $pagenow && get_plugin_page_hook( $plugin_page, 'tools.php' ) ) {
// There could be plugin specific params on the URL, so we need the whole query string.
if ( ! empty( $_SERVER['QUERY_STRING'] ) ) {
$query_string = $_SERVER['QUERY_STRING'];
} else {
$query_string = 'page=' . $plugin_page;
}
wp_redirect( admin_url( 'tools.php?' . $query_string ) );
exit;
}
}
unset( $the_parent );
}
$hook_suffix = '';
if ( isset( $page_hook ) ) {
$hook_suffix = $page_hook;
} elseif ( isset( $plugin_page ) ) {
$hook_suffix = $plugin_page;
} elseif ( isset( $pagenow ) ) {
$hook_suffix = $pagenow;
}
set_current_screen();
// Handle plugin admin pages.
if ( isset( $plugin_page ) ) {
if ( $page_hook ) {
/**
* Fires before a particular screen is loaded.
*
* The load-* hook fires in a number of contexts. This hook is for plugin screens
* where a callback is provided when the screen is registered.
*
* The dynamic portion of the hook name, `$page_hook`, refers to a mixture of plugin
* page information including:
* 1. The page type. If the plugin page is registered as a submenu page, such as for
* Settings, the page type would be 'settings'. Otherwise the type is 'toplevel'.
* 2. A separator of '_page_'.
* 3. The plugin basename minus the file extension.
*
* Together, the three parts form the `$page_hook`. Citing the example above,
* the hook name used would be 'load-settings_page_pluginbasename'.
*
* @see get_plugin_page_hook()
*
* @since 2.1.0
*/
do_action( "load-{$page_hook}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
if ( ! isset( $_GET['noheader'] ) ) {
require_once ABSPATH . 'wp-admin/admin-header.php';
}
/**
* Used to call the registered callback for a plugin screen.
*
* This hook uses a dynamic hook name, `$page_hook`, which refers to a mixture of plugin
* page information including:
* 1. The page type. If the plugin page is registered as a submenu page, such as for
* Settings, the page type would be 'settings'. Otherwise the type is 'toplevel'.
* 2. A separator of '_page_'.
* 3. The plugin basename minus the file extension.
*
* Together, the three parts form the `$page_hook`. Citing the example above,
* the hook name used would be 'settings_page_pluginbasename'.
*
* @see get_plugin_page_hook()
*
* @since 1.5.0
*/
do_action( $page_hook );
} else {
if ( validate_file( $plugin_page ) ) {
wp_die( __( 'Invalid plugin page.' ) );
}
if ( ! ( file_exists( WP_PLUGIN_DIR . "/$plugin_page" ) && is_file( WP_PLUGIN_DIR . "/$plugin_page" ) )
&& ! ( file_exists( WPMU_PLUGIN_DIR . "/$plugin_page" ) && is_file( WPMU_PLUGIN_DIR . "/$plugin_page" ) )
) {
/* translators: %s: Admin page generated by a plugin. */
wp_die( sprintf( __( 'Cannot load %s.' ), htmlentities( $plugin_page ) ) );
}
/**
* Fires before a particular screen is loaded.
*
* The load-* hook fires in a number of contexts. This hook is for plugin screens
* where the file to load is directly included, rather than the use of a function.
*
* The dynamic portion of the hook name, `$plugin_page`, refers to the plugin basename.
*
* @see plugin_basename()
*
* @since 1.5.0
*/
do_action( "load-{$plugin_page}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
if ( ! isset( $_GET['noheader'] ) ) {
require_once ABSPATH . 'wp-admin/admin-header.php';
}
if ( file_exists( WPMU_PLUGIN_DIR . "/$plugin_page" ) ) {
include WPMU_PLUGIN_DIR . "/$plugin_page";
} else {
include WP_PLUGIN_DIR . "/$plugin_page";
}
}
require_once ABSPATH . 'wp-admin/admin-footer.php';
exit;
} elseif ( isset( $_GET['import'] ) ) {
$importer = $_GET['import'];
if ( ! current_user_can( 'import' ) ) {
wp_die( __( 'Sorry, you are not allowed to import content into this site.' ) );
}
if ( validate_file( $importer ) ) {
wp_redirect( admin_url( 'import.php?invalid=' . $importer ) );
exit;
}
if ( ! isset( $wp_importers[ $importer ] ) || ! is_callable( $wp_importers[ $importer ][2] ) ) {
wp_redirect( admin_url( 'import.php?invalid=' . $importer ) );
exit;
}
/**
* Fires before an importer screen is loaded.
*
* The dynamic portion of the hook name, `$importer`, refers to the importer slug.
*
* Possible hook names include:
*
* - `load-importer-blogger`
* - `load-importer-wpcat2tag`
* - `load-importer-livejournal`
* - `load-importer-mt`
* - `load-importer-rss`
* - `load-importer-tumblr`
* - `load-importer-wordpress`
*
* @since 3.5.0
*/
do_action( "load-importer-{$importer}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
// Used in the HTML title tag.
$title = __( 'Import' );
$parent_file = 'tools.php';
$submenu_file = 'import.php';
if ( ! isset( $_GET['noheader'] ) ) {
require_once ABSPATH . 'wp-admin/admin-header.php';
}
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
define( 'WP_IMPORTING', true );
/**
* Filters whether to filter imported data through kses on import.
*
* Multisite uses this hook to filter all data through kses by default,
* as a super administrator may be assisting an untrusted user.
*
* @since 3.1.0
*
* @param bool $force Whether to force data to be filtered through kses. Default false.
*/
if ( apply_filters( 'force_filtered_html_on_import', false ) ) {
kses_init_filters(); // Always filter imported data with kses on multisite.
}
call_user_func( $wp_importers[ $importer ][2] );
require_once ABSPATH . 'wp-admin/admin-footer.php';
// Make sure rules are flushed.
flush_rewrite_rules( false );
exit;
} else {
/**
* Fires before a particular screen is loaded.
*
* The load-* hook fires in a number of contexts. This hook is for core screens.
*
* The dynamic portion of the hook name, `$pagenow`, is a global variable
* referring to the filename of the current screen, such as 'admin.php',
* 'post-new.php' etc. A complete hook for the latter would be
* 'load-post-new.php'.
*
* @since 2.1.0
*/
do_action( "load-{$pagenow}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
/*
* The following hooks are fired to ensure backward compatibility.
* In all other cases, 'load-' . $pagenow should be used instead.
*/
if ( 'page' === $typenow ) {
if ( 'post-new.php' === $pagenow ) {
do_action( 'load-page-new.php' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
} elseif ( 'post.php' === $pagenow ) {
do_action( 'load-page.php' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
}
} elseif ( 'edit-tags.php' === $pagenow ) {
if ( 'category' === $taxnow ) {
do_action( 'load-categories.php' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
} elseif ( 'link_category' === $taxnow ) {
do_action( 'load-edit-link-categories.php' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
}
} elseif ( 'term.php' === $pagenow ) {
do_action( 'load-edit-tags.php' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
}
}
if ( ! empty( $_REQUEST['action'] ) ) {
$action = $_REQUEST['action'];
/**
* Fires when an 'action' request variable is sent.
*
* The dynamic portion of the hook name, `$action`, refers to
* the action derived from the `GET` or `POST` request.
*
* @since 2.6.0
*/
do_action( "admin_action_{$action}" );
}
upload.php 0000755 00000035547 14744541145 0006573 0 ustar 00 %2$s',
esc_url( wp_nonce_url( 'upload.php?doaction=undo&action=untrash&ids=' . ( isset( $_GET['ids'] ) ? $_GET['ids'] : '' ), 'bulk-media' ) ),
__( 'Undo' )
);
$_SERVER['REQUEST_URI'] = remove_query_arg( array( 'trashed' ), $_SERVER['REQUEST_URI'] );
unset( $_GET['trashed'] );
}
if ( ! empty( $_GET['untrashed'] ) && absint( $_GET['untrashed'] ) ) {
$untrashed = absint( $_GET['untrashed'] );
if ( 1 === $untrashed ) {
$message = __( 'Media file restored from the Trash.' );
} else {
$message = sprintf(
/* translators: %s: Number of media files. */
_n( '%s media file restored from the Trash.', '%s media files restored from the Trash.', $untrashed ),
number_format_i18n( $untrashed )
);
}
$_SERVER['REQUEST_URI'] = remove_query_arg( array( 'untrashed' ), $_SERVER['REQUEST_URI'] );
unset( $_GET['untrashed'] );
}
$messages[1] = __( 'Media file updated.' );
$messages[2] = __( 'Media file permanently deleted.' );
$messages[3] = __( 'Error saving media file.' );
$messages[4] = __( 'Media file moved to the Trash.' ) . sprintf(
' %2$s',
esc_url( wp_nonce_url( 'upload.php?doaction=undo&action=untrash&ids=' . ( isset( $_GET['ids'] ) ? $_GET['ids'] : '' ), 'bulk-media' ) ),
__( 'Undo' )
);
$messages[5] = __( 'Media file restored from the Trash.' );
if ( ! empty( $_GET['message'] ) && isset( $messages[ $_GET['message'] ] ) ) {
$message = $messages[ $_GET['message'] ];
$_SERVER['REQUEST_URI'] = remove_query_arg( array( 'message' ), $_SERVER['REQUEST_URI'] );
}
$modes = array( 'grid', 'list' );
if ( isset( $_GET['mode'] ) && in_array( $_GET['mode'], $modes, true ) ) {
$mode = $_GET['mode'];
update_user_option( get_current_user_id(), 'media_library_mode', $mode );
} else {
$mode = get_user_option( 'media_library_mode', get_current_user_id() ) ? get_user_option( 'media_library_mode', get_current_user_id() ) : 'grid';
}
if ( 'grid' === $mode ) {
wp_enqueue_media();
wp_enqueue_script( 'media-grid' );
wp_enqueue_script( 'media' );
// Remove the error parameter added by deprecation of wp-admin/media.php.
add_filter(
'removable_query_args',
function () {
return array( 'error' );
},
10,
0
);
$q = $_GET;
// Let JS handle this.
unset( $q['s'] );
$vars = wp_edit_attachments_query_vars( $q );
$ignore = array( 'mode', 'post_type', 'post_status', 'posts_per_page' );
foreach ( $vars as $key => $value ) {
if ( ! $value || in_array( $key, $ignore, true ) ) {
unset( $vars[ $key ] );
}
}
wp_localize_script(
'media-grid',
'_wpMediaGridSettings',
array(
'adminUrl' => parse_url( self_admin_url(), PHP_URL_PATH ),
'queryVars' => (object) $vars,
)
);
get_current_screen()->add_help_tab(
array(
'id' => 'overview',
'title' => __( 'Overview' ),
'content' =>
'' . __( 'All the files you’ve uploaded are listed in the Media Library, with the most recent uploads listed first.' ) . '
' .
'' . __( 'You can view your media in a simple visual grid or a list with columns. Switch between these views using the icons to the left above the media.' ) . '
' .
'' . __( 'To delete media items, click the Bulk Select button at the top of the screen. Select any items you wish to delete, then click the Delete Selected button. Clicking the Cancel Selection button takes you back to viewing your media.' ) . '
',
)
);
get_current_screen()->add_help_tab(
array(
'id' => 'attachment-details',
'title' => __( 'Attachment Details' ),
'content' =>
'' . __( 'Clicking an item will display an Attachment Details dialog, which allows you to preview media and make quick edits. Any changes you make to the attachment details will be automatically saved.' ) . '
' .
'' . __( 'Use the arrow buttons at the top of the dialog, or the left and right arrow keys on your keyboard, to navigate between media items quickly.' ) . '
' .
'' . __( 'You can also delete individual items and access the extended edit screen from the details dialog.' ) . '
',
)
);
get_current_screen()->set_help_sidebar(
'' . __( 'For more information:' ) . '
' .
'' . __( 'Documentation on Media Library' ) . '
' .
'' . __( 'Support forums' ) . '
'
);
// Used in the HTML title tag.
$title = __( 'Media Library' );
$parent_file = 'upload.php';
require_once ABSPATH . 'wp-admin/admin-header.php';
?>
get_pagenum();
// Handle bulk actions.
$doaction = $wp_list_table->current_action();
if ( $doaction ) {
check_admin_referer( 'bulk-media' );
$post_ids = array();
if ( 'delete_all' === $doaction ) {
$post_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type='attachment' AND post_status = 'trash'" );
$doaction = 'delete';
} elseif ( isset( $_REQUEST['media'] ) ) {
$post_ids = $_REQUEST['media'];
} elseif ( isset( $_REQUEST['ids'] ) ) {
$post_ids = explode( ',', $_REQUEST['ids'] );
}
$post_ids = array_map( 'intval', (array) $post_ids );
$location = 'upload.php';
$referer = wp_get_referer();
if ( $referer ) {
if ( str_contains( $referer, 'upload.php' ) ) {
$location = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'message', 'ids', 'posted' ), $referer );
}
}
switch ( $doaction ) {
case 'detach':
wp_media_attach_action( $_REQUEST['parent_post_id'], 'detach' );
break;
case 'attach':
wp_media_attach_action( $_REQUEST['found_post_id'] );
break;
case 'trash':
if ( empty( $post_ids ) ) {
break;
}
foreach ( $post_ids as $post_id ) {
if ( ! current_user_can( 'delete_post', $post_id ) ) {
wp_die( __( 'Sorry, you are not allowed to move this item to the Trash.' ) );
}
if ( ! wp_trash_post( $post_id ) ) {
wp_die( __( 'Error in moving the item to Trash.' ) );
}
}
$location = add_query_arg(
array(
'trashed' => count( $post_ids ),
'ids' => implode( ',', $post_ids ),
),
$location
);
break;
case 'untrash':
if ( empty( $post_ids ) ) {
break;
}
foreach ( $post_ids as $post_id ) {
if ( ! current_user_can( 'delete_post', $post_id ) ) {
wp_die( __( 'Sorry, you are not allowed to restore this item from the Trash.' ) );
}
if ( ! wp_untrash_post( $post_id ) ) {
wp_die( __( 'Error in restoring the item from Trash.' ) );
}
}
$location = add_query_arg( 'untrashed', count( $post_ids ), $location );
break;
case 'delete':
if ( empty( $post_ids ) ) {
break;
}
foreach ( $post_ids as $post_id_del ) {
if ( ! current_user_can( 'delete_post', $post_id_del ) ) {
wp_die( __( 'Sorry, you are not allowed to delete this item.' ) );
}
if ( ! wp_delete_attachment( $post_id_del ) ) {
wp_die( __( 'Error in deleting the attachment.' ) );
}
}
$location = add_query_arg( 'deleted', count( $post_ids ), $location );
break;
default:
$screen = get_current_screen()->id;
/** This action is documented in wp-admin/edit.php */
$location = apply_filters( "handle_bulk_actions-{$screen}", $location, $doaction, $post_ids ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
}
wp_redirect( $location );
exit;
} elseif ( ! empty( $_GET['_wp_http_referer'] ) ) {
wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), wp_unslash( $_SERVER['REQUEST_URI'] ) ) );
exit;
}
$wp_list_table->prepare_items();
// Used in the HTML title tag.
$title = __( 'Media Library' );
$parent_file = 'upload.php';
wp_enqueue_script( 'media' );
add_screen_option( 'per_page' );
get_current_screen()->add_help_tab(
array(
'id' => 'overview',
'title' => __( 'Overview' ),
'content' =>
'' . __( 'All the files you’ve uploaded are listed in the Media Library, with the most recent uploads listed first. You can use the Screen Options tab to customize the display of this screen.' ) . '
' .
'' . __( 'You can narrow the list by file type/status or by date using the dropdown menus above the media table.' ) . '
' .
'' . __( 'You can view your media in a simple visual grid or a list with columns. Switch between these views using the icons to the left above the media.' ) . '
',
)
);
get_current_screen()->add_help_tab(
array(
'id' => 'actions-links',
'title' => __( 'Available Actions' ),
'content' =>
'' . __( 'Hovering over a row reveals action links that allow you to manage media items. You can perform the following actions:' ) . '
' .
'' .
'- ' . __( 'Edit takes you to a simple screen to edit that individual file’s metadata. You can also reach that screen by clicking on the media file name or thumbnail.' ) . '
' .
'- ' . __( 'Delete Permanently will delete the file from the media library (as well as from any posts to which it is currently attached).' ) . '
' .
'- ' . __( 'View will take you to a public display page for that file.' ) . '
' .
'- ' . __( 'Copy URL copies the URL for the media file to your clipboard.' ) . '
' .
'- ' . __( 'Download file downloads the original media file to your device.' ) . '
' .
'
',
)
);
get_current_screen()->add_help_tab(
array(
'id' => 'attaching-files',
'title' => __( 'Attaching Files' ),
'content' =>
'' . __( 'If a media file has not been attached to any content, you will see that in the Uploaded To column, and can click on Attach to launch a small popup that will allow you to search for existing content and attach the file.' ) . '
',
)
);
get_current_screen()->set_help_sidebar(
'' . __( 'For more information:' ) . '
' .
'' . __( 'Documentation on Media Library' ) . '
' .
'' . __( 'Support forums' ) . '
'
);
get_current_screen()->set_screen_reader_content(
array(
'heading_views' => __( 'Filter media items list' ),
'heading_pagination' => __( 'Media items list navigation' ),
'heading_list' => __( 'Media items list' ),
)
);
require_once ABSPATH . 'wp-admin/admin-header.php';
?>
';
printf(
/* translators: %s: Search query. */
__( 'Search results for: %s' ),
'
' . get_search_query() . ''
);
echo '';
}
?>
'message',
'additional_classes' => array( 'updated' ),
'dismissible' => true,
)
);
}
?>
ID ) );
}
if ( ! $user_id && IS_PROFILE_PAGE ) {
$user_id = $current_user->ID;
} elseif ( ! $user_id && ! IS_PROFILE_PAGE ) {
wp_die( __( 'Invalid user ID.' ) );
} elseif ( ! get_userdata( $user_id ) ) {
wp_die( __( 'Invalid user ID.' ) );
}
wp_enqueue_script( 'user-profile' );
if ( wp_is_application_passwords_available_for_user( $user_id ) ) {
wp_enqueue_script( 'application-passwords' );
}
if ( IS_PROFILE_PAGE ) {
// Used in the HTML title tag.
$title = __( 'Profile' );
} else {
// Used in the HTML title tag.
/* translators: %s: User's display name. */
$title = __( 'Edit User %s' );
}
if ( current_user_can( 'edit_users' ) && ! IS_PROFILE_PAGE ) {
$submenu_file = 'users.php';
} else {
$submenu_file = 'profile.php';
}
if ( current_user_can( 'edit_users' ) && ! is_user_admin() ) {
$parent_file = 'users.php';
} else {
$parent_file = 'profile.php';
}
$profile_help = '' . __( 'Your profile contains information about you (your “account”) as well as some personal options related to using WordPress.' ) . '
' .
'' . __( 'You can change your password, turn on keyboard shortcuts, change the color scheme of your WordPress administration screens, and turn off the WYSIWYG (Visual) editor, among other things. You can hide the Toolbar (formerly called the Admin Bar) from the front end of your site, however it cannot be disabled on the admin screens.' ) . '
' .
'' . __( 'You can select the language you wish to use while using the WordPress administration screen without affecting the language site visitors see.' ) . '
' .
'' . __( 'Your username cannot be changed, but you can use other fields to enter your real name or a nickname, and change which name to display on your posts.' ) . '
' .
'' . __( 'You can log out of other devices, such as your phone or a public computer, by clicking the Log Out Everywhere Else button.' ) . '
' .
'' . __( 'Required fields are indicated; the rest are optional. Profile information will only be displayed if your theme is set up to do so.' ) . '
' .
'' . __( 'Remember to click the Update Profile button when you are finished.' ) . '
';
get_current_screen()->add_help_tab(
array(
'id' => 'overview',
'title' => __( 'Overview' ),
'content' => $profile_help,
)
);
get_current_screen()->set_help_sidebar(
'' . __( 'For more information:' ) . '
' .
'' . __( 'Documentation on User Profiles' ) . '
' .
'' . __( 'Support forums' ) . '
'
);
$wp_http_referer = remove_query_arg( array( 'update', 'delete_count', 'user_id' ), $wp_http_referer );
$user_can_edit = current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' );
/**
* Filters whether to allow administrators on Multisite to edit every user.
*
* Enabling the user editing form via this filter also hinges on the user holding
* the 'manage_network_users' cap, and the logged-in user not matching the user
* profile open for editing.
*
* The filter was introduced to replace the EDIT_ANY_USER constant.
*
* @since 3.0.0
*
* @param bool $allow Whether to allow editing of any user. Default true.
*/
if ( is_multisite()
&& ! current_user_can( 'manage_network_users' )
&& $user_id !== $current_user->ID
&& ! apply_filters( 'enable_edit_any_user_configuration', true )
) {
wp_die( __( 'Sorry, you are not allowed to edit this user.' ) );
}
// Execute confirmed email change. See send_confirmation_on_profile_email().
if ( IS_PROFILE_PAGE && isset( $_GET['newuseremail'] ) && $current_user->ID ) {
$new_email = get_user_meta( $current_user->ID, '_new_email', true );
if ( $new_email && hash_equals( $new_email['hash'], $_GET['newuseremail'] ) ) {
$user = new stdClass();
$user->ID = $current_user->ID;
$user->user_email = esc_html( trim( $new_email['newemail'] ) );
if ( is_multisite() && $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $current_user->user_login ) ) ) {
$wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $user->user_email, $current_user->user_login ) );
}
wp_update_user( $user );
delete_user_meta( $current_user->ID, '_new_email' );
wp_redirect( add_query_arg( array( 'updated' => 'true' ), self_admin_url( 'profile.php' ) ) );
die();
} else {
wp_redirect( add_query_arg( array( 'error' => 'new-email' ), self_admin_url( 'profile.php' ) ) );
}
} elseif ( IS_PROFILE_PAGE && ! empty( $_GET['dismiss'] ) && $current_user->ID . '_new_email' === $_GET['dismiss'] ) {
check_admin_referer( 'dismiss-' . $current_user->ID . '_new_email' );
delete_user_meta( $current_user->ID, '_new_email' );
wp_redirect( add_query_arg( array( 'updated' => 'true' ), self_admin_url( 'profile.php' ) ) );
die();
}
switch ( $action ) {
case 'update':
check_admin_referer( 'update-user_' . $user_id );
if ( ! current_user_can( 'edit_user', $user_id ) ) {
wp_die( __( 'Sorry, you are not allowed to edit this user.' ) );
}
if ( IS_PROFILE_PAGE ) {
/**
* Fires before the page loads on the 'Profile' editing screen.
*
* The action only fires if the current user is editing their own profile.
*
* @since 2.0.0
*
* @param int $user_id The user ID.
*/
do_action( 'personal_options_update', $user_id );
} else {
/**
* Fires before the page loads on the 'Edit User' screen.
*
* @since 2.7.0
*
* @param int $user_id The user ID.
*/
do_action( 'edit_user_profile_update', $user_id );
}
// Update the email address in signups, if present.
if ( is_multisite() ) {
$user = get_userdata( $user_id );
if ( $user->user_login && isset( $_POST['email'] ) && is_email( $_POST['email'] ) && $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $user->user_login ) ) ) {
$wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $_POST['email'], $user_login ) );
}
}
// Update the user.
$errors = edit_user( $user_id );
// Grant or revoke super admin status if requested.
if ( is_multisite() && is_network_admin()
&& ! IS_PROFILE_PAGE && current_user_can( 'manage_network_options' )
&& ! isset( $super_admins ) && empty( $_POST['super_admin'] ) === is_super_admin( $user_id )
) {
empty( $_POST['super_admin'] ) ? revoke_super_admin( $user_id ) : grant_super_admin( $user_id );
}
if ( ! is_wp_error( $errors ) ) {
$redirect = add_query_arg( 'updated', true, get_edit_user_link( $user_id ) );
if ( $wp_http_referer ) {
$redirect = add_query_arg( 'wp_http_referer', urlencode( $wp_http_referer ), $redirect );
}
wp_redirect( $redirect );
exit;
}
// Intentional fall-through to display $errors.
default:
$profile_user = get_user_to_edit( $user_id );
if ( ! current_user_can( 'edit_user', $user_id ) ) {
wp_die( __( 'Sorry, you are not allowed to edit this user.' ) );
}
$title = sprintf( $title, $profile_user->display_name );
$sessions = WP_Session_Tokens::get_instance( $profile_user->ID );
require_once ABSPATH . 'wp-admin/admin-header.php';
?>
ID ) && current_user_can( 'manage_network_options' ) ) :
$message = '' . __( 'Important:' ) . ' ' . __( 'This user has super admin privileges.' );
wp_admin_notice(
$message,
array(
'type' => 'info',
)
);
endif;
if ( isset( $_GET['updated'] ) ) :
if ( IS_PROFILE_PAGE ) :
$message = '' . __( 'Profile updated.' ) . '
';
else :
$message = '' . __( 'User updated.' ) . '
';
endif;
if ( $wp_http_referer && ! str_contains( $wp_http_referer, 'user-new.php' ) && ! IS_PROFILE_PAGE ) :
$message .= sprintf(
'%2$s
',
esc_url( wp_validate_redirect( sanitize_url( $wp_http_referer ), self_admin_url( 'users.php' ) ) ),
__( '← Go to Users' )
);
endif;
wp_admin_notice(
$message,
array(
'id' => 'message',
'dismissible' => true,
'additional_classes' => array( 'updated' ),
'paragraph_wrap' => false,
)
);
endif;
if ( isset( $_GET['error'] ) ) :
$message = '';
if ( 'new-email' === $_GET['error'] ) :
$message = __( 'Error while saving the new email address. Please try again.' );
endif;
wp_admin_notice(
$message,
array(
'type' => 'error',
)
);
endif;
if ( isset( $errors ) && is_wp_error( $errors ) ) {
wp_admin_notice(
implode( "\n", $errors->get_error_messages() ),
array(
'additional_classes' => array( 'error' ),
)
);
}
?>
get_pagenum();
$action = $wp_list_table->current_action();
$plugin = isset( $_REQUEST['plugin'] ) ? wp_unslash( $_REQUEST['plugin'] ) : '';
$s = isset( $_REQUEST['s'] ) ? urlencode( wp_unslash( $_REQUEST['s'] ) ) : '';
// Clean up request URI from temporary args for screen options/paging uri's to work as expected.
$query_args_to_remove = array(
'error',
'deleted',
'activate',
'activate-multi',
'deactivate',
'deactivate-multi',
'enabled-auto-update',
'disabled-auto-update',
'enabled-auto-update-multi',
'disabled-auto-update-multi',
'_error_nonce',
);
$_SERVER['REQUEST_URI'] = remove_query_arg( $query_args_to_remove, $_SERVER['REQUEST_URI'] );
wp_enqueue_script( 'updates' );
WP_Plugin_Dependencies::initialize();
if ( $action ) {
switch ( $action ) {
case 'activate':
if ( ! current_user_can( 'activate_plugin', $plugin ) ) {
wp_die( __( 'Sorry, you are not allowed to activate this plugin.' ) );
}
if ( is_multisite() && ! is_network_admin() && is_network_only_plugin( $plugin ) ) {
wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) );
exit;
}
check_admin_referer( 'activate-plugin_' . $plugin );
$result = activate_plugin( $plugin, self_admin_url( 'plugins.php?error=true&plugin=' . urlencode( $plugin ) ), is_network_admin() );
if ( is_wp_error( $result ) ) {
if ( 'unexpected_output' === $result->get_error_code() ) {
$redirect = self_admin_url( 'plugins.php?error=true&charsout=' . strlen( $result->get_error_data() ) . '&plugin=' . urlencode( $plugin ) . "&plugin_status=$status&paged=$page&s=$s" );
wp_redirect( add_query_arg( '_error_nonce', wp_create_nonce( 'plugin-activation-error_' . $plugin ), $redirect ) );
exit;
} else {
wp_die( $result );
}
}
if ( ! is_network_admin() ) {
$recent = (array) get_option( 'recently_activated' );
unset( $recent[ $plugin ] );
update_option( 'recently_activated', $recent, false );
} else {
$recent = (array) get_site_option( 'recently_activated' );
unset( $recent[ $plugin ] );
update_site_option( 'recently_activated', $recent );
}
if ( isset( $_GET['from'] ) && 'import' === $_GET['from'] ) {
// Overrides the ?error=true one above and redirects to the Imports page, stripping the -importer suffix.
wp_redirect( self_admin_url( 'import.php?import=' . str_replace( '-importer', '', dirname( $plugin ) ) ) );
} elseif ( isset( $_GET['from'] ) && 'press-this' === $_GET['from'] ) {
wp_redirect( self_admin_url( 'press-this.php' ) );
} else {
// Overrides the ?error=true one above.
wp_redirect( self_admin_url( "plugins.php?activate=true&plugin_status=$status&paged=$page&s=$s" ) );
}
exit;
case 'activate-selected':
if ( ! current_user_can( 'activate_plugins' ) ) {
wp_die( __( 'Sorry, you are not allowed to activate plugins for this site.' ) );
}
check_admin_referer( 'bulk-plugins' );
$plugins = isset( $_POST['checked'] ) ? (array) wp_unslash( $_POST['checked'] ) : array();
if ( is_network_admin() ) {
foreach ( $plugins as $i => $plugin ) {
// Only activate plugins which are not already network activated.
if ( is_plugin_active_for_network( $plugin ) ) {
unset( $plugins[ $i ] );
}
}
} else {
foreach ( $plugins as $i => $plugin ) {
// Only activate plugins which are not already active and are not network-only when on Multisite.
if ( is_plugin_active( $plugin ) || ( is_multisite() && is_network_only_plugin( $plugin ) ) ) {
unset( $plugins[ $i ] );
}
// Only activate plugins which the user can activate.
if ( ! current_user_can( 'activate_plugin', $plugin ) ) {
unset( $plugins[ $i ] );
}
}
}
if ( empty( $plugins ) ) {
wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) );
exit;
}
activate_plugins( $plugins, self_admin_url( 'plugins.php?error=true' ), is_network_admin() );
if ( ! is_network_admin() ) {
$recent = (array) get_option( 'recently_activated' );
} else {
$recent = (array) get_site_option( 'recently_activated' );
}
foreach ( $plugins as $plugin ) {
unset( $recent[ $plugin ] );
}
if ( ! is_network_admin() ) {
update_option( 'recently_activated', $recent, false );
} else {
update_site_option( 'recently_activated', $recent );
}
wp_redirect( self_admin_url( "plugins.php?activate-multi=true&plugin_status=$status&paged=$page&s=$s" ) );
exit;
case 'update-selected':
check_admin_referer( 'bulk-plugins' );
if ( isset( $_GET['plugins'] ) ) {
$plugins = explode( ',', wp_unslash( $_GET['plugins'] ) );
} elseif ( isset( $_POST['checked'] ) ) {
$plugins = (array) wp_unslash( $_POST['checked'] );
} else {
$plugins = array();
}
// Used in the HTML title tag.
$title = __( 'Update Plugins' );
$parent_file = 'plugins.php';
wp_enqueue_script( 'updates' );
require_once ABSPATH . 'wp-admin/admin-header.php';
echo '';
echo '
' . esc_html( $title ) . '
';
$url = self_admin_url( 'update.php?action=update-selected&plugins=' . urlencode( implode( ',', $plugins ) ) );
$url = wp_nonce_url( $url, 'bulk-update-plugins' );
echo "";
echo '';
require_once ABSPATH . 'wp-admin/admin-footer.php';
exit;
case 'error_scrape':
if ( ! current_user_can( 'activate_plugin', $plugin ) ) {
wp_die( __( 'Sorry, you are not allowed to activate this plugin.' ) );
}
check_admin_referer( 'plugin-activation-error_' . $plugin );
$valid = validate_plugin( $plugin );
if ( is_wp_error( $valid ) ) {
wp_die( $valid );
}
if ( ! WP_DEBUG ) {
error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR );
}
ini_set( 'display_errors', true ); // Ensure that fatal errors are displayed.
// Go back to "sandbox" scope so we get the same errors as before.
plugin_sandbox_scrape( $plugin );
/** This action is documented in wp-admin/includes/plugin.php */
do_action( "activate_{$plugin}" );
exit;
case 'deactivate':
if ( ! current_user_can( 'deactivate_plugin', $plugin ) ) {
wp_die( __( 'Sorry, you are not allowed to deactivate this plugin.' ) );
}
check_admin_referer( 'deactivate-plugin_' . $plugin );
if ( ! is_network_admin() && is_plugin_active_for_network( $plugin ) ) {
wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) );
exit;
}
deactivate_plugins( $plugin, false, is_network_admin() );
if ( ! is_network_admin() ) {
update_option( 'recently_activated', array( $plugin => time() ) + (array) get_option( 'recently_activated' ), false );
} else {
update_site_option( 'recently_activated', array( $plugin => time() ) + (array) get_site_option( 'recently_activated' ) );
}
if ( headers_sent() ) {
echo "";
} else {
wp_redirect( self_admin_url( "plugins.php?deactivate=true&plugin_status=$status&paged=$page&s=$s" ) );
}
exit;
case 'deactivate-selected':
if ( ! current_user_can( 'deactivate_plugins' ) ) {
wp_die( __( 'Sorry, you are not allowed to deactivate plugins for this site.' ) );
}
check_admin_referer( 'bulk-plugins' );
$plugins = isset( $_POST['checked'] ) ? (array) wp_unslash( $_POST['checked'] ) : array();
// Do not deactivate plugins which are already deactivated.
if ( is_network_admin() ) {
$plugins = array_filter( $plugins, 'is_plugin_active_for_network' );
} else {
$plugins = array_filter( $plugins, 'is_plugin_active' );
$plugins = array_diff( $plugins, array_filter( $plugins, 'is_plugin_active_for_network' ) );
foreach ( $plugins as $i => $plugin ) {
// Only deactivate plugins which the user can deactivate.
if ( ! current_user_can( 'deactivate_plugin', $plugin ) ) {
unset( $plugins[ $i ] );
}
}
}
if ( empty( $plugins ) ) {
wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) );
exit;
}
deactivate_plugins( $plugins, false, is_network_admin() );
$deactivated = array();
foreach ( $plugins as $plugin ) {
$deactivated[ $plugin ] = time();
}
if ( ! is_network_admin() ) {
update_option( 'recently_activated', $deactivated + (array) get_option( 'recently_activated' ), false );
} else {
update_site_option( 'recently_activated', $deactivated + (array) get_site_option( 'recently_activated' ) );
}
wp_redirect( self_admin_url( "plugins.php?deactivate-multi=true&plugin_status=$status&paged=$page&s=$s" ) );
exit;
case 'delete-selected':
if ( ! current_user_can( 'delete_plugins' ) ) {
wp_die( __( 'Sorry, you are not allowed to delete plugins for this site.' ) );
}
check_admin_referer( 'bulk-plugins' );
// $_POST = from the plugin form; $_GET = from the FTP details screen.
$plugins = isset( $_REQUEST['checked'] ) ? (array) wp_unslash( $_REQUEST['checked'] ) : array();
if ( empty( $plugins ) ) {
wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) );
exit;
}
$plugins = array_filter( $plugins, 'is_plugin_inactive' ); // Do not allow to delete activated plugins.
if ( empty( $plugins ) ) {
wp_redirect( self_admin_url( "plugins.php?error=true&main=true&plugin_status=$status&paged=$page&s=$s" ) );
exit;
}
// Bail on all if any paths are invalid.
// validate_file() returns truthy for invalid files.
$invalid_plugin_files = array_filter( $plugins, 'validate_file' );
if ( $invalid_plugin_files ) {
wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) );
exit;
}
require ABSPATH . 'wp-admin/update.php';
$parent_file = 'plugins.php';
if ( ! isset( $_REQUEST['verify-delete'] ) ) {
wp_enqueue_script( 'jquery' );
require_once ABSPATH . 'wp-admin/admin-header.php';
?>
$data ) {
$plugin_info[ $plugin_file ] = _get_plugin_data_markup_translate( $plugin_file, $data );
$plugin_info[ $plugin_file ]['is_uninstallable'] = is_uninstallable_plugin( $plugin );
if ( ! $plugin_info[ $plugin_file ]['Network'] ) {
$have_non_network_plugins = true;
}
}
}
}
}
$plugins_to_delete = count( $plugin_info );
?>
' . __( 'Caution:' ) . ' ' . __( 'This plugin may be active on other sites in the network.' );
wp_admin_notice(
$maybe_active_plugin,
array(
'additional_classes' => array( 'error' ),
)
);
endif;
?>
' . __( 'Caution:' ) . ' ' . __( 'These plugins may be active on other sites in the network.' );
wp_admin_notice(
$maybe_active_plugins,
array(
'additional_classes' => array( 'error' ),
)
);
endif;
?>
', sprintf( __( '%1$s by %2$s (will also delete its data)' ), '' . $plugin['Name'] . '', '' . $plugin['AuthorName'] . '' ), '';
$data_to_delete = true;
} else {
/* translators: 1: Plugin name, 2: Plugin author. */
echo '- ', sprintf( _x( '%1$s by %2$s', 'plugin' ), '' . $plugin['Name'] . '', '' . $plugin['AuthorName'] ) . '', '
';
}
}
?>
'true' ), $redirect );
} elseif ( 'disable-auto-update' === $action ) {
$auto_updates = array_diff( $auto_updates, array( $plugin ) );
$redirect = add_query_arg( array( 'disabled-auto-update' => 'true' ), $redirect );
} else {
$plugins = (array) wp_unslash( $_POST['checked'] );
if ( 'enable-auto-update-selected' === $action ) {
$new_auto_updates = array_merge( $auto_updates, $plugins );
$new_auto_updates = array_unique( $new_auto_updates );
$query_args = array( 'enabled-auto-update-multi' => 'true' );
} else {
$new_auto_updates = array_diff( $auto_updates, $plugins );
$query_args = array( 'disabled-auto-update-multi' => 'true' );
}
// Return early if all selected plugins already have auto-updates enabled or disabled.
// Must use non-strict comparison, so that array order is not treated as significant.
if ( $new_auto_updates == $auto_updates ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual
wp_redirect( $redirect );
exit;
}
$auto_updates = $new_auto_updates;
$redirect = add_query_arg( $query_args, $redirect );
}
/** This filter is documented in wp-admin/includes/class-wp-plugins-list-table.php */
$all_items = apply_filters( 'all_plugins', get_plugins() );
// Remove plugins that don't exist or have been deleted since the option was last updated.
$auto_updates = array_intersect( $auto_updates, array_keys( $all_items ) );
update_site_option( 'auto_update_plugins', $auto_updates );
wp_redirect( $redirect );
exit;
default:
if ( isset( $_POST['checked'] ) ) {
check_admin_referer( 'bulk-plugins' );
$screen = get_current_screen()->id;
$sendback = wp_get_referer();
$plugins = isset( $_POST['checked'] ) ? (array) wp_unslash( $_POST['checked'] ) : array();
/** This action is documented in wp-admin/edit.php */
$sendback = apply_filters( "handle_bulk_actions-{$screen}", $sendback, $action, $plugins ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
wp_safe_redirect( $sendback );
exit;
}
break;
}
}
$wp_list_table->prepare_items();
wp_enqueue_script( 'plugin-install' );
add_thickbox();
add_screen_option( 'per_page', array( 'default' => 999 ) );
get_current_screen()->add_help_tab(
array(
'id' => 'overview',
'title' => __( 'Overview' ),
'content' =>
'' . __( 'Plugins extend and expand the functionality of WordPress. Once a plugin is installed, you may activate it or deactivate it here.' ) . '
' .
'' . __( 'The search for installed plugins will search for terms in their name, description, or author.' ) . ' ' . __( 'The search results will be updated as you type.' ) . '
' .
'' . sprintf(
/* translators: %s: WordPress Plugin Directory URL. */
__( 'If you would like to see more plugins to choose from, click on the “Add New Plugin” button and you will be able to browse or search for additional plugins from the WordPress Plugin Directory. Plugins in the WordPress Plugin Directory are designed and developed by third parties, and are compatible with the license WordPress uses. Oh, and they are free!' ),
__( 'https://wordpress.org/plugins/' )
) . '
',
)
);
get_current_screen()->add_help_tab(
array(
'id' => 'compatibility-problems',
'title' => __( 'Troubleshooting' ),
'content' =>
'' . __( 'Most of the time, plugins play nicely with the core of WordPress and with other plugins. Sometimes, though, a plugin’s code will get in the way of another plugin, causing compatibility issues. If your site starts doing strange things, this may be the problem. Try deactivating all your plugins and re-activating them in various combinations until you isolate which one(s) caused the issue.' ) . '
' .
'' . sprintf(
/* translators: %s: WP_PLUGIN_DIR constant value. */
__( 'If something goes wrong with a plugin and you cannot use WordPress, delete or rename that file in the %s directory and it will be automatically deactivated.' ),
'' . WP_PLUGIN_DIR . '
'
) . '
',
)
);
$help_sidebar_autoupdates = '';
if ( current_user_can( 'update_plugins' ) && wp_is_auto_update_enabled_for_type( 'plugin' ) ) {
get_current_screen()->add_help_tab(
array(
'id' => 'plugins-themes-auto-updates',
'title' => __( 'Auto-updates' ),
'content' =>
'' . __( 'Auto-updates can be enabled or disabled for each individual plugin. Plugins with auto-updates enabled will display the estimated date of the next auto-update. Auto-updates depends on the WP-Cron task scheduling system.' ) . '
' .
'' . __( 'Auto-updates are only available for plugins recognized by WordPress.org, or that include a compatible update system.' ) . '
' .
'' . __( 'Please note: Third-party themes and plugins, or custom code, may override WordPress scheduling.' ) . '
',
)
);
$help_sidebar_autoupdates = '' . __( 'Documentation on Auto-updates' ) . '
';
}
if ( current_user_can( 'install_plugins' ) ) {
get_current_screen()->add_help_tab(
array(
'id' => 'plugins-dependencies',
'title' => __( 'Dependencies' ),
'content' =>
'' . __( 'Plugin Dependencies aims to make the process of installing and activating add-ons (dependents) and the plugins they rely on (dependencies) consistent and easy.' ) . '
' .
'' . __( 'If a required plugin is deleted, a notice will be displayed on the Plugin administration screen informing the user that there is some missing dependencies to install and/or activate. Additionally, each plugin whose dependencies are not met will have an error notice on their plugin row.' ) . '
' .
'' . __( 'If a dependent plugin is missing some dependencies, its activation button will be disabled until the required dependencies are activated.' ) . '
',
)
);
}
get_current_screen()->set_help_sidebar(
'' . __( 'For more information:' ) . '
' .
'' . __( 'Documentation on Managing Plugins' ) . '
' .
$help_sidebar_autoupdates .
'' . __( 'Support forums' ) . '
'
);
get_current_screen()->set_screen_reader_content(
array(
'heading_views' => __( 'Filter plugins list' ),
'heading_pagination' => __( 'Plugins list navigation' ),
'heading_list' => __( 'Plugins list' ),
)
);
// Used in the HTML title tag.
$title = __( 'Plugins' );
$parent_file = 'plugins.php';
require_once ABSPATH . 'wp-admin/admin-header.php';
$invalid = validate_active_plugins();
if ( ! empty( $invalid ) ) {
foreach ( $invalid as $plugin_file => $error ) {
$deactivated_message = sprintf(
/* translators: 1: Plugin file, 2: Error message. */
__( 'The plugin %1$s has been deactivated due to an error: %2$s' ),
'' . esc_html( $plugin_file ) . '
',
esc_html( $error->get_error_message() )
);
wp_admin_notice(
$deactivated_message,
array(
'id' => 'message',
'additional_classes' => array( 'error' ),
)
);
}
}
// Used by wp_admin_notice() updated notices.
$updated_notice_args = array(
'id' => 'message',
'additional_classes' => array( 'updated' ),
'dismissible' => true,
);
if ( isset( $_GET['error'] ) ) {
if ( isset( $_GET['main'] ) ) {
$errmsg = __( 'You cannot delete a plugin while it is active on the main site.' );
} elseif ( isset( $_GET['charsout'] ) ) {
$errmsg = sprintf(
/* translators: %d: Number of characters. */
_n(
'The plugin generated %d character of unexpected output during activation.',
'The plugin generated %d characters of unexpected output during activation.',
$_GET['charsout']
),
$_GET['charsout']
);
$errmsg .= ' ' . __( 'If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.' );
} elseif ( 'resuming' === $_GET['error'] ) {
$errmsg = __( 'Plugin could not be resumed because it triggered a fatal error.' );
} else {
$errmsg = __( 'Plugin could not be activated because it triggered a fatal error.' );
}
if ( ! isset( $_GET['main'] ) && ! isset( $_GET['charsout'] )
&& isset( $_GET['_error_nonce'] ) && wp_verify_nonce( $_GET['_error_nonce'], 'plugin-activation-error_' . $plugin )
) {
$iframe_url = add_query_arg(
array(
'action' => 'error_scrape',
'plugin' => urlencode( $plugin ),
'_wpnonce' => urlencode( $_GET['_error_nonce'] ),
),
admin_url( 'plugins.php' )
);
$errmsg .= '';
}
wp_admin_notice(
$errmsg,
array(
'id' => 'message',
'additional_classes' => array( 'error' ),
)
);
} elseif ( isset( $_GET['deleted'] ) ) {
$delete_result = get_option( 'plugins_delete_result_' . $user_ID );
// Delete it once we're done.
delete_option( 'plugins_delete_result_' . $user_ID );
if ( is_wp_error( $delete_result ) ) {
$plugin_not_deleted_message = sprintf(
/* translators: %s: Error message. */
__( 'Plugin could not be deleted due to an error: %s' ),
esc_html( $delete_result->get_error_message() )
);
wp_admin_notice(
$plugin_not_deleted_message,
array(
'id' => 'message',
'additional_classes' => array( 'error' ),
'dismissible' => true,
)
);
} else {
if ( 1 === (int) $_GET['deleted'] ) {
$plugins_deleted_message = __( 'The selected plugin has been deleted.' );
} else {
$plugins_deleted_message = __( 'The selected plugins have been deleted.' );
}
wp_admin_notice( $plugins_deleted_message, $updated_notice_args );
}
} elseif ( isset( $_GET['activate'] ) ) {
wp_admin_notice( __( 'Plugin activated.' ), $updated_notice_args );
} elseif ( isset( $_GET['activate-multi'] ) ) {
wp_admin_notice( __( 'Selected plugins activated.' ), $updated_notice_args );
} elseif ( isset( $_GET['deactivate'] ) ) {
wp_admin_notice( __( 'Plugin deactivated.' ), $updated_notice_args );
} elseif ( isset( $_GET['deactivate-multi'] ) ) {
wp_admin_notice( __( 'Selected plugins deactivated.' ), $updated_notice_args );
} elseif ( 'update-selected' === $action ) {
wp_admin_notice( __( 'All selected plugins are up to date.' ), $updated_notice_args );
} elseif ( isset( $_GET['resume'] ) ) {
wp_admin_notice( __( 'Plugin resumed.' ), $updated_notice_args );
} elseif ( isset( $_GET['enabled-auto-update'] ) ) {
wp_admin_notice( __( 'Plugin will be auto-updated.' ), $updated_notice_args );
} elseif ( isset( $_GET['disabled-auto-update'] ) ) {
wp_admin_notice( __( 'Plugin will no longer be auto-updated.' ), $updated_notice_args );
} elseif ( isset( $_GET['enabled-auto-update-multi'] ) ) {
wp_admin_notice( __( 'Selected plugins will be auto-updated.' ), $updated_notice_args );
} elseif ( isset( $_GET['disabled-auto-update-multi'] ) ) {
wp_admin_notice( __( 'Selected plugins will no longer be auto-updated.' ), $updated_notice_args );
}
?>
';
printf(
/* translators: %s: Search query. */
__( 'Search results for: %s' ),
'
' . esc_html( urldecode( $s ) ) . ''
);
echo '';
}
?>
views(); ?>
' . __( 'You need a higher level of permission.' ) . '' .
'' . __( 'Sorry, you are not allowed to add users to this network.' ) . '
',
403
);
}
} elseif ( ! current_user_can( 'create_users' ) ) {
wp_die(
'' . __( 'You need a higher level of permission.' ) . '
' .
'' . __( 'Sorry, you are not allowed to create users.' ) . '
',
403
);
}
if ( is_multisite() ) {
add_filter( 'wpmu_signup_user_notification_email', 'admin_created_user_email' );
}
if ( isset( $_REQUEST['action'] ) && 'adduser' === $_REQUEST['action'] ) {
check_admin_referer( 'add-user', '_wpnonce_add-user' );
$user_details = null;
$user_email = wp_unslash( $_REQUEST['email'] );
if ( str_contains( $user_email, '@' ) ) {
$user_details = get_user_by( 'email', $user_email );
} else {
if ( current_user_can( 'manage_network_users' ) ) {
$user_details = get_user_by( 'login', $user_email );
} else {
wp_redirect( add_query_arg( array( 'update' => 'enter_email' ), 'user-new.php' ) );
die();
}
}
if ( ! $user_details ) {
wp_redirect( add_query_arg( array( 'update' => 'does_not_exist' ), 'user-new.php' ) );
die();
}
if ( ! current_user_can( 'promote_user', $user_details->ID ) ) {
wp_die(
'' . __( 'You need a higher level of permission.' ) . '
' .
'' . __( 'Sorry, you are not allowed to add users to this network.' ) . '
',
403
);
}
// Adding an existing user to this blog.
$new_user_email = array();
$redirect = 'user-new.php';
$username = $user_details->user_login;
$user_id = $user_details->ID;
if ( array_key_exists( $blog_id, get_blogs_of_user( $user_id ) ) ) {
$redirect = add_query_arg( array( 'update' => 'addexisting' ), 'user-new.php' );
} else {
if ( isset( $_POST['noconfirmation'] ) && current_user_can( 'manage_network_users' ) ) {
$result = add_existing_user_to_blog(
array(
'user_id' => $user_id,
'role' => $_REQUEST['role'],
)
);
if ( ! is_wp_error( $result ) ) {
$redirect = add_query_arg(
array(
'update' => 'addnoconfirmation',
'user_id' => $user_id,
),
'user-new.php'
);
} else {
$redirect = add_query_arg( array( 'update' => 'could_not_add' ), 'user-new.php' );
}
} else {
$newuser_key = wp_generate_password( 20, false );
add_option(
'new_user_' . $newuser_key,
array(
'user_id' => $user_id,
'email' => $user_details->user_email,
'role' => $_REQUEST['role'],
)
);
$roles = get_editable_roles();
$role = $roles[ $_REQUEST['role'] ];
/**
* Fires immediately after an existing user is invited to join the site, but before the notification is sent.
*
* @since 4.4.0
*
* @param int $user_id The invited user's ID.
* @param array $role Array containing role information for the invited user.
* @param string $newuser_key The key of the invitation.
*/
do_action( 'invite_user', $user_id, $role, $newuser_key );
$switched_locale = switch_to_user_locale( $user_id );
if ( '' !== get_option( 'blogname' ) ) {
$site_title = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
} else {
$site_title = parse_url( home_url(), PHP_URL_HOST );
}
/* translators: 1: Site title, 2: Site URL, 3: User role, 4: Activation URL. */
$message = __(
'Hi,
You\'ve been invited to join \'%1$s\' at
%2$s with the role of %3$s.
Please click the following link to confirm the invite:
%4$s'
);
$new_user_email['to'] = $user_details->user_email;
$new_user_email['subject'] = sprintf(
/* translators: Joining confirmation notification email subject. %s: Site title. */
__( '[%s] Joining Confirmation' ),
$site_title
);
$new_user_email['message'] = sprintf(
$message,
get_option( 'blogname' ),
home_url(),
wp_specialchars_decode( translate_user_role( $role['name'] ) ),
home_url( "/newbloguser/$newuser_key/" )
);
$new_user_email['headers'] = '';
/**
* Filters the contents of the email sent when an existing user is invited to join the site.
*
* @since 5.6.0
*
* @param array $new_user_email {
* Used to build wp_mail().
*
* @type string $to The email address of the invited user.
* @type string $subject The subject of the email.
* @type string $message The content of the email.
* @type string $headers Headers.
* }
* @param int $user_id The invited user's ID.
* @param array $role Array containing role information for the invited user.
* @param string $newuser_key The key of the invitation.
*
*/
$new_user_email = apply_filters( 'invited_user_email', $new_user_email, $user_id, $role, $newuser_key );
wp_mail(
$new_user_email['to'],
$new_user_email['subject'],
$new_user_email['message'],
$new_user_email['headers']
);
if ( $switched_locale ) {
restore_previous_locale();
}
$redirect = add_query_arg( array( 'update' => 'add' ), 'user-new.php' );
}
}
wp_redirect( $redirect );
die();
} elseif ( isset( $_REQUEST['action'] ) && 'createuser' === $_REQUEST['action'] ) {
check_admin_referer( 'create-user', '_wpnonce_create-user' );
if ( ! current_user_can( 'create_users' ) ) {
wp_die(
'' . __( 'You need a higher level of permission.' ) . '
' .
'' . __( 'Sorry, you are not allowed to create users.' ) . '
',
403
);
}
if ( ! is_multisite() ) {
$user_id = edit_user();
if ( is_wp_error( $user_id ) ) {
$add_user_errors = $user_id;
} else {
if ( current_user_can( 'list_users' ) ) {
$redirect = 'users.php?update=add&id=' . $user_id;
} else {
$redirect = add_query_arg( 'update', 'add', 'user-new.php' );
}
wp_redirect( $redirect );
die();
}
} else {
// Adding a new user to this site.
$new_user_email = wp_unslash( $_REQUEST['email'] );
$user_details = wpmu_validate_user_signup( $_REQUEST['user_login'], $new_user_email );
if ( is_wp_error( $user_details['errors'] ) && $user_details['errors']->has_errors() ) {
$add_user_errors = $user_details['errors'];
} else {
/** This filter is documented in wp-includes/user.php */
$new_user_login = apply_filters( 'pre_user_login', sanitize_user( wp_unslash( $_REQUEST['user_login'] ), true ) );
if ( isset( $_POST['noconfirmation'] ) && current_user_can( 'manage_network_users' ) ) {
add_filter( 'wpmu_signup_user_notification', '__return_false' ); // Disable confirmation email.
add_filter( 'wpmu_welcome_user_notification', '__return_false' ); // Disable welcome email.
}
wpmu_signup_user(
$new_user_login,
$new_user_email,
array(
'add_to_blog' => get_current_blog_id(),
'new_role' => $_REQUEST['role'],
)
);
if ( isset( $_POST['noconfirmation'] ) && current_user_can( 'manage_network_users' ) ) {
$key = $wpdb->get_var( $wpdb->prepare( "SELECT activation_key FROM {$wpdb->signups} WHERE user_login = %s AND user_email = %s", $new_user_login, $new_user_email ) );
$new_user = wpmu_activate_signup( $key );
if ( is_wp_error( $new_user ) ) {
$redirect = add_query_arg( array( 'update' => 'addnoconfirmation' ), 'user-new.php' );
} elseif ( ! is_user_member_of_blog( $new_user['user_id'] ) ) {
$redirect = add_query_arg( array( 'update' => 'created_could_not_add' ), 'user-new.php' );
} else {
$redirect = add_query_arg(
array(
'update' => 'addnoconfirmation',
'user_id' => $new_user['user_id'],
),
'user-new.php'
);
}
} else {
$redirect = add_query_arg( array( 'update' => 'newuserconfirmation' ), 'user-new.php' );
}
wp_redirect( $redirect );
die();
}
}
}
// Used in the HTML title tag.
$title = __( 'Add New User' );
$parent_file = 'users.php';
$do_both = false;
if ( is_multisite() && current_user_can( 'promote_users' ) && current_user_can( 'create_users' ) ) {
$do_both = true;
}
$help = '' . __( 'To add a new user to your site, fill in the form on this screen and click the Add New User button at the bottom.' ) . '
';
if ( is_multisite() ) {
$help .= '' . __( 'Because this is a multisite installation, you may add accounts that already exist on the Network by specifying a username or email, and defining a role. For more options, such as specifying a password, you have to be a Network Administrator and use the hover link under an existing user’s name to Edit the user profile under Network Admin > All Users.' ) . '
' .
'' . __( 'New users will receive an email letting them know they’ve been added as a user for your site. This email will also contain their password. Check the box if you do not want the user to receive a welcome email.' ) . '
';
} else {
$help .= '' . __( 'New users are automatically assigned a password, which they can change after logging in. You can view or edit the assigned password by clicking the Show Password button. The username cannot be changed once the user has been added.' ) . '
' .
'' . __( 'By default, new users will receive an email letting them know they’ve been added as a user for your site. This email will also contain a password reset link. Uncheck the box if you do not want to send the new user a welcome email.' ) . '
';
}
$help .= '' . __( 'Remember to click the Add New User button at the bottom of this screen when you are finished.' ) . '
';
get_current_screen()->add_help_tab(
array(
'id' => 'overview',
'title' => __( 'Overview' ),
'content' => $help,
)
);
get_current_screen()->add_help_tab(
array(
'id' => 'user-roles',
'title' => __( 'User Roles' ),
'content' => '' . __( 'Here is a basic overview of the different user roles and the permissions associated with each one:' ) . '
' .
'' .
'- ' . __( 'Subscribers can read comments/comment/receive newsletters, etc. but cannot create regular site content.' ) . '
' .
'- ' . __( 'Contributors can write and manage their posts but not publish posts or upload media files.' ) . '
' .
'- ' . __( 'Authors can publish and manage their own posts, and are able to upload files.' ) . '
' .
'- ' . __( 'Editors can publish posts, manage posts as well as manage other people’s posts, etc.' ) . '
' .
'- ' . __( 'Administrators have access to all the administration features.' ) . '
' .
'
',
)
);
get_current_screen()->set_help_sidebar(
'' . __( 'For more information:' ) . '
' .
'' . __( 'Documentation on Adding New Users' ) . '
' .
'' . __( 'Support forums' ) . '
'
);
wp_enqueue_script( 'wp-ajax-response' );
wp_enqueue_script( 'user-profile' );
/**
* Filters whether to enable user auto-complete for non-super admins in Multisite.
*
* @since 3.4.0
*
* @param bool $enable Whether to enable auto-complete for non-super admins. Default false.
*/
if ( is_multisite() && current_user_can( 'promote_users' ) && ! wp_is_large_network( 'users' )
&& ( current_user_can( 'manage_network_users' ) || apply_filters( 'autocomplete_users_for_site_admins', false ) )
) {
wp_enqueue_script( 'user-suggest' );
}
require_once ABSPATH . 'wp-admin/admin-header.php';
if ( isset( $_GET['update'] ) ) {
$messages = array();
if ( is_multisite() ) {
$edit_link = '';
if ( ( isset( $_GET['user_id'] ) ) ) {
$user_id_new = absint( $_GET['user_id'] );
if ( $user_id_new ) {
$edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user_id_new ) ) );
}
}
switch ( $_GET['update'] ) {
case 'newuserconfirmation':
$messages[] = __( 'Invitation email sent to new user. A confirmation link must be clicked before their account is created.' );
break;
case 'add':
$messages[] = __( 'Invitation email sent to user. A confirmation link must be clicked for them to be added to your site.' );
break;
case 'addnoconfirmation':
$message = __( 'User has been added to your site.' );
if ( $edit_link ) {
$message .= sprintf( ' %s', $edit_link, __( 'Edit user' ) );
}
$messages[] = $message;
break;
case 'addexisting':
$messages[] = __( 'That user is already a member of this site.' );
break;
case 'could_not_add':
$add_user_errors = new WP_Error( 'could_not_add', __( 'That user could not be added to this site.' ) );
break;
case 'created_could_not_add':
$add_user_errors = new WP_Error( 'created_could_not_add', __( 'User has been created, but could not be added to this site.' ) );
break;
case 'does_not_exist':
$add_user_errors = new WP_Error( 'does_not_exist', __( 'The requested user does not exist.' ) );
break;
case 'enter_email':
$add_user_errors = new WP_Error( 'enter_email', __( 'Please enter a valid email address.' ) );
break;
}
} else {
if ( 'add' === $_GET['update'] ) {
$messages[] = __( 'User added.' );
}
}
}
?>
get_error_messages() as $err ) {
$error_message .= "
$err\n";
}
wp_admin_notice(
'
',
array(
'additional_classes' => array( 'error' ),
'paragraph_wrap' => false,
)
);
endif;
if ( ! empty( $messages ) ) {
foreach ( $messages as $msg ) {
wp_admin_notice(
$msg,
array(
'id' => 'message',
'additional_classes' => array( 'updated' ),
'dismissible' => true,
)
);
}
}
?>
get_error_messages() as $message ) {
$error_message .= "
$message
\n";
}
wp_admin_notice(
$error_message,
array(
'additional_classes' => array( 'error' ),
'paragraph_wrap' => false,
)
);
endif;
?>
' . __( 'Add Existing User' ) . '';
}
if ( ! current_user_can( 'manage_network_users' ) ) {
echo '
' . __( 'Enter the email address of an existing user on this network to invite them to this site. That person will be sent an email asking them to confirm the invite.' ) . '
';
$label = __( 'Email' );
$type = 'email';
} else {
echo '
' . __( 'Enter the email address or username of an existing user on this network to invite them to this site. That person will be sent an email asking them to confirm the invite.' ) . '
';
$label = __( 'Email or Username' );
$type = 'text';
}
?>
' . __( 'Add New User' ) . '';
}
?>
add_help_tab(
array(
'id' => 'overview',
'title' => __( 'Overview' ),
'content' =>
'' . __( 'This screen is where you manage requests to erase personal data.' ) . '
' .
'' . __( 'Privacy Laws around the world require businesses and online services to delete, anonymize, or forget the data they collect about an individual. The rights those laws enshrine are sometimes called the "Right to be Forgotten".' ) . '
' .
'' . __( 'The tool associates data stored in WordPress with a supplied email address, including profile data and comments.' ) . '
' .
'' . __( 'Note: As this tool only gathers data from WordPress and participating plugins, you may need to do more to comply with erasure requests. For example, you are also responsible for ensuring that data collected by or stored with the 3rd party services your organization uses gets deleted.' ) . '
',
)
);
get_current_screen()->add_help_tab(
array(
'id' => 'default-data',
'title' => __( 'Default Data' ),
'content' =>
'' . __( 'WordPress collects (but never publishes) a limited amount of data from logged-in users but then deletes it or anonymizes it. That data can include:' ) . '
' .
'' . __( 'Profile Information — user email address, username, display name, nickname, first name, last name, description/bio, and registration date.' ) . '
' .
'' . __( 'Community Events Location — The IP Address of the user which is used for the Upcoming Community Events shown in the dashboard widget.' ) . '
' .
'' . __( 'Session Tokens — User login information, IP Addresses, Expiration Date, User Agent (Browser/OS), and Last Login.' ) . '
' .
'' . __( 'Comments — WordPress does not delete comments. The software does anonymize (but, again, never publishes) the associated Email Address, IP Address, and User Agent (Browser/OS).' ) . '
' .
'' . __( 'Media — A list of URLs for all media file uploads made by the user.' ) . '
',
)
);
$privacy_policy_guide = '' . sprintf(
/* translators: %s: URL to Privacy Policy Guide screen. */
__( 'If you are not sure, check the plugin documentation or contact the plugin author to see if the plugin collects data and if it supports the Data Eraser tool. This information may be available in the Privacy Policy Guide.' ),
admin_url( 'options-privacy.php?tab=policyguide' )
) . '
';
get_current_screen()->add_help_tab(
array(
'id' => 'plugin-data',
'title' => __( 'Plugin Data' ),
'content' =>
'' . __( 'Many plugins may collect or store personal data either in the WordPress database or remotely. Any Erase Personal Data request should delete data from plugins as well.' ) . '
' .
$privacy_policy_guide .
'' . __( 'If you are a plugin author, you can learn more about how to add the Personal Data Eraser to a plugin.' ) . '
',
)
);
get_current_screen()->set_help_sidebar(
'' . __( 'For more information:' ) . '
' .
'' . __( 'Documentation on Erase Personal Data' ) . '
' .
'' . __( 'Support forums' ) . '
'
);
// Handle list table actions.
_wp_personal_data_handle_actions();
// Cleans up failed and expired requests before displaying the list table.
_wp_personal_data_cleanup_requests();
wp_enqueue_script( 'privacy-tools' );
add_screen_option(
'per_page',
array(
'default' => 20,
'option' => 'remove_personal_data_requests_per_page',
)
);
$_list_table_args = array(
'plural' => 'privacy_requests',
'singular' => 'privacy_request',
);
$requests_table = _get_list_table( 'WP_Privacy_Data_Removal_Requests_List_Table', $_list_table_args );
$requests_table->screen->set_screen_reader_content(
array(
'heading_views' => __( 'Filter erase personal data list' ),
'heading_pagination' => __( 'Erase personal data list navigation' ),
'heading_list' => __( 'Erase personal data list' ),
)
);
$requests_table->process_bulk_action();
$requests_table->prepare_items();
require_once ABSPATH . 'wp-admin/admin-header.php';
?>
views(); ?>
add_help_tab(
array(
'id' => 'overview',
'title' => __( 'Overview' ),
'content' =>
'' . __( 'This screen is where you manage requests for an export of personal data.' ) . '
' .
'' . __( 'Privacy Laws around the world require businesses and online services to provide an export of some of the data they collect about an individual, and to deliver that export on request. The rights those laws enshrine are sometimes called the "Right of Data Portability". It allows individuals to obtain and reuse their personal data for their own purposes across different services. It allows them to move, copy or transfer personal data easily from one IT environment to another.' ) . '
' .
'' . __( 'The tool associates data stored in WordPress with a supplied email address, including profile data and comments.' ) . '
' .
'' . __( 'Note: Since this tool only gathers data from WordPress and participating plugins, you may need to do more to comply with export requests. For example, you should also send the requester some of the data collected from or stored with the 3rd party services your organization uses.' ) . '
',
)
);
get_current_screen()->add_help_tab(
array(
'id' => 'default-data',
'title' => __( 'Default Data' ),
'content' =>
'' . __( 'WordPress collects (but never publishes) a limited amount of data from registered users who have logged in to the site. Generally, these users are people who contribute to the site in some way -- content, store management, and so on. With rare exceptions, these users do not include occasional visitors who might have registered to comment on articles or buy products. The data WordPress retains can include:' ) . '
' .
'' . __( 'Profile Information — user email address, username, display name, nickname, first name, last name, description/bio, and registration date.' ) . '
' .
'' . __( 'Community Events Location — The IP Address of the user, which populates the Upcoming Community Events dashboard widget with relevant information.' ) . '
' .
'' . __( 'Session Tokens — User login information, IP Addresses, Expiration Date, User Agent (Browser/OS), and Last Login.' ) . '
' .
'' . __( 'Comments — For user comments, Email Address, IP Address, User Agent (Browser/OS), Date/Time, Comment Content, and Content URL.' ) . '
' .
'' . __( 'Media — A list of URLs for media files the user uploads.' ) . '
',
)
);
$privacy_policy_guide = '' . sprintf(
/* translators: %s: URL to Privacy Policy Guide screen. */
__( 'If you are not sure, check the plugin documentation or contact the plugin author to see if the plugin collects data and if it supports the Data Exporter tool. This information may be available in the Privacy Policy Guide.' ),
admin_url( 'options-privacy.php?tab=policyguide' )
) . '
';
get_current_screen()->add_help_tab(
array(
'id' => 'plugin-data',
'title' => __( 'Plugin Data' ),
'content' =>
'' . __( 'Many plugins may collect or store personal data either in the WordPress database or remotely. Any Export Personal Data request should include data from plugins as well.' ) . '
' .
$privacy_policy_guide .
'' . __( 'If you are a plugin author, you can learn more about how to add the Personal Data Exporter to a plugin.' ) . '
',
)
);
get_current_screen()->set_help_sidebar(
'' . __( 'For more information:' ) . '
' .
'' . __( 'Documentation on Export Personal Data' ) . '
' .
'' . __( 'Support forums' ) . '
'
);
// Handle list table actions.
_wp_personal_data_handle_actions();
// Cleans up failed and expired requests before displaying the list table.
_wp_personal_data_cleanup_requests();
wp_enqueue_script( 'privacy-tools' );
add_screen_option(
'per_page',
array(
'default' => 20,
'option' => 'export_personal_data_requests_per_page',
)
);
$_list_table_args = array(
'plural' => 'privacy_requests',
'singular' => 'privacy_request',
);
$requests_table = _get_list_table( 'WP_Privacy_Data_Export_Requests_List_Table', $_list_table_args );
$requests_table->screen->set_screen_reader_content(
array(
'heading_views' => __( 'Filter export personal data list' ),
'heading_pagination' => __( 'Export personal data list navigation' ),
'heading_list' => __( 'Export personal data list' ),
)
);
$requests_table->process_bulk_action();
$requests_table->prepare_items();
require_once ABSPATH . 'wp-admin/admin-header.php';
?>
views(); ?>
Links / Edit Link' ), 'link-manager.php' );
$submit_text = __( 'Update Link' );
$form_name = 'editlink';
$nonce_action = 'update-bookmark_' . $link_id;
} else {
/* translators: %s: URL to Links screen. */
$heading = sprintf( __( 'Links / Add New Link' ), 'link-manager.php' );
$submit_text = __( 'Add Link' );
$form_name = 'addlink';
$nonce_action = 'add-bookmark';
}
require_once ABSPATH . 'wp-admin/includes/meta-boxes.php';
add_meta_box( 'linksubmitdiv', __( 'Save' ), 'link_submit_meta_box', null, 'side', 'core' );
add_meta_box( 'linkcategorydiv', __( 'Categories' ), 'link_categories_meta_box', null, 'normal', 'core' );
add_meta_box( 'linktargetdiv', __( 'Target' ), 'link_target_meta_box', null, 'normal', 'core' );
add_meta_box( 'linkxfndiv', __( 'Link Relationship (XFN)' ), 'link_xfn_meta_box', null, 'normal', 'core' );
add_meta_box( 'linkadvanceddiv', __( 'Advanced' ), 'link_advanced_meta_box', null, 'normal', 'core' );
/** This action is documented in wp-admin/includes/meta-boxes.php */
do_action( 'add_meta_boxes', 'link', $link );
/**
* Fires when link-specific meta boxes are added.
*
* @since 3.0.0
*
* @param object $link Link object.
*/
do_action( 'add_meta_boxes_link', $link );
/** This action is documented in wp-admin/includes/meta-boxes.php */
do_action( 'do_meta_boxes', 'link', 'normal', $link );
/** This action is documented in wp-admin/includes/meta-boxes.php */
do_action( 'do_meta_boxes', 'link', 'advanced', $link );
/** This action is documented in wp-admin/includes/meta-boxes.php */
do_action( 'do_meta_boxes', 'link', 'side', $link );
add_screen_option(
'layout_columns',
array(
'max' => 2,
'default' => 2,
)
);
get_current_screen()->add_help_tab(
array(
'id' => 'overview',
'title' => __( 'Overview' ),
'content' =>
'' . __( 'You can add or edit links on this screen by entering information in each of the boxes. Only the link’s web address and name (the text you want to display on your site as the link) are required fields.' ) . '
' .
'' . __( 'The boxes for link name, web address, and description have fixed positions, while the others may be repositioned using drag and drop. You can also hide boxes you do not use in the Screen Options tab, or minimize boxes by clicking on the title bar of the box.' ) . '
' .
'' . __( 'XFN stands for XHTML Friends Network, which is optional. WordPress allows the generation of XFN attributes to show how you are related to the authors/owners of the site to which you are linking.' ) . '
',
)
);
get_current_screen()->set_help_sidebar(
'' . __( 'For more information:' ) . '
' .
'' . __( 'Documentation on Creating Links' ) . '
' .
'' . __( 'Support forums' ) . '
'
);
require_once ABSPATH . 'wp-admin/admin-header.php';
?>
'message',
'additional_classes' => array( 'updated' ),
'dismissible' => true,
)
);
}
?>
load-styles.php 0000755 00000005663 14744541145 0007543 0 ustar 00 get_etag( $load );
if ( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) && stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) === $etag ) {
header( "$protocol 304 Not Modified" );
exit;
}
foreach ( $load as $handle ) {
if ( ! array_key_exists( $handle, $wp_styles->registered ) ) {
continue;
}
$style = $wp_styles->registered[ $handle ];
if ( empty( $style->src ) ) {
continue;
}
$path = ABSPATH . $style->src;
if ( $rtl && ! empty( $style->extra['rtl'] ) ) {
// All default styles have fully independent RTL files.
$path = str_replace( '.min.css', '-rtl.min.css', $path );
}
$content = get_file( $path ) . "\n";
// Note: str_starts_with() is not used here, as wp-includes/compat.php is not loaded in this file.
if ( 0 === strpos( $style->src, '/' . WPINC . '/css/' ) ) {
$content = str_replace( '../images/', '../' . WPINC . '/images/', $content );
$content = str_replace( '../js/tinymce/', '../' . WPINC . '/js/tinymce/', $content );
$content = str_replace( '../fonts/', '../' . WPINC . '/fonts/', $content );
$out .= $content;
} else {
$out .= str_replace( '../images/', 'images/', $content );
}
}
header( "Etag: $etag" );
header( 'Content-Type: text/css; charset=UTF-8' );
header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + $expires_offset ) . ' GMT' );
header( "Cache-Control: public, max-age=$expires_offset" );
echo $out;
exit;
upgrade.php 0000755 00000013113 14744541145 0006717 0 ustar 00 db_version();
$php_compat = version_compare( $php_version, $required_php_version, '>=' );
if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) ) {
$mysql_compat = true;
} else {
$mysql_compat = version_compare( $mysql_version, $required_mysql_version, '>=' );
}
header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
?>
>
' . sprintf(
/* translators: %s: URL to Update PHP page. */
__( 'Learn more about updating PHP.' ),
esc_url( wp_get_update_php_url() )
);
$annotation = wp_get_update_php_annotation();
if ( $annotation ) {
$php_update_message .= '
' . $annotation . '';
}
if ( ! $mysql_compat && ! $php_compat ) {
$message = sprintf(
/* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required PHP version number, 4: Minimum required MySQL version number, 5: Current PHP version number, 6: Current MySQL version number. */
__( 'You cannot update because WordPress %2$s requires PHP version %3$s or higher and MySQL version %4$s or higher. You are running PHP version %5$s and MySQL version %6$s.' ),
$version_url,
$wp_version,
$required_php_version,
$required_mysql_version,
$php_version,
$mysql_version
) . $php_update_message;
} elseif ( ! $php_compat ) {
$message = sprintf(
/* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required PHP version number, 4: Current PHP version number. */
__( 'You cannot update because WordPress %2$s requires PHP version %3$s or higher. You are running version %4$s.' ),
$version_url,
$wp_version,
$required_php_version,
$php_version
) . $php_update_message;
} elseif ( ! $mysql_compat ) {
$message = sprintf(
/* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required MySQL version number, 4: Current MySQL version number. */
__( 'You cannot update because WordPress %2$s requires MySQL version %3$s or higher. You are running version %4$s.' ),
$version_url,
$wp_version,
$required_mysql_version,
$mysql_version
);
}
echo '
' . $message . '
';
?>
press-this.php 0000755 00000004534 14744541145 0007400 0 ustar 00 cap->create_posts ) ) {
wp_die(
__( 'Sorry, you are not allowed to create posts as this user.' ),
__( 'You need a higher level of permission.' ),
403
);
} elseif ( is_plugin_active( $plugin_file ) ) {
include WP_PLUGIN_DIR . '/press-this/class-wp-press-this-plugin.php';
$wp_press_this = new WP_Press_This_Plugin();
$wp_press_this->html();
} elseif ( current_user_can( 'activate_plugins' ) ) {
if ( file_exists( WP_PLUGIN_DIR . '/' . $plugin_file ) ) {
$url = wp_nonce_url(
add_query_arg(
array(
'action' => 'activate',
'plugin' => $plugin_file,
'from' => 'press-this',
),
admin_url( 'plugins.php' )
),
'activate-plugin_' . $plugin_file
);
$action = sprintf(
'%2$s',
esc_url( $url ),
__( 'Activate Press This' )
);
} else {
if ( is_main_site() ) {
$url = wp_nonce_url(
add_query_arg(
array(
'action' => 'install-plugin',
'plugin' => $plugin_slug,
'from' => 'press-this',
),
self_admin_url( 'update.php' )
),
'install-plugin_' . $plugin_slug
);
$action = sprintf(
'%3$s',
esc_url( $url ),
esc_attr( $plugin_slug ),
_x( 'Install Now', 'plugin' )
);
} else {
$action = sprintf(
/* translators: %s: URL to Press This bookmarklet on the main site. */
__( 'Press This is not installed. Please install Press This from the main site.' ),
get_admin_url( get_current_network_id(), 'press-this.php' )
);
}
}
wp_die(
__( 'The Press This plugin is required.' ) . '
' . $action,
__( 'Installation Required' ),
200
);
} else {
wp_die(
__( 'Press This is not available. Please contact your site administrator.' ),
__( 'Installation Required' ),
200
);
}
}
wp_load_press_this();
export.php 0000755 00000026030 14744541145 0006613 0 ustar 00
add_help_tab(
array(
'id' => 'overview',
'title' => __( 'Overview' ),
'content' => '' . __( 'You can export a file of your site’s content in order to import it into another installation or platform. The export file will be an XML file format called WXR. Posts, pages, comments, custom fields, categories, and tags can be included. You can choose for the WXR file to include only certain posts or pages by setting the dropdown filters to limit the export by category, author, date range by month, or publishing status.' ) . '
' .
'' . __( 'Once generated, your WXR file can be imported by another WordPress site or by another blogging platform able to access this format.' ) . '
',
)
);
get_current_screen()->set_help_sidebar(
'' . __( 'For more information:' ) . '
' .
'' . __( 'Documentation on Export' ) . '
' .
'' . __( 'Support forums' ) . '
'
);
// If the 'download' URL parameter is set, a WXR export file is baked and returned.
if ( isset( $_GET['download'] ) ) {
$args = array();
if ( ! isset( $_GET['content'] ) || 'all' === $_GET['content'] ) {
$args['content'] = 'all';
} elseif ( 'posts' === $_GET['content'] ) {
$args['content'] = 'post';
if ( $_GET['cat'] ) {
$args['category'] = (int) $_GET['cat'];
}
if ( $_GET['post_author'] ) {
$args['author'] = (int) $_GET['post_author'];
}
if ( $_GET['post_start_date'] || $_GET['post_end_date'] ) {
$args['start_date'] = $_GET['post_start_date'];
$args['end_date'] = $_GET['post_end_date'];
}
if ( $_GET['post_status'] ) {
$args['status'] = $_GET['post_status'];
}
} elseif ( 'pages' === $_GET['content'] ) {
$args['content'] = 'page';
if ( $_GET['page_author'] ) {
$args['author'] = (int) $_GET['page_author'];
}
if ( $_GET['page_start_date'] || $_GET['page_end_date'] ) {
$args['start_date'] = $_GET['page_start_date'];
$args['end_date'] = $_GET['page_end_date'];
}
if ( $_GET['page_status'] ) {
$args['status'] = $_GET['page_status'];
}
} elseif ( 'attachment' === $_GET['content'] ) {
$args['content'] = 'attachment';
if ( $_GET['attachment_start_date'] || $_GET['attachment_end_date'] ) {
$args['start_date'] = $_GET['attachment_start_date'];
$args['end_date'] = $_GET['attachment_end_date'];
}
} else {
$args['content'] = $_GET['content'];
}
/**
* Filters the export args.
*
* @since 3.5.0
*
* @param array $args The arguments to send to the exporter.
*/
$args = apply_filters( 'export_args', $args );
export_wp( $args );
die();
}
require_once ABSPATH . 'wp-admin/admin-header.php';
/**
* Creates the date options fields for exporting a given post type.
*
* @since 3.1.0
*
* @global wpdb $wpdb WordPress database abstraction object.
* @global WP_Locale $wp_locale WordPress date and time locale object.
*
* @param string $post_type The post type. Default 'post'.
*/
function export_date_options( $post_type = 'post' ) {
global $wpdb, $wp_locale;
$months = $wpdb->get_results(
$wpdb->prepare(
"SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
FROM $wpdb->posts
WHERE post_type = %s AND post_status != 'auto-draft'
ORDER BY post_date DESC",
$post_type
)
);
$month_count = count( $months );
if ( ! $month_count || ( 1 === $month_count && 0 === (int) $months[0]->month ) ) {
return;
}
foreach ( $months as $date ) {
if ( 0 === (int) $date->year ) {
continue;
}
$month = zeroise( $date->month, 2 );
printf(
'',
esc_attr( $date->year . '-' . $month ),
$wp_locale->get_month( $month ) . ' ' . $date->year
);
}
}
?>
includes/class-wp-upgrader.php 0000755 00000135117 14744541145 0012447 0 ustar 00 skin = new WP_Upgrader_Skin();
} else {
$this->skin = $skin;
}
}
/**
* Initializes the upgrader.
*
* This will set the relationship between the skin being used and this upgrader,
* and also add the generic strings to `WP_Upgrader::$strings`.
*
* Additionally, it will schedule a weekly task to clean up the temporary backup directory.
*
* @since 2.8.0
* @since 6.3.0 Added the `schedule_temp_backup_cleanup()` task.
*/
public function init() {
$this->skin->set_upgrader( $this );
$this->generic_strings();
if ( ! wp_installing() ) {
$this->schedule_temp_backup_cleanup();
}
}
/**
* Schedules the cleanup of the temporary backup directory.
*
* @since 6.3.0
*/
protected function schedule_temp_backup_cleanup() {
if ( false === wp_next_scheduled( 'wp_delete_temp_updater_backups' ) ) {
wp_schedule_event( time(), 'weekly', 'wp_delete_temp_updater_backups' );
}
}
/**
* Adds the generic strings to WP_Upgrader::$strings.
*
* @since 2.8.0
*/
public function generic_strings() {
$this->strings['bad_request'] = __( 'Invalid data provided.' );
$this->strings['fs_unavailable'] = __( 'Could not access filesystem.' );
$this->strings['fs_error'] = __( 'Filesystem error.' );
$this->strings['fs_no_root_dir'] = __( 'Unable to locate WordPress root directory.' );
/* translators: %s: Directory name. */
$this->strings['fs_no_content_dir'] = sprintf( __( 'Unable to locate WordPress content directory (%s).' ), 'wp-content' );
$this->strings['fs_no_plugins_dir'] = __( 'Unable to locate WordPress plugin directory.' );
$this->strings['fs_no_themes_dir'] = __( 'Unable to locate WordPress theme directory.' );
/* translators: %s: Directory name. */
$this->strings['fs_no_folder'] = __( 'Unable to locate needed folder (%s).' );
$this->strings['no_package'] = __( 'Package not available.' );
$this->strings['download_failed'] = __( 'Download failed.' );
$this->strings['installing_package'] = __( 'Installing the latest version…' );
$this->strings['no_files'] = __( 'The package contains no files.' );
$this->strings['folder_exists'] = __( 'Destination folder already exists.' );
$this->strings['mkdir_failed'] = __( 'Could not create directory.' );
$this->strings['incompatible_archive'] = __( 'The package could not be installed.' );
$this->strings['files_not_writable'] = __( 'The update cannot be installed because some files could not be copied. This is usually due to inconsistent file permissions.' );
$this->strings['dir_not_readable'] = __( 'A directory could not be read.' );
$this->strings['maintenance_start'] = __( 'Enabling Maintenance mode…' );
$this->strings['maintenance_end'] = __( 'Disabling Maintenance mode…' );
/* translators: %s: upgrade-temp-backup */
$this->strings['temp_backup_mkdir_failed'] = sprintf( __( 'Could not create the %s directory.' ), 'upgrade-temp-backup' );
/* translators: %s: upgrade-temp-backup */
$this->strings['temp_backup_move_failed'] = sprintf( __( 'Could not move the old version to the %s directory.' ), 'upgrade-temp-backup' );
/* translators: %s: The plugin or theme slug. */
$this->strings['temp_backup_restore_failed'] = __( 'Could not restore the original version of %s.' );
/* translators: %s: The plugin or theme slug. */
$this->strings['temp_backup_delete_failed'] = __( 'Could not delete the temporary backup directory for %s.' );
}
/**
* Connects to the filesystem.
*
* @since 2.8.0
*
* @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
*
* @param string[] $directories Optional. Array of directories. If any of these do
* not exist, a WP_Error object will be returned.
* Default empty array.
* @param bool $allow_relaxed_file_ownership Whether to allow relaxed file ownership.
* Default false.
* @return bool|WP_Error True if able to connect, false or a WP_Error otherwise.
*/
public function fs_connect( $directories = array(), $allow_relaxed_file_ownership = false ) {
global $wp_filesystem;
$credentials = $this->skin->request_filesystem_credentials( false, $directories[0], $allow_relaxed_file_ownership );
if ( false === $credentials ) {
return false;
}
if ( ! WP_Filesystem( $credentials, $directories[0], $allow_relaxed_file_ownership ) ) {
$error = true;
if ( is_object( $wp_filesystem ) && $wp_filesystem->errors->has_errors() ) {
$error = $wp_filesystem->errors;
}
// Failed to connect. Error and request again.
$this->skin->request_filesystem_credentials( $error, $directories[0], $allow_relaxed_file_ownership );
return false;
}
if ( ! is_object( $wp_filesystem ) ) {
return new WP_Error( 'fs_unavailable', $this->strings['fs_unavailable'] );
}
if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) {
return new WP_Error( 'fs_error', $this->strings['fs_error'], $wp_filesystem->errors );
}
foreach ( (array) $directories as $dir ) {
switch ( $dir ) {
case ABSPATH:
if ( ! $wp_filesystem->abspath() ) {
return new WP_Error( 'fs_no_root_dir', $this->strings['fs_no_root_dir'] );
}
break;
case WP_CONTENT_DIR:
if ( ! $wp_filesystem->wp_content_dir() ) {
return new WP_Error( 'fs_no_content_dir', $this->strings['fs_no_content_dir'] );
}
break;
case WP_PLUGIN_DIR:
if ( ! $wp_filesystem->wp_plugins_dir() ) {
return new WP_Error( 'fs_no_plugins_dir', $this->strings['fs_no_plugins_dir'] );
}
break;
case get_theme_root():
if ( ! $wp_filesystem->wp_themes_dir() ) {
return new WP_Error( 'fs_no_themes_dir', $this->strings['fs_no_themes_dir'] );
}
break;
default:
if ( ! $wp_filesystem->find_folder( $dir ) ) {
return new WP_Error( 'fs_no_folder', sprintf( $this->strings['fs_no_folder'], esc_html( basename( $dir ) ) ) );
}
break;
}
}
return true;
}
/**
* Downloads a package.
*
* @since 2.8.0
* @since 5.2.0 Added the `$check_signatures` parameter.
* @since 5.5.0 Added the `$hook_extra` parameter.
*
* @param string $package The URI of the package. If this is the full path to an
* existing local file, it will be returned untouched.
* @param bool $check_signatures Whether to validate file signatures. Default false.
* @param array $hook_extra Extra arguments to pass to the filter hooks. Default empty array.
* @return string|WP_Error The full path to the downloaded package file, or a WP_Error object.
*/
public function download_package( $package, $check_signatures = false, $hook_extra = array() ) {
/**
* Filters whether to return the package.
*
* @since 3.7.0
* @since 5.5.0 Added the `$hook_extra` parameter.
*
* @param bool $reply Whether to bail without returning the package.
* Default false.
* @param string $package The package file name.
* @param WP_Upgrader $upgrader The WP_Upgrader instance.
* @param array $hook_extra Extra arguments passed to hooked filters.
*/
$reply = apply_filters( 'upgrader_pre_download', false, $package, $this, $hook_extra );
if ( false !== $reply ) {
return $reply;
}
if ( ! preg_match( '!^(http|https|ftp)://!i', $package ) && file_exists( $package ) ) { // Local file or remote?
return $package; // Must be a local file.
}
if ( empty( $package ) ) {
return new WP_Error( 'no_package', $this->strings['no_package'] );
}
$this->skin->feedback( 'downloading_package', $package );
$download_file = download_url( $package, 300, $check_signatures );
if ( is_wp_error( $download_file ) && ! $download_file->get_error_data( 'softfail-filename' ) ) {
return new WP_Error( 'download_failed', $this->strings['download_failed'], $download_file->get_error_message() );
}
return $download_file;
}
/**
* Unpacks a compressed package file.
*
* @since 2.8.0
*
* @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
*
* @param string $package Full path to the package file.
* @param bool $delete_package Optional. Whether to delete the package file after attempting
* to unpack it. Default true.
* @return string|WP_Error The path to the unpacked contents, or a WP_Error on failure.
*/
public function unpack_package( $package, $delete_package = true ) {
global $wp_filesystem;
$this->skin->feedback( 'unpack_package' );
if ( ! $wp_filesystem->wp_content_dir() ) {
return new WP_Error( 'fs_no_content_dir', $this->strings['fs_no_content_dir'] );
}
$upgrade_folder = $wp_filesystem->wp_content_dir() . 'upgrade/';
// Clean up contents of upgrade directory beforehand.
$upgrade_files = $wp_filesystem->dirlist( $upgrade_folder );
if ( ! empty( $upgrade_files ) ) {
foreach ( $upgrade_files as $file ) {
$wp_filesystem->delete( $upgrade_folder . $file['name'], true );
}
}
// We need a working directory - strip off any .tmp or .zip suffixes.
$working_dir = $upgrade_folder . basename( basename( $package, '.tmp' ), '.zip' );
// Clean up working directory.
if ( $wp_filesystem->is_dir( $working_dir ) ) {
$wp_filesystem->delete( $working_dir, true );
}
// Unzip package to working directory.
$result = unzip_file( $package, $working_dir );
// Once extracted, delete the package if required.
if ( $delete_package ) {
unlink( $package );
}
if ( is_wp_error( $result ) ) {
$wp_filesystem->delete( $working_dir, true );
if ( 'incompatible_archive' === $result->get_error_code() ) {
return new WP_Error( 'incompatible_archive', $this->strings['incompatible_archive'], $result->get_error_data() );
}
return $result;
}
return $working_dir;
}
/**
* Flattens the results of WP_Filesystem_Base::dirlist() for iterating over.
*
* @since 4.9.0
* @access protected
*
* @param array $nested_files Array of files as returned by WP_Filesystem_Base::dirlist().
* @param string $path Relative path to prepend to child nodes. Optional.
* @return array A flattened array of the $nested_files specified.
*/
protected function flatten_dirlist( $nested_files, $path = '' ) {
$files = array();
foreach ( $nested_files as $name => $details ) {
$files[ $path . $name ] = $details;
// Append children recursively.
if ( ! empty( $details['files'] ) ) {
$children = $this->flatten_dirlist( $details['files'], $path . $name . '/' );
// Merge keeping possible numeric keys, which array_merge() will reindex from 0..n.
$files = $files + $children;
}
}
return $files;
}
/**
* Clears the directory where this item is going to be installed into.
*
* @since 4.3.0
*
* @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
*
* @param string $remote_destination The location on the remote filesystem to be cleared.
* @return true|WP_Error True upon success, WP_Error on failure.
*/
public function clear_destination( $remote_destination ) {
global $wp_filesystem;
$files = $wp_filesystem->dirlist( $remote_destination, true, true );
// False indicates that the $remote_destination doesn't exist.
if ( false === $files ) {
return true;
}
// Flatten the file list to iterate over.
$files = $this->flatten_dirlist( $files );
// Check all files are writable before attempting to clear the destination.
$unwritable_files = array();
// Check writability.
foreach ( $files as $filename => $file_details ) {
if ( ! $wp_filesystem->is_writable( $remote_destination . $filename ) ) {
// Attempt to alter permissions to allow writes and try again.
$wp_filesystem->chmod( $remote_destination . $filename, ( 'd' === $file_details['type'] ? FS_CHMOD_DIR : FS_CHMOD_FILE ) );
if ( ! $wp_filesystem->is_writable( $remote_destination . $filename ) ) {
$unwritable_files[] = $filename;
}
}
}
if ( ! empty( $unwritable_files ) ) {
return new WP_Error( 'files_not_writable', $this->strings['files_not_writable'], implode( ', ', $unwritable_files ) );
}
if ( ! $wp_filesystem->delete( $remote_destination, true ) ) {
return new WP_Error( 'remove_old_failed', $this->strings['remove_old_failed'] );
}
return true;
}
/**
* Install a package.
*
* Copies the contents of a package from a source directory, and installs them in
* a destination directory. Optionally removes the source. It can also optionally
* clear out the destination folder if it already exists.
*
* @since 2.8.0
* @since 6.2.0 Use move_dir() instead of copy_dir() when possible.
*
* @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
* @global array $wp_theme_directories
*
* @param array|string $args {
* Optional. Array or string of arguments for installing a package. Default empty array.
*
* @type string $source Required path to the package source. Default empty.
* @type string $destination Required path to a folder to install the package in.
* Default empty.
* @type bool $clear_destination Whether to delete any files already in the destination
* folder. Default false.
* @type bool $clear_working Whether to delete the files from the working directory
* after copying them to the destination. Default false.
* @type bool $abort_if_destination_exists Whether to abort the installation if
* the destination folder already exists. Default true.
* @type array $hook_extra Extra arguments to pass to the filter hooks called by
* WP_Upgrader::install_package(). Default empty array.
* }
*
* @return array|WP_Error The result (also stored in `WP_Upgrader::$result`), or a WP_Error on failure.
*/
public function install_package( $args = array() ) {
global $wp_filesystem, $wp_theme_directories;
$defaults = array(
'source' => '', // Please always pass this.
'destination' => '', // ...and this.
'clear_destination' => false,
'clear_working' => false,
'abort_if_destination_exists' => true,
'hook_extra' => array(),
);
$args = wp_parse_args( $args, $defaults );
// These were previously extract()'d.
$source = $args['source'];
$destination = $args['destination'];
$clear_destination = $args['clear_destination'];
// Give the upgrade an additional 300 seconds(5 minutes) to ensure the install doesn't prematurely timeout having used up the maximum script execution time upacking and downloading in WP_Upgrader->run.
if ( function_exists( 'set_time_limit' ) ) {
set_time_limit( 300 );
}
if (
( ! is_string( $source ) || '' === $source || trim( $source ) !== $source ) ||
( ! is_string( $destination ) || '' === $destination || trim( $destination ) !== $destination )
) {
return new WP_Error( 'bad_request', $this->strings['bad_request'] );
}
$this->skin->feedback( 'installing_package' );
/**
* Filters the installation response before the installation has started.
*
* Returning a value that could be evaluated as a `WP_Error` will effectively
* short-circuit the installation, returning that value instead.
*
* @since 2.8.0
*
* @param bool|WP_Error $response Installation response.
* @param array $hook_extra Extra arguments passed to hooked filters.
*/
$res = apply_filters( 'upgrader_pre_install', true, $args['hook_extra'] );
if ( is_wp_error( $res ) ) {
return $res;
}
// Retain the original source and destinations.
$remote_source = $args['source'];
$local_destination = $destination;
$dirlist = $wp_filesystem->dirlist( $remote_source );
if ( false === $dirlist ) {
return new WP_Error( 'source_read_failed', $this->strings['fs_error'], $this->strings['dir_not_readable'] );
}
$source_files = array_keys( $dirlist );
$remote_destination = $wp_filesystem->find_folder( $local_destination );
// Locate which directory to copy to the new folder. This is based on the actual folder holding the files.
if ( 1 === count( $source_files ) && $wp_filesystem->is_dir( trailingslashit( $args['source'] ) . $source_files[0] . '/' ) ) {
// Only one folder? Then we want its contents.
$source = trailingslashit( $args['source'] ) . trailingslashit( $source_files[0] );
} elseif ( 0 === count( $source_files ) ) {
// There are no files?
return new WP_Error( 'incompatible_archive_empty', $this->strings['incompatible_archive'], $this->strings['no_files'] );
} else {
/*
* It's only a single file, the upgrader will use the folder name of this file as the destination folder.
* Folder name is based on zip filename.
*/
$source = trailingslashit( $args['source'] );
}
/**
* Filters the source file location for the upgrade package.
*
* @since 2.8.0
* @since 4.4.0 The $hook_extra parameter became available.
*
* @param string $source File source location.
* @param string $remote_source Remote file source location.
* @param WP_Upgrader $upgrader WP_Upgrader instance.
* @param array $hook_extra Extra arguments passed to hooked filters.
*/
$source = apply_filters( 'upgrader_source_selection', $source, $remote_source, $this, $args['hook_extra'] );
if ( is_wp_error( $source ) ) {
return $source;
}
if ( ! empty( $args['hook_extra']['temp_backup'] ) ) {
$temp_backup = $this->move_to_temp_backup_dir( $args['hook_extra']['temp_backup'] );
if ( is_wp_error( $temp_backup ) ) {
return $temp_backup;
}
$this->temp_backups[] = $args['hook_extra']['temp_backup'];
}
// Has the source location changed? If so, we need a new source_files list.
if ( $source !== $remote_source ) {
$dirlist = $wp_filesystem->dirlist( $source );
if ( false === $dirlist ) {
return new WP_Error( 'new_source_read_failed', $this->strings['fs_error'], $this->strings['dir_not_readable'] );
}
$source_files = array_keys( $dirlist );
}
/*
* Protection against deleting files in any important base directories.
* Theme_Upgrader & Plugin_Upgrader also trigger this, as they pass the
* destination directory (WP_PLUGIN_DIR / wp-content/themes) intending
* to copy the directory into the directory, whilst they pass the source
* as the actual files to copy.
*/
$protected_directories = array( ABSPATH, WP_CONTENT_DIR, WP_PLUGIN_DIR, WP_CONTENT_DIR . '/themes' );
if ( is_array( $wp_theme_directories ) ) {
$protected_directories = array_merge( $protected_directories, $wp_theme_directories );
}
if ( in_array( $destination, $protected_directories, true ) ) {
$remote_destination = trailingslashit( $remote_destination ) . trailingslashit( basename( $source ) );
$destination = trailingslashit( $destination ) . trailingslashit( basename( $source ) );
}
if ( $clear_destination ) {
// We're going to clear the destination if there's something there.
$this->skin->feedback( 'remove_old' );
$removed = $this->clear_destination( $remote_destination );
/**
* Filters whether the upgrader cleared the destination.
*
* @since 2.8.0
*
* @param true|WP_Error $removed Whether the destination was cleared.
* True upon success, WP_Error on failure.
* @param string $local_destination The local package destination.
* @param string $remote_destination The remote package destination.
* @param array $hook_extra Extra arguments passed to hooked filters.
*/
$removed = apply_filters( 'upgrader_clear_destination', $removed, $local_destination, $remote_destination, $args['hook_extra'] );
if ( is_wp_error( $removed ) ) {
return $removed;
}
} elseif ( $args['abort_if_destination_exists'] && $wp_filesystem->exists( $remote_destination ) ) {
/*
* If we're not clearing the destination folder and something exists there already, bail.
* But first check to see if there are actually any files in the folder.
*/
$_files = $wp_filesystem->dirlist( $remote_destination );
if ( ! empty( $_files ) ) {
$wp_filesystem->delete( $remote_source, true ); // Clear out the source files.
return new WP_Error( 'folder_exists', $this->strings['folder_exists'], $remote_destination );
}
}
/*
* If 'clear_working' is false, the source should not be removed, so use copy_dir() instead.
*
* Partial updates, like language packs, may want to retain the destination.
* If the destination exists or has contents, this may be a partial update,
* and the destination should not be removed, so use copy_dir() instead.
*/
if ( $args['clear_working']
&& (
// Destination does not exist or has no contents.
! $wp_filesystem->exists( $remote_destination )
|| empty( $wp_filesystem->dirlist( $remote_destination ) )
)
) {
$result = move_dir( $source, $remote_destination, true );
} else {
// Create destination if needed.
if ( ! $wp_filesystem->exists( $remote_destination ) ) {
if ( ! $wp_filesystem->mkdir( $remote_destination, FS_CHMOD_DIR ) ) {
return new WP_Error( 'mkdir_failed_destination', $this->strings['mkdir_failed'], $remote_destination );
}
}
$result = copy_dir( $source, $remote_destination );
}
// Clear the working directory?
if ( $args['clear_working'] ) {
$wp_filesystem->delete( $remote_source, true );
}
if ( is_wp_error( $result ) ) {
return $result;
}
$destination_name = basename( str_replace( $local_destination, '', $destination ) );
if ( '.' === $destination_name ) {
$destination_name = '';
}
$this->result = compact( 'source', 'source_files', 'destination', 'destination_name', 'local_destination', 'remote_destination', 'clear_destination' );
/**
* Filters the installation response after the installation has finished.
*
* @since 2.8.0
*
* @param bool $response Installation response.
* @param array $hook_extra Extra arguments passed to hooked filters.
* @param array $result Installation result data.
*/
$res = apply_filters( 'upgrader_post_install', true, $args['hook_extra'], $this->result );
if ( is_wp_error( $res ) ) {
$this->result = $res;
return $res;
}
// Bombard the calling function will all the info which we've just used.
return $this->result;
}
/**
* Runs an upgrade/installation.
*
* Attempts to download the package (if it is not a local file), unpack it, and
* install it in the destination folder.
*
* @since 2.8.0
*
* @param array $options {
* Array or string of arguments for upgrading/installing a package.
*
* @type string $package The full path or URI of the package to install.
* Default empty.
* @type string $destination The full path to the destination folder.
* Default empty.
* @type bool $clear_destination Whether to delete any files already in the
* destination folder. Default false.
* @type bool $clear_working Whether to delete the files from the working
* directory after copying them to the destination.
* Default true.
* @type bool $abort_if_destination_exists Whether to abort the installation if the destination
* folder already exists. When true, `$clear_destination`
* should be false. Default true.
* @type bool $is_multi Whether this run is one of multiple upgrade/installation
* actions being performed in bulk. When true, the skin
* WP_Upgrader::header() and WP_Upgrader::footer()
* aren't called. Default false.
* @type array $hook_extra Extra arguments to pass to the filter hooks called by
* WP_Upgrader::run().
* }
* @return array|false|WP_Error The result from self::install_package() on success, otherwise a WP_Error,
* or false if unable to connect to the filesystem.
*/
public function run( $options ) {
$defaults = array(
'package' => '', // Please always pass this.
'destination' => '', // ...and this.
'clear_destination' => false,
'clear_working' => true,
'abort_if_destination_exists' => true, // Abort if the destination directory exists. Pass clear_destination as false please.
'is_multi' => false,
'hook_extra' => array(), // Pass any extra $hook_extra args here, this will be passed to any hooked filters.
);
$options = wp_parse_args( $options, $defaults );
/**
* Filters the package options before running an update.
*
* See also {@see 'upgrader_process_complete'}.
*
* @since 4.3.0
*
* @param array $options {
* Options used by the upgrader.
*
* @type string $package Package for update.
* @type string $destination Update location.
* @type bool $clear_destination Clear the destination resource.
* @type bool $clear_working Clear the working resource.
* @type bool $abort_if_destination_exists Abort if the Destination directory exists.
* @type bool $is_multi Whether the upgrader is running multiple times.
* @type array $hook_extra {
* Extra hook arguments.
*
* @type string $action Type of action. Default 'update'.
* @type string $type Type of update process. Accepts 'plugin', 'theme', or 'core'.
* @type bool $bulk Whether the update process is a bulk update. Default true.
* @type string $plugin Path to the plugin file relative to the plugins directory.
* @type string $theme The stylesheet or template name of the theme.
* @type string $language_update_type The language pack update type. Accepts 'plugin', 'theme',
* or 'core'.
* @type object $language_update The language pack update offer.
* }
* }
*/
$options = apply_filters( 'upgrader_package_options', $options );
if ( ! $options['is_multi'] ) { // Call $this->header separately if running multiple times.
$this->skin->header();
}
// Connect to the filesystem first.
$res = $this->fs_connect( array( WP_CONTENT_DIR, $options['destination'] ) );
// Mainly for non-connected filesystem.
if ( ! $res ) {
if ( ! $options['is_multi'] ) {
$this->skin->footer();
}
return false;
}
$this->skin->before();
if ( is_wp_error( $res ) ) {
$this->skin->error( $res );
$this->skin->after();
if ( ! $options['is_multi'] ) {
$this->skin->footer();
}
return $res;
}
/*
* Download the package. Note: If the package is the full path
* to an existing local file, it will be returned untouched.
*/
$download = $this->download_package( $options['package'], false, $options['hook_extra'] );
/*
* Allow for signature soft-fail.
* WARNING: This may be removed in the future.
*/
if ( is_wp_error( $download ) && $download->get_error_data( 'softfail-filename' ) ) {
// Don't output the 'no signature could be found' failure message for now.
if ( 'signature_verification_no_signature' !== $download->get_error_code() || WP_DEBUG ) {
// Output the failure error as a normal feedback, and not as an error.
$this->skin->feedback( $download->get_error_message() );
// Report this failure back to WordPress.org for debugging purposes.
wp_version_check(
array(
'signature_failure_code' => $download->get_error_code(),
'signature_failure_data' => $download->get_error_data(),
)
);
}
// Pretend this error didn't happen.
$download = $download->get_error_data( 'softfail-filename' );
}
if ( is_wp_error( $download ) ) {
$this->skin->error( $download );
$this->skin->after();
if ( ! $options['is_multi'] ) {
$this->skin->footer();
}
return $download;
}
$delete_package = ( $download !== $options['package'] ); // Do not delete a "local" file.
// Unzips the file into a temporary directory.
$working_dir = $this->unpack_package( $download, $delete_package );
if ( is_wp_error( $working_dir ) ) {
$this->skin->error( $working_dir );
$this->skin->after();
if ( ! $options['is_multi'] ) {
$this->skin->footer();
}
return $working_dir;
}
// With the given options, this installs it to the destination directory.
$result = $this->install_package(
array(
'source' => $working_dir,
'destination' => $options['destination'],
'clear_destination' => $options['clear_destination'],
'abort_if_destination_exists' => $options['abort_if_destination_exists'],
'clear_working' => $options['clear_working'],
'hook_extra' => $options['hook_extra'],
)
);
/**
* Filters the result of WP_Upgrader::install_package().
*
* @since 5.7.0
*
* @param array|WP_Error $result Result from WP_Upgrader::install_package().
* @param array $hook_extra Extra arguments passed to hooked filters.
*/
$result = apply_filters( 'upgrader_install_package_result', $result, $options['hook_extra'] );
$this->skin->set_result( $result );
if ( is_wp_error( $result ) ) {
// An automatic plugin update will have already performed its rollback.
if ( ! empty( $options['hook_extra']['temp_backup'] ) ) {
$this->temp_restores[] = $options['hook_extra']['temp_backup'];
/*
* Restore the backup on shutdown.
* Actions running on `shutdown` are immune to PHP timeouts,
* so in case the failure was due to a PHP timeout,
* it will still be able to properly restore the previous version.
*
* Zero arguments are accepted as a string can sometimes be passed
* internally during actions, causing an error because
* `WP_Upgrader::restore_temp_backup()` expects an array.
*/
add_action( 'shutdown', array( $this, 'restore_temp_backup' ), 10, 0 );
}
$this->skin->error( $result );
if ( ! method_exists( $this->skin, 'hide_process_failed' ) || ! $this->skin->hide_process_failed( $result ) ) {
$this->skin->feedback( 'process_failed' );
}
} else {
// Installation succeeded.
$this->skin->feedback( 'process_success' );
}
$this->skin->after();
// Clean up the backup kept in the temporary backup directory.
if ( ! empty( $options['hook_extra']['temp_backup'] ) ) {
// Delete the backup on `shutdown` to avoid a PHP timeout.
add_action( 'shutdown', array( $this, 'delete_temp_backup' ), 100, 0 );
}
if ( ! $options['is_multi'] ) {
/**
* Fires when the upgrader process is complete.
*
* See also {@see 'upgrader_package_options'}.
*
* @since 3.6.0
* @since 3.7.0 Added to WP_Upgrader::run().
* @since 4.6.0 `$translations` was added as a possible argument to `$hook_extra`.
*
* @param WP_Upgrader $upgrader WP_Upgrader instance. In other contexts this might be a
* Theme_Upgrader, Plugin_Upgrader, Core_Upgrade, or Language_Pack_Upgrader instance.
* @param array $hook_extra {
* Array of bulk item update data.
*
* @type string $action Type of action. Default 'update'.
* @type string $type Type of update process. Accepts 'plugin', 'theme', 'translation', or 'core'.
* @type bool $bulk Whether the update process is a bulk update. Default true.
* @type array $plugins Array of the basename paths of the plugins' main files.
* @type array $themes The theme slugs.
* @type array $translations {
* Array of translations update data.
*
* @type string $language The locale the translation is for.
* @type string $type Type of translation. Accepts 'plugin', 'theme', or 'core'.
* @type string $slug Text domain the translation is for. The slug of a theme/plugin or
* 'default' for core translations.
* @type string $version The version of a theme, plugin, or core.
* }
* }
*/
do_action( 'upgrader_process_complete', $this, $options['hook_extra'] );
$this->skin->footer();
}
return $result;
}
/**
* Toggles maintenance mode for the site.
*
* Creates/deletes the maintenance file to enable/disable maintenance mode.
*
* @since 2.8.0
*
* @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
*
* @param bool $enable True to enable maintenance mode, false to disable.
*/
public function maintenance_mode( $enable = false ) {
global $wp_filesystem;
if ( ! $wp_filesystem ) {
require_once ABSPATH . 'wp-admin/includes/file.php';
WP_Filesystem();
}
$file = $wp_filesystem->abspath() . '.maintenance';
if ( $enable ) {
if ( ! wp_doing_cron() ) {
$this->skin->feedback( 'maintenance_start' );
}
// Create maintenance file to signal that we are upgrading.
$maintenance_string = '';
$wp_filesystem->delete( $file );
$wp_filesystem->put_contents( $file, $maintenance_string, FS_CHMOD_FILE );
} elseif ( ! $enable && $wp_filesystem->exists( $file ) ) {
if ( ! wp_doing_cron() ) {
$this->skin->feedback( 'maintenance_end' );
}
$wp_filesystem->delete( $file );
}
}
/**
* Creates a lock using WordPress options.
*
* @since 4.5.0
*
* @global wpdb $wpdb The WordPress database abstraction object.
*
* @param string $lock_name The name of this unique lock.
* @param int $release_timeout Optional. The duration in seconds to respect an existing lock.
* Default: 1 hour.
* @return bool False if a lock couldn't be created or if the lock is still valid. True otherwise.
*/
public static function create_lock( $lock_name, $release_timeout = null ) {
global $wpdb;
if ( ! $release_timeout ) {
$release_timeout = HOUR_IN_SECONDS;
}
$lock_option = $lock_name . '.lock';
// Try to lock.
$lock_result = $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO `$wpdb->options` ( `option_name`, `option_value`, `autoload` ) VALUES (%s, %s, 'off') /* LOCK */", $lock_option, time() ) );
if ( ! $lock_result ) {
$lock_result = get_option( $lock_option );
// If a lock couldn't be created, and there isn't a lock, bail.
if ( ! $lock_result ) {
return false;
}
// Check to see if the lock is still valid. If it is, bail.
if ( $lock_result > ( time() - $release_timeout ) ) {
return false;
}
// There must exist an expired lock, clear it and re-gain it.
WP_Upgrader::release_lock( $lock_name );
return WP_Upgrader::create_lock( $lock_name, $release_timeout );
}
// Update the lock, as by this point we've definitely got a lock, just need to fire the actions.
update_option( $lock_option, time(), false );
return true;
}
/**
* Releases an upgrader lock.
*
* @since 4.5.0
*
* @see WP_Upgrader::create_lock()
*
* @param string $lock_name The name of this unique lock.
* @return bool True if the lock was successfully released. False on failure.
*/
public static function release_lock( $lock_name ) {
return delete_option( $lock_name . '.lock' );
}
/**
* Moves the plugin or theme being updated into a temporary backup directory.
*
* @since 6.3.0
*
* @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
*
* @param string[] $args {
* Array of data for the temporary backup.
*
* @type string $slug Plugin or theme slug.
* @type string $src Path to the root directory for plugins or themes.
* @type string $dir Destination subdirectory name. Accepts 'plugins' or 'themes'.
* }
*
* @return bool|WP_Error True on success, false on early exit, otherwise WP_Error.
*/
public function move_to_temp_backup_dir( $args ) {
global $wp_filesystem;
if ( empty( $args['slug'] ) || empty( $args['src'] ) || empty( $args['dir'] ) ) {
return false;
}
/*
* Skip any plugin that has "." as its slug.
* A slug of "." will result in a `$src` value ending in a period.
*
* On Windows, this will cause the 'plugins' folder to be moved,
* and will cause a failure when attempting to call `mkdir()`.
*/
if ( '.' === $args['slug'] ) {
return false;
}
if ( ! $wp_filesystem->wp_content_dir() ) {
return new WP_Error( 'fs_no_content_dir', $this->strings['fs_no_content_dir'] );
}
$dest_dir = $wp_filesystem->wp_content_dir() . 'upgrade-temp-backup/';
$sub_dir = $dest_dir . $args['dir'] . '/';
// Create the temporary backup directory if it does not exist.
if ( ! $wp_filesystem->is_dir( $sub_dir ) ) {
if ( ! $wp_filesystem->is_dir( $dest_dir ) ) {
$wp_filesystem->mkdir( $dest_dir, FS_CHMOD_DIR );
}
if ( ! $wp_filesystem->mkdir( $sub_dir, FS_CHMOD_DIR ) ) {
// Could not create the backup directory.
return new WP_Error( 'fs_temp_backup_mkdir', $this->strings['temp_backup_mkdir_failed'] );
}
}
$src_dir = $wp_filesystem->find_folder( $args['src'] );
$src = trailingslashit( $src_dir ) . $args['slug'];
$dest = $dest_dir . trailingslashit( $args['dir'] ) . $args['slug'];
// Delete the temporary backup directory if it already exists.
if ( $wp_filesystem->is_dir( $dest ) ) {
$wp_filesystem->delete( $dest, true );
}
// Move to the temporary backup directory.
$result = move_dir( $src, $dest, true );
if ( is_wp_error( $result ) ) {
return new WP_Error( 'fs_temp_backup_move', $this->strings['temp_backup_move_failed'] );
}
return true;
}
/**
* Restores the plugin or theme from temporary backup.
*
* @since 6.3.0
* @since 6.6.0 Added the `$temp_backups` parameter.
*
* @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
*
* @param array[] $temp_backups {
* Optional. An array of temporary backups.
*
* @type array ...$0 {
* Information about the backup.
*
* @type string $dir The temporary backup location in the upgrade-temp-backup directory.
* @type string $slug The item's slug.
* @type string $src The directory where the original is stored. For example, `WP_PLUGIN_DIR`.
* }
* }
* @return bool|WP_Error True on success, false on early exit, otherwise WP_Error.
*/
public function restore_temp_backup( array $temp_backups = array() ) {
global $wp_filesystem;
$errors = new WP_Error();
if ( empty( $temp_backups ) ) {
$temp_backups = $this->temp_restores;
}
foreach ( $temp_backups as $args ) {
if ( empty( $args['slug'] ) || empty( $args['src'] ) || empty( $args['dir'] ) ) {
return false;
}
if ( ! $wp_filesystem->wp_content_dir() ) {
$errors->add( 'fs_no_content_dir', $this->strings['fs_no_content_dir'] );
return $errors;
}
$src = $wp_filesystem->wp_content_dir() . 'upgrade-temp-backup/' . $args['dir'] . '/' . $args['slug'];
$dest_dir = $wp_filesystem->find_folder( $args['src'] );
$dest = trailingslashit( $dest_dir ) . $args['slug'];
if ( $wp_filesystem->is_dir( $src ) ) {
// Cleanup.
if ( $wp_filesystem->is_dir( $dest ) && ! $wp_filesystem->delete( $dest, true ) ) {
$errors->add(
'fs_temp_backup_delete',
sprintf( $this->strings['temp_backup_restore_failed'], $args['slug'] )
);
continue;
}
// Move it.
$result = move_dir( $src, $dest, true );
if ( is_wp_error( $result ) ) {
$errors->add(
'fs_temp_backup_delete',
sprintf( $this->strings['temp_backup_restore_failed'], $args['slug'] )
);
continue;
}
}
}
return $errors->has_errors() ? $errors : true;
}
/**
* Deletes a temporary backup.
*
* @since 6.3.0
* @since 6.6.0 Added the `$temp_backups` parameter.
*
* @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
*
* @param array[] $temp_backups {
* Optional. An array of temporary backups.
*
* @type array ...$0 {
* Information about the backup.
*
* @type string $dir The temporary backup location in the upgrade-temp-backup directory.
* @type string $slug The item's slug.
* @type string $src The directory where the original is stored. For example, `WP_PLUGIN_DIR`.
* }
* }
* @return bool|WP_Error True on success, false on early exit, otherwise WP_Error.
*/
public function delete_temp_backup( array $temp_backups = array() ) {
global $wp_filesystem;
$errors = new WP_Error();
if ( empty( $temp_backups ) ) {
$temp_backups = $this->temp_backups;
}
foreach ( $temp_backups as $args ) {
if ( empty( $args['slug'] ) || empty( $args['dir'] ) ) {
return false;
}
if ( ! $wp_filesystem->wp_content_dir() ) {
$errors->add( 'fs_no_content_dir', $this->strings['fs_no_content_dir'] );
return $errors;
}
$temp_backup_dir = $wp_filesystem->wp_content_dir() . "upgrade-temp-backup/{$args['dir']}/{$args['slug']}";
if ( ! $wp_filesystem->delete( $temp_backup_dir, true ) ) {
$errors->add(
'temp_backup_delete_failed',
sprintf( $this->strings['temp_backup_delete_failed'], $args['slug'] )
);
continue;
}
}
return $errors->has_errors() ? $errors : true;
}
}
/** Plugin_Upgrader class */
require_once ABSPATH . 'wp-admin/includes/class-plugin-upgrader.php';
/** Theme_Upgrader class */
require_once ABSPATH . 'wp-admin/includes/class-theme-upgrader.php';
/** Language_Pack_Upgrader class */
require_once ABSPATH . 'wp-admin/includes/class-language-pack-upgrader.php';
/** Core_Upgrader class */
require_once ABSPATH . 'wp-admin/includes/class-core-upgrader.php';
/** File_Upload_Upgrader class */
require_once ABSPATH . 'wp-admin/includes/class-file-upload-upgrader.php';
/** WP_Automatic_Updater class */
require_once ABSPATH . 'wp-admin/includes/class-wp-automatic-updater.php';
includes/class-wp-privacy-data-export-requests-list-table.php 0000755 00000012673 14744541145 0020451 0 ustar 00 status;
$request_id = $item->ID;
$nonce = wp_create_nonce( 'wp-privacy-export-personal-data-' . $request_id );
$download_data_markup = '';
$download_data_markup .= '' .
'' . __( 'Downloading data...' ) . ' ' .
'' .
'' . __( 'Download failed.' ) . ' ';
$download_data_markup .= '';
$row_actions['download-data'] = $download_data_markup;
if ( 'request-completed' !== $status ) {
$complete_request_markup = '';
$complete_request_markup .= sprintf(
'%s',
esc_url(
wp_nonce_url(
add_query_arg(
array(
'action' => 'complete',
'request_id' => array( $request_id ),
),
admin_url( 'export-personal-data.php' )
),
'bulk-privacy_requests'
)
),
esc_attr(
sprintf(
/* translators: %s: Request email. */
__( 'Mark export request for “%s” as completed.' ),
$item->email
)
),
__( 'Complete request' )
);
$complete_request_markup .= '';
}
if ( ! empty( $complete_request_markup ) ) {
$row_actions['complete-request'] = $complete_request_markup;
}
return sprintf( '%2$s %3$s', esc_url( 'mailto:' . $item->email ), $item->email, $this->row_actions( $row_actions ) );
}
/**
* Displays the next steps column.
*
* @since 4.9.6
*
* @param WP_User_Request $item Item being shown.
*/
public function column_next_steps( $item ) {
$status = $item->status;
switch ( $status ) {
case 'request-pending':
esc_html_e( 'Waiting for confirmation' );
break;
case 'request-confirmed':
/** This filter is documented in wp-admin/includes/ajax-actions.php */
$exporters = apply_filters( 'wp_privacy_personal_data_exporters', array() );
$exporters_count = count( $exporters );
$request_id = $item->ID;
$nonce = wp_create_nonce( 'wp-privacy-export-personal-data-' . $request_id );
echo '';
?>
';
break;
case 'request-failed':
echo '
';
break;
case 'request-completed':
echo '
' . esc_html__( 'Remove request' ) . '';
break;
}
}
}
includes/widgets.php 0000755 00000025240 14744541145 0010550 0 ustar 00 $widget['id'],
'widget_name' => $widget['name'],
'_display' => 'template',
);
if ( isset( $wp_registered_widget_controls[ $widget['id'] ]['id_base'] ) && isset( $widget['params'][0]['number'] ) ) {
$id_base = $wp_registered_widget_controls[ $widget['id'] ]['id_base'];
$args['_temp_id'] = "$id_base-__i__";
$args['_multi_num'] = next_widget_id_number( $id_base );
$args['_add'] = 'multi';
} else {
$args['_add'] = 'single';
if ( $sidebar ) {
$args['_hide'] = '1';
}
}
$control_args = array(
0 => $args,
1 => $widget['params'][0],
);
$sidebar_args = wp_list_widget_controls_dynamic_sidebar( $control_args );
wp_widget_control( ...$sidebar_args );
}
}
/**
* Callback to sort array by a 'name' key.
*
* @since 3.1.0
* @access private
*
* @param array $a First array.
* @param array $b Second array.
* @return int
*/
function _sort_name_callback( $a, $b ) {
return strnatcasecmp( $a['name'], $b['name'] );
}
/**
* Show the widgets and their settings for a sidebar.
* Used in the admin widget config screen.
*
* @since 2.5.0
*
* @param string $sidebar Sidebar ID.
* @param string $sidebar_name Optional. Sidebar name. Default empty.
*/
function wp_list_widget_controls( $sidebar, $sidebar_name = '' ) {
add_filter( 'dynamic_sidebar_params', 'wp_list_widget_controls_dynamic_sidebar' );
$description = wp_sidebar_description( $sidebar );
echo '
' . _x( 'Name', 'meta name' ) . ' |
' . __( 'Value' ) . ' |
|
'; // TBODY needed for list-manipulation JS.
return;
}
$count = 0;
?>
.
$entry['meta_id'] = (int) $entry['meta_id'];
$delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] );
$r .= "\n\t
";
$r .= "\n\t\t";
$r .= "\n\t\t ";
$r .= get_submit_button( __( 'Delete' ), 'deletemeta small', "deletemeta[{$entry['meta_id']}]", false, array( 'data-wp-lists' => "delete:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$delete_nonce" ) );
$r .= "\n\t\t";
$r .= get_submit_button( __( 'Update' ), 'updatemeta small', "meta-{$entry['meta_id']}-submit", false, array( 'data-wp-lists' => "add:the-list:meta-{$entry['meta_id']}::_ajax_nonce-add-meta=$update_nonce" ) );
$r .= ' ';
$r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false );
$r .= ' | ';
$r .= "\n\t\t | \n\t
";
return $r;
}
/**
* Prints the form in the Custom Fields meta box.
*
* @since 1.2.0
*
* @global wpdb $wpdb WordPress database abstraction object.
*
* @param WP_Post $post Optional. The post being edited.
*/
function meta_form( $post = null ) {
global $wpdb;
$post = get_post( $post );
/**
* Filters values for the meta key dropdown in the Custom Fields meta box.
*
* Returning a non-null value will effectively short-circuit and avoid a
* potentially expensive query against postmeta.
*
* @since 4.4.0
*
* @param array|null $keys Pre-defined meta keys to be used in place of a postmeta query. Default null.
* @param WP_Post $post The current post object.
*/
$keys = apply_filters( 'postmeta_form_keys', null, $post );
if ( null === $keys ) {
/**
* Filters the number of custom fields to retrieve for the drop-down
* in the Custom Fields meta box.
*
* @since 2.1.0
*
* @param int $limit Number of custom fields to retrieve. Default 30.
*/
$limit = apply_filters( 'postmeta_form_limit', 30 );
$keys = $wpdb->get_col(
$wpdb->prepare(
"SELECT DISTINCT meta_key
FROM $wpdb->postmeta
WHERE meta_key NOT BETWEEN '_' AND '_z'
HAVING meta_key NOT LIKE %s
ORDER BY meta_key
LIMIT %d",
$wpdb->esc_like( '_' ) . '%',
$limit
)
);
}
if ( $keys ) {
natcasesort( $keys );
}
?>
'newmeta-submit',
'data-wp-lists' => 'add:the-list:newmeta',
)
);
?>
post_status, array( 'draft', 'pending' ), true ) && ( ! $post->post_date_gmt || '0000-00-00 00:00:00' === $post->post_date_gmt ) );
}
$tab_index_attribute = '';
if ( (int) $tab_index > 0 ) {
$tab_index_attribute = " tabindex=\"$tab_index\"";
}
// @todo Remove this?
// echo '
';
$post_date = ( $for_post ) ? $post->post_date : get_comment()->comment_date;
$jj = ( $edit ) ? mysql2date( 'd', $post_date, false ) : current_time( 'd' );
$mm = ( $edit ) ? mysql2date( 'm', $post_date, false ) : current_time( 'm' );
$aa = ( $edit ) ? mysql2date( 'Y', $post_date, false ) : current_time( 'Y' );
$hh = ( $edit ) ? mysql2date( 'H', $post_date, false ) : current_time( 'H' );
$mn = ( $edit ) ? mysql2date( 'i', $post_date, false ) : current_time( 'i' );
$ss = ( $edit ) ? mysql2date( 's', $post_date, false ) : current_time( 's' );
$cur_jj = current_time( 'd' );
$cur_mm = current_time( 'm' );
$cur_aa = current_time( 'Y' );
$cur_hh = current_time( 'H' );
$cur_mn = current_time( 'i' );
$month = '
';
$day = '
';
$year = '
';
$hour = '
';
$minute = '
';
echo '
';
/* translators: 1: Month, 2: Day, 3: Year, 4: Hour, 5: Minute. */
printf( __( '%1$s %2$s, %3$s at %4$s:%5$s' ), $month, $day, $year, $hour, $minute );
echo '
';
if ( $multi ) {
return;
}
echo "\n\n";
$map = array(
'mm' => array( $mm, $cur_mm ),
'jj' => array( $jj, $cur_jj ),
'aa' => array( $aa, $cur_aa ),
'hh' => array( $hh, $cur_hh ),
'mn' => array( $mn, $cur_mn ),
);
foreach ( $map as $timeunit => $value ) {
list( $unit, $curr ) = $value;
echo '
' . "\n";
$cur_timeunit = 'cur_' . $timeunit;
echo '
' . "\n";
}
?>
" . esc_html( $template ) . '';
}
}
/**
* Prints out option HTML elements for the page parents drop-down.
*
* @since 1.5.0
* @since 4.4.0 `$post` argument was added.
*
* @global wpdb $wpdb WordPress database abstraction object.
*
* @param int $default_page Optional. The default page ID to be pre-selected. Default 0.
* @param int $parent_page Optional. The parent page ID. Default 0.
* @param int $level Optional. Page depth level. Default 0.
* @param int|WP_Post $post Post ID or WP_Post object.
* @return void|false Void on success, false if the page has no children.
*/
function parent_dropdown( $default_page = 0, $parent_page = 0, $level = 0, $post = null ) {
global $wpdb;
$post = get_post( $post );
$items = $wpdb->get_results(
$wpdb->prepare(
"SELECT ID, post_parent, post_title
FROM $wpdb->posts
WHERE post_parent = %d AND post_type = 'page'
ORDER BY menu_order",
$parent_page
)
);
if ( $items ) {
foreach ( $items as $item ) {
// A page cannot be its own parent.
if ( $post && $post->ID && (int) $item->ID === $post->ID ) {
continue;
}
$pad = str_repeat( ' ', $level * 3 );
$selected = selected( $default_page, $item->ID, false );
echo "\n\t
';
parent_dropdown( $default_page, $item->ID, $level + 1 );
}
} else {
return false;
}
}
/**
* Prints out option HTML elements for role selectors.
*
* @since 2.1.0
*
* @param string $selected Slug for the role that should be already selected.
*/
function wp_dropdown_roles( $selected = '' ) {
$r = '';
$editable_roles = array_reverse( get_editable_roles() );
foreach ( $editable_roles as $role => $details ) {
$name = translate_user_role( $details['name'] );
// Preselect specified role.
if ( $selected === $role ) {
$r .= "\n\t
";
} else {
$r .= "\n\t
";
}
}
echo $r;
}
/**
* Outputs the form used by the importers to accept the data to be imported.
*
* @since 2.0.0
*
* @param string $action The action attribute for the form.
*/
function wp_import_upload_form( $action ) {
/**
* Filters the maximum allowed upload size for import files.
*
* @since 2.3.0
*
* @see wp_max_upload_size()
*
* @param int $max_upload_size Allowed upload size. Default 1 MB.
*/
$bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() );
$size = size_format( $bytes );
$upload_dir = wp_upload_dir();
if ( ! empty( $upload_dir['error'] ) ) :
$upload_directory_error = '
' . __( 'Before you can upload your import file, you will need to fix the following error:' ) . '
';
$upload_directory_error .= '
' . $upload_dir['error'] . '
';
wp_admin_notice(
$upload_directory_error,
array(
'additional_classes' => array( 'error' ),
'paragraph_wrap' => false,
)
);
else :
?>
id ) ) {
return;
}
$page = $screen->id;
if ( ! isset( $wp_meta_boxes ) ) {
$wp_meta_boxes = array();
}
if ( ! isset( $wp_meta_boxes[ $page ] ) ) {
$wp_meta_boxes[ $page ] = array();
}
if ( ! isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
$wp_meta_boxes[ $page ][ $context ] = array();
}
foreach ( array_keys( $wp_meta_boxes[ $page ] ) as $a_context ) {
foreach ( array( 'high', 'core', 'default', 'low' ) as $a_priority ) {
if ( ! isset( $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ] ) ) {
continue;
}
// If a core box was previously removed, don't add.
if ( ( 'core' === $priority || 'sorted' === $priority )
&& false === $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ]
) {
return;
}
// If a core box was previously added by a plugin, don't add.
if ( 'core' === $priority ) {
/*
* If the box was added with default priority, give it core priority
* to maintain sort order.
*/
if ( 'default' === $a_priority ) {
$wp_meta_boxes[ $page ][ $a_context ]['core'][ $id ] = $wp_meta_boxes[ $page ][ $a_context ]['default'][ $id ];
unset( $wp_meta_boxes[ $page ][ $a_context ]['default'][ $id ] );
}
return;
}
// If no priority given and ID already present, use existing priority.
if ( empty( $priority ) ) {
$priority = $a_priority;
/*
* Else, if we're adding to the sorted priority, we don't know the title
* or callback. Grab them from the previously added context/priority.
*/
} elseif ( 'sorted' === $priority ) {
$title = $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ]['title'];
$callback = $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ]['callback'];
$callback_args = $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ]['args'];
}
// An ID can be in only one priority and one context.
if ( $priority !== $a_priority || $context !== $a_context ) {
unset( $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ] );
}
}
}
if ( empty( $priority ) ) {
$priority = 'low';
}
if ( ! isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) {
$wp_meta_boxes[ $page ][ $context ][ $priority ] = array();
}
$wp_meta_boxes[ $page ][ $context ][ $priority ][ $id ] = array(
'id' => $id,
'title' => $title,
'callback' => $callback,
'args' => $callback_args,
);
}
/**
* Renders a "fake" meta box with an information message,
* shown on the block editor, when an incompatible meta box is found.
*
* @since 5.0.0
*
* @param mixed $data_object The data object being rendered on this screen.
* @param array $box {
* Custom formats meta box arguments.
*
* @type string $id Meta box 'id' attribute.
* @type string $title Meta box title.
* @type callable $old_callback The original callback for this meta box.
* @type array $args Extra meta box arguments.
* }
*/
function do_block_editor_incompatible_meta_box( $data_object, $box ) {
$plugin = _get_plugin_from_callback( $box['old_callback'] );
$plugins = get_plugins();
echo '
';
if ( $plugin ) {
/* translators: %s: The name of the plugin that generated this meta box. */
printf( __( 'This meta box, from the %s plugin, is not compatible with the block editor.' ), "{$plugin['Name']}" );
} else {
_e( 'This meta box is not compatible with the block editor.' );
}
echo '
';
if ( empty( $plugins['classic-editor/classic-editor.php'] ) ) {
if ( current_user_can( 'install_plugins' ) ) {
$install_url = wp_nonce_url(
self_admin_url( 'plugin-install.php?tab=favorites&user=wordpressdotorg&save=0' ),
'save_wporg_username_' . get_current_user_id()
);
echo '
';
/* translators: %s: A link to install the Classic Editor plugin. */
printf( __( 'Please install the Classic Editor plugin to use this meta box.' ), esc_url( $install_url ) );
echo '
';
}
} elseif ( is_plugin_inactive( 'classic-editor/classic-editor.php' ) ) {
if ( current_user_can( 'activate_plugins' ) ) {
$activate_url = wp_nonce_url(
self_admin_url( 'plugins.php?action=activate&plugin=classic-editor/classic-editor.php' ),
'activate-plugin_classic-editor/classic-editor.php'
);
echo '
';
/* translators: %s: A link to activate the Classic Editor plugin. */
printf( __( 'Please activate the Classic Editor plugin to use this meta box.' ), esc_url( $activate_url ) );
echo '
';
}
} elseif ( $data_object instanceof WP_Post ) {
$edit_url = add_query_arg(
array(
'classic-editor' => '',
'classic-editor__forget' => '',
),
get_edit_post_link( $data_object )
);
echo '
';
/* translators: %s: A link to use the Classic Editor plugin. */
printf( __( 'Please open the classic editor to use this meta box.' ), esc_url( $edit_url ) );
echo '
';
}
}
/**
* Internal helper function to find the plugin from a meta box callback.
*
* @since 5.0.0
*
* @access private
*
* @param callable $callback The callback function to check.
* @return array|null The plugin that the callback belongs to, or null if it doesn't belong to a plugin.
*/
function _get_plugin_from_callback( $callback ) {
try {
if ( is_array( $callback ) ) {
$reflection = new ReflectionMethod( $callback[0], $callback[1] );
} elseif ( is_string( $callback ) && str_contains( $callback, '::' ) ) {
$reflection = new ReflectionMethod( $callback );
} else {
$reflection = new ReflectionFunction( $callback );
}
} catch ( ReflectionException $exception ) {
// We could not properly reflect on the callable, so we abort here.
return null;
}
// Don't show an error if it's an internal PHP function.
if ( ! $reflection->isInternal() ) {
// Only show errors if the meta box was registered by a plugin.
$filename = wp_normalize_path( $reflection->getFileName() );
$plugin_dir = wp_normalize_path( WP_PLUGIN_DIR );
if ( str_starts_with( $filename, $plugin_dir ) ) {
$filename = str_replace( $plugin_dir, '', $filename );
$filename = preg_replace( '|^/([^/]*/).*$|', '\\1', $filename );
$plugins = get_plugins();
foreach ( $plugins as $name => $plugin ) {
if ( str_starts_with( $name, $filename ) ) {
return $plugin;
}
}
}
}
return null;
}
/**
* Meta-Box template function.
*
* @since 2.5.0
*
* @global array $wp_meta_boxes Global meta box state.
*
* @param string|WP_Screen $screen The screen identifier. If you have used add_menu_page() or
* add_submenu_page() to create a new screen (and hence screen_id)
* make sure your menu slug conforms to the limits of sanitize_key()
* otherwise the 'screen' menu may not correctly render on your page.
* @param string $context The screen context for which to display meta boxes.
* @param mixed $data_object Gets passed to the meta box callback function as the first parameter.
* Often this is the object that's the focus of the current screen,
* for example a `WP_Post` or `WP_Comment` object.
* @return int Number of meta_boxes.
*/
function do_meta_boxes( $screen, $context, $data_object ) {
global $wp_meta_boxes;
static $already_sorted = false;
if ( empty( $screen ) ) {
$screen = get_current_screen();
} elseif ( is_string( $screen ) ) {
$screen = convert_to_screen( $screen );
}
$page = $screen->id;
$hidden = get_hidden_meta_boxes( $screen );
printf( '
';
return $i;
}
/**
* Removes a meta box from one or more screens.
*
* @since 2.6.0
* @since 4.4.0 The `$screen` parameter now accepts an array of screen IDs.
*
* @global array $wp_meta_boxes Global meta box state.
*
* @param string $id Meta box ID (used in the 'id' attribute for the meta box).
* @param string|array|WP_Screen $screen The screen or screens on which the meta box is shown (such as a
* post type, 'link', or 'comment'). Accepts a single screen ID,
* WP_Screen object, or array of screen IDs.
* @param string $context The context within the screen where the box is set to display.
* Contexts vary from screen to screen. Post edit screen contexts
* include 'normal', 'side', and 'advanced'. Comments screen contexts
* include 'normal' and 'side'. Menus meta boxes (accordion sections)
* all use the 'side' context.
*/
function remove_meta_box( $id, $screen, $context ) {
global $wp_meta_boxes;
if ( empty( $screen ) ) {
$screen = get_current_screen();
} elseif ( is_string( $screen ) ) {
$screen = convert_to_screen( $screen );
} elseif ( is_array( $screen ) ) {
foreach ( $screen as $single_screen ) {
remove_meta_box( $id, $single_screen, $context );
}
}
if ( ! isset( $screen->id ) ) {
return;
}
$page = $screen->id;
if ( ! isset( $wp_meta_boxes ) ) {
$wp_meta_boxes = array();
}
if ( ! isset( $wp_meta_boxes[ $page ] ) ) {
$wp_meta_boxes[ $page ] = array();
}
if ( ! isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
$wp_meta_boxes[ $page ][ $context ] = array();
}
foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) {
$wp_meta_boxes[ $page ][ $context ][ $priority ][ $id ] = false;
}
}
/**
* Meta Box Accordion Template Function.
*
* Largely made up of abstracted code from do_meta_boxes(), this
* function serves to build meta boxes as list items for display as
* a collapsible accordion.
*
* @since 3.6.0
*
* @uses global $wp_meta_boxes Used to retrieve registered meta boxes.
*
* @param string|object $screen The screen identifier.
* @param string $context The screen context for which to display accordion sections.
* @param mixed $data_object Gets passed to the section callback function as the first parameter.
* @return int Number of meta boxes as accordion sections.
*/
function do_accordion_sections( $screen, $context, $data_object ) {
global $wp_meta_boxes;
wp_enqueue_script( 'accordion' );
if ( empty( $screen ) ) {
$screen = get_current_screen();
} elseif ( is_string( $screen ) ) {
$screen = convert_to_screen( $screen );
}
$page = $screen->id;
$hidden = get_hidden_meta_boxes( $screen );
?>
$id,
'title' => $title,
'callback' => $callback,
'before_section' => '',
'after_section' => '',
'section_class' => '',
);
$section = wp_parse_args( $args, $defaults );
if ( 'misc' === $page ) {
_deprecated_argument(
__FUNCTION__,
'3.0.0',
sprintf(
/* translators: %s: misc */
__( 'The "%s" options group has been removed. Use another settings group.' ),
'misc'
)
);
$page = 'general';
}
if ( 'privacy' === $page ) {
_deprecated_argument(
__FUNCTION__,
'3.5.0',
sprintf(
/* translators: %s: privacy */
__( 'The "%s" options group has been removed. Use another settings group.' ),
'privacy'
)
);
$page = 'reading';
}
$wp_settings_sections[ $page ][ $id ] = $section;
}
/**
* Adds a new field to a section of a settings page.
*
* Part of the Settings API. Use this to define a settings field that will show
* as part of a settings section inside a settings page. The fields are shown using
* do_settings_fields() in do_settings_sections().
*
* The $callback argument should be the name of a function that echoes out the
* HTML input tags for this setting field. Use get_option() to retrieve existing
* values to show.
*
* @since 2.7.0
* @since 4.2.0 The `$class` argument was added.
*
* @global array $wp_settings_fields Storage array of settings fields and info about their pages/sections.
*
* @param string $id Slug-name to identify the field. Used in the 'id' attribute of tags.
* @param string $title Formatted title of the field. Shown as the label for the field
* during output.
* @param callable $callback Function that fills the field with the desired form inputs. The
* function should echo its output.
* @param string $page The slug-name of the settings page on which to show the section
* (general, reading, writing, ...).
* @param string $section Optional. The slug-name of the section of the settings page
* in which to show the box. Default 'default'.
* @param array $args {
* Optional. Extra arguments that get passed to the callback function.
*
* @type string $label_for When supplied, the setting title will be wrapped
* in a `