Code is Poetry.

WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.


Built from https://develop.svn.wordpress.org/trunk@42343


git-svn-id: http://core.svn.wordpress.org/trunk@42172 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Gary Pendergast 2017-11-30 23:11:00 +00:00
parent 62be7ad218
commit aaf99e6913
610 changed files with 55731 additions and 43711 deletions

View File

@ -18,8 +18,9 @@ if ( !is_multisite() ) {
die();
}
if ( is_object( $wp_object_cache ) )
if ( is_object( $wp_object_cache ) ) {
$wp_object_cache->cache_enabled = false;
}
// Fix for page title
$wp_query->is_404 = false;
@ -75,18 +76,19 @@ get_header( 'wp-activate' );
<div class="wp-activate-container">
<?php if ( empty( $_GET['key'] ) && empty( $_POST['key'] ) ) { ?>
<h2><?php _e('Activation Key Required') ?></h2>
<h2><?php _e( 'Activation Key Required' ); ?></h2>
<form name="activateform" id="activateform" method="post" action="<?php echo network_site_url( 'wp-activate.php' ); ?>">
<p>
<label for="key"><?php _e('Activation Key:') ?></label>
<label for="key"><?php _e( 'Activation Key:' ); ?></label>
<br /><input type="text" name="key" id="key" value="" size="50" />
</p>
<p class="submit">
<input id="submit" type="submit" name="Submit" class="submit" value="<?php esc_attr_e('Activate') ?>" />
<input id="submit" type="submit" name="Submit" class="submit" value="<?php esc_attr_e( 'Activate' ); ?>" />
</p>
</form>
<?php } else {
<?php
} else {
$key = ! empty( $_GET['key'] ) ? $_GET['key'] : $_POST['key'];
$result = wpmu_activate_signup( $key );
@ -130,25 +132,31 @@ get_header( 'wp-activate' );
<h2><?php _e( 'Your account is now active!' ); ?></h2>
<div id="signup-welcome">
<p><span class="h3"><?php _e('Username:'); ?></span> <?php echo $user->user_login ?></p>
<p><span class="h3"><?php _e( 'Username:' ); ?></span> <?php echo $user->user_login; ?></p>
<p><span class="h3"><?php _e( 'Password:' ); ?></span> <?php echo $result['password']; ?></p>
</div>
<?php if ( $url && $url != network_home_url( '', 'http' ) ) :
<?php
if ( $url && $url != network_home_url( '', 'http' ) ) :
switch_to_blog( (int) $result['blog_id'] );
$login_url = wp_login_url();
restore_current_blog();
?>
<p class="view"><?php
<p class="view">
<?php
/* translators: 1: site URL, 2: login URL */
printf( __( 'Your account is now activated. <a href="%1$s">View your site</a> or <a href="%2$s">Log in</a>' ), $url, esc_url( $login_url ) );
?></p>
?>
</p>
<?php else : ?>
<p class="view"><?php
<p class="view">
<?php
/* translators: 1: login URL, 2: network home URL */
printf( __( 'Your account is now activated. <a href="%1$s">Log in</a> or go back to the <a href="%2$s">homepage</a>.' ), network_site_url( 'wp-login.php', 'login' ), network_home_url() );
?></p>
<?php endif;
?>
</p>
<?php
endif;
}
}
?>
@ -158,4 +166,5 @@ get_header( 'wp-activate' );
var key_input = document.getElementById('key');
key_input && key_input.focus();
</script>
<?php get_footer( 'wp-activate' );
<?php
get_footer( 'wp-activate' );

View File

@ -182,33 +182,42 @@ include( ABSPATH . 'wp-admin/admin-header.php' );
);
?>
</h2>
<p><?php printf(
__( 'WordPress is working on a new way to create and control your content and we&#8217;d love to have your help. Interested in being an <a href="%s">early tester</a> or getting involved with the Gutenberg project? <a href="%s">Contribute on GitHub</a>.' ),
<p>
<?php
printf(
__( 'WordPress is working on a new way to create and control your content and we&#8217;d love to have your help. Interested in being an <a href="%1$s">early tester</a> or getting involved with the Gutenberg project? <a href="%2$s">Contribute on GitHub</a>.' ),
__( 'https://wordpress.org/plugins/gutenberg/' ),
'https://github.com/WordPress/gutenberg' ); ?></p>
'https://github.com/WordPress/gutenberg'
);
?>
</p>
</div>
<hr />
<div class="changelog">
<h2><?php
<h2>
<?php
printf(
/* translators: %s: smiling face with smiling eyes emoji */
__( 'Developer Happiness %s' ),
'&#x1F60A'
);
?></h2>
?>
</h2>
<div class="under-the-hood two-col">
<div class="col">
<h3><a href="https://make.wordpress.org/core/2017/11/01/improvements-to-the-customize-js-api-in-4-9/"><?php _e( 'Customizer JS API Improvements' ); ?></a></h3>
<p><?php
<p>
<?php
printf(
/* translators: %s: https://make.wordpress.org/core/2017/11/01/improvements-to-the-customize-js-api-in-4-9/ */
__( 'We&#8217;ve made numerous improvements to the Customizer JS API in WordPress 4.9, eliminating many pain points and making it just as easy to work with as the PHP API. There are also new base control templates, a date/time control, and section/panel/global notifications to name a few. <a href="%s">Check out the full list.</a>' ),
'https://make.wordpress.org/core/2017/11/01/improvements-to-the-customize-js-api-in-4-9/'
);
?></p>
?>
</p>
</div>
<div class="col">
<h3><a href="https://make.wordpress.org/core/2017/10/22/code-editing-improvements-in-wordpress-4-9/"><?php _e( 'CodeMirror available for use in your themes and plugins' ); ?></a></h3>
@ -352,16 +361,22 @@ __( '<strong>Version %s</strong> addressed one security issue.' );
__( '<strong>Version %s</strong> addressed some security issues.' );
/* translators: 1: WordPress version number, 2: plural number of bugs. */
_n_noop( '<strong>Version %1$s</strong> addressed %2$s bug.',
'<strong>Version %1$s</strong> addressed %2$s bugs.' );
_n_noop(
'<strong>Version %1$s</strong> addressed %2$s bug.',
'<strong>Version %1$s</strong> addressed %2$s bugs.'
);
/* translators: 1: WordPress version number, 2: plural number of bugs. Singular security issue. */
_n_noop( '<strong>Version %1$s</strong> addressed a security issue and fixed %2$s bug.',
'<strong>Version %1$s</strong> addressed a security issue and fixed %2$s bugs.' );
_n_noop(
'<strong>Version %1$s</strong> addressed a security issue and fixed %2$s bug.',
'<strong>Version %1$s</strong> addressed a security issue and fixed %2$s bugs.'
);
/* translators: 1: WordPress version number, 2: plural number of bugs. More than one security issue. */
_n_noop( '<strong>Version %1$s</strong> addressed some security issues and fixed %2$s bug.',
'<strong>Version %1$s</strong> addressed some security issues and fixed %2$s bugs.' );
_n_noop(
'<strong>Version %1$s</strong> addressed some security issues and fixed %2$s bug.',
'<strong>Version %1$s</strong> addressed some security issues and fixed %2$s bugs.'
);
/* translators: %s: Codex URL */
__( 'For more information, see <a href="%s">the release notes</a>.' );

View File

@ -25,8 +25,9 @@ require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );
send_origin_headers();
// Require an action parameter
if ( empty( $_REQUEST['action'] ) )
if ( empty( $_REQUEST['action'] ) ) {
wp_die( '0', 400 );
}
/** Load WordPress Administration APIs */
require_once( ABSPATH . 'wp-admin/includes/admin.php' );
@ -44,27 +45,90 @@ nocache_headers();
do_action( 'admin_init' );
$core_actions_get = array(
'fetch-list', 'ajax-tag-search', 'wp-compression-test', 'imgedit-preview', 'oembed-cache',
'autocomplete-user', 'dashboard-widgets', 'logged-in',
'fetch-list',
'ajax-tag-search',
'wp-compression-test',
'imgedit-preview',
'oembed-cache',
'autocomplete-user',
'dashboard-widgets',
'logged-in',
);
$core_actions_post = array(
'oembed-cache', 'image-editor', 'delete-comment', 'delete-tag', 'delete-link',
'delete-meta', 'delete-post', 'trash-post', 'untrash-post', 'delete-page', 'dim-comment',
'add-link-category', 'add-tag', 'get-tagcloud', 'get-comments', 'replyto-comment',
'edit-comment', 'add-menu-item', 'add-meta', 'add-user', 'closed-postboxes',
'hidden-columns', 'update-welcome-panel', 'menu-get-metabox', 'wp-link-ajax',
'menu-locations-save', 'menu-quick-search', 'meta-box-order', 'get-permalink',
'sample-permalink', 'inline-save', 'inline-save-tax', 'find_posts', 'widgets-order',
'save-widget', 'delete-inactive-widgets', 'set-post-thumbnail', 'date_format', 'time_format',
'wp-remove-post-lock', 'dismiss-wp-pointer', 'upload-attachment', 'get-attachment',
'query-attachments', 'save-attachment', 'save-attachment-compat', 'send-link-to-editor',
'send-attachment-to-editor', 'save-attachment-order', 'heartbeat', 'get-revision-diffs',
'save-user-color-scheme', 'update-widget', 'query-themes', 'parse-embed', 'set-attachment-thumbnail',
'parse-media-shortcode', 'destroy-sessions', 'install-plugin', 'update-plugin', 'crop-image',
'generate-password', 'save-wporg-username', 'delete-plugin', 'search-plugins',
'search-install-plugins', 'activate-plugin', 'update-theme', 'delete-theme', 'install-theme',
'get-post-thumbnail-html', 'get-community-events', 'edit-theme-plugin-file',
'oembed-cache',
'image-editor',
'delete-comment',
'delete-tag',
'delete-link',
'delete-meta',
'delete-post',
'trash-post',
'untrash-post',
'delete-page',
'dim-comment',
'add-link-category',
'add-tag',
'get-tagcloud',
'get-comments',
'replyto-comment',
'edit-comment',
'add-menu-item',
'add-meta',
'add-user',
'closed-postboxes',
'hidden-columns',
'update-welcome-panel',
'menu-get-metabox',
'wp-link-ajax',
'menu-locations-save',
'menu-quick-search',
'meta-box-order',
'get-permalink',
'sample-permalink',
'inline-save',
'inline-save-tax',
'find_posts',
'widgets-order',
'save-widget',
'delete-inactive-widgets',
'set-post-thumbnail',
'date_format',
'time_format',
'wp-remove-post-lock',
'dismiss-wp-pointer',
'upload-attachment',
'get-attachment',
'query-attachments',
'save-attachment',
'save-attachment-compat',
'send-link-to-editor',
'send-attachment-to-editor',
'save-attachment-order',
'heartbeat',
'get-revision-diffs',
'save-user-color-scheme',
'update-widget',
'query-themes',
'parse-embed',
'set-attachment-thumbnail',
'parse-media-shortcode',
'destroy-sessions',
'install-plugin',
'update-plugin',
'crop-image',
'generate-password',
'save-wporg-username',
'delete-plugin',
'search-plugins',
'search-install-plugins',
'activate-plugin',
'update-theme',
'delete-theme',
'install-theme',
'get-post-thumbnail-html',
'get-community-events',
'edit-theme-plugin-file',
);
// Deprecated
@ -72,11 +136,13 @@ $core_actions_post_deprecated = array( 'wp-fullscreen-save-post', 'press-this-sa
$core_actions_post = array_merge( $core_actions_post, $core_actions_post_deprecated );
// Register core Ajax calls.
if ( ! empty( $_GET['action'] ) && in_array( $_GET['action'], $core_actions_get ) )
if ( ! empty( $_GET['action'] ) && in_array( $_GET['action'], $core_actions_get ) ) {
add_action( 'wp_ajax_' . $_GET['action'], 'wp_ajax_' . str_replace( '-', '_', $_GET['action'] ), 1 );
}
if ( ! empty( $_POST['action'] ) && in_array( $_POST['action'], $core_actions_post ) )
if ( ! empty( $_POST['action'] ) && in_array( $_POST['action'], $core_actions_post ) ) {
add_action( 'wp_ajax_' . $_POST['action'], 'wp_ajax_' . str_replace( '-', '_', $_POST['action'] ), 1 );
}
add_action( 'wp_ajax_nopriv_heartbeat', 'wp_ajax_nopriv_heartbeat', 1 );

View File

@ -7,8 +7,9 @@
*/
// don't load directly
if ( !defined('ABSPATH') )
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* @global string $hook_suffix
@ -100,9 +101,10 @@ do_action( "admin_footer-{$hook_suffix}" );
// get_site_option() won't exist when auto upgrading from <= 2.7
if ( function_exists( 'get_site_option' ) ) {
if ( false === get_site_option('can_compress_scripts') )
if ( false === get_site_option( 'can_compress_scripts' ) ) {
compression_test();
}
}
?>

View File

@ -7,8 +7,9 @@
*/
@header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
if ( ! defined( 'WP_ADMIN' ) )
if ( ! defined( 'WP_ADMIN' ) ) {
require_once( dirname( __FILE__ ) . '/admin.php' );
}
/**
* In case admin-header.php is included in a function.
@ -26,8 +27,9 @@ global $title, $hook_suffix, $current_screen, $wp_locale, $pagenow,
$update_title, $total_update_count, $parent_file;
// Catch plugins that include admin-header.php before admin.php completes.
if ( empty( $current_screen ) )
if ( empty( $current_screen ) ) {
set_current_screen();
}
get_admin_page_title();
$title = esc_html( strip_tags( $title ) );
@ -141,37 +143,46 @@ do_action( "admin_head-{$hook_suffix}" );
*/
do_action( 'admin_head' );
if ( get_user_setting('mfold') == 'f' )
if ( get_user_setting( 'mfold' ) == 'f' ) {
$admin_body_class .= ' folded';
}
if ( !get_user_setting('unfold') )
if ( ! get_user_setting( 'unfold' ) ) {
$admin_body_class .= ' auto-fold';
}
if ( is_admin_bar_showing() )
if ( is_admin_bar_showing() ) {
$admin_body_class .= ' admin-bar';
}
if ( is_rtl() )
if ( is_rtl() ) {
$admin_body_class .= ' rtl';
}
if ( $current_screen->post_type )
if ( $current_screen->post_type ) {
$admin_body_class .= ' post-type-' . $current_screen->post_type;
}
if ( $current_screen->taxonomy )
if ( $current_screen->taxonomy ) {
$admin_body_class .= ' taxonomy-' . $current_screen->taxonomy;
}
$admin_body_class .= ' branch-' . str_replace( array( '.', ',' ), '-', floatval( get_bloginfo( 'version' ) ) );
$admin_body_class .= ' version-' . str_replace( '.', '-', preg_replace( '/^([.0-9]+).*/', '$1', get_bloginfo( 'version' ) ) );
$admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
$admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_user_locale() ) ) );
if ( wp_is_mobile() )
if ( wp_is_mobile() ) {
$admin_body_class .= ' mobile';
}
if ( is_multisite() )
if ( is_multisite() ) {
$admin_body_class .= ' multisite';
}
if ( is_network_admin() )
if ( is_network_admin() ) {
$admin_body_class .= ' network-admin';
}
$admin_body_class .= ' no-customize-support no-svg';
@ -262,5 +273,6 @@ if ( is_network_admin() ) {
*/
do_action( 'all_admin_notices' );
if ( $parent_file == 'options-general.php' )
if ( $parent_file == 'options-general.php' ) {
require( ABSPATH . 'wp-admin/options-head.php' );
}

View File

@ -13,10 +13,11 @@ if ( ! defined( 'WP_ADMIN' ) ) {
define( 'WP_ADMIN', true );
}
if ( defined('ABSPATH') )
if ( defined( 'ABSPATH' ) ) {
require_once( ABSPATH . 'wp-load.php' );
else
} else {
require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );
}
/** Allow for cross-domain requests (from the front end). */
send_origin_headers();

View File

@ -15,18 +15,21 @@ if ( ! defined( 'WP_ADMIN' ) ) {
define( 'WP_ADMIN', true );
}
if ( ! defined('WP_NETWORK_ADMIN') )
if ( ! defined( 'WP_NETWORK_ADMIN' ) ) {
define( 'WP_NETWORK_ADMIN', false );
}
if ( ! defined('WP_USER_ADMIN') )
if ( ! defined( 'WP_USER_ADMIN' ) ) {
define( 'WP_USER_ADMIN', false );
}
if ( ! WP_NETWORK_ADMIN && ! WP_USER_ADMIN ) {
define( 'WP_BLOG_ADMIN', true );
}
if ( isset($_GET['import']) && !defined('WP_LOAD_IMPORTERS') )
if ( isset( $_GET['import'] ) && ! defined( 'WP_LOAD_IMPORTERS' ) ) {
define( 'WP_LOAD_IMPORTERS', true );
}
require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );
@ -70,7 +73,12 @@ if ( get_option('db_upgraded') ) {
*/
if ( $c <= 50 || ( $c > 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' ) );
$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 );
@ -84,8 +92,9 @@ require_once(ABSPATH . 'wp-admin/includes/admin.php');
auth_redirect();
// Schedule trash collection
if ( ! wp_next_scheduled( 'wp_scheduled_delete' ) && ! wp_installing() )
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() ) {
@ -122,22 +131,25 @@ if ( isset($_GET['page']) ) {
$plugin_page = plugin_basename( $plugin_page );
}
if ( isset( $_REQUEST['post_type'] ) && post_type_exists( $_REQUEST['post_type'] ) )
if ( isset( $_REQUEST['post_type'] ) && post_type_exists( $_REQUEST['post_type'] ) ) {
$typenow = $_REQUEST['post_type'];
else
} else {
$typenow = '';
}
if ( isset( $_REQUEST['taxonomy'] ) && taxonomy_exists( $_REQUEST['taxonomy'] ) )
if ( isset( $_REQUEST['taxonomy'] ) && taxonomy_exists( $_REQUEST['taxonomy'] ) ) {
$taxnow = $_REQUEST['taxonomy'];
else
} else {
$taxnow = '';
}
if ( WP_NETWORK_ADMIN )
if ( WP_NETWORK_ADMIN ) {
require( ABSPATH . 'wp-admin/network/menu.php' );
elseif ( WP_USER_ADMIN )
} elseif ( WP_USER_ADMIN ) {
require( ABSPATH . 'wp-admin/user/menu.php' );
else
} else {
require( ABSPATH . 'wp-admin/menu.php' );
}
if ( current_user_can( 'manage_options' ) ) {
wp_raise_memory_limit( 'admin' );
@ -156,20 +168,22 @@ if ( current_user_can( 'manage_options' ) ) {
do_action( 'admin_init' );
if ( isset( $plugin_page ) ) {
if ( !empty($typenow) )
if ( ! empty( $typenow ) ) {
$the_parent = $pagenow . '?post_type=' . $typenow;
else
} else {
$the_parent = $pagenow;
}
if ( ! $page_hook = get_plugin_page_hook( $plugin_page, $the_parent ) ) {
$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' ]) )
if ( ! empty( $_SERVER['QUERY_STRING'] ) ) {
$query_string = $_SERVER['QUERY_STRING'];
else
} else {
$query_string = 'page=' . $plugin_page;
}
wp_redirect( admin_url( 'tools.php?' . $query_string ) );
exit;
}
@ -212,8 +226,9 @@ if ( isset($plugin_page) ) {
* @since 2.1.0
*/
do_action( "load-{$page_hook}" );
if (! isset($_GET['noheader']))
if ( ! isset( $_GET['noheader'] ) ) {
require_once( ABSPATH . 'wp-admin/admin-header.php' );
}
/**
* Used to call the registered callback for a plugin screen.
@ -227,8 +242,9 @@ if ( isset($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") ) )
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" ) ) ) {
wp_die( sprintf( __( 'Cannot load %s.' ), htmlentities( $plugin_page ) ) );
}
/**
* Fires before a particular screen is loaded.
@ -244,14 +260,16 @@ if ( isset($plugin_page) ) {
*/
do_action( "load-{$plugin_page}" );
if ( !isset($_GET['noheader']))
if ( ! isset( $_GET['noheader'] ) ) {
require_once( ABSPATH . 'wp-admin/admin-header.php' );
}
if ( file_exists(WPMU_PLUGIN_DIR . "/$plugin_page") )
if ( file_exists( WPMU_PLUGIN_DIR . "/$plugin_page" ) ) {
include( WPMU_PLUGIN_DIR . "/$plugin_page" );
else
} else {
include( WP_PLUGIN_DIR . "/$plugin_page" );
}
}
include( ABSPATH . 'wp-admin/admin-footer.php' );
@ -287,8 +305,9 @@ if ( isset($plugin_page) ) {
$submenu_file = 'import.php';
$title = __( 'Import' );
if (! isset($_GET['noheader']))
if ( ! isset( $_GET['noheader'] ) ) {
require_once( ABSPATH . 'wp-admin/admin-header.php' );
}
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
@ -336,15 +355,17 @@ if ( isset($plugin_page) ) {
* In all other cases, 'load-' . $pagenow should be used instead.
*/
if ( $typenow == 'page' ) {
if ( $pagenow == 'post-new.php' )
if ( $pagenow == 'post-new.php' ) {
do_action( 'load-page-new.php' );
elseif ( $pagenow == 'post.php' )
} elseif ( $pagenow == 'post.php' ) {
do_action( 'load-page.php' );
}
} elseif ( $pagenow == 'edit-tags.php' ) {
if ( $taxnow == 'category' )
if ( $taxnow == 'category' ) {
do_action( 'load-categories.php' );
elseif ( $taxnow == 'link_category' )
} elseif ( $taxnow == 'link_category' ) {
do_action( 'load-edit-link-categories.php' );
}
} elseif ( 'term.php' === $pagenow ) {
do_action( 'load-edit-tags.php' );
}

View File

@ -41,15 +41,18 @@ if ( ! current_user_can( 'upload_files' ) ) {
// just fetch the detail form for that attachment
if ( isset( $_REQUEST['attachment_id'] ) && ( $id = intval( $_REQUEST['attachment_id'] ) ) && $_REQUEST['fetch'] ) {
$post = get_post( $id );
if ( 'attachment' != $post->post_type )
if ( 'attachment' != $post->post_type ) {
wp_die( __( 'Invalid post type.' ) );
if ( ! current_user_can( 'edit_post', $id ) )
}
if ( ! current_user_can( 'edit_post', $id ) ) {
wp_die( __( 'Sorry, you are not allowed to edit this item.' ) );
}
switch ( $_REQUEST['fetch'] ) {
case 3:
if ( $thumb_url = wp_get_attachment_image_src( $id, 'thumbnail', true ) )
if ( $thumb_url = wp_get_attachment_image_src( $id, 'thumbnail', true ) ) {
echo '<img class="pinkynail" src="' . esc_url( $thumb_url[0] ) . '" alt="" />';
}
echo '<a class="edit-attachment" href="' . esc_url( get_edit_post_link( $id ) ) . '" target="_blank">' . _x( 'Edit', 'media item' ) . '</a>';
// Title shouldn't ever be empty, but use filename just in case.
@ -59,7 +62,12 @@ if ( isset($_REQUEST['attachment_id']) && ($id = intval($_REQUEST['attachment_id
break;
case 2:
add_filter( 'attachment_fields_to_edit', 'media_single_attachment_fields_to_edit', 10, 2 );
echo get_media_item($id, array( 'send' => false, 'delete' => true ));
echo get_media_item(
$id, array(
'send' => false,
'delete' => true,
)
);
break;
default:
add_filter( 'attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2 );
@ -74,9 +82,10 @@ check_admin_referer('media-form');
$post_id = 0;
if ( isset( $_REQUEST['post_id'] ) ) {
$post_id = absint( $_REQUEST['post_id'] );
if ( ! get_post( $post_id ) || ! current_user_can( 'edit_post', $post_id ) )
if ( ! get_post( $post_id ) || ! current_user_can( 'edit_post', $post_id ) ) {
$post_id = 0;
}
}
$id = media_handle_upload( 'async-upload', $post_id );
if ( is_wp_error( $id ) ) {

View File

@ -18,33 +18,38 @@ $submenu_file = 'edit-comments.php';
global $action;
wp_reset_vars( array( 'action' ) );
if ( isset( $_POST['deletecomment'] ) )
if ( isset( $_POST['deletecomment'] ) ) {
$action = 'deletecomment';
}
if ( 'cdc' == $action )
if ( 'cdc' == $action ) {
$action = 'delete';
elseif ( 'mac' == $action )
} elseif ( 'mac' == $action ) {
$action = 'approve';
}
if ( isset( $_GET['dt'] ) ) {
if ( 'spam' == $_GET['dt'] )
if ( 'spam' == $_GET['dt'] ) {
$action = 'spam';
elseif ( 'trash' == $_GET['dt'] )
} elseif ( 'trash' == $_GET['dt'] ) {
$action = 'trash';
}
}
switch ( $action ) {
case 'editcomment':
$title = __( 'Edit Comment' );
get_current_screen()->add_help_tab( array(
get_current_screen()->add_help_tab(
array(
'id' => 'overview',
'title' => __( 'Overview' ),
'content' =>
'<p>' . __( 'You can edit the information left in a comment if needed. This is often useful when you notice that a commenter has made a typographical error.' ) . '</p>' .
'<p>' . __( 'You can also moderate the comment from this screen using the Status box, where you can also change the timestamp of the comment.' ) . '</p>'
) );
'<p>' . __( 'You can also moderate the comment from this screen using the Status box, where you can also change the timestamp of the comment.' ) . '</p>',
)
);
get_current_screen()->set_help_sidebar(
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
@ -57,14 +62,17 @@ case 'editcomment' :
$comment_id = absint( $_GET['c'] );
if ( !$comment = get_comment( $comment_id ) )
if ( ! $comment = get_comment( $comment_id ) ) {
comment_footer_die( __( 'Invalid comment ID.' ) . sprintf( ' <a href="%s">' . __( 'Go back' ) . '</a>.', 'javascript:history.go(-1)' ) );
}
if ( !current_user_can( 'edit_comment', $comment_id ) )
if ( ! current_user_can( 'edit_comment', $comment_id ) ) {
comment_footer_die( __( 'Sorry, you are not allowed to edit this comment.' ) );
}
if ( 'trash' == $comment->comment_approved )
if ( 'trash' == $comment->comment_approved ) {
comment_footer_die( __( 'This comment is in the Trash. Please move it out of the Trash if you want to edit it.' ) );
}
$comment = get_comment_to_edit( $comment_id );
@ -76,7 +84,6 @@ case 'delete' :
case 'approve':
case 'trash':
case 'spam':
$title = __( 'Moderate Comment' );
$comment_id = absint( $_GET['c'] );
@ -196,7 +203,8 @@ if ( $comment->comment_approved != '0' ) { // if not unapproved
<td>
<?php
/* translators: 1: comment date, 2: comment time */
$submitted = sprintf( __( '%1$s at %2$s' ),
$submitted = sprintf(
__( '%1$s at %2$s' ),
/* translators: comment date format. See https://secure.php.net/date */
get_comment_date( __( 'Y/m/d' ), $comment ),
get_comment_date( __( 'g:i a' ), $comment )
@ -244,26 +252,30 @@ case 'approvecomment' :
case 'unapprovecomment':
$comment_id = absint( $_REQUEST['c'] );
if ( in_array( $action, array( 'approvecomment', 'unapprovecomment' ) ) )
if ( in_array( $action, array( 'approvecomment', 'unapprovecomment' ) ) ) {
check_admin_referer( 'approve-comment_' . $comment_id );
else
} else {
check_admin_referer( 'delete-comment_' . $comment_id );
}
$noredir = isset( $_REQUEST['noredir'] );
if ( !$comment = get_comment($comment_id) )
if ( ! $comment = get_comment( $comment_id ) ) {
comment_footer_die( __( 'Invalid comment ID.' ) . sprintf( ' <a href="%s">' . __( 'Go back' ) . '</a>.', 'edit-comments.php' ) );
if ( !current_user_can( 'edit_comment', $comment->comment_ID ) )
}
if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) ) {
comment_footer_die( __( 'Sorry, you are not allowed to edit comments on this post.' ) );
}
if ( '' != wp_get_referer() && ! $noredir && false === strpos(wp_get_referer(), 'comment.php') )
if ( '' != wp_get_referer() && ! $noredir && false === strpos( wp_get_referer(), 'comment.php' ) ) {
$redir = wp_get_referer();
elseif ( '' != wp_get_original_referer() && ! $noredir )
} elseif ( '' != wp_get_original_referer() && ! $noredir ) {
$redir = wp_get_original_referer();
elseif ( in_array( $action, array( 'approvecomment', 'unapprovecomment' ) ) )
} elseif ( in_array( $action, array( 'approvecomment', 'unapprovecomment' ) ) ) {
$redir = admin_url( 'edit-comments.php?p=' . absint( $comment->comment_post_ID ) );
else
} else {
$redir = admin_url( 'edit-comments.php' );
}
$redir = remove_query_arg( array( 'spammed', 'unspammed', 'trashed', 'untrashed', 'deleted', 'ids', 'approved', 'unapproved' ), $redir );
@ -274,7 +286,12 @@ case 'unapprovecomment' :
break;
case 'trashcomment':
wp_trash_comment( $comment );
$redir = add_query_arg( array('trashed' => '1', 'ids' => $comment_id), $redir );
$redir = add_query_arg(
array(
'trashed' => '1',
'ids' => $comment_id,
), $redir
);
break;
case 'untrashcomment':
wp_untrash_comment( $comment );
@ -282,7 +299,12 @@ case 'unapprovecomment' :
break;
case 'spamcomment':
wp_spam_comment( $comment );
$redir = add_query_arg( array('spammed' => '1', 'ids' => $comment_id), $redir );
$redir = add_query_arg(
array(
'spammed' => '1',
'ids' => $comment_id,
), $redir
);
break;
case 'unspamcomment':
wp_unspam_comment( $comment );
@ -302,7 +324,6 @@ case 'unapprovecomment' :
die;
case 'editedcomment':
$comment_id = absint( $_POST['comment_ID'] );
$comment_post_id = absint( $_POST['comment_post_ID'] );

View File

@ -39,7 +39,8 @@ $credits = wp_credits();
if ( ! $credits ) {
echo '<p class="about-description">';
/* translators: 1: https://wordpress.org/about/, 2: https://make.wordpress.org/ */
printf( __( 'WordPress is created by a <a href="%1$s">worldwide team</a> of passionate individuals. <a href="%2$s">Get involved in WordPress</a>.' ),
printf(
__( 'WordPress is created by a <a href="%1$s">worldwide team</a> of passionate individuals. <a href="%2$s">Get involved in WordPress</a>.' ),
'https://wordpress.org/about/',
__( 'https://make.wordpress.org/' )
);
@ -66,8 +67,9 @@ foreach ( $credits['groups'] as $group_slug => $group_data ) {
echo '<h3 class="wp-people-group">' . esc_html( $title ) . "</h3>\n";
}
if ( ! empty( $group_data['shuffle'] ) )
if ( ! empty( $group_data['shuffle'] ) ) {
shuffle( $group_data['data'] ); // We were going to sort by ability to pronounce "hierarchical," but that wouldn't be fair to Matt.
}
switch ( $group_data['type'] ) {
case 'list':
@ -91,8 +93,9 @@ foreach ( $credits['groups'] as $group_slug => $group_data ) {
$data2x = get_avatar_data( $person_data[1] . '@md5.gravatar.com', array( 'size' => $size ) );
echo '<img src="' . esc_url( $data['url'] ) . '" srcset="' . esc_url( $data2x['url'] ) . ' 2x" class="gravatar" alt="" />' . "\n";
echo esc_html( $person_data[0] ) . "</a>\n\t";
if ( ! $compact )
if ( ! $compact ) {
echo '<span class="title">' . translate( $person_data[3] ) . "</span>\n";
}
echo "</li>\n";
}
echo "</ul>\n";
@ -101,12 +104,15 @@ foreach ( $credits['groups'] as $group_slug => $group_data ) {
}
?>
<p class="clear"><?php
<p class="clear">
<?php
/* translators: %s: https://make.wordpress.org/ */
printf( __( 'Want to see your name in lights on this page? <a href="%s">Get involved in WordPress</a>.' ),
printf(
__( 'Want to see your name in lights on this page? <a href="%s">Get involved in WordPress</a>.' ),
__( 'https://make.wordpress.org/' )
);
?></p>
?>
</p>
</div>
</div>

View File

@ -82,15 +82,17 @@ class Custom_Background {
* @since 3.0.0
*/
public function admin_load() {
get_current_screen()->add_help_tab( array(
get_current_screen()->add_help_tab(
array(
'id' => 'overview',
'title' => __( 'Overview' ),
'content' =>
'<p>' . __( 'You can customize the look of your site without touching any of your theme&#8217;s code by using a custom background. Your background can be an image or a color.' ) . '</p>' .
'<p>' . __( 'To use a background image, simply upload it or choose an image that has already been uploaded to your Media Library by clicking the &#8220;Choose Image&#8221; button. You can display a single instance of your image, or tile it to fill the screen. You can have your background fixed in place, so your site content moves on top of it, or you can have it scroll with your site.' ) . '</p>' .
'<p>' . __( 'You can also choose a background color by clicking the Select Color button and either typing in a legitimate HTML hex value, e.g. &#8220;#ff0000&#8221; for red, or by choosing a color using the color picker.' ) . '</p>' .
'<p>' . __( 'Don&#8217;t forget to click on the Save Changes button when you are finished.' ) . '</p>'
) );
'<p>' . __( 'Don&#8217;t forget to click on the Save Changes button when you are finished.' ) . '</p>',
)
);
get_current_screen()->set_help_sidebar(
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
@ -109,8 +111,9 @@ class Custom_Background {
* @since 3.0.0
*/
public function take_action() {
if ( empty($_POST) )
if ( empty( $_POST ) ) {
return;
}
if ( isset( $_POST['reset-background'] ) ) {
check_admin_referer( 'custom-background-reset', '_wpnonce-custom-background-reset' );
@ -202,11 +205,12 @@ class Custom_Background {
if ( isset( $_POST['background-color'] ) ) {
check_admin_referer( 'custom-background' );
$color = preg_replace( '/[^0-9a-fA-F]/', '', $_POST['background-color'] );
if ( strlen($color) == 6 || strlen($color) == 3 )
if ( strlen( $color ) == 6 || strlen( $color ) == 3 ) {
set_theme_mod( 'background_color', $color );
else
} else {
set_theme_mod( 'background_color', '' );
}
}
$this->updated = true;
}
@ -252,8 +256,9 @@ class Custom_Background {
call_user_func( $this->admin_image_div_callback );
} else {
$background_styles = '';
if ( $bgcolor = get_background_color() )
if ( $bgcolor = get_background_color() ) {
$background_styles .= 'background-color: #' . $bgcolor . ';';
}
$background_image_thumb = get_background_image();
if ( $background_image_thumb ) {
@ -289,7 +294,7 @@ class Custom_Background {
<form method="post">
<?php wp_nonce_field( 'custom-background-remove', '_wpnonce-custom-background-remove' ); ?>
<?php submit_button( __( 'Remove Background Image' ), '', 'remove-background', false ); ?><br/>
<?php _e('This will remove the background image. You will not be able to restore any customizations.') ?>
<?php _e( 'This will remove the background image. You will not be able to restore any customizations.' ); ?>
</form>
</td>
</tr>
@ -303,7 +308,7 @@ class Custom_Background {
<form method="post">
<?php wp_nonce_field( 'custom-background-reset', '_wpnonce-custom-background-reset' ); ?>
<?php submit_button( __( 'Restore Original Image' ), '', 'reset-background', false ); ?><br/>
<?php _e('This will restore the original background image. You will not be able to restore any customizations.') ?>
<?php _e( 'This will restore the original background image. You will not be able to restore any customizations.' ); ?>
</form>
</td>
</tr>
@ -349,19 +354,46 @@ $background_position = sprintf(
$background_position_options = array(
array(
'left top' => array( 'label' => __( 'Top Left' ), 'icon' => 'dashicons dashicons-arrow-left-alt' ),
'center top' => array( 'label' => __( 'Top' ), 'icon' => 'dashicons dashicons-arrow-up-alt' ),
'right top' => array( 'label' => __( 'Top Right' ), 'icon' => 'dashicons dashicons-arrow-right-alt' ),
'left top' => array(
'label' => __( 'Top Left' ),
'icon' => 'dashicons dashicons-arrow-left-alt',
),
'center top' => array(
'label' => __( 'Top' ),
'icon' => 'dashicons dashicons-arrow-up-alt',
),
'right top' => array(
'label' => __( 'Top Right' ),
'icon' => 'dashicons dashicons-arrow-right-alt',
),
),
array(
'left center' => array( 'label' => __( 'Left' ), 'icon' => 'dashicons dashicons-arrow-left-alt' ),
'center center' => array( 'label' => __( 'Center' ), 'icon' => 'background-position-center-icon' ),
'right center' => array( 'label' => __( 'Right' ), 'icon' => 'dashicons dashicons-arrow-right-alt' ),
'left center' => array(
'label' => __( 'Left' ),
'icon' => 'dashicons dashicons-arrow-left-alt',
),
'center center' => array(
'label' => __( 'Center' ),
'icon' => 'background-position-center-icon',
),
'right center' => array(
'label' => __( 'Right' ),
'icon' => 'dashicons dashicons-arrow-right-alt',
),
),
array(
'left bottom' => array( 'label' => __( 'Bottom Left' ), 'icon' => 'dashicons dashicons-arrow-left-alt' ),
'center bottom' => array( 'label' => __( 'Bottom' ), 'icon' => 'dashicons dashicons-arrow-down-alt' ),
'right bottom' => array( 'label' => __( 'Bottom Right' ), 'icon' => 'dashicons dashicons-arrow-right-alt' ),
'left bottom' => array(
'label' => __( 'Bottom Left' ),
'icon' => 'dashicons dashicons-arrow-left-alt',
),
'center bottom' => array(
'label' => __( 'Bottom' ),
'icon' => 'dashicons dashicons-arrow-down-alt',
),
'right bottom' => array(
'label' => __( 'Bottom Right' ),
'icon' => 'dashicons dashicons-arrow-right-alt',
),
),
);
?>
@ -416,10 +448,11 @@ $background_position_options = array(
<td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Background Color' ); ?></span></legend>
<?php
$default_color = '';
if ( current_theme_supports( 'custom-background', 'default-color' ) )
if ( current_theme_supports( 'custom-background', 'default-color' ) ) {
$default_color = ' data-default-color="#' . esc_attr( get_theme_support( 'custom-background', 'default-color' ) ) . '"';
}
?>
<input type="text" name="background-color" id="background-color" value="#<?php echo esc_attr( get_background_color() ); ?>"<?php echo $default_color ?>>
<input type="text" name="background-color" id="background-color" value="#<?php echo esc_attr( get_background_color() ); ?>"<?php echo $default_color; ?>>
</fieldset></td>
</tr>
</tbody>
@ -439,21 +472,24 @@ if ( current_theme_supports( 'custom-background', 'default-color' ) )
* @since 3.0.0
*/
public function handle_upload() {
if ( empty($_FILES) )
if ( empty( $_FILES ) ) {
return;
}
check_admin_referer( 'custom-background-upload', '_wpnonce-custom-background-upload' );
$overrides = array( 'test_form' => false );
$uploaded_file = $_FILES['import'];
$wp_filetype = wp_check_filetype_and_ext( $uploaded_file['tmp_name'], $uploaded_file['name'] );
if ( ! wp_match_mime_types( 'image', $wp_filetype['type'] ) )
if ( ! wp_match_mime_types( 'image', $wp_filetype['type'] ) ) {
wp_die( __( 'The uploaded file is not a valid image. Please try again.' ) );
}
$file = wp_handle_upload( $uploaded_file, $overrides );
if ( isset($file['error']) )
if ( isset( $file['error'] ) ) {
wp_die( $file['error'] );
}
$url = $file['url'];
$type = $file['type'];
@ -466,7 +502,7 @@ if ( current_theme_supports( 'custom-background', 'default-color' ) )
'post_content' => $url,
'post_mime_type' => $type,
'guid' => $url,
'context' => 'custom-background'
'context' => 'custom-background',
);
// Save the data
@ -512,7 +548,6 @@ if ( current_theme_supports( 'custom-background', 'default-color' ) )
}
/**
*
* @since 3.4.0
* @deprecated 3.5.0
*
@ -524,7 +559,6 @@ if ( current_theme_supports( 'custom-background', 'default-color' ) )
}
/**
*
* @since 3.4.0
* @deprecated 3.5.0
*
@ -536,18 +570,29 @@ if ( current_theme_supports( 'custom-background', 'default-color' ) )
}
/**
*
* @since 3.4.0
* @deprecated 3.5.0
*/
public function wp_set_background_image() {
if ( ! current_user_can('edit_theme_options') || ! isset( $_POST['attachment_id'] ) ) exit;
if ( ! current_user_can( 'edit_theme_options' ) || ! isset( $_POST['attachment_id'] ) ) {
exit;
}
$attachment_id = absint( $_POST['attachment_id'] );
/** This filter is documented in wp-admin/includes/media.php */
$sizes = array_keys(apply_filters( 'image_size_names_choose', array('thumbnail' => __('Thumbnail'), 'medium' => __('Medium'), 'large' => __('Large'), 'full' => __('Full Size')) ));
$sizes = array_keys(
apply_filters(
'image_size_names_choose', array(
'thumbnail' => __( 'Thumbnail' ),
'medium' => __( 'Medium' ),
'large' => __( 'Large' ),
'full' => __( 'Full Size' ),
)
)
);
$size = 'thumbnail';
if ( in_array( $_POST['size'], $sizes ) )
if ( in_array( $_POST['size'], $sizes ) ) {
$size = esc_attr( $_POST['size'] );
}
update_post_meta( $attachment_id, '_wp_attachment_is_custom_background', get_option( 'stylesheet' ) );
$url = wp_get_attachment_image_src( $attachment_id, $size );

View File

@ -91,32 +91,38 @@ class Custom_Image_Header {
* @since 3.0.0
*/
public function help() {
get_current_screen()->add_help_tab( array(
get_current_screen()->add_help_tab(
array(
'id' => 'overview',
'title' => __( 'Overview' ),
'content' =>
'<p>' . __( 'This screen is used to customize the header section of your theme.' ) . '</p>' .
'<p>' . __( 'You can choose from the theme&#8217;s default header images, or use one of your own. You can also customize how your Site Title and Tagline are displayed.') . '<p>'
) );
'<p>' . __( 'You can choose from the theme&#8217;s default header images, or use one of your own. You can also customize how your Site Title and Tagline are displayed.' ) . '<p>',
)
);
get_current_screen()->add_help_tab( array(
get_current_screen()->add_help_tab(
array(
'id' => 'set-header-image',
'title' => __( 'Header Image' ),
'content' =>
'<p>' . __( 'You can set a custom image header for your site. Simply upload the image and crop it, and the new header will go live immediately. Alternatively, you can use an image that has already been uploaded to your Media Library by clicking the &#8220;Choose Image&#8221; button.' ) . '</p>' .
'<p>' . __( 'Some themes come with additional header images bundled. If you see multiple images displayed, select the one you&#8217;d like and click the &#8220;Save Changes&#8221; button.' ) . '</p>' .
'<p>' . __( 'If your theme has more than one default header image, or you have uploaded more than one custom header image, you have the option of having WordPress display a randomly different image on each page of your site. Click the &#8220;Random&#8221; radio button next to the Uploaded Images or Default Images section to enable this feature.' ) . '</p>' .
'<p>' . __( 'If you don&#8217;t want a header image to be displayed on your site at all, click the &#8220;Remove Header Image&#8221; button at the bottom of the Header Image section of this page. If you want to re-enable the header image later, you just have to select one of the other image options and click &#8220;Save Changes&#8221;.') . '</p>'
) );
'<p>' . __( 'If you don&#8217;t want a header image to be displayed on your site at all, click the &#8220;Remove Header Image&#8221; button at the bottom of the Header Image section of this page. If you want to re-enable the header image later, you just have to select one of the other image options and click &#8220;Save Changes&#8221;.' ) . '</p>',
)
);
get_current_screen()->add_help_tab( array(
get_current_screen()->add_help_tab(
array(
'id' => 'set-header-text',
'title' => __( 'Header Text' ),
'content' =>
'<p>' . sprintf( __( 'For most themes, the header text is your Site Title and Tagline, as defined in the <a href="%1$s">General Settings</a> section.' ), admin_url( 'options-general.php' ) ) . '<p>' .
'<p>' . __( 'In the Header Text section of this page, you can choose whether to display this text or hide it. You can also choose a color for the text by clicking the Select Color button and either typing in a legitimate HTML hex value, e.g. &#8220;#ff0000&#8221; for red, or by choosing a color using the color picker.' ) . '</p>' .
'<p>' . __( 'Don&#8217;t forget to click &#8220;Save Changes&#8221; when you&#8217;re done!') . '</p>'
) );
'<p>' . __( 'Don&#8217;t forget to click &#8220;Save Changes&#8221; when you&#8217;re done!' ) . '</p>',
)
);
get_current_screen()->set_help_sidebar(
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
@ -133,15 +139,17 @@ class Custom_Image_Header {
* @return int Current step
*/
public function step() {
if ( ! isset( $_GET['step'] ) )
if ( ! isset( $_GET['step'] ) ) {
return 1;
}
$step = (int) $_GET['step'];
if ( $step < 1 || 3 < $step ||
( 2 == $step && ! wp_verify_nonce( $_REQUEST['_wpnonce-custom-header-upload'], 'custom-header-upload' ) ) ||
( 3 == $step && ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'custom-header-crop-image' ) )
)
) {
return 1;
}
return $step;
}
@ -157,8 +165,9 @@ class Custom_Image_Header {
if ( ( 1 == $step || 3 == $step ) ) {
wp_enqueue_media();
wp_enqueue_script( 'custom-header' );
if ( current_theme_supports( 'custom-header', 'header-text' ) )
if ( current_theme_supports( 'custom-header', 'header-text' ) ) {
wp_enqueue_script( 'wp-color-picker' );
}
} elseif ( 2 == $step ) {
wp_enqueue_script( 'imgareaselect' );
}
@ -172,11 +181,12 @@ class Custom_Image_Header {
public function css_includes() {
$step = $this->step();
if ( ( 1 == $step || 3 == $step ) && current_theme_supports( 'custom-header', 'header-text' ) )
if ( ( 1 == $step || 3 == $step ) && current_theme_supports( 'custom-header', 'header-text' ) ) {
wp_enqueue_style( 'wp-color-picker' );
elseif ( 2 == $step )
} elseif ( 2 == $step ) {
wp_enqueue_style( 'imgareaselect' );
}
}
/**
* Execute custom header modification.
@ -184,11 +194,13 @@ class Custom_Image_Header {
* @since 2.6.0
*/
public function take_action() {
if ( ! current_user_can('edit_theme_options') )
if ( ! current_user_can( 'edit_theme_options' ) ) {
return;
}
if ( empty( $_POST ) )
if ( empty( $_POST ) ) {
return;
}
$this->updated = true;
@ -211,11 +223,12 @@ class Custom_Image_Header {
check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' );
$_POST['text-color'] = str_replace( '#', '', $_POST['text-color'] );
$color = preg_replace( '/[^0-9a-fA-F]/', '', $_POST['text-color'] );
if ( strlen($color) == 6 || strlen($color) == 3 )
if ( strlen( $color ) == 6 || strlen( $color ) == 3 ) {
set_theme_mod( 'header_textcolor', $color );
elseif ( ! $color )
} elseif ( ! $color ) {
set_theme_mod( 'header_textcolor', 'blank' );
}
}
if ( isset( $_POST['default-header'] ) ) {
check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' );
@ -234,8 +247,9 @@ class Custom_Image_Header {
public function process_default_headers() {
global $_wp_default_headers;
if ( !isset($_wp_default_headers) )
if ( ! isset( $_wp_default_headers ) ) {
return;
}
if ( ! empty( $this->default_headers ) ) {
return;
@ -285,8 +299,9 @@ class Custom_Image_Header {
echo '<div class="default-header">';
echo '<label><input name="default-header" type="radio" value="' . esc_attr( $header_key ) . '" ' . checked( $header_url, get_theme_mod( 'header_image' ), false ) . ' />';
$width = '';
if ( !empty( $header['attachment_id'] ) )
if ( ! empty( $header['attachment_id'] ) ) {
$width = ' width="230"';
}
echo '<img src="' . set_url_scheme( $header_thumbnail ) . '" alt="' . esc_attr( $header_alt_text ) . '"' . $width . ' /></label>';
echo '</div>';
}
@ -300,11 +315,12 @@ class Custom_Image_Header {
*/
public function js() {
$step = $this->step();
if ( ( 1 == $step || 3 == $step ) && current_theme_supports( 'custom-header', 'header-text' ) )
if ( ( 1 == $step || 3 == $step ) && current_theme_supports( 'custom-header', 'header-text' ) ) {
$this->js_1();
elseif ( 2 == $step )
} elseif ( 2 == $step ) {
$this->js_2();
}
}
/**
* Display JavaScript based on Step 1 and 3.
@ -372,7 +388,9 @@ class Custom_Image_Header {
*
* @since 2.6.0
*/
public function js_2() { ?>
public function js_2() {
?>
<script type="text/javascript">
function onEndCrop( coords ) {
jQuery( '#x1' ).val(coords.x);
@ -492,17 +510,20 @@ class Custom_Image_Header {
$header_image_style = '';
}
if ( $custom_header->width )
if ( $custom_header->width ) {
$header_image_style .= 'max-width:' . $custom_header->width . 'px;';
if ( $custom_header->height )
}
if ( $custom_header->height ) {
$header_image_style .= 'height:' . $custom_header->height . 'px;';
}
?>
<div id="headimg" style="<?php echo $header_image_style; ?>">
<?php
if ( display_header_text() )
if ( display_header_text() ) {
$style = ' style="color:#' . get_header_textcolor() . ';"';
else
} else {
$style = ' style="display:none;"';
}
?>
<h1><a id="name" class="displaying-header-text" <?php echo $style; ?> onclick="return false;" href="<?php bloginfo( 'url' ); ?>" tabindex="-1"><?php bloginfo( 'name' ); ?></a></h1>
<div id="desc" class="displaying-header-text" <?php echo $style; ?>><?php bloginfo( 'description' ); ?></div>
@ -521,7 +542,7 @@ class Custom_Image_Header {
if ( ! current_theme_supports( 'custom-header', 'flex-height' ) && ! current_theme_supports( 'custom-header', 'flex-width' ) ) {
printf( __( 'Images of exactly <strong>%1$d &times; %2$d pixels</strong> will be used as-is.' ) . '<br />', get_theme_support( 'custom-header', 'width' ), get_theme_support( 'custom-header', 'height' ) );
} elseif ( current_theme_supports( 'custom-header', 'flex-height' ) ) {
if ( ! current_theme_supports( 'custom-header', 'flex-width' ) )
if ( ! current_theme_supports( 'custom-header', 'flex-width' ) ) {
printf(
/* translators: %s: size in pixels */
__( 'Images should be at least %s wide.' ) . ' ',
@ -531,8 +552,9 @@ class Custom_Image_Header {
get_theme_support( 'custom-header', 'width' )
)
);
}
} elseif ( current_theme_supports( 'custom-header', 'flex-width' ) ) {
if ( ! current_theme_supports( 'custom-header', 'flex-height' ) )
if ( ! current_theme_supports( 'custom-header', 'flex-height' ) ) {
printf(
/* translators: %s: size in pixels */
__( 'Images should be at least %s tall.' ) . ' ',
@ -543,8 +565,9 @@ class Custom_Image_Header {
)
);
}
}
if ( current_theme_supports( 'custom-header', 'flex-height' ) || current_theme_supports( 'custom-header', 'flex-width' ) ) {
if ( current_theme_supports( 'custom-header', 'width' ) )
if ( current_theme_supports( 'custom-header', 'width' ) ) {
printf(
/* translators: %s: size in pixels */
__( 'Suggested width is %s.' ) . ' ',
@ -554,7 +577,8 @@ class Custom_Image_Header {
get_theme_support( 'custom-header', 'width' )
)
);
if ( current_theme_supports( 'custom-header', 'height' ) )
}
if ( current_theme_supports( 'custom-header', 'height' ) ) {
printf(
/* translators: %s: size in pixels */
__( 'Suggested height is %s.' ) . ' ',
@ -565,8 +589,10 @@ class Custom_Image_Header {
)
);
}
?></p>
<form enctype="multipart/form-data" id="upload-form" class="wp-upload-form" method="post" action="<?php echo esc_url( add_query_arg( 'step', 2 ) ) ?>">
}
?>
</p>
<form enctype="multipart/form-data" id="upload-form" class="wp-upload-form" method="post" action="<?php echo esc_url( add_query_arg( 'step', 2 ) ); ?>">
<p>
<label for="upload"><?php _e( 'Choose an image from your computer:' ); ?></label><br />
<input type="file" id="upload" name="import" />
@ -575,11 +601,15 @@ class Custom_Image_Header {
<?php submit_button( __( 'Upload' ), '', 'submit', false ); ?>
</p>
<?php
$modal_update_href = esc_url( add_query_arg( array(
$modal_update_href = esc_url(
add_query_arg(
array(
'page' => 'custom-header',
'step' => 2,
'_wpnonce-custom-header-upload' => wp_create_nonce( 'custom-header-upload' ),
), admin_url('themes.php') ) );
), admin_url( 'themes.php' )
)
);
?>
<p>
<label for="choose-from-library-link"><?php _e( 'Or choose an image from your media library:' ); ?></label><br />
@ -595,7 +625,7 @@ class Custom_Image_Header {
</tbody>
</table>
<form method="post" action="<?php echo esc_url( add_query_arg( 'step', 1 ) ) ?>">
<form method="post" action="<?php echo esc_url( add_query_arg( 'step', 1 ) ); ?>">
<?php submit_button( null, 'screen-reader-text', 'save-header-options', false ); ?>
<table class="form-table">
<tbody>
@ -603,44 +633,50 @@ class Custom_Image_Header {
<tr>
<th scope="row"><?php _e( 'Uploaded Images' ); ?></th>
<td>
<p><?php _e( 'You can choose one of your previously uploaded headers, or show a random one.' ) ?></p>
<p><?php _e( 'You can choose one of your previously uploaded headers, or show a random one.' ); ?></p>
<?php
$this->show_header_selector( 'uploaded' );
?>
</td>
</tr>
<?php endif;
if ( ! empty( $this->default_headers ) ) : ?>
<?php
endif;
if ( ! empty( $this->default_headers ) ) :
?>
<tr>
<th scope="row"><?php _e( 'Default Images' ); ?></th>
<td>
<?php if ( current_theme_supports( 'custom-header', 'uploads' ) ) : ?>
<p><?php _e( 'If you don&lsquo;t want to upload your own image, you can use one of these cool headers, or show a random one.' ) ?></p>
<p><?php _e( 'If you don&lsquo;t want to upload your own image, you can use one of these cool headers, or show a random one.' ); ?></p>
<?php else : ?>
<p><?php _e( 'You can use one of these cool headers or show a random one on each page.' ) ?></p>
<p><?php _e( 'You can use one of these cool headers or show a random one on each page.' ); ?></p>
<?php endif; ?>
<?php
$this->show_header_selector( 'default' );
?>
</td>
</tr>
<?php endif;
if ( get_header_image() ) : ?>
<?php
endif;
if ( get_header_image() ) :
?>
<tr>
<th scope="row"><?php _e( 'Remove Image' ); ?></th>
<td>
<p><?php _e( 'This will remove the header image. You will not be able to restore any customizations.' ) ?></p>
<p><?php _e( 'This will remove the header image. You will not be able to restore any customizations.' ); ?></p>
<?php submit_button( __( 'Remove Header Image' ), '', 'removeheader', false ); ?>
</td>
</tr>
<?php endif;
<?php
endif;
$default_image = sprintf( get_theme_support( 'custom-header', 'default-image' ), get_template_directory_uri(), get_stylesheet_directory_uri() );
if ( $default_image && get_header_image() != $default_image ) : ?>
if ( $default_image && get_header_image() != $default_image ) :
?>
<tr>
<th scope="row"><?php _e( 'Reset Image' ); ?></th>
<td>
<p><?php _e( 'This will restore the original header image. You will not be able to restore any customizations.' ) ?></p>
<p><?php _e( 'This will restore the original header image. You will not be able to restore any customizations.' ); ?></p>
<?php submit_button( __( 'Restore Original Header Image' ), '', 'resetheader', false ); ?>
</td>
</tr>
@ -693,7 +729,8 @@ class Custom_Image_Header {
</tr>
</tbody>
</table>
<?php endif;
<?php
endif;
/**
* Fires just before the submit button in the custom header options form.
@ -702,13 +739,15 @@ class Custom_Image_Header {
*/
do_action( 'custom_header_options' );
wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?>
wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' );
?>
<?php submit_button( null, 'primary', 'save-header-options' ); ?>
</form>
</div>
<?php }
<?php
}
/**
* Display second step of custom header image page.
@ -748,20 +787,22 @@ wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?>
$max_width = 0;
// For flex, limit size of image displayed to 1500px unless theme says otherwise
if ( current_theme_supports( 'custom-header', 'flex-width' ) )
if ( current_theme_supports( 'custom-header', 'flex-width' ) ) {
$max_width = 1500;
}
if ( current_theme_supports( 'custom-header', 'max-width' ) )
if ( current_theme_supports( 'custom-header', 'max-width' ) ) {
$max_width = max( $max_width, get_theme_support( 'custom-header', 'max-width' ) );
}
$max_width = max( $max_width, get_theme_support( 'custom-header', 'width' ) );
// If flexible height isn't supported and the image is the exact right size
if ( ! current_theme_supports( 'custom-header', 'flex-height' ) && ! current_theme_supports( 'custom-header', 'flex-width' )
&& $width == get_theme_support( 'custom-header', 'width' ) && $height == get_theme_support( 'custom-header', 'height' ) )
{
&& $width == get_theme_support( 'custom-header', 'width' ) && $height == get_theme_support( 'custom-header', 'height' ) ) {
// Add the meta-data
if ( file_exists( $file ) )
if ( file_exists( $file ) ) {
wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $file ) );
}
$this->set_header_image( compact( 'url', 'attachment_id', 'width', 'height' ) );
@ -779,8 +820,9 @@ wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?>
} elseif ( $width > $max_width ) {
$oitar = $width / $max_width;
$image = wp_crop_image( $attachment_id, 0, 0, $width, $height, $max_width, $height / $oitar, false, str_replace( basename( $file ), 'midsize-' . basename( $file ), $file ) );
if ( ! $image || is_wp_error( $image ) )
if ( ! $image || is_wp_error( $image ) ) {
wp_die( __( 'Image could not be processed. Please go back and try again.' ), __( 'Image Processing Error' ) );
}
/** This filter is documented in wp-admin/custom-header.php */
$image = apply_filters( 'wp_create_file_in_uploads', $image, $attachment_id ); // For replication
@ -813,13 +855,14 @@ wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?>
<?php if ( empty( $_POST ) && isset( $_GET['file'] ) ) { ?>
<input type="hidden" name="create-new-attachment" value="true" />
<?php } ?>
<?php wp_nonce_field( 'custom-header-crop-image' ) ?>
<?php wp_nonce_field( 'custom-header-crop-image' ); ?>
<p class="submit">
<?php submit_button( __( 'Crop and Publish' ), 'primary', 'submit', false ); ?>
<?php
if ( isset( $oitar ) && 1 == $oitar && ( current_theme_supports( 'custom-header', 'flex-height' ) || current_theme_supports( 'custom-header', 'flex-width' ) ) )
if ( isset( $oitar ) && 1 == $oitar && ( current_theme_supports( 'custom-header', 'flex-height' ) || current_theme_supports( 'custom-header', 'flex-width' ) ) ) {
submit_button( __( 'Skip Cropping, Publish Image as Is' ), '', 'skip-cropping', false );
}
?>
</p>
</form>
@ -838,13 +881,15 @@ wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?>
$uploaded_file = $_FILES['import'];
$wp_filetype = wp_check_filetype_and_ext( $uploaded_file['tmp_name'], $uploaded_file['name'] );
if ( ! wp_match_mime_types( 'image', $wp_filetype['type'] ) )
if ( ! wp_match_mime_types( 'image', $wp_filetype['type'] ) ) {
wp_die( __( 'The uploaded file is not a valid image. Please try again.' ) );
}
$file = wp_handle_upload( $uploaded_file, $overrides );
if ( isset($file['error']) )
if ( isset( $file['error'] ) ) {
wp_die( $file['error'], __( 'Image Upload Error' ) );
}
$url = $file['url'];
$type = $file['type'];
@ -857,7 +902,7 @@ wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?>
'post_content' => $url,
'post_mime_type' => $type,
'guid' => $url,
'context' => 'custom-header'
'context' => 'custom-header',
);
// Save the data
@ -901,30 +946,35 @@ wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?>
$attachment_id = absint( $_POST['attachment_id'] );
$original = get_attached_file( $attachment_id );
$dimensions = $this->get_header_dimensions( array(
$dimensions = $this->get_header_dimensions(
array(
'height' => $_POST['height'],
'width' => $_POST['width'],
) );
)
);
$height = $dimensions['dst_height'];
$width = $dimensions['dst_width'];
if ( empty( $_POST['skip-cropping'] ) )
if ( empty( $_POST['skip-cropping'] ) ) {
$cropped = wp_crop_image( $attachment_id, (int) $_POST['x1'], (int) $_POST['y1'], (int) $_POST['width'], (int) $_POST['height'], $width, $height );
elseif ( ! empty( $_POST['create-new-attachment'] ) )
} elseif ( ! empty( $_POST['create-new-attachment'] ) ) {
$cropped = _copy_image_file( $attachment_id );
else
} else {
$cropped = get_attached_file( $attachment_id );
}
if ( ! $cropped || is_wp_error( $cropped ) )
if ( ! $cropped || is_wp_error( $cropped ) ) {
wp_die( __( 'Image could not be processed. Please go back and try again.' ), __( 'Image Processing Error' ) );
}
/** This filter is documented in wp-admin/custom-header.php */
$cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); // For replication
$object = $this->create_attachment_object( $cropped, $attachment_id );
if ( ! empty( $_POST['create-new-attachment'] ) )
if ( ! empty( $_POST['create-new-attachment'] ) ) {
unset( $object['ID'] );
}
// Update the attachment
$attachment_id = $this->insert_attachment( $object, $cropped );
@ -961,16 +1011,18 @@ wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?>
* @since 2.1.0
*/
public function admin_page() {
if ( ! current_user_can('edit_theme_options') )
if ( ! current_user_can( 'edit_theme_options' ) ) {
wp_die( __( 'Sorry, you are not allowed to customize headers.' ) );
}
$step = $this->step();
if ( 2 == $step )
if ( 2 == $step ) {
$this->step_2();
elseif ( 3 == $step )
} elseif ( 3 == $step ) {
$this->step_3();
else
} else {
$this->step_1();
}
}
/**
* Unused since 3.5.0.
@ -1011,8 +1063,9 @@ wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?>
final public function set_header_image( $choice ) {
if ( is_array( $choice ) || is_object( $choice ) ) {
$choice = (array) $choice;
if ( ! isset( $choice['attachment_id'] ) || ! isset( $choice['url'] ) )
if ( ! isset( $choice['attachment_id'] ) || ! isset( $choice['url'] ) ) {
return;
}
$choice['url'] = esc_url_raw( $choice['url'] );
@ -1042,11 +1095,12 @@ wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?>
} else {
$this->process_default_headers();
if ( isset( $this->default_headers[ $choice ] ) )
if ( isset( $this->default_headers[ $choice ] ) ) {
$header_image_data = $this->default_headers[ $choice ];
else
} else {
return;
}
}
set_theme_mod( 'header_image', esc_url_raw( $header_image_data['url'] ) );
set_theme_mod( 'header_image_data', $header_image_data );
@ -1107,7 +1161,10 @@ wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?>
$has_flex_width = current_theme_supports( 'custom-header', 'flex-width' );
$has_flex_height = current_theme_supports( 'custom-header', 'flex-height' );
$has_max_width = current_theme_supports( 'custom-header', 'max-width' );
$dst = array( 'dst_height' => null, 'dst_width' => null );
$dst = array(
'dst_height' => null,
'dst_width' => null,
);
// For flex, limit size of image displayed to 1500px unless theme says otherwise
if ( $has_flex_width ) {
@ -1121,21 +1178,17 @@ wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?>
if ( $has_flex_height && ( ! $has_flex_width || $width > $max_width ) ) {
$dst['dst_height'] = absint( $height * ( $max_width / $width ) );
}
elseif ( $has_flex_height && $has_flex_width ) {
} elseif ( $has_flex_height && $has_flex_width ) {
$dst['dst_height'] = $height;
}
else {
} else {
$dst['dst_height'] = $theme_height;
}
if ( $has_flex_width && ( ! $has_flex_height || $width > $max_width ) ) {
$dst['dst_width'] = absint( $width * ( $max_width / $width ) );
}
elseif ( $has_flex_width && $has_flex_height ) {
} elseif ( $has_flex_width && $has_flex_height ) {
$dst['dst_width'] = $width;
}
else {
} else {
$dst['dst_width'] = $theme_width;
}
@ -1227,10 +1280,12 @@ wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?>
$crop_details = $_POST['cropDetails'];
$dimensions = $this->get_header_dimensions( array(
$dimensions = $this->get_header_dimensions(
array(
'height' => $crop_details['height'],
'width' => $crop_details['width'],
) );
)
);
$attachment_id = absint( $_POST['id'] );
@ -1264,7 +1319,8 @@ wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?>
$new_attachment_id = $this->insert_attachment( $object, $cropped );
$object['attachment_id'] = $new_attachment_id;
$object['url'] = wp_get_attachment_url( $new_attachment_id );;
$object['url'] = wp_get_attachment_url( $new_attachment_id );
$object['width'] = $dimensions['dst_width'];
$object['height'] = $dimensions['dst_height'];
@ -1387,7 +1443,7 @@ wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?>
$header_images['default'] = array(
'url' => $default,
'thumbnail_url' => $default,
'description' => 'Default'
'description' => 'Default',
);
// The rest of the set comes after.

View File

@ -133,7 +133,9 @@ $body_class = 'wp-core-ui wp-customizer js';
if ( wp_is_mobile() ) :
$body_class .= ' mobile';
?><meta name="viewport" id="viewport-meta" content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=1.2" /><?php
?>
<meta name="viewport" id="viewport-meta" content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=1.2" />
<?php
endif;
if ( $wp_customize->is_ios() ) {
@ -147,7 +149,8 @@ $body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '
$admin_title = sprintf( $wp_customize->get_document_title_template(), __( 'Loading&hellip;' ) );
?><title><?php echo $admin_title; ?></title>
?>
<title><?php echo $admin_title; ?></title>
<script type="text/javascript">
var ajaxurl = <?php echo wp_json_encode( admin_url( 'admin-ajax.php', 'relative' ) ); ?>,
@ -202,14 +205,18 @@ do_action( 'customize_controls_print_scripts' );
<div class="wp-full-overlay-sidebar-content" tabindex="-1">
<div id="customize-info" class="accordion-section customize-info">
<div class="accordion-section-title">
<span class="preview-notice"><?php
<span class="preview-notice">
<?php
echo sprintf( __( 'You are customizing %s' ), '<strong class="panel-title site-title">' . get_bloginfo( 'name', 'display' ) . '</strong>' );
?></span>
?>
</span>
<button type="button" class="customize-help-toggle dashicons dashicons-editor-help" aria-expanded="false"><span class="screen-reader-text"><?php _e( 'Help' ); ?></span></button>
</div>
<div class="customize-panel-description"><?php
<div class="customize-panel-description">
<?php
_e( 'The Customizer allows you to preview changes to your site before publishing them. You can navigate to different pages on your site within the preview. Edit shortcuts are shown for some editable elements.' );
?></div>
?>
</div>
</div>
<div id="customize-theme-controls">
@ -238,7 +245,7 @@ do_action( 'customize_controls_print_scripts' );
$class .= ' active';
}
?>
<button type="button" class="<?php echo esc_attr( $class ); ?>" aria-pressed="<?php echo esc_attr( $active ) ?>" data-device="<?php echo esc_attr( $device ); ?>">
<button type="button" class="<?php echo esc_attr( $class ); ?>" aria-pressed="<?php echo esc_attr( $active ); ?>" data-device="<?php echo esc_attr( $device ); ?>">
<span class="screen-reader-text"><?php echo esc_html( $settings['label'] ); ?></span>
</button>
<?php endforeach; ?>

View File

@ -47,8 +47,9 @@ if ( $doaction ) {
wp_defer_comment_counting( true );
foreach ( $comment_ids as $comment_id ) { // Check the permissions on each
if ( !current_user_can( 'edit_comment', $comment_id ) )
if ( ! current_user_can( 'edit_comment', $comment_id ) ) {
continue;
}
switch ( $doaction ) {
case 'approve':
@ -104,22 +105,30 @@ if ( $doaction ) {
wp_defer_comment_counting( false );
if ( $approved )
if ( $approved ) {
$redirect_to = add_query_arg( 'approved', $approved, $redirect_to );
if ( $unapproved )
}
if ( $unapproved ) {
$redirect_to = add_query_arg( 'unapproved', $unapproved, $redirect_to );
if ( $spammed )
}
if ( $spammed ) {
$redirect_to = add_query_arg( 'spammed', $spammed, $redirect_to );
if ( $unspammed )
}
if ( $unspammed ) {
$redirect_to = add_query_arg( 'unspammed', $unspammed, $redirect_to );
if ( $trashed )
}
if ( $trashed ) {
$redirect_to = add_query_arg( 'trashed', $trashed, $redirect_to );
if ( $untrashed )
}
if ( $untrashed ) {
$redirect_to = add_query_arg( 'untrashed', $untrashed, $redirect_to );
if ( $deleted )
}
if ( $deleted ) {
$redirect_to = add_query_arg( 'deleted', $deleted, $redirect_to );
if ( $trashed || $spammed )
}
if ( $trashed || $spammed ) {
$redirect_to = add_query_arg( 'ids', join( ',', $comment_ids ), $redirect_to );
}
wp_safe_redirect( $redirect_to );
exit;
@ -138,13 +147,15 @@ if ( $post_id ) {
$draft_or_post_title = wp_html_excerpt( _draft_or_post_title( $post_id ), 50, '&hellip;' );
if ( $comments_count->moderated > 0 ) {
/* translators: 1: comments count 2: post title */
$title = sprintf( __( 'Comments (%1$s) on &#8220;%2$s&#8221;' ),
$title = sprintf(
__( 'Comments (%1$s) on &#8220;%2$s&#8221;' ),
number_format_i18n( $comments_count->moderated ),
$draft_or_post_title
);
} else {
/* translators: %s: post title */
$title = sprintf( __( 'Comments on &#8220;%s&#8221;' ),
$title = sprintf(
__( 'Comments on &#8220;%s&#8221;' ),
$draft_or_post_title
);
}
@ -152,7 +163,8 @@ if ( $post_id ) {
$comments_count = wp_count_comments();
if ( $comments_count->moderated > 0 ) {
/* translators: %s: comments count */
$title = sprintf( __( 'Comments (%s)' ),
$title = sprintf(
__( 'Comments (%s)' ),
number_format_i18n( $comments_count->moderated )
);
} else {
@ -162,13 +174,16 @@ if ( $post_id ) {
add_screen_option( 'per_page' );
get_current_screen()->add_help_tab( array(
get_current_screen()->add_help_tab(
array(
'id' => 'overview',
'title' => __( 'Overview' ),
'content' =>
'<p>' . __( 'You can manage comments made on your site similar to the way you manage posts and other content. This screen is customizable in the same ways as other management screens, and you can act on comments using the on-hover action links or the Bulk Actions.' ) . '</p>'
) );
get_current_screen()->add_help_tab( array(
'<p>' . __( 'You can manage comments made on your site similar to the way you manage posts and other content. This screen is customizable in the same ways as other management screens, and you can act on comments using the on-hover action links or the Bulk Actions.' ) . '</p>',
)
);
get_current_screen()->add_help_tab(
array(
'id' => 'moderating-comments',
'title' => __( 'Moderating Comments' ),
'content' =>
@ -177,8 +192,9 @@ get_current_screen()->add_help_tab( array(
'<p>' . __( 'In the <strong>Comment</strong> column, hovering over any comment gives you options to approve, reply (and approve), quick edit, edit, spam mark, or trash that comment.' ) . '</p>' .
'<p>' . __( 'In the <strong>In Response To</strong> column, there are three elements. The text is the name of the post that inspired the comment, and links to the post editor for that entry. The View Post link leads to that post on your live site. The small bubble with the number in it shows the number of approved comments that post has received. If there are pending comments, a red notification circle with the number of pending comments is displayed. Clicking the notification circle will filter the comments screen to show only pending comments on that post.' ) . '</p>' .
'<p>' . __( 'In the <strong>Submitted On</strong> column, the date and time the comment was left on your site appears. Clicking on the date/time link will take you to that comment on your live site.' ) . '</p>' .
'<p>' . __( 'Many people take advantage of keyboard shortcuts to moderate their comments more quickly. Use the link to the side to learn more.' ) . '</p>'
) );
'<p>' . __( 'Many people take advantage of keyboard shortcuts to moderate their comments more quickly. Use the link to the side to learn more.' ) . '</p>',
)
);
get_current_screen()->set_help_sidebar(
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
@ -188,21 +204,26 @@ get_current_screen()->set_help_sidebar(
'<p>' . __( '<a href="https://wordpress.org/support/">Support Forums</a>' ) . '</p>'
);
get_current_screen()->set_screen_reader_content( array(
get_current_screen()->set_screen_reader_content(
array(
'heading_views' => __( 'Filter comments list' ),
'heading_pagination' => __( 'Comments list navigation' ),
'heading_list' => __( 'Comments list' ),
) );
)
);
require_once( ABSPATH . 'wp-admin/admin-header.php' );
?>
<div class="wrap">
<h1 class="wp-heading-inline"><?php
<h1 class="wp-heading-inline">
<?php
if ( $post_id ) {
/* translators: %s: link to post */
printf( __( 'Comments on &#8220;%s&#8221;' ),
sprintf( '<a href="%1$s">%2$s</a>',
printf(
__( 'Comments on &#8220;%s&#8221;' ),
sprintf(
'<a href="%1$s">%2$s</a>',
get_edit_post_link( $post_id ),
wp_html_excerpt( _draft_or_post_title( $post_id ), 50, '&hellip;' )
)
@ -210,13 +231,15 @@ if ( $post_id ) {
} else {
_e( 'Comments' );
}
?></h1>
?>
</h1>
<?php
if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) {
echo '<span class="subtitle">';
/* translators: %s: search keywords */
printf( __( 'Search results for &#8220;%s&#8221;' ),
printf(
__( 'Search results for &#8220;%s&#8221;' ),
wp_html_excerpt( esc_html( wp_unslash( $_REQUEST['s'] ) ), 50, '&hellip;' )
);
echo '</span>';
@ -237,9 +260,10 @@ if ( isset( $_REQUEST['error'] ) ) {
$error_msg = __( 'Sorry, you are not allowed to edit comments on this post.' );
break;
}
if ( $error_msg )
if ( $error_msg ) {
echo '<div id="moderated" class="error"><p>' . $error_msg . '</p></div>';
}
}
if ( isset( $_REQUEST['approved'] ) || isset( $_REQUEST['deleted'] ) || isset( $_REQUEST['trashed'] ) || isset( $_REQUEST['untrashed'] ) || isset( $_REQUEST['spammed'] ) || isset( $_REQUEST['unspammed'] ) || isset( $_REQUEST['same'] ) ) {
$approved = isset( $_REQUEST['approved'] ) ? (int) $_REQUEST['approved'] : 0;
@ -259,7 +283,7 @@ if ( isset($_REQUEST['approved']) || isset($_REQUEST['deleted']) || isset($_REQU
if ( $spammed > 0 ) {
$ids = isset( $_REQUEST['ids'] ) ? $_REQUEST['ids'] : 0;
/* translators: %s: number of comments marked as spam */
$messages[] = sprintf( _n( '%s comment marked as spam.', '%s comments marked as spam.', $spammed ), $spammed ) . ' <a href="' . esc_url( wp_nonce_url( "edit-comments.php?doaction=undo&action=unspam&ids=$ids", "bulk-comments" ) ) . '">' . __('Undo') . '</a><br />';
$messages[] = sprintf( _n( '%s comment marked as spam.', '%s comments marked as spam.', $spammed ), $spammed ) . ' <a href="' . esc_url( wp_nonce_url( "edit-comments.php?doaction=undo&action=unspam&ids=$ids", 'bulk-comments' ) ) . '">' . __( 'Undo' ) . '</a><br />';
}
if ( $unspammed > 0 ) {
@ -270,7 +294,7 @@ if ( isset($_REQUEST['approved']) || isset($_REQUEST['deleted']) || isset($_REQU
if ( $trashed > 0 ) {
$ids = isset( $_REQUEST['ids'] ) ? $_REQUEST['ids'] : 0;
/* translators: %s: number of comments moved to the Trash */
$messages[] = sprintf( _n( '%s comment moved to the Trash.', '%s comments moved to the Trash.', $trashed ), $trashed ) . ' <a href="' . esc_url( wp_nonce_url( "edit-comments.php?doaction=undo&action=untrash&ids=$ids", "bulk-comments" ) ) . '">' . __('Undo') . '</a><br />';
$messages[] = sprintf( _n( '%s comment moved to the Trash.', '%s comments moved to the Trash.', $trashed ), $trashed ) . ' <a href="' . esc_url( wp_nonce_url( "edit-comments.php?doaction=undo&action=untrash&ids=$ids", 'bulk-comments' ) ) . '">' . __( 'Undo' ) . '</a><br />';
}
if ( $untrashed > 0 ) {

View File

@ -7,8 +7,9 @@
*/
// don't load directly
if ( !defined('ABSPATH') )
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
/**
* @global string $post_type
@ -20,10 +21,16 @@ global $post_type, $post_type_object, $post;
if ( is_multisite() ) {
add_action( 'admin_footer', '_admin_notice_post_locked' );
} else {
$check_users = get_users( array( 'fields' => 'ID', 'number' => 2 ) );
$check_users = get_users(
array(
'fields' => 'ID',
'number' => 2,
)
);
if ( count( $check_users ) > 1 )
if ( count( $check_users ) > 1 ) {
add_action( 'admin_footer', '_admin_notice_post_locked' );
}
unset( $check_users );
}
@ -49,11 +56,13 @@ if ( post_type_supports( $post_type, 'editor' ) && ! wp_is_mobile() &&
$_wp_editor_expand = ( get_user_setting( 'editor_expand', 'on' ) === 'on' );
}
if ( wp_is_mobile() )
if ( wp_is_mobile() ) {
wp_enqueue_script( 'jquery-touch-punch' );
}
/**
* Post ID global
*
* @name $post_ID
* @var int
*/
@ -103,37 +112,43 @@ $viewable = is_post_type_viewable( $post_type_object );
if ( $viewable ) {
// Preview post link.
$preview_post_link_html = sprintf( ' <a target="_blank" href="%1$s">%2$s</a>',
$preview_post_link_html = sprintf(
' <a target="_blank" href="%1$s">%2$s</a>',
esc_url( $preview_url ),
__( 'Preview post' )
);
// Scheduled post preview link.
$scheduled_post_link_html = sprintf( ' <a target="_blank" href="%1$s">%2$s</a>',
$scheduled_post_link_html = sprintf(
' <a target="_blank" href="%1$s">%2$s</a>',
esc_url( $permalink ),
__( 'Preview post' )
);
// View post link.
$view_post_link_html = sprintf( ' <a href="%1$s">%2$s</a>',
$view_post_link_html = sprintf(
' <a href="%1$s">%2$s</a>',
esc_url( $permalink ),
__( 'View post' )
);
// Preview page link.
$preview_page_link_html = sprintf( ' <a target="_blank" href="%1$s">%2$s</a>',
$preview_page_link_html = sprintf(
' <a target="_blank" href="%1$s">%2$s</a>',
esc_url( $preview_url ),
__( 'Preview page' )
);
// Scheduled page preview link.
$scheduled_page_link_html = sprintf( ' <a target="_blank" href="%1$s">%2$s</a>',
$scheduled_page_link_html = sprintf(
' <a target="_blank" href="%1$s">%2$s</a>',
esc_url( $permalink ),
__( 'Preview page' )
);
// View page link.
$view_page_link_html = sprintf( ' <a href="%1$s">%2$s</a>',
$view_page_link_html = sprintf(
' <a href="%1$s">%2$s</a>',
esc_url( $permalink ),
__( 'View page' )
);
@ -185,17 +200,19 @@ $messages = apply_filters( 'post_updated_messages', $messages );
$message = false;
if ( isset( $_GET['message'] ) ) {
$_GET['message'] = absint( $_GET['message'] );
if ( isset($messages[$post_type][$_GET['message']]) )
if ( isset( $messages[ $post_type ][ $_GET['message'] ] ) ) {
$message = $messages[ $post_type ][ $_GET['message'] ];
elseif ( !isset($messages[$post_type]) && isset($messages['post'][$_GET['message']]) )
} elseif ( ! isset( $messages[ $post_type ] ) && isset( $messages['post'][ $_GET['message'] ] ) ) {
$message = $messages['post'][ $_GET['message'] ];
}
}
$notice = false;
$form_extra = '';
if ( 'auto-draft' == $post->post_status ) {
if ( 'edit' == $action )
if ( 'edit' == $action ) {
$post->post_title = '';
}
$autosave = false;
$form_extra .= "<input type='hidden' id='auto_draft' name='auto_draft' value='1' />";
} else {
@ -215,8 +232,9 @@ if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql
}
}
// If this autosave isn't different from the current post, begone.
if ( ! $notice )
if ( ! $notice ) {
wp_delete_post_revision( $autosave->ID );
}
unset( $autosave_field, $_autosave_field );
}
@ -233,7 +251,10 @@ if ( post_type_supports($post_type, 'revisions') && 'auto-draft' != $post->post_
// We should aim to show the revisions meta box only when there are revisions.
if ( count( $revisions ) > 1 ) {
reset( $revisions ); // Reset pointer for key()
$publish_callback_args = array( 'revisions_count' => count( $revisions ), 'revision_id' => key( $revisions ) );
$publish_callback_args = array(
'revisions_count' => count( $revisions ),
'revision_id' => key( $revisions ),
);
add_meta_box( 'revisionsdiv', __( 'Revisions' ), 'post_revisions_meta_box', null, 'normal', 'core' );
}
}
@ -251,21 +272,24 @@ if ( 'attachment' == $post_type ) {
add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', null, 'side', 'core', $publish_callback_args );
}
if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post_type, 'post-formats' ) )
if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post_type, 'post-formats' ) ) {
add_meta_box( 'formatdiv', _x( 'Format', 'post format' ), 'post_format_meta_box', null, 'side', 'core' );
}
// all taxonomies
foreach ( get_object_taxonomies( $post ) as $tax_name ) {
$taxonomy = get_taxonomy( $tax_name );
if ( ! $taxonomy->show_ui || false === $taxonomy->meta_box_cb )
if ( ! $taxonomy->show_ui || false === $taxonomy->meta_box_cb ) {
continue;
}
$label = $taxonomy->labels->name;
if ( ! is_taxonomy_hierarchical( $tax_name ) )
if ( ! is_taxonomy_hierarchical( $tax_name ) ) {
$tax_meta_box_id = 'tagsdiv-' . $tax_name;
else
} else {
$tax_meta_box_id = $tax_name . 'div';
}
add_meta_box( $tax_meta_box_id, $label, $taxonomy->meta_box_cb, null, 'side', 'core', array( 'taxonomy' => $tax_name ) );
}
@ -274,17 +298,21 @@ if ( post_type_supports( $post_type, 'page-attributes' ) || count( get_page_temp
add_meta_box( 'pageparentdiv', $post_type_object->labels->attributes, 'page_attributes_meta_box', null, 'side', 'core' );
}
if ( $thumbnail_support && current_user_can( 'upload_files' ) )
if ( $thumbnail_support && current_user_can( 'upload_files' ) ) {
add_meta_box( 'postimagediv', esc_html( $post_type_object->labels->featured_image ), 'post_thumbnail_meta_box', null, 'side', 'low' );
}
if ( post_type_supports($post_type, 'excerpt') )
if ( post_type_supports( $post_type, 'excerpt' ) ) {
add_meta_box( 'postexcerpt', __( 'Excerpt' ), 'post_excerpt_meta_box', null, 'normal', 'core' );
}
if ( post_type_supports($post_type, 'trackbacks') )
if ( post_type_supports( $post_type, 'trackbacks' ) ) {
add_meta_box( 'trackbacksdiv', __( 'Send Trackbacks' ), 'post_trackback_meta_box', null, 'normal', 'core' );
}
if ( post_type_supports($post_type, 'custom-fields') )
if ( post_type_supports( $post_type, 'custom-fields' ) ) {
add_meta_box( 'postcustom', __( 'Custom Fields' ), 'post_custom_meta_box', null, 'normal', 'core' );
}
/**
* Fires in the middle of built-in meta box registration.
@ -316,8 +344,9 @@ if ( in_array( get_post_status( $post ), $stati ) ) {
}
}
if ( ! ( 'pending' == get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) ) )
if ( ! ( 'pending' == get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) ) ) {
add_meta_box( 'slugdiv', __( 'Slug' ), 'post_slug_meta_box', null, 'normal', 'core' );
}
if ( post_type_supports( $post_type, 'author' ) && current_user_can( $post_type_object->cap->edit_others_posts ) ) {
add_meta_box( 'authordiv', __( 'Author' ), 'post_author_meta_box', null, 'normal', 'core' );
@ -361,16 +390,23 @@ do_action( 'do_meta_boxes', $post_type, 'advanced', $post );
/** This action is documented in wp-admin/edit-form-advanced.php */
do_action( 'do_meta_boxes', $post_type, 'side', $post );
add_screen_option('layout_columns', array('max' => 2, 'default' => 2) );
add_screen_option(
'layout_columns', array(
'max' => 2,
'default' => 2,
)
);
if ( 'post' == $post_type ) {
$customize_display = '<p>' . __( 'The title field and the big Post Editing Area are fixed in place, but you can reposition all the other boxes using drag and drop. You can also minimize or expand them by clicking the title bar of each box. Use the Screen Options tab to unhide more boxes (Excerpt, Send Trackbacks, Custom Fields, Discussion, Slug, Author) or to choose a 1- or 2-column layout for this screen.' ) . '</p>';
get_current_screen()->add_help_tab( array(
get_current_screen()->add_help_tab(
array(
'id' => 'customize-display',
'title' => __( 'Customizing This Display' ),
'content' => $customize_display,
) );
)
);
$title_and_editor = '<p>' . __( '<strong>Title</strong> &mdash; Enter a title for your post. After you enter a title, you&#8217;ll see the permalink below, which you can edit.' ) . '</p>';
$title_and_editor .= '<p>' . __( '<strong>Post editor</strong> &mdash; Enter the text for your post. There are two modes of editing: Visual and Text. Choose the mode by clicking on the appropriate tab.' ) . '</p>';
@ -380,11 +416,13 @@ if ( 'post' == $post_type ) {
$title_and_editor .= '<p>' . __( 'You can enable distraction-free writing mode using the icon to the right. This feature is not available for old browsers or devices with small screens, and requires that the full-height editor be enabled in Screen Options.' ) . '</p>';
$title_and_editor .= '<p>' . __( 'Keyboard users: When you&#8217;re working in the visual editor, you can use <kbd>Alt + F10</kbd> to access the toolbar.' ) . '</p>';
get_current_screen()->add_help_tab( array(
get_current_screen()->add_help_tab(
array(
'id' => 'title-post-editor',
'title' => __( 'Title and Post Editor' ),
'content' => $title_and_editor,
) );
)
);
get_current_screen()->set_help_sidebar(
'<p>' . sprintf( __( 'You can also create posts with the <a href="%s">Press This bookmarklet</a>.' ), 'tools.php' ) . '</p>' .
@ -396,11 +434,13 @@ if ( 'post' == $post_type ) {
$about_pages = '<p>' . __( 'Pages are similar to posts in that they have a title, body text, and associated metadata, but they are different in that they are not part of the chronological blog stream, kind of like permanent posts. Pages are not categorized or tagged, but can have a hierarchy. You can nest pages under other pages by making one the &#8220;Parent&#8221; of the other, creating a group of pages.' ) . '</p>' .
'<p>' . __( 'Creating a Page is very similar to creating a Post, and the screens can be customized in the same way using drag and drop, the Screen Options tab, and expanding/collapsing boxes as you choose. This screen also has the distraction-free writing space, available in both the Visual and Text modes via the Fullscreen buttons. The Page editor mostly works the same as the Post editor, but there are some Page-specific features in the Page Attributes box.' ) . '</p>';
get_current_screen()->add_help_tab( array(
get_current_screen()->add_help_tab(
array(
'id' => 'about-pages',
'title' => __( 'About Pages' ),
'content' => $about_pages,
) );
)
);
get_current_screen()->set_help_sidebar(
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
@ -409,15 +449,17 @@ if ( 'post' == $post_type ) {
'<p>' . __( '<a href="https://wordpress.org/support/">Support Forums</a>' ) . '</p>'
);
} elseif ( 'attachment' == $post_type ) {
get_current_screen()->add_help_tab( array(
get_current_screen()->add_help_tab(
array(
'id' => 'overview',
'title' => __( 'Overview' ),
'content' =>
'<p>' . __( 'This screen allows you to edit four fields for metadata in a file within the media library.' ) . '</p>' .
'<p>' . __( 'For images only, you can click on Edit Image under the thumbnail to expand out an inline image editor with icons for cropping, rotating, or flipping the image as well as for undoing and redoing. The boxes on the right give you more options for scaling the image, for cropping it, and for cropping the thumbnail in a different way than you crop the original image. You can click on Help in those boxes to get more information.' ) . '</p>' .
'<p>' . __( 'Note that you crop the image by clicking on it (the Crop icon is already selected) and dragging the cropping frame to select the desired part. Then click Save to retain the cropping.' ) . '</p>' .
'<p>' . __('Remember to click Update Media to save metadata entered or changed.') . '</p>'
) );
'<p>' . __( 'Remember to click Update Media to save metadata entered or changed.' ) . '</p>',
)
);
get_current_screen()->set_help_sidebar(
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
@ -430,11 +472,13 @@ if ( 'post' == $post_type || 'page' == $post_type ) {
$inserting_media = '<p>' . __( 'You can upload and insert media (images, audio, documents, etc.) by clicking the Add Media button. You can select from the images and files already uploaded to the Media Library, or upload new media to add to your page or post. To create an image gallery, select the images to add and click the &#8220;Create a new gallery&#8221; button.' ) . '</p>';
$inserting_media .= '<p>' . __( 'You can also embed media from many popular websites including Twitter, YouTube, Flickr and others by pasting the media URL on its own line into the content of your post/page. Please refer to the Codex to <a href="https://codex.wordpress.org/Embeds">learn more about embeds</a>.' ) . '</p>';
get_current_screen()->add_help_tab( array(
get_current_screen()->add_help_tab(
array(
'id' => 'inserting-media',
'title' => __( 'Inserting Media' ),
'content' => $inserting_media,
) );
)
);
}
if ( 'post' == $post_type ) {
@ -454,39 +498,47 @@ if ( 'post' == $post_type ) {
$publish_box .= '</ul>';
get_current_screen()->add_help_tab( array(
get_current_screen()->add_help_tab(
array(
'id' => 'publish-box',
'title' => __( 'Publish Settings' ),
'content' => $publish_box,
) );
)
);
$discussion_settings = '<p>' . __( '<strong>Send Trackbacks</strong> &mdash; Trackbacks are a way to notify legacy blog systems that you&#8217;ve linked to them. Enter the URL(s) you want to send trackbacks. If you link to other WordPress sites they&#8217;ll be notified automatically using pingbacks, and this field is unnecessary.' ) . '</p>';
$discussion_settings .= '<p>' . __( '<strong>Discussion</strong> &mdash; You can turn comments and pings on or off, and if there are comments on the post, you can see them here and moderate them.' ) . '</p>';
get_current_screen()->add_help_tab( array(
get_current_screen()->add_help_tab(
array(
'id' => 'discussion-settings',
'title' => __( 'Discussion Settings' ),
'content' => $discussion_settings,
) );
)
);
} elseif ( 'page' == $post_type ) {
$page_attributes = '<p>' . __( '<strong>Parent</strong> &mdash; You can arrange your pages in hierarchies. For example, you could have an &#8220;About&#8221; page that has &#8220;Life Story&#8221; and &#8220;My Dog&#8221; pages under it. There are no limits to how many levels you can nest pages.' ) . '</p>' .
'<p>' . __( '<strong>Template</strong> &mdash; Some themes have custom templates you can use for certain pages that might have additional features or custom layouts. If so, you&#8217;ll see them in this dropdown menu.' ) . '</p>' .
'<p>' . __( '<strong>Order</strong> &mdash; Pages are usually ordered alphabetically, but you can choose your own order by entering a number (1 for first, etc.) in this field.' ) . '</p>';
get_current_screen()->add_help_tab( array(
get_current_screen()->add_help_tab(
array(
'id' => 'page-attributes',
'title' => __( 'Page Attributes' ),
'content' => $page_attributes,
) );
)
);
}
require_once( ABSPATH . 'wp-admin/admin-header.php' );
?>
<div class="wrap">
<h1 class="wp-heading-inline"><?php
<h1 class="wp-heading-inline">
<?php
echo esc_html( $title );
?></h1>
?>
</h1>
<?php
if ( isset( $post_new_file ) && current_user_can( $post_type_object->cap->create_posts ) ) {
@ -497,7 +549,7 @@ if ( isset( $post_new_file ) && current_user_can( $post_type_object->cap->create
<hr class="wp-header-end">
<?php if ( $notice ) : ?>
<div id="notice" class="notice notice-warning"><p id="has-newer-autosave"><?php echo $notice ?></p></div>
<div id="notice" class="notice notice-warning"><p id="has-newer-autosave"><?php echo $notice; ?></p></div>
<?php endif; ?>
<?php if ( $message ) : ?>
<div id="message" class="updated notice notice-success is-dismissible"><p><?php echo $message; ?></p></div>
@ -507,7 +559,8 @@ if ( isset( $post_new_file ) && current_user_can( $post_type_object->cap->create
<span class="hide-if-no-sessionstorage"><?php _e( 'We&#8217;re backing up this post in your browser, just in case.' ); ?></span>
</p>
</div>
<form name="post" action="post.php" method="post" id="post"<?php
<form name="post" action="post.php" method="post" id="post"
<?php
/**
* Fires inside the post editor form tag.
*
@ -518,21 +571,23 @@ if ( isset( $post_new_file ) && current_user_can( $post_type_object->cap->create
do_action( 'post_edit_form_tag', $post );
$referer = wp_get_referer();
?>>
?>
>
<?php wp_nonce_field( $nonce_action ); ?>
<input type="hidden" id="user-id" name="user_ID" value="<?php echo (int) $user_ID ?>" />
<input type="hidden" id="hiddenaction" name="action" value="<?php echo esc_attr( $form_action ) ?>" />
<input type="hidden" id="originalaction" name="originalaction" value="<?php echo esc_attr( $form_action ) ?>" />
<input type="hidden" id="user-id" name="user_ID" value="<?php echo (int) $user_ID; ?>" />
<input type="hidden" id="hiddenaction" name="action" value="<?php echo esc_attr( $form_action ); ?>" />
<input type="hidden" id="originalaction" name="originalaction" value="<?php echo esc_attr( $form_action ); ?>" />
<input type="hidden" id="post_author" name="post_author" value="<?php echo esc_attr( $post->post_author ); ?>" />
<input type="hidden" id="post_type" name="post_type" value="<?php echo esc_attr( $post_type ) ?>" />
<input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo esc_attr( $post->post_status) ?>" />
<input type="hidden" id="post_type" name="post_type" value="<?php echo esc_attr( $post_type ); ?>" />
<input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo esc_attr( $post->post_status ); ?>" />
<input type="hidden" id="referredby" name="referredby" value="<?php echo $referer ? esc_url( $referer ) : ''; ?>" />
<?php if ( ! empty( $active_post_lock ) ) { ?>
<input type="hidden" id="active_post_lock" value="<?php echo esc_attr( implode( ':', $active_post_lock ) ); ?>" />
<?php
}
if ( 'draft' != get_post_status( $post ) )
if ( 'draft' != get_post_status( $post ) ) {
wp_original_referer_field( true, 'previous' );
}
echo $form_extra;
@ -550,7 +605,8 @@ wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
*
* @param WP_Post $post Post object.
*/
do_action( 'edit_form_top', $post ); ?>
do_action( 'edit_form_top', $post );
?>
<div id="poststuff">
<div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">
@ -602,8 +658,9 @@ if ( $post_type_object->public && ! ( 'pending' == get_post_status( $post ) && !
?>
<div id="edit-slug-box" class="hide-if-no-js">
<?php
if ( $has_sample_permalink )
if ( $has_sample_permalink ) {
echo $sample_permalink_html;
}
?>
</div>
<?php
@ -634,7 +691,9 @@ if ( post_type_supports($post_type, 'editor') ) {
?>
<div id="postdivrich" class="postarea<?php echo $_wp_editor_expand_class; ?>">
<?php wp_editor( $post->post_content, 'content', array(
<?php
wp_editor(
$post->post_content, 'content', array(
'_content_editor_dfw' => $_content_editor_dfw,
'drag_drop_upload' => true,
'tabfocus_elements' => 'content-html,save-post',
@ -645,7 +704,9 @@ if ( post_type_supports($post_type, 'editor') ) {
'add_unload_trigger' => false,
'wp_keep_scroll_position' => ! $is_IE,
),
) ); ?>
)
);
?>
<table id="post-status-info"><tbody><tr>
<td id="wp-word-count" class="hide-if-no-js"><?php printf( __( 'Word count: %s' ), '<span class="word-count">0</span>' ); ?></td>
<td class="autosave-info">
@ -661,13 +722,15 @@ if ( post_type_supports($post_type, 'editor') ) {
printf( __( 'Last edited on %1$s at %2$s' ), mysql2date( __( 'F j, Y' ), $post->post_modified ), mysql2date( __( 'g:i a' ), $post->post_modified ) );
}
echo '</span>';
} ?>
}
?>
</td>
<td id="content-resize-handle" class="hide-if-no-js"><br /></td>
</tr></tbody></table>
</div>
<?php }
<?php
}
/**
* Fires after the content editor.
*
@ -693,8 +756,7 @@ if ( 'page' == $post_type ) {
* @param WP_Post $post Post object.
*/
do_action( 'submitpage_box', $post );
}
else {
} else {
/**
* Fires before meta boxes with 'side' context are output for all post types other than 'page'.
*
@ -726,8 +788,7 @@ if ( 'page' == $post_type ) {
* @param WP_Post $post Post object.
*/
do_action( 'edit_page_form', $post );
}
else {
} else {
/**
* Fires after 'normal' context meta boxes have been output for all post types other than 'page'.
*
@ -761,8 +822,9 @@ do_action( 'dbx_post_sidebar', $post );
</div>
<?php
if ( post_type_supports( $post_type, 'comments' ) )
if ( post_type_supports( $post_type, 'comments' ) ) {
wp_comment_reply();
}
?>
<?php if ( ! wp_is_mobile() && post_type_supports( $post_type, 'title' ) && '' === $post->post_title ) : ?>

View File

@ -7,11 +7,12 @@
*/
// don't load directly
if ( !defined('ABSPATH') )
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
?>
<form name="post" action="comment.php" method="post" id="post">
<?php wp_nonce_field('update-comment_' . $comment->comment_ID) ?>
<?php wp_nonce_field( 'update-comment_' . $comment->comment_ID ); ?>
<div class="wrap">
<h1><?php _e( 'Edit Comment' ); ?></h1>
@ -36,7 +37,7 @@ if ( 'approved' === wp_get_comment_status( $comment ) && $comment->comment_post_
<div id="namediv" class="stuffbox">
<div class="inside">
<fieldset>
<legend class="edit-comment-author"><?php _e( 'Author' ) ?></legend>
<legend class="edit-comment-author"><?php _e( 'Author' ); ?></legend>
<table class="form-table editcomment">
<tbody>
<tr>
@ -66,14 +67,21 @@ if ( 'approved' === wp_get_comment_status( $comment ) && $comment->comment_post_
<?php
echo '<label for="content" class="screen-reader-text">' . __( 'Comment' ) . '</label>';
$quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close' );
wp_editor( $comment->comment_content, 'content', array( 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings ) );
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
wp_editor(
$comment->comment_content, 'content', array(
'media_buttons' => false,
'tinymce' => false,
'quicktags' => $quicktags_settings,
)
);
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
?>
</div>
</div><!-- /post-body-content -->
<div id="postbox-container-1" class="postbox-container">
<div id="submitdiv" class="stuffbox" >
<h2><?php _e( 'Status' ) ?></h2>
<h2><?php _e( 'Status' ); ?></h2>
<div class="inside">
<div class="submitbox" id="submitcomment">
<div id="minor-publishing">
@ -92,13 +100,15 @@ if ( 'approved' === wp_get_comment_status( $comment ) && $comment->comment_post_
/* translators: Publish box date format, see https://secure.php.net/date */
$datef = __( 'M j, Y @ H:i' );
?>
<span id="timestamp"><?php
<span id="timestamp">
<?php
printf(
/* translators: %s: comment date */
__( 'Submitted on: %s' ),
'<b>' . date_i18n( $datef, strtotime( $comment->comment_date ) ) . '</b>'
);
?></span>
?>
</span>
<a href="#edit_timestamp" class="edit-timestamp hide-if-no-js"><span aria-hidden="true"><?php _e( 'Edit' ); ?></span> <span class="screen-reader-text"><?php _e( 'Edit date and time' ); ?></span></a>
<fieldset id='timestampdiv' class='hide-if-js'>
<legend class="screen-reader-text"><?php _e( 'Date and time' ); ?></legend>
@ -117,11 +127,13 @@ if ( current_user_can( 'edit_post', $post_id ) ) {
?>
<div class="misc-pub-section misc-pub-response-to">
<?php printf(
<?php
printf(
/* translators: %s: post link */
__( 'In response to: %s' ),
'<b>' . $post_link . '</b>'
); ?>
);
?>
</div>
<?php
@ -132,14 +144,18 @@ if ( $comment->comment_parent ) :
$name = get_comment_author( $parent );
?>
<div class="misc-pub-section misc-pub-reply-to">
<?php printf(
<?php
printf(
/* translators: %s: comment link */
__( 'In reply to: %s' ),
'<b><a href="' . $parent_link . '">' . $name . '</a></b>'
); ?>
);
?>
</div>
<?php endif;
endif; ?>
<?php
endif;
endif;
?>
<?php
/**
@ -159,7 +175,7 @@ endif; ?>
<div id="major-publishing-actions">
<div id="delete-action">
<?php echo "<a class='submitdelete deletion' href='" . wp_nonce_url("comment.php?action=" . ( !EMPTY_TRASH_DAYS ? 'deletecomment' : 'trashcomment' ) . "&amp;c=$comment->comment_ID&amp;_wp_original_http_referer=" . urlencode(wp_get_referer()), 'delete-comment_' . $comment->comment_ID) . "'>" . ( !EMPTY_TRASH_DAYS ? __('Delete Permanently') : __('Move to Trash') ) . "</a>\n"; ?>
<?php echo "<a class='submitdelete deletion' href='" . wp_nonce_url( 'comment.php?action=' . ( ! EMPTY_TRASH_DAYS ? 'deletecomment' : 'trashcomment' ) . "&amp;c=$comment->comment_ID&amp;_wp_original_http_referer=" . urlencode( wp_get_referer() ), 'delete-comment_' . $comment->comment_ID ) . "'>" . ( ! EMPTY_TRASH_DAYS ? __( 'Delete Permanently' ) : __( 'Move to Trash' ) ) . "</a>\n"; ?>
</div>
<div id="publishing-action">
<?php submit_button( __( 'Update' ), 'primary large', 'save', false ); ?>
@ -191,8 +207,8 @@ $referer = wp_get_referer();
?>
</div>
<input type="hidden" name="c" value="<?php echo esc_attr($comment->comment_ID) ?>" />
<input type="hidden" name="p" value="<?php echo esc_attr($comment->comment_post_ID) ?>" />
<input type="hidden" name="c" value="<?php echo esc_attr( $comment->comment_ID ); ?>" />
<input type="hidden" name="p" value="<?php echo esc_attr( $comment->comment_post_ID ); ?>" />
<input name="referredby" type="hidden" id="referredby" value="<?php echo $referer ? esc_url( $referer ) : ''; ?>" />
<?php wp_original_referer_field( true, 'previous' ); ?>
<input type="hidden" name="noredir" value="1" />
@ -206,4 +222,5 @@ $referer = wp_get_referer();
<script type="text/javascript">
try{document.post.name.focus();}catch(e){}
</script>
<?php endif;
<?php
endif;

View File

@ -7,8 +7,9 @@
*/
// don't load directly
if ( !defined('ABSPATH') )
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
if ( ! empty( $link_id ) ) {
$heading = sprintf( __( '<a href="%s">Links</a> / Edit Link' ), 'link-manager.php' );
@ -49,16 +50,23 @@ do_action( 'do_meta_boxes', 'link', 'advanced', $link );
/** This action is documented in wp-admin/edit-form-advanced.php */
do_action( 'do_meta_boxes', 'link', 'side', $link );
add_screen_option('layout_columns', array('max' => 2, 'default' => 2) );
add_screen_option(
'layout_columns', array(
'max' => 2,
'default' => 2,
)
);
get_current_screen()->add_help_tab( array(
get_current_screen()->add_help_tab(
array(
'id' => 'overview',
'title' => __( 'Overview' ),
'content' =>
'<p>' . __( 'You can add or edit links on this screen by entering information in each of the boxes. Only the link&#8217;s web address and name (the text you want to display on your site as the link) are required fields.' ) . '</p>' .
'<p>' . __( '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 don&#8217;t use in the Screen Options tab, or minimize boxes by clicking on the title bar of the box.' ) . '</p>' .
'<p>' . __( 'XFN stands for <a href="http://gmpg.org/xfn/">XHTML Friends Network</a>, 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.' ) . '</p>'
) );
'<p>' . __( 'XFN stands for <a href="http://gmpg.org/xfn/">XHTML Friends Network</a>, 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.' ) . '</p>',
)
);
get_current_screen()->set_help_sidebar(
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
@ -70,9 +78,11 @@ require_once( ABSPATH . 'wp-admin/admin-header.php' );
?>
<div class="wrap">
<h1 class="wp-heading-inline"><?php
<h1 class="wp-heading-inline">
<?php
echo esc_html( $title );
?></h1>
?>
</h1>
<a href="link-add.php" class="page-title-action"><?php echo esc_html_x( 'Add New', 'link' ); ?></a>
@ -90,14 +100,15 @@ if ( ! empty( $link_added ) ) {
wp_nonce_field( $nonce_action );
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
?>
<div id="poststuff">
<div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">
<div id="post-body-content">
<div id="namediv" class="stuffbox">
<h2><label for="link_name"><?php _ex( 'Name', 'link name' ) ?></label></h2>
<h2><label for="link_name"><?php _ex( 'Name', 'link name' ); ?></label></h2>
<div class="inside">
<input type="text" name="link_name" size="30" maxlength="255" value="<?php echo esc_attr( $link->link_name ); ?>" id="link_name" />
<p><?php _e( 'Example: Nifty blogging software' ); ?></p>
@ -105,7 +116,7 @@ wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
</div>
<div id="addressdiv" class="stuffbox">
<h2><label for="link_url"><?php _e( 'Web Address' ) ?></label></h2>
<h2><label for="link_url"><?php _e( 'Web Address' ); ?></label></h2>
<div class="inside">
<input type="text" name="link_url" size="30" maxlength="255" class="code" value="<?php echo esc_attr( $link->link_url ); ?>" id="link_url" />
<p><?php _e( 'Example: <code>http://wordpress.org/</code> &#8212; don&#8217;t forget the <code>http://</code>' ); ?></p>
@ -113,7 +124,7 @@ wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
</div>
<div id="descriptiondiv" class="stuffbox">
<h2><label for="link_description"><?php _e( 'Description' ) ?></label></h2>
<h2><label for="link_description"><?php _e( 'Description' ); ?></label></h2>
<div class="inside">
<input type="text" name="link_description" size="30" maxlength="255" value="<?php echo isset( $link->link_description ) ? esc_attr( $link->link_description ) : ''; ?>" id="link_description" />
<p><?php _e( 'This will be shown when someone hovers over the link in the blogroll, or optionally below the link.' ); ?></p>
@ -141,10 +152,11 @@ do_meta_boxes(null, 'advanced', $link);
</div>
<?php
if ( $link_id ) : ?>
if ( $link_id ) :
?>
<input type="hidden" name="action" value="save" />
<input type="hidden" name="link_id" value="<?php echo (int) $link_id; ?>" />
<input type="hidden" name="cat_id" value="<?php echo (int) $cat_id ?>" />
<input type="hidden" name="cat_id" value="<?php echo (int) $cat_id; ?>" />
<?php else : ?>
<input type="hidden" name="action" value="add" />
<?php endif; ?>

View File

@ -74,16 +74,19 @@ do_action( "{$taxonomy}_pre_edit_form", $tag, $taxonomy ); ?>
<div id="message" class="updated">
<p><strong><?php echo $message; ?></strong></p>
<?php if ( $wp_http_referer ) { ?>
<p><a href="<?php echo esc_url( wp_validate_redirect( esc_url_raw( $wp_http_referer ), admin_url( 'term.php?taxonomy=' . $taxonomy ) ) ); ?>"><?php
<p><a href="<?php echo esc_url( wp_validate_redirect( esc_url_raw( $wp_http_referer ), admin_url( 'term.php?taxonomy=' . $taxonomy ) ) ); ?>">
<?php
echo esc_html( $tax->labels->back_to_items );
?></a></p>
?>
</a></p>
<?php } ?>
</div>
<?php endif; ?>
<div id="ajax-response"></div>
<form name="edittag" id="edittag" method="post" action="edit-tags.php" class="validate"<?php
<form name="edittag" id="edittag" method="post" action="edit-tags.php" class="validate"
<?php
/**
* Fires inside the Edit Term form tag.
*
@ -92,10 +95,11 @@ do_action( "{$taxonomy}_pre_edit_form", $tag, $taxonomy ); ?>
* @since 3.7.0
*/
do_action( "{$taxonomy}_term_edit_form_tag" );
?>>
?>
>
<input type="hidden" name="action" value="editedtag"/>
<input type="hidden" name="tag_ID" value="<?php echo esc_attr( $tag_ID ) ?>"/>
<input type="hidden" name="taxonomy" value="<?php echo esc_attr( $taxonomy ) ?>"/>
<input type="hidden" name="tag_ID" value="<?php echo esc_attr( $tag_ID ); ?>"/>
<input type="hidden" name="taxonomy" value="<?php echo esc_attr( $taxonomy ); ?>"/>
<?php
wp_original_referer_field( true, 'previous' );
wp_nonce_field( 'update-tag_' . $tag_ID );
@ -167,7 +171,8 @@ if ( isset( $tag->name ) ) {
/** This filter is documented in wp-admin/edit-tags.php */
$dropdown_args = apply_filters( 'taxonomy_parent_dropdown_args', $dropdown_args, $taxonomy, 'edit' );
wp_dropdown_categories( $dropdown_args ); ?>
wp_dropdown_categories( $dropdown_args );
?>
<?php if ( 'category' == $taxonomy ) : ?>
<p class="description"><?php _e( 'Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have children categories for Bebop and Big Band. Totally optional.' ); ?></p>
<?php else : ?>
@ -266,7 +271,7 @@ do_action( "{$taxonomy}_edit_form", $tag, $taxonomy );
<?php if ( current_user_can( 'delete_term', $tag->term_id ) ) : ?>
<span id="delete-link">
<a class="delete" href="<?php echo admin_url( wp_nonce_url( "edit-tags.php?action=delete&taxonomy=$taxonomy&tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id ) ) ?>"><?php _e( 'Delete' ); ?></a>
<a class="delete" href="<?php echo admin_url( wp_nonce_url( "edit-tags.php?action=delete&taxonomy=$taxonomy&tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id ) ); ?>"><?php _e( 'Delete' ); ?></a>
</span>
<?php endif; ?>
@ -279,4 +284,5 @@ do_action( "{$taxonomy}_edit_form", $tag, $taxonomy );
<script type="text/javascript">
try{document.forms.edittag.name.focus();}catch(e){}
</script>
<?php endif;
<?php
endif;

View File

@ -9,13 +9,15 @@
/** WordPress Administration Bootstrap */
require_once( dirname( __FILE__ ) . '/admin.php' );
if ( ! $taxnow )
if ( ! $taxnow ) {
wp_die( __( 'Invalid taxonomy.' ) );
}
$tax = get_taxonomy( $taxnow );
if ( ! $tax )
if ( ! $tax ) {
wp_die( __( 'Invalid taxonomy.' ) );
}
if ( ! in_array( $tax->name, get_taxonomies( array( 'show_ui' => true ) ) ) ) {
wp_die( __( 'Sorry, you are not allowed to edit terms in this taxonomy.' ) );
@ -52,12 +54,19 @@ if ( 'post' != $post_type ) {
$submenu_file = "edit-tags.php?taxonomy=$taxonomy";
}
add_screen_option( 'per_page', array( 'default' => 20, 'option' => 'edit_' . $tax->name . '_per_page' ) );
add_screen_option(
'per_page', array(
'default' => 20,
'option' => 'edit_' . $tax->name . '_per_page',
)
);
get_current_screen()->set_screen_reader_content( array(
get_current_screen()->set_screen_reader_content(
array(
'heading_pagination' => $tax->labels->items_list_navigation,
'heading_list' => $tax->labels->items_list,
) );
)
);
$location = false;
$referer = wp_get_referer();
@ -79,10 +88,16 @@ case 'add-tag':
}
$ret = wp_insert_term( $_POST['tag-name'], $taxonomy, $_POST );
if ( $ret && !is_wp_error( $ret ) )
if ( $ret && ! is_wp_error( $ret ) ) {
$location = add_query_arg( 'message', 1, $referer );
else
$location = add_query_arg( array( 'error' => true, 'message' => 4 ), $referer );
} else {
$location = add_query_arg(
array(
'error' => true,
'message' => 4,
), $referer
);
}
break;
@ -159,15 +174,21 @@ case 'editedtag':
}
$tag = get_term( $tag_ID, $taxonomy );
if ( ! $tag )
if ( ! $tag ) {
wp_die( __( 'You attempted to edit an item that doesn&#8217;t exist. Perhaps it was deleted?' ) );
}
$ret = wp_update_term( $tag_ID, $taxonomy, $_POST );
if ( $ret && ! is_wp_error( $ret ) ) {
$location = add_query_arg( 'message', 3, $referer );
} else {
$location = add_query_arg( array( 'error' => true, 'message' => 5 ), $referer );
$location = add_query_arg(
array(
'error' => true,
'message' => 5,
), $referer
);
}
break;
default:
@ -211,63 +232,74 @@ if ( $pagenum > $total_pages && $total_pages > 0 ) {
}
wp_enqueue_script( 'admin-tags' );
if ( current_user_can($tax->cap->edit_terms) )
if ( current_user_can( $tax->cap->edit_terms ) ) {
wp_enqueue_script( 'inline-edit-tax' );
}
if ( 'category' == $taxonomy || 'link_category' == $taxonomy || 'post_tag' == $taxonomy ) {
$help = '';
if ( 'category' == $taxonomy )
if ( 'category' == $taxonomy ) {
$help = '<p>' . sprintf( __( 'You can use categories to define sections of your site and group related posts. The default category is &#8220;Uncategorized&#8221; until you change it in your <a href="%s">writing settings</a>.' ), 'options-writing.php' ) . '</p>';
elseif ( 'link_category' == $taxonomy )
} elseif ( 'link_category' == $taxonomy ) {
$help = '<p>' . __( 'You can create groups of links by using Link Categories. Link Category names must be unique and Link Categories are separate from the categories you use for posts.' ) . '</p>';
else
} else {
$help = '<p>' . __( 'You can assign keywords to your posts using <strong>tags</strong>. Unlike categories, tags have no hierarchy, meaning there&#8217;s no relationship from one tag to another.' ) . '</p>';
}
if ( 'link_category' == $taxonomy )
if ( 'link_category' == $taxonomy ) {
$help .= '<p>' . __( 'You can delete Link Categories in the Bulk Action pull-down, but that action does not delete the links within the category. Instead, it moves them to the default Link Category.' ) . '</p>';
else
} else {
$help .= '<p>' . __( 'What&#8217;s the difference between categories and tags? Normally, tags are ad-hoc keywords that identify important information in your post (names, subjects, etc) that may or may not recur in other posts, while categories are pre-determined sections. If you think of your site like a book, the categories are like the Table of Contents and the tags are like the terms in the index.' ) . '</p>';
}
get_current_screen()->add_help_tab( array(
get_current_screen()->add_help_tab(
array(
'id' => 'overview',
'title' => __( 'Overview' ),
'content' => $help,
) );
)
);
if ( 'category' == $taxonomy || 'post_tag' == $taxonomy ) {
if ( 'category' == $taxonomy )
if ( 'category' == $taxonomy ) {
$help = '<p>' . __( 'When adding a new category on this screen, you&#8217;ll fill in the following fields:' ) . '</p>';
else
} else {
$help = '<p>' . __( 'When adding a new tag on this screen, you&#8217;ll fill in the following fields:' ) . '</p>';
}
$help .= '<ul>' .
'<li>' . __( '<strong>Name</strong> &mdash; The name is how it appears on your site.' ) . '</li>';
if ( ! global_terms_enabled() )
if ( ! global_terms_enabled() ) {
$help .= '<li>' . __( '<strong>Slug</strong> &mdash; The &#8220;slug&#8221; is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.' ) . '</li>';
}
if ( 'category' == $taxonomy )
if ( 'category' == $taxonomy ) {
$help .= '<li>' . __( '<strong>Parent</strong> &mdash; Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have child categories for Bebop and Big Band. Totally optional. To create a subcategory, just choose another category from the Parent dropdown.' ) . '</li>';
}
$help .= '<li>' . __( '<strong>Description</strong> &mdash; The description is not prominent by default; however, some themes may display it.' ) . '</li>' .
'</ul>' .
'<p>' . __( 'You can change the display of this screen using the Screen Options tab to set how many items are displayed per screen and to display/hide columns in the table.' ) . '</p>';
get_current_screen()->add_help_tab( array(
get_current_screen()->add_help_tab(
array(
'id' => 'adding-terms',
'title' => 'category' == $taxonomy ? __( 'Adding Categories' ) : __( 'Adding Tags' ),
'content' => $help,
) );
)
);
}
$help = '<p><strong>' . __( 'For more information:' ) . '</strong></p>';
if ( 'category' == $taxonomy )
if ( 'category' == $taxonomy ) {
$help .= '<p>' . __( '<a href="https://codex.wordpress.org/Posts_Categories_Screen">Documentation on Categories</a>' ) . '</p>';
elseif ( 'link_category' == $taxonomy )
} elseif ( 'link_category' == $taxonomy ) {
$help .= '<p>' . __( '<a href="https://codex.wordpress.org/Links_Link_Categories_Screen">Documentation on Link Categories</a>' ) . '</p>';
else
} else {
$help .= '<p>' . __( '<a href="https://codex.wordpress.org/Posts_Tags_Screen">Documentation on Tags</a>' ) . '</p>';
}
$help .= '<p>' . __( '<a href="https://wordpress.org/support/">Support Forums</a>' ) . '</p>';
@ -305,8 +337,10 @@ if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) {
<?php if ( $message ) : ?>
<div id="message" class="<?php echo $class; ?> notice is-dismissible"><p><?php echo $message; ?></p></div>
<?php $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'message', 'error' ), $_SERVER['REQUEST_URI'] );
endif; ?>
<?php
$_SERVER['REQUEST_URI'] = remove_query_arg( array( 'message', 'error' ), $_SERVER['REQUEST_URI'] );
endif;
?>
<div id="ajax-response"></div>
<form class="search-form wp-clearfix" method="get">
@ -371,7 +405,8 @@ if ( current_user_can($tax->cap->edit_terms) ) {
<div class="form-wrap">
<h2><?php echo $tax->labels->add_new_item; ?></h2>
<form id="addtag" method="post" action="edit-tags.php" class="validate"<?php
<form id="addtag" method="post" action="edit-tags.php" class="validate"
<?php
/**
* Fires inside the Add Tag form tag.
*
@ -380,7 +415,8 @@ if ( current_user_can($tax->cap->edit_terms) ) {
* @since 3.7.0
*/
do_action( "{$taxonomy}_term_new_form_tag" );
?>>
?>
>
<input type="hidden" name="action" value="add-tag" />
<input type="hidden" name="screen" value="<?php echo esc_attr( $current_screen->id ); ?>" />
<input type="hidden" name="taxonomy" value="<?php echo esc_attr( $taxonomy ); ?>" />
@ -552,14 +588,15 @@ do_action( "{$taxonomy}_add_form", $taxonomy );
?>
</p>
<?php if ( current_user_can( 'import' ) ) : ?>
<p><?php printf( __( 'Categories can be selectively converted to tags using the <a href="%s">category to tag converter</a>.' ), esc_url( $import_link ) ) ?></p>
<p><?php printf( __( 'Categories can be selectively converted to tags using the <a href="%s">category to tag converter</a>.' ), esc_url( $import_link ) ); ?></p>
<?php endif; ?>
</div>
<?php elseif ( 'post_tag' == $taxonomy && current_user_can( 'import' ) ) : ?>
<div class="form-wrap edit-term-notes">
<p><?php printf( __( 'Tags can be selectively converted to categories using the <a href="%s">tag to category converter</a>.' ), esc_url( $import_link ) ); ?></p>
</div>
<?php endif;
<?php
endif;
/**
* Fires after the taxonomy list table.

View File

@ -9,8 +9,9 @@
/** WordPress Administration Bootstrap */
require_once( dirname( __FILE__ ) . '/admin.php' );
if ( ! $typenow )
if ( ! $typenow ) {
wp_die( __( 'Invalid post type.' ) );
}
if ( ! in_array( $typenow, get_post_types( array( 'show_ui' => true ) ) ) ) {
wp_die( __( 'Sorry, you are not allowed to edit posts in this post type.' ) );
@ -31,8 +32,9 @@ global $post_type, $post_type_object;
$post_type = $typenow;
$post_type_object = get_post_type_object( $post_type );
if ( ! $post_type_object )
if ( ! $post_type_object ) {
wp_die( __( 'Invalid post type.' ) );
}
if ( ! current_user_can( $post_type_object->cap->edit_posts ) ) {
wp_die(
@ -70,11 +72,13 @@ if ( $doaction ) {
check_admin_referer( 'bulk-posts' );
$sendback = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'locked', 'ids' ), wp_get_referer() );
if ( ! $sendback )
if ( ! $sendback ) {
$sendback = admin_url( $parent_file );
}
$sendback = add_query_arg( 'paged', $pagenum, $sendback );
if ( strpos($sendback, 'post.php') !== false )
if ( strpos( $sendback, 'post.php' ) !== false ) {
$sendback = admin_url( $post_new_file );
}
if ( 'delete_all' == $doaction ) {
// Prepare for deletion of all posts with a specified post status (i.e. Empty trash).
@ -102,30 +106,40 @@ if ( $doaction ) {
$trashed = $locked = 0;
foreach ( (array) $post_ids as $post_id ) {
if ( !current_user_can( 'delete_post', $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_check_post_lock( $post_id ) ) {
$locked++;
continue;
}
if ( !wp_trash_post($post_id) )
if ( ! wp_trash_post( $post_id ) ) {
wp_die( __( 'Error in moving to Trash.' ) );
}
$trashed++;
}
$sendback = add_query_arg( array('trashed' => $trashed, 'ids' => join(',', $post_ids), 'locked' => $locked ), $sendback );
$sendback = add_query_arg(
array(
'trashed' => $trashed,
'ids' => join( ',', $post_ids ),
'locked' => $locked,
), $sendback
);
break;
case 'untrash':
$untrashed = 0;
foreach ( (array) $post_ids as $post_id ) {
if ( !current_user_can( 'delete_post', $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) )
if ( ! wp_untrash_post( $post_id ) ) {
wp_die( __( 'Error in restoring from Trash.' ) );
}
$untrashed++;
}
@ -136,16 +150,19 @@ if ( $doaction ) {
foreach ( (array) $post_ids as $post_id ) {
$post_del = get_post( $post_id );
if ( !current_user_can( 'delete_post', $post_id ) )
if ( ! current_user_can( 'delete_post', $post_id ) ) {
wp_die( __( 'Sorry, you are not allowed to delete this item.' ) );
}
if ( $post_del->post_type == 'attachment' ) {
if ( ! wp_delete_attachment($post_id) )
if ( ! wp_delete_attachment( $post_id ) ) {
wp_die( __( 'Error in deleting.' ) );
}
} else {
if ( !wp_delete_post($post_id) )
if ( ! wp_delete_post( $post_id ) ) {
wp_die( __( 'Error in deleting.' ) );
}
}
$deleted++;
}
$sendback = add_query_arg( 'deleted', $deleted, $sendback );
@ -185,13 +202,16 @@ wp_enqueue_script('heartbeat');
$title = $post_type_object->labels->name;
if ( 'post' == $post_type ) {
get_current_screen()->add_help_tab( array(
get_current_screen()->add_help_tab(
array(
'id' => 'overview',
'title' => __( 'Overview' ),
'content' =>
'<p>' . __('This screen provides access to all of your posts. You can customize the display of this screen to suit your workflow.') . '</p>'
) );
get_current_screen()->add_help_tab( array(
'<p>' . __( 'This screen provides access to all of your posts. You can customize the display of this screen to suit your workflow.' ) . '</p>',
)
);
get_current_screen()->add_help_tab(
array(
'id' => 'screen-content',
'title' => __( 'Screen Content' ),
'content' =>
@ -201,9 +221,11 @@ if ( 'post' == $post_type ) {
'<li>' . __( 'You can filter the list of posts by post status using the text links above the posts list to only show posts with that status. The default view is to show all posts.' ) . '</li>' .
'<li>' . __( 'You can view posts in a simple title list or with an excerpt using the Screen Options tab.' ) . '</li>' .
'<li>' . __( 'You can refine the list to show only posts in a specific category or from a specific month by using the dropdown menus above the posts list. Click the Filter button after making your selection. You also can refine the list by clicking on the post author, category or tag in the posts list.' ) . '</li>' .
'</ul>'
) );
get_current_screen()->add_help_tab( array(
'</ul>',
)
);
get_current_screen()->add_help_tab(
array(
'id' => 'action-links',
'title' => __( 'Available Actions' ),
'content' =>
@ -213,15 +235,18 @@ if ( 'post' == $post_type ) {
'<li>' . __( '<strong>Quick Edit</strong> provides inline access to the metadata of your post, allowing you to update post details without leaving this screen.' ) . '</li>' .
'<li>' . __( '<strong>Trash</strong> removes your post from this list and places it in the trash, from which you can permanently delete it.' ) . '</li>' .
'<li>' . __( '<strong>Preview</strong> will show you what your draft post will look like if you publish it. View will take you to your live site to view the post. Which link is available depends on your post&#8217;s status.' ) . '</li>' .
'</ul>'
) );
get_current_screen()->add_help_tab( array(
'</ul>',
)
);
get_current_screen()->add_help_tab(
array(
'id' => 'bulk-actions',
'title' => __( 'Bulk Actions' ),
'content' =>
'<p>' . __( 'You can also edit or move multiple posts to the trash at once. Select the posts you want to act on using the checkboxes, then select the action you want to take from the Bulk Actions menu and click Apply.' ) . '</p>' .
'<p>' . __('When using Bulk Edit, you can change the metadata (categories, author, etc.) for all selected posts at once. To remove a post from the grouping, just click the x next to its name in the Bulk Edit area that appears.') . '</p>'
) );
'<p>' . __( 'When using Bulk Edit, you can change the metadata (categories, author, etc.) for all selected posts at once. To remove a post from the grouping, just click the x next to its name in the Bulk Edit area that appears.' ) . '</p>',
)
);
get_current_screen()->set_help_sidebar(
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
@ -230,19 +255,23 @@ if ( 'post' == $post_type ) {
);
} elseif ( 'page' == $post_type ) {
get_current_screen()->add_help_tab( array(
get_current_screen()->add_help_tab(
array(
'id' => 'overview',
'title' => __( 'Overview' ),
'content' =>
'<p>' . __('Pages are similar to posts in that they have a title, body text, and associated metadata, but they are different in that they are not part of the chronological blog stream, kind of like permanent posts. Pages are not categorized or tagged, but can have a hierarchy. You can nest pages under other pages by making one the &#8220;Parent&#8221; of the other, creating a group of pages.') . '</p>'
) );
get_current_screen()->add_help_tab( array(
'<p>' . __( 'Pages are similar to posts in that they have a title, body text, and associated metadata, but they are different in that they are not part of the chronological blog stream, kind of like permanent posts. Pages are not categorized or tagged, but can have a hierarchy. You can nest pages under other pages by making one the &#8220;Parent&#8221; of the other, creating a group of pages.' ) . '</p>',
)
);
get_current_screen()->add_help_tab(
array(
'id' => 'managing-pages',
'title' => __( 'Managing Pages' ),
'content' =>
'<p>' . __( 'Managing pages is very similar to managing posts, and the screens can be customized in the same way.' ) . '</p>' .
'<p>' . __('You can also perform the same types of actions, including narrowing the list by using the filters, acting on a page using the action links that appear when you hover over a row, or using the Bulk Actions menu to edit the metadata for multiple pages at once.') . '</p>'
) );
'<p>' . __( 'You can also perform the same types of actions, including narrowing the list by using the filters, acting on a page using the action links that appear when you hover over a row, or using the Bulk Actions menu to edit the metadata for multiple pages at once.' ) . '</p>',
)
);
get_current_screen()->set_help_sidebar(
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
@ -252,13 +281,20 @@ if ( 'post' == $post_type ) {
}
get_current_screen()->set_screen_reader_content( array(
get_current_screen()->set_screen_reader_content(
array(
'heading_views' => $post_type_object->labels->filter_items_list,
'heading_pagination' => $post_type_object->labels->items_list_navigation,
'heading_list' => $post_type_object->labels->items_list,
) );
)
);
add_screen_option( 'per_page', array( 'default' => 20, 'option' => 'edit_' . $post_type . '_per_page' ) );
add_screen_option(
'per_page', array(
'default' => 20,
'option' => 'edit_' . $post_type . '_per_page',
)
);
$bulk_counts = array(
'updated' => isset( $_REQUEST['updated'] ) ? absint( $_REQUEST['updated'] ) : 0,
@ -303,9 +339,11 @@ $bulk_counts = array_filter( $bulk_counts );
require_once( ABSPATH . 'wp-admin/admin-header.php' );
?>
<div class="wrap">
<h1 class="wp-heading-inline"><?php
<h1 class="wp-heading-inline">
<?php
echo esc_html( $post_type_object->labels->name );
?></h1>
?>
</h1>
<?php
if ( current_user_can( $post_type_object->cap->create_posts ) ) {
@ -324,19 +362,21 @@ if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) {
// If we have a bulk message to issue:
$messages = array();
foreach ( $bulk_counts as $message => $count ) {
if ( isset( $bulk_messages[ $post_type ][ $message ] ) )
if ( isset( $bulk_messages[ $post_type ][ $message ] ) ) {
$messages[] = sprintf( $bulk_messages[ $post_type ][ $message ], number_format_i18n( $count ) );
elseif ( isset( $bulk_messages['post'][ $message ] ) )
} elseif ( isset( $bulk_messages['post'][ $message ] ) ) {
$messages[] = sprintf( $bulk_messages['post'][ $message ], number_format_i18n( $count ) );
}
if ( $message == 'trashed' && isset( $_REQUEST['ids'] ) ) {
$ids = preg_replace( '/[^0-9,]/', '', $_REQUEST['ids'] );
$messages[] = '<a href="' . esc_url( wp_nonce_url( "edit.php?post_type=$post_type&doaction=undo&action=untrash&ids=$ids", "bulk-posts" ) ) . '">' . __('Undo') . '</a>';
$messages[] = '<a href="' . esc_url( wp_nonce_url( "edit.php?post_type=$post_type&doaction=undo&action=untrash&ids=$ids", 'bulk-posts' ) ) . '">' . __( 'Undo' ) . '</a>';
}
}
if ( $messages )
if ( $messages ) {
echo '<div id="message" class="updated notice is-dismissible"><p>' . join( ' ', $messages ) . '</p></div>';
}
unset( $messages );
$_SERVER['REQUEST_URI'] = remove_query_arg( array( 'locked', 'skipped', 'updated', 'deleted', 'trashed', 'untrashed' ), $_SERVER['REQUEST_URI'] );
@ -364,8 +404,9 @@ $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'locked', 'skipped', 'updated
</form>
<?php
if ( $wp_list_table->has_items() )
if ( $wp_list_table->has_items() ) {
$wp_list_table->inline_edit();
}
?>
<div id="ajax-response"></div>

View File

@ -9,8 +9,9 @@
/** Load WordPress Bootstrap */
require_once( dirname( __FILE__ ) . '/admin.php' );
if ( !current_user_can('export') )
if ( ! current_user_can( 'export' ) ) {
wp_die( __( 'Sorry, you are not allowed to export the content of this site.' ) );
}
/** Load WordPress export API */
require_once( ABSPATH . 'wp-admin/includes/export.php' );
@ -42,12 +43,14 @@ function export_add_js() {
}
add_action( 'admin_head', 'export_add_js' );
get_current_screen()->add_help_tab( array(
get_current_screen()->add_help_tab(
array(
'id' => 'overview',
'title' => __( 'Overview' ),
'content' => '<p>' . __( 'You can export a file of your site&#8217;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.' ) . '</p>' .
'<p>' . __( 'Once generated, your WXR file can be imported by another WordPress site or by another blogging platform able to access this format.' ) . '</p>',
) );
)
);
get_current_screen()->set_help_sidebar(
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
@ -64,32 +67,37 @@ if ( isset( $_GET['download'] ) ) {
} elseif ( 'posts' == $_GET['content'] ) {
$args['content'] = 'post';
if ( $_GET['cat'] )
if ( $_GET['cat'] ) {
$args['category'] = (int) $_GET['cat'];
}
if ( $_GET['post_author'] )
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'] )
if ( $_GET['post_status'] ) {
$args['status'] = $_GET['post_status'];
}
} elseif ( 'pages' == $_GET['content'] ) {
$args['content'] = 'page';
if ( $_GET['page_author'] )
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'] )
if ( $_GET['page_status'] ) {
$args['status'] = $_GET['page_status'];
}
} elseif ( 'attachment' == $_GET['content'] ) {
$args['content'] = 'attachment';
@ -97,8 +105,7 @@ if ( isset( $_GET['download'] ) ) {
$args['start_date'] = $_GET['attachment_start_date'];
$args['end_date'] = $_GET['attachment_end_date'];
}
}
else {
} else {
$args['content'] = $_GET['content'];
}
@ -130,20 +137,26 @@ require_once( ABSPATH . 'wp-admin/admin-header.php' );
function export_date_options( $post_type = 'post' ) {
global $wpdb, $wp_locale;
$months = $wpdb->get_results( $wpdb->prepare( "
$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 ) );
", $post_type
)
);
$month_count = count( $months );
if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) )
if ( ! $month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) {
return;
}
foreach ( $months as $date ) {
if ( 0 == $date->year )
if ( 0 == $date->year ) {
continue;
}
$month = zeroise( $date->month, 2 );
echo '<option value="' . $date->year . '-' . $month . '">' . $wp_locale->get_month( $month ) . ' ' . $date->year . '</option>';
@ -177,13 +190,16 @@ function export_date_options( $post_type = 'post' ) {
<label><span class="label-responsive"><?php _e( 'Authors:' ); ?></span>
<?php
$authors = $wpdb->get_col( "SELECT DISTINCT post_author FROM {$wpdb->posts} WHERE post_type = 'post'" );
wp_dropdown_users( array(
wp_dropdown_users(
array(
'include' => $authors,
'name' => 'post_author',
'multi' => true,
'show_option_all' => __( 'All' ),
'show' => 'display_name_with_login',
) ); ?>
)
);
?>
</label>
</li>
<li>
@ -205,8 +221,10 @@ function export_date_options( $post_type = 'post' ) {
<label for="post-status" class="label-responsive"><?php _e( 'Status:' ); ?></label>
<select name="post_status" id="post-status">
<option value="0"><?php _e( 'All' ); ?></option>
<?php $post_stati = get_post_stati( array( 'internal' => false ), 'objects' );
foreach ( $post_stati as $status ) : ?>
<?php
$post_stati = get_post_stati( array( 'internal' => false ), 'objects' );
foreach ( $post_stati as $status ) :
?>
<option value="<?php echo esc_attr( $status->name ); ?>"><?php echo esc_html( $status->label ); ?></option>
<?php endforeach; ?>
</select>
@ -219,13 +237,16 @@ function export_date_options( $post_type = 'post' ) {
<label><span class="label-responsive"><?php _e( 'Authors:' ); ?></span>
<?php
$authors = $wpdb->get_col( "SELECT DISTINCT post_author FROM {$wpdb->posts} WHERE post_type = 'page'" );
wp_dropdown_users( array(
wp_dropdown_users(
array(
'include' => $authors,
'name' => 'page_author',
'multi' => true,
'show_option_all' => __( 'All' ),
'show' => 'display_name_with_login',
) ); ?>
)
);
?>
</label>
</li>
<li>
@ -254,7 +275,14 @@ function export_date_options( $post_type = 'post' ) {
</li>
</ul>
<?php foreach ( get_post_types( array( '_builtin' => false, 'can_export' => true ), 'objects' ) as $post_type ) : ?>
<?php
foreach ( get_post_types(
array(
'_builtin' => false,
'can_export' => true,
), 'objects'
) as $post_type ) :
?>
<p><label><input type="radio" name="content" value="<?php echo esc_attr( $post_type->name ); ?>" /> <?php echo esc_html( $post_type->label ); ?></label></p>
<?php endforeach; ?>

View File

@ -42,12 +42,15 @@ include( ABSPATH . 'wp-admin/admin-header.php' );
<p><?php printf( __( 'WordPress grows when people like you tell their friends about it, and the thousands of businesses and services that are built on and around WordPress share that fact with their users. We&#8217;re flattered every time someone spreads the good word, just make sure to <a href="%s">check out our trademark guidelines</a> first.' ), 'https://wordpressfoundation.org/trademark-policy/' ); ?></p>
<p><?php
<p>
<?php
$plugins_url = current_user_can( 'activate_plugins' ) ? admin_url( 'plugins.php' ) : __( 'https://wordpress.org/plugins/' );
$themes_url = current_user_can( 'switch_themes' ) ? admin_url( 'themes.php' ) : __( 'https://wordpress.org/themes/' );
printf( __( 'Every plugin and theme in WordPress.org&#8217;s directory is 100%% GPL or a similarly free and compatible license, so you can feel safe finding <a href="%1$s">plugins</a> and <a href="%2$s">themes</a> there. If you get a plugin or theme from another source, make sure to <a href="%3$s">ask them if it&#8217;s GPL</a> first. If they don&#8217;t respect the WordPress license, we don&#8217;t recommend them.' ), $plugins_url, $themes_url, 'https://wordpress.org/about/license/' ); ?></p>
printf( __( 'Every plugin and theme in WordPress.org&#8217;s directory is 100%% GPL or a similarly free and compatible license, so you can feel safe finding <a href="%1$s">plugins</a> and <a href="%2$s">themes</a> there. If you get a plugin or theme from another source, make sure to <a href="%3$s">ask them if it&#8217;s GPL</a> first. If they don&#8217;t respect the WordPress license, we don&#8217;t recommend them.' ), $plugins_url, $themes_url, 'https://wordpress.org/about/license/' );
?>
</p>
<p><?php _e( 'Don&#8217;t you wish all software came with these freedoms? So do we! For more information, check out the <a href="https://www.fsf.org/">Free Software Foundation</a>.' ); ?></p>
</div>

View File

@ -17,12 +17,14 @@ if ( ! current_user_can( 'import' ) ) {
$title = __( 'Import' );
get_current_screen()->add_help_tab( array(
get_current_screen()->add_help_tab(
array(
'id' => 'overview',
'title' => __( 'Overview' ),
'content' => '<p>' . __( 'This screen lists links to plugins to import data from blogging/content management platforms. Choose the platform you want to import from, and click Install Now when you are prompted in the popup window. If your platform is not listed, click the link to search the plugin directory for other importer plugins to see if there is one for your platform.' ) . '</p>' .
'<p>' . __( 'In previous versions of WordPress, all importers were built-in. They have been turned into plugins since most people only use them once or infrequently.' ) . '</p>',
) );
)
);
get_current_screen()->set_help_sidebar(
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
@ -59,10 +61,12 @@ $parent_file = 'tools.php';
<h1><?php echo esc_html( $title ); ?></h1>
<?php if ( ! empty( $_GET['invalid'] ) ) : ?>
<div class="error">
<p><strong><?php _e( 'ERROR:' ); ?></strong> <?php
<p><strong><?php _e( 'ERROR:' ); ?></strong>
<?php
/* translators: %s: importer slug */
printf( __( 'The %s importer is invalid or is not installed.' ), '<strong>' . esc_html( $_GET['invalid'] ) . '</strong>' );
?></p>
?>
</p>
</div>
<?php endif; ?>
<p><?php _e( 'If you have posts or comments in another system, WordPress can import those into this site. To get started, choose a system to import from below:' ); ?></p>
@ -73,13 +77,19 @@ $importers = get_importers();
// If a popular importer is not registered, create a dummy registration that links to the plugin installer.
foreach ( $popular_importers as $pop_importer => $pop_data ) {
if ( isset( $importers[ $pop_importer ] ) )
if ( isset( $importers[ $pop_importer ] ) ) {
continue;
if ( isset( $importers[ $pop_data['importer-id'] ] ) )
}
if ( isset( $importers[ $pop_data['importer-id'] ] ) ) {
continue;
}
// Fill the array of registered (already installed) importers with data of the popular importers from the WordPress.org API.
$importers[ $pop_data['importer-id'] ] = array( $pop_data['name'], $pop_data['description'], 'install' => $pop_data['plugin-slug'] );
$importers[ $pop_data['importer-id'] ] = array(
$pop_data['name'],
$pop_data['description'],
'install' => $pop_data['plugin-slug'],
);
}
if ( empty( $importers ) ) {
@ -103,11 +113,15 @@ if ( empty( $importers ) ) {
if ( ! empty( $plugins ) ) {
$keys = array_keys( $plugins );
$plugin_file = $plugin_slug . '/' . $keys[0];
$url = wp_nonce_url( add_query_arg( array(
$url = wp_nonce_url(
add_query_arg(
array(
'action' => 'activate',
'plugin' => $plugin_file,
'from' => 'import',
), admin_url( 'plugins.php' ) ), 'activate-plugin_' . $plugin_file );
), admin_url( 'plugins.php' )
), 'activate-plugin_' . $plugin_file
);
$action = sprintf(
'<a href="%s" aria-label="%s">%s</a>',
esc_url( $url ),
@ -122,11 +136,15 @@ if ( empty( $importers ) ) {
if ( empty( $action ) ) {
if ( is_main_site() ) {
$url = wp_nonce_url( add_query_arg( array(
$url = wp_nonce_url(
add_query_arg(
array(
'action' => 'install-plugin',
'plugin' => $plugin_slug,
'from' => 'import',
), self_admin_url( 'update.php' ) ), 'install-plugin_' . $plugin_slug );
), self_admin_url( 'update.php' )
), 'install-plugin_' . $plugin_slug
);
$action = sprintf(
'<a href="%1$s" class="install-now" data-slug="%2$s" data-name="%3$s" aria-label="%4$s">%5$s</a>',
esc_url( $url ),
@ -145,9 +163,11 @@ if ( empty( $importers ) ) {
}
}
} else {
$url = add_query_arg( array(
$url = add_query_arg(
array(
'import' => $importer_id,
), self_admin_url( 'admin.php' ) );
), self_admin_url( 'admin.php' )
);
$action = sprintf(
'<a href="%1$s" aria-label="%2$s">%3$s</a>',
esc_url( $url ),
@ -160,14 +180,16 @@ if ( empty( $importers ) ) {
}
if ( ! $is_plugin_installed && is_main_site() ) {
$url = add_query_arg( array(
$url = add_query_arg(
array(
'tab' => 'plugin-information',
'plugin' => $plugin_slug,
'from' => 'import',
'TB_iframe' => 'true',
'width' => 600,
'height' => 550,
), network_admin_url( 'plugin-install.php' ) );
), network_admin_url( 'plugin-install.php' )
);
$action .= sprintf(
' | <a href="%1$s" class="thickbox open-plugin-details-modal" aria-label="%2$s">%3$s</a>',
esc_url( $url ),
@ -193,8 +215,9 @@ if ( empty( $importers ) ) {
<?php
}
if ( current_user_can('install_plugins') )
if ( current_user_can( 'install_plugins' ) ) {
echo '<p>' . sprintf( __( 'If the importer you need is not listed, <a href="%s">search the plugin directory</a> to see if an importer is available.' ), esc_url( network_admin_url( 'plugin-install.php?tab=search&type=tag&s=importer' ) ) ) . '</p>';
}
?>
</div>

File diff suppressed because it is too large Load Diff

View File

@ -39,8 +39,9 @@ function edit_link( $link_id = 0 ) {
$_POST['link_name'] = esc_html( $_POST['link_name'] );
$_POST['link_image'] = esc_html( $_POST['link_image'] );
$_POST['link_rss'] = esc_url( $_POST['link_rss'] );
if ( !isset($_POST['link_visible']) || 'N' != $_POST['link_visible'] )
if ( ! isset( $_POST['link_visible'] ) || 'N' != $_POST['link_visible'] ) {
$_POST['link_visible'] = 'Y';
}
if ( ! empty( $link_id ) ) {
$_POST['link_id'] = $link_id;
@ -59,15 +60,17 @@ function edit_link( $link_id = 0 ) {
*/
function get_default_link_to_edit() {
$link = new stdClass;
if ( isset( $_GET['linkurl'] ) )
if ( isset( $_GET['linkurl'] ) ) {
$link->link_url = esc_url( wp_unslash( $_GET['linkurl'] ) );
else
} else {
$link->link_url = '';
}
if ( isset( $_GET['name'] ) )
if ( isset( $_GET['name'] ) ) {
$link->link_name = esc_attr( wp_unslash( $_GET['name'] ) );
else
} else {
$link->link_name = '';
}
$link->link_visible = 'Y';
@ -152,7 +155,12 @@ function get_link_to_edit( $link ) {
function wp_insert_link( $linkdata, $wp_error = false ) {
global $wpdb;
$defaults = array( 'link_id' => 0, 'link_name' => '', 'link_url' => '', 'link_rating' => 0 );
$defaults = array(
'link_id' => 0,
'link_name' => '',
'link_url' => '',
'link_rating' => 0,
);
$args = wp_parse_args( $linkdata, $defaults );
$r = wp_unslash( sanitize_bookmark( $args, 'db' ) );
@ -249,8 +257,9 @@ function wp_insert_link( $linkdata, $wp_error = false ) {
*/
function wp_set_link_cats( $link_id = 0, $link_categories = array() ) {
// If $link_categories isn't already an array, make it one:
if ( !is_array( $link_categories ) || 0 == count( $link_categories ) )
if ( ! is_array( $link_categories ) || 0 == count( $link_categories ) ) {
$link_categories = array( get_option( 'default_link_category' ) );
}
$link_categories = array_map( 'intval', $link_categories );
$link_categories = array_unique( $link_categories );
@ -277,10 +286,11 @@ function wp_update_link( $linkdata ) {
$link = wp_slash( $link );
// Passed link category list overwrites existing category list if not empty.
if ( isset( $linkdata['link_category'] ) && is_array( $linkdata['link_category'] ) && 0 != count( $linkdata['link_category'] ) )
if ( isset( $linkdata['link_category'] ) && is_array( $linkdata['link_category'] ) && 0 != count( $linkdata['link_category'] ) ) {
$link_cats = $linkdata['link_category'];
else
} else {
$link_cats = $link['link_category'];
}
// Merge old and new fields with new fields overwriting old ones.
$linkdata = array_merge( $link, $linkdata );
@ -299,8 +309,9 @@ function wp_update_link( $linkdata ) {
*/
function wp_link_manager_disabled_message() {
global $pagenow;
if ( 'link-manager.php' != $pagenow && 'link-add.php' != $pagenow && 'link.php' != $pagenow )
if ( 'link-manager.php' != $pagenow && 'link-add.php' != $pagenow && 'link.php' != $pagenow ) {
return;
}
add_filter( 'pre_option_link_manager_enabled', '__return_true', 100 );
$really_can_manage_links = current_user_can( 'manage_links' );

View File

@ -50,7 +50,6 @@ class Automatic_Upgrader_Skin extends WP_Upgrader_Skin {
}
/**
*
* @return array
*/
public function get_upgrade_messages() {
@ -58,7 +57,6 @@ class Automatic_Upgrader_Skin extends WP_Upgrader_Skin {
}
/**
*
* @param string|array|WP_Error $data
*/
public function feedback( $data ) {
@ -69,30 +67,35 @@ class Automatic_Upgrader_Skin extends WP_Upgrader_Skin {
} else {
$string = $data;
}
if ( ! empty( $this->upgrader->strings[ $string ] ) )
if ( ! empty( $this->upgrader->strings[ $string ] ) ) {
$string = $this->upgrader->strings[ $string ];
}
if ( strpos( $string, '%' ) !== false ) {
$args = func_get_args();
$args = array_splice( $args, 1 );
if ( ! empty( $args ) )
if ( ! empty( $args ) ) {
$string = vsprintf( $string, $args );
}
}
$string = trim( $string );
// Only allow basic HTML in the messages, as it'll be used in emails/logs rather than direct browser output.
$string = wp_kses( $string, array(
$string = wp_kses(
$string, array(
'a' => array(
'href' => true
'href' => true,
),
'br' => true,
'em' => true,
'strong' => true,
) );
)
);
if ( empty( $string ) )
if ( empty( $string ) ) {
return;
}
$this->messages[] = $string;
}
@ -107,7 +110,8 @@ class Automatic_Upgrader_Skin extends WP_Upgrader_Skin {
*/
public function footer() {
$output = ob_get_clean();
if ( ! empty( $output ) )
if ( ! empty( $output ) ) {
$this->feedback( $output );
}
}
}

View File

@ -24,7 +24,6 @@ class Bulk_Plugin_Upgrader_Skin extends Bulk_Upgrader_Skin {
}
/**
*
* @param string $title
*/
public function before( $title = '' ) {
@ -32,7 +31,6 @@ class Bulk_Plugin_Upgrader_Skin extends Bulk_Upgrader_Skin {
}
/**
*
* @param string $title
*/
public function after( $title = '' ) {
@ -46,10 +44,11 @@ class Bulk_Plugin_Upgrader_Skin extends Bulk_Upgrader_Skin {
parent::bulk_footer();
$update_actions = array(
'plugins_page' => '<a href="' . self_admin_url( 'plugins.php' ) . '" target="_parent">' . __( 'Return to Plugins page' ) . '</a>',
'updates_page' => '<a href="' . self_admin_url( 'update-core.php' ) . '" target="_parent">' . __( 'Return to WordPress Updates page' ) . '</a>'
'updates_page' => '<a href="' . self_admin_url( 'update-core.php' ) . '" target="_parent">' . __( 'Return to WordPress Updates page' ) . '</a>',
);
if ( ! current_user_can( 'activate_plugins' ) )
if ( ! current_user_can( 'activate_plugins' ) ) {
unset( $update_actions['plugins_page'] );
}
/**
* Filters the list of action links available following bulk plugin updates.
@ -61,7 +60,8 @@ class Bulk_Plugin_Upgrader_Skin extends Bulk_Upgrader_Skin {
*/
$update_actions = apply_filters( 'update_bulk_plugins_complete_actions', $update_actions, $this->plugin_info );
if ( ! empty($update_actions) )
if ( ! empty( $update_actions ) ) {
$this->feedback( implode( ' | ', (array) $update_actions ) );
}
}
}

View File

@ -24,7 +24,6 @@ class Bulk_Theme_Upgrader_Skin extends Bulk_Upgrader_Skin {
}
/**
*
* @param string $title
*/
public function before( $title = '' ) {
@ -32,7 +31,6 @@ class Bulk_Theme_Upgrader_Skin extends Bulk_Upgrader_Skin {
}
/**
*
* @param string $title
*/
public function after( $title = '' ) {
@ -46,10 +44,11 @@ class Bulk_Theme_Upgrader_Skin extends Bulk_Upgrader_Skin {
parent::bulk_footer();
$update_actions = array(
'themes_page' => '<a href="' . self_admin_url( 'themes.php' ) . '" target="_parent">' . __( 'Return to Themes page' ) . '</a>',
'updates_page' => '<a href="' . self_admin_url( 'update-core.php' ) . '" target="_parent">' . __( 'Return to WordPress Updates page' ) . '</a>'
'updates_page' => '<a href="' . self_admin_url( 'update-core.php' ) . '" target="_parent">' . __( 'Return to WordPress Updates page' ) . '</a>',
);
if ( ! current_user_can( 'switch_themes' ) && ! current_user_can( 'edit_theme_options' ) )
if ( ! current_user_can( 'switch_themes' ) && ! current_user_can( 'edit_theme_options' ) ) {
unset( $update_actions['themes_page'] );
}
/**
* Filters the list of action links available following bulk theme updates.
@ -61,7 +60,8 @@ class Bulk_Theme_Upgrader_Skin extends Bulk_Upgrader_Skin {
*/
$update_actions = apply_filters( 'update_bulk_theme_complete_actions', $update_actions, $this->theme_info );
if ( ! empty($update_actions) )
if ( ! empty( $update_actions ) ) {
$this->feedback( implode( ' | ', (array) $update_actions ) );
}
}
}

View File

@ -23,11 +23,13 @@ class Bulk_Upgrader_Skin extends WP_Upgrader_Skin {
public $error = false;
/**
*
* @param array $args
*/
public function __construct( $args = array() ) {
$defaults = array( 'url' => '', 'nonce' => '' );
$defaults = array(
'url' => '',
'nonce' => '',
);
$args = wp_parse_args( $args, $defaults );
parent::__construct( $args );
@ -47,12 +49,12 @@ class Bulk_Upgrader_Skin extends WP_Upgrader_Skin {
}
/**
*
* @param string $string
*/
public function feedback( $string ) {
if ( isset( $this->upgrader->strings[$string] ) )
if ( isset( $this->upgrader->strings[ $string ] ) ) {
$string = $this->upgrader->strings[ $string ];
}
if ( strpos( $string, '%' ) !== false ) {
$args = func_get_args();
@ -63,13 +65,15 @@ class Bulk_Upgrader_Skin extends WP_Upgrader_Skin {
$string = vsprintf( $string, $args );
}
}
if ( empty($string) )
if ( empty( $string ) ) {
return;
if ( $this->in_loop )
}
if ( $this->in_loop ) {
echo "$string<br />\n";
else
} else {
echo "<p>$string</p>\n";
}
}
/**
*/
@ -84,21 +88,22 @@ class Bulk_Upgrader_Skin extends WP_Upgrader_Skin {
}
/**
*
* @param string|WP_Error $error
*/
public function error( $error ) {
if ( is_string($error) && isset( $this->upgrader->strings[$error] ) )
if ( is_string( $error ) && isset( $this->upgrader->strings[ $error ] ) ) {
$this->error = $this->upgrader->strings[ $error ];
}
if ( is_wp_error( $error ) ) {
$messages = array();
foreach ( $error->get_error_messages() as $emessage ) {
if ( $error->get_error_data() && is_string( $error->get_error_data() ) )
if ( $error->get_error_data() && is_string( $error->get_error_data() ) ) {
$messages[] = $emessage . ' ' . esc_html( strip_tags( $error->get_error_data() ) );
else
} else {
$messages[] = $emessage;
}
}
$this->error = implode( ', ', $messages );
}
echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js( $this->upgrader->update_current ) . '\').hide();</script>';
@ -117,7 +122,6 @@ class Bulk_Upgrader_Skin extends WP_Upgrader_Skin {
}
/**
*
* @param string $title
*/
public function before( $title = '' ) {
@ -130,7 +134,6 @@ class Bulk_Upgrader_Skin extends WP_Upgrader_Skin {
}
/**
*
* @param string $title
*/
public function after( $title = '' ) {

View File

@ -78,8 +78,9 @@ class Core_Upgrader extends WP_Upgrader {
$this->upgrade_strings();
// Is an update available?
if ( !isset( $current->response ) || $current->response == 'latest' )
if ( ! isset( $current->response ) || $current->response == 'latest' ) {
return new WP_Error( 'up_to_date', $this->strings['up_to_date'] );
}
$res = $this->fs_connect( array( ABSPATH, WP_CONTENT_DIR ), $parsed_args['allow_relaxed_file_ownership'] );
if ( ! $res || is_wp_error( $res ) ) {
@ -89,10 +90,11 @@ class Core_Upgrader extends WP_Upgrader {
$wp_dir = trailingslashit( $wp_filesystem->abspath() );
$partial = true;
if ( $parsed_args['do_rollback'] )
if ( $parsed_args['do_rollback'] ) {
$partial = false;
elseif ( $parsed_args['pre_check_md5'] && ! $this->check_files() )
} elseif ( $parsed_args['pre_check_md5'] && ! $this->check_files() ) {
$partial = false;
}
/*
* If partial update is returned from the API, use that, unless we're doing
@ -100,17 +102,18 @@ class Core_Upgrader extends WP_Upgrader {
* the new_bundled zip. Don't though if the constant is set to skip bundled items.
* If the API returns a no_content zip, go with it. Finally, default to the full zip.
*/
if ( $parsed_args['do_rollback'] && $current->packages->rollback )
if ( $parsed_args['do_rollback'] && $current->packages->rollback ) {
$to_download = 'rollback';
elseif ( $current->packages->partial && 'reinstall' != $current->response && $wp_version == $current->partial_version && $partial )
} elseif ( $current->packages->partial && 'reinstall' != $current->response && $wp_version == $current->partial_version && $partial ) {
$to_download = 'partial';
elseif ( $current->packages->new_bundled && version_compare( $wp_version, $current->new_bundled, '<' )
&& ( ! defined( 'CORE_UPGRADE_SKIP_NEW_BUNDLED' ) || ! CORE_UPGRADE_SKIP_NEW_BUNDLED ) )
} elseif ( $current->packages->new_bundled && version_compare( $wp_version, $current->new_bundled, '<' )
&& ( ! defined( 'CORE_UPGRADE_SKIP_NEW_BUNDLED' ) || ! CORE_UPGRADE_SKIP_NEW_BUNDLED ) ) {
$to_download = 'new_bundled';
elseif ( $current->packages->no_content )
} elseif ( $current->packages->no_content ) {
$to_download = 'no_content';
else
} else {
$to_download = 'full';
}
// Lock to prevent multiple Core Updates occurring
$lock = WP_Upgrader::create_lock( 'core_updater', 15 * MINUTE_IN_SECONDS );
@ -157,13 +160,14 @@ class Core_Upgrader extends WP_Upgrader {
* mkdir_failed__copy_dir, copy_failed__copy_dir_retry, and disk_full.
* do_rollback allows for update_core() to trigger a rollback if needed.
*/
if ( false !== strpos( $error_code, 'do_rollback' ) )
if ( false !== strpos( $error_code, 'do_rollback' ) ) {
$try_rollback = true;
elseif ( false !== strpos( $error_code, '__copy_dir' ) )
} elseif ( false !== strpos( $error_code, '__copy_dir' ) ) {
$try_rollback = true;
elseif ( 'disk_full' === $error_code )
} elseif ( 'disk_full' === $error_code ) {
$try_rollback = true;
}
}
if ( $try_rollback ) {
/** This filter is documented in wp-admin/includes/update-core.php */
@ -175,12 +179,22 @@ class Core_Upgrader extends WP_Upgrader {
$rollback_result = $this->upgrade( $current, array_merge( $parsed_args, array( 'do_rollback' => true ) ) );
$original_result = $result;
$result = new WP_Error( 'rollback_was_required', $this->strings['rollback_was_required'], (object) array( 'update' => $original_result, 'rollback' => $rollback_result ) );
$result = new WP_Error(
'rollback_was_required', $this->strings['rollback_was_required'], (object) array(
'update' => $original_result,
'rollback' => $rollback_result,
)
);
}
}
/** This action is documented in wp-admin/includes/class-wp-upgrader.php */
do_action( 'upgrader_process_complete', $this, array( 'action' => 'update', 'type' => 'core' ) );
do_action(
'upgrader_process_complete', $this, array(
'action' => 'update',
'type' => 'core',
)
);
// Clear the current updates
delete_site_transient( 'update_core' );
@ -261,29 +275,34 @@ class Core_Upgrader extends WP_Upgrader {
}
// 1: If we're already on that version, not much point in updating?
if ( $offered_ver == $wp_version )
if ( $offered_ver == $wp_version ) {
return false;
}
// 2: If we're running a newer version, that's a nope
if ( version_compare( $wp_version, $offered_ver, '>' ) )
if ( version_compare( $wp_version, $offered_ver, '>' ) ) {
return false;
}
$failure_data = get_site_option( 'auto_core_update_failed' );
if ( $failure_data ) {
// If this was a critical update failure, cannot update.
if ( ! empty( $failure_data['critical'] ) )
if ( ! empty( $failure_data['critical'] ) ) {
return false;
}
// Don't claim we can update on update-core.php if we have a non-critical failure logged.
if ( $wp_version == $failure_data['current'] && false !== strpos( $offered_ver, '.1.next.minor' ) )
if ( $wp_version == $failure_data['current'] && false !== strpos( $offered_ver, '.1.next.minor' ) ) {
return false;
}
// Cannot update if we're retrying the same A to B update that caused a non-critical failure.
// Some non-critical failures do allow retries, like download_failed.
// 3.7.1 => 3.7.2 resulted in files_not_writable, if we are still on 3.7.1 and still trying to update to 3.7.2.
if ( empty( $failure_data['retry'] ) && $wp_version == $failure_data['current'] && $offered_ver == $failure_data['attempted'] )
if ( empty( $failure_data['retry'] ) && $wp_version == $failure_data['current'] && $offered_ver == $failure_data['attempted'] ) {
return false;
}
}
// 3: 3.7-alpha-25000 -> 3.7-alpha-25678 -> 3.7-beta1 -> 3.7-beta2
if ( $current_is_development_version ) {
@ -296,8 +315,9 @@ class Core_Upgrader extends WP_Upgrader {
* @param bool $upgrade_dev Whether to enable automatic updates for
* development versions.
*/
if ( ! apply_filters( 'allow_dev_auto_core_updates', $upgrade_dev ) )
if ( ! apply_filters( 'allow_dev_auto_core_updates', $upgrade_dev ) ) {
return false;
}
// Else fall through to minor + major branches below.
}
@ -346,16 +366,19 @@ class Core_Upgrader extends WP_Upgrader {
$checksums = get_core_checksums( $wp_version, isset( $wp_local_package ) ? $wp_local_package : 'en_US' );
if ( ! is_array( $checksums ) )
if ( ! is_array( $checksums ) ) {
return false;
}
foreach ( $checksums as $file => $checksum ) {
// Skip files which get updated
if ( 'wp-content' == substr( $file, 0, 10 ) )
if ( 'wp-content' == substr( $file, 0, 10 ) ) {
continue;
if ( ! file_exists( ABSPATH . $file ) || md5_file( ABSPATH . $file ) !== $checksum )
}
if ( ! file_exists( ABSPATH . $file ) || md5_file( ABSPATH . $file ) !== $checksum ) {
return false;
}
}
return true;
}

View File

@ -52,16 +52,21 @@ class File_Upload_Upgrader {
*/
public function __construct( $form, $urlholder ) {
if ( empty($_FILES[$form]['name']) && empty($_GET[$urlholder]) )
if ( empty( $_FILES[ $form ]['name'] ) && empty( $_GET[ $urlholder ] ) ) {
wp_die( __( 'Please select a file' ) );
}
//Handle a newly uploaded file, Else assume it's already been uploaded
if ( ! empty( $_FILES ) ) {
$overrides = array( 'test_form' => false, 'test_type' => false );
$overrides = array(
'test_form' => false,
'test_type' => false,
);
$file = wp_handle_upload( $_FILES[ $form ], $overrides );
if ( isset( $file['error'] ) )
if ( isset( $file['error'] ) ) {
wp_die( $file['error'] );
}
$this->filename = $_FILES[ $form ]['name'];
$this->package = $file['file'];
@ -73,7 +78,7 @@ class File_Upload_Upgrader {
'post_mime_type' => $file['type'],
'guid' => $file['url'],
'context' => 'upgrader',
'post_status' => 'private'
'post_status' => 'private',
);
// Save the data.
@ -86,15 +91,17 @@ class File_Upload_Upgrader {
// Numeric Package = previously uploaded file, see above.
$this->id = (int) $_GET[ $urlholder ];
$attachment = get_post( $this->id );
if ( empty($attachment) )
if ( empty( $attachment ) ) {
wp_die( __( 'Please select a file' ) );
}
$this->filename = $attachment->post_title;
$this->package = get_attached_file( $attachment->ID );
} else {
// Else, It's set to something, Back compat for plugins using the old (pre-3.3) File_Uploader handler.
if ( ! ( ( $uploads = wp_upload_dir() ) && false === $uploads['error'] ) )
if ( ! ( ( $uploads = wp_upload_dir() ) && false === $uploads['error'] ) ) {
wp_die( $uploads['error'] );
}
$this->filename = sanitize_file_name( $_GET[ $urlholder ] );
$this->package = $uploads['basedir'] . '/' . $this->filename;
@ -113,11 +120,12 @@ class File_Upload_Upgrader {
* @return bool Whether the cleanup was successful.
*/
public function cleanup() {
if ( $this->id )
if ( $this->id ) {
wp_delete_attachment( $this->id );
elseif ( file_exists( $this->package ) )
} elseif ( file_exists( $this->package ) ) {
return @unlink( $this->package );
}
return true;
}

View File

@ -22,11 +22,15 @@ class Language_Pack_Upgrader_Skin extends WP_Upgrader_Skin {
public $display_footer_actions = true;
/**
*
* @param array $args
*/
public function __construct( $args = array() ) {
$defaults = array( 'url' => '', 'nonce' => '', 'title' => __( 'Update Translations' ), 'skip_header_footer' => false );
$defaults = array(
'url' => '',
'nonce' => '',
'title' => __( 'Update Translations' ),
'skip_header_footer' => false,
);
$args = wp_parse_args( $args, $defaults );
if ( $args['skip_header_footer'] ) {
$this->done_header = true;
@ -47,7 +51,6 @@ class Language_Pack_Upgrader_Skin extends WP_Upgrader_Skin {
}
/**
*
* @param string|WP_Error $error
*/
public function error( $error ) {
@ -78,7 +81,8 @@ class Language_Pack_Upgrader_Skin extends WP_Upgrader_Skin {
*/
$update_actions = apply_filters( 'update_translations_complete_actions', $update_actions );
if ( $update_actions && $this->display_footer_actions )
if ( $update_actions && $this->display_footer_actions ) {
$this->feedback( implode( ' | ', $update_actions ) );
}
}
}

View File

@ -94,9 +94,11 @@ class Language_Pack_Upgrader extends WP_Upgrader {
if ( $upgrader && $upgrader->skin instanceof Automatic_Upgrader_Skin ) {
$skin = $upgrader->skin;
} else {
$skin = new Language_Pack_Upgrader_Skin( array(
$skin = new Language_Pack_Upgrader_Skin(
array(
'skip_header_footer' => true,
) );
)
);
}
$lp_upgrader = new Language_Pack_Upgrader( $skin );
@ -171,8 +173,9 @@ class Language_Pack_Upgrader extends WP_Upgrader {
$this->init();
$this->upgrade_strings();
if ( ! $language_updates )
if ( ! $language_updates ) {
$language_updates = wp_get_translation_updates();
}
if ( empty( $language_updates ) ) {
$this->skin->header();
@ -183,8 +186,9 @@ class Language_Pack_Upgrader extends WP_Upgrader {
return true;
}
if ( 'upgrader_process_complete' == current_filter() )
if ( 'upgrader_process_complete' == current_filter() ) {
$this->skin->feedback( 'starting_upgrade' );
}
// Remove any existing upgrade filters from the plugin/theme upgraders #WP29425 & #WP29230
remove_all_filters( 'upgrader_pre_install' );
@ -213,9 +217,11 @@ class Language_Pack_Upgrader extends WP_Upgrader {
* as we then may need to create a /plugins or /themes directory inside of it.
*/
$remote_destination = $wp_filesystem->find_folder( WP_LANG_DIR );
if ( ! $wp_filesystem->exists( $remote_destination ) )
if ( ! $wp_filesystem->mkdir( $remote_destination, FS_CHMOD_DIR ) )
if ( ! $wp_filesystem->exists( $remote_destination ) ) {
if ( ! $wp_filesystem->mkdir( $remote_destination, FS_CHMOD_DIR ) ) {
return new WP_Error( 'mkdir_failed_lang_dir', $this->strings['mkdir_failed'], $remote_destination );
}
}
$language_updates_results = array();
@ -224,10 +230,11 @@ class Language_Pack_Upgrader extends WP_Upgrader {
$this->skin->language_update = $language_update;
$destination = WP_LANG_DIR;
if ( 'plugin' == $language_update->type )
if ( 'plugin' == $language_update->type ) {
$destination .= '/plugins';
elseif ( 'theme' == $language_update->type )
} elseif ( 'theme' == $language_update->type ) {
$destination .= '/themes';
}
$this->update_current++;
@ -241,7 +248,7 @@ class Language_Pack_Upgrader extends WP_Upgrader {
'hook_extra' => array(
'language_update_type' => $language_update->type,
'language_update' => $language_update,
)
),
);
$result = $this->run( $options );
@ -268,12 +275,14 @@ class Language_Pack_Upgrader extends WP_Upgrader {
remove_action( 'upgrader_process_complete', 'wp_update_themes' );
/** This action is documented in wp-admin/includes/class-wp-upgrader.php */
do_action( 'upgrader_process_complete', $this, array(
do_action(
'upgrader_process_complete', $this, array(
'action' => 'update',
'type' => 'translation',
'bulk' => true,
'translations' => $language_updates_results
) );
'translations' => $language_updates_results,
)
);
// Re-add upgrade hooks.
add_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 );
@ -311,8 +320,9 @@ class Language_Pack_Upgrader extends WP_Upgrader {
public function check_package( $source, $remote_source ) {
global $wp_filesystem;
if ( is_wp_error( $source ) )
if ( is_wp_error( $source ) ) {
return $source;
}
// Check that the folder contains a valid language.
$files = $wp_filesystem->dirlist( $remote_source );
@ -320,16 +330,19 @@ class Language_Pack_Upgrader extends WP_Upgrader {
// Check to see if a .po and .mo exist in the folder.
$po = $mo = false;
foreach ( (array) $files as $file => $filedata ) {
if ( '.po' == substr( $file, -3 ) )
if ( '.po' == substr( $file, -3 ) ) {
$po = true;
elseif ( '.mo' == substr( $file, -3 ) )
} elseif ( '.mo' == substr( $file, -3 ) ) {
$mo = true;
}
}
if ( ! $mo || ! $po ) {
return new WP_Error( 'incompatible_archive_pomo', $this->strings['incompatible_archive'],
return new WP_Error(
'incompatible_archive_pomo', $this->strings['incompatible_archive'],
/* translators: 1: .po 2: .mo */
sprintf( __( 'The language pack is missing either the %1$s or %2$s files.' ),
sprintf(
__( 'The language pack is missing either the %1$s or %2$s files.' ),
'<code>.po</code>',
'<code>.mo</code>'
)
@ -354,14 +367,16 @@ class Language_Pack_Upgrader extends WP_Upgrader {
case 'theme':
$theme = wp_get_theme( $update->slug );
if ( $theme->exists() )
if ( $theme->exists() ) {
return $theme->Get( 'Name' );
}
break;
case 'plugin':
$plugin_data = get_plugins( '/' . $update->slug );
$plugin_data = reset( $plugin_data );
if ( $plugin_data )
if ( $plugin_data ) {
return $plugin_data['Name'];
}
break;
}
return '';

View File

@ -20,11 +20,16 @@ class Plugin_Installer_Skin extends WP_Upgrader_Skin {
public $type;
/**
*
* @param array $args
*/
public function __construct( $args = array() ) {
$defaults = array( 'type' => 'web', 'url' => '', 'plugin' => '', 'nonce' => '', 'title' => '' );
$defaults = array(
'type' => 'web',
'url' => '',
'plugin' => '',
'nonce' => '',
'title' => '',
);
$args = wp_parse_args( $args, $defaults );
$this->type = $args['type'];
@ -36,8 +41,9 @@ class Plugin_Installer_Skin extends WP_Upgrader_Skin {
/**
*/
public function before() {
if ( !empty($this->api) )
$this->upgrader->strings['process_success'] = sprintf( __('Successfully installed the plugin <strong>%s %s</strong>.'), $this->api->name, $this->api->version);
if ( ! empty( $this->api ) ) {
$this->upgrader->strings['process_success'] = sprintf( __( 'Successfully installed the plugin <strong>%1$s %2$s</strong>.' ), $this->api->name, $this->api->version );
}
}
/**

View File

@ -21,11 +21,15 @@ class Plugin_Upgrader_Skin extends WP_Upgrader_Skin {
public $plugin_network_active = false;
/**
*
* @param array $args
*/
public function __construct( $args = array() ) {
$defaults = array( 'url' => '', 'plugin' => '', 'nonce' => '', 'title' => __('Update Plugin') );
$defaults = array(
'url' => '',
'plugin' => '',
'nonce' => '',
'title' => __( 'Update Plugin' ),
);
$args = wp_parse_args( $args, $defaults );
$this->plugin = $args['plugin'];
@ -49,10 +53,11 @@ class Plugin_Upgrader_Skin extends WP_Upgrader_Skin {
$update_actions = array(
'activate_plugin' => '<a href="' . wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . urlencode( $this->plugin ), 'activate-plugin_' . $this->plugin ) . '" target="_parent">' . __( 'Activate Plugin' ) . '</a>',
'plugins_page' => '<a href="' . self_admin_url( 'plugins.php' ) . '" target="_parent">' . __( 'Return to Plugins page' ) . '</a>'
'plugins_page' => '<a href="' . self_admin_url( 'plugins.php' ) . '" target="_parent">' . __( 'Return to Plugins page' ) . '</a>',
);
if ( $this->plugin_active || ! $this->result || is_wp_error( $this->result ) || ! current_user_can( 'activate_plugin', $this->plugin ) )
if ( $this->plugin_active || ! $this->result || is_wp_error( $this->result ) || ! current_user_can( 'activate_plugin', $this->plugin ) ) {
unset( $update_actions['activate_plugin'] );
}
/**
* Filters the list of action links available following a single plugin update.
@ -64,7 +69,8 @@ class Plugin_Upgrader_Skin extends WP_Upgrader_Skin {
*/
$update_actions = apply_filters( 'update_plugin_complete_actions', $update_actions, $this->plugin );
if ( ! empty($update_actions) )
if ( ! empty( $update_actions ) ) {
$this->feedback( implode( ' | ', (array) $update_actions ) );
}
}
}

View File

@ -103,7 +103,8 @@ class Plugin_Upgrader extends WP_Upgrader {
add_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9, 0 );
}
$this->run( array(
$this->run(
array(
'package' => $package,
'destination' => WP_PLUGIN_DIR,
'clear_destination' => false, // Do not overwrite files.
@ -111,14 +112,16 @@ class Plugin_Upgrader extends WP_Upgrader {
'hook_extra' => array(
'type' => 'plugin',
'action' => 'install',
),
)
) );
);
remove_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9 );
remove_filter( 'upgrader_source_selection', array( $this, 'check_package' ) );
if ( ! $this->result || is_wp_error($this->result) )
if ( ! $this->result || is_wp_error( $this->result ) ) {
return $this->result;
}
// Force refresh of plugin update information
wp_clean_plugins_cache( $parsed_args['clear_update_cache'] );
@ -171,7 +174,8 @@ class Plugin_Upgrader extends WP_Upgrader {
add_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9, 0 );
}
$this->run( array(
$this->run(
array(
'package' => $r->package,
'destination' => WP_PLUGIN_DIR,
'clear_destination' => true,
@ -181,15 +185,17 @@ class Plugin_Upgrader extends WP_Upgrader {
'type' => 'plugin',
'action' => 'update',
),
) );
)
);
// Cleanup our hooks, in case something else does a upgrade on this connection.
remove_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9 );
remove_filter( 'upgrader_pre_install', array( $this, 'deactivate_plugin_before_upgrade' ) );
remove_filter( 'upgrader_clear_destination', array( $this, 'delete_old_plugin' ) );
if ( ! $this->result || is_wp_error($this->result) )
if ( ! $this->result || is_wp_error( $this->result ) ) {
return $this->result;
}
// Force refresh of plugin update information
wp_clean_plugins_cache( $parsed_args['clear_update_cache'] );
@ -245,10 +251,12 @@ class Plugin_Upgrader extends WP_Upgrader {
* @TODO: For multisite, maintenance mode should only kick in for individual sites if at all possible.
*/
$maintenance = ( is_multisite() && ! empty( $plugins ) );
foreach ( $plugins as $plugin )
foreach ( $plugins as $plugin ) {
$maintenance = $maintenance || ( is_plugin_active( $plugin ) && isset( $current->response[ $plugin ] ) );
if ( $maintenance )
}
if ( $maintenance ) {
$this->maintenance_mode( true );
}
$results = array();
@ -272,22 +280,25 @@ class Plugin_Upgrader extends WP_Upgrader {
$this->skin->plugin_active = is_plugin_active( $plugin );
$result = $this->run( array(
$result = $this->run(
array(
'package' => $r->package,
'destination' => WP_PLUGIN_DIR,
'clear_destination' => true,
'clear_working' => true,
'is_multi' => true,
'hook_extra' => array(
'plugin' => $plugin
'plugin' => $plugin,
),
)
) );
);
$results[ $plugin ] = $this->result;
// Prevent credentials auth screen from displaying multiple times
if ( false === $result )
if ( false === $result ) {
break;
}
} //end foreach $plugins
$this->maintenance_mode( false );
@ -296,12 +307,14 @@ class Plugin_Upgrader extends WP_Upgrader {
wp_clean_plugins_cache( $parsed_args['clear_update_cache'] );
/** This action is documented in wp-admin/includes/class-wp-upgrader.php */
do_action( 'upgrader_process_complete', $this, array(
do_action(
'upgrader_process_complete', $this, array(
'action' => 'update',
'type' => 'plugin',
'bulk' => true,
'plugins' => $plugins,
) );
)
);
$this->skin->bulk_footer();
@ -330,12 +343,14 @@ class Plugin_Upgrader extends WP_Upgrader {
public function check_package( $source ) {
global $wp_filesystem;
if ( is_wp_error($source) )
if ( is_wp_error( $source ) ) {
return $source;
}
$working_directory = str_replace( $wp_filesystem->wp_content_dir(), trailingslashit( WP_CONTENT_DIR ), $source );
if ( ! is_dir($working_directory) ) // Sanity check, if the above fails, let's not prevent installation.
if ( ! is_dir( $working_directory ) ) { // Sanity check, if the above fails, let's not prevent installation.
return $source;
}
// Check the folder contains at least 1 valid plugin.
$plugins_found = false;
@ -350,8 +365,9 @@ class Plugin_Upgrader extends WP_Upgrader {
}
}
if ( ! $plugins_found )
if ( ! $plugins_found ) {
return new WP_Error( 'incompatible_archive_no_plugins', $this->strings['incompatible_archive'], __( 'No valid plugins were found.' ) );
}
return $source;
}
@ -366,14 +382,17 @@ class Plugin_Upgrader extends WP_Upgrader {
* @return string|false The full path to the main plugin file, or false.
*/
public function plugin_info() {
if ( ! is_array($this->result) )
if ( ! is_array( $this->result ) ) {
return false;
if ( empty($this->result['destination_name']) )
}
if ( empty( $this->result['destination_name'] ) ) {
return false;
}
$plugin = get_plugins( '/' . $this->result['destination_name'] ); //Ensure to pass with leading slash
if ( empty($plugin) )
if ( empty( $plugin ) ) {
return false;
}
$pluginfiles = array_keys( $plugin ); //Assume the requested plugin is the first in the list
@ -394,16 +413,19 @@ class Plugin_Upgrader extends WP_Upgrader {
*/
public function deactivate_plugin_before_upgrade( $return, $plugin ) {
if ( is_wp_error($return) ) //Bypass.
if ( is_wp_error( $return ) ) { //Bypass.
return $return;
}
// When in cron (background updates) don't deactivate the plugin, as we require a browser to reactivate it
if ( wp_doing_cron() )
if ( wp_doing_cron() ) {
return $return;
}
$plugin = isset( $plugin['plugin'] ) ? $plugin['plugin'] : '';
if ( empty($plugin) )
if ( empty( $plugin ) ) {
return new WP_Error( 'bad_request', $this->strings['bad_request'] );
}
if ( is_plugin_active( $plugin ) ) {
//Deactivate the plugin silently, Prevent deactivation hooks from running.
@ -432,27 +454,32 @@ class Plugin_Upgrader extends WP_Upgrader {
public function delete_old_plugin( $removed, $local_destination, $remote_destination, $plugin ) {
global $wp_filesystem;
if ( is_wp_error($removed) )
if ( is_wp_error( $removed ) ) {
return $removed; //Pass errors through.
}
$plugin = isset( $plugin['plugin'] ) ? $plugin['plugin'] : '';
if ( empty($plugin) )
if ( empty( $plugin ) ) {
return new WP_Error( 'bad_request', $this->strings['bad_request'] );
}
$plugins_dir = $wp_filesystem->wp_plugins_dir();
$this_plugin_dir = trailingslashit( dirname( $plugins_dir . $plugin ) );
if ( ! $wp_filesystem->exists($this_plugin_dir) ) //If it's already vanished.
if ( ! $wp_filesystem->exists( $this_plugin_dir ) ) { //If it's already vanished.
return $removed;
}
// If plugin is in its own directory, recursively delete the directory.
if ( strpos($plugin, '/') && $this_plugin_dir != $plugins_dir ) //base check on if plugin includes directory separator AND that it's not the root plugin folder
if ( strpos( $plugin, '/' ) && $this_plugin_dir != $plugins_dir ) { //base check on if plugin includes directory separator AND that it's not the root plugin folder
$deleted = $wp_filesystem->delete( $this_plugin_dir, true );
else
} else {
$deleted = $wp_filesystem->delete( $plugins_dir . $plugin );
}
if ( ! $deleted )
if ( ! $deleted ) {
return new WP_Error( 'remove_old_failed', $this->strings['remove_old_failed'] );
}
return true;
}

View File

@ -20,11 +20,16 @@ class Theme_Installer_Skin extends WP_Upgrader_Skin {
public $type;
/**
*
* @param array $args
*/
public function __construct( $args = array() ) {
$defaults = array( 'type' => 'web', 'url' => '', 'theme' => '', 'nonce' => '', 'title' => '' );
$defaults = array(
'type' => 'web',
'url' => '',
'theme' => '',
'nonce' => '',
'title' => '',
);
$args = wp_parse_args( $args, $defaults );
$this->type = $args['type'];
@ -36,29 +41,34 @@ class Theme_Installer_Skin extends WP_Upgrader_Skin {
/**
*/
public function before() {
if ( !empty($this->api) )
if ( ! empty( $this->api ) ) {
$this->upgrader->strings['process_success'] = sprintf( $this->upgrader->strings['process_success_specific'], $this->api->name, $this->api->version );
}
}
/**
*/
public function after() {
if ( empty($this->upgrader->result['destination_name']) )
if ( empty( $this->upgrader->result['destination_name'] ) ) {
return;
}
$theme_info = $this->upgrader->theme_info();
if ( empty( $theme_info ) )
if ( empty( $theme_info ) ) {
return;
}
$name = $theme_info->display( 'Name' );
$stylesheet = $this->upgrader->result['destination_name'];
$template = $theme_info->get_template();
$activate_link = add_query_arg( array(
$activate_link = add_query_arg(
array(
'action' => 'activate',
'template' => urlencode( $template ),
'stylesheet' => urlencode( $stylesheet ),
), admin_url('themes.php') );
), admin_url( 'themes.php' )
);
$activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet );
$install_actions = array();
@ -75,16 +85,19 @@ class Theme_Installer_Skin extends WP_Upgrader_Skin {
}
$install_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink"><span aria-hidden="true">' . __( 'Activate' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Activate &#8220;%s&#8221;' ), $name ) . '</span></a>';
if ( is_network_admin() && current_user_can( 'manage_network_themes' ) )
if ( is_network_admin() && current_user_can( 'manage_network_themes' ) ) {
$install_actions['network_enable'] = '<a href="' . esc_url( wp_nonce_url( 'themes.php?action=enable&amp;theme=' . urlencode( $stylesheet ), 'enable-theme_' . $stylesheet ) ) . '" target="_parent">' . __( 'Network Enable' ) . '</a>';
}
if ( $this->type == 'web' )
if ( $this->type == 'web' ) {
$install_actions['themes_page'] = '<a href="' . self_admin_url( 'theme-install.php' ) . '" target="_parent">' . __( 'Return to Theme Installer' ) . '</a>';
elseif ( current_user_can( 'switch_themes' ) || current_user_can( 'edit_theme_options' ) )
} elseif ( current_user_can( 'switch_themes' ) || current_user_can( 'edit_theme_options' ) ) {
$install_actions['themes_page'] = '<a href="' . self_admin_url( 'themes.php' ) . '" target="_parent">' . __( 'Return to Themes page' ) . '</a>';
}
if ( ! $this->result || is_wp_error($this->result) || is_network_admin() || ! current_user_can( 'switch_themes' ) )
if ( ! $this->result || is_wp_error( $this->result ) || is_network_admin() || ! current_user_can( 'switch_themes' ) ) {
unset( $install_actions['activate'], $install_actions['preview'] );
}
/**
* Filters the list of action links available following a single theme installation.
@ -97,7 +110,8 @@ class Theme_Installer_Skin extends WP_Upgrader_Skin {
* @param WP_Theme $theme_info Theme object.
*/
$install_actions = apply_filters( 'install_theme_complete_actions', $install_actions, $this->api, $stylesheet, $theme_info );
if ( ! empty($install_actions) )
if ( ! empty( $install_actions ) ) {
$this->feedback( implode( ' | ', (array) $install_actions ) );
}
}
}

View File

@ -19,11 +19,15 @@ class Theme_Upgrader_Skin extends WP_Upgrader_Skin {
public $theme = '';
/**
*
* @param array $args
*/
public function __construct( $args = array() ) {
$defaults = array( 'url' => '', 'theme' => '', 'nonce' => '', 'title' => __('Update Theme') );
$defaults = array(
'url' => '',
'theme' => '',
'nonce' => '',
'title' => __( 'Update Theme' ),
);
$args = wp_parse_args( $args, $defaults );
$this->theme = $args['theme'];
@ -42,11 +46,13 @@ class Theme_Upgrader_Skin extends WP_Upgrader_Skin {
$stylesheet = $this->upgrader->result['destination_name'];
$template = $theme_info->get_template();
$activate_link = add_query_arg( array(
$activate_link = add_query_arg(
array(
'action' => 'activate',
'template' => urlencode( $template ),
'stylesheet' => urlencode( $stylesheet ),
), admin_url('themes.php') );
), admin_url( 'themes.php' )
);
$activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet );
$customize_url = add_query_arg(
@ -67,9 +73,10 @@ class Theme_Upgrader_Skin extends WP_Upgrader_Skin {
$update_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink"><span aria-hidden="true">' . __( 'Activate' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Activate &#8220;%s&#8221;' ), $name ) . '</span></a>';
}
if ( ! $this->result || is_wp_error( $this->result ) || is_network_admin() )
if ( ! $this->result || is_wp_error( $this->result ) || is_network_admin() ) {
unset( $update_actions['preview'], $update_actions['activate'] );
}
}
$update_actions['themes_page'] = '<a href="' . self_admin_url( 'themes.php' ) . '" target="_parent">' . __( 'Return to Themes page' ) . '</a>';
@ -83,7 +90,8 @@ class Theme_Upgrader_Skin extends WP_Upgrader_Skin {
*/
$update_actions = apply_filters( 'update_theme_complete_actions', $update_actions, $this->theme );
if ( ! empty($update_actions) )
if ( ! empty( $update_actions ) ) {
$this->feedback( implode( ' | ', (array) $update_actions ) );
}
}
}

View File

@ -97,8 +97,9 @@ class Theme_Upgrader extends WP_Upgrader {
// Check to see if we need to install a parent theme
$theme_info = $this->theme_info();
if ( ! $theme_info->parent() )
if ( ! $theme_info->parent() ) {
return $install_result;
}
$this->skin->feedback( 'parent_theme_search' );
@ -109,7 +110,15 @@ class Theme_Upgrader extends WP_Upgrader {
}
// We don't have the parent theme, let's install it.
$api = themes_api('theme_information', array('slug' => $theme_info->get('Template'), 'fields' => array('sections' => false, 'tags' => false) ) ); //Save on a bit of bandwidth.
$api = themes_api(
'theme_information', array(
'slug' => $theme_info->get( 'Template' ),
'fields' => array(
'sections' => false,
'tags' => false,
),
)
); //Save on a bit of bandwidth.
if ( ! $api || is_wp_error( $api ) ) {
$this->skin->feedback( 'parent_theme_not_found', $theme_info->get( 'Template' ) );
@ -131,15 +140,18 @@ class Theme_Upgrader extends WP_Upgrader {
add_filter( 'install_theme_complete_actions', '__return_false', 999 ); // Don't show any actions after installing the theme.
// Install the parent theme
$parent_result = $this->run( array(
$parent_result = $this->run(
array(
'package' => $api->download_link,
'destination' => get_theme_root(),
'clear_destination' => false, //Do not overwrite files.
'clear_working' => true
) );
'clear_working' => true,
)
);
if ( is_wp_error($parent_result) )
if ( is_wp_error( $parent_result ) ) {
add_filter( 'install_theme_complete_actions', array( $this, 'hide_activate_preview_actions' ) );
}
// Start cleaning up after the parents installation
remove_filter( 'install_theme_complete_actions', '__return_false', 999 );
@ -202,7 +214,8 @@ class Theme_Upgrader extends WP_Upgrader {
add_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9, 0 );
}
$this->run( array(
$this->run(
array(
'package' => $package,
'destination' => get_theme_root(),
'clear_destination' => false, //Do not overwrite files.
@ -211,14 +224,16 @@ class Theme_Upgrader extends WP_Upgrader {
'type' => 'theme',
'action' => 'install',
),
) );
)
);
remove_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9 );
remove_filter( 'upgrader_source_selection', array( $this, 'check_package' ) );
remove_filter( 'upgrader_post_install', array( $this, 'check_parent_theme_filter' ) );
if ( ! $this->result || is_wp_error($this->result) )
if ( ! $this->result || is_wp_error( $this->result ) ) {
return $this->result;
}
// Refresh the Theme Update information
wp_clean_themes_cache( $parsed_args['clear_update_cache'] );
@ -271,7 +286,8 @@ class Theme_Upgrader extends WP_Upgrader {
add_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9, 0 );
}
$this->run( array(
$this->run(
array(
'package' => $r['package'],
'destination' => get_theme_root( $theme ),
'clear_destination' => true,
@ -281,15 +297,17 @@ class Theme_Upgrader extends WP_Upgrader {
'type' => 'theme',
'action' => 'update',
),
) );
)
);
remove_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9 );
remove_filter( 'upgrader_pre_install', array( $this, 'current_before' ) );
remove_filter( 'upgrader_post_install', array( $this, 'current_after' ) );
remove_filter( 'upgrader_clear_destination', array( $this, 'delete_old_theme' ) );
if ( ! $this->result || is_wp_error($this->result) )
if ( ! $this->result || is_wp_error( $this->result ) ) {
return $this->result;
}
wp_clean_themes_cache( $parsed_args['clear_update_cache'] );
@ -344,10 +362,12 @@ class Theme_Upgrader extends WP_Upgrader {
// - a theme with an update available is currently in use.
// @TODO: For multisite, maintenance mode should only kick in for individual sites if at all possible.
$maintenance = ( is_multisite() && ! empty( $themes ) );
foreach ( $themes as $theme )
foreach ( $themes as $theme ) {
$maintenance = $maintenance || $theme == get_stylesheet() || $theme == get_template();
if ( $maintenance )
}
if ( $maintenance ) {
$this->maintenance_mode( true );
}
$results = array();
@ -370,22 +390,25 @@ class Theme_Upgrader extends WP_Upgrader {
// Get the URL to the zip file
$r = $current->response[ $theme ];
$result = $this->run( array(
$result = $this->run(
array(
'package' => $r['package'],
'destination' => get_theme_root( $theme ),
'clear_destination' => true,
'clear_working' => true,
'is_multi' => true,
'hook_extra' => array(
'theme' => $theme
'theme' => $theme,
),
) );
)
);
$results[ $theme ] = $this->result;
// Prevent credentials auth screen from displaying multiple times
if ( false === $result )
if ( false === $result ) {
break;
}
} //end foreach $plugins
$this->maintenance_mode( false );
@ -394,12 +417,14 @@ class Theme_Upgrader extends WP_Upgrader {
wp_clean_themes_cache( $parsed_args['clear_update_cache'] );
/** This action is documented in wp-admin/includes/class-wp-upgrader.php */
do_action( 'upgrader_process_complete', $this, array(
do_action(
'upgrader_process_complete', $this, array(
'action' => 'update',
'type' => 'theme',
'bulk' => true,
'themes' => $themes,
) );
)
);
$this->skin->bulk_footer();
@ -430,30 +455,41 @@ class Theme_Upgrader extends WP_Upgrader {
public function check_package( $source ) {
global $wp_filesystem;
if ( is_wp_error($source) )
if ( is_wp_error( $source ) ) {
return $source;
}
// Check the folder contains a valid theme
$working_directory = str_replace( $wp_filesystem->wp_content_dir(), trailingslashit( WP_CONTENT_DIR ), $source );
if ( ! is_dir($working_directory) ) // Sanity check, if the above fails, let's not prevent installation.
if ( ! is_dir( $working_directory ) ) { // Sanity check, if the above fails, let's not prevent installation.
return $source;
}
// A proper archive should have a style.css file in the single subdirectory
if ( ! file_exists( $working_directory . 'style.css' ) ) {
return new WP_Error( 'incompatible_archive_theme_no_style', $this->strings['incompatible_archive'],
return new WP_Error(
'incompatible_archive_theme_no_style', $this->strings['incompatible_archive'],
/* translators: %s: style.css */
sprintf( __( 'The theme is missing the %s stylesheet.' ),
sprintf(
__( 'The theme is missing the %s stylesheet.' ),
'<code>style.css</code>'
)
);
}
$info = get_file_data( $working_directory . 'style.css', array( 'Name' => 'Theme Name', 'Template' => 'Template' ) );
$info = get_file_data(
$working_directory . 'style.css', array(
'Name' => 'Theme Name',
'Template' => 'Template',
)
);
if ( empty( $info['Name'] ) ) {
return new WP_Error( 'incompatible_archive_theme_no_name', $this->strings['incompatible_archive'],
return new WP_Error(
'incompatible_archive_theme_no_name', $this->strings['incompatible_archive'],
/* translators: %s: style.css */
sprintf( __( 'The %s stylesheet doesn&#8217;t contain a valid theme header.' ),
sprintf(
__( 'The %s stylesheet doesn&#8217;t contain a valid theme header.' ),
'<code>style.css</code>'
)
);
@ -461,9 +497,11 @@ class Theme_Upgrader extends WP_Upgrader {
// If it's not a child theme, it must have at least an index.php to be legit.
if ( empty( $info['Template'] ) && ! file_exists( $working_directory . 'index.php' ) ) {
return new WP_Error( 'incompatible_archive_theme_no_index', $this->strings['incompatible_archive'],
return new WP_Error(
'incompatible_archive_theme_no_index', $this->strings['incompatible_archive'],
/* translators: %s: index.php */
sprintf( __( 'The theme is missing the %s file.' ),
sprintf(
__( 'The theme is missing the %s file.' ),
'<code>index.php</code>'
)
);
@ -485,16 +523,19 @@ class Theme_Upgrader extends WP_Upgrader {
* @return bool|WP_Error
*/
public function current_before( $return, $theme ) {
if ( is_wp_error($return) )
if ( is_wp_error( $return ) ) {
return $return;
}
$theme = isset( $theme['theme'] ) ? $theme['theme'] : '';
if ( $theme != get_stylesheet() ) //If not current
if ( $theme != get_stylesheet() ) { //If not current
return $return;
}
//Change to maintenance mode now.
if ( ! $this->bulk )
if ( ! $this->bulk ) {
$this->maintenance_mode( true );
}
return $return;
}
@ -512,13 +553,15 @@ class Theme_Upgrader extends WP_Upgrader {
* @return bool|WP_Error
*/
public function current_after( $return, $theme ) {
if ( is_wp_error($return) )
if ( is_wp_error( $return ) ) {
return $return;
}
$theme = isset( $theme['theme'] ) ? $theme['theme'] : '';
if ( $theme != get_stylesheet() ) // If not current
if ( $theme != get_stylesheet() ) { // If not current
return $return;
}
// Ensure stylesheet name hasn't changed after the upgrade:
if ( $theme == get_stylesheet() && $theme != $this->result['destination_name'] ) {
@ -528,8 +571,9 @@ class Theme_Upgrader extends WP_Upgrader {
}
//Time to remove maintenance mode
if ( ! $this->bulk )
if ( ! $this->bulk ) {
$this->maintenance_mode( false );
}
return $return;
}
@ -552,18 +596,21 @@ class Theme_Upgrader extends WP_Upgrader {
public function delete_old_theme( $removed, $local_destination, $remote_destination, $theme ) {
global $wp_filesystem;
if ( is_wp_error( $removed ) )
if ( is_wp_error( $removed ) ) {
return $removed; // Pass errors through.
}
if ( ! isset( $theme['theme'] ) )
if ( ! isset( $theme['theme'] ) ) {
return $removed;
}
$theme = $theme['theme'];
$themes_dir = trailingslashit( $wp_filesystem->wp_themes_dir( $theme ) );
if ( $wp_filesystem->exists( $themes_dir . $theme ) ) {
if ( ! $wp_filesystem->delete( $themes_dir . $theme, true ) )
if ( ! $wp_filesystem->delete( $themes_dir . $theme, true ) ) {
return false;
}
}
return true;
}
@ -582,11 +629,12 @@ class Theme_Upgrader extends WP_Upgrader {
public function theme_info( $theme = null ) {
if ( empty( $theme ) ) {
if ( !empty($this->result['destination_name']) )
if ( ! empty( $this->result['destination_name'] ) ) {
$theme = $this->result['destination_name'];
else
} else {
return false;
}
}
return wp_get_theme( $theme );
}

View File

@ -18,7 +18,10 @@
*/
class Walker_Category_Checklist extends Walker {
public $tree_type = 'category';
public $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this
public $db_fields = array(
'parent' => 'parent',
'id' => 'term_id',
); //TODO: decouple this
/**
* Starts the list before the elements are added.

View File

@ -15,7 +15,6 @@
*/
class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu {
/**
*
* @param array $fields
*/
public function __construct( $fields = false ) {
@ -84,8 +83,9 @@ class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu {
$output .= '<label class="menu-item-title">';
$output .= '<input type="checkbox" class="menu-item-checkbox';
if ( ! empty( $item->front_or_home ) )
if ( ! empty( $item->front_or_home ) ) {
$output .= ' add-to-top';
}
$output .= '" name="menu-item[' . $possible_object_id . '][menu-item-object-id]" value="' . esc_attr( $item->object_id ) . '" /> ';
@ -94,9 +94,10 @@ class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu {
} elseif ( isset( $item->post_type ) ) {
/** This filter is documented in wp-includes/post-template.php */
$title = apply_filters( 'the_title', $item->post_title, $item->ID );
if ( ! empty( $item->front_or_home ) && _x( 'Home', 'nav menu home label' ) !== $title )
if ( ! empty( $item->front_or_home ) && _x( 'Home', 'nav menu home label' ) !== $title ) {
$title = sprintf( _x( 'Home: %s', 'nav menu front page title' ), $title );
}
}
$output .= isset( $title ) ? esc_html( $title ) : esc_html( $item->title );
$output .= '</label>';

View File

@ -73,8 +73,9 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
$original_title = false;
if ( 'taxonomy' == $item->type ) {
$original_title = get_term_field( 'name', $item->object_id, $item->object, 'raw' );
if ( is_wp_error( $original_title ) )
if ( is_wp_error( $original_title ) ) {
$original_title = false;
}
} elseif ( 'post_type' == $item->type ) {
$original_object = get_post( $item->object_id );
$original_title = get_the_title( $original_object->ID );
@ -106,8 +107,9 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
$title = ( ! isset( $item->label ) || '' == $item->label ) ? $title : $item->label;
$submenu_text = '';
if ( 0 == $depth )
if ( 0 == $depth ) {
$submenu_text = 'style="display: none;"';
}
?>
<li id="menu-item-<?php echo $item_id; ?>" class="<?php echo implode( ' ', $classes ); ?>">
@ -117,7 +119,8 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
<span class="item-controls">
<span class="item-type"><?php echo esc_html( $item->type_label ); ?></span>
<span class="item-order hide-if-js">
<a href="<?php
<a href="
<?php
echo wp_nonce_url(
add_query_arg(
array(
@ -128,9 +131,11 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
),
'move-menu_item'
);
?>" class="item-move-up" aria-label="<?php esc_attr_e( 'Move up' ) ?>">&#8593;</a>
?>
" class="item-move-up" aria-label="<?php esc_attr_e( 'Move up' ); ?>">&#8593;</a>
|
<a href="<?php
<a href="
<?php
echo wp_nonce_url(
add_query_arg(
array(
@ -141,11 +146,14 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
),
'move-menu_item'
);
?>" class="item-move-down" aria-label="<?php esc_attr_e( 'Move down' ) ?>">&#8595;</a>
?>
" class="item-move-down" aria-label="<?php esc_attr_e( 'Move down' ); ?>">&#8595;</a>
</span>
<a class="item-edit" id="edit-<?php echo $item_id; ?>" href="<?php
<a class="item-edit" id="edit-<?php echo $item_id; ?>" href="
<?php
echo ( isset( $_GET['edit-menu-item'] ) && $item_id == $_GET['edit-menu-item'] ) ? admin_url( 'nav-menus.php' ) : add_query_arg( 'edit-menu-item', $item_id, remove_query_arg( $removed_args, admin_url( 'nav-menus.php#menu-item-settings-' . $item_id ) ) );
?>" aria-label="<?php esc_attr_e( 'Edit menu item' ); ?>"><span class="screen-reader-text"><?php _e( 'Edit' ); ?></span></a>
?>
" aria-label="<?php esc_attr_e( 'Edit menu item' ); ?>"><span class="screen-reader-text"><?php _e( 'Edit' ); ?></span></a>
</span>
</div>
</div>
@ -212,7 +220,8 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
<?php printf( __( 'Original: %s' ), '<a href="' . esc_attr( $item->url ) . '">' . esc_html( $original_title ) . '</a>' ); ?>
</p>
<?php endif; ?>
<a class="item-delete submitdelete deletion" id="delete-<?php echo $item_id; ?>" href="<?php
<a class="item-delete submitdelete deletion" id="delete-<?php echo $item_id; ?>" href="
<?php
echo wp_nonce_url(
add_query_arg(
array(
@ -222,8 +231,20 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
admin_url( 'nav-menus.php' )
),
'delete-menu_item_' . $item_id
); ?>"><?php _e( 'Remove' ); ?></a> <span class="meta-sep hide-if-no-js"> | </span> <a class="item-cancel submitcancel hide-if-no-js" id="cancel-<?php echo $item_id; ?>" href="<?php echo esc_url( add_query_arg( array( 'edit-menu-item' => $item_id, 'cancel' => time() ), admin_url( 'nav-menus.php' ) ) );
?>#menu-item-settings-<?php echo $item_id; ?>"><?php _e('Cancel'); ?></a>
);
?>
"><?php _e( 'Remove' ); ?></a> <span class="meta-sep hide-if-no-js"> | </span> <a class="item-cancel submitcancel hide-if-no-js" id="cancel-<?php echo $item_id; ?>" href="
<?php
echo esc_url(
add_query_arg(
array(
'edit-menu-item' => $item_id,
'cancel' => time(),
), admin_url( 'nav-menus.php' )
)
);
?>
#menu-item-settings-<?php echo $item_id; ?>"><?php _e( 'Cancel' ); ?></a>
</div>
<input class="menu-item-data-db-id" type="hidden" name="menu-item-db-id[<?php echo $item_id; ?>]" value="<?php echo $item_id; ?>" />

View File

@ -29,11 +29,13 @@ class WP_Automatic_Updater {
*/
public function is_disabled() {
// Background updates are disabled if you don't want file changes.
if ( ! wp_is_file_mod_allowed( 'automatic_updater' ) )
if ( ! wp_is_file_mod_allowed( 'automatic_updater' ) ) {
return true;
}
if ( wp_installing() )
if ( wp_installing() ) {
return true;
}
// More fine grained control can be done through the WP_AUTO_UPDATE_CORE constant and filters.
$disabled = defined( 'AUTOMATIC_UPDATER_DISABLED' ) && AUTOMATIC_UPDATER_DISABLED;
@ -71,8 +73,9 @@ class WP_Automatic_Updater {
*/
public function is_vcs_checkout( $context ) {
$context_dirs = array( untrailingslashit( $context ) );
if ( $context !== ABSPATH )
if ( $context !== ABSPATH ) {
$context_dirs[] = untrailingslashit( ABSPATH );
}
$vcs_dirs = array( '.svn', '.git', '.hg', '.bzr' );
$check_dirs = array();
@ -83,8 +86,9 @@ class WP_Automatic_Updater {
$check_dirs[] = $context_dir;
// Once we've hit '/' or 'C:\', we need to stop. dirname will keep returning the input here.
if ( $context_dir == dirname( $context_dir ) )
if ( $context_dir == dirname( $context_dir ) ) {
break;
}
// Continue one level at a time.
} while ( $context_dir = dirname( $context_dir ) );
@ -95,10 +99,11 @@ class WP_Automatic_Updater {
// Search all directories we've found for evidence of version control.
foreach ( $vcs_dirs as $vcs_dir ) {
foreach ( $check_dirs as $check_dir ) {
if ( $checkout = @is_dir( rtrim( $check_dir, '\\/' ) . "/$vcs_dir" ) )
if ( $checkout = @is_dir( rtrim( $check_dir, '\\/' ) . "/$vcs_dir" ) ) {
break 2;
}
}
}
/**
* Filters whether the automatic updater should consider a filesystem
@ -131,8 +136,9 @@ class WP_Automatic_Updater {
// Used to see if WP_Filesystem is set up to allow unattended updates.
$skin = new Automatic_Upgrader_Skin;
if ( $this->is_disabled() )
if ( $this->is_disabled() ) {
return false;
}
// Only relax the filesystem checks when the update doesn't include new files
$allow_relaxed_file_ownership = false;
@ -142,16 +148,18 @@ class WP_Automatic_Updater {
// If we can't do an auto core update, we may still be able to email the user.
if ( ! $skin->request_filesystem_credentials( false, $context, $allow_relaxed_file_ownership ) || $this->is_vcs_checkout( $context ) ) {
if ( 'core' == $type )
if ( 'core' == $type ) {
$this->send_core_update_notification_email( $item );
}
return false;
}
// Next up, is this an item we can update?
if ( 'core' == $type )
if ( 'core' == $type ) {
$update = Core_Upgrader::should_update_to_version( $item->current );
else
} else {
$update = ! empty( $item->autoupdate );
}
/**
* Filters whether to automatically update core, a plugin, a theme, or a language.
@ -175,8 +183,9 @@ class WP_Automatic_Updater {
$update = apply_filters( "auto_update_{$type}", $update, $item );
if ( ! $update ) {
if ( 'core' == $type )
if ( 'core' == $type ) {
$this->send_core_update_notification_email( $item );
}
return false;
}
@ -185,14 +194,16 @@ class WP_Automatic_Updater {
global $wpdb;
$php_compat = version_compare( phpversion(), $item->php_version, '>=' );
if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) )
if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) ) {
$mysql_compat = true;
else
} else {
$mysql_compat = version_compare( $wpdb->db_version(), $item->mysql_version, '>=' );
}
if ( ! $php_compat || ! $mysql_compat )
if ( ! $php_compat || ! $mysql_compat ) {
return false;
}
}
return true;
}
@ -208,8 +219,9 @@ class WP_Automatic_Updater {
$notified = get_site_option( 'auto_core_update_notified' );
// Don't notify if we've already notified the same email address of the same version.
if ( $notified && $notified['email'] == get_site_option( 'admin_email' ) && $notified['version'] == $item->current )
if ( $notified && $notified['email'] == get_site_option( 'admin_email' ) && $notified['version'] == $item->current ) {
return false;
}
// See if we need to notify users of a core update.
$notify = ! empty( $item->notify_email );
@ -233,8 +245,9 @@ class WP_Automatic_Updater {
* @param bool $notify Whether the site administrator is notified.
* @param object $item The update offer.
*/
if ( ! apply_filters( 'send_core_update_notification_email', $notify, $item ) )
if ( ! apply_filters( 'send_core_update_notification_email', $notify, $item ) ) {
return false;
}
$this->send_email( 'manual', $item );
return true;
@ -275,8 +288,9 @@ class WP_Automatic_Updater {
}
// Determine whether we can and should perform this update.
if ( ! $this->should_update( $type, $item, $context ) )
if ( ! $this->should_update( $type, $item, $context ) ) {
return false;
}
/**
* Fires immediately prior to an auto-update.
@ -321,7 +335,8 @@ class WP_Automatic_Updater {
}
// Boom, This sites about to get a whole new splash of paint!
$upgrade_result = $upgrader->upgrade( $upgrader_item, array(
$upgrade_result = $upgrader->upgrade(
$upgrader_item, array(
'clear_update_cache' => false,
// Always use partial builds if possible for core updates.
'pre_check_md5' => false,
@ -329,7 +344,8 @@ class WP_Automatic_Updater {
'attempt_rollback' => true,
// Allow relaxed file ownership in some scenarios
'allow_relaxed_file_ownership' => $allow_relaxed_file_ownership,
) );
)
);
// If the filesystem is unavailable, false is returned.
if ( false === $upgrade_result ) {
@ -354,7 +370,7 @@ class WP_Automatic_Updater {
'item' => $item,
'result' => $upgrade_result,
'name' => $item_name,
'messages' => $skin->get_upgrade_messages()
'messages' => $skin->get_upgrade_messages(),
);
return $upgrade_result;
@ -366,14 +382,17 @@ class WP_Automatic_Updater {
* @since 3.7.0
*/
public function run() {
if ( $this->is_disabled() )
if ( $this->is_disabled() ) {
return;
}
if ( ! is_main_network() || ! is_main_site() )
if ( ! is_main_network() || ! is_main_site() ) {
return;
}
if ( ! WP_Upgrader::create_lock( 'auto_updater' ) )
if ( ! WP_Upgrader::create_lock( 'auto_updater' ) ) {
return;
}
// Don't automatically run these thins, as we'll handle it ourselves
remove_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 );
@ -407,8 +426,9 @@ class WP_Automatic_Updater {
wp_version_check(); // Check for Core updates
$core_update = find_core_auto_update();
if ( $core_update )
if ( $core_update ) {
$this->update( 'core', $core_update );
}
// Clean up, and check for any pending translations
// (Core_Upgrader checks for core updates)
@ -456,11 +476,13 @@ class WP_Automatic_Updater {
* install is a development version.
* Return false to avoid the email.
*/
if ( apply_filters( 'automatic_updates_send_debug_email', $development_version ) )
if ( apply_filters( 'automatic_updates_send_debug_email', $development_version ) ) {
$this->send_debug_email();
}
if ( ! empty( $this->update_results['core'] ) )
if ( ! empty( $this->update_results['core'] ) ) {
$this->after_core_update( $this->update_results['core'][0] );
}
/**
* Fires after all automatic updates have run.
@ -547,21 +569,25 @@ class WP_Automatic_Updater {
$n = get_site_option( 'auto_core_update_notified' );
// Don't notify if we've already notified the same email address of the same version of the same notification type.
if ( $n && 'fail' == $n['type'] && $n['email'] == get_site_option( 'admin_email' ) && $n['version'] == $core_update->current )
if ( $n && 'fail' == $n['type'] && $n['email'] == get_site_option( 'admin_email' ) && $n['version'] == $core_update->current ) {
$send = false;
}
update_site_option( 'auto_core_update_failed', array(
update_site_option(
'auto_core_update_failed', array(
'attempted' => $core_update->current,
'current' => $wp_version,
'error_code' => $error_code,
'error_data' => $result->get_error_data(),
'timestamp' => time(),
'retry' => in_array( $error_code, $transient_failures ),
) );
)
);
if ( $send )
if ( $send ) {
$this->send_email( 'fail', $core_update, $result );
}
}
/**
* Sends an email upon the completion or failure of a background core update.
@ -573,17 +599,20 @@ class WP_Automatic_Updater {
* @param mixed $result Optional. The result for the core update. Can be WP_Error.
*/
protected function send_email( $type, $core_update, $result = null ) {
update_site_option( 'auto_core_update_notified', array(
update_site_option(
'auto_core_update_notified', array(
'type' => $type,
'email' => get_site_option( 'admin_email' ),
'version' => $core_update->current,
'timestamp' => time(),
) );
)
);
$next_user_core_update = get_preferred_from_update_core();
// If the update transient is empty, use the update we just performed
if ( ! $next_user_core_update )
if ( ! $next_user_core_update ) {
$next_user_core_update = $core_update;
}
$newer_version_available = ( 'upgrade' == $next_user_core_update->response && version_compare( $next_user_core_update->version, $core_update->version, '>' ) );
/**
@ -597,8 +626,9 @@ class WP_Automatic_Updater {
* @param object $core_update The update offer that was attempted.
* @param mixed $result The result for the core update. Can be WP_Error.
*/
if ( 'manual' !== $type && ! apply_filters( 'auto_core_update_send_email', true, $type, $core_update, $result ) )
if ( 'manual' !== $type && ! apply_filters( 'auto_core_update_send_email', true, $type, $core_update, $result ) ) {
return;
}
switch ( $type ) {
case 'success': // We updated.
@ -631,12 +661,13 @@ class WP_Automatic_Updater {
case 'success':
$body .= sprintf( __( 'Howdy! Your site at %1$s has been updated automatically to WordPress %2$s.' ), home_url(), $core_update->current );
$body .= "\n\n";
if ( ! $newer_version_available )
if ( ! $newer_version_available ) {
$body .= __( 'No further action is needed on your part.' ) . ' ';
}
// Can only reference the About screen if their update was successful.
list( $about_version ) = explode( '-', $core_update->current, 2 );
$body .= sprintf( __( "For more on version %s, see the About WordPress screen:" ), $about_version );
$body .= sprintf( __( 'For more on version %s, see the About WordPress screen:' ), $about_version );
$body .= "\n" . admin_url( 'about.php' );
if ( $newer_version_available ) {
@ -655,18 +686,20 @@ class WP_Automatic_Updater {
// Don't show this message if there is a newer version available.
// Potential for confusion, and also not useful for them to know at this point.
if ( 'fail' == $type && ! $newer_version_available )
if ( 'fail' == $type && ! $newer_version_available ) {
$body .= __( 'We tried but were unable to update your site automatically.' ) . ' ';
}
$body .= __( 'Updating is easy and only takes a few moments:' );
$body .= "\n" . network_admin_url( 'update-core.php' );
break;
case 'critical':
if ( $newer_version_available )
if ( $newer_version_available ) {
$body .= sprintf( __( 'Your site at %1$s experienced a critical failure while trying to update WordPress to version %2$s.' ), home_url(), $core_update->current );
else
} else {
$body .= sprintf( __( 'Your site at %1$s experienced a critical failure while trying to update to the latest version of WordPress, %2$s.' ), home_url(), $core_update->current );
}
$body .= "\n\n" . __( "This means your site may be offline or broken. Don't panic; this can be fixed." );
@ -678,7 +711,7 @@ class WP_Automatic_Updater {
$critical_support = 'critical' === $type && ! empty( $core_update->support_email );
if ( $critical_support ) {
// Support offer if available.
$body .= "\n\n" . sprintf( __( "The WordPress team is willing to help you. Forward this email to %s and the team will work with you to make sure your site is working." ), $core_update->support_email );
$body .= "\n\n" . sprintf( __( 'The WordPress team is willing to help you. Forward this email to %s and the team will work with you to make sure your site is working.' ), $core_update->support_email );
} else {
// Add a note about the support forums.
$body .= "\n\n" . __( 'If you experience any issues or need support, the volunteers in the WordPress.org support forums may be able to help.' );
@ -691,7 +724,7 @@ class WP_Automatic_Updater {
}
if ( $critical_support ) {
$body .= " " . __( "If you reach out to us, we'll also ensure you'll never have this problem again." );
$body .= ' ' . __( "If you reach out to us, we'll also ensure you'll never have this problem again." );
}
// If things are successful and we're now on the latest, mention plugins and themes if any are out of date.
@ -710,24 +743,29 @@ class WP_Automatic_Updater {
// If we had a rollback and we're still critical, then the rollback failed too.
// Loop through all errors (the main WP_Error, the update result, the rollback result) for code, data, etc.
if ( 'rollback_was_required' == $result->get_error_code() )
if ( 'rollback_was_required' == $result->get_error_code() ) {
$errors = array( $result, $result->get_error_data()->update, $result->get_error_data()->rollback );
else
} else {
$errors = array( $result );
}
foreach ( $errors as $error ) {
if ( ! is_wp_error( $error ) )
if ( ! is_wp_error( $error ) ) {
continue;
}
$error_code = $error->get_error_code();
$body .= "\n\n" . sprintf( __( "Error code: %s" ), $error_code );
if ( 'rollback_was_required' == $error_code )
$body .= "\n\n" . sprintf( __( 'Error code: %s' ), $error_code );
if ( 'rollback_was_required' == $error_code ) {
continue;
if ( $error->get_error_message() )
}
if ( $error->get_error_message() ) {
$body .= "\n" . $error->get_error_message();
}
$error_data = $error->get_error_data();
if ( $error_data )
if ( $error_data ) {
$body .= "\n" . implode( ', ', (array) $error_data );
}
}
$body .= "\n";
}
@ -767,8 +805,9 @@ class WP_Automatic_Updater {
*/
protected function send_debug_email() {
$update_count = 0;
foreach ( $this->update_results as $type => $updates )
foreach ( $this->update_results as $type => $updates ) {
$update_count += count( $updates );
}
$body = array();
$failures = 0;
@ -789,8 +828,9 @@ class WP_Automatic_Updater {
// Plugins, Themes, Translations
foreach ( array( 'plugin', 'theme', 'translation' ) as $type ) {
if ( ! isset( $this->update_results[ $type ] ) )
if ( ! isset( $this->update_results[ $type ] ) ) {
continue;
}
$success_items = wp_list_filter( $this->update_results[ $type ], array( 'result' => true ) );
if ( $success_items ) {
$messages = array(
@ -825,7 +865,8 @@ class WP_Automatic_Updater {
$site_title = wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES );
if ( $failures ) {
$body[] = trim( __(
$body[] = trim(
__(
"BETA TESTING?
=============
@ -835,7 +876,9 @@ If you think these failures might be due to a bug in WordPress, could you report
* Open a thread in the support forums: https://wordpress.org/support/forum/alphabeta
* Or, if you're comfortable writing a bug report: https://core.trac.wordpress.org/
Thanks! -- The WordPress Team" ) );
Thanks! -- The WordPress Team"
)
);
$body[] = '';
$subject = sprintf( __( '[%s] There were failures during background updates' ), $site_title );
@ -843,27 +886,34 @@ Thanks! -- The WordPress Team" ) );
$subject = sprintf( __( '[%s] Background updates have finished' ), $site_title );
}
$body[] = trim( __(
$body[] = trim(
__(
'UPDATE LOG
==========' ) );
=========='
)
);
$body[] = '';
foreach ( array( 'core', 'plugin', 'theme', 'translation' ) as $type ) {
if ( ! isset( $this->update_results[ $type ] ) )
if ( ! isset( $this->update_results[ $type ] ) ) {
continue;
}
foreach ( $this->update_results[ $type ] as $update ) {
$body[] = $update->name;
$body[] = str_repeat( '-', strlen( $update->name ) );
foreach ( $update->messages as $message )
$body[] = " " . html_entity_decode( str_replace( '&#8230;', '...', $message ) );
foreach ( $update->messages as $message ) {
$body[] = ' ' . html_entity_decode( str_replace( '&#8230;', '...', $message ) );
}
if ( is_wp_error( $update->result ) ) {
$results = array( 'update' => $update->result );
// If we rolled back, we want to know an error that occurred then too.
if ( 'rollback_was_required' === $update->result->get_error_code() )
if ( 'rollback_was_required' === $update->result->get_error_code() ) {
$results = (array) $update->result->get_error_data();
}
foreach ( $results as $result_type => $result ) {
if ( ! is_wp_error( $result ) )
if ( ! is_wp_error( $result ) ) {
continue;
}
if ( 'rollback' === $result_type ) {
/* translators: 1: Error code, 2: Error message. */
@ -873,10 +923,11 @@ Thanks! -- The WordPress Team" ) );
$body[] = ' ' . sprintf( __( 'Error: [%1$s] %2$s' ), $result->get_error_code(), $result->get_error_message() );
}
if ( $result->get_error_data() )
if ( $result->get_error_data() ) {
$body[] = ' ' . implode( ', ', (array) $result->get_error_data() );
}
}
}
$body[] = '';
}
}
@ -885,7 +936,7 @@ Thanks! -- The WordPress Team" ) );
'to' => get_site_option( 'admin_email' ),
'subject' => $subject,
'body' => implode( "\n", $body ),
'headers' => ''
'headers' => '',
);
/**

View File

@ -45,12 +45,14 @@ class WP_Comments_List_Table extends WP_List_Table {
add_filter( 'comment_author', array( $this, 'floated_admin_avatar' ), 10, 2 );
}
parent::__construct( array(
parent::__construct(
array(
'plural' => 'comments',
'singular' => 'comment',
'ajax' => true,
'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
) );
)
);
}
public function floated_admin_avatar( $name, $comment_ID ) {
@ -67,7 +69,6 @@ class WP_Comments_List_Table extends WP_List_Table {
}
/**
*
* @global int $post_id
* @global string $comment_status
* @global string $search
@ -77,8 +78,9 @@ class WP_Comments_List_Table extends WP_List_Table {
global $post_id, $comment_status, $search, $comment_type;
$comment_status = isset( $_REQUEST['comment_status'] ) ? $_REQUEST['comment_status'] : 'all';
if ( !in_array( $comment_status, array( 'all', 'moderated', 'approved', 'spam', 'trash' ) ) )
if ( ! in_array( $comment_status, array( 'all', 'moderated', 'approved', 'spam', 'trash' ) ) ) {
$comment_status = 'all';
}
$comment_type = ! empty( $_REQUEST['comment_type'] ) ? $_REQUEST['comment_type'] : '';
@ -97,8 +99,7 @@ class WP_Comments_List_Table extends WP_List_Table {
if ( isset( $_REQUEST['number'] ) ) {
$number = (int) $_REQUEST['number'];
}
else {
} else {
$number = $comments_per_page + min( 8, $comments_per_page ); // Grab a few extra
}
@ -145,20 +146,25 @@ class WP_Comments_List_Table extends WP_List_Table {
$this->pending_count = get_pending_comments_num( $_comment_post_ids );
}
$total_comments = get_comments( array_merge( $args, array(
$total_comments = get_comments(
array_merge(
$args, array(
'count' => true,
'offset' => 0,
'number' => 0
) ) );
'number' => 0,
)
)
);
$this->set_pagination_args( array(
$this->set_pagination_args(
array(
'total_items' => $total_comments,
'per_page' => $comments_per_page,
) );
)
);
}
/**
*
* @param string $comment_status
* @return int
*/
@ -176,7 +182,6 @@ class WP_Comments_List_Table extends WP_List_Table {
}
/**
*
* @global string $comment_status
*/
public function no_items() {
@ -190,7 +195,6 @@ class WP_Comments_List_Table extends WP_List_Table {
}
/**
*
* @global int $post_id
* @global string $comment_status
* @global string $comment_type
@ -235,15 +239,17 @@ class WP_Comments_List_Table extends WP_List_Table {
'Trash <span class="count">(%s)</span>',
'Trash <span class="count">(%s)</span>',
'comments'
)
),
);
if ( !EMPTY_TRASH_DAYS )
if ( ! EMPTY_TRASH_DAYS ) {
unset( $stati['trash'] );
}
$link = admin_url( 'edit-comments.php' );
if ( !empty($comment_type) && 'all' != $comment_type )
if ( ! empty( $comment_type ) && 'all' != $comment_type ) {
$link = add_query_arg( 'comment_type', $comment_type, $link );
}
foreach ( $stati as $status => $label ) {
$current_link_attributes = '';
@ -252,11 +258,13 @@ class WP_Comments_List_Table extends WP_List_Table {
$current_link_attributes = ' class="current" aria-current="page"';
}
if ( !isset( $num_comments->$status ) )
if ( ! isset( $num_comments->$status ) ) {
$num_comments->$status = 10;
}
$link = add_query_arg( 'comment_status', $status, $link );
if ( $post_id )
if ( $post_id ) {
$link = add_query_arg( 'p', absint( $post_id ), $link );
}
/*
// I toyed with this, but decided against it. Leaving it in here in case anyone thinks it is a good idea. ~ Mark
if ( !empty( $_REQUEST['s'] ) )
@ -264,7 +272,8 @@ class WP_Comments_List_Table extends WP_List_Table {
*/
$status_links[ $status ] = "<a href='$link'$current_link_attributes>" . sprintf(
translate_nooped_plural( $label, $num_comments->$status ),
sprintf( '<span class="%s-count">%s</span>',
sprintf(
'<span class="%s-count">%s</span>',
( 'moderated' === $status ) ? 'pending' : $status,
number_format_i18n( $num_comments->$status )
)
@ -283,7 +292,6 @@ class WP_Comments_List_Table extends WP_List_Table {
}
/**
*
* @global string $comment_status
*
* @return array
@ -292,12 +300,15 @@ class WP_Comments_List_Table extends WP_List_Table {
global $comment_status;
$actions = array();
if ( in_array( $comment_status, array( 'all', 'approved' ) ) )
if ( in_array( $comment_status, array( 'all', 'approved' ) ) ) {
$actions['unapprove'] = __( 'Unapprove' );
if ( in_array( $comment_status, array( 'all', 'moderated' ) ) )
}
if ( in_array( $comment_status, array( 'all', 'moderated' ) ) ) {
$actions['approve'] = __( 'Approve' );
if ( in_array( $comment_status, array( 'all', 'moderated', 'approved', 'trash' ) ) )
}
if ( in_array( $comment_status, array( 'all', 'moderated', 'approved', 'trash' ) ) ) {
$actions['spam'] = _x( 'Mark as Spam', 'comment' );
}
if ( 'trash' === $comment_status ) {
$actions['untrash'] = __( 'Restore' );
@ -305,16 +316,16 @@ class WP_Comments_List_Table extends WP_List_Table {
$actions['unspam'] = _x( 'Not Spam', 'comment' );
}
if ( in_array( $comment_status, array( 'trash', 'spam' ) ) || !EMPTY_TRASH_DAYS )
if ( in_array( $comment_status, array( 'trash', 'spam' ) ) || ! EMPTY_TRASH_DAYS ) {
$actions['delete'] = __( 'Delete Permanently' );
else
} else {
$actions['trash'] = __( 'Move to Trash' );
}
return $actions;
}
/**
*
* @global string $comment_status
* @global string $comment_type
*
@ -343,13 +354,16 @@ class WP_Comments_List_Table extends WP_List_Table {
*
* @param array $comment_types An array of comment types. Accepts 'Comments', 'Pings'.
*/
$comment_types = apply_filters( 'admin_comment_types_dropdown', array(
$comment_types = apply_filters(
'admin_comment_types_dropdown', array(
'comment' => __( 'Comments' ),
'pings' => __( 'Pings' ),
) );
)
);
foreach ( $comment_types as $type => $label )
foreach ( $comment_types as $type => $label ) {
echo "\t" . '<option value="' . esc_attr( $type ) . '"' . selected( $comment_type, $type, false ) . ">$label</option>\n";
}
?>
</select>
<?php
@ -382,14 +396,14 @@ class WP_Comments_List_Table extends WP_List_Table {
* @return string|false
*/
public function current_action() {
if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) )
if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) {
return 'delete_all';
}
return parent::current_action();
}
/**
*
* @global int $post_id
*
* @return array
@ -399,8 +413,9 @@ class WP_Comments_List_Table extends WP_List_Table {
$columns = array();
if ( $this->checkbox )
if ( $this->checkbox ) {
$columns['cb'] = '<input type="checkbox" />';
}
$columns['author'] = __( 'Author' );
$columns['comment'] = _x( 'Comment', 'column name' );
@ -416,14 +431,13 @@ class WP_Comments_List_Table extends WP_List_Table {
}
/**
*
* @return array
*/
protected function get_sortable_columns() {
return array(
'author' => 'comment_author',
'response' => 'comment_post_ID',
'date' => 'comment_date'
'date' => 'comment_date',
);
}
@ -441,7 +455,7 @@ class WP_Comments_List_Table extends WP_List_Table {
/**
*/
public function display() {
wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' );
wp_nonce_field( 'fetch-list-' . get_class( $this ), '_ajax_fetch_list_nonce' );
$this->display_tablenav( 'top' );
@ -549,12 +563,16 @@ class WP_Comments_List_Table extends WP_List_Table {
// Preorder it: Approve | Reply | Quick Edit | Edit | Spam | Trash.
$actions = array(
'approve' => '', 'unapprove' => '',
'approve' => '',
'unapprove' => '',
'reply' => '',
'quickedit' => '',
'edit' => '',
'spam' => '', 'unspam' => '',
'trash' => '', 'untrash' => '', 'delete' => ''
'spam' => '',
'unspam' => '',
'trash' => '',
'untrash' => '',
'delete' => '',
);
// Not looking at all comments.
@ -605,14 +623,15 @@ class WP_Comments_List_Table extends WP_List_Table {
( ( ( 'approve' === $action || 'unapprove' === $action ) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
// Reply and quickedit need a hide-if-no-js span when not added with ajax
if ( ( 'reply' === $action || 'quickedit' === $action ) && ! wp_doing_ajax() )
if ( ( 'reply' === $action || 'quickedit' === $action ) && ! wp_doing_ajax() ) {
$action .= ' hide-if-no-js';
elseif ( ( $action === 'untrash' && $the_comment_status === 'trash' ) || ( $action === 'unspam' && $the_comment_status === 'spam' ) ) {
if ( '1' == get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true ) )
} elseif ( ( $action === 'untrash' && $the_comment_status === 'trash' ) || ( $action === 'unspam' && $the_comment_status === 'spam' ) ) {
if ( '1' == get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true ) ) {
$action .= ' approve';
else
} else {
$action .= ' unapprove';
}
}
$out .= "<span class='$action'>$sep$link</span>";
}
@ -624,11 +643,11 @@ class WP_Comments_List_Table extends WP_List_Table {
}
/**
*
* @param WP_Comment $comment The comment object.
*/
public function column_cb( $comment ) {
if ( $this->user_can ) { ?>
if ( $this->user_can ) {
?>
<label class="screen-reader-text" for="cb-select-<?php echo $comment->comment_ID; ?>"><?php _e( 'Select comment' ); ?></label>
<input id="cb-select-<?php echo $comment->comment_ID; ?>" type="checkbox" name="delete_comments[]" value="<?php echo $comment->comment_ID; ?>" />
<?php
@ -657,12 +676,15 @@ class WP_Comments_List_Table extends WP_List_Table {
}
comment_text( $comment );
if ( $this->user_can ) { ?>
if ( $this->user_can ) {
?>
<div id="inline-<?php echo $comment->comment_ID; ?>" class="hidden">
<textarea class="comment" rows="1" cols="1"><?php
<textarea class="comment" rows="1" cols="1">
<?php
/** This filter is documented in wp-admin/includes/comment.php */
echo esc_textarea( apply_filters( 'comment_edit_pre', $comment->comment_content ) );
?></textarea>
?>
</textarea>
<div class="author-email"><?php echo esc_attr( $comment->comment_author_email ); ?></div>
<div class="author"><?php echo esc_attr( $comment->comment_author ); ?></div>
<div class="author-url"><?php echo esc_attr( $comment->comment_author_url ); ?></div>
@ -673,7 +695,6 @@ class WP_Comments_List_Table extends WP_List_Table {
}
/**
*
* @global string $comment_status
*
* @param WP_Comment $comment The comment object.
@ -688,7 +709,9 @@ class WP_Comments_List_Table extends WP_List_Table {
$author_url_display = wp_html_excerpt( $author_url_display, 49, '&hellip;' );
}
echo "<strong>"; comment_author( $comment ); echo '</strong><br />';
echo '<strong>';
comment_author( $comment );
echo '</strong><br />';
if ( ! empty( $author_url_display ) ) {
printf( '<a href="%s">%s</a><br />', esc_url( $author_url ), esc_html( $author_url_display ) );
}
@ -705,7 +728,12 @@ class WP_Comments_List_Table extends WP_List_Table {
$author_ip = get_comment_author_IP( $comment );
if ( $author_ip ) {
$author_ip_url = add_query_arg( array( 's' => $author_ip, 'mode' => 'detail' ), admin_url( 'edit-comments.php' ) );
$author_ip_url = add_query_arg(
array(
's' => $author_ip,
'mode' => 'detail',
), admin_url( 'edit-comments.php' )
);
if ( 'spam' === $comment_status ) {
$author_ip_url = add_query_arg( 'comment_status', 'spam', $author_ip_url );
}
@ -715,12 +743,12 @@ class WP_Comments_List_Table extends WP_List_Table {
}
/**
*
* @param WP_Comment $comment The comment object.
*/
public function column_date( $comment ) {
/* translators: 1: comment date, 2: comment time */
$submitted = sprintf( __( '%1$s at %2$s' ),
$submitted = sprintf(
__( '%1$s at %2$s' ),
/* translators: comment date format. See https://secure.php.net/date */
get_comment_date( __( 'Y/m/d' ), $comment ),
get_comment_date( __( 'g:i a' ), $comment )
@ -740,7 +768,6 @@ class WP_Comments_List_Table extends WP_List_Table {
}
/**
*
* @param WP_Comment $comment The comment object.
*/
public function column_response( $comment ) {
@ -778,7 +805,6 @@ class WP_Comments_List_Table extends WP_List_Table {
}
/**
*
* @param WP_Comment $comment The comment object.
* @param string $column_name The custom column's name.
*/

View File

@ -203,7 +203,7 @@ class WP_Community_Events {
// Wrap the args in an array compatible with the second parameter of `wp_remote_get()`.
return array(
'body' => $args
'body' => $args,
);
}
@ -463,11 +463,13 @@ class WP_Community_Events {
return;
}
error_log( sprintf(
error_log(
sprintf(
'%s: %s. Details: %s',
__METHOD__,
trim( $message, '.' ),
wp_json_encode( $details )
) );
)
);
}
}

View File

@ -55,8 +55,9 @@ class WP_Filesystem_Base {
public function abspath() {
$folder = $this->find_folder( ABSPATH );
// Perhaps the FTP folder is rooted at the WordPress install, Check for wp-includes folder in root, Could have some false positives, but rare.
if ( ! $folder && $this->is_dir( '/' . WPINC ) )
if ( ! $folder && $this->is_dir( '/' . WPINC ) ) {
$folder = '/';
}
return $folder;
}
@ -94,8 +95,9 @@ class WP_Filesystem_Base {
$theme_root = get_theme_root( $theme );
// Account for relative theme roots
if ( '/themes' == $theme_root || ! is_dir( $theme_root ) )
if ( '/themes' == $theme_root || ! is_dir( $theme_root ) ) {
$theme_root = WP_CONTENT_DIR . $theme_root;
}
return $this->find_folder( $theme_root );
}
@ -166,29 +168,33 @@ class WP_Filesystem_Base {
* @return string|false The location of the remote path, false on failure.
*/
public function find_folder( $folder ) {
if ( isset( $this->cache[ $folder ] ) )
if ( isset( $this->cache[ $folder ] ) ) {
return $this->cache[ $folder ];
}
if ( stripos( $this->method, 'ftp' ) !== false ) {
$constant_overrides = array(
'FTP_BASE' => ABSPATH,
'FTP_CONTENT_DIR' => WP_CONTENT_DIR,
'FTP_PLUGIN_DIR' => WP_PLUGIN_DIR,
'FTP_LANG_DIR' => WP_LANG_DIR
'FTP_LANG_DIR' => WP_LANG_DIR,
);
// Direct matches ( folder = CONSTANT/ )
foreach ( $constant_overrides as $constant => $dir ) {
if ( ! defined( $constant ) )
if ( ! defined( $constant ) ) {
continue;
if ( $folder === $dir )
}
if ( $folder === $dir ) {
return trailingslashit( constant( $constant ) );
}
}
// Prefix Matches ( folder = CONSTANT/subdir )
foreach ( $constant_overrides as $constant => $dir ) {
if ( ! defined( $constant ) )
if ( ! defined( $constant ) ) {
continue;
}
if ( 0 === stripos( $folder, $dir ) ) { // $folder starts with $dir
$potential_folder = preg_replace( '#^' . preg_quote( $dir, '#' ) . '/#i', trailingslashit( constant( $constant ) ), $folder );
$potential_folder = trailingslashit( $potential_folder );
@ -207,16 +213,18 @@ class WP_Filesystem_Base {
$folder = preg_replace( '|^([a-z]{1}):|i', '', $folder ); // Strip out windows drive letter if it's there.
$folder = str_replace( '\\', '/', $folder ); // Windows path sanitisation
if ( isset($this->cache[ $folder ] ) )
if ( isset( $this->cache[ $folder ] ) ) {
return $this->cache[ $folder ];
}
if ( $this->exists( $folder ) ) { // Folder exists at that absolute path.
$folder = trailingslashit( $folder );
$this->cache[ $folder ] = $folder;
return $folder;
}
if ( $return = $this->search_for_folder($folder) )
if ( $return = $this->search_for_folder( $folder ) ) {
$this->cache[ $folder ] = $return;
}
return $return;
}
@ -233,8 +241,9 @@ class WP_Filesystem_Base {
* @return string|false The location of the remote path, false to cease looping.
*/
public function search_for_folder( $folder, $base = '.', $loop = false ) {
if ( empty( $base ) || '.' == $base )
if ( empty( $base ) || '.' == $base ) {
$base = trailingslashit( $this->cwd() );
}
$folder = untrailingslashit( $folder );
@ -251,8 +260,9 @@ class WP_Filesystem_Base {
$files = $this->dirlist( $base );
foreach ( $folder_parts as $index => $key ) {
if ( $index == $last_index )
if ( $index == $last_index ) {
continue; // We want this to be caught by the next code block.
}
/*
* Working from /home/ to /user/ to /wordpress/ see if that file exists within
@ -272,10 +282,11 @@ class WP_Filesystem_Base {
// Only search for the remaining path tokens in the directory, not the full path again.
$newfolder = implode( '/', array_slice( $folder_parts, $index + 1 ) );
if ( $ret = $this->search_for_folder( $newfolder, $newdir, $loop) )
if ( $ret = $this->search_for_folder( $newfolder, $newdir, $loop ) ) {
return $ret;
}
}
}
// Only check this as a last resort, to prevent locating the incorrect install.
// All above procedures will fail quickly if this is the right branch to take.
@ -289,8 +300,9 @@ class WP_Filesystem_Base {
// Prevent this function from looping again.
// No need to proceed if we've just searched in /
if ( $loop || '/' == $base )
if ( $loop || '/' == $base ) {
return false;
}
// As an extra last resort, Change back to / if the folder wasn't found.
// This comes into effect when the CWD is /home/user/ but WP is at /var/www/....
@ -312,22 +324,23 @@ class WP_Filesystem_Base {
*/
public function gethchmod( $file ) {
$perms = intval( $this->getchmod( $file ), 8 );
if (($perms & 0xC000) == 0xC000) // Socket
if ( ( $perms & 0xC000 ) == 0xC000 ) { // Socket
$info = 's';
elseif (($perms & 0xA000) == 0xA000) // Symbolic Link
} elseif ( ( $perms & 0xA000 ) == 0xA000 ) { // Symbolic Link
$info = 'l';
elseif (($perms & 0x8000) == 0x8000) // Regular
} elseif ( ( $perms & 0x8000 ) == 0x8000 ) { // Regular
$info = '-';
elseif (($perms & 0x6000) == 0x6000) // Block special
} elseif ( ( $perms & 0x6000 ) == 0x6000 ) { // Block special
$info = 'b';
elseif (($perms & 0x4000) == 0x4000) // Directory
} elseif ( ( $perms & 0x4000 ) == 0x4000 ) { // Directory
$info = 'd';
elseif (($perms & 0x2000) == 0x2000) // Character special
} elseif ( ( $perms & 0x2000 ) == 0x2000 ) { // Character special
$info = 'c';
elseif (($perms & 0x1000) == 0x1000) // FIFO pipe
} elseif ( ( $perms & 0x1000 ) == 0x1000 ) { // FIFO pipe
$info = 'p';
else // Unknown
} else { // Unknown
$info = 'u';
}
// Owner
$info .= ( ( $perms & 0x0100 ) ? 'r' : '-' );
@ -388,7 +401,12 @@ class WP_Filesystem_Base {
}
$mode = str_pad( $realmode, 10, '-', STR_PAD_LEFT );
$trans = array('-'=>'0', 'r'=>'4', 'w'=>'2', 'x'=>'1');
$trans = array(
'-' => '0',
'r' => '4',
'w' => '2',
'x' => '1',
);
$mode = strtr( $mode, $trans );
$newmode = $mode[0];

View File

@ -18,7 +18,6 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
/**
* constructor
*
*
* @param mixed $arg ignored argument
*/
public function __construct( $arg ) {
@ -29,7 +28,6 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
/**
* Reads entire file into a string
*
*
* @param string $file Name of the file to read.
* @return string|bool The function returns the read data or false on failure.
*/
@ -40,7 +38,6 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
/**
* Reads entire file into an array
*
*
* @param string $file Path to the file.
* @return array|bool the file contents in an array or false on failure.
*/
@ -51,7 +48,6 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
/**
* Write a string to a file
*
*
* @param string $file Remote path to the file where to write the data.
* @param string $contents The data to write.
* @param int $mode Optional. The file permissions as octal number, usually 0644.
@ -60,8 +56,9 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
*/
public function put_contents( $file, $contents, $mode = false ) {
$fp = @fopen( $file, 'wb' );
if ( ! $fp )
if ( ! $fp ) {
return false;
}
mbstring_binary_safe_encoding();
@ -73,8 +70,9 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
fclose( $fp );
if ( $data_length !== $bytes_written )
if ( $data_length !== $bytes_written ) {
return false;
}
$this->chmod( $file, $mode );
@ -84,7 +82,6 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
/**
* Gets the current working directory
*
*
* @return string|bool the current working directory on success, or false on failure.
*/
public function cwd() {
@ -94,7 +91,6 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
/**
* Change directory
*
*
* @param string $dir The new current directory.
* @return bool Returns true on success or false on failure.
*/
@ -105,24 +101,27 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
/**
* Changes file group
*
*
* @param string $file Path to the file.
* @param mixed $group A group name or number.
* @param bool $recursive Optional. If set True changes file group recursively. Default false.
* @return bool Returns true on success or false on failure.
*/
public function chgrp( $file, $group, $recursive = false ) {
if ( ! $this->exists($file) )
if ( ! $this->exists( $file ) ) {
return false;
if ( ! $recursive )
}
if ( ! $recursive ) {
return @chgrp( $file, $group );
if ( ! $this->is_dir($file) )
}
if ( ! $this->is_dir( $file ) ) {
return @chgrp( $file, $group );
}
// Is a directory, and we want recursive
$file = trailingslashit( $file );
$filelist = $this->dirlist( $file );
foreach ($filelist as $filename)
foreach ( $filelist as $filename ) {
$this->chgrp( $file . $filename, $group, $recursive );
}
return true;
}
@ -130,7 +129,6 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
/**
* Changes filesystem permissions
*
*
* @param string $file Path to the file.
* @param int $mode Optional. The permissions as octal number, usually 0644 for files,
* 0755 for dirs. Default false.
@ -139,21 +137,24 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
*/
public function chmod( $file, $mode = false, $recursive = false ) {
if ( ! $mode ) {
if ( $this->is_file($file) )
if ( $this->is_file( $file ) ) {
$mode = FS_CHMOD_FILE;
elseif ( $this->is_dir($file) )
} elseif ( $this->is_dir( $file ) ) {
$mode = FS_CHMOD_DIR;
else
} else {
return false;
}
}
if ( ! $recursive || ! $this->is_dir($file) )
if ( ! $recursive || ! $this->is_dir( $file ) ) {
return @chmod( $file, $mode );
}
// Is a directory, and we want recursive
$file = trailingslashit( $file );
$filelist = $this->dirlist( $file );
foreach ( (array)$filelist as $filename => $filemeta)
foreach ( (array) $filelist as $filename => $filemeta ) {
$this->chmod( $file . $filename, $mode, $recursive );
}
return true;
}
@ -161,7 +162,6 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
/**
* Changes file owner
*
*
* @param string $file Path to the file.
* @param mixed $owner A user name or number.
* @param bool $recursive Optional. If set True changes file owner recursively.
@ -169,12 +169,15 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
* @return bool Returns true on success or false on failure.
*/
public function chown( $file, $owner, $recursive = false ) {
if ( ! $this->exists($file) )
if ( ! $this->exists( $file ) ) {
return false;
if ( ! $recursive )
}
if ( ! $recursive ) {
return @chown( $file, $owner );
if ( ! $this->is_dir($file) )
}
if ( ! $this->is_dir( $file ) ) {
return @chown( $file, $owner );
}
// Is a directory, and we want recursive
$filelist = $this->dirlist( $file );
foreach ( $filelist as $filename ) {
@ -186,16 +189,17 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
/**
* Gets file owner
*
*
* @param string $file Path to the file.
* @return string|bool Username of the user or false on error.
*/
public function owner( $file ) {
$owneruid = @fileowner( $file );
if ( ! $owneruid )
if ( ! $owneruid ) {
return false;
if ( ! function_exists('posix_getpwuid') )
}
if ( ! function_exists( 'posix_getpwuid' ) ) {
return $owneruid;
}
$ownerarray = posix_getpwuid( $owneruid );
return $ownerarray['name'];
}
@ -205,7 +209,6 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
*
* FIXME does not handle errors in fileperms()
*
*
* @param string $file Path to the file.
* @return string Mode of the file (last 3 digits).
*/
@ -214,22 +217,22 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @return string|false
*/
public function group( $file ) {
$gid = @filegroup( $file );
if ( ! $gid )
if ( ! $gid ) {
return false;
if ( ! function_exists('posix_getgrgid') )
}
if ( ! function_exists( 'posix_getgrgid' ) ) {
return $gid;
}
$grouparray = posix_getgrgid( $gid );
return $grouparray['name'];
}
/**
*
* @param string $source
* @param string $destination
* @param bool $overwrite
@ -237,29 +240,32 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
* @return bool
*/
public function copy( $source, $destination, $overwrite = false, $mode = false ) {
if ( ! $overwrite && $this->exists($destination) )
if ( ! $overwrite && $this->exists( $destination ) ) {
return false;
}
$rtval = copy( $source, $destination );
if ( $mode )
if ( $mode ) {
$this->chmod( $destination, $mode );
}
return $rtval;
}
/**
*
* @param string $source
* @param string $destination
* @param bool $overwrite
* @return bool
*/
public function move( $source, $destination, $overwrite = false ) {
if ( ! $overwrite && $this->exists($destination) )
if ( ! $overwrite && $this->exists( $destination ) ) {
return false;
}
// Try using rename first. if that fails (for example, source is read only) try copy.
if ( @rename($source, $destination) )
if ( @rename( $source, $destination ) ) {
return true;
}
if ( $this->copy( $source, $destination, $overwrite ) && $this->exists( $destination ) ) {
$this->delete( $source );
@ -270,21 +276,23 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @param bool $recursive
* @param string $type
* @return bool
*/
public function delete( $file, $recursive = false, $type = false ) {
if ( empty( $file ) ) // Some filesystems report this as /, which can cause non-expected recursive deletion of all files in the filesystem.
if ( empty( $file ) ) { // Some filesystems report this as /, which can cause non-expected recursive deletion of all files in the filesystem.
return false;
}
$file = str_replace( '\\', '/', $file ); // for win32, occasional problems deleting files otherwise
if ( 'f' == $type || $this->is_file($file) )
if ( 'f' == $type || $this->is_file( $file ) ) {
return @unlink( $file );
if ( ! $recursive && $this->is_dir($file) )
}
if ( ! $recursive && $this->is_dir( $file ) ) {
return @rmdir( $file );
}
// At this point it's a folder, and we're in recursive mode
$file = trailingslashit( $file );
@ -293,18 +301,19 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
$retval = true;
if ( is_array( $filelist ) ) {
foreach ( $filelist as $filename => $fileinfo ) {
if ( ! $this->delete($file . $filename, $recursive, $fileinfo['type']) )
if ( ! $this->delete( $file . $filename, $recursive, $fileinfo['type'] ) ) {
$retval = false;
}
}
}
if ( file_exists($file) && ! @rmdir($file) )
if ( file_exists( $file ) && ! @rmdir( $file ) ) {
$retval = false;
}
return $retval;
}
/**
*
* @param string $file
* @return bool
*/
@ -312,7 +321,6 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
return @file_exists( $file );
}
/**
*
* @param string $file
* @return bool
*/
@ -320,7 +328,6 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
return @is_file( $file );
}
/**
*
* @param string $path
* @return bool
*/
@ -329,7 +336,6 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @return bool
*/
@ -338,7 +344,6 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @return bool
*/
@ -347,7 +352,6 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @return int
*/
@ -356,7 +360,6 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @return int
*/
@ -365,7 +368,6 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @return int
*/
@ -374,22 +376,22 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @param int $time
* @param int $atime
* @return bool
*/
public function touch( $file, $time = 0, $atime = 0 ) {
if ($time == 0)
if ( $time == 0 ) {
$time = time();
if ($atime == 0)
}
if ( $atime == 0 ) {
$atime = time();
}
return @touch( $file, $time, $atime );
}
/**
*
* @param string $path
* @param mixed $chmod
* @param mixed $chown
@ -399,24 +401,28 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
public function mkdir( $path, $chmod = false, $chown = false, $chgrp = false ) {
// Safe mode fails with a trailing slash under certain PHP versions.
$path = untrailingslashit( $path );
if ( empty($path) )
if ( empty( $path ) ) {
return false;
}
if ( ! $chmod )
if ( ! $chmod ) {
$chmod = FS_CHMOD_DIR;
}
if ( ! @mkdir($path) )
if ( ! @mkdir( $path ) ) {
return false;
}
$this->chmod( $path, $chmod );
if ( $chown )
if ( $chown ) {
$this->chown( $path, $chown );
if ( $chgrp )
}
if ( $chgrp ) {
$this->chgrp( $path, $chgrp );
}
return true;
}
/**
*
* @param string $path
* @param bool $recursive
* @return bool
@ -426,7 +432,6 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
}
/**
*
* @param string $path
* @param bool $include_hidden
* @param bool $recursive
@ -440,12 +445,14 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
$limit_file = false;
}
if ( ! $this->is_dir($path) )
if ( ! $this->is_dir( $path ) ) {
return false;
}
$dir = @dir( $path );
if ( ! $dir )
if ( ! $dir ) {
return false;
}
$ret = array();
@ -453,14 +460,17 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
$struc = array();
$struc['name'] = $entry;
if ( '.' == $struc['name'] || '..' == $struc['name'] )
if ( '.' == $struc['name'] || '..' == $struc['name'] ) {
continue;
}
if ( ! $include_hidden && '.' == $struc['name'][0] )
if ( ! $include_hidden && '.' == $struc['name'][0] ) {
continue;
}
if ( $limit_file && $struc['name'] != $limit_file)
if ( $limit_file && $struc['name'] != $limit_file ) {
continue;
}
$struc['perms'] = $this->gethchmod( $path . '/' . $entry );
$struc['permsn'] = $this->getnumchmodfromh( $struc['perms'] );
@ -474,11 +484,12 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
$struc['type'] = $this->is_dir( $path . '/' . $entry ) ? 'd' : 'f';
if ( 'd' == $struc['type'] ) {
if ( $recursive )
if ( $recursive ) {
$struc['files'] = $this->dirlist( $path . '/' . $struc['name'], $include_hidden, $recursive );
else
} else {
$struc['files'] = array();
}
}
$ret[ $struc['name'] ] = $struc;
}

View File

@ -17,7 +17,6 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
public $link;
/**
*
* @param array $opt
*/
public function __construct( $opt = '' ) {
@ -32,49 +31,57 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
// This Class uses the timeout on a per-connection basis, Others use it on a per-action basis.
if ( ! defined('FS_TIMEOUT') )
if ( ! defined( 'FS_TIMEOUT' ) ) {
define( 'FS_TIMEOUT', 240 );
}
if ( empty($opt['port']) )
if ( empty( $opt['port'] ) ) {
$this->options['port'] = 21;
else
} else {
$this->options['port'] = $opt['port'];
}
if ( empty($opt['hostname']) )
if ( empty( $opt['hostname'] ) ) {
$this->errors->add( 'empty_hostname', __( 'FTP hostname is required' ) );
else
} else {
$this->options['hostname'] = $opt['hostname'];
}
// Check if the options provided are OK.
if ( empty($opt['username']) )
if ( empty( $opt['username'] ) ) {
$this->errors->add( 'empty_username', __( 'FTP username is required' ) );
else
} else {
$this->options['username'] = $opt['username'];
}
if ( empty($opt['password']) )
if ( empty( $opt['password'] ) ) {
$this->errors->add( 'empty_password', __( 'FTP password is required' ) );
else
} else {
$this->options['password'] = $opt['password'];
}
$this->options['ssl'] = false;
if ( isset($opt['connection_type']) && 'ftps' == $opt['connection_type'] )
if ( isset( $opt['connection_type'] ) && 'ftps' == $opt['connection_type'] ) {
$this->options['ssl'] = true;
}
}
/**
*
* @return bool
*/
public function connect() {
if ( isset($this->options['ssl']) && $this->options['ssl'] && function_exists('ftp_ssl_connect') )
if ( isset( $this->options['ssl'] ) && $this->options['ssl'] && function_exists( 'ftp_ssl_connect' ) ) {
$this->link = @ftp_ssl_connect( $this->options['hostname'], $this->options['port'], FS_CONNECT_TIMEOUT );
else
} else {
$this->link = @ftp_connect( $this->options['hostname'], $this->options['port'], FS_CONNECT_TIMEOUT );
}
if ( ! $this->link ) {
$this->errors->add( 'connect',
$this->errors->add(
'connect',
/* translators: %s: hostname:port */
sprintf( __( 'Failed to connect to FTP Server %s' ),
sprintf(
__( 'Failed to connect to FTP Server %s' ),
$this->options['hostname'] . ':' . $this->options['port']
)
);
@ -82,9 +89,11 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
}
if ( ! @ftp_login( $this->link, $this->options['username'], $this->options['password'] ) ) {
$this->errors->add( 'auth',
$this->errors->add(
'auth',
/* translators: %s: username */
sprintf( __( 'Username/Password incorrect for %s' ),
sprintf(
__( 'Username/Password incorrect for %s' ),
$this->options['username']
)
);
@ -93,8 +102,9 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
// Set the Connection to use Passive FTP
@ftp_pasv( $this->link, true );
if ( @ftp_get_option($this->link, FTP_TIMEOUT_SEC) < FS_TIMEOUT )
if ( @ftp_get_option( $this->link, FTP_TIMEOUT_SEC ) < FS_TIMEOUT ) {
@ftp_set_option( $this->link, FTP_TIMEOUT_SEC, FS_TIMEOUT );
}
return true;
}
@ -126,8 +136,9 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
fseek( $temp, 0 ); // Skip back to the start of the file being written to
$contents = '';
while ( ! feof($temp) )
while ( ! feof( $temp ) ) {
$contents .= fread( $temp, 8192 );
}
fclose( $temp );
unlink( $tempfile );
@ -135,7 +146,6 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @return array
*/
@ -144,7 +154,6 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @param string $contents
* @param bool|int $mode
@ -185,18 +194,17 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
}
/**
*
* @return string
*/
public function cwd() {
$cwd = @ftp_pwd( $this->link );
if ( $cwd )
if ( $cwd ) {
$cwd = trailingslashit( $cwd );
}
return $cwd;
}
/**
*
* @param string $dir
* @return bool
*/
@ -205,7 +213,6 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @param int $mode
* @param bool $recursive
@ -213,29 +220,31 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
*/
public function chmod( $file, $mode = false, $recursive = false ) {
if ( ! $mode ) {
if ( $this->is_file($file) )
if ( $this->is_file( $file ) ) {
$mode = FS_CHMOD_FILE;
elseif ( $this->is_dir($file) )
} elseif ( $this->is_dir( $file ) ) {
$mode = FS_CHMOD_DIR;
else
} else {
return false;
}
}
// chmod any sub-objects if recursive.
if ( $recursive && $this->is_dir( $file ) ) {
$filelist = $this->dirlist( $file );
foreach ( (array)$filelist as $filename => $filemeta )
foreach ( (array) $filelist as $filename => $filemeta ) {
$this->chmod( $file . '/' . $filename, $mode, $recursive );
}
}
// chmod the file or directory
if ( ! function_exists('ftp_chmod') )
if ( ! function_exists( 'ftp_chmod' ) ) {
return (bool) @ftp_site( $this->link, sprintf( 'CHMOD %o %s', $mode, $file ) );
}
return (bool) @ftp_chmod( $this->link, $mode, $file );
}
/**
*
* @param string $file
* @return string
*/
@ -244,7 +253,6 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
return $dir[ $file ]['owner'];
}
/**
*
* @param string $file
* @return string
*/
@ -254,7 +262,6 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @return string
*/
@ -264,7 +271,6 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
}
/**
*
* @param string $source
* @param string $destination
* @param bool $overwrite
@ -272,16 +278,17 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
* @return bool
*/
public function copy( $source, $destination, $overwrite = false, $mode = false ) {
if ( ! $overwrite && $this->exists($destination) )
if ( ! $overwrite && $this->exists( $destination ) ) {
return false;
}
$content = $this->get_contents( $source );
if ( false === $content )
if ( false === $content ) {
return false;
}
return $this->put_contents( $destination, $content, $mode );
}
/**
*
* @param string $source
* @param string $destination
* @param bool $overwrite
@ -292,29 +299,32 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @param bool $recursive
* @param string $type
* @return bool
*/
public function delete( $file, $recursive = false, $type = false ) {
if ( empty($file) )
if ( empty( $file ) ) {
return false;
if ( 'f' == $type || $this->is_file($file) )
}
if ( 'f' == $type || $this->is_file( $file ) ) {
return @ftp_delete( $this->link, $file );
if ( !$recursive )
}
if ( ! $recursive ) {
return @ftp_rmdir( $this->link, $file );
}
$filelist = $this->dirlist( trailingslashit( $file ) );
if ( !empty($filelist) )
foreach ( $filelist as $delete_file )
if ( ! empty( $filelist ) ) {
foreach ( $filelist as $delete_file ) {
$this->delete( trailingslashit( $file ) . $delete_file['name'], $recursive, $delete_file['type'] );
}
}
return @ftp_rmdir( $this->link, $file );
}
/**
*
* @param string $file
* @return bool
*/
@ -329,7 +339,6 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @return bool
*/
@ -338,7 +347,6 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
}
/**
*
* @param string $path
* @return bool
*/
@ -353,7 +361,6 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @return bool
*/
@ -362,7 +369,6 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @return bool
*/
@ -371,7 +377,6 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @return bool
*/
@ -380,7 +385,6 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @return int
*/
@ -389,7 +393,6 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @return int
*/
@ -398,7 +401,6 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @return bool
*/
@ -407,7 +409,6 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
}
/**
*
* @param string $path
* @param mixed $chmod
* @param mixed $chown
@ -416,17 +417,18 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
*/
public function mkdir( $path, $chmod = false, $chown = false, $chgrp = false ) {
$path = untrailingslashit( $path );
if ( empty($path) )
if ( empty( $path ) ) {
return false;
}
if ( !@ftp_mkdir($this->link, $path) )
if ( ! @ftp_mkdir( $this->link, $path ) ) {
return false;
}
$this->chmod( $path, $chmod );
return true;
}
/**
*
* @param string $path
* @param bool $recursive
* @return bool
@ -436,50 +438,54 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
}
/**
*
* @staticvar bool $is_windows
* @param string $line
* @return array
*/
public function parselisting( $line ) {
static $is_windows = null;
if ( is_null($is_windows) )
if ( is_null( $is_windows ) ) {
$is_windows = stripos( ftp_systype( $this->link ), 'win' ) !== false;
}
if ( $is_windows && preg_match( '/([0-9]{2})-([0-9]{2})-([0-9]{2}) +([0-9]{2}):([0-9]{2})(AM|PM) +([0-9]+|<DIR>) +(.+)/', $line, $lucifer ) ) {
$b = array();
if ( $lucifer[3] < 70 )
if ( $lucifer[3] < 70 ) {
$lucifer[3] += 2000;
else
} else {
$lucifer[3] += 1900; // 4digit year fix
}
$b['isdir'] = ( $lucifer[7] == '<DIR>' );
if ( $b['isdir'] )
if ( $b['isdir'] ) {
$b['type'] = 'd';
else
} else {
$b['type'] = 'f';
}
$b['size'] = $lucifer[7];
$b['month'] = $lucifer[1];
$b['day'] = $lucifer[2];
$b['year'] = $lucifer[3];
$b['hour'] = $lucifer[4];
$b['minute'] = $lucifer[5];
$b['time'] = @mktime($lucifer[4] + (strcasecmp($lucifer[6], "PM") == 0 ? 12 : 0), $lucifer[5], 0, $lucifer[1], $lucifer[2], $lucifer[3]);
$b['time'] = @mktime( $lucifer[4] + ( strcasecmp( $lucifer[6], 'PM' ) == 0 ? 12 : 0 ), $lucifer[5], 0, $lucifer[1], $lucifer[2], $lucifer[3] );
$b['am/pm'] = $lucifer[6];
$b['name'] = $lucifer[8];
} elseif ( ! $is_windows && $lucifer = preg_split( '/[ ]/', $line, 9, PREG_SPLIT_NO_EMPTY ) ) {
//echo $line."\n";
$lcount = count( $lucifer );
if ( $lcount < 8 )
if ( $lcount < 8 ) {
return '';
}
$b = array();
$b['isdir'] = $lucifer[0]{0} === 'd';
$b['islink'] = $lucifer[0]{0} === 'l';
if ( $b['isdir'] )
if ( $b['isdir'] ) {
$b['type'] = 'd';
elseif ( $b['islink'] )
} elseif ( $b['islink'] ) {
$b['type'] = 'l';
else
} else {
$b['type'] = 'f';
}
$b['perms'] = $lucifer[0];
$b['permsn'] = $this->getnumchmodfromh( $b['perms'] );
$b['number'] = $lucifer[1];
@ -495,7 +501,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
$b['month'] = $lucifer[5];
$b['day'] = $lucifer[6];
if ( preg_match( '/([0-9]{2}):([0-9]{2})/', $lucifer[7], $l2 ) ) {
$b['year'] = date("Y");
$b['year'] = date( 'Y' );
$b['hour'] = $l2[1];
$b['minute'] = $l2[2];
} else {
@ -517,7 +523,6 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
}
/**
*
* @param string $path
* @param bool $include_hidden
* @param bool $recursive
@ -532,28 +537,34 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
}
$pwd = @ftp_pwd( $this->link );
if ( ! @ftp_chdir($this->link, $path) ) // Cant change to folder = folder doesn't exist
if ( ! @ftp_chdir( $this->link, $path ) ) { // Cant change to folder = folder doesn't exist
return false;
}
$list = @ftp_rawlist( $this->link, '-a', false );
@ftp_chdir( $this->link, $pwd );
if ( empty($list) ) // Empty array = non-existent folder (real folder will show . at least)
if ( empty( $list ) ) { // Empty array = non-existent folder (real folder will show . at least)
return false;
}
$dirlist = array();
foreach ( $list as $k => $v ) {
$entry = $this->parselisting( $v );
if ( empty($entry) )
if ( empty( $entry ) ) {
continue;
}
if ( '.' == $entry['name'] || '..' == $entry['name'] )
if ( '.' == $entry['name'] || '..' == $entry['name'] ) {
continue;
}
if ( ! $include_hidden && '.' == $entry['name'][0] )
if ( ! $include_hidden && '.' == $entry['name'][0] ) {
continue;
}
if ( $limit_file && $entry['name'] != $limit_file)
if ( $limit_file && $entry['name'] != $limit_file ) {
continue;
}
$dirlist[ $entry['name'] ] = $entry;
}
@ -561,11 +572,12 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
$ret = array();
foreach ( (array) $dirlist as $struc ) {
if ( 'd' == $struc['type'] ) {
if ( $recursive )
if ( $recursive ) {
$struc['files'] = $this->dirlist( $path . '/' . $struc['name'], $include_hidden, $recursive );
else
} else {
$struc['files'] = array();
}
}
$ret[ $struc['name'] ] = $struc;
}
@ -575,7 +587,8 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
/**
*/
public function __destruct() {
if ( $this->link )
if ( $this->link ) {
ftp_close( $this->link );
}
}
}

View File

@ -20,7 +20,6 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
public $ftp;
/**
*
* @param array $opt
*/
public function __construct( $opt = '' ) {
@ -33,42 +32,48 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
}
$this->ftp = new ftp();
if ( empty($opt['port']) )
if ( empty( $opt['port'] ) ) {
$this->options['port'] = 21;
else
} else {
$this->options['port'] = (int) $opt['port'];
}
if ( empty($opt['hostname']) )
if ( empty( $opt['hostname'] ) ) {
$this->errors->add( 'empty_hostname', __( 'FTP hostname is required' ) );
else
} else {
$this->options['hostname'] = $opt['hostname'];
}
// Check if the options provided are OK.
if ( empty ($opt['username']) )
if ( empty( $opt['username'] ) ) {
$this->errors->add( 'empty_username', __( 'FTP username is required' ) );
else
} else {
$this->options['username'] = $opt['username'];
}
if ( empty ($opt['password']) )
if ( empty( $opt['password'] ) ) {
$this->errors->add( 'empty_password', __( 'FTP password is required' ) );
else
} else {
$this->options['password'] = $opt['password'];
}
}
/**
*
* @return bool
*/
public function connect() {
if ( ! $this->ftp )
if ( ! $this->ftp ) {
return false;
}
$this->ftp->setTimeout( FS_CONNECT_TIMEOUT );
if ( ! $this->ftp->SetServer( $this->options['hostname'], $this->options['port'] ) ) {
$this->errors->add( 'connect',
$this->errors->add(
'connect',
/* translators: %s: hostname:port */
sprintf( __( 'Failed to connect to FTP Server %s' ),
sprintf(
__( 'Failed to connect to FTP Server %s' ),
$this->options['hostname'] . ':' . $this->options['port']
)
);
@ -76,9 +81,11 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
}
if ( ! $this->ftp->connect() ) {
$this->errors->add( 'connect',
$this->errors->add(
'connect',
/* translators: %s: hostname:port */
sprintf( __( 'Failed to connect to FTP Server %s' ),
sprintf(
__( 'Failed to connect to FTP Server %s' ),
$this->options['hostname'] . ':' . $this->options['port']
)
);
@ -86,9 +93,11 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
}
if ( ! $this->ftp->login( $this->options['username'], $this->options['password'] ) ) {
$this->errors->add( 'auth',
$this->errors->add(
'auth',
/* translators: %s: username */
sprintf( __( 'Username/Password incorrect for %s' ),
sprintf(
__( 'Username/Password incorrect for %s' ),
$this->options['username']
)
);
@ -111,8 +120,9 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
* or if the file doesn't exist.
*/
public function get_contents( $file ) {
if ( ! $this->exists($file) )
if ( ! $this->exists( $file ) ) {
return false;
}
$temp = wp_tempnam( $file );
@ -137,8 +147,9 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
fseek( $temphandle, 0 ); // Skip back to the start of the file being written to
$contents = '';
while ( ! feof($temphandle) )
while ( ! feof( $temphandle ) ) {
$contents .= fread( $temphandle, 8192 );
}
fclose( $temphandle );
unlink( $temp );
@ -146,7 +157,6 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @return array
*/
@ -155,7 +165,6 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @param string $contents
* @param int|bool $mode
@ -196,18 +205,17 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
}
/**
*
* @return string
*/
public function cwd() {
$cwd = $this->ftp->pwd();
if ( $cwd )
if ( $cwd ) {
$cwd = trailingslashit( $cwd );
}
return $cwd;
}
/**
*
* @param string $file
* @return bool
*/
@ -216,7 +224,6 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @param int|bool $mode
* @param bool $recursive
@ -224,27 +231,28 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
*/
public function chmod( $file, $mode = false, $recursive = false ) {
if ( ! $mode ) {
if ( $this->is_file($file) )
if ( $this->is_file( $file ) ) {
$mode = FS_CHMOD_FILE;
elseif ( $this->is_dir($file) )
} elseif ( $this->is_dir( $file ) ) {
$mode = FS_CHMOD_DIR;
else
} else {
return false;
}
}
// chmod any sub-objects if recursive.
if ( $recursive && $this->is_dir( $file ) ) {
$filelist = $this->dirlist( $file );
foreach ( (array)$filelist as $filename => $filemeta )
foreach ( (array) $filelist as $filename => $filemeta ) {
$this->chmod( $file . '/' . $filename, $mode, $recursive );
}
}
// chmod the file or directory
return $this->ftp->chmod( $file, $mode );
}
/**
*
* @param string $file
* @return string
*/
@ -254,7 +262,6 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @return string
*/
@ -264,7 +271,6 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @return string
*/
@ -274,7 +280,6 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
}
/**
*
* @param string $source
* @param string $destination
* @param bool $overwrite
@ -282,18 +287,19 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
* @return bool
*/
public function copy( $source, $destination, $overwrite = false, $mode = false ) {
if ( ! $overwrite && $this->exists($destination) )
if ( ! $overwrite && $this->exists( $destination ) ) {
return false;
}
$content = $this->get_contents( $source );
if ( false === $content )
if ( false === $content ) {
return false;
}
return $this->put_contents( $destination, $content, $mode );
}
/**
*
* @param string $source
* @param string $destination
* @param bool $overwrite
@ -304,25 +310,26 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @param bool $recursive
* @param string $type
* @return bool
*/
public function delete( $file, $recursive = false, $type = false ) {
if ( empty($file) )
if ( empty( $file ) ) {
return false;
if ( 'f' == $type || $this->is_file($file) )
}
if ( 'f' == $type || $this->is_file( $file ) ) {
return $this->ftp->delete( $file );
if ( !$recursive )
}
if ( ! $recursive ) {
return $this->ftp->rmdir( $file );
}
return $this->ftp->mdel( $file );
}
/**
*
* @param string $file
* @return bool
*/
@ -338,20 +345,20 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @return bool
*/
public function is_file( $file ) {
if ( $this->is_dir($file) )
if ( $this->is_dir( $file ) ) {
return false;
if ( $this->exists($file) )
}
if ( $this->exists( $file ) ) {
return true;
}
return false;
}
/**
*
* @param string $path
* @return bool
*/
@ -365,7 +372,6 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @return bool
*/
@ -374,7 +380,6 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @return bool
*/
@ -383,7 +388,6 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @return bool
*/
@ -392,7 +396,6 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @return int
*/
@ -409,7 +412,6 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @param int $time
* @param int $atime
@ -420,7 +422,6 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
}
/**
*
* @param string $path
* @param mixed $chmod
* @param mixed $chown
@ -429,19 +430,21 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
*/
public function mkdir( $path, $chmod = false, $chown = false, $chgrp = false ) {
$path = untrailingslashit( $path );
if ( empty($path) )
if ( empty( $path ) ) {
return false;
}
if ( ! $this->ftp->mkdir($path) )
if ( ! $this->ftp->mkdir( $path ) ) {
return false;
if ( ! $chmod )
}
if ( ! $chmod ) {
$chmod = FS_CHMOD_DIR;
}
$this->chmod( $path, $chmod );
return true;
}
/**
*
* @param string $path
* @param bool $recursive
* @return bool
@ -451,7 +454,6 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
}
/**
*
* @param string $path
* @param bool $include_hidden
* @param bool $recursive
@ -478,25 +480,30 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
$ret = array();
foreach ( $list as $struc ) {
if ( '.' == $struc['name'] || '..' == $struc['name'] )
if ( '.' == $struc['name'] || '..' == $struc['name'] ) {
continue;
}
if ( ! $include_hidden && '.' == $struc['name'][0] )
if ( ! $include_hidden && '.' == $struc['name'][0] ) {
continue;
}
if ( $limit_file && $struc['name'] != $limit_file )
if ( $limit_file && $struc['name'] != $limit_file ) {
continue;
}
if ( 'd' == $struc['type'] ) {
if ( $recursive )
if ( $recursive ) {
$struc['files'] = $this->dirlist( $path . '/' . $struc['name'], $include_hidden, $recursive );
else
} else {
$struc['files'] = array();
}
}
// Replace symlinks formatted as "source -> target" with just the source name
if ( $struc['islink'] )
if ( $struc['islink'] ) {
$struc['name'] = preg_replace( '/(\s*->\s*.*)$/', '', $struc['name'] );
}
// Add the Octal representation of the file permissions
$struc['permsn'] = $this->getnumchmodfromh( $struc['perms'] );

View File

@ -46,7 +46,6 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
public $keys = false;
/**
*
* @param array $opt
*/
public function __construct( $opt = '' ) {
@ -71,15 +70,17 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
}
// Set defaults:
if ( empty($opt['port']) )
if ( empty( $opt['port'] ) ) {
$this->options['port'] = 22;
else
} else {
$this->options['port'] = $opt['port'];
}
if ( empty($opt['hostname']) )
if ( empty( $opt['hostname'] ) ) {
$this->errors->add( 'empty_hostname', __( 'SSH2 hostname is required' ) );
else
} else {
$this->options['hostname'] = $opt['hostname'];
}
// Check if the options provided are OK.
if ( ! empty( $opt['public_key'] ) && ! empty( $opt['private_key'] ) ) {
@ -93,20 +94,21 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
$this->errors->add( 'empty_username', __( 'SSH2 username is required' ) );
}
if ( !empty($opt['username']) )
if ( ! empty( $opt['username'] ) ) {
$this->options['username'] = $opt['username'];
}
if ( empty( $opt['password'] ) ) {
// Password can be blank if we are using keys.
if ( !$this->keys )
if ( ! $this->keys ) {
$this->errors->add( 'empty_password', __( 'SSH2 password is required' ) );
}
} else {
$this->options['password'] = $opt['password'];
}
}
/**
*
* @return bool
*/
public function connect() {
@ -117,9 +119,11 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
}
if ( ! $this->link ) {
$this->errors->add( 'connect',
$this->errors->add(
'connect',
/* translators: %s: hostname:port */
sprintf( __( 'Failed to connect to SSH2 Server %s' ),
sprintf(
__( 'Failed to connect to SSH2 Server %s' ),
$this->options['hostname'] . ':' . $this->options['port']
)
);
@ -128,9 +132,11 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
if ( ! $this->keys ) {
if ( ! @ssh2_auth_password( $this->link, $this->options['username'], $this->options['password'] ) ) {
$this->errors->add( 'auth',
$this->errors->add(
'auth',
/* translators: %s: username */
sprintf( __( 'Username/Password incorrect for %s' ),
sprintf(
__( 'Username/Password incorrect for %s' ),
$this->options['username']
)
);
@ -138,9 +144,11 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
}
} else {
if ( ! @ssh2_auth_pubkey_file( $this->link, $this->options['username'], $this->options['public_key'], $this->options['private_key'], $this->options['password'] ) ) {
$this->errors->add( 'auth',
$this->errors->add(
'auth',
/* translators: %s: username */
sprintf( __( 'Public and Private keys incorrect for %s' ),
sprintf(
__( 'Public and Private keys incorrect for %s' ),
$this->options['username']
)
);
@ -150,9 +158,11 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
$this->sftp_link = ssh2_sftp( $this->link );
if ( ! $this->sftp_link ) {
$this->errors->add( 'connect',
$this->errors->add(
'connect',
/* translators: %s: hostname:port */
sprintf( __( 'Failed to initialize a SFTP subsystem session with the SSH2 Server %s' ),
sprintf(
__( 'Failed to initialize a SFTP subsystem session with the SSH2 Server %s' ),
$this->options['hostname'] . ':' . $this->options['port']
)
);
@ -170,7 +180,6 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
* this, the path is converted to /./ which is semantically the same as /
* See https://bugs.php.net/bug.php?id=64169 for more details.
*
*
* @since 4.4.0
*
* @param string $path The File/Directory path on the remote server to return
@ -184,20 +193,22 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
}
/**
*
* @param string $command
* @param bool $returnbool
* @return bool|string True on success, false on failure. String if the command was executed, `$returnbool`
* is false (default), and data from the resulting stream was retrieved.
*/
public function run_command( $command, $returnbool = false ) {
if ( ! $this->link )
if ( ! $this->link ) {
return false;
}
if ( ! ( $stream = ssh2_exec( $this->link, $command ) ) ) {
$this->errors->add( 'command',
$this->errors->add(
'command',
/* translators: %s: command */
sprintf( __( 'Unable to perform command: %s'),
sprintf(
__( 'Unable to perform command: %s' ),
$command
)
);
@ -207,16 +218,16 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
$data = stream_get_contents( $stream );
fclose( $stream );
if ( $returnbool )
if ( $returnbool ) {
return ( $data === false ) ? false : '' != trim( $data );
else
} else {
return $data;
}
}
return false;
}
/**
*
* @param string $file
* @return string|false
*/
@ -225,7 +236,6 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @return array
*/
@ -234,7 +244,6 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @param string $contents
* @param bool|int $mode
@ -243,8 +252,9 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
public function put_contents( $file, $contents, $mode = false ) {
$ret = file_put_contents( $this->sftp_path( $file ), $contents );
if ( $ret !== strlen( $contents ) )
if ( $ret !== strlen( $contents ) ) {
return false;
}
$this->chmod( $file, $mode );
@ -252,7 +262,6 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
}
/**
*
* @return bool
*/
public function cwd() {
@ -264,7 +273,6 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
}
/**
*
* @param string $dir
* @return bool|string
*/
@ -273,7 +281,6 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @param string $group
* @param bool $recursive
@ -281,72 +288,77 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
* @return bool
*/
public function chgrp( $file, $group, $recursive = false ) {
if ( ! $this->exists($file) )
if ( ! $this->exists( $file ) ) {
return false;
if ( ! $recursive || ! $this->is_dir($file) )
}
if ( ! $recursive || ! $this->is_dir( $file ) ) {
return $this->run_command( sprintf( 'chgrp %s %s', escapeshellarg( $group ), escapeshellarg( $file ) ), true );
}
return $this->run_command( sprintf( 'chgrp -R %s %s', escapeshellarg( $group ), escapeshellarg( $file ) ), true );
}
/**
*
* @param string $file
* @param int $mode
* @param bool $recursive
* @return bool|string
*/
public function chmod( $file, $mode = false, $recursive = false ) {
if ( ! $this->exists($file) )
return false;
if ( ! $mode ) {
if ( $this->is_file($file) )
$mode = FS_CHMOD_FILE;
elseif ( $this->is_dir($file) )
$mode = FS_CHMOD_DIR;
else
if ( ! $this->exists( $file ) ) {
return false;
}
if ( ! $recursive || ! $this->is_dir($file) )
if ( ! $mode ) {
if ( $this->is_file( $file ) ) {
$mode = FS_CHMOD_FILE;
} elseif ( $this->is_dir( $file ) ) {
$mode = FS_CHMOD_DIR;
} else {
return false;
}
}
if ( ! $recursive || ! $this->is_dir( $file ) ) {
return $this->run_command( sprintf( 'chmod %o %s', $mode, escapeshellarg( $file ) ), true );
}
return $this->run_command( sprintf( 'chmod -R %o %s', $mode, escapeshellarg( $file ) ), true );
}
/**
* Change the ownership of a file / folder.
*
*
* @param string $file Path to the file.
* @param string|int $owner A user name or number.
* @param bool $recursive Optional. If set True changes file owner recursivly. Default False.
* @return bool True on success or false on failure.
*/
public function chown( $file, $owner, $recursive = false ) {
if ( ! $this->exists($file) )
if ( ! $this->exists( $file ) ) {
return false;
if ( ! $recursive || ! $this->is_dir($file) )
}
if ( ! $recursive || ! $this->is_dir( $file ) ) {
return $this->run_command( sprintf( 'chown %s %s', escapeshellarg( $owner ), escapeshellarg( $file ) ), true );
}
return $this->run_command( sprintf( 'chown -R %s %s', escapeshellarg( $owner ), escapeshellarg( $file ) ), true );
}
/**
*
* @param string $file
* @return string|false
*/
public function owner( $file ) {
$owneruid = @fileowner( $this->sftp_path( $file ) );
if ( ! $owneruid )
if ( ! $owneruid ) {
return false;
if ( ! function_exists('posix_getpwuid') )
}
if ( ! function_exists( 'posix_getpwuid' ) ) {
return $owneruid;
}
$ownerarray = posix_getpwuid( $owneruid );
return $ownerarray['name'];
}
/**
*
* @param string $file
* @return string
*/
@ -355,22 +367,22 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @return string|false
*/
public function group( $file ) {
$gid = @filegroup( $this->sftp_path( $file ) );
if ( ! $gid )
if ( ! $gid ) {
return false;
if ( ! function_exists('posix_getgrgid') )
}
if ( ! function_exists( 'posix_getgrgid' ) ) {
return $gid;
}
$grouparray = posix_getgrgid( $gid );
return $grouparray['name'];
}
/**
*
* @param string $source
* @param string $destination
* @param bool $overwrite
@ -378,16 +390,17 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
* @return bool
*/
public function copy( $source, $destination, $overwrite = false, $mode = false ) {
if ( ! $overwrite && $this->exists($destination) )
if ( ! $overwrite && $this->exists( $destination ) ) {
return false;
}
$content = $this->get_contents( $source );
if ( false === $content)
if ( false === $content ) {
return false;
}
return $this->put_contents( $destination, $content, $mode );
}
/**
*
* @param string $source
* @param string $destination
* @param bool $overwrite
@ -398,17 +411,18 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @param bool $recursive
* @param string|bool $type
* @return bool
*/
public function delete( $file, $recursive = false, $type = false ) {
if ( 'f' == $type || $this->is_file($file) )
if ( 'f' == $type || $this->is_file( $file ) ) {
return ssh2_sftp_unlink( $this->sftp_link, $file );
if ( ! $recursive )
}
if ( ! $recursive ) {
return ssh2_sftp_rmdir( $this->sftp_link, $file );
}
$filelist = $this->dirlist( $file );
if ( is_array( $filelist ) ) {
foreach ( $filelist as $filename => $fileinfo ) {
@ -419,7 +433,6 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @return bool
*/
@ -428,7 +441,6 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @return bool
*/
@ -437,7 +449,6 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
}
/**
*
* @param string $path
* @return bool
*/
@ -446,7 +457,6 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @return bool
*/
@ -455,7 +465,6 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @return bool
*/
@ -465,7 +474,6 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @return int
*/
@ -474,7 +482,6 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @return int
*/
@ -483,7 +490,6 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @return int
*/
@ -492,7 +498,6 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
}
/**
*
* @param string $file
* @param int $time
* @param int $atime
@ -502,7 +507,6 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
}
/**
*
* @param string $path
* @param mixed $chmod
* @param mixed $chown
@ -511,22 +515,26 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
*/
public function mkdir( $path, $chmod = false, $chown = false, $chgrp = false ) {
$path = untrailingslashit( $path );
if ( empty($path) )
if ( empty( $path ) ) {
return false;
}
if ( ! $chmod )
if ( ! $chmod ) {
$chmod = FS_CHMOD_DIR;
if ( ! ssh2_sftp_mkdir($this->sftp_link, $path, $chmod, true) )
}
if ( ! ssh2_sftp_mkdir( $this->sftp_link, $path, $chmod, true ) ) {
return false;
if ( $chown )
}
if ( $chown ) {
$this->chown( $path, $chown );
if ( $chgrp )
}
if ( $chgrp ) {
$this->chgrp( $path, $chgrp );
}
return true;
}
/**
*
* @param string $path
* @param bool $recursive
* @return bool
@ -536,7 +544,6 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
}
/**
*
* @param string $path
* @param bool $include_hidden
* @param bool $recursive
@ -550,27 +557,32 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
$limit_file = false;
}
if ( ! $this->is_dir($path) )
if ( ! $this->is_dir( $path ) ) {
return false;
}
$ret = array();
$dir = @dir( $this->sftp_path( $path ) );
if ( ! $dir )
if ( ! $dir ) {
return false;
}
while ( false !== ( $entry = $dir->read() ) ) {
$struc = array();
$struc['name'] = $entry;
if ( '.' == $struc['name'] || '..' == $struc['name'] )
if ( '.' == $struc['name'] || '..' == $struc['name'] ) {
continue; //Do not care about these folders.
}
if ( ! $include_hidden && '.' == $struc['name'][0] )
if ( ! $include_hidden && '.' == $struc['name'][0] ) {
continue;
}
if ( $limit_file && $struc['name'] != $limit_file )
if ( $limit_file && $struc['name'] != $limit_file ) {
continue;
}
$struc['perms'] = $this->gethchmod( $path . '/' . $entry );
$struc['permsn'] = $this->getnumchmodfromh( $struc['perms'] );
@ -584,11 +596,12 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
$struc['type'] = $this->is_dir( $path . '/' . $entry ) ? 'd' : 'f';
if ( 'd' == $struc['type'] ) {
if ( $recursive )
if ( $recursive ) {
$struc['files'] = $this->dirlist( $path . '/' . $struc['name'], $include_hidden, $recursive );
else
} else {
$struc['files'] = array();
}
}
$ret[ $struc['name'] ] = $struc;
}

View File

@ -5,7 +5,6 @@
class WP_Importer {
/**
* Class Constructor
*
*/
public function __construct() {}
@ -69,8 +68,9 @@ class WP_Importer {
$result = $wpdb->get_results( $sql );
if ( !empty( $result ) )
if ( ! empty( $result ) ) {
$count = intval( $result[0]->cnt );
}
// Unset to save memory.
unset( $results );
@ -123,7 +123,6 @@ class WP_Importer {
}
/**
*
* @param int $blog_id
* @return int|void
*/
@ -139,7 +138,13 @@ class WP_Importer {
if ( empty( $parsed['path'] ) ) {
$parsed['path'] = '/';
}
$blogs = get_sites( array( 'domain' => $parsed['host'], 'number' => 1, 'path' => $parsed['path'] ) );
$blogs = get_sites(
array(
'domain' => $parsed['host'],
'number' => 1,
'path' => $parsed['path'],
)
);
if ( ! $blogs ) {
fwrite( STDERR, "Error: Could not find blog\n" );
exit();
@ -149,15 +154,15 @@ class WP_Importer {
}
if ( function_exists( 'is_multisite' ) ) {
if ( is_multisite() )
if ( is_multisite() ) {
switch_to_blog( $blog_id );
}
}
return $blog_id;
}
/**
*
* @param int $user_id
* @return int|void
*/
@ -202,10 +207,12 @@ class WP_Importer {
$headers = array();
$args = array();
if ( true === $head )
if ( true === $head ) {
$args['method'] = 'HEAD';
if ( !empty( $username ) && !empty( $password ) )
}
if ( ! empty( $username ) && ! empty( $password ) ) {
$headers['Authorization'] = 'Basic ' . base64_encode( "$username:$password" );
}
$args['headers'] = $headers;
@ -283,9 +290,9 @@ function get_cli_args( $param, $required = false ) {
$il = sizeof( $args );
for ( $i = 1, $il; $i < $il; $i++ ) {
if ( (bool) preg_match( "/^--(.+)/", $args[$i], $match ) ) {
$parts = explode( "=", $match[1] );
$key = preg_replace( "/[^a-z0-9]+/", "", $parts[0] );
if ( (bool) preg_match( '/^--(.+)/', $args[ $i ], $match ) ) {
$parts = explode( '=', $match[1] );
$key = preg_replace( '/[^a-z0-9]+/', '', $parts[0] );
if ( isset( $parts[1] ) ) {
$out[ $key ] = $parts[1];
@ -294,7 +301,7 @@ function get_cli_args( $param, $required = false ) {
}
$last_arg = $key;
} elseif ( (bool) preg_match( "/^-([a-zA-Z0-9]+)/", $args[$i], $match ) ) {
} elseif ( (bool) preg_match( '/^-([a-zA-Z0-9]+)/', $args[ $i ], $match ) ) {
for ( $j = 0, $jl = strlen( $match[1] ); $j < $jl; $j++ ) {
$key = $match[1]{$j};
$out[ $key ] = true;

View File

@ -47,8 +47,9 @@ final class WP_Internal_Pointers {
);
// Check if screen related pointer is registered
if ( empty( $registered_pointers[ $hook_suffix ] ) )
if ( empty( $registered_pointers[ $hook_suffix ] ) ) {
return;
}
$pointers = (array) $registered_pointers[ $hook_suffix ];
@ -76,18 +77,20 @@ final class WP_Internal_Pointers {
foreach ( array_diff( $pointers, $dismissed ) as $pointer ) {
if ( isset( $caps_required[ $pointer ] ) ) {
foreach ( $caps_required[ $pointer ] as $cap ) {
if ( ! current_user_can( $cap ) )
if ( ! current_user_can( $cap ) ) {
continue 2;
}
}
}
// Bind pointer print function
add_action( 'admin_print_footer_scripts', array( 'WP_Internal_Pointers', 'pointer_' . $pointer ) );
$got_pointers = true;
}
if ( ! $got_pointers )
if ( ! $got_pointers ) {
return;
}
// Add pointers script and style to queue
wp_enqueue_style( 'wp-pointer' );
@ -106,8 +109,9 @@ final class WP_Internal_Pointers {
* @param array $args Arguments to be passed to the pointer JS (see wp-pointer.js).
*/
private static function print_js( $pointer_id, $selector, $args ) {
if ( empty( $pointer_id ) || empty( $selector ) || empty( $args ) || empty( $args['content'] ) )
if ( empty( $pointer_id ) || empty( $selector ) || empty( $args ) || empty( $args['content'] ) ) {
return;
}
?>
<script type="text/javascript">

View File

@ -27,14 +27,15 @@ class WP_Links_List_Table extends WP_List_Table {
* @param array $args An associative array of arguments.
*/
public function __construct( $args = array() ) {
parent::__construct( array(
parent::__construct(
array(
'plural' => 'bookmarks',
'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
) );
)
);
}
/**
*
* @return bool
*/
public function ajax_user_can() {
@ -42,7 +43,6 @@ class WP_Links_List_Table extends WP_List_Table {
}
/**
*
* @global int $cat_id
* @global string $s
* @global string $orderby
@ -53,16 +53,23 @@ class WP_Links_List_Table extends WP_List_Table {
wp_reset_vars( array( 'action', 'cat_id', 'link_id', 'orderby', 'order', 's' ) );
$args = array( 'hide_invisible' => 0, 'hide_empty' => 0 );
$args = array(
'hide_invisible' => 0,
'hide_empty' => 0,
);
if ( 'all' != $cat_id )
if ( 'all' != $cat_id ) {
$args['category'] = $cat_id;
if ( !empty( $s ) )
}
if ( ! empty( $s ) ) {
$args['search'] = $s;
if ( !empty( $orderby ) )
}
if ( ! empty( $orderby ) ) {
$args['orderby'] = $orderby;
if ( !empty( $order ) )
}
if ( ! empty( $order ) ) {
$args['order'] = $order;
}
$this->items = get_bookmarks( $args );
}
@ -74,7 +81,6 @@ class WP_Links_List_Table extends WP_List_Table {
}
/**
*
* @return array
*/
protected function get_bulk_actions() {
@ -85,15 +91,15 @@ class WP_Links_List_Table extends WP_List_Table {
}
/**
*
* @global int $cat_id
* @param string $which
*/
protected function extra_tablenav( $which ) {
global $cat_id;
if ( 'top' != $which )
if ( 'top' != $which ) {
return;
}
?>
<div class="alignleft actions">
<?php
@ -117,7 +123,6 @@ class WP_Links_List_Table extends WP_List_Table {
}
/**
*
* @return array
*/
public function get_columns() {
@ -128,12 +133,11 @@ class WP_Links_List_Table extends WP_List_Table {
'categories' => __( 'Categories' ),
'rel' => __( 'Relationship' ),
'visible' => __( 'Visible' ),
'rating' => __( 'Rating' )
'rating' => __( 'Rating' ),
);
}
/**
*
* @return array
*/
protected function get_sortable_columns() {
@ -141,7 +145,7 @@ class WP_Links_List_Table extends WP_List_Table {
'name' => 'name',
'url' => 'url',
'visible' => 'visible',
'rating' => 'rating'
'rating' => 'rating',
);
}
@ -179,7 +183,8 @@ class WP_Links_List_Table extends WP_List_Table {
*/
public function column_name( $link ) {
$edit_link = get_edit_bookmark_link( $link );
printf( '<strong><a class="row-title" href="%s" aria-label="%s">%s</a></strong>',
printf(
'<strong><a class="row-title" href="%s" aria-label="%s">%s</a></strong>',
$edit_link,
/* translators: %s: link name */
esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $link->link_name ) ),
@ -290,7 +295,7 @@ class WP_Links_List_Table extends WP_List_Table {
$link->link_category = wp_get_link_cats( $link->link_id );
?>
<tr id="link-<?php echo $link->link_id; ?>">
<?php $this->single_row_columns( $link ) ?>
<?php $this->single_row_columns( $link ); ?>
</tr>
<?php
}
@ -315,7 +320,7 @@ class WP_Links_List_Table extends WP_List_Table {
$actions = array();
$actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
$actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("link.php?action=delete&amp;link_id=$link->link_id", 'delete-bookmark_' . $link->link_id) . "' onclick=\"if ( confirm( '" . esc_js(sprintf(__("You are about to delete this link '%s'\n 'Cancel' to stop, 'OK' to delete."), $link->link_name)) . "' ) ) { return true;}return false;\">" . __('Delete') . "</a>";
$actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url( "link.php?action=delete&amp;link_id=$link->link_id", 'delete-bookmark_' . $link->link_id ) . "' onclick=\"if ( confirm( '" . esc_js( sprintf( __( "You are about to delete this link '%s'\n 'Cancel' to stop, 'OK' to delete." ), $link->link_name ) ) . "' ) ) { return true;}return false;\">" . __( 'Delete' ) . '</a>';
return $this->row_actions( $actions );
}
}

View File

@ -17,8 +17,9 @@ class _WP_List_Table_Compat extends WP_List_Table {
public $_columns;
public function __construct( $screen, $columns = array() ) {
if ( is_string( $screen ) )
if ( is_string( $screen ) ) {
$screen = convert_to_screen( $screen );
}
$this->_screen = $screen;
@ -29,7 +30,6 @@ class _WP_List_Table_Compat extends WP_List_Table {
}
/**
*
* @return array
*/
protected function get_column_info() {
@ -42,7 +42,6 @@ class _WP_List_Table_Compat extends WP_List_Table {
}
/**
*
* @return array
*/
public function get_columns() {

View File

@ -91,10 +91,24 @@ class WP_List_Table {
*
* @var array
*/
protected $compat_methods = array( 'set_pagination_args', 'get_views', 'get_bulk_actions', 'bulk_actions',
'row_actions', 'months_dropdown', 'view_switcher', 'comments_bubble', 'get_items_per_page', 'pagination',
'get_sortable_columns', 'get_column_info', 'get_table_classes', 'display_tablenav', 'extra_tablenav',
'single_row_columns' );
protected $compat_methods = array(
'set_pagination_args',
'get_views',
'get_bulk_actions',
'bulk_actions',
'row_actions',
'months_dropdown',
'view_switcher',
'comments_bubble',
'get_items_per_page',
'pagination',
'get_sortable_columns',
'get_column_info',
'get_table_classes',
'display_tablenav',
'extra_tablenav',
'single_row_columns',
);
/**
* Constructor.
@ -122,19 +136,22 @@ class WP_List_Table {
* }
*/
public function __construct( $args = array() ) {
$args = wp_parse_args( $args, array(
$args = wp_parse_args(
$args, array(
'plural' => '',
'singular' => '',
'ajax' => false,
'screen' => null,
) );
)
);
$this->screen = convert_to_screen( $args['screen'] );
add_filter( "manage_{$this->screen->id}_columns", array( $this, 'get_columns' ), 0 );
if ( !$args['plural'] )
if ( ! $args['plural'] ) {
$args['plural'] = $this->screen->base;
}
$args['plural'] = sanitize_key( $args['plural'] );
$args['singular'] = sanitize_key( $args['singular'] );
@ -149,7 +166,7 @@ class WP_List_Table {
if ( empty( $this->modes ) ) {
$this->modes = array(
'list' => __( 'List View' ),
'excerpt' => __( 'Excerpt View' )
'excerpt' => __( 'Excerpt View' ),
);
}
}
@ -238,6 +255,7 @@ class WP_List_Table {
/**
* Prepares the list of items for displaying.
*
* @uses WP_List_Table::set_pagination_args()
*
* @since 3.1.0
@ -255,14 +273,17 @@ class WP_List_Table {
* @param array|string $args Array or string of arguments with information about the pagination.
*/
protected function set_pagination_args( $args ) {
$args = wp_parse_args( $args, array(
$args = wp_parse_args(
$args, array(
'total_items' => 0,
'total_pages' => 0,
'per_page' => 0,
) );
)
);
if ( !$args['total_pages'] && $args['per_page'] > 0 )
if ( ! $args['total_pages'] && $args['per_page'] > 0 ) {
$args['total_pages'] = ceil( $args['total_items'] / $args['per_page'] );
}
// Redirect if page number is invalid and headers are not already sent.
if ( ! headers_sent() && ! wp_doing_ajax() && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages'] ) {
@ -321,19 +342,24 @@ class WP_List_Table {
* @param string $input_id ID attribute value for the search input field.
*/
public function search_box( $text, $input_id ) {
if ( empty( $_REQUEST['s'] ) && !$this->has_items() )
if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) {
return;
}
$input_id = $input_id . '-search-input';
if ( ! empty( $_REQUEST['orderby'] ) )
if ( ! empty( $_REQUEST['orderby'] ) ) {
echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />';
if ( ! empty( $_REQUEST['order'] ) )
}
if ( ! empty( $_REQUEST['order'] ) ) {
echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
if ( ! empty( $_REQUEST['post_mime_type'] ) )
}
if ( ! empty( $_REQUEST['post_mime_type'] ) ) {
echo '<input type="hidden" name="post_mime_type" value="' . esc_attr( $_REQUEST['post_mime_type'] ) . '" />';
if ( ! empty( $_REQUEST['detached'] ) )
}
if ( ! empty( $_REQUEST['detached'] ) ) {
echo '<input type="hidden" name="detached" value="' . esc_attr( $_REQUEST['detached'] ) . '" />';
}
?>
<p class="search-box">
<label class="screen-reader-text" for="<?php echo esc_attr( $input_id ); ?>"><?php echo $text; ?>:</label>
@ -374,8 +400,9 @@ class WP_List_Table {
*/
$views = apply_filters( "views_{$this->screen->id}", $views );
if ( empty( $views ) )
if ( empty( $views ) ) {
return;
}
$this->screen->render_screen_reader_content( 'heading_views' );
@ -384,7 +411,7 @@ class WP_List_Table {
$views[ $class ] = "\t<li class='$class'>$view";
}
echo implode( " |</li>\n", $views ) . "</li>\n";
echo "</ul>";
echo '</ul>';
}
/**
@ -428,8 +455,9 @@ class WP_List_Table {
$two = '2';
}
if ( empty( $this->_actions ) )
if ( empty( $this->_actions ) ) {
return;
}
echo '<label for="bulk-action-selector-' . esc_attr( $which ) . '" class="screen-reader-text">' . __( 'Select bulk action' ) . '</label>';
echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr( $which ) . "\">\n";
@ -455,14 +483,17 @@ class WP_List_Table {
* @return string|false The action name or False if no action was selected
*/
public function current_action() {
if ( isset( $_REQUEST['filter_action'] ) && ! empty( $_REQUEST['filter_action'] ) )
if ( isset( $_REQUEST['filter_action'] ) && ! empty( $_REQUEST['filter_action'] ) ) {
return false;
}
if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] )
if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] ) {
return $_REQUEST['action'];
}
if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] )
if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] ) {
return $_REQUEST['action2'];
}
return false;
}
@ -480,8 +511,9 @@ class WP_List_Table {
$action_count = count( $actions );
$i = 0;
if ( !$action_count )
if ( ! $action_count ) {
return '';
}
$out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">';
foreach ( $actions as $action => $link ) {
@ -528,13 +560,17 @@ class WP_List_Table {
$extra_checks = $wpdb->prepare( ' AND post_status = %s', $_GET['post_status'] );
}
$months = $wpdb->get_results( $wpdb->prepare( "
$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
$extra_checks
ORDER BY post_date DESC
", $post_type ) );
", $post_type
)
);
/**
* Filters the 'Months' drop-down results.
@ -548,8 +584,9 @@ class WP_List_Table {
$month_count = count( $months );
if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) )
if ( ! $month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) {
return;
}
$m = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0;
?>
@ -558,13 +595,15 @@ class WP_List_Table {
<option<?php selected( $m, 0 ); ?> value="0"><?php _e( 'All dates' ); ?></option>
<?php
foreach ( $months as $arc_row ) {
if ( 0 == $arc_row->year )
if ( 0 == $arc_row->year ) {
continue;
}
$month = zeroise( $arc_row->month, 2 );
$year = $arc_row->year;
printf( "<option %s value='%s'>%s</option>\n",
printf(
"<option %s value='%s'>%s</option>\n",
selected( $m, $year . $month, false ),
esc_attr( $arc_row->year . $month ),
/* translators: 1: month name, 2: 4-digit year */
@ -590,8 +629,9 @@ class WP_List_Table {
<?php
foreach ( $this->modes as $mode => $title ) {
$classes = array( 'view-' . $mode );
if ( $current_mode === $mode )
if ( $current_mode === $mode ) {
$classes[] = 'current';
}
printf(
"<a href='%s' class='%s' id='view-switch-$mode'><span class='screen-reader-text'>%s</span></a>\n",
esc_url( add_query_arg( 'mode', $mode ) ),
@ -624,31 +664,50 @@ class WP_List_Table {
// No comments at all.
if ( ! $approved_comments && ! $pending_comments ) {
printf( '<span aria-hidden="true">&#8212;</span><span class="screen-reader-text">%s</span>',
printf(
'<span aria-hidden="true">&#8212;</span><span class="screen-reader-text">%s</span>',
__( 'No comments' )
);
// Approved comments have different display depending on some conditions.
} elseif ( $approved_comments ) {
printf( '<a href="%s" class="post-com-count post-com-count-approved"><span class="comment-count-approved" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>',
esc_url( add_query_arg( array( 'p' => $post_id, 'comment_status' => 'approved' ), admin_url( 'edit-comments.php' ) ) ),
printf(
'<a href="%s" class="post-com-count post-com-count-approved"><span class="comment-count-approved" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>',
esc_url(
add_query_arg(
array(
'p' => $post_id,
'comment_status' => 'approved',
), admin_url( 'edit-comments.php' )
)
),
$approved_comments_number,
$pending_comments ? $approved_phrase : $approved_only_phrase
);
} else {
printf( '<span class="post-com-count post-com-count-no-comments"><span class="comment-count comment-count-no-comments" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></span>',
printf(
'<span class="post-com-count post-com-count-no-comments"><span class="comment-count comment-count-no-comments" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></span>',
$approved_comments_number,
$pending_comments ? __( 'No approved comments' ) : __( 'No comments' )
);
}
if ( $pending_comments ) {
printf( '<a href="%s" class="post-com-count post-com-count-pending"><span class="comment-count-pending" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>',
esc_url( add_query_arg( array( 'p' => $post_id, 'comment_status' => 'moderated' ), admin_url( 'edit-comments.php' ) ) ),
printf(
'<a href="%s" class="post-com-count post-com-count-pending"><span class="comment-count-pending" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>',
esc_url(
add_query_arg(
array(
'p' => $post_id,
'comment_status' => 'moderated',
), admin_url( 'edit-comments.php' )
)
),
$pending_comments_number,
$pending_phrase
);
} else {
printf( '<span class="post-com-count post-com-count-pending post-com-count-no-pending"><span class="comment-count comment-count-no-pending" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></span>',
printf(
'<span class="post-com-count post-com-count-pending post-com-count-no-pending"><span class="comment-count comment-count-no-pending" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></span>',
$pending_comments_number,
$approved_comments ? __( 'No pending comments' ) : __( 'No comments' )
);
@ -665,8 +724,9 @@ class WP_List_Table {
public function get_pagenum() {
$pagenum = isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 0;
if ( isset( $this->_pagination_args['total_pages'] ) && $pagenum > $this->_pagination_args['total_pages'] )
if ( isset( $this->_pagination_args['total_pages'] ) && $pagenum > $this->_pagination_args['total_pages'] ) {
$pagenum = $this->_pagination_args['total_pages'];
}
return max( 1, $pagenum );
}
@ -682,8 +742,9 @@ class WP_List_Table {
*/
protected function get_items_per_page( $option, $default = 20 ) {
$per_page = (int) get_user_option( $option );
if ( empty( $per_page ) || $per_page < 1 )
if ( empty( $per_page ) || $per_page < 1 ) {
$per_page = $default;
}
/**
* Filters the number of items to be displayed on each page of the list table.
@ -758,7 +819,8 @@ class WP_List_Table {
if ( $disable_first ) {
$page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">&laquo;</span>';
} else {
$page_links[] = sprintf( "<a class='first-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
$page_links[] = sprintf(
"<a class='first-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
esc_url( remove_query_arg( 'paged', $current_url ) ),
__( 'First page' ),
'&laquo;'
@ -768,7 +830,8 @@ class WP_List_Table {
if ( $disable_prev ) {
$page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">&lsaquo;</span>';
} else {
$page_links[] = sprintf( "<a class='prev-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
$page_links[] = sprintf(
"<a class='prev-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
esc_url( add_query_arg( 'paged', max( 1, $current - 1 ), $current_url ) ),
__( 'Previous page' ),
'&lsaquo;'
@ -779,7 +842,8 @@ class WP_List_Table {
$html_current_page = $current;
$total_pages_before = '<span class="screen-reader-text">' . __( 'Current Page' ) . '</span><span id="table-paging" class="paging-input"><span class="tablenav-paging-text">';
} else {
$html_current_page = sprintf( "%s<input class='current-page' id='current-page-selector' type='text' name='paged' value='%s' size='%d' aria-describedby='table-paging' /><span class='tablenav-paging-text'>",
$html_current_page = sprintf(
"%s<input class='current-page' id='current-page-selector' type='text' name='paged' value='%s' size='%d' aria-describedby='table-paging' /><span class='tablenav-paging-text'>",
'<label for="current-page-selector" class="screen-reader-text">' . __( 'Current Page' ) . '</label>',
$current,
strlen( $total_pages )
@ -791,7 +855,8 @@ class WP_List_Table {
if ( $disable_next ) {
$page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">&rsaquo;</span>';
} else {
$page_links[] = sprintf( "<a class='next-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
$page_links[] = sprintf(
"<a class='next-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
esc_url( add_query_arg( 'paged', min( $total_pages, $current + 1 ), $current_url ) ),
__( 'Next page' ),
'&rsaquo;'
@ -801,7 +866,8 @@ class WP_List_Table {
if ( $disable_last ) {
$page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">&raquo;</span>';
} else {
$page_links[] = sprintf( "<a class='last-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
$page_links[] = sprintf(
"<a class='last-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
esc_url( add_query_arg( 'paged', $total_pages, $current_url ) ),
__( 'Last page' ),
'&raquo;'
@ -965,12 +1031,14 @@ class WP_List_Table {
$sortable = array();
foreach ( $_sortable as $id => $data ) {
if ( empty( $data ) )
if ( empty( $data ) ) {
continue;
}
$data = (array) $data;
if ( !isset( $data[1] ) )
if ( ! isset( $data[1] ) ) {
$data[1] = false;
}
$sortable[ $id ] = $data;
}
@ -1035,10 +1103,11 @@ class WP_List_Table {
$class[] = 'hidden';
}
if ( 'cb' === $column_key )
if ( 'cb' === $column_key ) {
$class[] = 'check-column';
elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ) ) )
} elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ) ) ) {
$class[] = 'num';
}
if ( $column_key === $primary ) {
$class[] = 'column-primary';
@ -1064,8 +1133,9 @@ class WP_List_Table {
$scope = ( 'th' === $tag ) ? 'scope="col"' : '';
$id = $with_id ? "id='$column_key'" : '';
if ( !empty( $class ) )
if ( ! empty( $class ) ) {
$class = "class='" . join( ' ', $class ) . "'";
}
echo "<$tag $scope $id $class>$column_display_name</$tag>";
}
@ -1090,10 +1160,13 @@ class WP_List_Table {
</tr>
</thead>
<tbody id="the-list"<?php
<tbody id="the-list"
<?php
if ( $singular ) {
echo " data-wp-lists='list:$singular'";
} ?>>
}
?>
>
<?php $this->display_rows_or_placeholder(); ?>
</tbody>
@ -1136,7 +1209,8 @@ class WP_List_Table {
<div class="alignleft actions bulkactions">
<?php $this->bulk_actions( $which ); ?>
</div>
<?php endif;
<?php
endif;
$this->extra_tablenav( $which );
$this->pagination( $which );
?>
@ -1176,9 +1250,10 @@ class WP_List_Table {
* @since 3.1.0
*/
public function display_rows() {
foreach ( $this->items as $item )
foreach ( $this->items as $item ) {
$this->single_row( $item );
}
}
/**
* Generates content for a single row of the table
@ -1194,14 +1269,12 @@ class WP_List_Table {
}
/**
*
* @param object $item
* @param string $column_name
*/
protected function column_default( $item, $column_name ) {}
/**
*
* @param object $item
*/
protected function column_cb( $item ) {}
@ -1248,12 +1321,12 @@ class WP_List_Table {
echo "<td $attributes>";
echo call_user_func( array( $this, 'column_' . $column_name ), $item );
echo $this->handle_row_actions( $item, $column_name, $primary );
echo "</td>";
echo '</td>';
} else {
echo "<td $attributes>";
echo $this->column_default( $item, $column_name );
echo $this->handle_row_actions( $item, $column_name, $primary );
echo "</td>";
echo '</td>';
}
}
}
@ -1307,7 +1380,6 @@ class WP_List_Table {
/**
* Send required variables to JavaScript land
*
*/
public function _js_vars() {
$args = array(
@ -1315,7 +1387,7 @@ class WP_List_Table {
'screen' => array(
'id' => $this->screen->id,
'base' => $this->screen->base,
)
),
);
printf( "<script type='text/javascript'>list_args = %s;</script>\n", wp_json_encode( $args ) );

View File

@ -42,17 +42,18 @@ class WP_Media_List_Table extends WP_List_Table {
$this->modes = array(
'list' => __( 'List View' ),
'grid' => __( 'Grid View' )
'grid' => __( 'Grid View' ),
);
parent::__construct( array(
parent::__construct(
array(
'plural' => 'media',
'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
) );
)
);
}
/**
*
* @return bool
*/
public function ajax_user_can() {
@ -60,7 +61,6 @@ class WP_Media_List_Table extends WP_List_Table {
}
/**
*
* @global WP_Query $wp_query
* @global array $post_mime_types
* @global array $avail_post_mime_types
@ -75,11 +75,13 @@ class WP_Media_List_Table extends WP_List_Table {
$mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode'];
$this->set_pagination_args( array(
$this->set_pagination_args(
array(
'total_items' => $wp_query->found_posts,
'total_pages' => $wp_query->max_num_pages,
'per_page' => $wp_query->query_vars['posts_per_page'],
) );
)
);
}
/**
@ -132,7 +134,6 @@ class WP_Media_List_Table extends WP_List_Table {
}
/**
*
* @return array
*/
protected function get_bulk_actions() {
@ -148,8 +149,9 @@ class WP_Media_List_Table extends WP_List_Table {
$actions['delete'] = __( 'Delete Permanently' );
}
if ( $this->detached )
if ( $this->detached ) {
$actions['attach'] = __( 'Attach' );
}
return $actions;
}
@ -177,30 +179,32 @@ class WP_Media_List_Table extends WP_List_Table {
if ( $this->is_trash && current_user_can( 'edit_others_posts' ) && $this->has_items() ) {
submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false );
} ?>
}
?>
</div>
<?php
}
/**
*
* @return string
*/
public function current_action() {
if ( isset( $_REQUEST['found_post_id'] ) && isset( $_REQUEST['media'] ) )
if ( isset( $_REQUEST['found_post_id'] ) && isset( $_REQUEST['media'] ) ) {
return 'attach';
}
if ( isset( $_REQUEST['parent_post_id'] ) && isset( $_REQUEST['media'] ) )
if ( isset( $_REQUEST['parent_post_id'] ) && isset( $_REQUEST['media'] ) ) {
return 'detach';
}
if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) )
if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) {
return 'delete_all';
}
return parent::current_action();
}
/**
*
* @return bool
*/
public function has_items() {
@ -259,13 +263,12 @@ class WP_Media_List_Table extends WP_List_Table {
<div class="search-form">
<label for="media-search-input" class="screen-reader-text"><?php esc_html_e( 'Search Media' ); ?></label>
<input type="search" placeholder="<?php esc_attr_e( 'Search media items...' ) ?>" id="media-search-input" class="search" name="s" value="<?php _admin_search_query(); ?>"></div>
<input type="search" placeholder="<?php esc_attr_e( 'Search media items...' ); ?>" id="media-search-input" class="search" name="s" value="<?php _admin_search_query(); ?>"></div>
</div>
<?php
}
/**
*
* @return array
*/
public function get_columns() {
@ -303,9 +306,10 @@ class WP_Media_List_Table extends WP_List_Table {
/* translators: column name */
if ( ! $this->detached ) {
$posts_columns['parent'] = _x( 'Uploaded to', 'column name' );
if ( post_type_supports( 'attachment', 'comments' ) )
if ( post_type_supports( 'attachment', 'comments' ) ) {
$posts_columns['comments'] = '<span class="vers comment-grey-bubble" title="' . esc_attr__( 'Comments' ) . '"><span class="screen-reader-text">' . __( 'Comments' ) . '</span></span>';
}
}
/* translators: column name */
$posts_columns['date'] = _x( 'Date', 'column name' );
/**
@ -321,7 +325,6 @@ class WP_Media_List_Table extends WP_List_Table {
}
/**
*
* @return array
*/
protected function get_sortable_columns() {
@ -342,12 +345,16 @@ class WP_Media_List_Table extends WP_List_Table {
* @param WP_Post $post The current WP_Post object.
*/
public function column_cb( $post ) {
if ( current_user_can( 'edit_post', $post->ID ) ) { ?>
<label class="screen-reader-text" for="cb-select-<?php echo $post->ID; ?>"><?php
if ( current_user_can( 'edit_post', $post->ID ) ) {
?>
<label class="screen-reader-text" for="cb-select-<?php echo $post->ID; ?>">
<?php
echo sprintf( __( 'Select %s' ), _draft_or_post_title() );
?></label>
?>
</label>
<input type="checkbox" name="media[]" id="cb-select-<?php echo $post->ID; ?>" value="<?php echo $post->ID; ?>" />
<?php }
<?php
}
}
/**
@ -379,9 +386,11 @@ class WP_Media_List_Table extends WP_List_Table {
<strong<?php echo $class; ?>>
<?php
echo $link_start;
if ( $thumb ) : ?>
if ( $thumb ) :
?>
<span class="media-icon <?php echo sanitize_html_class( $mime . '-icon' ); ?>"><?php echo $thumb; ?></span>
<?php endif;
<?php
endif;
echo $title . $link_end;
_media_states( $post );
?>
@ -404,7 +413,8 @@ class WP_Media_List_Table extends WP_List_Table {
* @param WP_Post $post The current WP_Post object.
*/
public function column_author( $post ) {
printf( '<a href="%s">%s</a>',
printf(
'<a href="%s">%s</a>',
esc_url( add_query_arg( array( 'author' => get_the_author_meta( 'ID' ) ), 'upload.php' ) ),
get_the_author()
);
@ -471,20 +481,24 @@ class WP_Media_List_Table extends WP_List_Table {
if ( $parent_type && $parent_type->show_ui && current_user_can( 'edit_post', $post->post_parent ) ) {
?>
<strong><a href="<?php echo get_edit_post_link( $post->post_parent ); ?>">
<?php echo $title ?></a></strong><?php
<?php echo $title; ?></a></strong>
<?php
} elseif ( $parent_type && current_user_can( 'read_post', $post->post_parent ) ) {
?>
<strong><?php echo $title ?></strong><?php
<strong><?php echo $title; ?></strong>
<?php
} else {
_e( '(Private post)' );
}
if ( $user_can_edit ) :
$detach_url = add_query_arg( array(
$detach_url = add_query_arg(
array(
'parent_post_id' => $post->post_parent,
'media[]' => $post->ID,
'_wpnonce' => wp_create_nonce( 'bulk-' . $this->_args['plural'] )
), 'upload.php' );
'_wpnonce' => wp_create_nonce( 'bulk-' . $this->_args['plural'] ),
), 'upload.php'
);
printf(
'<br /><a href="%s" class="hide-if-no-js detach-from-parent" aria-label="%s">%s</a>',
$detach_url,
@ -494,8 +508,10 @@ class WP_Media_List_Table extends WP_List_Table {
);
endif;
} else {
_e( '(Unattached)' ); ?>
<?php if ( $user_can_edit ) {
_e( '(Unattached)' );
?>
<?php
if ( $user_can_edit ) {
$title = _draft_or_post_title( $post->post_parent );
printf(
'<br /><a href="#the-list" onclick="findPosts.open( \'media[]\', \'%s\' ); return false;" class="hide-if-no-js aria-button-if-js" aria-label="%s">%s</a>',
@ -557,7 +573,8 @@ class WP_Media_List_Table extends WP_List_Table {
$posts_in_term_qv['taxonomy'] = $taxonomy;
$posts_in_term_qv['term'] = $t->slug;
$out[] = sprintf( '<a href="%s">%s</a>',
$out[] = sprintf(
'<a href="%s">%s</a>',
esc_url( add_query_arg( $posts_in_term_qv, 'upload.php' ) ),
esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) )
);
@ -585,7 +602,6 @@ class WP_Media_List_Table extends WP_List_Table {
}
/**
*
* @global WP_Post $post
*/
public function display_rows() {
@ -598,7 +614,8 @@ class WP_Media_List_Table extends WP_List_Table {
add_filter( 'the_title', 'esc_html' );
while ( have_posts() ) : the_post();
while ( have_posts() ) :
the_post();
if (
( $this->is_trash && $post->post_status != 'trash' )
|| ( ! $this->is_trash && $post->post_status === 'trash' )
@ -682,8 +699,7 @@ class WP_Media_List_Table extends WP_List_Table {
__( 'Attach' )
);
}
}
else {
} else {
if ( current_user_can( 'edit_post', $post->ID ) && ! $this->is_trash ) {
$actions['edit'] = sprintf(
'<a href="%s" aria-label="%s">%s</a>',

View File

@ -39,17 +39,18 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
'archived' => array( 'site-archived', __( 'Archived' ) ),
'spam' => array( 'site-spammed', _x( 'Spam', 'site' ) ),
'deleted' => array( 'site-deleted', __( 'Deleted' ) ),
'mature' => array( 'site-mature', __( 'Mature' ) )
'mature' => array( 'site-mature', __( 'Mature' ) ),
);
parent::__construct( array(
parent::__construct(
array(
'plural' => 'sites',
'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
) );
)
);
}
/**
*
* @return bool
*/
public function ajax_user_can() {
@ -91,11 +92,13 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
* the latest sites with no paging in order to avoid expensive count queries.
*/
if ( ! $s && wp_is_large_network() ) {
if ( !isset($_REQUEST['orderby']) )
if ( ! isset( $_REQUEST['orderby'] ) ) {
$_GET['orderby'] = $_REQUEST['orderby'] = '';
if ( !isset($_REQUEST['order']) )
}
if ( ! isset( $_REQUEST['order'] ) ) {
$_GET['order'] = $_REQUEST['order'] = 'DESC';
}
}
$args = array(
'number' => intval( $per_page ),
@ -146,7 +149,7 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
$args['orderby'] = $order_by;
if ( $order_by ) {
$args['order'] = ( isset( $_REQUEST['order'] ) && 'DESC' === strtoupper( $_REQUEST['order'] ) ) ? "DESC" : "ASC";
$args['order'] = ( isset( $_REQUEST['order'] ) && 'DESC' === strtoupper( $_REQUEST['order'] ) ) ? 'DESC' : 'ASC';
}
if ( wp_is_large_network() ) {
@ -171,16 +174,22 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
$this->items = array_slice( $_sites, 0, $per_page );
}
$total_sites = get_sites( array_merge( $args, array(
$total_sites = get_sites(
array_merge(
$args, array(
'count' => true,
'offset' => 0,
'number' => 0,
) ) );
)
)
);
$this->set_pagination_args( array(
$this->set_pagination_args(
array(
'total_items' => $total_sites,
'per_page' => $per_page,
) );
)
);
}
/**
@ -190,13 +199,13 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
}
/**
*
* @return array
*/
protected function get_bulk_actions() {
$actions = array();
if ( current_user_can( 'delete_sites' ) )
if ( current_user_can( 'delete_sites' ) ) {
$actions['delete'] = __( 'Delete' );
}
$actions['spam'] = _x( 'Mark as Spam', 'site' );
$actions['notspam'] = _x( 'Not Spam', 'site' );
@ -213,9 +222,10 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
parent::pagination( $which );
if ( 'top' === $which )
if ( 'top' === $which ) {
$this->view_switcher( $mode );
}
}
/**
* @return array
@ -266,11 +276,14 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
if ( ! is_main_site( $blog['blog_id'] ) ) :
$blogname = untrailingslashit( $blog['domain'] . $blog['path'] );
?>
<label class="screen-reader-text" for="blog_<?php echo $blog['blog_id']; ?>"><?php
<label class="screen-reader-text" for="blog_<?php echo $blog['blog_id']; ?>">
<?php
printf( __( 'Select %s' ), $blogname );
?></label>
<input type="checkbox" id="blog_<?php echo $blog['blog_id'] ?>" name="allblogs[]" value="<?php echo esc_attr( $blog['blog_id'] ) ?>" />
<?php endif;
?>
</label>
<input type="checkbox" id="blog_<?php echo $blog['blog_id']; ?>" name="allblogs[]" value="<?php echo esc_attr( $blog['blog_id'] ); ?>" />
<?php
endif;
}
/**
@ -393,7 +406,12 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
public function column_users( $blog ) {
$user_count = wp_cache_get( $blog['blog_id'] . '_user_count', 'blog-details' );
if ( ! $user_count ) {
$blog_users = get_users( array( 'blog_id' => $blog['blog_id'], 'fields' => 'ID' ) );
$blog_users = get_users(
array(
'blog_id' => $blog['blog_id'],
'fields' => 'ID',
)
);
$user_count = count( $blog_users );
unset( $blog_users );
wp_cache_set( $blog['blog_id'] . '_user_count', $user_count, 'blog-details', 12 * HOUR_IN_SECONDS );
@ -449,7 +467,6 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
}
/**
*
* @global string $mode
*/
public function display_rows() {
@ -502,10 +519,14 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
// Preordered.
$actions = array(
'edit' => '', 'backend' => '',
'activate' => '', 'deactivate' => '',
'archive' => '', 'unarchive' => '',
'spam' => '', 'unspam' => '',
'edit' => '',
'backend' => '',
'activate' => '',
'deactivate' => '',
'archive' => '',
'unarchive' => '',
'spam' => '',
'unspam' => '',
'delete' => '',
'visit' => '',
);

View File

@ -37,25 +37,28 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
public function __construct( $args = array() ) {
global $status, $page;
parent::__construct( array(
parent::__construct(
array(
'plural' => 'themes',
'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
) );
)
);
$status = isset( $_REQUEST['theme_status'] ) ? $_REQUEST['theme_status'] : 'all';
if ( !in_array( $status, array( 'all', 'enabled', 'disabled', 'upgrade', 'search', 'broken' ) ) )
if ( ! in_array( $status, array( 'all', 'enabled', 'disabled', 'upgrade', 'search', 'broken' ) ) ) {
$status = 'all';
}
$page = $this->get_pagenum();
$this->is_site_themes = ( 'site-themes-network' === $this->screen->id ) ? true : false;
if ( $this->is_site_themes )
if ( $this->is_site_themes ) {
$this->site_id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
}
}
/**
*
* @return array
*/
protected function get_table_classes() {
@ -64,18 +67,17 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
}
/**
*
* @return bool
*/
public function ajax_user_can() {
if ( $this->is_site_themes )
if ( $this->is_site_themes ) {
return current_user_can( 'manage_sites' );
else
} else {
return current_user_can( 'manage_network_themes' );
}
}
/**
*
* @global string $status
* @global array $totals
* @global int $page
@ -136,11 +138,13 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
}
$totals = array();
foreach ( $themes as $type => $list )
foreach ( $themes as $type => $list ) {
$totals[ $type ] = count( $list );
}
if ( empty( $themes[ $status ] ) && !in_array( $status, array( 'all', 'search' ) ) )
if ( empty( $themes[ $status ] ) && ! in_array( $status, array( 'all', 'search' ) ) ) {
$status = 'all';
}
$this->items = $themes[ $status ];
WP_Theme::sort_by_name( $this->items );
@ -148,10 +152,12 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
$this->has_items = ! empty( $themes['all'] );
$total_this_page = $totals[ $status ];
wp_localize_script( 'updates', '_wpUpdatesItemCounts', array(
wp_localize_script(
'updates', '_wpUpdatesItemCounts', array(
'themes' => $totals,
'totals' => wp_get_update_data(),
) );
)
);
if ( $orderby ) {
$orderby = ucfirst( $orderby );
@ -168,13 +174,16 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
$start = ( $page - 1 ) * $themes_per_page;
if ( $total_this_page > $themes_per_page )
if ( $total_this_page > $themes_per_page ) {
$this->items = array_slice( $this->items, $start, $themes_per_page, true );
}
$this->set_pagination_args( array(
$this->set_pagination_args(
array(
'total_items' => $total_this_page,
'per_page' => $themes_per_page,
) );
)
);
}
/**
@ -184,20 +193,24 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
*/
public function _search_callback( $theme ) {
static $term = null;
if ( is_null( $term ) )
if ( is_null( $term ) ) {
$term = wp_unslash( $_REQUEST['s'] );
}
foreach ( array( 'Name', 'Description', 'Author', 'Author', 'AuthorURI' ) as $field ) {
// Don't mark up; Do translate.
if ( false !== stripos( $theme->display( $field, false, true ), $term ) )
if ( false !== stripos( $theme->display( $field, false, true ), $term ) ) {
return true;
}
}
if ( false !== stripos( $theme->get_stylesheet(), $term ) ) {
return true;
}
if ( false !== stripos( $theme->get_stylesheet(), $term ) )
return true;
if ( false !== stripos( $theme->get_template(), $term ) )
if ( false !== stripos( $theme->get_template(), $term ) ) {
return true;
}
return false;
}
@ -216,14 +229,16 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
$a = $theme_a[ $orderby ];
$b = $theme_b[ $orderby ];
if ( $a == $b )
if ( $a == $b ) {
return 0;
}
if ( 'DESC' === $order )
if ( 'DESC' === $order ) {
return ( $a < $b ) ? 1 : -1;
else
} else {
return ( $a < $b ) ? -1 : 1;
}
}
/**
*/
@ -236,7 +251,6 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
}
/**
*
* @return array
*/
public function get_columns() {
@ -248,7 +262,6 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
}
/**
*
* @return array
*/
protected function get_sortable_columns() {
@ -269,7 +282,6 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
}
/**
*
* @global array $totals
* @global string $status
* @return array
@ -279,8 +291,9 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
$status_links = array();
foreach ( $totals as $type => $count ) {
if ( !$count )
if ( ! $count ) {
continue;
}
switch ( $type ) {
case 'all':
@ -300,13 +313,15 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
break;
}
if ( $this->is_site_themes )
if ( $this->is_site_themes ) {
$url = 'site-themes.php?id=' . $this->site_id;
else
} else {
$url = 'themes.php';
}
if ( 'search' != $type ) {
$status_links[$type] = sprintf( "<a href='%s'%s>%s</a>",
$status_links[ $type ] = sprintf(
"<a href='%s'%s>%s</a>",
esc_url( add_query_arg( 'theme_status', $type, $url ) ),
( $type === $status ) ? ' class="current" aria-current="page"' : '',
sprintf( $text, number_format_i18n( $count ) )
@ -326,25 +341,30 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
global $status;
$actions = array();
if ( 'enabled' != $status )
if ( 'enabled' != $status ) {
$actions['enable-selected'] = $this->is_site_themes ? __( 'Enable' ) : __( 'Network Enable' );
if ( 'disabled' != $status )
}
if ( 'disabled' != $status ) {
$actions['disable-selected'] = $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' );
}
if ( ! $this->is_site_themes ) {
if ( current_user_can( 'update_themes' ) )
if ( current_user_can( 'update_themes' ) ) {
$actions['update-selected'] = __( 'Update' );
if ( current_user_can( 'delete_themes' ) )
}
if ( current_user_can( 'delete_themes' ) ) {
$actions['delete-selected'] = __( 'Delete' );
}
}
return $actions;
}
/**
*/
public function display_rows() {
foreach ( $this->items as $theme )
foreach ( $this->items as $theme ) {
$this->single_row( $theme );
}
}
/**
* Handles the checkbox column output.
@ -356,8 +376,8 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
public function column_cb( $theme ) {
$checkbox_id = 'checkbox_' . md5( $theme->get( 'Name' ) );
?>
<input type="checkbox" name="checked[]" value="<?php echo esc_attr( $theme->get_stylesheet() ) ?>" id="<?php echo $checkbox_id ?>" />
<label class="screen-reader-text" for="<?php echo $checkbox_id ?>" ><?php _e( 'Select' ) ?> <?php echo $theme->display( 'Name' ) ?></label>
<input type="checkbox" name="checked[]" value="<?php echo esc_attr( $theme->get_stylesheet() ); ?>" id="<?php echo $checkbox_id; ?>" />
<label class="screen-reader-text" for="<?php echo $checkbox_id; ?>" ><?php _e( 'Select' ); ?> <?php echo $theme->display( 'Name' ); ?></label>
<?php
}
@ -389,7 +409,7 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
$actions = array(
'enable' => '',
'disable' => '',
'delete' => ''
'delete' => '',
);
$stylesheet = $theme->get_stylesheet();
@ -397,12 +417,14 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
if ( ! $allowed ) {
if ( ! $theme->errors() ) {
$url = add_query_arg( array(
$url = add_query_arg(
array(
'action' => 'enable',
'theme' => $theme_key,
'paged' => $page,
's' => $s,
), $url );
), $url
);
if ( $this->is_site_themes ) {
/* translators: %s: theme name */
@ -412,19 +434,22 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
$aria_label = sprintf( __( 'Network Enable %s' ), $theme->display( 'Name' ) );
}
$actions['enable'] = sprintf( '<a href="%s" class="edit" aria-label="%s">%s</a>',
$actions['enable'] = sprintf(
'<a href="%s" class="edit" aria-label="%s">%s</a>',
esc_url( wp_nonce_url( $url, 'enable-theme_' . $stylesheet ) ),
esc_attr( $aria_label ),
( $this->is_site_themes ? __( 'Enable' ) : __( 'Network Enable' ) )
);
}
} else {
$url = add_query_arg( array(
$url = add_query_arg(
array(
'action' => 'disable',
'theme' => $theme_key,
'paged' => $page,
's' => $s,
), $url );
), $url
);
if ( $this->is_site_themes ) {
/* translators: %s: theme name */
@ -434,7 +459,8 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
$aria_label = sprintf( __( 'Network Disable %s' ), $theme->display( 'Name' ) );
}
$actions['disable'] = sprintf( '<a href="%s" aria-label="%s">%s</a>',
$actions['disable'] = sprintf(
'<a href="%s" aria-label="%s">%s</a>',
esc_url( wp_nonce_url( $url, 'disable-theme_' . $stylesheet ) ),
esc_attr( $aria_label ),
( $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' ) )
@ -442,18 +468,21 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
}
if ( ! $allowed && current_user_can( 'delete_themes' ) && ! $this->is_site_themes && $stylesheet != get_option( 'stylesheet' ) && $stylesheet != get_option( 'template' ) ) {
$url = add_query_arg( array(
$url = add_query_arg(
array(
'action' => 'delete-selected',
'checked[]' => $theme_key,
'theme_status' => $context,
'paged' => $page,
's' => $s,
), 'themes.php' );
), 'themes.php'
);
/* translators: %s: theme name */
$aria_label = sprintf( _x( 'Delete %s', 'theme' ), $theme->display( 'Name' ) );
$actions['delete'] = sprintf( '<a href="%s" class="delete" aria-label="%s">%s</a>',
$actions['delete'] = sprintf(
'<a href="%s" class="delete" aria-label="%s">%s</a>',
esc_url( wp_nonce_url( $url, 'bulk-themes' ) ),
esc_attr( $aria_label ),
__( 'Delete' )
@ -526,8 +555,9 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
}
$class = ! $allowed ? 'inactive' : 'active';
if ( ! empty( $totals['upgrade'] ) && ! empty( $theme->update ) )
if ( ! empty( $totals['upgrade'] ) && ! empty( $theme->update ) ) {
$class .= ' update';
}
echo "<div class='theme-description'><p>" . $theme->display( 'Description' ) . "</p></div>
<div class='$class second theme-version-author-uri'>";
@ -544,7 +574,8 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
/* translators: %s: theme name */
$aria_label = sprintf( __( 'Visit %s homepage' ), $theme->display( 'Name' ) );
$theme_meta[] = sprintf( '<a href="%s" aria-label="%s">%s</a>',
$theme_meta[] = sprintf(
'<a href="%s" aria-label="%s">%s</a>',
$theme->display( 'ThemeURI' ),
esc_attr( $aria_label ),
__( 'Visit Theme Site' )
@ -618,7 +649,6 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
break;
case 'name':
$active_theme_label = '';
/* The presence of the site_id property means that this is a subsite view and a label for the active theme needs to be added */
@ -641,7 +671,7 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
$this->column_name( $item );
echo "</td>";
echo '</td>';
break;
case 'description':
@ -657,7 +687,7 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
$this->column_default( $item, $column_name );
echo "</td>";
echo '</td>';
break;
}
}
@ -685,17 +715,19 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
$class .= ' update';
}
printf( '<tr class="%s" data-slug="%s">',
printf(
'<tr class="%s" data-slug="%s">',
esc_attr( $class ),
esc_attr( $stylesheet )
);
$this->single_row_columns( $theme );
echo "</tr>";
echo '</tr>';
if ( $this->is_site_themes )
if ( $this->is_site_themes ) {
remove_action( "after_theme_row_$stylesheet", 'wp_theme_update_row' );
}
/**
* Fires after each row in the Multisite themes list table.

View File

@ -17,7 +17,6 @@
*/
class WP_MS_Users_List_Table extends WP_List_Table {
/**
*
* @return bool
*/
public function ajax_user_can() {
@ -25,7 +24,6 @@ class WP_MS_Users_List_Table extends WP_List_Table {
}
/**
*
* @global string $usersearch
* @global string $role
* @global wpdb $wpdb
@ -47,7 +45,7 @@ class WP_MS_Users_List_Table extends WP_List_Table {
'offset' => ( $paged - 1 ) * $users_per_page,
'search' => $usersearch,
'blog_id' => 0,
'fields' => 'all_with_meta'
'fields' => 'all_with_meta',
);
if ( wp_is_large_network( 'users' ) ) {
@ -68,18 +66,22 @@ class WP_MS_Users_List_Table extends WP_List_Table {
* expensive count queries.
*/
if ( ! $usersearch && wp_is_large_network( 'users' ) ) {
if ( !isset($_REQUEST['orderby']) )
if ( ! isset( $_REQUEST['orderby'] ) ) {
$_GET['orderby'] = $_REQUEST['orderby'] = 'id';
if ( !isset($_REQUEST['order']) )
}
if ( ! isset( $_REQUEST['order'] ) ) {
$_GET['order'] = $_REQUEST['order'] = 'DESC';
}
$args['count_total'] = false;
}
if ( isset( $_REQUEST['orderby'] ) )
if ( isset( $_REQUEST['orderby'] ) ) {
$args['orderby'] = $_REQUEST['orderby'];
}
if ( isset( $_REQUEST['order'] ) )
if ( isset( $_REQUEST['order'] ) ) {
$args['order'] = $_REQUEST['order'];
}
if ( ! empty( $_REQUEST['mode'] ) ) {
$mode = $_REQUEST['mode'] === 'excerpt' ? 'excerpt' : 'list';
@ -96,20 +98,22 @@ class WP_MS_Users_List_Table extends WP_List_Table {
$this->items = $wp_user_search->get_results();
$this->set_pagination_args( array(
$this->set_pagination_args(
array(
'total_items' => $wp_user_search->get_total(),
'per_page' => $users_per_page,
) );
)
);
}
/**
*
* @return array
*/
protected function get_bulk_actions() {
$actions = array();
if ( current_user_can( 'delete_users' ) )
if ( current_user_can( 'delete_users' ) ) {
$actions['delete'] = __( 'Delete' );
}
$actions['spam'] = _x( 'Mark as Spam', 'user' );
$actions['notspam'] = _x( 'Not Spam', 'user' );
@ -123,7 +127,6 @@ class WP_MS_Users_List_Table extends WP_List_Table {
}
/**
*
* @global string $role
* @return array
*/
@ -159,7 +162,6 @@ class WP_MS_Users_List_Table extends WP_List_Table {
}
/**
*
* @return array
*/
public function get_columns() {
@ -169,7 +171,7 @@ class WP_MS_Users_List_Table extends WP_List_Table {
'name' => __( 'Name' ),
'email' => __( 'Email' ),
'registered' => _x( 'Registered', 'user' ),
'blogs' => __( 'Sites' )
'blogs' => __( 'Sites' ),
);
/**
* Filters the columns displayed in the Network Admin Users list table.
@ -183,7 +185,6 @@ class WP_MS_Users_List_Table extends WP_List_Table {
}
/**
*
* @return array
*/
protected function get_sortable_columns() {
@ -208,7 +209,7 @@ class WP_MS_Users_List_Table extends WP_List_Table {
}
?>
<label class="screen-reader-text" for="blog_<?php echo $user->ID; ?>"><?php echo sprintf( __( 'Select %s' ), $user->user_login ); ?></label>
<input type="checkbox" id="blog_<?php echo $user->ID ?>" name="allusers[]" value="<?php echo esc_attr( $user->ID ) ?>" />
<input type="checkbox" id="blog_<?php echo $user->ID; ?>" name="allusers[]" value="<?php echo esc_attr( $user->ID ); ?>" />
<?php
}
@ -401,7 +402,10 @@ class WP_MS_Users_List_Table extends WP_List_Table {
foreach ( $this->items as $user ) {
$class = '';
$status_list = array( 'spam' => 'site-spammed', 'deleted' => 'site-deleted' );
$status_list = array(
'spam' => 'site-spammed',
'deleted' => 'site-deleted',
);
foreach ( $status_list as $status => $col ) {
if ( $user->$status ) {

View File

@ -24,7 +24,6 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
private $error;
/**
*
* @return bool
*/
public function ajax_user_can() {
@ -79,7 +78,6 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
}
/**
*
* @global array $tabs
* @global string $tab
* @global int $paged
@ -138,8 +136,9 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
$nonmenu_tabs = apply_filters( 'install_plugins_nonmenu_tabs', $nonmenu_tabs );
// If a non-valid menu tab has been selected, And it's not a non-menu action.
if ( empty( $tab ) || ( !isset( $tabs[ $tab ] ) && !in_array( $tab, (array) $nonmenu_tabs ) ) )
if ( empty( $tab ) || ( ! isset( $tabs[ $tab ] ) && ! in_array( $tab, (array) $nonmenu_tabs ) ) ) {
$tab = key( $tabs );
}
$installed_plugins = $this->get_installed_plugins();
@ -149,7 +148,7 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
'fields' => array(
'last_updated' => true,
'icons' => true,
'active_installs' => true
'active_installs' => true,
),
// Send the locale and installed plugin slugs to the API so it can provide context-sensitive results.
'locale' => get_user_locale(),
@ -194,10 +193,11 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
} else {
$user = get_user_option( 'wporg_favorites' );
}
if ( $user )
if ( $user ) {
$args['user'] = $user;
else
} else {
$args = false;
}
add_action( 'install_plugins_favorites', 'install_plugins_favorites_form', 9, 0 );
break;
@ -219,8 +219,9 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
*/
$args = apply_filters( "install_plugins_table_api_args_{$tab}", $args );
if ( !$args )
if ( ! $args ) {
return;
}
$api = plugins_api( 'query_plugins', $args );
@ -235,10 +236,12 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
uasort( $this->items, array( $this, 'order_callback' ) );
}
$this->set_pagination_args( array(
$this->set_pagination_args(
array(
'total_items' => $api->info['results'],
'per_page' => $args['per_page'],
) );
)
);
if ( isset( $api->info['groups'] ) ) {
$this->groups = $api->info['groups'];
@ -257,10 +260,12 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
$js_plugins['upgrade'] = array_values( $upgrade_plugins );
}
wp_localize_script( 'updates', '_wpUpdatesItemCounts', array(
wp_localize_script(
'updates', '_wpUpdatesItemCounts', array(
'plugins' => $js_plugins,
'totals' => wp_get_update_data(),
) );
)
);
}
}
@ -278,7 +283,6 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
}
/**
*
* @global array $tabs
* @global string $tab
*
@ -375,7 +379,8 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
*
* @since 2.7.0
*/
do_action( 'install_plugins_table_header' ); ?>
do_action( 'install_plugins_table_header' );
?>
</div>
<?php $this->pagination( $which ); ?>
<br class="clear" />
@ -430,10 +435,22 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
public function display_rows() {
$plugins_allowedtags = array(
'a' => array( 'href' => array(),'title' => array(), 'target' => array() ),
'abbr' => array( 'title' => array() ),'acronym' => array( 'title' => array() ),
'code' => array(), 'pre' => array(), 'em' => array(),'strong' => array(),
'ul' => array(), 'ol' => array(), 'li' => array(), 'p' => array(), 'br' => array()
'a' => array(
'href' => array(),
'title' => array(),
'target' => array(),
),
'abbr' => array( 'title' => array() ),
'acronym' => array( 'title' => array() ),
'code' => array(),
'pre' => array(),
'em' => array(),
'strong' => array(),
'ul' => array(),
'ol' => array(),
'li' => array(),
'p' => array(),
'br' => array(),
);
$plugins_group_titles = array(
@ -512,11 +529,13 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
$button_text = __( 'Activate' );
/* translators: %s: Plugin name */
$button_label = _x( 'Activate %s', 'plugin' );
$activate_url = add_query_arg( array(
$activate_url = add_query_arg(
array(
'_wpnonce' => wp_create_nonce( 'activate-plugin_' . $status['file'] ),
'action' => 'activate',
'plugin' => $status['file'],
), network_admin_url( 'plugins.php' ) );
), network_admin_url( 'plugins.php' )
);
if ( is_network_admin() ) {
$button_text = __( 'Network Activate' );
@ -538,8 +557,10 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
}
}
$details_link = self_admin_url( 'plugin-install.php?tab=plugin-information&amp;plugin=' . $plugin['slug'] .
'&amp;TB_iframe=true&amp;width=600&amp;height=550' );
$details_link = self_admin_url(
'plugin-install.php?tab=plugin-information&amp;plugin=' . $plugin['slug'] .
'&amp;TB_iframe=true&amp;width=600&amp;height=550'
);
/* translators: 1: Plugin name and version. */
$action_links[] = '<a href="' . esc_url( $details_link ) . '" class="thickbox open-plugin-details-modal" aria-label="' . esc_attr( sprintf( __( 'More information about %s' ), $name ) ) . '" data-title="' . esc_attr( $name ) . '">' . __( 'More Details' ) . '</a>';
@ -572,7 +593,7 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
<h3>
<a href="<?php echo esc_url( $details_link ); ?>" class="thickbox open-plugin-details-modal">
<?php echo $title; ?>
<img src="<?php echo esc_attr( $plugin_icon_url ) ?>" class="plugin-icon" alt="">
<img src="<?php echo esc_attr( $plugin_icon_url ); ?>" class="plugin-icon" alt="">
</a>
</h3>
</div>
@ -590,7 +611,15 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
</div>
<div class="plugin-card-bottom">
<div class="vers column-rating">
<?php wp_star_rating( array( 'rating' => $plugin['rating'], 'type' => 'percent', 'number' => $plugin['num_ratings'] ) ); ?>
<?php
wp_star_rating(
array(
'rating' => $plugin['rating'],
'type' => 'percent',
'number' => $plugin['num_ratings'],
)
);
?>
<span class="num-ratings" aria-hidden="true">(<?php echo number_format_i18n( $plugin['num_ratings'] ); ?>)</span>
</div>
<div class="column-updated">

View File

@ -32,17 +32,21 @@ class WP_Plugins_List_Table extends WP_List_Table {
public function __construct( $args = array() ) {
global $status, $page;
parent::__construct( array(
parent::__construct(
array(
'plural' => 'plugins',
'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
) );
)
);
$status = 'all';
if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], array( 'active', 'inactive', 'recently_activated', 'upgrade', 'mustuse', 'dropins', 'search' ) ) )
if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], array( 'active', 'inactive', 'recently_activated', 'upgrade', 'mustuse', 'dropins', 'search' ) ) ) {
$status = $_REQUEST['plugin_status'];
}
if ( isset($_REQUEST['s']) )
if ( isset( $_REQUEST['s'] ) ) {
$_SERVER['REQUEST_URI'] = add_query_arg( 's', wp_unslash( $_REQUEST['s'] ) );
}
$page = $this->get_pagenum();
}
@ -62,7 +66,6 @@ class WP_Plugins_List_Table extends WP_List_Table {
}
/**
*
* @global string $status
* @global array $plugins
* @global array $totals
@ -122,8 +125,9 @@ class WP_Plugins_List_Table extends WP_List_Table {
}
/** This action is documented in wp-admin/includes/class-wp-plugins-list-table.php */
if ( apply_filters( 'show_advanced_plugins', true, 'dropins' ) )
if ( apply_filters( 'show_advanced_plugins', true, 'dropins' ) ) {
$plugins['dropins'] = get_dropins();
}
if ( current_user_can( 'update_plugins' ) ) {
$current = get_site_transient( 'update_plugins' );
@ -184,7 +188,6 @@ class WP_Plugins_List_Table extends WP_List_Table {
if ( isset( $plugins['upgrade'][ $plugin_file ] ) ) {
$plugins['upgrade'][ $plugin_file ] = $plugin_data = array_merge( (array) $plugin_info->response[ $plugin_file ], $plugin_data );
}
} elseif ( isset( $plugin_info->no_update[ $plugin_file ] ) ) {
$plugins['all'][ $plugin_file ] = $plugin_data = array_merge( (array) $plugin_info->no_update[ $plugin_file ], $plugin_data );
// Make sure that $plugins['upgrade'] also receives the extra info since it is used on ?plugin_status=upgrade
@ -231,11 +234,13 @@ class WP_Plugins_List_Table extends WP_List_Table {
}
$totals = array();
foreach ( $plugins as $type => $list )
foreach ( $plugins as $type => $list ) {
$totals[ $type ] = count( $list );
}
if ( empty( $plugins[ $status ] ) && !in_array( $status, array( 'all', 'search' ) ) )
if ( empty( $plugins[ $status ] ) && ! in_array( $status, array( 'all', 'search' ) ) ) {
$status = 'all';
}
$this->items = array();
foreach ( $plugins[ $status ] as $plugin_file => $plugin_data ) {
@ -250,10 +255,12 @@ class WP_Plugins_List_Table extends WP_List_Table {
$js_plugins[ $key ] = array_keys( (array) $list );
}
wp_localize_script( 'updates', '_wpUpdatesItemCounts', array(
wp_localize_script(
'updates', '_wpUpdatesItemCounts', array(
'plugins' => $js_plugins,
'totals' => wp_get_update_data(),
) );
)
);
if ( ! $orderby ) {
$orderby = 'Name';
@ -269,13 +276,16 @@ class WP_Plugins_List_Table extends WP_List_Table {
$start = ( $page - 1 ) * $plugins_per_page;
if ( $total_this_page > $plugins_per_page )
if ( $total_this_page > $plugins_per_page ) {
$this->items = array_slice( $this->items, $start, $plugins_per_page );
}
$this->set_pagination_args( array(
$this->set_pagination_args(
array(
'total_items' => $total_this_page,
'per_page' => $plugins_per_page,
) );
)
);
}
/**
@ -309,8 +319,9 @@ class WP_Plugins_List_Table extends WP_List_Table {
$a = $plugin_a[ $orderby ];
$b = $plugin_b[ $orderby ];
if ( $a == $b )
if ( $a == $b ) {
return 0;
}
if ( 'DESC' === $order ) {
return strcasecmp( $b, $a );
@ -320,7 +331,6 @@ class WP_Plugins_List_Table extends WP_List_Table {
}
/**
*
* @global array $plugins
*/
public function no_items() {
@ -335,11 +345,12 @@ class WP_Plugins_List_Table extends WP_List_Table {
if ( ! is_multisite() && current_user_can( 'install_plugins' ) ) {
echo ' <a href="' . esc_url( admin_url( 'plugin-install.php?tab=search&s=' . urlencode( $s ) ) ) . '">' . __( 'Search for plugins in the WordPress Plugin Directory.' ) . '</a>';
}
} elseif ( ! empty( $plugins['all'] ) )
} elseif ( ! empty( $plugins['all'] ) ) {
_e( 'No plugins found.' );
else
} else {
_e( 'You do not appear to have any plugins available at this time.' );
}
}
/**
* Displays the search box.
@ -372,7 +383,6 @@ class WP_Plugins_List_Table extends WP_List_Table {
}
/**
*
* @global string $status
* @return array
*/
@ -394,7 +404,6 @@ class WP_Plugins_List_Table extends WP_List_Table {
}
/**
*
* @global array $totals
* @global string $status
* @return array
@ -404,8 +413,9 @@ class WP_Plugins_List_Table extends WP_List_Table {
$status_links = array();
foreach ( $totals as $type => $count ) {
if ( !$count )
if ( ! $count ) {
continue;
}
switch ( $type ) {
case 'all':
@ -432,7 +442,8 @@ class WP_Plugins_List_Table extends WP_List_Table {
}
if ( 'search' !== $type ) {
$status_links[$type] = sprintf( "<a href='%s'%s>%s</a>",
$status_links[ $type ] = sprintf(
"<a href='%s'%s>%s</a>",
add_query_arg( 'plugin_status', $type, 'plugins.php' ),
( $type === $status ) ? ' class="current" aria-current="page"' : '',
sprintf( $text, number_format_i18n( $count ) )
@ -444,7 +455,6 @@ class WP_Plugins_List_Table extends WP_List_Table {
}
/**
*
* @global string $status
* @return array
*/
@ -453,18 +463,22 @@ class WP_Plugins_List_Table extends WP_List_Table {
$actions = array();
if ( 'active' != $status )
if ( 'active' != $status ) {
$actions['activate-selected'] = $this->screen->in_admin( 'network' ) ? __( 'Network Activate' ) : __( 'Activate' );
}
if ( 'inactive' != $status && 'recent' != $status )
if ( 'inactive' != $status && 'recent' != $status ) {
$actions['deactivate-selected'] = $this->screen->in_admin( 'network' ) ? __( 'Network Deactivate' ) : __( 'Deactivate' );
}
if ( ! is_multisite() || $this->screen->in_admin( 'network' ) ) {
if ( current_user_can( 'update_plugins' ) )
if ( current_user_can( 'update_plugins' ) ) {
$actions['update-selected'] = __( 'Update' );
if ( current_user_can( 'delete_plugins' ) && ( 'active' != $status ) )
}
if ( current_user_can( 'delete_plugins' ) && ( 'active' != $status ) ) {
$actions['delete-selected'] = __( 'Delete' );
}
}
return $actions;
}
@ -476,8 +490,9 @@ class WP_Plugins_List_Table extends WP_List_Table {
public function bulk_actions( $which = '' ) {
global $status;
if ( in_array( $status, array( 'mustuse', 'dropins' ) ) )
if ( in_array( $status, array( 'mustuse', 'dropins' ) ) ) {
return;
}
parent::bulk_actions( $which );
}
@ -489,8 +504,9 @@ class WP_Plugins_List_Table extends WP_List_Table {
protected function extra_tablenav( $which ) {
global $status;
if ( ! in_array($status, array('recently_activated', 'mustuse', 'dropins') ) )
if ( ! in_array( $status, array( 'recently_activated', 'mustuse', 'dropins' ) ) ) {
return;
}
echo '<div class="alignleft actions">';
@ -498,12 +514,14 @@ class WP_Plugins_List_Table extends WP_List_Table {
submit_button( __( 'Clear List' ), '', 'clear-recent-list', false );
} elseif ( 'top' === $which && 'mustuse' === $status ) {
/* translators: %s: mu-plugins directory name */
echo '<p>' . sprintf( __( 'Files in the %s directory are executed automatically.' ),
echo '<p>' . sprintf(
__( 'Files in the %s directory are executed automatically.' ),
'<code>' . str_replace( ABSPATH, '/', WPMU_PLUGIN_DIR ) . '</code>'
) . '</p>';
} elseif ( 'top' === $which && 'dropins' === $status ) {
/* translators: %s: wp-content directory name */
echo '<p>' . sprintf( __( 'Drop-ins are advanced plugins in the %s directory that replace WordPress functionality when present.' ),
echo '<p>' . sprintf(
__( 'Drop-ins are advanced plugins in the %s directory that replace WordPress functionality when present.' ),
'<code>' . str_replace( ABSPATH, '', WP_CONTENT_DIR ) . '</code>'
) . '</p>';
}
@ -514,25 +532,27 @@ class WP_Plugins_List_Table extends WP_List_Table {
* @return string
*/
public function current_action() {
if ( isset($_POST['clear-recent-list']) )
if ( isset( $_POST['clear-recent-list'] ) ) {
return 'clear-recent-list';
}
return parent::current_action();
}
/**
*
* @global string $status
*/
public function display_rows() {
global $status;
if ( is_multisite() && ! $this->screen->in_admin( 'network' ) && in_array( $status, array( 'mustuse', 'dropins' ) ) )
if ( is_multisite() && ! $this->screen->in_admin( 'network' ) && in_array( $status, array( 'mustuse', 'dropins' ) ) ) {
return;
}
foreach ( $this->items as $plugin_file => $plugin_data )
foreach ( $this->items as $plugin_file => $plugin_data ) {
$this->single_row( array( $plugin_file, $plugin_data ) );
}
}
/**
* @global string $status
@ -566,8 +586,9 @@ class WP_Plugins_List_Table extends WP_List_Table {
} elseif ( 'dropins' === $context ) {
$dropins = _get_dropins();
$plugin_name = $plugin_file;
if ( $plugin_file != $plugin_data['Name'] )
if ( $plugin_file != $plugin_data['Name'] ) {
$plugin_name .= '<br/>' . $plugin_data['Name'];
}
if ( true === ( $dropins[ $plugin_file ][1] ) ) { // Doesn't require a constant
$is_active = true;
$description = '<p><strong>' . $dropins[ $plugin_file ][0] . '</strong></p>';
@ -578,13 +599,15 @@ class WP_Plugins_List_Table extends WP_List_Table {
$is_active = false;
$description = '<p><strong>' . $dropins[ $plugin_file ][0] . ' <span class="error-message">' . __( 'Inactive:' ) . '</span></strong> ' .
/* translators: 1: drop-in constant name, 2: wp-config.php */
sprintf( __( 'Requires %1$s in %2$s file.' ),
sprintf(
__( 'Requires %1$s in %2$s file.' ),
"<code>define('" . $dropins[ $plugin_file ][1] . "', true);</code>",
'<code>wp-config.php</code>'
) . '</p>';
}
if ( $plugin_data['Description'] )
if ( $plugin_data['Description'] ) {
$description .= '<p>' . $plugin_data['Description'] . '</p>';
}
} else {
if ( $screen->in_admin( 'network' ) ) {
$is_active = is_plugin_active_for_network( $plugin_file );
@ -635,9 +658,7 @@ class WP_Plugins_List_Table extends WP_List_Table {
$actions['delete'] = '<a href="' . wp_nonce_url( 'plugins.php?action=delete-selected&amp;checked[]=' . urlencode( $plugin_file ) . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'bulk-plugins' ) . '" class="delete" aria-label="' . esc_attr( sprintf( _x( 'Delete %s', 'plugin' ), $plugin_data['Name'] ) ) . '">' . __( 'Delete' ) . '</a>';
}
} // end if $is_active
} // end if $screen->in_admin( 'network' )
} // end if $context
$actions = array_filter( $actions );
@ -716,11 +737,11 @@ class WP_Plugins_List_Table extends WP_List_Table {
}
$class = $is_active ? 'active' : 'inactive';
$checkbox_id = "checkbox_" . md5($plugin_data['Name']);
$checkbox_id = 'checkbox_' . md5( $plugin_data['Name'] );
if ( $restrict_network_active || $restrict_network_only || in_array( $status, array( 'mustuse', 'dropins' ) ) ) {
$checkbox = '';
} else {
$checkbox = "<label class='screen-reader-text' for='" . $checkbox_id . "' >" . sprintf( __( 'Select %s' ), $plugin_data['Name'] ) . "</label>"
$checkbox = "<label class='screen-reader-text' for='" . $checkbox_id . "' >" . sprintf( __( 'Select %s' ), $plugin_data['Name'] ) . '</label>'
. "<input type='checkbox' name='checked[]' value='" . esc_attr( $plugin_file ) . "' id='" . $checkbox_id . "' />";
}
if ( 'dropins' != $context ) {
@ -728,11 +749,13 @@ class WP_Plugins_List_Table extends WP_List_Table {
$plugin_name = $plugin_data['Name'];
}
if ( ! empty( $totals['upgrade'] ) && ! empty( $plugin_data['update'] ) )
if ( ! empty( $totals['upgrade'] ) && ! empty( $plugin_data['update'] ) ) {
$class .= ' update';
}
$plugin_slug = isset( $plugin_data['slug'] ) ? $plugin_data['slug'] : sanitize_title( $plugin_name );
printf( '<tr class="%s" data-slug="%s" data-plugin="%s">',
printf(
'<tr class="%s" data-slug="%s" data-plugin="%s">',
esc_attr( $class ),
esc_attr( $plugin_slug ),
esc_attr( $plugin_file )
@ -753,7 +776,7 @@ class WP_Plugins_List_Table extends WP_List_Table {
case 'name':
echo "<td class='plugin-title column-primary'><strong>$plugin_name</strong>";
echo $this->row_actions( $actions, true );
echo "</td>";
echo '</td>';
break;
case 'description':
$classes = 'column-description desc';
@ -763,26 +786,34 @@ class WP_Plugins_List_Table extends WP_List_Table {
<div class='$class second plugin-version-author-uri'>";
$plugin_meta = array();
if ( !empty( $plugin_data['Version'] ) )
if ( ! empty( $plugin_data['Version'] ) ) {
$plugin_meta[] = sprintf( __( 'Version %s' ), $plugin_data['Version'] );
}
if ( ! empty( $plugin_data['Author'] ) ) {
$author = $plugin_data['Author'];
if ( !empty( $plugin_data['AuthorURI'] ) )
if ( ! empty( $plugin_data['AuthorURI'] ) ) {
$author = '<a href="' . $plugin_data['AuthorURI'] . '">' . $plugin_data['Author'] . '</a>';
}
$plugin_meta[] = sprintf( __( 'By %s' ), $author );
}
// Details link using API info, if available
if ( isset( $plugin_data['slug'] ) && current_user_can( 'install_plugins' ) ) {
$plugin_meta[] = sprintf( '<a href="%s" class="thickbox open-plugin-details-modal" aria-label="%s" data-title="%s">%s</a>',
esc_url( network_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $plugin_data['slug'] .
'&TB_iframe=true&width=600&height=550' ) ),
$plugin_meta[] = sprintf(
'<a href="%s" class="thickbox open-plugin-details-modal" aria-label="%s" data-title="%s">%s</a>',
esc_url(
network_admin_url(
'plugin-install.php?tab=plugin-information&plugin=' . $plugin_data['slug'] .
'&TB_iframe=true&width=600&height=550'
)
),
esc_attr( sprintf( __( 'More information about %s' ), $plugin_name ) ),
esc_attr( $plugin_name ),
__( 'View details' )
);
} elseif ( ! empty( $plugin_data['PluginURI'] ) ) {
$plugin_meta[] = sprintf( '<a href="%s">%s</a>',
$plugin_meta[] = sprintf(
'<a href="%s">%s</a>',
esc_url( $plugin_data['PluginURI'] ),
__( 'Visit plugin site' )
);
@ -805,7 +836,7 @@ class WP_Plugins_List_Table extends WP_List_Table {
$plugin_meta = apply_filters( 'plugin_row_meta', $plugin_meta, $plugin_file, $plugin_data, $status );
echo implode( ' | ', $plugin_meta );
echo "</div></td>";
echo '</div></td>';
break;
default:
$classes = "$column_name column-$column_name $class";
@ -823,11 +854,11 @@ class WP_Plugins_List_Table extends WP_List_Table {
*/
do_action( 'manage_plugins_custom_column', $column_name, $plugin_file, $plugin_data );
echo "</td>";
echo '</td>';
}
}
echo "</tr>";
echo '</tr>';
/**
* Fires after each row in the Plugins list table.

View File

@ -18,7 +18,6 @@
class WP_Post_Comments_List_Table extends WP_Comments_List_Table {
/**
*
* @return array
*/
protected function get_column_info() {
@ -34,7 +33,6 @@ class WP_Post_Comments_List_Table extends WP_Comments_List_Table {
}
/**
*
* @return array
*/
protected function get_table_classes() {
@ -45,29 +43,32 @@ class WP_Post_Comments_List_Table extends WP_Comments_List_Table {
}
/**
*
* @param bool $output_empty
*/
public function display( $output_empty = false ) {
$singular = $this->_args['singular'];
wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' );
wp_nonce_field( 'fetch-list-' . get_class( $this ), '_ajax_fetch_list_nonce' );
?>
<table class="<?php echo implode( ' ', $this->get_table_classes() ); ?>" style="display:none;">
<tbody id="the-comment-list"<?php
<tbody id="the-comment-list"
<?php
if ( $singular ) {
echo " data-wp-lists='list:$singular'";
} ?>>
<?php if ( ! $output_empty ) {
}
?>
>
<?php
if ( ! $output_empty ) {
$this->display_rows_or_placeholder();
} ?>
}
?>
</tbody>
</table>
<?php
}
/**
*
* @param bool $comment_status
* @return int
*/

View File

@ -74,24 +74,34 @@ class WP_Posts_List_Table extends WP_List_Table {
public function __construct( $args = array() ) {
global $post_type_object, $wpdb;
parent::__construct( array(
parent::__construct(
array(
'plural' => 'posts',
'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
) );
)
);
$post_type = $this->screen->post_type;
$post_type_object = get_post_type_object( $post_type );
$exclude_states = get_post_stati( array(
$exclude_states = get_post_stati(
array(
'show_in_admin_all_list' => false,
) );
$this->user_posts_count = intval( $wpdb->get_var( $wpdb->prepare( "
)
);
$this->user_posts_count = intval(
$wpdb->get_var(
$wpdb->prepare(
"
SELECT COUNT( 1 )
FROM $wpdb->posts
WHERE post_type = %s
AND post_status NOT IN ( '" . implode( "','", $exclude_states ) . "' )
AND post_author = %d
", $post_type, get_current_user_id() ) ) );
", $post_type, get_current_user_id()
)
)
);
if ( $this->user_posts_count && ! current_user_can( $post_type_object->cap->edit_others_posts ) && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['all_posts'] ) && empty( $_REQUEST['author'] ) && empty( $_REQUEST['show_sticky'] ) ) {
$_GET['author'] = get_current_user_id();
@ -115,7 +125,6 @@ class WP_Posts_List_Table extends WP_List_Table {
}
/**
*
* @return bool
*/
public function ajax_user_can() {
@ -123,7 +132,6 @@ class WP_Posts_List_Table extends WP_List_Table {
}
/**
*
* @global array $avail_post_stati
* @global WP_Query $wp_query
* @global int $per_page
@ -175,14 +183,15 @@ class WP_Posts_List_Table extends WP_List_Table {
$this->is_trash = isset( $_REQUEST['post_status'] ) && $_REQUEST['post_status'] === 'trash';
$this->set_pagination_args( array(
$this->set_pagination_args(
array(
'total_items' => $total_items,
'per_page' => $per_page
) );
'per_page' => $per_page,
)
);
}
/**
*
* @return bool
*/
public function has_items() {
@ -192,11 +201,12 @@ class WP_Posts_List_Table extends WP_List_Table {
/**
*/
public function no_items() {
if ( isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status'] )
if ( isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status'] ) {
echo get_post_type_object( $this->screen->post_type )->labels->not_found_in_trash;
else
} else {
echo get_post_type_object( $this->screen->post_type )->labels->not_found;
}
}
/**
* Determine if the current view is the "All" view.
@ -253,7 +263,6 @@ class WP_Posts_List_Table extends WP_List_Table {
}
/**
*
* @global array $locked_post_status This seems to be deprecated.
* @global array $avail_post_stati
* @return array
@ -263,8 +272,9 @@ class WP_Posts_List_Table extends WP_List_Table {
$post_type = $this->screen->post_type;
if ( !empty($locked_post_status) )
if ( ! empty( $locked_post_status ) ) {
return array();
}
$status_links = array();
$num_posts = wp_count_posts( $post_type, 'readable' );
@ -287,7 +297,7 @@ class WP_Posts_List_Table extends WP_List_Table {
$mine_args = array(
'post_type' => $post_type,
'author' => $current_user_id
'author' => $current_user_id,
);
$mine_inner_html = sprintf(
@ -356,7 +366,7 @@ class WP_Posts_List_Table extends WP_List_Table {
$sticky_args = array(
'post_type' => $post_type,
'show_sticky' => 1
'show_sticky' => 1,
);
$sticky_inner_html = sprintf(
@ -370,7 +380,7 @@ class WP_Posts_List_Table extends WP_List_Table {
);
$sticky_link = array(
'sticky' => $this->get_edit_link( $sticky_args, $sticky_inner_html, $class )
'sticky' => $this->get_edit_link( $sticky_args, $sticky_inner_html, $class ),
);
// Sticky comes after Publish, or if not listed, after All.
@ -382,7 +392,6 @@ class WP_Posts_List_Table extends WP_List_Table {
}
/**
*
* @return array
*/
protected function get_bulk_actions() {
@ -439,7 +448,7 @@ class WP_Posts_List_Table extends WP_List_Table {
'hierarchical' => 1,
'show_count' => 0,
'orderby' => 'name',
'selected' => $cat
'selected' => $cat,
);
echo '<label class="screen-reader-text" for="cat">' . __( 'Filter by category' ) . '</label>';
@ -503,18 +512,17 @@ class WP_Posts_List_Table extends WP_List_Table {
}
/**
*
* @return string
*/
public function current_action() {
if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) )
if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) {
return 'delete_all';
}
return parent::current_action();
}
/**
*
* @return array
*/
protected function get_table_classes() {
@ -522,7 +530,6 @@ class WP_Posts_List_Table extends WP_List_Table {
}
/**
*
* @return array
*/
public function get_columns() {
@ -557,19 +564,21 @@ class WP_Posts_List_Table extends WP_List_Table {
$taxonomies = array_filter( $taxonomies, 'taxonomy_exists' );
foreach ( $taxonomies as $taxonomy ) {
if ( 'category' === $taxonomy )
if ( 'category' === $taxonomy ) {
$column_key = 'categories';
elseif ( 'post_tag' === $taxonomy )
} elseif ( 'post_tag' === $taxonomy ) {
$column_key = 'tags';
else
} else {
$column_key = 'taxonomy-' . $taxonomy;
}
$posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name;
}
$post_status = ! empty( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all';
if ( post_type_supports( $post_type, 'comments' ) && !in_array( $post_status, array( 'pending', 'draft', 'future' ) ) )
if ( post_type_supports( $post_type, 'comments' ) && ! in_array( $post_status, array( 'pending', 'draft', 'future' ) ) ) {
$posts_columns['comments'] = '<span class="vers comment-grey-bubble" title="' . esc_attr__( 'Comments' ) . '"><span class="screen-reader-text">' . __( 'Comments' ) . '</span></span>';
}
$posts_columns['date'] = __( 'Date' );
@ -609,7 +618,6 @@ class WP_Posts_List_Table extends WP_List_Table {
}
/**
*
* @return array
*/
protected function get_sortable_columns() {
@ -617,7 +625,7 @@ class WP_Posts_List_Table extends WP_List_Table {
'title' => 'title',
'parent' => 'parent',
'comments' => 'comment_count',
'date' => array( 'date', true )
'date' => array( 'date', true ),
);
}
@ -630,8 +638,9 @@ class WP_Posts_List_Table extends WP_List_Table {
public function display_rows( $posts = array(), $level = 0 ) {
global $wp_query, $per_page;
if ( empty( $posts ) )
if ( empty( $posts ) ) {
$posts = $wp_query->posts;
}
add_filter( 'the_title', 'esc_html' );
@ -650,14 +659,16 @@ class WP_Posts_List_Table extends WP_List_Table {
// Create array of post IDs.
$post_ids = array();
foreach ( $posts as $a_post )
foreach ( $posts as $a_post ) {
$post_ids[] = $a_post->ID;
}
$this->comment_pending_count = get_pending_comments_num( $post_ids );
foreach ( $posts as $post )
foreach ( $posts as $post ) {
$this->single_row( $post, $level );
}
}
/**
* @global wpdb $wpdb
@ -674,9 +685,10 @@ class WP_Posts_List_Table extends WP_List_Table {
if ( ! $pages ) {
$pages = get_pages( array( 'sort_column' => 'menu_order' ) );
if ( ! $pages )
if ( ! $pages ) {
return;
}
}
/*
* Arrange pages into two parts: top level pages and children_pages
@ -699,11 +711,12 @@ class WP_Posts_List_Table extends WP_List_Table {
clean_post_cache( $page );
}
if ( 0 == $page->post_parent )
if ( 0 == $page->post_parent ) {
$top_level_pages[] = $page;
else
} else {
$children_pages[ $page->post_parent ][] = $page;
}
}
$pages = &$top_level_pages;
}
@ -714,8 +727,9 @@ class WP_Posts_List_Table extends WP_List_Table {
$to_display = array();
foreach ( $pages as $page ) {
if ( $count >= $end )
if ( $count >= $end ) {
break;
}
if ( $count >= $start ) {
$to_display[ $page->ID ] = $level;
@ -723,16 +737,18 @@ class WP_Posts_List_Table extends WP_List_Table {
$count++;
if ( isset( $children_pages ) )
if ( isset( $children_pages ) ) {
$this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display );
}
}
// If it is the last pagenum and there are orphaned pages, display them with paging as well.
if ( isset( $children_pages ) && $count < $end ) {
foreach ( $children_pages as $orphans ) {
foreach ( $orphans as $op ) {
if ( $count >= $end )
if ( $count >= $end ) {
break;
}
if ( $count >= $start ) {
$to_display[ $op->ID ] = 0;
@ -772,15 +788,17 @@ class WP_Posts_List_Table extends WP_List_Table {
* @param array $to_display List of pages to be displayed. Passed by reference.
*/
private function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page, &$to_display ) {
if ( ! isset( $children_pages[$parent] ) )
if ( ! isset( $children_pages[ $parent ] ) ) {
return;
}
$start = ( $pagenum - 1 ) * $per_page;
$end = $start + $per_page;
foreach ( $children_pages[ $parent ] as $page ) {
if ( $count >= $end )
if ( $count >= $end ) {
break;
}
// If the page starts in a subtree, print the parents.
if ( $count == $start && $page->post_parent > 0 ) {
@ -795,8 +813,9 @@ class WP_Posts_List_Table extends WP_List_Table {
$my_parent = get_post( $parent_id );
$my_parents[] = $my_parent;
if ( !$my_parent->post_parent )
if ( ! $my_parent->post_parent ) {
break;
}
$my_parent = $my_parent->post_parent;
}
$num_parents = count( $my_parents );
@ -826,22 +845,28 @@ class WP_Posts_List_Table extends WP_List_Table {
* @param WP_Post $post The current WP_Post object.
*/
public function column_cb( $post ) {
if ( current_user_can( 'edit_post', $post->ID ) ): ?>
<label class="screen-reader-text" for="cb-select-<?php the_ID(); ?>"><?php
if ( current_user_can( 'edit_post', $post->ID ) ) :
?>
<label class="screen-reader-text" for="cb-select-<?php the_ID(); ?>">
<?php
printf( __( 'Select %s' ), _draft_or_post_title() );
?></label>
?>
</label>
<input id="cb-select-<?php the_ID(); ?>" type="checkbox" name="post[]" value="<?php the_ID(); ?>" />
<div class="locked-indicator">
<span class="locked-indicator-icon" aria-hidden="true"></span>
<span class="screen-reader-text"><?php
<span class="screen-reader-text">
<?php
printf(
/* translators: %s: post title */
__( '&#8220;%s&#8221; is locked' ),
_draft_or_post_title()
);
?></span>
?>
</span>
</div>
<?php endif;
<?php
endif;
}
/**
@ -910,7 +935,7 @@ class WP_Posts_List_Table extends WP_List_Table {
}
$pad = str_repeat( '&#8212; ', $this->current_level );
echo "<strong>";
echo '<strong>';
$format = get_post_format( $post->ID );
if ( $format ) {
@ -920,7 +945,7 @@ class WP_Posts_List_Table extends WP_List_Table {
$format_args = array(
'post_format' => $format,
'post_type' => $post->post_type
'post_type' => $post->post_type,
);
echo $this->get_edit_link( $format_args, $label . ':', $format_class );
@ -1068,7 +1093,7 @@ class WP_Posts_List_Table extends WP_List_Table {
public function column_author( $post ) {
$args = array(
'post_type' => $post->post_type,
'author' => get_the_author_meta( 'ID' )
'author' => get_the_author_meta( 'ID' ),
);
echo $this->get_edit_link( $args, get_the_author() );
}
@ -1369,15 +1394,24 @@ class WP_Posts_List_Table extends WP_List_Table {
continue;
}
if ( $taxonomy->hierarchical )
if ( $taxonomy->hierarchical ) {
$hierarchical_taxonomies[] = $taxonomy;
else
} else {
$flat_taxonomies[] = $taxonomy;
}
}
$m = ( isset( $mode ) && 'excerpt' === $mode ) ? 'excerpt' : 'list';
$can_publish = current_user_can( $post_type_object->cap->publish_posts );
$core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true );
$core_columns = array(
'cb' => true,
'date' => true,
'title' => true,
'categories' => true,
'tags' => true,
'comments' => true,
'author' => true,
);
?>
@ -1389,11 +1423,15 @@ class WP_Posts_List_Table extends WP_List_Table {
$quick_edit_classes = "quick-edit-row quick-edit-row-$hclass inline-edit-{$screen->post_type}";
$bulk = 0;
while ( $bulk < 2 ) { ?>
while ( $bulk < 2 ) {
?>
<tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="<?php echo $inline_edit_classes . ' ';
<tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="
<?php
echo $inline_edit_classes . ' ';
echo $bulk ? $bulk_edit_classes : $quick_edit_classes;
?>" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange">
?>
" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange">
<fieldset class="inline-edit-col-left">
<legend class="inline-edit-legend"><?php echo $bulk ? __( 'Bulk Edit' ) : __( 'Quick Edit' ); ?></legend>
@ -1401,7 +1439,8 @@ class WP_Posts_List_Table extends WP_List_Table {
<?php
if ( post_type_supports( $screen->post_type, 'title' ) ) :
if ( $bulk ) : ?>
if ( $bulk ) :
?>
<div id="bulk-title-div">
<div id="bulk-titles"></div>
</div>
@ -1418,8 +1457,10 @@ class WP_Posts_List_Table extends WP_List_Table {
<span class="input-text-wrap"><input type="text" name="post_name" value="" /></span>
</label>
<?php endif; // $bulk
endif; // post_type_supports title ?>
<?php
endif; // $bulk
endif; // post_type_supports title
?>
<?php if ( ! $bulk ) : ?>
<fieldset class="inline-edit-date">
@ -1427,7 +1468,8 @@ class WP_Posts_List_Table extends WP_List_Table {
<?php touch_time( 1, 1, 0, 1 ); ?>
</fieldset>
<br class="clear" />
<?php endif; // $bulk
<?php
endif; // $bulk
if ( post_type_supports( $screen->post_type, 'author' ) ) :
$authors_dropdown = '';
@ -1442,8 +1484,9 @@ class WP_Posts_List_Table extends WP_List_Table {
'echo' => 0,
'show' => 'display_name_with_login',
);
if ( $bulk )
if ( $bulk ) {
$users_opt['show_option_none'] = __( '&mdash; No Change &mdash;' );
}
if ( $authors = wp_dropdown_users( $users_opt ) ) :
$authors_dropdown = '<label class="inline-edit-author">';
@ -1454,7 +1497,9 @@ class WP_Posts_List_Table extends WP_List_Table {
endif; // authors
?>
<?php if ( !$bulk ) echo $authors_dropdown;
<?php
if ( ! $bulk ) {
echo $authors_dropdown;}
endif; // post_type_supports author
if ( ! $bulk && $can_publish ) :
@ -1488,10 +1533,10 @@ class WP_Posts_List_Table extends WP_List_Table {
<?php foreach ( $hierarchical_taxonomies as $taxonomy ) : ?>
<span class="title inline-edit-categories-label"><?php echo esc_html( $taxonomy->labels->name ) ?></span>
<span class="title inline-edit-categories-label"><?php echo esc_html( $taxonomy->labels->name ); ?></span>
<input type="hidden" name="<?php echo ( $taxonomy->name === 'category' ) ? 'post_category[]' : 'tax_input[' . esc_attr( $taxonomy->name ) . '][]'; ?>" value="0" />
<ul class="cat-checklist <?php echo esc_attr( $taxonomy->name )?>-checklist">
<?php wp_terms_checklist( null, array( 'taxonomy' => $taxonomy->name ) ) ?>
<ul class="cat-checklist <?php echo esc_attr( $taxonomy->name ); ?>-checklist">
<?php wp_terms_checklist( null, array( 'taxonomy' => $taxonomy->name ) ); ?>
</ul>
<?php endforeach; //$hierarchical_taxonomies as $taxonomy ?>
@ -1503,8 +1548,9 @@ class WP_Posts_List_Table extends WP_List_Table {
<fieldset class="inline-edit-col-right"><div class="inline-edit-col">
<?php
if ( post_type_supports( $screen->post_type, 'author' ) && $bulk )
if ( post_type_supports( $screen->post_type, 'author' ) && $bulk ) {
echo $authors_dropdown;
}
if ( post_type_supports( $screen->post_type, 'page-attributes' ) ) :
@ -1522,8 +1568,9 @@ class WP_Posts_List_Table extends WP_List_Table {
'sort_column' => 'menu_order, post_title',
);
if ( $bulk )
if ( $bulk ) {
$dropdown_args['show_option_no_change'] = __( '&mdash; No Change &mdash;' );
}
/**
* Filters the arguments used to generate the Quick Edit page-parent drop-down.
@ -1543,11 +1590,12 @@ class WP_Posts_List_Table extends WP_List_Table {
<?php
endif; // hierarchical
if ( !$bulk ) : ?>
if ( ! $bulk ) :
?>
<label>
<span class="title"><?php _e( 'Order' ); ?></span>
<span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order ?>" /></span>
<span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order; ?>" /></span>
</label>
<?php
@ -1567,7 +1615,7 @@ class WP_Posts_List_Table extends WP_List_Table {
$default_title = apply_filters( 'default_page_template_title', __( 'Default Template' ), 'quick-edit' );
?>
<option value="default"><?php echo esc_html( $default_title ); ?></option>
<?php page_template_dropdown( '', $screen->post_type ) ?>
<?php page_template_dropdown( '', $screen->post_type ); ?>
</select>
</label>
<?php endif; ?>
@ -1575,12 +1623,13 @@ class WP_Posts_List_Table extends WP_List_Table {
<?php if ( count( $flat_taxonomies ) && ! $bulk ) : ?>
<?php foreach ( $flat_taxonomies as $taxonomy ) : ?>
<?php if ( current_user_can( $taxonomy->cap->assign_terms ) ) :
<?php
if ( current_user_can( $taxonomy->cap->assign_terms ) ) :
$taxonomy_name = esc_attr( $taxonomy->name );
?>
<label class="inline-edit-tags">
<span class="title"><?php echo esc_html( $taxonomy->labels->name ) ?></span>
<span class="title"><?php echo esc_html( $taxonomy->labels->name ); ?></span>
<textarea data-wp-taxonomy="<?php echo $taxonomy_name; ?>" cols="22" rows="1" name="tax_input[<?php echo $taxonomy_name; ?>]" class="tax_input_<?php echo $taxonomy_name; ?>"></textarea>
</label>
<?php endif; ?>
@ -1589,8 +1638,10 @@ class WP_Posts_List_Table extends WP_List_Table {
<?php endif; // count( $flat_taxonomies ) && !$bulk ?>
<?php if ( post_type_supports( $screen->post_type, 'comments' ) || post_type_supports( $screen->post_type, 'trackbacks' ) ) :
if ( $bulk ) : ?>
<?php
if ( post_type_supports( $screen->post_type, 'comments' ) || post_type_supports( $screen->post_type, 'trackbacks' ) ) :
if ( $bulk ) :
?>
<div class="inline-edit-group wp-clearfix">
<?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?>
@ -1630,8 +1681,10 @@ class WP_Posts_List_Table extends WP_List_Table {
<?php endif; ?>
</div>
<?php endif; // $bulk
endif; // post_type_supports comments or pings ?>
<?php
endif; // $bulk
endif; // post_type_supports comments or pings
?>
<div class="inline-edit-group wp-clearfix">
<label class="inline-edit-status alignleft">
@ -1644,7 +1697,7 @@ class WP_Posts_List_Table extends WP_List_Table {
<option value="publish"><?php _e( 'Published' ); ?></option>
<option value="future"><?php _e( 'Scheduled' ); ?></option>
<?php if ( $bulk ) : ?>
<option value="private"><?php _e( 'Private' ) ?></option>
<option value="private"><?php _e( 'Private' ); ?></option>
<?php endif; // $bulk ?>
<?php endif; ?>
<option value="pending"><?php _e( 'Pending Review' ); ?></option>
@ -1711,8 +1764,9 @@ class WP_Posts_List_Table extends WP_List_Table {
list( $columns ) = $this->get_column_info();
foreach ( $columns as $column_name => $column_display_name ) {
if ( isset( $core_columns[$column_name] ) )
if ( isset( $core_columns[ $column_name ] ) ) {
continue;
}
if ( $bulk ) {
@ -1738,19 +1792,21 @@ class WP_Posts_List_Table extends WP_List_Table {
*/
do_action( 'quick_edit_custom_box', $column_name, $screen->post_type, '' );
}
}
?>
<div class="submit inline-edit-save">
<button type="button" class="button cancel alignleft"><?php _e( 'Cancel' ); ?></button>
<?php if ( ! $bulk ) {
<?php
if ( ! $bulk ) {
wp_nonce_field( 'inlineeditnonce', '_inline_edit', false );
?>
<button type="button" class="button button-primary save alignright"><?php _e( 'Update' ); ?></button>
<span class="spinner"></span>
<?php } else {
<?php
} else {
submit_button( __( 'Update' ), 'primary alignright', 'bulk_edit', false );
} ?>
}
?>
<input type="hidden" name="post_view" value="<?php echo esc_attr( $m ); ?>" />
<input type="hidden" name="screen" value="<?php echo esc_attr( $screen->id ); ?>" />
<?php if ( ! $bulk && ! post_type_supports( $screen->post_type, 'author' ) ) { ?>

View File

@ -108,6 +108,7 @@ final class WP_Screen {
/**
* The taxonomy associated with the screen, if any.
* The 'edit-tags.php?taxonomy=category' screen has a taxonomy of 'category'.
*
* @since 3.3.0
* @var string
*/
@ -203,18 +204,20 @@ final class WP_Screen {
$in_admin = false;
$action = '';
if ( $hook_name )
if ( $hook_name ) {
$id = $hook_name;
else
} else {
$id = $GLOBALS['hook_suffix'];
}
// For those pesky meta boxes.
if ( $hook_name && post_type_exists( $hook_name ) ) {
$post_type = $id;
$id = 'post'; // changes later. ends up being $base.
} else {
if ( '.php' == substr( $id, -4 ) )
if ( '.php' == substr( $id, -4 ) ) {
$id = substr( $id, 0, -4 );
}
if ( 'post-new' == $id || 'link-add' == $id || 'media-new' == $id || 'user-new' == $id ) {
$id = substr( $id, 0, -4 );
@ -243,50 +246,58 @@ final class WP_Screen {
}
}
if ( ! $in_admin )
$in_admin = 'site';
} else {
if ( defined( 'WP_NETWORK_ADMIN' ) && WP_NETWORK_ADMIN )
$in_admin = 'network';
elseif ( defined( 'WP_USER_ADMIN' ) && WP_USER_ADMIN )
$in_admin = 'user';
else
if ( ! $in_admin ) {
$in_admin = 'site';
}
} else {
if ( defined( 'WP_NETWORK_ADMIN' ) && WP_NETWORK_ADMIN ) {
$in_admin = 'network';
} elseif ( defined( 'WP_USER_ADMIN' ) && WP_USER_ADMIN ) {
$in_admin = 'user';
} else {
$in_admin = 'site';
}
}
if ( 'index' == $id )
if ( 'index' == $id ) {
$id = 'dashboard';
elseif ( 'front' == $id )
} elseif ( 'front' == $id ) {
$in_admin = false;
}
$base = $id;
// If this is the current screen, see if we can be more accurate for post types and taxonomies.
if ( ! $hook_name ) {
if ( isset( $_REQUEST['post_type'] ) )
if ( isset( $_REQUEST['post_type'] ) ) {
$post_type = post_type_exists( $_REQUEST['post_type'] ) ? $_REQUEST['post_type'] : false;
if ( isset( $_REQUEST['taxonomy'] ) )
}
if ( isset( $_REQUEST['taxonomy'] ) ) {
$taxonomy = taxonomy_exists( $_REQUEST['taxonomy'] ) ? $_REQUEST['taxonomy'] : false;
}
switch ( $base ) {
case 'post':
if ( isset( $_GET['post'] ) )
if ( isset( $_GET['post'] ) ) {
$post_id = (int) $_GET['post'];
elseif ( isset( $_POST['post_ID'] ) )
} elseif ( isset( $_POST['post_ID'] ) ) {
$post_id = (int) $_POST['post_ID'];
else
} else {
$post_id = 0;
}
if ( $post_id ) {
$post = get_post( $post_id );
if ( $post )
if ( $post ) {
$post_type = $post->post_type;
}
}
break;
case 'edit-tags':
case 'term':
if ( null === $post_type && is_object_in_taxonomy( 'post', $taxonomy ? $taxonomy : 'post_tag' ) )
if ( null === $post_type && is_object_in_taxonomy( 'post', $taxonomy ? $taxonomy : 'post_tag' ) ) {
$post_type = 'post';
}
break;
case 'upload':
$post_type = 'attachment';
@ -296,25 +307,29 @@ final class WP_Screen {
switch ( $base ) {
case 'post':
if ( null === $post_type )
if ( null === $post_type ) {
$post_type = 'post';
}
$id = $post_type;
break;
case 'edit':
if ( null === $post_type )
if ( null === $post_type ) {
$post_type = 'post';
}
$id .= '-' . $post_type;
break;
case 'edit-tags':
case 'term':
if ( null === $taxonomy )
if ( null === $taxonomy ) {
$taxonomy = 'post_tag';
}
// The edit-tags ID does not contain the post type. Look for it in the request.
if ( null === $post_type ) {
$post_type = 'post';
if ( isset( $_REQUEST['post_type'] ) && post_type_exists( $_REQUEST['post_type'] ) )
if ( isset( $_REQUEST['post_type'] ) && post_type_exists( $_REQUEST['post_type'] ) ) {
$post_type = $_REQUEST['post_type'];
}
}
$id = 'edit-' . $taxonomy;
break;
@ -330,8 +345,9 @@ final class WP_Screen {
if ( isset( self::$_registry[ $id ] ) ) {
$screen = self::$_registry[ $id ];
if ( $screen === get_current_screen() )
if ( $screen === get_current_screen() ) {
return $screen;
}
} else {
$screen = new WP_Screen();
$screen->id = $id;
@ -393,8 +409,9 @@ final class WP_Screen {
* @return bool True if the screen is in the indicated admin, false otherwise.
*/
public function in_admin( $admin = null ) {
if ( empty( $admin ) )
if ( empty( $admin ) ) {
return (bool) $this->in_admin;
}
return ( $admin == $this->in_admin );
}
@ -482,11 +499,13 @@ final class WP_Screen {
* @return string The option value if set, null otherwise.
*/
public function get_option( $option, $key = false ) {
if ( ! isset( $this->_options[ $option ] ) )
if ( ! isset( $this->_options[ $option ] ) ) {
return null;
}
if ( $key ) {
if ( isset( $this->_options[ $option ][ $key ] ) )
if ( isset( $this->_options[ $option ][ $key ] ) ) {
return $this->_options[ $option ][ $key ];
}
return null;
}
return $this->_options[ $option ];
@ -533,8 +552,9 @@ final class WP_Screen {
* @return array Help tab arguments.
*/
public function get_help_tab( $id ) {
if ( ! isset( $this->_help_tabs[ $id ] ) )
if ( ! isset( $this->_help_tabs[ $id ] ) ) {
return null;
}
return $this->_help_tabs[ $id ];
}
@ -568,8 +588,9 @@ final class WP_Screen {
$args['id'] = sanitize_html_class( $args['id'] );
// Ensure we have an ID and title.
if ( ! $args['id'] || ! $args['title'] )
if ( ! $args['id'] || ! $args['title'] ) {
return;
}
// Allows for overriding an existing tab with that ID.
$this->_help_tabs[ $args['id'] ] = $args;
@ -734,7 +755,6 @@ final class WP_Screen {
* @param string $old_help Help text that appears on the screen.
* @param string $screen_id Screen ID.
* @param WP_Screen $this Current WP_Screen instance.
*
*/
$old_help = apply_filters( 'contextual_help', $old_help, $this->id, $this );
@ -751,23 +771,27 @@ final class WP_Screen {
* @param string $old_help_default Default contextual help text.
*/
$default_help = apply_filters( 'default_contextual_help', '' );
if ( $default_help )
if ( $default_help ) {
$old_help = '<p>' . $default_help . '</p>';
}
}
if ( $old_help ) {
$this->add_help_tab( array(
$this->add_help_tab(
array(
'id' => 'old-contextual-help',
'title' => __( 'Overview' ),
'content' => $old_help,
) );
)
);
}
$help_sidebar = $this->get_help_sidebar();
$help_class = 'hidden';
if ( ! $help_sidebar )
if ( ! $help_sidebar ) {
$help_class .= ' no-sidebar';
}
// Time to render!
?>
@ -816,8 +840,9 @@ final class WP_Screen {
echo $tab['content'];
// If it exists, fire tab callback.
if ( ! empty( $tab['callback'] ) )
if ( ! empty( $tab['callback'] ) ) {
call_user_func_array( $tab['callback'], array( $this, $tab ) );
}
?>
</div>
<?php
@ -844,33 +869,39 @@ final class WP_Screen {
*/
$columns = apply_filters( 'screen_layout_columns', array(), $this->id, $this );
if ( ! empty( $columns ) && isset( $columns[ $this->id ] ) )
if ( ! empty( $columns ) && isset( $columns[ $this->id ] ) ) {
$this->add_option( 'layout_columns', array( 'max' => $columns[ $this->id ] ) );
}
if ( $this->get_option( 'layout_columns' ) ) {
$this->columns = (int) get_user_option( "screen_layout_$this->id" );
if ( ! $this->columns && $this->get_option( 'layout_columns', 'default' ) )
if ( ! $this->columns && $this->get_option( 'layout_columns', 'default' ) ) {
$this->columns = $this->get_option( 'layout_columns', 'default' );
}
}
$GLOBALS['screen_layout_columns'] = $this->columns; // Set the global for back-compat.
// Add screen options
if ( $this->show_screen_options() )
if ( $this->show_screen_options() ) {
$this->render_screen_options();
}
?>
</div>
<?php
if ( ! $this->get_help_tabs() && ! $this->show_screen_options() )
if ( ! $this->get_help_tabs() && ! $this->show_screen_options() ) {
return;
}
?>
<div id="screen-meta-links">
<?php if ( $this->get_help_tabs() ) : ?>
<div id="contextual-help-link-wrap" class="hide-if-no-js screen-meta-toggle">
<button type="button" id="contextual-help-link" class="button show-settings" aria-controls="contextual-help-wrap" aria-expanded="false"><?php _e( 'Help' ); ?></button>
</div>
<?php endif;
if ( $this->show_screen_options() ) : ?>
<?php
endif;
if ( $this->show_screen_options() ) :
?>
<div id="screen-options-link-wrap" class="hide-if-no-js screen-meta-toggle">
<button type="button" id="show-settings-link" class="button show-settings" aria-controls="screen-options-wrap" aria-expanded="false"><?php _e( 'Screen Options' ); ?></button>
</div>
@ -880,7 +911,6 @@ final class WP_Screen {
}
/**
*
* @global array $wp_meta_boxes
*
* @return bool
@ -888,8 +918,9 @@ final class WP_Screen {
public function show_screen_options() {
global $wp_meta_boxes;
if ( is_bool( $this->_show_screen_options ) )
if ( is_bool( $this->_show_screen_options ) ) {
return $this->_show_screen_options;
}
$columns = get_column_headers( $this );
@ -924,8 +955,9 @@ final class WP_Screen {
*/
$this->_screen_settings = apply_filters( 'screen_settings', $this->_screen_settings, $this );
if ( $this->_screen_settings || $this->_options )
if ( $this->_screen_settings || $this->_options ) {
$show_screen = true;
}
/**
* Filters whether to show the Screen Options tab.
@ -950,9 +982,11 @@ final class WP_Screen {
* }
*/
public function render_screen_options( $options = array() ) {
$options = wp_parse_args( $options, array(
$options = wp_parse_args(
$options, array(
'wrap' => true,
) );
)
);
$wrapper_start = $wrapper_end = $form_start = $form_end = '';
@ -1096,7 +1130,8 @@ final class WP_Screen {
?>
<fieldset class='columns-prefs'>
<legend class="screen-layout"><?php _e( 'Layout' ); ?></legend><?php
<legend class="screen-layout"><?php _e( 'Layout' ); ?></legend>
<?php
for ( $i = 1; $i <= $num; ++$i ) :
?>
<label class="columns-prefs-<?php echo $i; ?>">
@ -1105,7 +1140,8 @@ final class WP_Screen {
<?php printf( _n( '%s column', '%s columns', $i ), number_format_i18n( $i ) ); ?>
</label>
<?php
endfor; ?>
endfor;
?>
</fieldset>
<?php
}
@ -1189,7 +1225,12 @@ final class WP_Screen {
return;
}
$view_mode_post_types = get_post_types( array( 'hierarchical' => false, 'show_ui' => true ) );
$view_mode_post_types = get_post_types(
array(
'hierarchical' => false,
'show_ui' => true,
)
);
/**
* Filters the post types that have different view mode options.

View File

@ -96,7 +96,7 @@ class WP_Site_Icon {
'post_content' => $url,
'post_mime_type' => $image_type,
'guid' => $url,
'context' => 'site-icon'
'context' => 'site-icon',
);
return $object;

View File

@ -38,32 +38,36 @@ class WP_Terms_List_Table extends WP_List_Table {
public function __construct( $args = array() ) {
global $post_type, $taxonomy, $action, $tax;
parent::__construct( array(
parent::__construct(
array(
'plural' => 'tags',
'singular' => 'tag',
'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
) );
)
);
$action = $this->screen->action;
$post_type = $this->screen->post_type;
$taxonomy = $this->screen->taxonomy;
if ( empty( $taxonomy ) )
if ( empty( $taxonomy ) ) {
$taxonomy = 'post_tag';
}
if ( ! taxonomy_exists( $taxonomy ) )
if ( ! taxonomy_exists( $taxonomy ) ) {
wp_die( __( 'Invalid taxonomy.' ) );
}
$tax = get_taxonomy( $taxonomy );
// @todo Still needed? Maybe just the show_ui part.
if ( empty( $post_type ) || !in_array( $post_type, get_post_types( array( 'show_ui' => true ) ) ) )
if ( empty( $post_type ) || ! in_array( $post_type, get_post_types( array( 'show_ui' => true ) ) ) ) {
$post_type = 'post';
}
}
/**
*
* @return bool
*/
public function ajax_user_can() {
@ -113,22 +117,25 @@ class WP_Terms_List_Table extends WP_List_Table {
'number' => $tags_per_page,
);
if ( !empty( $_REQUEST['orderby'] ) )
if ( ! empty( $_REQUEST['orderby'] ) ) {
$args['orderby'] = trim( wp_unslash( $_REQUEST['orderby'] ) );
}
if ( !empty( $_REQUEST['order'] ) )
if ( ! empty( $_REQUEST['order'] ) ) {
$args['order'] = trim( wp_unslash( $_REQUEST['order'] ) );
}
$this->callback_args = $args;
$this->set_pagination_args( array(
$this->set_pagination_args(
array(
'total_items' => wp_count_terms( $this->screen->taxonomy, compact( 'search' ) ),
'per_page' => $tags_per_page,
) );
)
);
}
/**
*
* @return bool
*/
public function has_items() {
@ -143,7 +150,6 @@ class WP_Terms_List_Table extends WP_List_Table {
}
/**
*
* @return array
*/
protected function get_bulk_actions() {
@ -157,18 +163,17 @@ class WP_Terms_List_Table extends WP_List_Table {
}
/**
*
* @return string
*/
public function current_action() {
if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['delete_tags'] ) && ( 'delete' === $_REQUEST['action'] || 'delete' === $_REQUEST['action2'] ) )
if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['delete_tags'] ) && ( 'delete' === $_REQUEST['action'] || 'delete' === $_REQUEST['action2'] ) ) {
return 'bulk-delete';
}
return parent::current_action();
}
/**
*
* @return array
*/
public function get_columns() {
@ -189,7 +194,6 @@ class WP_Terms_List_Table extends WP_List_Table {
}
/**
*
* @return array
*/
protected function get_sortable_columns() {
@ -198,7 +202,7 @@ class WP_Terms_List_Table extends WP_List_Table {
'description' => 'description',
'slug' => 'slug',
'posts' => 'count',
'links' => 'count'
'links' => 'count',
);
}
@ -207,12 +211,14 @@ class WP_Terms_List_Table extends WP_List_Table {
public function display_rows_or_placeholder() {
$taxonomy = $this->screen->taxonomy;
$args = wp_parse_args( $this->callback_args, array(
$args = wp_parse_args(
$this->callback_args, array(
'page' => 1,
'number' => 20,
'search' => '',
'hide_empty' => 0
) );
'hide_empty' => 0,
)
);
$page = $args['page'];
@ -268,11 +274,13 @@ class WP_Terms_List_Table extends WP_List_Table {
foreach ( $terms as $key => $term ) {
if ( $count >= $end )
if ( $count >= $end ) {
break;
}
if ( $term->parent != $parent && empty( $_REQUEST['s'] ) )
if ( $term->parent != $parent && empty( $_REQUEST['s'] ) ) {
continue;
}
// If the page starts in a subtree, print the parents.
if ( $count == $start && $term->parent > 0 && empty( $_REQUEST['s'] ) ) {
@ -282,8 +290,9 @@ class WP_Terms_List_Table extends WP_List_Table {
$my_parent = get_term( $p, $taxonomy );
$my_parents[] = $my_parent;
$p = $my_parent->parent;
if ( in_array( $p, $parent_ids ) ) // Prevent parent loops.
if ( in_array( $p, $parent_ids ) ) { // Prevent parent loops.
break;
}
$parent_ids[] = $p;
}
unset( $parent_ids );
@ -305,10 +314,11 @@ class WP_Terms_List_Table extends WP_List_Table {
unset( $terms[ $key ] );
if ( isset( $children[$term->term_id] ) && empty( $_REQUEST['s'] ) )
if ( isset( $children[ $term->term_id ] ) && empty( $_REQUEST['s'] ) ) {
$this->_rows( $taxonomy, $terms, $children, $start, $per_page, $count, $term->term_id, $level + 1 );
}
}
}
/**
* @global string $taxonomy
@ -521,20 +531,26 @@ class WP_Terms_List_Table extends WP_List_Table {
$tax = get_taxonomy( $this->screen->taxonomy );
$ptype_object = get_post_type_object( $this->screen->post_type );
if ( ! $ptype_object->show_ui )
if ( ! $ptype_object->show_ui ) {
return $count;
}
if ( $tax->query_var ) {
$args = array( $tax->query_var => $tag->slug );
} else {
$args = array( 'taxonomy' => $tax->name, 'term' => $tag->slug );
$args = array(
'taxonomy' => $tax->name,
'term' => $tag->slug,
);
}
if ( 'post' != $this->screen->post_type )
if ( 'post' != $this->screen->post_type ) {
$args['post_type'] = $this->screen->post_type;
}
if ( 'attachment' === $this->screen->post_type )
if ( 'attachment' === $this->screen->post_type ) {
return "<a href='" . esc_url( add_query_arg( $args, 'upload.php' ) ) . "'>$count</a>";
}
return "<a href='" . esc_url( add_query_arg( $args, 'edit.php' ) ) . "'>$count</a>";
}
@ -545,8 +561,9 @@ class WP_Terms_List_Table extends WP_List_Table {
*/
public function column_links( $tag ) {
$count = number_format_i18n( $tag->count );
if ( $count )
if ( $count ) {
$count = "<a href='link-manager.php?cat_id=$tag->term_id'>$count</a>";
}
return $count;
}
@ -579,8 +596,9 @@ class WP_Terms_List_Table extends WP_List_Table {
public function inline_edit() {
$tax = get_taxonomy( $this->screen->taxonomy );
if ( ! current_user_can( $tax->cap->edit_terms ) )
if ( ! current_user_can( $tax->cap->edit_terms ) ) {
return;
}
?>
<form method="get"><table style="display: none"><tbody id="inlineedit">
@ -602,13 +620,20 @@ class WP_Terms_List_Table extends WP_List_Table {
</div></fieldset>
<?php
$core_columns = array( 'cb' => true, 'description' => true, 'name' => true, 'slug' => true, 'posts' => true );
$core_columns = array(
'cb' => true,
'description' => true,
'name' => true,
'slug' => true,
'posts' => true,
);
list( $columns ) = $this->get_column_info();
foreach ( $columns as $column_name => $column_display_name ) {
if ( isset( $core_columns[$column_name] ) )
if ( isset( $core_columns[ $column_name ] ) ) {
continue;
}
/** This action is documented in wp-admin/includes/class-wp-posts-list-table.php */
do_action( 'quick_edit_custom_box', $column_name, 'edit-tags', $this->screen->taxonomy );

View File

@ -20,7 +20,6 @@ class WP_Theme_Install_List_Table extends WP_Themes_List_Table {
public $features = array();
/**
*
* @return bool
*/
public function ajax_user_can() {
@ -28,7 +27,6 @@ class WP_Theme_Install_List_Table extends WP_Themes_List_Table {
}
/**
*
* @global array $tabs
* @global string $tab
* @global int $paged
@ -48,8 +46,9 @@ class WP_Theme_Install_List_Table extends WP_Themes_List_Table {
$search_terms = array_unique( array_filter( array_map( 'trim', explode( ',', $search_string ) ) ) );
}
if ( ! empty( $_REQUEST['features'] ) )
if ( ! empty( $_REQUEST['features'] ) ) {
$this->features = $_REQUEST['features'];
}
$paged = $this->get_pagenum();
@ -58,8 +57,9 @@ class WP_Theme_Install_List_Table extends WP_Themes_List_Table {
// These are the tabs which are shown on the page,
$tabs = array();
$tabs['dashboard'] = __( 'Search' );
if ( 'search' === $tab )
if ( 'search' === $tab ) {
$tabs['search'] = __( 'Search Results' );
}
$tabs['upload'] = __( 'Upload' );
$tabs['featured'] = _x( 'Featured', 'themes' );
//$tabs['popular'] = _x( 'Popular', 'themes' );
@ -82,10 +82,15 @@ class WP_Theme_Install_List_Table extends WP_Themes_List_Table {
$nonmenu_tabs = apply_filters( 'install_themes_nonmenu_tabs', $nonmenu_tabs );
// If a non-valid menu tab has been selected, And it's not a non-menu action.
if ( empty( $tab ) || ( ! isset( $tabs[ $tab ] ) && ! in_array( $tab, (array) $nonmenu_tabs ) ) )
if ( empty( $tab ) || ( ! isset( $tabs[ $tab ] ) && ! in_array( $tab, (array) $nonmenu_tabs ) ) ) {
$tab = key( $tabs );
}
$args = array( 'page' => $paged, 'per_page' => $per_page, 'fields' => $theme_field_defaults );
$args = array(
'page' => $paged,
'per_page' => $per_page,
'fields' => $theme_field_defaults,
);
switch ( $tab ) {
case 'search':
@ -136,21 +141,25 @@ class WP_Theme_Install_List_Table extends WP_Themes_List_Table {
*/
$args = apply_filters( "install_themes_table_api_args_{$tab}", $args );
if ( ! $args )
if ( ! $args ) {
return;
}
$api = themes_api( 'query_themes', $args );
if ( is_wp_error( $api ) )
if ( is_wp_error( $api ) ) {
wp_die( $api->get_error_message() . '</p> <p><a href="#" onclick="document.location.reload(); return false;">' . __( 'Try again' ) . '</a>' );
}
$this->items = $api->themes;
$this->set_pagination_args( array(
$this->set_pagination_args(
array(
'total_items' => $api->info['results'],
'per_page' => $args['per_page'],
'infinite_scroll' => true,
) );
)
);
}
/**
@ -160,7 +169,6 @@ class WP_Theme_Install_List_Table extends WP_Themes_List_Table {
}
/**
*
* @global array $tabs
* @global string $tab
* @return array
@ -181,7 +189,7 @@ class WP_Theme_Install_List_Table extends WP_Themes_List_Table {
/**
*/
public function display() {
wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' );
wp_nonce_field( 'fetch-list-' . get_class( $this ), '_ajax_fetch_list_nonce' );
?>
<div class="tablenav top themes">
<div class="alignleft actions">
@ -212,10 +220,13 @@ class WP_Theme_Install_List_Table extends WP_Themes_List_Table {
$themes = $this->items;
foreach ( $themes as $theme ) {
?>
<div class="available-theme installable-theme"><?php
<div class="available-theme installable-theme">
<?php
$this->single_row( $theme );
?></div>
<?php } // end foreach $theme_names
?>
</div>
<?php
} // end foreach $theme_names
$this->theme_installer();
}
@ -246,29 +257,36 @@ class WP_Theme_Install_List_Table extends WP_Themes_List_Table {
public function single_row( $theme ) {
global $themes_allowedtags;
if ( empty( $theme ) )
if ( empty( $theme ) ) {
return;
}
$name = wp_kses( $theme->name, $themes_allowedtags );
$author = wp_kses( $theme->author, $themes_allowedtags );
$preview_title = sprintf( __( 'Preview &#8220;%s&#8221;' ), $name );
$preview_url = add_query_arg( array(
$preview_url = add_query_arg(
array(
'tab' => 'theme-information',
'theme' => $theme->slug,
), self_admin_url( 'theme-install.php' ) );
), self_admin_url( 'theme-install.php' )
);
$actions = array();
$install_url = add_query_arg( array(
$install_url = add_query_arg(
array(
'action' => 'install-theme',
'theme' => $theme->slug,
), self_admin_url( 'update.php' ) );
), self_admin_url( 'update.php' )
);
$update_url = add_query_arg( array(
$update_url = add_query_arg(
array(
'action' => 'upgrade-theme',
'theme' => $theme->slug,
), self_admin_url( 'update.php' ) );
), self_admin_url( 'update.php' )
);
$status = $this->_get_theme_status( $theme );
@ -312,7 +330,7 @@ class WP_Theme_Install_List_Table extends WP_Themes_List_Table {
<?php foreach ( $actions as $action ) : ?>
<li><?php echo $action; ?></li>
<?php endforeach; ?>
<li class="hide-if-no-js"><a href="#" class="theme-detail"><?php _e('Details') ?></a></li>
<li class="hide-if-no-js"><a href="#" class="theme-detail"><?php _e( 'Details' ); ?></a></li>
</ul>
</div>
@ -375,26 +393,32 @@ class WP_Theme_Install_List_Table extends WP_Themes_List_Table {
public function install_theme_info( $theme ) {
global $themes_allowedtags;
if ( empty( $theme ) )
if ( empty( $theme ) ) {
return;
}
$name = wp_kses( $theme->name, $themes_allowedtags );
$author = wp_kses( $theme->author, $themes_allowedtags );
$install_url = add_query_arg( array(
$install_url = add_query_arg(
array(
'action' => 'install-theme',
'theme' => $theme->slug,
), self_admin_url( 'update.php' ) );
), self_admin_url( 'update.php' )
);
$update_url = add_query_arg( array(
$update_url = add_query_arg(
array(
'action' => 'upgrade-theme',
'theme' => $theme->slug,
), self_admin_url( 'update.php' ) );
), self_admin_url( 'update.php' )
);
$status = $this->_get_theme_status( $theme );
?>
<div class="install-theme-info"><?php
<div class="install-theme-info">
<?php
switch ( $status ) {
case 'update_available':
echo '<a class="theme-install button button-primary" href="' . esc_url( wp_nonce_url( $update_url, 'upgrade-theme_' . $theme->slug ) ) . '" title="' . esc_attr( sprintf( __( 'Update to version %s' ), $theme->version ) ) . '">' . __( 'Update' ) . '</a>';
@ -407,16 +431,25 @@ class WP_Theme_Install_List_Table extends WP_Themes_List_Table {
default:
echo '<a class="theme-install button button-primary" href="' . esc_url( wp_nonce_url( $install_url, 'install-theme_' . $theme->slug ) ) . '">' . __( 'Install' ) . '</a>';
break;
} ?>
}
?>
<h3 class="theme-name"><?php echo $name; ?></h3>
<span class="theme-by"><?php printf( __( 'By %s' ), $author ); ?></span>
<?php if ( isset( $theme->screenshot_url ) ) : ?>
<img class="theme-screenshot" src="<?php echo esc_url( $theme->screenshot_url ); ?>" alt="" />
<?php endif; ?>
<div class="theme-details">
<?php wp_star_rating( array( 'rating' => $theme->rating, 'type' => 'percent', 'number' => $theme->num_ratings ) ); ?>
<?php
wp_star_rating(
array(
'rating' => $theme->rating,
'type' => 'percent',
'number' => $theme->num_ratings,
)
);
?>
<div class="theme-version">
<strong><?php _e('Version:') ?> </strong>
<strong><?php _e( 'Version:' ); ?> </strong>
<?php echo wp_kses( $theme->version, $themes_allowedtags ); ?>
</div>
<div class="theme-description">
@ -456,13 +489,14 @@ class WP_Theme_Install_List_Table extends WP_Themes_List_Table {
$installed_theme = wp_get_theme( $theme->slug );
if ( $installed_theme->exists() ) {
if ( version_compare( $installed_theme->get('Version'), $theme->version, '=' ) )
if ( version_compare( $installed_theme->get( 'Version' ), $theme->version, '=' ) ) {
$status = 'latest_installed';
elseif ( version_compare( $installed_theme->get('Version'), $theme->version, '>' ) )
} elseif ( version_compare( $installed_theme->get( 'Version' ), $theme->version, '>' ) ) {
$status = 'newer_installed';
else
} else {
$status = 'update_available';
}
}
return $status;
}

View File

@ -30,14 +30,15 @@ class WP_Themes_List_Table extends WP_List_Table {
* @param array $args An associative array of arguments.
*/
public function __construct( $args = array() ) {
parent::__construct( array(
parent::__construct(
array(
'ajax' => true,
'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
) );
)
);
}
/**
*
* @return bool
*/
public function ajax_user_can() {
@ -50,18 +51,21 @@ class WP_Themes_List_Table extends WP_List_Table {
public function prepare_items() {
$themes = wp_get_themes( array( 'allowed' => true ) );
if ( ! empty( $_REQUEST['s'] ) )
if ( ! empty( $_REQUEST['s'] ) ) {
$this->search_terms = array_unique( array_filter( array_map( 'trim', explode( ',', strtolower( wp_unslash( $_REQUEST['s'] ) ) ) ) ) );
}
if ( ! empty( $_REQUEST['features'] ) )
if ( ! empty( $_REQUEST['features'] ) ) {
$this->features = $_REQUEST['features'];
}
if ( $this->search_terms || $this->features ) {
foreach ( $themes as $key => $theme ) {
if ( ! $this->search_theme( $theme ) )
if ( ! $this->search_theme( $theme ) ) {
unset( $themes[ $key ] );
}
}
}
unset( $themes[ get_option( 'stylesheet' ) ] );
WP_Theme::sort_by_name( $themes );
@ -73,11 +77,13 @@ class WP_Themes_List_Table extends WP_List_Table {
$this->items = array_slice( $themes, $start, $per_page, true );
$this->set_pagination_args( array(
$this->set_pagination_args(
array(
'total_items' => count( $themes ),
'per_page' => $per_page,
'infinite_scroll' => true,
) );
)
);
}
/**
@ -115,8 +121,9 @@ class WP_Themes_List_Table extends WP_List_Table {
* @param string $which
*/
public function tablenav( $which = 'top' ) {
if ( $this->get_pagination_arg( 'total_pages' ) <= 1 )
if ( $this->get_pagination_arg( 'total_pages' ) <= 1 ) {
return;
}
?>
<div class="tablenav themes <?php echo $which; ?>">
<?php $this->pagination( $which ); ?>
@ -129,7 +136,7 @@ class WP_Themes_List_Table extends WP_List_Table {
/**
*/
public function display() {
wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' );
wp_nonce_field( 'fetch-list-' . get_class( $this ), '_ajax_fetch_list_nonce' );
?>
<?php $this->tablenav( 'top' ); ?>
@ -142,7 +149,6 @@ class WP_Themes_List_Table extends WP_List_Table {
}
/**
*
* @return array
*/
public function get_columns() {
@ -167,7 +173,9 @@ class WP_Themes_List_Table extends WP_List_Table {
$themes = $this->items;
foreach ( $themes as $theme ) :
?><div class="available-theme"><?php
?>
<div class="available-theme">
<?php
$template = $theme->get_template();
$stylesheet = $theme->get_stylesheet();
@ -175,7 +183,7 @@ class WP_Themes_List_Table extends WP_List_Table {
$version = $theme->display( 'Version' );
$author = $theme->display( 'Author' );
$activate_link = wp_nonce_url( "themes.php?action=activate&amp;template=" . urlencode( $template ) . "&amp;stylesheet=" . urlencode( $stylesheet ), 'switch-theme_' . $stylesheet );
$activate_link = wp_nonce_url( 'themes.php?action=activate&amp;template=' . urlencode( $template ) . '&amp;stylesheet=' . urlencode( $stylesheet ), 'switch-theme_' . $stylesheet );
$actions = array();
$actions['activate'] = '<a href="' . $activate_link . '" class="activatelink" title="'
@ -186,10 +194,11 @@ class WP_Themes_List_Table extends WP_List_Table {
. __( 'Live Preview' ) . '</a>';
}
if ( ! is_multisite() && current_user_can( 'delete_themes' ) )
if ( ! is_multisite() && current_user_can( 'delete_themes' ) ) {
$actions['delete'] = '<a class="submitdelete deletion" href="' . wp_nonce_url( 'themes.php?action=delete&amp;stylesheet=' . urlencode( $stylesheet ), 'delete-theme_' . $stylesheet )
. '" onclick="' . "return confirm( '" . esc_js( sprintf( __( "You are about to delete this theme '%s'\n 'Cancel' to stop, 'OK' to delete." ), $title ) )
. "' );" . '">' . __( 'Delete' ) . '</a>';
}
/** This filter is documented in wp-admin/includes/class-wp-ms-themes-list-table.php */
$actions = apply_filters( 'theme_action_links', $actions, $theme, 'all' );
@ -219,7 +228,7 @@ class WP_Themes_List_Table extends WP_List_Table {
<?php foreach ( $actions as $action ) : ?>
<li><?php echo $action; ?></li>
<?php endforeach; ?>
<li class="hide-if-no-js"><a href="#" class="theme-detail"><?php _e('Details') ?></a></li>
<li class="hide-if-no-js"><a href="#" class="theme-detail"><?php _e( 'Details' ); ?></a></li>
</ul>
<?php echo $delete_action; ?>
@ -229,11 +238,15 @@ class WP_Themes_List_Table extends WP_List_Table {
<div class="themedetaildiv hide-if-js">
<p><strong><?php _e( 'Version:' ); ?></strong> <?php echo $version; ?></p>
<p><?php echo $theme->display( 'Description' ); ?></p>
<?php if ( $theme->parent() ) {
printf( ' <p class="howto">' . __( 'This <a href="%1$s">child theme</a> requires its parent theme, %2$s.' ) . '</p>',
<?php
if ( $theme->parent() ) {
printf(
' <p class="howto">' . __( 'This <a href="%1$s">child theme</a> requires its parent theme, %2$s.' ) . '</p>',
__( 'https://codex.wordpress.org/Child_Themes' ),
$theme->parent()->display( 'Name' ) );
} ?>
$theme->parent()->display( 'Name' )
);
}
?>
</div>
</div>
@ -248,14 +261,16 @@ class WP_Themes_List_Table extends WP_List_Table {
public function search_theme( $theme ) {
// Search the features
foreach ( $this->features as $word ) {
if ( ! in_array( $word, $theme->get('Tags') ) )
if ( ! in_array( $word, $theme->get( 'Tags' ) ) ) {
return false;
}
}
// Match all phrases
foreach ( $this->search_terms as $word ) {
if ( in_array( $word, $theme->get('Tags') ) )
if ( in_array( $word, $theme->get( 'Tags' ) ) ) {
continue;
}
foreach ( array( 'Name', 'Description', 'Author', 'AuthorURI' ) as $header ) {
// Don't mark up; Do translate.
@ -264,11 +279,13 @@ class WP_Themes_List_Table extends WP_List_Table {
}
}
if ( false !== stripos( $theme->get_stylesheet(), $word ) )
if ( false !== stripos( $theme->get_stylesheet(), $word ) ) {
continue;
}
if ( false !== stripos( $theme->get_template(), $word ) )
if ( false !== stripos( $theme->get_template(), $word ) ) {
continue;
}
return false;
}
@ -293,8 +310,9 @@ class WP_Themes_List_Table extends WP_List_Table {
'total_pages' => ! empty( $this->_pagination_args['total_pages'] ) ? $this->_pagination_args['total_pages'] : 1,
);
if ( is_array( $extra_args ) )
if ( is_array( $extra_args ) ) {
$args = array_merge( $args, $extra_args );
}
printf( "<script type='text/javascript'>var theme_list_args = %s;</script>\n", wp_json_encode( $args ) );
parent::_js_vars();

View File

@ -29,21 +29,25 @@ class WP_Upgrader_Skin {
public $options = array();
/**
*
* @param array $args
*/
public function __construct( $args = array() ) {
$defaults = array( 'url' => '', 'nonce' => '', 'title' => '', 'context' => false );
$defaults = array(
'url' => '',
'nonce' => '',
'title' => '',
'context' => false,
);
$this->options = wp_parse_args( $args, $defaults );
}
/**
*
* @param WP_Upgrader $upgrader
*/
public function set_upgrader( &$upgrader ) {
if ( is_object($upgrader) )
if ( is_object( $upgrader ) ) {
$this->upgrader =& $upgrader;
}
$this->add_strings();
}
@ -115,31 +119,32 @@ class WP_Upgrader_Skin {
}
/**
*
* @param string|WP_Error $errors
*/
public function error( $errors ) {
if ( ! $this->done_header )
if ( ! $this->done_header ) {
$this->header();
}
if ( is_string( $errors ) ) {
$this->feedback( $errors );
} elseif ( is_wp_error( $errors ) && $errors->get_error_code() ) {
foreach ( $errors->get_error_messages() as $message ) {
if ( $errors->get_error_data() && is_string( $errors->get_error_data() ) )
if ( $errors->get_error_data() && is_string( $errors->get_error_data() ) ) {
$this->feedback( $message . ' ' . esc_html( strip_tags( $errors->get_error_data() ) ) );
else
} else {
$this->feedback( $message );
}
}
}
}
/**
*
* @param string $string
*/
public function feedback( $string ) {
if ( isset( $this->upgrader->strings[$string] ) )
if ( isset( $this->upgrader->strings[ $string ] ) ) {
$string = $this->upgrader->strings[ $string ];
}
if ( strpos( $string, '%' ) !== false ) {
$args = func_get_args();
@ -150,8 +155,9 @@ class WP_Upgrader_Skin {
$string = vsprintf( $string, $args );
}
}
if ( empty($string) )
if ( empty( $string ) ) {
return;
}
show_message( $string );
}

View File

@ -120,11 +120,12 @@ class WP_Upgrader {
* instance.
*/
public function __construct( $skin = null ) {
if ( null == $skin )
if ( null == $skin ) {
$this->skin = new WP_Upgrader_Skin();
else
} else {
$this->skin = $skin;
}
}
/**
* Initialize the upgrader.
@ -190,40 +191,48 @@ class WP_Upgrader {
if ( ! WP_Filesystem( $credentials, $directories[0], $allow_relaxed_file_ownership ) ) {
$error = true;
if ( is_object($wp_filesystem) && $wp_filesystem->errors->get_error_code() )
if ( is_object( $wp_filesystem ) && $wp_filesystem->errors->get_error_code() ) {
$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) )
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->get_error_code() )
if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
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() )
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() )
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() )
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() )
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) )
if ( ! $wp_filesystem->find_folder( $dir ) ) {
return new WP_Error( 'fs_no_folder', sprintf( $this->strings['fs_no_folder'], esc_html( basename( $dir ) ) ) );
}
break;
}
}
@ -252,21 +261,25 @@ class WP_Upgrader {
* @param WP_Upgrader $this The WP_Upgrader instance.
*/
$reply = apply_filters( 'upgrader_pre_download', false, $package, $this );
if ( false !== $reply )
if ( false !== $reply ) {
return $reply;
}
if ( ! preg_match('!^(http|https|ftp)://!i', $package) && file_exists($package) ) //Local file or remote?
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) )
if ( empty( $package ) ) {
return new WP_Error( 'no_package', $this->strings['no_package'] );
}
$this->skin->feedback( 'downloading_package', $package );
$download_file = download_url( $package );
if ( is_wp_error($download_file) )
if ( is_wp_error( $download_file ) ) {
return new WP_Error( 'download_failed', $this->strings['download_failed'], $download_file->get_error_message() );
}
return $download_file;
}
@ -293,23 +306,26 @@ class WP_Upgrader {
//Clean up contents of upgrade directory beforehand.
$upgrade_files = $wp_filesystem->dirlist( $upgrade_folder );
if ( ! empty( $upgrade_files ) ) {
foreach ( $upgrade_files as $file )
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) )
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 )
if ( $delete_package ) {
unlink( $package );
}
if ( is_wp_error( $result ) ) {
$wp_filesystem->delete( $working_dir, true );
@ -437,7 +453,7 @@ class WP_Upgrader {
'clear_destination' => false,
'clear_working' => false,
'abort_if_destination_exists' => true,
'hook_extra' => array()
'hook_extra' => array(),
);
$args = wp_parse_args( $args, $defaults );
@ -648,7 +664,7 @@ class WP_Upgrader {
'abort_if_destination_exists' => true, // Abort if the Destination directory exists, Pass clear_destination as false please
'clear_working' => true,
'is_multi' => false,
'hook_extra' => array() // Pass any extra $hook_extra args here, this will be passed to any hooked filters.
'hook_extra' => array(), // Pass any extra $hook_extra args here, this will be passed to any hooked filters.
);
$options = wp_parse_args( $options, $defaults );
@ -738,14 +754,16 @@ class WP_Upgrader {
}
// With the given options, this installs it to the destination directory.
$result = $this->install_package( array(
$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']
) );
'hook_extra' => $options['hook_extra'],
)
);
$this->skin->set_result( $result );
if ( is_wp_error( $result ) ) {

View File

@ -43,17 +43,20 @@ class WP_Users_List_Table extends WP_List_Table {
* @param array $args An associative array of arguments.
*/
public function __construct( $args = array() ) {
parent::__construct( array(
parent::__construct(
array(
'singular' => 'user',
'plural' => 'users',
'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
) );
)
);
$this->is_site_users = 'site-users-network' === $this->screen->id;
if ( $this->is_site_users )
if ( $this->is_site_users ) {
$this->site_id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
}
}
/**
* Check the current user's permissions.
@ -63,11 +66,12 @@ class WP_Users_List_Table extends WP_List_Table {
* @return bool
*/
public function ajax_user_can() {
if ( $this->is_site_users )
if ( $this->is_site_users ) {
return current_user_can( 'manage_sites' );
else
} else {
return current_user_can( 'list_users' );
}
}
/**
* Prepare the users list for display.
@ -95,7 +99,7 @@ class WP_Users_List_Table extends WP_List_Table {
'offset' => ( $paged - 1 ) * $users_per_page,
'include' => wp_get_users_with_no_role( $this->site_id ),
'search' => $usersearch,
'fields' => 'all_with_meta'
'fields' => 'all_with_meta',
);
} else {
$args = array(
@ -103,21 +107,25 @@ class WP_Users_List_Table extends WP_List_Table {
'offset' => ( $paged - 1 ) * $users_per_page,
'role' => $role,
'search' => $usersearch,
'fields' => 'all_with_meta'
'fields' => 'all_with_meta',
);
}
if ( '' !== $args['search'] )
if ( '' !== $args['search'] ) {
$args['search'] = '*' . $args['search'] . '*';
}
if ( $this->is_site_users )
if ( $this->is_site_users ) {
$args['blog_id'] = $this->site_id;
}
if ( isset( $_REQUEST['orderby'] ) )
if ( isset( $_REQUEST['orderby'] ) ) {
$args['orderby'] = $_REQUEST['orderby'];
}
if ( isset( $_REQUEST['order'] ) )
if ( isset( $_REQUEST['order'] ) ) {
$args['order'] = $_REQUEST['order'];
}
/**
* Filters the query arguments used to retrieve users for the current users list table.
@ -134,10 +142,12 @@ class WP_Users_List_Table extends WP_List_Table {
$this->items = $wp_user_search->get_results();
$this->set_pagination_args( array(
$this->set_pagination_args(
array(
'total_items' => $wp_user_search->get_total(),
'per_page' => $users_per_page,
) );
)
);
}
/**
@ -186,8 +196,9 @@ class WP_Users_List_Table extends WP_List_Table {
$role_links = array();
$role_links['all'] = "<a href='$url'$current_link_attributes>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_users, 'users' ), number_format_i18n( $total_users ) ) . '</a>';
foreach ( $wp_roles->get_names() as $this_role => $name ) {
if ( !isset($avail_roles[$this_role]) )
if ( ! isset( $avail_roles[ $this_role ] ) ) {
continue;
}
$current_link_attributes = '';
@ -230,12 +241,14 @@ class WP_Users_List_Table extends WP_List_Table {
$actions = array();
if ( is_multisite() ) {
if ( current_user_can( 'remove_users' ) )
if ( current_user_can( 'remove_users' ) ) {
$actions['remove'] = __( 'Remove' );
}
} else {
if ( current_user_can( 'delete_users' ) )
if ( current_user_can( 'delete_users' ) ) {
$actions['delete'] = __( 'Delete' );
}
}
return $actions;
}
@ -254,9 +267,9 @@ class WP_Users_List_Table extends WP_List_Table {
?>
<div class="alignleft actions">
<?php if ( current_user_can( 'promote_users' ) && $this->has_items() ) : ?>
<label class="screen-reader-text" for="<?php echo $id ?>"><?php _e( 'Change role to&hellip;' ) ?></label>
<select name="<?php echo $id ?>" id="<?php echo $id ?>">
<option value=""><?php _e( 'Change role to&hellip;' ) ?></option>
<label class="screen-reader-text" for="<?php echo $id; ?>"><?php _e( 'Change role to&hellip;' ); ?></label>
<select name="<?php echo $id; ?>" id="<?php echo $id; ?>">
<option value=""><?php _e( 'Change role to&hellip;' ); ?></option>
<?php wp_dropdown_roles(); ?>
</select>
<?php
@ -321,11 +334,12 @@ class WP_Users_List_Table extends WP_List_Table {
'name' => __( 'Name' ),
'email' => __( 'Email' ),
'role' => __( 'Role' ),
'posts' => __( 'Posts' )
'posts' => __( 'Posts' ),
);
if ( $this->is_site_users )
if ( $this->is_site_users ) {
unset( $c['posts'] );
}
return $c;
}
@ -353,8 +367,9 @@ class WP_Users_List_Table extends WP_List_Table {
*/
public function display_rows() {
// Query the post counts for this page
if ( ! $this->is_site_users )
if ( ! $this->is_site_users ) {
$post_counts = count_many_users_posts( array_keys( $this->items ) );
}
foreach ( $this->items as $userid => $user_object ) {
echo "\n\t" . $this->single_row( $user_object, '', '', isset( $post_counts ) ? $post_counts[ $userid ] : 0 );
@ -382,10 +397,11 @@ class WP_Users_List_Table extends WP_List_Table {
$user_object->filter = 'display';
$email = $user_object->user_email;
if ( $this->is_site_users )
if ( $this->is_site_users ) {
$url = "site-users.php?id={$this->site_id}&amp;";
else
} else {
$url = 'users.php?';
}
$user_roles = $this->get_role_list( $user_object );
@ -412,10 +428,12 @@ class WP_Users_List_Table extends WP_List_Table {
$edit = "<strong>{$user_object->user_login}{$super_admin}</strong><br />";
}
if ( !is_multisite() && get_current_user_id() != $user_object->ID && current_user_can( 'delete_user', $user_object->ID ) )
$actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url( "users.php?action=delete&amp;user=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Delete' ) . "</a>";
if ( is_multisite() && get_current_user_id() != $user_object->ID && current_user_can( 'remove_user', $user_object->ID ) )
$actions['remove'] = "<a class='submitdelete' href='" . wp_nonce_url( $url."action=remove&amp;user=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Remove' ) . "</a>";
if ( ! is_multisite() && get_current_user_id() != $user_object->ID && current_user_can( 'delete_user', $user_object->ID ) ) {
$actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url( "users.php?action=delete&amp;user=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Delete' ) . '</a>';
}
if ( is_multisite() && get_current_user_id() != $user_object->ID && current_user_can( 'remove_user', $user_object->ID ) ) {
$actions['remove'] = "<a class='submitdelete' href='" . wp_nonce_url( $url . "action=remove&amp;user=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Remove' ) . '</a>';
}
// Add a link to the user's author archive, if not empty.
$author_posts_url = get_author_posts_url( $user_object->ID );
@ -528,7 +546,7 @@ class WP_Users_List_Table extends WP_List_Table {
if ( $primary === $column_name ) {
$r .= $this->row_actions( $actions );
}
$r .= "</td>";
$r .= '</td>';
}
}
$r .= '</tr>';

View File

@ -32,11 +32,14 @@ function comment_exists( $comment_author, $comment_date, $timezone = 'blog' ) {
$date_field = 'comment_date_gmt';
}
return $wpdb->get_var( $wpdb->prepare("SELECT comment_post_ID FROM $wpdb->comments
return $wpdb->get_var(
$wpdb->prepare(
"SELECT comment_post_ID FROM $wpdb->comments
WHERE comment_author = %s AND $date_field = %s",
stripslashes( $comment_author ),
stripslashes( $comment_date )
) );
)
);
}
/**
@ -45,21 +48,28 @@ function comment_exists( $comment_author, $comment_date, $timezone = 'blog' ) {
* @since 2.0.0
*/
function edit_comment() {
if ( ! current_user_can( 'edit_comment', (int) $_POST['comment_ID'] ) )
if ( ! current_user_can( 'edit_comment', (int) $_POST['comment_ID'] ) ) {
wp_die( __( 'Sorry, you are not allowed to edit comments on this post.' ) );
}
if ( isset( $_POST['newcomment_author'] ) )
if ( isset( $_POST['newcomment_author'] ) ) {
$_POST['comment_author'] = $_POST['newcomment_author'];
if ( isset( $_POST['newcomment_author_email'] ) )
}
if ( isset( $_POST['newcomment_author_email'] ) ) {
$_POST['comment_author_email'] = $_POST['newcomment_author_email'];
if ( isset( $_POST['newcomment_author_url'] ) )
}
if ( isset( $_POST['newcomment_author_url'] ) ) {
$_POST['comment_author_url'] = $_POST['newcomment_author_url'];
if ( isset( $_POST['comment_status'] ) )
}
if ( isset( $_POST['comment_status'] ) ) {
$_POST['comment_approved'] = $_POST['comment_status'];
if ( isset( $_POST['content'] ) )
}
if ( isset( $_POST['content'] ) ) {
$_POST['comment_content'] = $_POST['content'];
if ( isset( $_POST['comment_ID'] ) )
}
if ( isset( $_POST['comment_ID'] ) ) {
$_POST['comment_ID'] = (int) $_POST['comment_ID'];
}
foreach ( array( 'aa', 'mm', 'jj', 'hh', 'mn' ) as $timeunit ) {
if ( ! empty( $_POST[ 'hidden_' . $timeunit ] ) && $_POST[ 'hidden_' . $timeunit ] != $_POST[ $timeunit ] ) {
@ -94,8 +104,9 @@ function edit_comment() {
* @return WP_Comment|false Comment if found. False on failure.
*/
function get_comment_to_edit( $id ) {
if ( !$comment = get_comment($id) )
if ( ! $comment = get_comment( $id ) ) {
return false;
}
$comment->comment_ID = (int) $comment->comment_ID;
$comment->comment_post_ID = (int) $comment->comment_post_ID;
@ -144,21 +155,25 @@ function get_pending_comments_num( $post_id ) {
$pending = $wpdb->get_results( "SELECT comment_post_ID, COUNT(comment_ID) as num_comments FROM $wpdb->comments WHERE comment_post_ID IN ( $post_id_in ) AND comment_approved = '0' GROUP BY comment_post_ID", ARRAY_A );
if ( $single ) {
if ( empty($pending) )
if ( empty( $pending ) ) {
return 0;
else
} else {
return absint( $pending[0]['num_comments'] );
}
}
$pending_keyed = array();
// Default to zero pending for all posts in request
foreach ( $post_id_array as $id )
foreach ( $post_id_array as $id ) {
$pending_keyed[ $id ] = 0;
}
if ( !empty($pending) )
foreach ( $pending as $pend )
if ( ! empty( $pending ) ) {
foreach ( $pending as $pend ) {
$pending_keyed[ $pend['comment_post_ID'] ] = absint( $pend['num_comments'] );
}
}
return $pending_keyed;
}
@ -180,9 +195,10 @@ function floated_admin_avatar( $name ) {
* @since 2.7.0
*/
function enqueue_comment_hotkeys_js() {
if ( 'true' == get_user_option( 'comment_shortcuts' ) )
if ( 'true' == get_user_option( 'comment_shortcuts' ) ) {
wp_enqueue_script( 'jquery-table-hotkeys' );
}
}
/**
* Display error message at bottom of comments.

View File

@ -35,13 +35,15 @@ function wp_credits() {
$response = wp_remote_get( $url, $options );
if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) )
if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
return false;
}
$results = json_decode( wp_remote_retrieve_body( $response ), true );
if ( ! is_array( $results ) )
if ( ! is_array( $results ) ) {
return false;
}
set_site_transient( 'wordpress_credits_' . $locale, $results, DAY_IN_SECONDS );
}

View File

@ -28,18 +28,21 @@ function wp_dashboard_setup() {
if ( $response && $response['upgrade'] ) {
add_filter( 'postbox_classes_dashboard_dashboard_browser_nag', 'dashboard_browser_nag_class' );
if ( $response['insecure'] )
if ( $response['insecure'] ) {
wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'You are using an insecure browser!' ), 'wp_dashboard_browser_nag' );
else
} else {
wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'Your browser is out of date!' ), 'wp_dashboard_browser_nag' );
}
}
// Right Now
if ( is_blog_admin() && current_user_can('edit_posts') )
if ( is_blog_admin() && current_user_can( 'edit_posts' ) ) {
wp_add_dashboard_widget( 'dashboard_right_now', __( 'At a Glance' ), 'wp_dashboard_right_now' );
}
if ( is_network_admin() )
if ( is_network_admin() ) {
wp_add_dashboard_widget( 'network_dashboard_right_now', __( 'Right Now' ), 'wp_network_dashboard_right_now' );
}
// Activity Widget
if ( is_blog_admin() ) {
@ -171,12 +174,14 @@ function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_
$side_widgets = array( 'dashboard_quick_press', 'dashboard_primary' );
$location = 'normal';
if ( in_array($widget_id, $side_widgets) )
if ( in_array( $widget_id, $side_widgets ) ) {
$location = 'side';
}
$priority = 'core';
if ( 'dashboard_browser_nag' === $widget_id )
if ( 'dashboard_browser_nag' === $widget_id ) {
$priority = 'high';
}
add_meta_box( $widget_id, $widget_name, $callback, $screen, $location, $priority, $callback_args );
}
@ -266,7 +271,6 @@ function wp_dashboard_right_now() {
} else {
printf( '<li class="%1$s-count"><span>%2$s</span></li>', $post_type, $text );
}
}
}
// Comments
@ -282,11 +286,13 @@ function wp_dashboard_right_now() {
/* translators: %s: number of comments in moderation */
$aria_label = sprintf( _nx( '%s comment in moderation', '%s comments in moderation', $num_comm->moderated, 'comments' ), $moderated_comments_count_i18n );
?>
<li class="comment-mod-count<?php
<li class="comment-mod-count
<?php
if ( ! $num_comm->moderated ) {
echo ' hidden';
}
?>"><a href="edit-comments.php?comment_status=moderated" aria-label="<?php esc_attr_e( $aria_label ); ?>"><?php echo $text; ?></a></li>
?>
"><a href="edit-comments.php?comment_status=moderated" aria-label="<?php esc_attr_e( $aria_label ); ?>"><?php echo $text; ?></a></li>
<?php
}
@ -372,11 +378,13 @@ function wp_dashboard_right_now() {
$actions = ob_get_clean();
if ( !empty( $actions ) ) : ?>
if ( ! empty( $actions ) ) :
?>
<div class="sub">
<?php echo $actions; ?>
</div>
<?php endif;
<?php
endif;
}
/**
@ -384,10 +392,12 @@ function wp_dashboard_right_now() {
*/
function wp_network_dashboard_right_now() {
$actions = array();
if ( current_user_can('create_sites') )
if ( current_user_can( 'create_sites' ) ) {
$actions['create-site'] = '<a href="' . network_admin_url( 'site-new.php' ) . '">' . __( 'Create a New Site' ) . '</a>';
if ( current_user_can('create_users') )
}
if ( current_user_can( 'create_users' ) ) {
$actions['create-user'] = '<a href="' . network_admin_url( 'user-new.php' ) . '">' . __( 'Create a New User' ) . '</a>';
}
$c_users = get_user_count();
$c_blogs = get_blog_count();
@ -487,9 +497,10 @@ function wp_dashboard_quick_press( $error_msg = false ) {
$post = get_default_post_to_edit( 'post', true );
$user_id = get_current_user_id();
// Don't create an option if this is a super admin who does not belong to this site.
if ( in_array( get_current_blog_id(), array_keys( get_blogs_of_user( $user_id ) ) ) )
if ( in_array( get_current_blog_id(), array_keys( get_blogs_of_user( $user_id ) ) ) ) {
update_user_option( $user_id, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID
}
}
$post_ID = (int) $post->ID;
?>
@ -545,7 +556,7 @@ function wp_dashboard_recent_drafts( $drafts = false ) {
'author' => get_current_user_id(),
'posts_per_page' => 4,
'orderby' => 'modified',
'order' => 'DESC'
'order' => 'DESC',
);
/**
@ -612,11 +623,13 @@ function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
if ( current_user_can( 'edit_comment', $comment->comment_ID ) ) {
// Pre-order it: Approve | Reply | Edit | Spam | Trash.
$actions = array(
'approve' => '', 'unapprove' => '',
'approve' => '',
'unapprove' => '',
'reply' => '',
'edit' => '',
'spam' => '',
'trash' => '', 'delete' => '',
'trash' => '',
'delete' => '',
'view' => '',
);
@ -761,20 +774,24 @@ function wp_dashboard_site_activity() {
echo '<div id="activity-widget">';
$future_posts = wp_dashboard_recent_posts( array(
$future_posts = wp_dashboard_recent_posts(
array(
'max' => 5,
'status' => 'future',
'order' => 'ASC',
'title' => __( 'Publishing Soon' ),
'id' => 'future-posts',
) );
$recent_posts = wp_dashboard_recent_posts( array(
)
);
$recent_posts = wp_dashboard_recent_posts(
array(
'max' => 5,
'status' => 'publish',
'order' => 'DESC',
'title' => __( 'Recently Published' ),
'id' => 'published-posts',
) );
)
);
$recent_comments = wp_dashboard_recent_comments();
@ -894,22 +911,25 @@ function wp_dashboard_recent_comments( $total_items = 5 ) {
$comments_query = array(
'number' => $total_items * 5,
'offset' => 0
'offset' => 0,
);
if ( ! current_user_can( 'edit_posts' ) )
if ( ! current_user_can( 'edit_posts' ) ) {
$comments_query['status'] = 'approve';
}
while ( count( $comments ) < $total_items && $possible = get_comments( $comments_query ) ) {
if ( ! is_array( $possible ) ) {
break;
}
foreach ( $possible as $comment ) {
if ( ! current_user_can( 'read_post', $comment->comment_post_ID ) )
if ( ! current_user_can( 'read_post', $comment->comment_post_ID ) ) {
continue;
}
$comments[] = $comment;
if ( count( $comments ) == $total_items )
if ( count( $comments ) == $total_items ) {
break 2;
}
}
$comments_query['offset'] += $comments_query['number'];
$comments_query['number'] = $total_items * 10;
}
@ -919,8 +939,9 @@ function wp_dashboard_recent_comments( $total_items = 5 ) {
echo '<h3>' . __( 'Recent Comments' ) . '</h3>';
echo '<ul id="the-comment-list" data-wp-lists="list:comment">';
foreach ( $comments as $comment )
foreach ( $comments as $comment ) {
_wp_dashboard_recent_comments_row( $comment );
}
echo '</ul>';
if ( current_user_can( 'edit_posts' ) ) {
@ -949,7 +970,7 @@ function wp_dashboard_rss_output( $widget_id ) {
$widgets = get_option( 'dashboard_widget_options' );
echo '<div class="rss-widget">';
wp_widget_rss_output( $widgets[ $widget_id ] );
echo "</div>";
echo '</div>';
}
/**
@ -1020,7 +1041,12 @@ function wp_dashboard_trigger_widget_control( $widget_control_id = false ) {
global $wp_dashboard_control_callbacks;
if ( is_scalar( $widget_control_id ) && $widget_control_id && isset( $wp_dashboard_control_callbacks[ $widget_control_id ] ) && is_callable( $wp_dashboard_control_callbacks[ $widget_control_id ] ) ) {
call_user_func( $wp_dashboard_control_callbacks[$widget_control_id], '', array( 'id' => $widget_control_id, 'callback' => $wp_dashboard_control_callbacks[$widget_control_id] ) );
call_user_func(
$wp_dashboard_control_callbacks[ $widget_control_id ], '', array(
'id' => $widget_control_id,
'callback' => $wp_dashboard_control_callbacks[ $widget_control_id ],
)
);
}
}
@ -1036,11 +1062,13 @@ function wp_dashboard_trigger_widget_control( $widget_control_id = false ) {
* @param array $form_inputs
*/
function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) {
if ( !$widget_options = get_option( 'dashboard_widget_options' ) )
if ( ! $widget_options = get_option( 'dashboard_widget_options' ) ) {
$widget_options = array();
}
if ( !isset($widget_options[$widget_id]) )
if ( ! isset( $widget_options[ $widget_id ] ) ) {
$widget_options[ $widget_id ] = array();
}
$number = 1; // Hack to use wp_widget_rss_form()
$widget_options[ $widget_id ]['number'] = $number;
@ -1206,15 +1234,18 @@ function wp_print_community_events_templates() {
?>
<script id="tmpl-community-events-attend-event-near" type="text/template">
<?php printf(
<?php
printf(
/* translators: %s: the name of a city */
__( 'Attend an upcoming event near %s.' ),
'<strong>{{ data.location.description }}</strong>'
); ?>
);
?>
</script>
<script id="tmpl-community-events-could-not-locate" type="text/template">
<?php printf(
<?php
printf(
/* translators: %s is the name of the city we couldn't locate.
* Replace the examples with cities in your locale, but test
* that they match the expected location before including them.
@ -1222,7 +1253,8 @@ function wp_print_community_events_templates() {
*/
__( 'We couldn&#8217;t locate %s. Please try another nearby city. For example: Kansas City; Springfield; Portland.' ),
'<em>{{data.unknownCity}}</em>'
); ?>
);
?>
</script>
<script id="tmpl-community-events-event-list" type="text/template">
@ -1249,19 +1281,23 @@ function wp_print_community_events_templates() {
<script id="tmpl-community-events-no-upcoming-events" type="text/template">
<li class="event-none">
<# if ( data.location.description ) { #>
<?php printf(
<?php
printf(
/* translators: 1: the city the user searched for, 2: meetup organization documentation URL */
__( 'There aren&#8217;t any events scheduled near %1$s at the moment. Would you like to <a href="%2$s">organize one</a>?' ),
'{{ data.location.description }}',
__( 'https://make.wordpress.org/community/handbook/meetup-organizer/welcome/' )
); ?>
);
?>
<# } else { #>
<?php printf(
<?php
printf(
/* translators: %s: meetup organization documentation URL */
__( 'There aren&#8217;t any events scheduled near you at the moment. Would you like to <a href="%s">organize one</a>?' ),
__( 'https://make.wordpress.org/community/handbook/meetup-organizer/welcome/' )
); ?>
);
?>
<# } #>
</li>
</script>
@ -1349,7 +1385,7 @@ function wp_dashboard_primary() {
'show_summary' => 0,
'show_author' => 0,
'show_date' => 0,
)
),
);
wp_dashboard_cached_rss_widget( 'dashboard_primary', 'wp_dashboard_primary_output', $feeds );
@ -1369,7 +1405,7 @@ function wp_dashboard_primary_output( $widget_id, $feeds ) {
$args['type'] = $type;
echo '<div class="rss-widget">';
wp_widget_rss_output( $args['url'], $args );
echo "</div>";
echo '</div>';
}
}
@ -1383,16 +1419,18 @@ function wp_dashboard_primary_output( $widget_id, $feeds ) {
* @return bool|null True if not multisite, user can't upload files, or the space check option is disabled.
*/
function wp_dashboard_quota() {
if ( !is_multisite() || !current_user_can( 'upload_files' ) || get_site_option( 'upload_space_check_disabled' ) )
if ( ! is_multisite() || ! current_user_can( 'upload_files' ) || get_site_option( 'upload_space_check_disabled' ) ) {
return true;
}
$quota = get_space_allowed();
$used = get_space_used();
if ( $used > $quota )
if ( $used > $quota ) {
$percentused = '100';
else
} else {
$percentused = ( $used / $quota ) * 100;
}
$used_class = ( $percentused >= 70 ) ? ' warning' : '';
$used = round( $used, 2 );
$percentused = number_format( $percentused );
@ -1402,7 +1440,8 @@ function wp_dashboard_quota() {
<div class="mu-storage">
<ul>
<li class="storage-count">
<?php $text = sprintf(
<?php
$text = sprintf(
/* translators: %s: number of megabytes */
__( '%s MB Space Allowed' ),
number_format_i18n( $quota )
@ -1412,9 +1451,11 @@ function wp_dashboard_quota() {
esc_url( admin_url( 'upload.php' ) ),
$text,
__( 'Manage Uploads' )
); ?>
);
?>
</li><li class="storage-count <?php echo $used_class; ?>">
<?php $text = sprintf(
<?php
$text = sprintf(
/* translators: 1: number of megabytes, 2: percentage */
__( '%1$s MB (%2$s%%) Space Used' ),
number_format_i18n( $used, 2 ),
@ -1425,7 +1466,8 @@ function wp_dashboard_quota() {
esc_url( admin_url( 'upload.php' ) ),
$text,
__( 'Manage Uploads' )
); ?>
);
?>
</li>
</ul>
</div>
@ -1440,12 +1482,14 @@ function wp_dashboard_browser_nag() {
if ( $response ) {
if ( $response['insecure'] ) {
/* translators: %s: browser name and link */
$msg = sprintf( __( "It looks like you're using an insecure version of %s. Using an outdated browser makes your computer unsafe. For the best WordPress experience, please update your browser." ),
$msg = sprintf(
__( "It looks like you're using an insecure version of %s. Using an outdated browser makes your computer unsafe. For the best WordPress experience, please update your browser." ),
sprintf( '<a href="%s">%s</a>', esc_url( $response['update_url'] ), esc_html( $response['name'] ) )
);
} else {
/* translators: %s: browser name and link */
$msg = sprintf( __( "It looks like you're using an old version of %s. For the best WordPress experience, please update your browser." ),
$msg = sprintf(
__( "It looks like you're using an old version of %s. For the best WordPress experience, please update your browser." ),
sprintf( '<a href="%s">%s</a>', esc_url( $response['update_url'] ), esc_html( $response['name'] ) )
);
}
@ -1461,8 +1505,9 @@ function wp_dashboard_browser_nag() {
$browsehappy = 'https://browsehappy.com/';
$locale = get_user_locale();
if ( 'en_US' !== $locale )
if ( 'en_US' !== $locale ) {
$browsehappy = add_query_arg( 'locale', $locale, $browsehappy );
}
$notice .= '<p>' . sprintf( __( '<a href="%1$s" class="update-browser-link">Update %2$s</a> or learn how to <a href="%3$s" class="browse-happy-link">browse happy</a>' ), esc_attr( $response['update_url'] ), esc_html( $response['name'] ), esc_url( $browsehappy ) ) . '</p>';
$notice .= '<p class="hide-if-no-js"><a href="" class="dismiss" aria-label="' . esc_attr__( 'Dismiss the browser warning panel' ) . '">' . __( 'Dismiss' ) . '</a></p>';
@ -1489,8 +1534,9 @@ function wp_dashboard_browser_nag() {
function dashboard_browser_nag_class( $classes ) {
$response = wp_check_browser_version();
if ( $response && $response['insecure'] )
if ( $response && $response['insecure'] ) {
$classes[] = 'browser-insecure';
}
return $classes;
}
@ -1503,8 +1549,9 @@ function dashboard_browser_nag_class( $classes ) {
* @return array|bool False on failure, array of browser data on success.
*/
function wp_check_browser_version() {
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) )
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
return false;
}
$key = md5( $_SERVER['HTTP_USER_AGENT'] );
@ -1515,7 +1562,7 @@ function wp_check_browser_version() {
$url = 'http://api.wordpress.org/core/browse-happy/1.1/';
$options = array(
'body' => array( 'useragent' => $_SERVER['HTTP_USER_AGENT'] ),
'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' )
'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ),
);
if ( wp_http_supports( array( 'ssl' ) ) ) {
@ -1524,8 +1571,9 @@ function wp_check_browser_version() {
$response = wp_remote_post( $url, $options );
if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) )
if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
return false;
}
/**
* Response should be an array with:
@ -1541,8 +1589,9 @@ function wp_check_browser_version() {
*/
$response = json_decode( wp_remote_retrieve_body( $response ), true );
if ( ! is_array( $response ) )
if ( ! is_array( $response ) ) {
return false;
}
set_site_transient( 'browser_' . $key, $response, WEEK_IN_SECONDS );
}
@ -1598,16 +1647,20 @@ function wp_welcome_panel() {
<h3><?php _e( 'More Actions' ); ?></h3>
<ul>
<?php if ( current_theme_supports( 'widgets' ) || current_theme_supports( 'menus' ) ) : ?>
<li><div class="welcome-icon welcome-widgets-menus"><?php
<li><div class="welcome-icon welcome-widgets-menus">
<?php
if ( current_theme_supports( 'widgets' ) && current_theme_supports( 'menus' ) ) {
printf( __( 'Manage <a href="%1$s">widgets</a> or <a href="%2$s">menus</a>' ),
admin_url( 'widgets.php' ), admin_url( 'nav-menus.php' ) );
printf(
__( 'Manage <a href="%1$s">widgets</a> or <a href="%2$s">menus</a>' ),
admin_url( 'widgets.php' ), admin_url( 'nav-menus.php' )
);
} elseif ( current_theme_supports( 'widgets' ) ) {
echo '<a href="' . admin_url( 'widgets.php' ) . '">' . __( 'Manage widgets' ) . '</a>';
} else {
echo '<a href="' . admin_url( 'nav-menus.php' ) . '">' . __( 'Manage menus' ) . '</a>';
}
?></div></li>
?>
</div></li>
<?php endif; ?>
<?php if ( current_user_can( 'manage_options' ) ) : ?>
<li><?php printf( '<a href="%s" class="welcome-icon welcome-comments">' . __( 'Turn comments on or off' ) . '</a>', admin_url( 'options-discussion.php' ) ); ?></li>

View File

@ -56,8 +56,13 @@ define( 'WXR_VERSION', '1.2' );
function export_wp( $args = array() ) {
global $wpdb, $post;
$defaults = array( 'content' => 'all', 'author' => false, 'category' => false,
'start_date' => false, 'end_date' => false, 'status' => false,
$defaults = array(
'content' => 'all',
'author' => false,
'category' => false,
'start_date' => false,
'end_date' => false,
'status' => false,
);
$args = wp_parse_args( $args, $defaults );
@ -75,7 +80,7 @@ function export_wp( $args = array() ) {
$sitename .= '.';
}
$date = date( 'Y-m-d' );
$wp_filename = $sitename . 'wordpress.' . $date . '.xml';
$wp_filename = $sitename . 'WordPress.' . $date . '.xml';
/**
* Filters the export filename.
*
@ -93,8 +98,9 @@ function export_wp( $args = array() ) {
if ( 'all' != $args['content'] && post_type_exists( $args['content'] ) ) {
$ptype = get_post_type_object( $args['content'] );
if ( ! $ptype->can_export )
if ( ! $ptype->can_export ) {
$args['content'] = 'post';
}
$where = $wpdb->prepare( "{$wpdb->posts}.post_type = %s", $args['content'] );
} else {
@ -103,10 +109,11 @@ function export_wp( $args = array() ) {
$where = $wpdb->prepare( "{$wpdb->posts}.post_type IN (" . implode( ',', $esses ) . ')', $post_types );
}
if ( $args['status'] && ( 'post' == $args['content'] || 'page' == $args['content'] ) )
if ( $args['status'] && ( 'post' == $args['content'] || 'page' == $args['content'] ) ) {
$where .= $wpdb->prepare( " AND {$wpdb->posts}.post_status = %s", $args['status'] );
else
} else {
$where .= " AND {$wpdb->posts}.post_status != 'auto-draft'";
}
$join = '';
if ( $args['category'] && 'post' == $args['content'] ) {
@ -117,15 +124,18 @@ function export_wp( $args = array() ) {
}
if ( 'post' == $args['content'] || 'page' == $args['content'] || 'attachment' == $args['content'] ) {
if ( $args['author'] )
if ( $args['author'] ) {
$where .= $wpdb->prepare( " AND {$wpdb->posts}.post_author = %d", $args['author'] );
}
if ( $args['start_date'] )
if ( $args['start_date'] ) {
$where .= $wpdb->prepare( " AND {$wpdb->posts}.post_date >= %s", date( 'Y-m-d', strtotime( $args['start_date'] ) ) );
}
if ( $args['end_date'] )
if ( $args['end_date'] ) {
$where .= $wpdb->prepare( " AND {$wpdb->posts}.post_date < %s", date( 'Y-m-d', strtotime( '+1 month', strtotime( $args['end_date'] ) ) ) );
}
}
// Grab a snapshot of post IDs, just in case it changes during the export.
$post_ids = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} $join WHERE $where" );
@ -148,19 +158,21 @@ function export_wp( $args = array() ) {
// Put categories in order with no child going before its parent.
while ( $cat = array_shift( $categories ) ) {
if ( $cat->parent == 0 || isset( $cats[$cat->parent] ) )
if ( $cat->parent == 0 || isset( $cats[ $cat->parent ] ) ) {
$cats[ $cat->term_id ] = $cat;
else
} else {
$categories[] = $cat;
}
}
// Put terms in order with no child going before its parent.
while ( $t = array_shift( $custom_terms ) ) {
if ( $t->parent == 0 || isset( $terms[$t->parent] ) )
if ( $t->parent == 0 || isset( $terms[ $t->parent ] ) ) {
$terms[ $t->term_id ] = $t;
else
} else {
$custom_terms[] = $t;
}
}
unset( $categories, $custom_taxonomies, $custom_terms );
}
@ -192,12 +204,13 @@ function export_wp( $args = array() ) {
*/
function wxr_site_url() {
// Multisite: the base URL.
if ( is_multisite() )
if ( is_multisite() ) {
return network_home_url();
// WordPress (single site): the blog URL.
else
} // WordPress (single site): the blog URL.
else {
return get_bloginfo_rss( 'url' );
}
}
/**
* Output a cat_name XML tag from a given category object
@ -207,8 +220,9 @@ function export_wp( $args = array() ) {
* @param object $category Category Object
*/
function wxr_cat_name( $category ) {
if ( empty( $category->name ) )
if ( empty( $category->name ) ) {
return;
}
echo '<wp:cat_name>' . wxr_cdata( $category->name ) . "</wp:cat_name>\n";
}
@ -221,8 +235,9 @@ function export_wp( $args = array() ) {
* @param object $category Category Object
*/
function wxr_category_description( $category ) {
if ( empty( $category->description ) )
if ( empty( $category->description ) ) {
return;
}
echo '<wp:category_description>' . wxr_cdata( $category->description ) . "</wp:category_description>\n";
}
@ -235,8 +250,9 @@ function export_wp( $args = array() ) {
* @param object $tag Tag Object
*/
function wxr_tag_name( $tag ) {
if ( empty( $tag->name ) )
if ( empty( $tag->name ) ) {
return;
}
echo '<wp:tag_name>' . wxr_cdata( $tag->name ) . "</wp:tag_name>\n";
}
@ -249,8 +265,9 @@ function export_wp( $args = array() ) {
* @param object $tag Tag Object
*/
function wxr_tag_description( $tag ) {
if ( empty( $tag->description ) )
if ( empty( $tag->description ) ) {
return;
}
echo '<wp:tag_description>' . wxr_cdata( $tag->description ) . "</wp:tag_description>\n";
}
@ -263,8 +280,9 @@ function export_wp( $args = array() ) {
* @param object $term Term Object
*/
function wxr_term_name( $term ) {
if ( empty( $term->name ) )
if ( empty( $term->name ) ) {
return;
}
echo '<wp:term_name>' . wxr_cdata( $term->name ) . "</wp:term_name>\n";
}
@ -277,8 +295,9 @@ function export_wp( $args = array() ) {
* @param object $term Term Object
*/
function wxr_term_description( $term ) {
if ( empty( $term->description ) )
if ( empty( $term->description ) ) {
return;
}
echo "\t\t<wp:term_description>" . wxr_cdata( $term->description ) . "</wp:term_description>\n";
}
@ -335,8 +354,9 @@ function export_wp( $args = array() ) {
$authors = array();
$results = $wpdb->get_results( "SELECT DISTINCT post_author FROM $wpdb->posts WHERE post_status != 'auto-draft' $and" );
foreach ( (array) $results as $result )
foreach ( (array) $results as $result ) {
$authors[] = get_userdata( $result->post_author );
}
$authors = array_filter( $authors );
@ -359,8 +379,9 @@ function export_wp( $args = array() ) {
*/
function wxr_nav_menu_terms() {
$nav_menus = wp_get_nav_menus();
if ( empty( $nav_menus ) || ! is_array( $nav_menus ) )
if ( empty( $nav_menus ) || ! is_array( $nav_menus ) ) {
return;
}
foreach ( $nav_menus as $menu ) {
echo "\t<wp:term>";
@ -381,8 +402,9 @@ function export_wp( $args = array() ) {
$post = get_post();
$taxonomies = get_object_taxonomies( $post->post_type );
if ( empty( $taxonomies ) )
if ( empty( $taxonomies ) ) {
return;
}
$terms = wp_get_object_terms( $post->ID, $taxonomies );
foreach ( (array) $terms as $term ) {
@ -391,14 +413,14 @@ function export_wp( $args = array() ) {
}
/**
*
* @param bool $return_me
* @param string $meta_key
* @return bool
*/
function wxr_filter_postmeta( $return_me, $meta_key ) {
if ( '_edit_lock' == $meta_key )
if ( '_edit_lock' == $meta_key ) {
$return_me = true;
}
return $return_me;
}
add_filter( 'wxr_export_skip_postmeta', 'wxr_filter_postmeta', 10, 2 );
@ -449,18 +471,22 @@ function export_wp( $args = array() ) {
<wp:term_id><?php echo intval( $c->term_id ); ?></wp:term_id>
<wp:category_nicename><?php echo wxr_cdata( $c->slug ); ?></wp:category_nicename>
<wp:category_parent><?php echo wxr_cdata( $c->parent ? $cats[ $c->parent ]->slug : '' ); ?></wp:category_parent>
<?php wxr_cat_name( $c );
<?php
wxr_cat_name( $c );
wxr_category_description( $c );
wxr_term_meta( $c ); ?>
wxr_term_meta( $c );
?>
</wp:category>
<?php endforeach; ?>
<?php foreach ( $tags as $t ) : ?>
<wp:tag>
<wp:term_id><?php echo intval( $t->term_id ); ?></wp:term_id>
<wp:tag_slug><?php echo wxr_cdata( $t->slug ); ?></wp:tag_slug>
<?php wxr_tag_name( $t );
<?php
wxr_tag_name( $t );
wxr_tag_description( $t );
wxr_term_meta( $t ); ?>
wxr_term_meta( $t );
?>
</wp:tag>
<?php endforeach; ?>
<?php foreach ( $terms as $t ) : ?>
@ -469,19 +495,25 @@ function export_wp( $args = array() ) {
<wp:term_taxonomy><?php echo wxr_cdata( $t->taxonomy ); ?></wp:term_taxonomy>
<wp:term_slug><?php echo wxr_cdata( $t->slug ); ?></wp:term_slug>
<wp:term_parent><?php echo wxr_cdata( $t->parent ? $terms[ $t->parent ]->slug : '' ); ?></wp:term_parent>
<?php wxr_term_name( $t );
<?php
wxr_term_name( $t );
wxr_term_description( $t );
wxr_term_meta( $t ); ?>
wxr_term_meta( $t );
?>
</wp:term>
<?php endforeach; ?>
<?php if ( 'all' == $args['content'] ) wxr_nav_menu_terms(); ?>
<?php
if ( 'all' == $args['content'] ) {
wxr_nav_menu_terms();}
?>
<?php
/** This action is documented in wp-includes/feed-rss2.php */
do_action( 'rss2_head' );
?>
<?php if ( $post_ids ) {
<?php
if ( $post_ids ) {
/**
* @global WP_Query $wp_query
*/
@ -501,16 +533,19 @@ function export_wp( $args = array() ) {
$is_sticky = is_sticky( $post->ID ) ? 1 : 0;
?>
<item>
<title><?php
<title>
<?php
/** This filter is documented in wp-includes/feed.php */
echo apply_filters( 'the_title_rss', $post->post_title );
?></title>
<link><?php the_permalink_rss() ?></link>
?>
</title>
<link><?php the_permalink_rss(); ?></link>
<pubDate><?php echo mysql2date( 'D, d M Y H:i:s +0000', get_post_time( 'Y-m-d H:i:s', true ), false ); ?></pubDate>
<dc:creator><?php echo wxr_cdata( get_the_author_meta( 'login' ) ); ?></dc:creator>
<guid isPermaLink="false"><?php the_guid(); ?></guid>
<description></description>
<content:encoded><?php
<content:encoded>
<?php
/**
* Filters the post content used for WXR exports.
*
@ -519,8 +554,10 @@ function export_wp( $args = array() ) {
* @param string $post_content Content of the current post.
*/
echo wxr_cdata( apply_filters( 'the_content_export', $post->post_content ) );
?></content:encoded>
<excerpt:encoded><?php
?>
</content:encoded>
<excerpt:encoded>
<?php
/**
* Filters the post excerpt used for WXR exports.
*
@ -529,7 +566,8 @@ function export_wp( $args = array() ) {
* @param string $post_excerpt Excerpt for the current post.
*/
echo wxr_cdata( apply_filters( 'the_excerpt_export', $post->post_excerpt ) );
?></excerpt:encoded>
?>
</excerpt:encoded>
<wp:post_id><?php echo intval( $post->ID ); ?></wp:post_id>
<wp:post_date><?php echo wxr_cdata( $post->post_date ); ?></wp:post_date>
<wp:post_date_gmt><?php echo wxr_cdata( $post->post_date_gmt ); ?></wp:post_date_gmt>
@ -546,7 +584,8 @@ function export_wp( $args = array() ) {
<wp:attachment_url><?php echo wxr_cdata( wp_get_attachment_url( $post->ID ) ); ?></wp:attachment_url>
<?php endif; ?>
<?php wxr_post_taxonomy(); ?>
<?php $postmeta = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->postmeta WHERE post_id = %d", $post->ID ) );
<?php
$postmeta = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->postmeta WHERE post_id = %d", $post->ID ) );
foreach ( $postmeta as $meta ) :
/**
* Filters whether to selectively skip post meta used for WXR exports.
@ -560,18 +599,21 @@ function export_wp( $args = array() ) {
* @param string $meta_key Current meta key.
* @param object $meta Current meta object.
*/
if ( apply_filters( 'wxr_export_skip_postmeta', false, $meta->meta_key, $meta ) )
if ( apply_filters( 'wxr_export_skip_postmeta', false, $meta->meta_key, $meta ) ) {
continue;
}
?>
<wp:postmeta>
<wp:meta_key><?php echo wxr_cdata( $meta->meta_key ); ?></wp:meta_key>
<wp:meta_value><?php echo wxr_cdata( $meta->meta_value ); ?></wp:meta_value>
</wp:postmeta>
<?php endforeach;
<?php
endforeach;
$_comments = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved <> 'spam'", $post->ID ) );
$comments = array_map( 'get_comment', $_comments );
foreach ( $comments as $c ) : ?>
foreach ( $comments as $c ) :
?>
<wp:comment>
<wp:comment_id><?php echo intval( $c->comment_ID ); ?></wp:comment_id>
<wp:comment_author><?php echo wxr_cdata( $c->comment_author ); ?></wp:comment_author>
@ -580,12 +622,13 @@ function export_wp( $args = array() ) {
<wp:comment_author_IP><?php echo wxr_cdata( $c->comment_author_IP ); ?></wp:comment_author_IP>
<wp:comment_date><?php echo wxr_cdata( $c->comment_date ); ?></wp:comment_date>
<wp:comment_date_gmt><?php echo wxr_cdata( $c->comment_date_gmt ); ?></wp:comment_date_gmt>
<wp:comment_content><?php echo wxr_cdata( $c->comment_content ) ?></wp:comment_content>
<wp:comment_content><?php echo wxr_cdata( $c->comment_content ); ?></wp:comment_content>
<wp:comment_approved><?php echo wxr_cdata( $c->comment_approved ); ?></wp:comment_approved>
<wp:comment_type><?php echo wxr_cdata( $c->comment_type ); ?></wp:comment_type>
<wp:comment_parent><?php echo intval( $c->comment_parent ); ?></wp:comment_parent>
<wp:comment_user_id><?php echo intval( $c->user_id ); ?></wp:comment_user_id>
<?php $c_meta = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->commentmeta WHERE comment_id = %d", $c->comment_ID ) );
<?php
$c_meta = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->commentmeta WHERE comment_id = %d", $c->comment_ID ) );
foreach ( $c_meta as $meta ) :
/**
* Filters whether to selectively skip comment meta used for WXR exports.
@ -614,7 +657,8 @@ function export_wp( $args = array() ) {
<?php
}
}
} ?>
}
?>
</channel>
</rss>
<?php

View File

@ -669,8 +669,9 @@ function wp_tempnam( $filename = '', $dir = '' ) {
function validate_file_to_edit( $file, $allowed_files = array() ) {
$code = validate_file( $file, $allowed_files );
if (!$code )
if ( ! $code ) {
return $file;
}
switch ( $code ) {
case 1:
@ -756,7 +757,7 @@ function _wp_handle_upload( &$file, $overrides, $time, $action ) {
'',
__( 'Missing a temporary folder.' ),
__( 'Failed to write file to disk.' ),
__( 'File upload stopped by extension.' )
__( 'File upload stopped by extension.' ),
);
}
@ -888,11 +889,13 @@ function _wp_handle_upload( &$file, $overrides, $time, $action ) {
* }
* @param string $context The type of upload action. Values include 'upload' or 'sideload'.
*/
return apply_filters( 'wp_handle_upload', array(
return apply_filters(
'wp_handle_upload', array(
'file' => $new_file,
'url' => $url,
'type' => $type
), 'wp_handle_sideload' === $action ? 'sideload' : 'upload' );
'type' => $type,
), 'wp_handle_sideload' === $action ? 'sideload' : 'upload'
);
}
/**
@ -966,16 +969,24 @@ function wp_handle_sideload( &$file, $overrides = false, $time = null ) {
*/
function download_url( $url, $timeout = 300 ) {
//WARNING: The file is not automatically deleted, The script must unlink() the file.
if ( ! $url )
if ( ! $url ) {
return new WP_Error( 'http_no_url', __( 'Invalid URL Provided.' ) );
}
$url_filename = basename( parse_url( $url, PHP_URL_PATH ) );
$tmpfname = wp_tempnam( $url_filename );
if ( ! $tmpfname )
if ( ! $tmpfname ) {
return new WP_Error( 'http_no_file', __( 'Could not create Temporary file.' ) );
}
$response = wp_safe_remote_get( $url, array( 'timeout' => $timeout, 'stream' => true, 'filename' => $tmpfname ) );
$response = wp_safe_remote_get(
$url, array(
'timeout' => $timeout,
'stream' => true,
'filename' => $tmpfname,
)
);
if ( is_wp_error( $response ) ) {
unlink( $tmpfname );
@ -1009,17 +1020,19 @@ function download_url( $url, $timeout = 300 ) {
* @return bool|object WP_Error on failure, true on success, false when the MD5 format is unknown/unexpected
*/
function verify_file_md5( $filename, $expected_md5 ) {
if ( 32 == strlen( $expected_md5 ) )
if ( 32 == strlen( $expected_md5 ) ) {
$expected_raw_md5 = pack( 'H*', $expected_md5 );
elseif ( 24 == strlen( $expected_md5 ) )
} elseif ( 24 == strlen( $expected_md5 ) ) {
$expected_raw_md5 = base64_decode( $expected_md5 );
else
} else {
return false; // unknown format
}
$file_md5 = md5_file( $filename, true );
if ( $file_md5 === $expected_raw_md5 )
if ( $file_md5 === $expected_raw_md5 ) {
return true;
}
return new WP_Error( 'md5_mismatch', sprintf( __( 'The checksum of the file (%1$s) does not match the expected checksum value (%2$s).' ), bin2hex( $file_md5 ), bin2hex( $expected_raw_md5 ) ) );
}
@ -1042,8 +1055,9 @@ function verify_file_md5( $filename, $expected_md5 ) {
function unzip_file( $file, $to ) {
global $wp_filesystem;
if ( ! $wp_filesystem || !is_object($wp_filesystem) )
if ( ! $wp_filesystem || ! is_object( $wp_filesystem ) ) {
return new WP_Error( 'fs_unavailable', __( 'Could not access filesystem.' ) );
}
// Unzip can use a lot of memory, but not this much hopefully.
wp_raise_memory_limit( 'admin' );
@ -1055,19 +1069,22 @@ function unzip_file($file, $to) {
if ( ! $wp_filesystem->is_dir( $to ) ) { //Only do parents if no children exist
$path = preg_split( '![/\\\]!', untrailingslashit( $to ) );
for ( $i = count( $path ); $i >= 0; $i-- ) {
if ( empty($path[$i]) )
if ( empty( $path[ $i ] ) ) {
continue;
}
$dir = implode( '/', array_slice( $path, 0, $i + 1 ) );
if ( preg_match('!^[a-z]:$!i', $dir) ) // Skip it if it looks like a Windows Drive letter.
if ( preg_match( '!^[a-z]:$!i', $dir ) ) { // Skip it if it looks like a Windows Drive letter.
continue;
}
if ( ! $wp_filesystem->is_dir($dir) )
if ( ! $wp_filesystem->is_dir( $dir ) ) {
$needed_dirs[] = $dir;
else
} else {
break; // A folder exists, therefor, we dont need the check the levels below this
}
}
}
/**
* Filters whether to use ZipArchive to unzip archives.
@ -1081,10 +1098,11 @@ function unzip_file($file, $to) {
if ( true === $result ) {
return $result;
} elseif ( is_wp_error( $result ) ) {
if ( 'incompatible_archive' != $result->get_error_code() )
if ( 'incompatible_archive' != $result->get_error_code() ) {
return $result;
}
}
}
// Fall through to PclZip if ZipArchive is not available, or encountered an error opening the file.
return _unzip_file_pclzip( $file, $to, $needed_dirs );
}
@ -1110,17 +1128,20 @@ function _unzip_file_ziparchive($file, $to, $needed_dirs = array() ) {
$z = new ZipArchive();
$zopen = $z->open( $file, ZIPARCHIVE::CHECKCONS );
if ( true !== $zopen )
if ( true !== $zopen ) {
return new WP_Error( 'incompatible_archive', __( 'Incompatible Archive.' ), array( 'ziparchive_error' => $zopen ) );
}
$uncompressed_size = 0;
for ( $i = 0; $i < $z->numFiles; $i++ ) {
if ( ! $info = $z->statIndex($i) )
if ( ! $info = $z->statIndex( $i ) ) {
return new WP_Error( 'stat_failed_ziparchive', __( 'Could not retrieve file from archive.' ) );
}
if ( '__MACOSX/' === substr($info['name'], 0, 9) ) // Skip the OS X-created __MACOSX directory
if ( '__MACOSX/' === substr( $info['name'], 0, 9 ) ) { // Skip the OS X-created __MACOSX directory
continue;
}
// Don't extract invalid files:
if ( 0 !== validate_file( $info['name'] ) ) {
@ -1145,17 +1166,20 @@ function _unzip_file_ziparchive($file, $to, $needed_dirs = array() ) {
*/
if ( wp_doing_cron() ) {
$available_space = @disk_free_space( WP_CONTENT_DIR );
if ( $available_space && ( $uncompressed_size * 2.1 ) > $available_space )
if ( $available_space && ( $uncompressed_size * 2.1 ) > $available_space ) {
return new WP_Error( 'disk_full_unzip_file', __( 'Could not copy files. You may have run out of disk space.' ), compact( 'uncompressed_size', 'available_space' ) );
}
}
$needed_dirs = array_unique( $needed_dirs );
foreach ( $needed_dirs as $dir ) {
// Check the parent folders of the folders all exist within the creation array.
if ( untrailingslashit($to) == $dir ) // Skip over the working directory, We know this exists (or will exist)
if ( untrailingslashit( $to ) == $dir ) { // Skip over the working directory, We know this exists (or will exist)
continue;
if ( strpos($dir, $to) === false ) // If the directory is not within the working directory, Skip it
}
if ( strpos( $dir, $to ) === false ) { // If the directory is not within the working directory, Skip it
continue;
}
$parent_folder = dirname( $dir );
while ( ! empty( $parent_folder ) && untrailingslashit( $to ) != $parent_folder && ! in_array( $parent_folder, $needed_dirs ) ) {
@ -1175,14 +1199,17 @@ function _unzip_file_ziparchive($file, $to, $needed_dirs = array() ) {
unset( $needed_dirs );
for ( $i = 0; $i < $z->numFiles; $i++ ) {
if ( ! $info = $z->statIndex($i) )
if ( ! $info = $z->statIndex( $i ) ) {
return new WP_Error( 'stat_failed_ziparchive', __( 'Could not retrieve file from archive.' ) );
}
if ( '/' == substr($info['name'], -1) ) // directory
if ( '/' == substr( $info['name'], -1 ) ) { // directory
continue;
}
if ( '__MACOSX/' === substr($info['name'], 0, 9) ) // Don't extract the OS X-created __MACOSX directory files
if ( '__MACOSX/' === substr( $info['name'], 0, 9 ) ) { // Don't extract the OS X-created __MACOSX directory files
continue;
}
// Don't extract invalid files:
if ( 0 !== validate_file( $info['name'] ) ) {
@ -1190,12 +1217,14 @@ function _unzip_file_ziparchive($file, $to, $needed_dirs = array() ) {
}
$contents = $z->getFromIndex( $i );
if ( false === $contents )
if ( false === $contents ) {
return new WP_Error( 'extract_failed_ziparchive', __( 'Could not extract file from archive.' ), $info['name'] );
}
if ( ! $wp_filesystem->put_contents( $to . $info['name'], $contents, FS_CHMOD_FILE) )
if ( ! $wp_filesystem->put_contents( $to . $info['name'], $contents, FS_CHMOD_FILE ) ) {
return new WP_Error( 'copy_failed_ziparchive', __( 'Could not copy file.' ), $info['name'] );
}
}
$z->close();
@ -1231,18 +1260,21 @@ function _unzip_file_pclzip($file, $to, $needed_dirs = array()) {
reset_mbstring_encoding();
// Is the archive valid?
if ( !is_array($archive_files) )
if ( ! is_array( $archive_files ) ) {
return new WP_Error( 'incompatible_archive', __( 'Incompatible Archive.' ), $archive->errorInfo( true ) );
}
if ( 0 == count($archive_files) )
if ( 0 == count( $archive_files ) ) {
return new WP_Error( 'empty_archive_pclzip', __( 'Empty archive.' ) );
}
$uncompressed_size = 0;
// Determine any children directories needed (From within the archive)
foreach ( $archive_files as $file ) {
if ( '__MACOSX/' === substr($file['filename'], 0, 9) ) // Skip the OS X-created __MACOSX directory
if ( '__MACOSX/' === substr( $file['filename'], 0, 9 ) ) { // Skip the OS X-created __MACOSX directory
continue;
}
$uncompressed_size += $file['size'];
@ -1256,17 +1288,20 @@ function _unzip_file_pclzip($file, $to, $needed_dirs = array()) {
*/
if ( wp_doing_cron() ) {
$available_space = @disk_free_space( WP_CONTENT_DIR );
if ( $available_space && ( $uncompressed_size * 2.1 ) > $available_space )
if ( $available_space && ( $uncompressed_size * 2.1 ) > $available_space ) {
return new WP_Error( 'disk_full_unzip_file', __( 'Could not copy files. You may have run out of disk space.' ), compact( 'uncompressed_size', 'available_space' ) );
}
}
$needed_dirs = array_unique( $needed_dirs );
foreach ( $needed_dirs as $dir ) {
// Check the parent folders of the folders all exist within the creation array.
if ( untrailingslashit($to) == $dir ) // Skip over the working directory, We know this exists (or will exist)
if ( untrailingslashit( $to ) == $dir ) { // Skip over the working directory, We know this exists (or will exist)
continue;
if ( strpos($dir, $to) === false ) // If the directory is not within the working directory, Skip it
}
if ( strpos( $dir, $to ) === false ) { // If the directory is not within the working directory, Skip it
continue;
}
$parent_folder = dirname( $dir );
while ( ! empty( $parent_folder ) && untrailingslashit( $to ) != $parent_folder && ! in_array( $parent_folder, $needed_dirs ) ) {
@ -1279,27 +1314,31 @@ function _unzip_file_pclzip($file, $to, $needed_dirs = array()) {
// Create those directories if need be:
foreach ( $needed_dirs as $_dir ) {
// Only check to see if the dir exists upon creation failure. Less I/O this way.
if ( ! $wp_filesystem->mkdir( $_dir, FS_CHMOD_DIR ) && ! $wp_filesystem->is_dir( $_dir ) )
if ( ! $wp_filesystem->mkdir( $_dir, FS_CHMOD_DIR ) && ! $wp_filesystem->is_dir( $_dir ) ) {
return new WP_Error( 'mkdir_failed_pclzip', __( 'Could not create directory.' ), substr( $_dir, strlen( $to ) ) );
}
}
unset( $needed_dirs );
// Extract the files from the zip
foreach ( $archive_files as $file ) {
if ( $file['folder'] )
if ( $file['folder'] ) {
continue;
}
if ( '__MACOSX/' === substr($file['filename'], 0, 9) ) // Don't extract the OS X-created __MACOSX directory files
if ( '__MACOSX/' === substr( $file['filename'], 0, 9 ) ) { // Don't extract the OS X-created __MACOSX directory files
continue;
}
// Don't extract invalid files:
if ( 0 !== validate_file( $file['filename'] ) ) {
continue;
}
if ( ! $wp_filesystem->put_contents( $to . $file['filename'], $file['content'], FS_CHMOD_FILE) )
if ( ! $wp_filesystem->put_contents( $to . $file['filename'], $file['content'], FS_CHMOD_FILE ) ) {
return new WP_Error( 'copy_failed_pclzip', __( 'Could not copy file.' ), $file['filename'] );
}
}
return true;
}
@ -1325,34 +1364,39 @@ function copy_dir($from, $to, $skip_list = array() ) {
$to = trailingslashit( $to );
foreach ( (array) $dirlist as $filename => $fileinfo ) {
if ( in_array( $filename, $skip_list ) )
if ( in_array( $filename, $skip_list ) ) {
continue;
}
if ( 'f' == $fileinfo['type'] ) {
if ( ! $wp_filesystem->copy( $from . $filename, $to . $filename, true, FS_CHMOD_FILE ) ) {
// If copy failed, chmod file to 0644 and try again.
$wp_filesystem->chmod( $to . $filename, FS_CHMOD_FILE );
if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) )
if ( ! $wp_filesystem->copy( $from . $filename, $to . $filename, true, FS_CHMOD_FILE ) ) {
return new WP_Error( 'copy_failed_copy_dir', __( 'Could not copy file.' ), $to . $filename );
}
}
} elseif ( 'd' == $fileinfo['type'] ) {
if ( ! $wp_filesystem->is_dir( $to . $filename ) ) {
if ( !$wp_filesystem->mkdir($to . $filename, FS_CHMOD_DIR) )
if ( ! $wp_filesystem->mkdir( $to . $filename, FS_CHMOD_DIR ) ) {
return new WP_Error( 'mkdir_failed_copy_dir', __( 'Could not create directory.' ), $to . $filename );
}
}
// generate the $sub_skip_list for the subdirectory as a sub-set of the existing $skip_list
$sub_skip_list = array();
foreach ( $skip_list as $skip_item ) {
if ( 0 === strpos( $skip_item, $filename . '/' ) )
if ( 0 === strpos( $skip_item, $filename . '/' ) ) {
$sub_skip_list[] = preg_replace( '!^' . preg_quote( $filename, '!' ) . '/!i', '', $skip_item );
}
}
$result = copy_dir( $from . $filename, $to . $filename, $sub_skip_list );
if ( is_wp_error($result) )
if ( is_wp_error( $result ) ) {
return $result;
}
}
}
return true;
}
@ -1380,8 +1424,9 @@ function WP_Filesystem( $args = false, $context = false, $allow_relaxed_file_own
$method = get_filesystem_method( $args, $context, $allow_relaxed_file_ownership );
if ( ! $method )
if ( ! $method ) {
return false;
}
if ( ! class_exists( "WP_Filesystem_$method" ) ) {
@ -1397,8 +1442,9 @@ function WP_Filesystem( $args = false, $context = false, $allow_relaxed_file_own
*/
$abstraction_file = apply_filters( 'filesystem_method_file', ABSPATH . 'wp-admin/includes/class-wp-filesystem-' . $method . '.php', $method );
if ( ! file_exists($abstraction_file) )
if ( ! file_exists( $abstraction_file ) ) {
return;
}
require_once( $abstraction_file );
}
@ -1407,22 +1453,28 @@ function WP_Filesystem( $args = false, $context = false, $allow_relaxed_file_own
$wp_filesystem = new $method( $args );
//Define the timeouts for the connections. Only available after the construct is called to allow for per-transport overriding of the default.
if ( ! defined('FS_CONNECT_TIMEOUT') )
if ( ! defined( 'FS_CONNECT_TIMEOUT' ) ) {
define( 'FS_CONNECT_TIMEOUT', 30 );
if ( ! defined('FS_TIMEOUT') )
}
if ( ! defined( 'FS_TIMEOUT' ) ) {
define( 'FS_TIMEOUT', 30 );
}
if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() )
if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
return false;
}
if ( !$wp_filesystem->connect() )
if ( ! $wp_filesystem->connect() ) {
return false; //There was an error connecting to the server.
}
// Set the permission constants if not already set.
if ( ! defined('FS_CHMOD_DIR') )
if ( ! defined( 'FS_CHMOD_DIR' ) ) {
define( 'FS_CHMOD_DIR', ( fileperms( ABSPATH ) & 0777 | 0755 ) );
if ( ! defined('FS_CHMOD_FILE') )
}
if ( ! defined( 'FS_CHMOD_FILE' ) ) {
define( 'FS_CHMOD_FILE', ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ) );
}
return true;
}
@ -1497,9 +1549,15 @@ function get_filesystem_method( $args = array(), $context = '', $allow_relaxed_f
}
}
if ( ! $method && isset($args['connection_type']) && 'ssh' == $args['connection_type'] && extension_loaded('ssh2') && function_exists('stream_get_contents') ) $method = 'ssh2';
if ( ! $method && extension_loaded('ftp') ) $method = 'ftpext';
if ( ! $method && ( extension_loaded('sockets') || function_exists('fsockopen') ) ) $method = 'ftpsockets'; //Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread
if ( ! $method && isset( $args['connection_type'] ) && 'ssh' == $args['connection_type'] && extension_loaded( 'ssh2' ) && function_exists( 'stream_get_contents' ) ) {
$method = 'ssh2';
}
if ( ! $method && extension_loaded( 'ftp' ) ) {
$method = 'ftpext';
}
if ( ! $method && ( extension_loaded( 'sockets' ) || function_exists( 'fsockopen' ) ) ) {
$method = 'ftpsockets'; //Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread
}
/**
* Filters the filesystem method to use.
@ -1566,20 +1624,28 @@ function request_filesystem_credentials( $form_post, $type = '', $error = false,
* @param array $extra_fields Extra POST fields.
*/
$req_cred = apply_filters( 'request_filesystem_credentials', '', $form_post, $type, $error, $context, $extra_fields, $allow_relaxed_file_ownership );
if ( '' !== $req_cred )
if ( '' !== $req_cred ) {
return $req_cred;
}
if ( empty( $type ) ) {
$type = get_filesystem_method( array(), $context, $allow_relaxed_file_ownership );
}
if ( 'direct' == $type )
if ( 'direct' == $type ) {
return true;
}
if ( is_null( $extra_fields ) )
if ( is_null( $extra_fields ) ) {
$extra_fields = array( 'version', 'locale' );
}
$credentials = get_option('ftp_credentials', array( 'hostname' => '', 'username' => ''));
$credentials = get_option(
'ftp_credentials', array(
'hostname' => '',
'username' => '',
)
);
$submitted_form = wp_unslash( $_POST );
@ -1609,8 +1675,9 @@ function request_filesystem_credentials( $form_post, $type = '', $error = false,
if ( strpos( $credentials['hostname'], ':' ) ) {
list( $credentials['hostname'], $credentials['port'] ) = explode( ':', $credentials['hostname'], 2 );
if ( ! is_numeric($credentials['port']) )
if ( ! is_numeric( $credentials['port'] ) ) {
unset( $credentials['port'] );
}
} else {
unset( $credentials['port'] );
}
@ -1630,8 +1697,9 @@ function request_filesystem_credentials( $form_post, $type = '', $error = false,
( 'ssh' == $credentials['connection_type'] && ! empty( $credentials['public_key'] ) && ! empty( $credentials['private_key'] ) )
) ) {
$stored_credentials = $credentials;
if ( !empty($stored_credentials['port']) ) //save port as part of hostname to simplify above code.
if ( ! empty( $stored_credentials['port'] ) ) { //save port as part of hostname to simplify above code.
$stored_credentials['hostname'] .= ':' . $stored_credentials['port'];
}
unset( $stored_credentials['password'], $stored_credentials['port'], $stored_credentials['private_key'], $stored_credentials['public_key'] );
if ( ! wp_installing() ) {
@ -1648,18 +1716,22 @@ function request_filesystem_credentials( $form_post, $type = '', $error = false,
if ( $error ) {
$error_string = __( '<strong>ERROR:</strong> There was an error connecting to the server, Please verify the settings are correct.' );
if ( is_wp_error($error) )
if ( is_wp_error( $error ) ) {
$error_string = esc_html( $error->get_error_message() );
}
echo '<div id="message" class="error"><p>' . $error_string . '</p></div>';
}
$types = array();
if ( extension_loaded('ftp') || extension_loaded('sockets') || function_exists('fsockopen') )
if ( extension_loaded( 'ftp' ) || extension_loaded( 'sockets' ) || function_exists( 'fsockopen' ) ) {
$types['ftp'] = __( 'FTP' );
if ( extension_loaded('ftp') ) //Only this supports FTPS
}
if ( extension_loaded( 'ftp' ) ) { //Only this supports FTPS
$types['ftps'] = __( 'FTPS (SSL)' );
if ( extension_loaded('ssh2') && function_exists('stream_get_contents') )
}
if ( extension_loaded( 'ssh2' ) && function_exists( 'stream_get_contents' ) ) {
$types['ssh'] = __( 'SSH2' );
}
/**
* Filters the connection types to output to the filesystem credentials form.
@ -1677,7 +1749,7 @@ function request_filesystem_credentials( $form_post, $type = '', $error = false,
$types = apply_filters( 'fs_ftp_connection_types', $types, $credentials, $type, $error, $context );
?>
<form action="<?php echo esc_url( $form_post ) ?>" method="post">
<form action="<?php echo esc_url( $form_post ); ?>" method="post">
<div id="request-filesystem-credentials-form" class="request-filesystem-credentials-form">
<?php
// Print a H1 heading in the FTP credentials modal dialog, default is a H2.
@ -1687,7 +1759,8 @@ if ( 'plugins.php' === $pagenow || 'plugin-install.php' === $pagenow ) {
}
echo "<$heading_tag id='request-filesystem-credentials-title'>" . __( 'Connection Information' ) . "</$heading_tag>";
?>
<p id="request-filesystem-credentials-desc"><?php
<p id="request-filesystem-credentials-desc">
<?php
$label_user = __( 'Username' );
$label_pass = __( 'Password' );
_e( 'To perform the requested action, WordPress needs to access your web server.' );
@ -1710,31 +1783,49 @@ echo "<$heading_tag id='request-filesystem-credentials-title'>" . __( 'Connectio
if ( defined( 'FTP_PASS' ) ) {
$password_value = '*****';
}
?></p>
?>
</p>
<label for="hostname">
<span class="field-title"><?php _e( 'Hostname' ) ?></span>
<input name="hostname" type="text" id="hostname" aria-describedby="request-filesystem-credentials-desc" class="code" placeholder="<?php esc_attr_e( 'example: www.wordpress.org' ) ?>" value="<?php echo esc_attr($hostname); if ( !empty($port) ) echo ":$port"; ?>"<?php disabled( defined('FTP_HOST') ); ?> />
<span class="field-title"><?php _e( 'Hostname' ); ?></span>
<input name="hostname" type="text" id="hostname" aria-describedby="request-filesystem-credentials-desc" class="code" placeholder="<?php esc_attr_e( 'example: www.wordpress.org' ); ?>" value="
<?php
echo esc_attr( $hostname );
if ( ! empty( $port ) ) {
echo ":$port";}
?>
"<?php disabled( defined( 'FTP_HOST' ) ); ?> />
</label>
<div class="ftp-username">
<label for="username">
<span class="field-title"><?php echo $label_user; ?></span>
<input name="username" type="text" id="username" value="<?php echo esc_attr($username) ?>"<?php disabled( defined('FTP_USER') ); ?> />
<input name="username" type="text" id="username" value="<?php echo esc_attr( $username ); ?>"<?php disabled( defined( 'FTP_USER' ) ); ?> />
</label>
</div>
<div class="ftp-password">
<label for="password">
<span class="field-title"><?php echo $label_pass; ?></span>
<input name="password" type="password" id="password" value="<?php echo $password_value; ?>"<?php disabled( defined( 'FTP_PASS' ) ); ?> />
<em><?php if ( ! defined('FTP_PASS') ) _e( 'This password will not be stored on the server.' ); ?></em>
<em>
<?php
if ( ! defined( 'FTP_PASS' ) ) {
_e( 'This password will not be stored on the server.' );}
?>
</em>
</label>
</div>
<fieldset>
<legend><?php _e( 'Connection Type' ); ?></legend>
<?php
$disabled = disabled( ( defined( 'FTP_SSL' ) && FTP_SSL ) || ( defined( 'FTP_SSH' ) && FTP_SSH ), true, false );
foreach ( $types as $name => $text ) : ?>
<label for="<?php echo esc_attr( $name ) ?>">
<input type="radio" name="connection_type" id="<?php echo esc_attr( $name ) ?>" value="<?php echo esc_attr( $name ) ?>"<?php checked( $name, $connection_type ); echo $disabled; ?> />
foreach ( $types as $name => $text ) :
?>
<label for="<?php echo esc_attr( $name ); ?>">
<input type="radio" name="connection_type" id="<?php echo esc_attr( $name ); ?>" value="<?php echo esc_attr( $name ); ?>"
<?php
checked( $name, $connection_type );
echo $disabled;
?>
/>
<?php echo $text; ?>
</label>
<?php
@ -1751,22 +1842,23 @@ if ( isset( $types['ssh'] ) ) {
<fieldset id="ssh-keys"<?php echo $hidden_class; ?>>
<legend><?php _e( 'Authentication Keys' ); ?></legend>
<label for="public_key">
<span class="field-title"><?php _e('Public Key:') ?></span>
<input name="public_key" type="text" id="public_key" aria-describedby="auth-keys-desc" value="<?php echo esc_attr($public_key) ?>"<?php disabled( defined('FTP_PUBKEY') ); ?> />
<span class="field-title"><?php _e( 'Public Key:' ); ?></span>
<input name="public_key" type="text" id="public_key" aria-describedby="auth-keys-desc" value="<?php echo esc_attr( $public_key ); ?>"<?php disabled( defined( 'FTP_PUBKEY' ) ); ?> />
</label>
<label for="private_key">
<span class="field-title"><?php _e('Private Key:') ?></span>
<input name="private_key" type="text" id="private_key" value="<?php echo esc_attr($private_key) ?>"<?php disabled( defined('FTP_PRIKEY') ); ?> />
<span class="field-title"><?php _e( 'Private Key:' ); ?></span>
<input name="private_key" type="text" id="private_key" value="<?php echo esc_attr( $private_key ); ?>"<?php disabled( defined( 'FTP_PRIKEY' ) ); ?> />
</label>
<p id="auth-keys-desc"><?php _e( 'Enter the location on the server where the public and private keys are located. If a passphrase is needed, enter that in the password field above.' ) ?></p>
<p id="auth-keys-desc"><?php _e( 'Enter the location on the server where the public and private keys are located. If a passphrase is needed, enter that in the password field above.' ); ?></p>
</fieldset>
<?php
}
foreach ( (array) $extra_fields as $field ) {
if ( isset( $submitted_form[ $field ] ) )
if ( isset( $submitted_form[ $field ] ) ) {
echo '<input type="hidden" name="' . esc_attr( $field ) . '" value="' . esc_attr( $submitted_form[ $field ] ) . '" />';
}
}
?>
<p class="request-filesystem-credentials-action-buttons">
<?php wp_nonce_field( 'filesystem-credentials', '_fs_nonce', false, true ); ?>

View File

@ -20,24 +20,27 @@ function wp_image_editor($post_id, $msg = false) {
$sub_sizes = isset( $meta['sizes'] ) && is_array( $meta['sizes'] );
$note = '';
if ( isset( $meta['width'], $meta['height'] ) )
if ( isset( $meta['width'], $meta['height'] ) ) {
$big = max( $meta['width'], $meta['height'] );
else
} else {
die( __( 'Image data does not exist. Please re-upload the image.' ) );
}
$sizer = $big > 400 ? 400 / $big : 1;
$backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true );
$can_restore = false;
if ( ! empty( $backup_sizes ) && isset( $backup_sizes['full-orig'], $meta['file'] ) )
if ( ! empty( $backup_sizes ) && isset( $backup_sizes['full-orig'], $meta['file'] ) ) {
$can_restore = $backup_sizes['full-orig']['file'] != basename( $meta['file'] );
}
if ( $msg ) {
if ( isset($msg->error) )
if ( isset( $msg->error ) ) {
$note = "<div class='error'><p>$msg->error</p></div>";
elseif ( isset($msg->msg) )
} elseif ( isset( $msg->msg ) ) {
$note = "<div class='updated'><p>$msg->msg</p></div>";
}
}
?>
<div class="imgedit-wrap wp-clearfix">
@ -81,12 +84,16 @@ function wp_image_editor($post_id, $msg = false) {
<div class="imgedit-group-top">
<h2><button type="button" onclick="imageEdit.toggleHelp(this);" class="button-link"><?php _e( 'Restore Original Image' ); ?> <span class="dashicons dashicons-arrow-down imgedit-help-toggle"></span></button></h2>
<div class="imgedit-help">
<p><?php _e('Discard any changes and restore the original image.');
<p>
<?php
_e( 'Discard any changes and restore the original image.' );
if ( !defined('IMAGE_EDIT_OVERWRITE') || !IMAGE_EDIT_OVERWRITE )
if ( ! defined( 'IMAGE_EDIT_OVERWRITE' ) || ! IMAGE_EDIT_OVERWRITE ) {
echo ' ' . __( 'Previously edited copies of the image will not be deleted.' );
}
?></p>
?>
</p>
<div class="imgedit-submit">
<input type="button" onclick="imageEdit.action(<?php echo "$post_id, '$nonce'"; ?>, 'restore')" class="button button-primary" value="<?php esc_attr_e( 'Restore image' ); ?>" <?php echo $can_restore; ?> />
</div>
@ -140,7 +147,8 @@ function wp_image_editor($post_id, $msg = false) {
</div>
<?php if ( $thumb && $sub_sizes ) {
<?php
if ( $thumb && $sub_sizes ) {
$thumb_img = wp_constrain_dimensions( $thumb['width'], $thumb['height'], 160, 120 );
?>
@ -182,15 +190,22 @@ function wp_image_editor($post_id, $msg = false) {
<div class="imgedit-panel-content wp-clearfix">
<?php echo $note; ?>
<div class="imgedit-menu wp-clearfix">
<button type="button" onclick="imageEdit.crop(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-crop button disabled" disabled><span class="screen-reader-text"><?php esc_html_e( 'Crop' ); ?></span></button><?php
<button type="button" onclick="imageEdit.crop(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-crop button disabled" disabled><span class="screen-reader-text"><?php esc_html_e( 'Crop' ); ?></span></button>
<?php
// On some setups GD library does not provide imagerotate() - Ticket #11536
if ( wp_image_editor_supports( array( 'mime_type' => get_post_mime_type( $post_id ), 'methods' => array( 'rotate' ) ) ) ) {
if ( wp_image_editor_supports(
array(
'mime_type' => get_post_mime_type( $post_id ),
'methods' => array( 'rotate' ),
)
) ) {
$note_no_rotate = '';
?>
<button type="button" class="imgedit-rleft button" onclick="imageEdit.rotate( 90, <?php echo "$post_id, '$nonce'"; ?>, this)"><span class="screen-reader-text"><?php esc_html_e( 'Rotate counter-clockwise' ); ?></span></button>
<button type="button" class="imgedit-rright button" onclick="imageEdit.rotate(-90, <?php echo "$post_id, '$nonce'"; ?>, this)"><span class="screen-reader-text"><?php esc_html_e( 'Rotate clockwise' ); ?></span></button>
<?php } else {
<?php
} else {
$note_no_rotate = '<p class="note-no-rotate"><em>' . __( 'Image rotation is not supported by your web host.' ) . '</em></p>';
?>
<button type="button" class="imgedit-rleft button disabled" disabled></button>
@ -250,8 +265,9 @@ function wp_stream_image( $image, $mime_type, $attachment_id ) {
*/
$image = apply_filters( 'image_editor_save_pre', $image, $attachment_id );
if ( is_wp_error( $image->stream( $mime_type ) ) )
if ( is_wp_error( $image->stream( $mime_type ) ) ) {
return false;
}
return true;
} else {
@ -315,8 +331,9 @@ function wp_save_image_file( $filename, $image, $mime_type, $post_id ) {
*/
$saved = apply_filters( 'wp_save_image_editor_file', null, $filename, $image, $mime_type, $post_id );
if ( null !== $saved )
if ( null !== $saved ) {
return $saved;
}
return $image->save( $filename, $mime_type );
} else {
@ -342,12 +359,12 @@ function wp_save_image_file( $filename, $image, $mime_type, $post_id ) {
*/
$saved = apply_filters( 'wp_save_image_file', null, $filename, $image, $mime_type, $post_id );
if ( null !== $saved )
if ( null !== $saved ) {
return $saved;
}
switch ( $mime_type ) {
case 'image/jpeg':
/** This filter is documented in wp-includes/class-wp-image-editor.php */
return imagejpeg( $image, $filename, apply_filters( 'jpeg_quality', 90, 'edit_image' ) );
case 'image/png':
@ -465,11 +482,13 @@ function _crop_image_resource($img, $x, $y, $w, $h) {
* @return WP_Image_Editor WP_Image_Editor instance with changes applied.
*/
function image_edit_apply_changes( $image, $changes ) {
if ( is_resource( $image ) )
if ( is_resource( $image ) ) {
_deprecated_argument( __FUNCTION__, '3.5.0', __( '$image needs to be an WP_Image_Editor object' ) );
}
if ( !is_array($changes) )
if ( ! is_array( $changes ) ) {
return $image;
}
// Expand change operations.
foreach ( $changes as $key => $obj ) {
@ -506,9 +525,10 @@ function image_edit_apply_changes( $image, $changes ) {
break;
}
}
if ( !$combined )
if ( ! $combined ) {
$filtered[ ++$i ] = $changes[ $j ];
}
}
$changes = $filtered;
unset( $filtered );
}
@ -543,18 +563,21 @@ function image_edit_apply_changes( $image, $changes ) {
switch ( $operation->type ) {
case 'rotate':
if ( $operation->angle != 0 ) {
if ( $image instanceof WP_Image_Editor )
if ( $image instanceof WP_Image_Editor ) {
$image->rotate( $operation->angle );
else
} else {
$image = _rotate_image_resource( $image, $operation->angle );
}
}
break;
case 'flip':
if ( $operation->axis != 0 )
if ( $image instanceof WP_Image_Editor )
if ( $operation->axis != 0 ) {
if ( $image instanceof WP_Image_Editor ) {
$image->flip( ( $operation->axis & 1 ) != 0, ( $operation->axis & 2 ) != 0 );
else
} else {
$image = _flip_image_resource( $image, ( $operation->axis & 1 ) != 0, ( $operation->axis & 2 ) != 0 );
}
}
break;
case 'crop':
$sel = $operation->sel;
@ -597,8 +620,9 @@ function stream_preview_image( $post_id ) {
}
$changes = ! empty( $_REQUEST['history'] ) ? json_decode( wp_unslash( $_REQUEST['history'] ) ) : null;
if ( $changes )
if ( $changes ) {
$img = image_edit_apply_changes( $img, $changes );
}
// Scale the image.
$size = $img->get_size();
@ -609,8 +633,9 @@ function stream_preview_image( $post_id ) {
$w2 = max( 1, $w * $ratio );
$h2 = max( 1, $h * $ratio );
if ( is_wp_error( $img->resize( $w2, $h2 ) ) )
if ( is_wp_error( $img->resize( $w2, $h2 ) ) ) {
return false;
}
return wp_stream_image( $img, $post->post_mime_type, $post_id );
}
@ -650,7 +675,11 @@ function wp_restore_image($post_id) {
wp_delete_file( $file );
}
} elseif ( isset( $meta['width'], $meta['height'] ) ) {
$backup_sizes["full-$suffix"] = array('width' => $meta['width'], 'height' => $meta['height'], 'file' => $parts['basename']);
$backup_sizes[ "full-$suffix" ] = array(
'width' => $meta['width'],
'height' => $meta['height'],
'file' => $parts['basename'],
);
}
}
@ -691,10 +720,11 @@ function wp_restore_image($post_id) {
return $msg;
}
if ( !$restored )
if ( ! $restored ) {
$msg->error = __( 'Image metadata is inconsistent.' );
else
} else {
$msg->msg = __( 'Image restored successfully.' );
}
return $msg;
}
@ -733,9 +763,10 @@ function wp_save_image( $post_id ) {
$diff = round( $sX / $sY, 2 ) - round( $fwidth / $fheight, 2 );
if ( -0.1 < $diff && $diff < 0.1 ) {
// Scale the full size image.
if ( $img->resize( $fwidth, $fheight ) )
if ( $img->resize( $fwidth, $fheight ) ) {
$scaled = true;
}
}
if ( ! $scaled ) {
$return->error = esc_js( __( 'Error while saving the scaled image. Please reload the page and try again.' ) );
@ -743,8 +774,9 @@ function wp_save_image( $post_id ) {
}
} elseif ( ! empty( $_REQUEST['history'] ) ) {
$changes = json_decode( wp_unslash( $_REQUEST['history'] ) );
if ( $changes )
if ( $changes ) {
$img = image_edit_apply_changes( $img, $changes );
}
} else {
$return->error = esc_js( __( 'Nothing to save, the image has not changed.' ) );
return $return;
@ -758,8 +790,9 @@ function wp_save_image( $post_id ) {
return $return;
}
if ( !is_array($backup_sizes) )
if ( ! is_array( $backup_sizes ) ) {
$backup_sizes = array();
}
// Generate new filename.
$path = get_attached_file( $post_id );
@ -809,7 +842,11 @@ function wp_save_image( $post_id ) {
}
if ( $tag ) {
$backup_sizes[$tag] = array('width' => $meta['width'], 'height' => $meta['height'], 'file' => $basename );
$backup_sizes[ $tag ] = array(
'width' => $meta['width'],
'height' => $meta['height'],
'file' => $basename,
);
}
$success = ( $path === $new_path ) || update_attached_file( $post_id, $new_path );
@ -821,9 +858,10 @@ function wp_save_image( $post_id ) {
if ( $success && ( 'nothumb' == $target || 'all' == $target ) ) {
$sizes = get_intermediate_image_sizes();
if ( 'nothumb' == $target )
if ( 'nothumb' == $target ) {
$sizes = array_diff( $sizes, array( 'thumbnail' ) );
}
}
$return->fw = $meta['width'];
$return->fh = $meta['height'];
@ -854,15 +892,17 @@ function wp_save_image( $post_id ) {
$tag = false;
if ( isset( $meta['sizes'][ $size ] ) ) {
if ( isset( $backup_sizes[ "$size-orig" ] ) ) {
if ( ( !defined('IMAGE_EDIT_OVERWRITE') || !IMAGE_EDIT_OVERWRITE ) && $backup_sizes["$size-orig"]['file'] != $meta['sizes'][$size]['file'] )
if ( ( ! defined( 'IMAGE_EDIT_OVERWRITE' ) || ! IMAGE_EDIT_OVERWRITE ) && $backup_sizes[ "$size-orig" ]['file'] != $meta['sizes'][ $size ]['file'] ) {
$tag = "$size-$suffix";
}
} else {
$tag = "$size-orig";
}
if ( $tag )
if ( $tag ) {
$backup_sizes[ $tag ] = $meta['sizes'][ $size ];
}
}
if ( isset( $_wp_additional_image_sizes[ $size ] ) ) {
$width = intval( $_wp_additional_image_sizes[ $size ]['width'] );
@ -874,7 +914,11 @@ function wp_save_image( $post_id ) {
$crop = ( $nocrop ) ? false : get_option( "{$size}_crop" );
}
$_sizes[ $size ] = array( 'width' => $width, 'height' => $height, 'crop' => $crop );
$_sizes[ $size ] = array(
'width' => $width,
'height' => $height,
'crop' => $crop,
);
}
$meta['sizes'] = array_merge( $meta['sizes'], $img->multi_resize( $_sizes ) );

View File

@ -37,15 +37,18 @@ function wp_crop_image( $src, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $s
}
$editor = wp_get_image_editor( $src );
if ( is_wp_error( $editor ) )
if ( is_wp_error( $editor ) ) {
return $editor;
}
$src = $editor->crop( $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs );
if ( is_wp_error( $src ) )
if ( is_wp_error( $src ) ) {
return $src;
}
if ( ! $dst_file )
if ( ! $dst_file ) {
$dst_file = str_replace( basename( $src_file ), 'cropped-' . basename( $src_file ), $src_file );
}
/*
* The directory containing the original file may no longer exist when
@ -56,8 +59,9 @@ function wp_crop_image( $src, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $s
$dst_file = dirname( $dst_file ) . '/' . wp_unique_filename( dirname( $dst_file ), basename( $dst_file ) );
$result = $editor->save( $dst_file );
if ( is_wp_error( $result ) )
if ( is_wp_error( $result ) ) {
return $result;
}
return $dst_file;
}
@ -91,7 +95,11 @@ function wp_generate_attachment_metadata( $attachment_id, $file ) {
$sizes = array();
foreach ( get_intermediate_image_sizes() as $s ) {
$sizes[$s] = array( 'width' => '', 'height' => '', 'crop' => false );
$sizes[ $s ] = array(
'width' => '',
'height' => '',
'crop' => false,
);
if ( isset( $_wp_additional_image_sizes[ $s ]['width'] ) ) {
// For theme-added sizes
$sizes[ $s ]['width'] = intval( $_wp_additional_image_sizes[ $s ]['width'] );
@ -131,17 +139,18 @@ function wp_generate_attachment_metadata( $attachment_id, $file ) {
if ( $sizes ) {
$editor = wp_get_image_editor( $file );
if ( ! is_wp_error( $editor ) )
if ( ! is_wp_error( $editor ) ) {
$metadata['sizes'] = $editor->multi_resize( $sizes );
}
} else {
$metadata['sizes'] = array();
}
// Fetch additional metadata from EXIF/IPTC.
$image_meta = wp_read_image_metadata( $file );
if ( $image_meta )
if ( $image_meta ) {
$metadata['image_meta'] = $image_meta;
}
} elseif ( wp_attachment_is( 'video', $attachment ) ) {
$metadata = wp_read_video_metadata( $file );
$support = current_theme_supports( 'post-thumbnails', 'attachment:video' ) || post_type_supports( 'attachment:video', 'thumbnail' );
@ -153,15 +162,17 @@ function wp_generate_attachment_metadata( $attachment_id, $file ) {
if ( $support && ! empty( $metadata['image']['data'] ) ) {
// Check for existing cover.
$hash = md5( $metadata['image']['data'] );
$posts = get_posts( array(
$posts = get_posts(
array(
'fields' => 'ids',
'post_type' => 'attachment',
'post_mime_type' => $metadata['image']['mime'],
'post_status' => 'inherit',
'posts_per_page' => 1,
'meta_key' => '_cover_hash',
'meta_value' => $hash
) );
'meta_value' => $hash,
)
);
$exists = reset( $posts );
if ( ! empty( $exists ) ) {
@ -202,8 +213,7 @@ function wp_generate_attachment_metadata( $attachment_id, $file ) {
update_post_meta( $attachment_id, '_thumbnail_id', $sub_attachment_id );
}
}
}
// Try to create image thumbnails for PDFs
} // Try to create image thumbnails for PDFs
elseif ( 'application/pdf' === $mime_type ) {
$fallback_sizes = array(
'thumbnail',
@ -303,8 +313,9 @@ function wp_generate_attachment_metadata( $attachment_id, $file ) {
*/
function wp_exif_frac2dec( $str ) {
@list( $n, $d ) = explode( '/', $str );
if ( !empty($d) )
if ( ! empty( $d ) ) {
return $n / $d;
}
return $str;
}
@ -340,8 +351,9 @@ function wp_exif_date2ts($str) {
* @return bool|array False on failure. Image metadata array on success.
*/
function wp_read_image_metadata( $file ) {
if ( ! file_exists( $file ) )
if ( ! file_exists( $file ) ) {
return false;
}
list( , , $sourceImageType ) = getimagesize( $file );
@ -403,16 +415,19 @@ function wp_read_image_metadata( $file ) {
$meta['caption'] = $caption;
}
if ( ! empty( $iptc['2#110'][0] ) ) // credit
if ( ! empty( $iptc['2#110'][0] ) ) { // credit
$meta['credit'] = trim( $iptc['2#110'][0] );
elseif ( ! empty( $iptc['2#080'][0] ) ) // creator / legacy byline
} elseif ( ! empty( $iptc['2#080'][0] ) ) { // creator / legacy byline
$meta['credit'] = trim( $iptc['2#080'][0] );
}
if ( ! empty( $iptc['2#055'][0] ) && ! empty( $iptc['2#060'][0] ) ) // created date and time
if ( ! empty( $iptc['2#055'][0] ) && ! empty( $iptc['2#060'][0] ) ) { // created date and time
$meta['created_timestamp'] = strtotime( $iptc['2#055'][0] . ' ' . $iptc['2#060'][0] );
}
if ( ! empty( $iptc['2#116'][0] ) ) // copyright
if ( ! empty( $iptc['2#116'][0] ) ) { // copyright
$meta['copyright'] = trim( $iptc['2#116'][0] );
}
if ( ! empty( $iptc['2#025'][0] ) ) { // keywords array
$meta['keywords'] = array_values( $iptc['2#025'] );
@ -571,8 +586,9 @@ function file_is_displayable_image($path) {
*/
function load_image_to_edit( $attachment_id, $mime_type, $size = 'full' ) {
$filepath = _load_image_to_edit_path( $attachment_id, $size );
if ( empty( $filepath ) )
if ( empty( $filepath ) ) {
return false;
}
switch ( $mime_type ) {
case 'image/jpeg':
@ -676,8 +692,9 @@ function _load_image_to_edit_path( $attachment_id, $size = 'full' ) {
*/
function _copy_image_file( $attachment_id ) {
$dst_file = $src_file = get_attached_file( $attachment_id );
if ( ! file_exists( $src_file ) )
if ( ! file_exists( $src_file ) ) {
$src_file = _load_image_to_edit_path( $attachment_id );
}
if ( $src_file ) {
$dst_file = str_replace( basename( $dst_file ), 'copy-' . basename( $dst_file ), $dst_file );
@ -689,8 +706,9 @@ function _copy_image_file( $attachment_id ) {
*/
wp_mkdir_p( dirname( $dst_file ) );
if ( ! @copy( $src_file, $dst_file ) )
if ( ! @copy( $src_file, $dst_file ) ) {
$dst_file = false;
}
} else {
$dst_file = false;
}

View File

@ -53,8 +53,9 @@ function _usort_by_first_member( $a, $b ) {
*/
function register_importer( $id, $name, $description, $callback ) {
global $wp_importers;
if ( is_wp_error( $callback ) )
if ( is_wp_error( $callback ) ) {
return $callback;
}
$wp_importers[ $id ] = array( $name, $description, $callback );
}
@ -81,11 +82,14 @@ function wp_import_cleanup( $id ) {
function wp_import_handle_upload() {
if ( ! isset( $_FILES['import'] ) ) {
return array(
'error' => __( 'File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.' )
'error' => __( 'File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.' ),
);
}
$overrides = array( 'test_form' => false, 'test_type' => false );
$overrides = array(
'test_form' => false,
'test_type' => false,
);
$_FILES['import']['name'] .= '.txt';
$upload = wp_handle_upload( $_FILES['import'], $overrides );
@ -100,7 +104,7 @@ function wp_import_handle_upload() {
'post_mime_type' => $upload['type'],
'guid' => $upload['url'],
'context' => 'import',
'post_status' => 'private'
'post_status' => 'private',
);
// Save the data
@ -112,7 +116,10 @@ function wp_import_handle_upload() {
*/
wp_schedule_single_event( time() + DAY_IN_SECONDS, 'importer_scheduled_cleanup', array( $id ) );
return array( 'file' => $upload['file'], 'id' => $id );
return array(
'file' => $upload['file'],
'id' => $id,
);
}
/**
@ -130,10 +137,12 @@ function wp_get_popular_importers() {
$popular_importers = get_site_transient( $cache_key );
if ( ! $popular_importers ) {
$url = add_query_arg( array(
$url = add_query_arg(
array(
'locale' => $locale,
'version' => $wp_version,
), 'http://api.wordpress.org/core/importers/1.1/' );
), 'http://api.wordpress.org/core/importers/1.1/'
);
$options = array( 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ) );
if ( wp_http_supports( array( 'ssl' ) ) ) {
@ -152,14 +161,16 @@ function wp_get_popular_importers() {
if ( is_array( $popular_importers ) ) {
// If the data was received as translated, return it as-is.
if ( $popular_importers['translated'] )
if ( $popular_importers['translated'] ) {
return $popular_importers['importers'];
}
foreach ( $popular_importers['importers'] as &$importer ) {
$importer['description'] = translate( $importer['description'] );
if ( $importer['name'] != 'WordPress' )
if ( $importer['name'] != 'WordPress' ) {
$importer['name'] = translate( $importer['name'] );
}
}
return $popular_importers['importers'];
}

View File

@ -40,15 +40,17 @@ function _get_list_table( $class, $args = array() ) {
);
if ( isset( $core_classes[ $class ] ) ) {
foreach ( (array) $core_classes[ $class ] as $required )
foreach ( (array) $core_classes[ $class ] as $required ) {
require_once( ABSPATH . 'wp-admin/includes/class-wp-' . $required . '-list-table.php' );
}
if ( isset( $args['screen'] ) )
if ( isset( $args['screen'] ) ) {
$args['screen'] = convert_to_screen( $args['screen'] );
elseif ( isset( $GLOBALS['hook_suffix'] ) )
} elseif ( isset( $GLOBALS['hook_suffix'] ) ) {
$args['screen'] = get_current_screen();
else
} else {
$args['screen'] = null;
}
return new $class( $args );
}

File diff suppressed because it is too large Load Diff

View File

@ -49,20 +49,22 @@ foreach ($menu as $menu_page) {
$hook_args = substr( $menu_page[2], $pos + 1 );
wp_parse_str( $hook_args, $hook_args );
// Set the hook name to be the post type.
if ( isset($hook_args['post_type']) )
if ( isset( $hook_args['post_type'] ) ) {
$hook_name = $hook_args['post_type'];
else
} else {
$hook_name = basename( $hook_name, '.php' );
}
unset( $hook_args );
} else {
$hook_name = basename( $menu_page[2], '.php' );
}
$hook_name = sanitize_title( $hook_name );
if ( isset($compat[$hook_name]) )
if ( isset( $compat[ $hook_name ] ) ) {
$hook_name = $compat[ $hook_name ];
elseif ( !$hook_name )
} elseif ( ! $hook_name ) {
continue;
}
$admin_page_hooks[ $menu_page[2] ] = $hook_name;
}
@ -80,9 +82,10 @@ foreach ($submenu as $parent => $sub) {
}
unset( $index, $data );
if ( empty($submenu[$parent]) )
if ( empty( $submenu[ $parent ] ) ) {
unset( $submenu[ $parent ] );
}
}
unset( $sub, $parent );
/*
@ -91,8 +94,9 @@ unset($sub, $parent);
* will have the next submenu in line be assigned as the new menu parent.
*/
foreach ( $menu as $id => $data ) {
if ( empty($submenu[$data[2]]) )
if ( empty( $submenu[ $data[2] ] ) ) {
continue;
}
$subs = $submenu[ $data[2] ];
$first_sub = reset( $subs );
$old_parent = $data[2];
@ -111,10 +115,11 @@ foreach ( $menu as $id => $data ) {
}
unset( $submenu[ $old_parent ], $index );
if ( isset($_wp_submenu_nopriv[$old_parent]) )
if ( isset( $_wp_submenu_nopriv[ $old_parent ] ) ) {
$_wp_submenu_nopriv[ $new_parent ] = $_wp_submenu_nopriv[ $old_parent ];
}
}
}
unset( $id, $data, $subs, $first_sub, $old_parent, $new_parent );
if ( is_network_admin() ) {
@ -154,8 +159,9 @@ if ( is_network_admin() ) {
* that the user does not have. Run re-parent loop again.
*/
foreach ( $menu as $id => $data ) {
if ( ! current_user_can($data[1]) )
if ( ! current_user_can( $data[1] ) ) {
$_wp_menu_nopriv[ $data[2] ] = true;
}
/*
* If there is only one submenu and it is has same destination as the parent,
@ -164,9 +170,10 @@ foreach ( $menu as $id => $data ) {
if ( ! empty( $submenu[ $data[2] ] ) && 1 == count( $submenu[ $data[2] ] ) ) {
$subs = $submenu[ $data[2] ];
$first_sub = reset( $subs );
if ( $data[2] == $first_sub[2] )
if ( $data[2] == $first_sub[2] ) {
unset( $submenu[ $data[2] ] );
}
}
// If submenu is empty...
if ( empty( $submenu[ $data[2] ] ) ) {
@ -179,7 +186,6 @@ foreach ( $menu as $id => $data ) {
unset( $id, $data, $subs, $first_sub );
/**
*
* @param string $add
* @param string $class
* @return string
@ -190,7 +196,6 @@ function add_cssclass($add, $class) {
}
/**
*
* @param array $menu
* @return array
*/
@ -238,7 +243,7 @@ function add_menu_classes($menu) {
return apply_filters( 'add_menu_classes', $menu );
}
uksort($menu, "strnatcasecmp"); // make it all pretty
uksort( $menu, 'strnatcasecmp' ); // make it all pretty
/**
* Filters whether to enable custom ordering of the administration menu.
@ -274,7 +279,6 @@ if ( apply_filters( 'custom_menu_order', false ) ) {
$default_menu_order = array_flip( $default_menu_order );
/**
*
* @global array $menu_order
* @global array $default_menu_order
*
@ -291,8 +295,9 @@ if ( apply_filters( 'custom_menu_order', false ) ) {
} elseif ( ! isset( $menu_order[ $a ] ) && isset( $menu_order[ $b ] ) ) {
return 1;
} elseif ( isset( $menu_order[ $a ] ) && isset( $menu_order[ $b ] ) ) {
if ( $menu_order[$a] == $menu_order[$b] )
if ( $menu_order[ $a ] == $menu_order[ $b ] ) {
return 0;
}
return ( $menu_order[ $a ] < $menu_order[ $b ] ) ? -1 : 1;
} else {
return ( $default_menu_order[ $a ] <= $default_menu_order[ $b ] ) ? -1 : 1;
@ -326,8 +331,9 @@ unset( $id, $data, $prev_menu_was_separator );
// Remove the last menu item if it is a separator.
$last_menu_key = array_keys( $menu );
$last_menu_key = array_pop( $last_menu_key );
if ( !empty( $menu ) && 'wp-menu-separator' == $menu[ $last_menu_key ][ 4 ] )
if ( ! empty( $menu ) && 'wp-menu-separator' == $menu[ $last_menu_key ][4] ) {
unset( $menu[ $last_menu_key ] );
}
unset( $last_menu_key );
if ( ! user_can_access_admin_page() ) {

View File

@ -61,7 +61,8 @@ if ( 'publish' == $post->post_status ) {
$preview_button_text = __( 'Preview' );
}
$preview_button = sprintf( '%1$s<span class="screen-reader-text"> %2$s</span>',
$preview_button = sprintf(
'%1$s<span class="screen-reader-text"> %2$s</span>',
$preview_button_text,
/* translators: accessibility text */
__( '(opens in a new window)' )
@ -87,7 +88,8 @@ do_action( 'post_submitbox_minor_actions', $post );
<div id="misc-publishing-actions">
<div class="misc-pub-section misc-pub-post-status">
<?php _e( 'Status:' ) ?> <span id="post-status-display"><?php
<?php _e( 'Status:' ); ?> <span id="post-status-display">
<?php
switch ( $post->post_status ) {
case 'private':
@ -120,20 +122,20 @@ switch ( $post->post_status ) {
<div id="post-status-select" class="hide-if-js">
<input type="hidden" name="hidden_post_status" id="hidden_post_status" value="<?php echo esc_attr( ( 'auto-draft' == $post->post_status ) ? 'draft' : $post->post_status ); ?>" />
<label for="post_status" class="screen-reader-text"><?php _e( 'Set status' ) ?></label>
<label for="post_status" class="screen-reader-text"><?php _e( 'Set status' ); ?></label>
<select name="post_status" id="post_status">
<?php if ( 'publish' == $post->post_status ) : ?>
<option<?php selected( $post->post_status, 'publish' ); ?> value='publish'><?php _e('Published') ?></option>
<option<?php selected( $post->post_status, 'publish' ); ?> value='publish'><?php _e( 'Published' ); ?></option>
<?php elseif ( 'private' == $post->post_status ) : ?>
<option<?php selected( $post->post_status, 'private' ); ?> value='publish'><?php _e('Privately Published') ?></option>
<option<?php selected( $post->post_status, 'private' ); ?> value='publish'><?php _e( 'Privately Published' ); ?></option>
<?php elseif ( 'future' == $post->post_status ) : ?>
<option<?php selected( $post->post_status, 'future' ); ?> value='future'><?php _e('Scheduled') ?></option>
<option<?php selected( $post->post_status, 'future' ); ?> value='future'><?php _e( 'Scheduled' ); ?></option>
<?php endif; ?>
<option<?php selected( $post->post_status, 'pending' ); ?> value='pending'><?php _e('Pending Review') ?></option>
<option<?php selected( $post->post_status, 'pending' ); ?> value='pending'><?php _e( 'Pending Review' ); ?></option>
<?php if ( 'auto-draft' == $post->post_status ) : ?>
<option<?php selected( $post->post_status, 'auto-draft' ); ?> value='draft'><?php _e('Draft') ?></option>
<option<?php selected( $post->post_status, 'auto-draft' ); ?> value='draft'><?php _e( 'Draft' ); ?></option>
<?php else : ?>
<option<?php selected( $post->post_status, 'draft' ); ?> value='draft'><?php _e('Draft') ?></option>
<option<?php selected( $post->post_status, 'draft' ); ?> value='draft'><?php _e( 'Draft' ); ?></option>
<?php endif; ?>
</select>
<a href="#post_status" class="save-post-status hide-if-no-js button"><?php _e( 'OK' ); ?></a>
@ -144,7 +146,8 @@ switch ( $post->post_status ) {
</div><!-- .misc-pub-section -->
<div class="misc-pub-section misc-pub-visibility" id="visibility">
<?php _e('Visibility:'); ?> <span id="post-visibility-display"><?php
<?php _e( 'Visibility:' ); ?> <span id="post-visibility-display">
<?php
if ( 'private' == $post->post_status ) {
$post->post_password = '';
@ -161,7 +164,9 @@ if ( 'private' == $post->post_status ) {
$visibility_trans = __( 'Public' );
}
echo esc_html( $visibility_trans ); ?></span>
echo esc_html( $visibility_trans );
?>
</span>
<?php if ( $can_publish ) { ?>
<a href="#visibility" class="edit-visibility hide-if-no-js" role="button"><span aria-hidden="true"><?php _e( 'Edit' ); ?></span> <span class="screen-reader-text"><?php _e( 'Edit visibility' ); ?></span></a>
@ -213,7 +218,8 @@ if ( 0 != $post->ID ) {
$date = date_i18n( $datef, strtotime( current_time( 'mysql' ) ) );
}
if ( ! empty( $args['args']['revisions_count'] ) ) : ?>
if ( ! empty( $args['args']['revisions_count'] ) ) :
?>
<div class="misc-pub-section misc-pub-revisions">
<?php
/* translators: Post revisions heading. 1: The number of available revisions */
@ -221,9 +227,11 @@ if ( ! empty( $args['args']['revisions_count'] ) ) : ?>
?>
<a class="hide-if-no-js" href="<?php echo esc_url( get_edit_post_link( $args['args']['revision_id'] ) ); ?>"><span aria-hidden="true"><?php _ex( 'Browse', 'revisions' ); ?></span> <span class="screen-reader-text"><?php _e( 'Browse revisions' ); ?></span></a>
</div>
<?php endif;
<?php
endif;
if ( $can_publish ) : // Contributors don't get to choose the date of publish ?>
if ( $can_publish ) : // Contributors don't get to choose the date of publish
?>
<div class="misc-pub-section curtime misc-pub-curtime">
<span id="timestamp">
<?php printf( $stamp, $date ); ?></span>
@ -285,14 +293,17 @@ do_action( 'post_submitbox_start', $post );
?>
<div id="delete-action">
<?php
if ( current_user_can( "delete_post", $post->ID ) ) {
if ( !EMPTY_TRASH_DAYS )
if ( current_user_can( 'delete_post', $post->ID ) ) {
if ( ! EMPTY_TRASH_DAYS ) {
$delete_text = __( 'Delete Permanently' );
else
} else {
$delete_text = __( 'Move to Trash' );
}
?>
<a class="submitdelete deletion" href="<?php echo get_delete_post_link( $post->ID ); ?>"><?php echo $delete_text; ?></a>
<?php
}
?>
<a class="submitdelete deletion" href="<?php echo get_delete_post_link($post->ID); ?>"><?php echo $delete_text; ?></a><?php
} ?>
</div>
<div id="publishing-action">
@ -300,23 +311,28 @@ if ( current_user_can( "delete_post", $post->ID ) ) {
<?php
if ( ! in_array( $post->post_status, array( 'publish', 'future', 'private' ) ) || 0 == $post->ID ) {
if ( $can_publish ) :
if ( !empty($post->post_date_gmt) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) : ?>
if ( ! empty( $post->post_date_gmt ) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) :
?>
<input name="original_publish" type="hidden" id="original_publish" value="<?php echo esc_attr_x( 'Schedule', 'post action/button label' ); ?>" />
<?php submit_button( _x( 'Schedule', 'post action/button label' ), 'primary large', 'publish', false ); ?>
<?php else : ?>
<input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Publish') ?>" />
<input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e( 'Publish' ); ?>" />
<?php submit_button( __( 'Publish' ), 'primary large', 'publish', false ); ?>
<?php endif;
else : ?>
<input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Submit for Review') ?>" />
<?php
endif;
else :
?>
<input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e( 'Submit for Review' ); ?>" />
<?php submit_button( __( 'Submit for Review' ), 'primary large', 'publish', false ); ?>
<?php
endif;
} else { ?>
<input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Update') ?>" />
<input name="save" type="submit" class="button button-primary button-large" id="publish" value="<?php esc_attr_e( 'Update' ) ?>" />
} else {
?>
<input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e( 'Update' ); ?>" />
<input name="save" type="submit" class="button button-primary button-large" id="publish" value="<?php esc_attr_e( 'Update' ); ?>" />
<?php
} ?>
}
?>
</div>
<div class="clear"></div>
</div>
@ -346,7 +362,8 @@ function attachment_submit_meta_box( $post ) {
<div id="misc-publishing-actions">
<div class="misc-pub-section curtime misc-pub-curtime">
<span id="timestamp"><?php
<span id="timestamp">
<?php
$date = date_i18n(
/* translators: Publish box date format, see https://secure.php.net/date */
__( 'M j, Y @ H:i' ),
@ -357,7 +374,8 @@ function attachment_submit_meta_box( $post ) {
__( 'Uploaded on: %s' ),
'<b>' . $date . '</b>'
);
?></span>
?>
</span>
</div><!-- .misc-pub-section -->
<?php
@ -379,20 +397,21 @@ function attachment_submit_meta_box( $post ) {
<div id="major-publishing-actions">
<div id="delete-action">
<?php
if ( current_user_can( 'delete_post', $post->ID ) )
if ( current_user_can( 'delete_post', $post->ID ) ) {
if ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) {
echo "<a class='submitdelete deletion' href='" . get_delete_post_link( $post->ID ) . "'>" . _x( 'Trash', 'verb' ) . "</a>";
echo "<a class='submitdelete deletion' href='" . get_delete_post_link( $post->ID ) . "'>" . _x( 'Trash', 'verb' ) . '</a>';
} else {
$delete_ays = ! MEDIA_TRASH ? " onclick='return showNotice.warn();'" : '';
echo "<a class='submitdelete deletion'$delete_ays href='" . get_delete_post_link( $post->ID, null, true ) . "'>" . __( 'Delete Permanently' ) . "</a>";
echo "<a class='submitdelete deletion'$delete_ays href='" . get_delete_post_link( $post->ID, null, true ) . "'>" . __( 'Delete Permanently' ) . '</a>';
}
}
?>
</div>
<div id="publishing-action">
<span class="spinner"></span>
<input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Update') ?>" />
<input name="save" type="submit" class="button button-primary button-large" id="publish" value="<?php esc_attr_e( 'Update' ) ?>" />
<input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e( 'Update' ); ?>" />
<input name="save" type="submit" class="button button-primary button-large" id="publish" value="<?php esc_attr_e( 'Update' ); ?>" />
</div>
<div class="clear"></div>
</div><!-- #major-publishing-actions -->
@ -423,11 +442,13 @@ function post_format_meta_box( $post, $box ) {
if ( is_array( $post_formats[0] ) ) :
$post_format = get_post_format( $post->ID );
if ( !$post_format )
if ( ! $post_format ) {
$post_format = '0';
}
// Add in the current one if it isn't there yet, in case the current theme doesn't support it
if ( $post_format && !in_array( $post_format, $post_formats[0] ) )
if ( $post_format && ! in_array( $post_format, $post_formats[0] ) ) {
$post_formats[0][] = $post_format;
}
?>
<div id="post-formats-select">
<fieldset>
@ -438,7 +459,9 @@ function post_format_meta_box( $post, $box ) {
<?php endforeach; ?>
</fieldset>
</div>
<?php endif; endif;
<?php
endif;
endif;
}
/**
@ -554,7 +577,14 @@ function post_categories_meta_box( $post, $box ) {
echo "<input type='hidden' name='{$name}[]' value='0' />"; // Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks.
?>
<ul id="<?php echo $tax_name; ?>checklist" data-wp-lists="list:<?php echo $tax_name; ?>" class="categorychecklist form-no-clear">
<?php wp_terms_checklist( $post->ID, array( 'taxonomy' => $tax_name, 'popular_cats' => $popular_ids ) ); ?>
<?php
wp_terms_checklist(
$post->ID, array(
'taxonomy' => $tax_name,
'popular_cats' => $popular_ids,
)
);
?>
</ul>
</div>
<?php if ( current_user_can( $taxonomy->cap->edit_terms ) ) : ?>
@ -628,14 +658,16 @@ function post_categories_meta_box( $post, $box ) {
*/
function post_excerpt_meta_box( $post ) {
?>
<label class="screen-reader-text" for="excerpt"><?php _e('Excerpt') ?></label><textarea rows="1" cols="40" name="excerpt" id="excerpt"><?php echo $post->post_excerpt; // textarea_escaped ?></textarea>
<p><?php
<label class="screen-reader-text" for="excerpt"><?php _e( 'Excerpt' ); ?></label><textarea rows="1" cols="40" name="excerpt" id="excerpt"><?php echo $post->post_excerpt; // textarea_escaped ?></textarea>
<p>
<?php
printf(
/* translators: %s: Codex URL */
__( 'Excerpts are optional hand-crafted summaries of your content that can be used in your theme. <a href="%s">Learn more about manual excerpts</a>.' ),
__( 'https://codex.wordpress.org/Excerpt' )
);
?></p>
?>
</p>
<?php
}
@ -653,7 +685,7 @@ function post_trackback_meta_box($post) {
$pings = '<p>' . __( 'Already pinged:' ) . '</p><ul>';
$already_pinged = explode( "\n", trim( $post->pinged ) );
foreach ( $already_pinged as $pinged_url ) {
$pings .= "\n\t<li>" . esc_html($pinged_url) . "</li>";
$pings .= "\n\t<li>" . esc_html( $pinged_url ) . '</li>';
}
$pings .= '</ul>';
}
@ -664,17 +696,20 @@ function post_trackback_meta_box($post) {
<?php echo $form_trackback; ?>
</p>
<p id="trackback-url-desc" class="howto"><?php _e( 'Separate multiple URLs with spaces' ); ?></p>
<p><?php
<p>
<?php
printf(
/* translators: %s: Codex URL */
__( 'Trackbacks are a way to notify legacy blog systems that you&#8217;ve linked to them. If you link other WordPress sites, they&#8217;ll be notified automatically using <a href="%s">pingbacks</a>, no other action necessary.' ),
__( 'https://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments' )
);
?></p>
?>
</p>
<?php
if ( ! empty($pings) )
if ( ! empty( $pings ) ) {
echo $pings;
}
}
/**
* Display custom fields form fields.
@ -690,19 +725,23 @@ function post_custom_meta_box($post) {
<?php
$metadata = has_meta( $post->ID );
foreach ( $metadata as $key => $value ) {
if ( is_protected_meta( $metadata[ $key ][ 'meta_key' ], 'post' ) || ! current_user_can( 'edit_post_meta', $post->ID, $metadata[ $key ][ 'meta_key' ] ) )
if ( is_protected_meta( $metadata[ $key ]['meta_key'], 'post' ) || ! current_user_can( 'edit_post_meta', $post->ID, $metadata[ $key ]['meta_key'] ) ) {
unset( $metadata[ $key ] );
}
}
list_meta( $metadata );
meta_form( $post ); ?>
meta_form( $post );
?>
</div>
<p><?php
<p>
<?php
printf(
/* translators: %s: Codex URL */
__( 'Custom fields can be used to add extra metadata to a post that you can <a href="%s">use in your theme</a>.' ),
__( 'https://codex.wordpress.org/Using_Custom_Fields' )
);
?></p>
?>
</p>
<?php
}
@ -717,13 +756,16 @@ function post_comment_status_meta_box($post) {
?>
<input name="advanced_view" type="hidden" value="1" />
<p class="meta-options">
<label for="comment_status" class="selectit"><input name="comment_status" type="checkbox" id="comment_status" value="open" <?php checked($post->comment_status, 'open'); ?> /> <?php _e( 'Allow comments' ) ?></label><br />
<label for="ping_status" class="selectit"><input name="ping_status" type="checkbox" id="ping_status" value="open" <?php checked($post->ping_status, 'open'); ?> /> <?php
<label for="comment_status" class="selectit"><input name="comment_status" type="checkbox" id="comment_status" value="open" <?php checked( $post->comment_status, 'open' ); ?> /> <?php _e( 'Allow comments' ); ?></label><br />
<label for="ping_status" class="selectit"><input name="ping_status" type="checkbox" id="ping_status" value="open" <?php checked( $post->ping_status, 'open' ); ?> />
<?php
printf(
/* translators: %s: Codex URL */
__( 'Allow <a href="%s">trackbacks and pingbacks</a> on this page' ),
__( 'https://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments' ) );
?></label>
__( 'https://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments' )
);
?>
</label>
<?php
/**
* Fires at the end of the Discussion meta box on the post editing screen.
@ -764,7 +806,13 @@ function post_comment_meta_box( $post ) {
<p class="hide-if-no-js" id="add-new-comment"><a class="button" href="#commentstatusdiv" onclick="window.commentReply && commentReply.addcomment(<?php echo $post->ID; ?>);return false;"><?php _e( 'Add comment' ); ?></a></p>
<?php
$total = get_comments( array( 'post_id' => $post->ID, 'number' => 1, 'count' => true ) );
$total = get_comments(
array(
'post_id' => $post->ID,
'number' => 1,
'count' => true,
)
);
$wp_list_table = _get_list_table( 'WP_Post_Comments_List_Table' );
$wp_list_table->display( true );
@ -797,7 +845,7 @@ function post_slug_meta_box($post) {
/** This filter is documented in wp-admin/edit-tag-form.php */
$editable_slug = apply_filters( 'editable_slug', $post->post_name, $post );
?>
<label class="screen-reader-text" for="post_name"><?php _e('Slug') ?></label><input name="post_name" type="text" size="13" id="post_name" value="<?php echo esc_attr( $editable_slug ); ?>" />
<label class="screen-reader-text" for="post_name"><?php _e( 'Slug' ); ?></label><input name="post_name" type="text" size="13" id="post_name" value="<?php echo esc_attr( $editable_slug ); ?>" />
<?php
}
@ -815,13 +863,15 @@ function post_author_meta_box($post) {
?>
<label class="screen-reader-text" for="post_author_override"><?php _e( 'Author' ); ?></label>
<?php
wp_dropdown_users( array(
wp_dropdown_users(
array(
'who' => 'authors',
'name' => 'post_author_override',
'selected' => empty( $post->ID ) ? $user_ID : $post->post_author,
'include_selected' => true,
'show' => 'display_name_with_login',
) );
)
);
}
/**
@ -879,7 +929,8 @@ function page_attributes_meta_box($post) {
if ( count( get_page_templates( $post ) ) > 0 && get_option( 'page_for_posts' ) != $post->ID ) :
$template = ! empty( $post->page_template ) ? $post->page_template : false;
?>
<p class="post-attributes-label-wrapper"><label class="post-attributes-label" for="page_template"><?php _e( 'Template' ); ?></label><?php
<p class="post-attributes-label-wrapper"><label class="post-attributes-label" for="page_template"><?php _e( 'Template' ); ?></label>
<?php
/**
* Fires immediately after the label inside the 'Template' section
* of the 'Page Attributes' meta box.
@ -890,7 +941,8 @@ function page_attributes_meta_box($post) {
* @param WP_Post $post The current post.
*/
do_action( 'page_attributes_meta_box_template', $template, $post );
?></p>
?>
</p>
<select name="page_template" id="page_template">
<?php
/**
@ -923,7 +975,8 @@ do_action( 'page_attributes_misc_attributes', $post );
?>
<?php if ( 'page' == $post->post_type && get_current_screen()->get_help_tabs() ) : ?>
<p><?php _e( 'Need help? Use the Help tab above the screen title.' ); ?></p>
<?php endif;
<?php
endif;
endif;
}
@ -958,7 +1011,7 @@ function link_submit_meta_box($link) {
<div id="misc-publishing-actions">
<div class="misc-pub-section misc-pub-private">
<label for="link_private" class="selectit"><input id="link_private" name="link_visible" type="checkbox" value="N" <?php checked($link->link_visible, 'N'); ?> /> <?php _e('Keep this link private') ?></label>
<label for="link_private" class="selectit"><input id="link_private" name="link_visible" type="checkbox" value="N" <?php checked( $link->link_visible, 'N' ); ?> /> <?php _e( 'Keep this link private' ); ?></label>
</div>
</div>
@ -971,16 +1024,17 @@ do_action( 'post_submitbox_start', null );
?>
<div id="delete-action">
<?php
if ( !empty($_GET['action']) && 'edit' == $_GET['action'] && current_user_can('manage_links') ) { ?>
if ( ! empty( $_GET['action'] ) && 'edit' == $_GET['action'] && current_user_can( 'manage_links' ) ) {
?>
<a class="submitdelete deletion" href="<?php echo wp_nonce_url( "link.php?action=delete&amp;link_id=$link->link_id", 'delete-bookmark_' . $link->link_id ); ?>" onclick="if ( confirm('<?php echo esc_js( sprintf( __( "You are about to delete this link '%s'\n 'Cancel' to stop, 'OK' to delete." ), $link->link_name ) ); ?>') ) {return true;}return false;"><?php _e( 'Delete' ); ?></a>
<?php } ?>
</div>
<div id="publishing-action">
<?php if ( ! empty( $link->link_id ) ) { ?>
<input name="save" type="submit" class="button button-primary button-large" id="publish" value="<?php esc_attr_e( 'Update Link' ) ?>" />
<input name="save" type="submit" class="button button-primary button-large" id="publish" value="<?php esc_attr_e( 'Update Link' ); ?>" />
<?php } else { ?>
<input name="save" type="submit" class="button button-primary button-large" id="publish" value="<?php esc_attr_e( 'Add Link' ) ?>" />
<input name="save" type="submit" class="button button-primary button-large" id="publish" value="<?php esc_attr_e( 'Add Link' ); ?>" />
<?php } ?>
</div>
<div class="clear"></div>
@ -1016,10 +1070,11 @@ function link_categories_meta_box($link) {
<div id="categories-all" class="tabs-panel">
<ul id="categorychecklist" data-wp-lists="list:category" class="categorychecklist form-no-clear">
<?php
if ( isset($link->link_id) )
if ( isset( $link->link_id ) ) {
wp_link_category_checklist( $link->link_id );
else
} else {
wp_link_category_checklist();
}
?>
</ul>
</div>
@ -1051,8 +1106,10 @@ function link_categories_meta_box($link) {
*
* @param object $link
*/
function link_target_meta_box($link) { ?>
<fieldset><legend class="screen-reader-text"><span><?php _e('Target') ?></span></legend>
function link_target_meta_box( $link ) {
?>
<fieldset><legend class="screen-reader-text"><span><?php _e( 'Target' ); ?></span></legend>
<p><label for="link_target_blank" class="selectit">
<input id="link_target_blank" type="radio" name="link_target" value="_blank" <?php echo ( isset( $link->link_target ) && ( $link->link_target == '_blank' ) ? 'checked="checked"' : '' ); ?> />
<?php _e( '<code>_blank</code> &mdash; new window or tab.' ); ?></label></p>
@ -1093,10 +1150,18 @@ function xfn_check( $class, $value = '', $deprecated = '' ) {
}
if ( '' == $value ) {
if ('family' == $class && strpos($link_rel, 'child') === false && strpos($link_rel, 'parent') === false && strpos($link_rel, 'sibling') === false && strpos($link_rel, 'spouse') === false && strpos($link_rel, 'kin') === false) echo ' checked="checked"';
if ('friendship' == $class && strpos($link_rel, 'friend') === false && strpos($link_rel, 'acquaintance') === false && strpos($link_rel, 'contact') === false) echo ' checked="checked"';
if ('geographical' == $class && strpos($link_rel, 'co-resident') === false && strpos($link_rel, 'neighbor') === false) echo ' checked="checked"';
if ('identity' == $class && in_array('me', $rels) ) echo ' checked="checked"';
if ( 'family' == $class && strpos( $link_rel, 'child' ) === false && strpos( $link_rel, 'parent' ) === false && strpos( $link_rel, 'sibling' ) === false && strpos( $link_rel, 'spouse' ) === false && strpos( $link_rel, 'kin' ) === false ) {
echo ' checked="checked"';
}
if ( 'friendship' == $class && strpos( $link_rel, 'friend' ) === false && strpos( $link_rel, 'acquaintance' ) === false && strpos( $link_rel, 'contact' ) === false ) {
echo ' checked="checked"';
}
if ( 'geographical' == $class && strpos( $link_rel, 'co-resident' ) === false && strpos( $link_rel, 'neighbor' ) === false ) {
echo ' checked="checked"';
}
if ( 'identity' == $class && in_array( 'me', $rels ) ) {
echo ' checked="checked"';
}
}
}
@ -1111,104 +1176,104 @@ function link_xfn_meta_box($link) {
?>
<table class="links-table">
<tr>
<th scope="row"><label for="link_rel"><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('rel:') ?></label></th>
<th scope="row"><label for="link_rel"><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e( 'rel:' ); ?></label></th>
<td><input type="text" name="link_rel" id="link_rel" value="<?php echo ( isset( $link->link_rel ) ? esc_attr( $link->link_rel ) : '' ); ?>" /></td>
</tr>
<tr>
<th scope="row"><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('identity') ?></th>
<td><fieldset><legend class="screen-reader-text"><span><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('identity') ?></span></legend>
<th scope="row"><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e( 'identity' ); ?></th>
<td><fieldset><legend class="screen-reader-text"><span><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e( 'identity' ); ?></span></legend>
<label for="me">
<input type="checkbox" name="identity" value="me" id="me" <?php xfn_check( 'identity', 'me' ); ?> />
<?php _e('another web address of mine') ?></label>
<?php _e( 'another web address of mine' ); ?></label>
</fieldset></td>
</tr>
<tr>
<th scope="row"><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('friendship') ?></th>
<td><fieldset><legend class="screen-reader-text"><span><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('friendship') ?></span></legend>
<th scope="row"><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e( 'friendship' ); ?></th>
<td><fieldset><legend class="screen-reader-text"><span><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e( 'friendship' ); ?></span></legend>
<label for="contact">
<input class="valinp" type="radio" name="friendship" value="contact" id="contact" <?php xfn_check('friendship', 'contact'); ?> />&nbsp;<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('contact') ?>
<input class="valinp" type="radio" name="friendship" value="contact" id="contact" <?php xfn_check( 'friendship', 'contact' ); ?> />&nbsp;<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e( 'contact' ); ?>
</label>
<label for="acquaintance">
<input class="valinp" type="radio" name="friendship" value="acquaintance" id="acquaintance" <?php xfn_check('friendship', 'acquaintance'); ?> />&nbsp;<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('acquaintance') ?>
<input class="valinp" type="radio" name="friendship" value="acquaintance" id="acquaintance" <?php xfn_check( 'friendship', 'acquaintance' ); ?> />&nbsp;<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e( 'acquaintance' ); ?>
</label>
<label for="friend">
<input class="valinp" type="radio" name="friendship" value="friend" id="friend" <?php xfn_check('friendship', 'friend'); ?> />&nbsp;<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('friend') ?>
<input class="valinp" type="radio" name="friendship" value="friend" id="friend" <?php xfn_check( 'friendship', 'friend' ); ?> />&nbsp;<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e( 'friend' ); ?>
</label>
<label for="friendship">
<input name="friendship" type="radio" class="valinp" value="" id="friendship" <?php xfn_check('friendship'); ?> />&nbsp;<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('none') ?>
<input name="friendship" type="radio" class="valinp" value="" id="friendship" <?php xfn_check( 'friendship' ); ?> />&nbsp;<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e( 'none' ); ?>
</label>
</fieldset></td>
</tr>
<tr>
<th scope="row"> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('physical') ?> </th>
<td><fieldset><legend class="screen-reader-text"><span><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('physical') ?></span></legend>
<th scope="row"> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e( 'physical' ); ?> </th>
<td><fieldset><legend class="screen-reader-text"><span><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e( 'physical' ); ?></span></legend>
<label for="met">
<input class="valinp" type="checkbox" name="physical" value="met" id="met" <?php xfn_check('physical', 'met'); ?> />&nbsp;<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('met') ?>
<input class="valinp" type="checkbox" name="physical" value="met" id="met" <?php xfn_check( 'physical', 'met' ); ?> />&nbsp;<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e( 'met' ); ?>
</label>
</fieldset></td>
</tr>
<tr>
<th scope="row"> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('professional') ?> </th>
<td><fieldset><legend class="screen-reader-text"><span><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('professional') ?></span></legend>
<th scope="row"> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e( 'professional' ); ?> </th>
<td><fieldset><legend class="screen-reader-text"><span><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e( 'professional' ); ?></span></legend>
<label for="co-worker">
<input class="valinp" type="checkbox" name="professional" value="co-worker" id="co-worker" <?php xfn_check('professional', 'co-worker'); ?> />&nbsp;<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('co-worker') ?>
<input class="valinp" type="checkbox" name="professional" value="co-worker" id="co-worker" <?php xfn_check( 'professional', 'co-worker' ); ?> />&nbsp;<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e( 'co-worker' ); ?>
</label>
<label for="colleague">
<input class="valinp" type="checkbox" name="professional" value="colleague" id="colleague" <?php xfn_check('professional', 'colleague'); ?> />&nbsp;<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('colleague') ?>
<input class="valinp" type="checkbox" name="professional" value="colleague" id="colleague" <?php xfn_check( 'professional', 'colleague' ); ?> />&nbsp;<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e( 'colleague' ); ?>
</label>
</fieldset></td>
</tr>
<tr>
<th scope="row"><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('geographical') ?></th>
<td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('geographical') ?> </span></legend>
<th scope="row"><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e( 'geographical' ); ?></th>
<td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e( 'geographical' ); ?> </span></legend>
<label for="co-resident">
<input class="valinp" type="radio" name="geographical" value="co-resident" id="co-resident" <?php xfn_check('geographical', 'co-resident'); ?> />&nbsp;<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('co-resident') ?>
<input class="valinp" type="radio" name="geographical" value="co-resident" id="co-resident" <?php xfn_check( 'geographical', 'co-resident' ); ?> />&nbsp;<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e( 'co-resident' ); ?>
</label>
<label for="neighbor">
<input class="valinp" type="radio" name="geographical" value="neighbor" id="neighbor" <?php xfn_check('geographical', 'neighbor'); ?> />&nbsp;<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('neighbor') ?>
<input class="valinp" type="radio" name="geographical" value="neighbor" id="neighbor" <?php xfn_check( 'geographical', 'neighbor' ); ?> />&nbsp;<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e( 'neighbor' ); ?>
</label>
<label for="geographical">
<input class="valinp" type="radio" name="geographical" value="" id="geographical" <?php xfn_check('geographical'); ?> />&nbsp;<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('none') ?>
<input class="valinp" type="radio" name="geographical" value="" id="geographical" <?php xfn_check( 'geographical' ); ?> />&nbsp;<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e( 'none' ); ?>
</label>
</fieldset></td>
</tr>
<tr>
<th scope="row"><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('family') ?></th>
<td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('family') ?> </span></legend>
<th scope="row"><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e( 'family' ); ?></th>
<td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e( 'family' ); ?> </span></legend>
<label for="child">
<input class="valinp" type="radio" name="family" value="child" id="child" <?php xfn_check('family', 'child'); ?> />&nbsp;<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('child') ?>
<input class="valinp" type="radio" name="family" value="child" id="child" <?php xfn_check( 'family', 'child' ); ?> />&nbsp;<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e( 'child' ); ?>
</label>
<label for="kin">
<input class="valinp" type="radio" name="family" value="kin" id="kin" <?php xfn_check('family', 'kin'); ?> />&nbsp;<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('kin') ?>
<input class="valinp" type="radio" name="family" value="kin" id="kin" <?php xfn_check( 'family', 'kin' ); ?> />&nbsp;<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e( 'kin' ); ?>
</label>
<label for="parent">
<input class="valinp" type="radio" name="family" value="parent" id="parent" <?php xfn_check('family', 'parent'); ?> />&nbsp;<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('parent') ?>
<input class="valinp" type="radio" name="family" value="parent" id="parent" <?php xfn_check( 'family', 'parent' ); ?> />&nbsp;<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e( 'parent' ); ?>
</label>
<label for="sibling">
<input class="valinp" type="radio" name="family" value="sibling" id="sibling" <?php xfn_check('family', 'sibling'); ?> />&nbsp;<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('sibling') ?>
<input class="valinp" type="radio" name="family" value="sibling" id="sibling" <?php xfn_check( 'family', 'sibling' ); ?> />&nbsp;<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e( 'sibling' ); ?>
</label>
<label for="spouse">
<input class="valinp" type="radio" name="family" value="spouse" id="spouse" <?php xfn_check('family', 'spouse'); ?> />&nbsp;<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('spouse') ?>
<input class="valinp" type="radio" name="family" value="spouse" id="spouse" <?php xfn_check( 'family', 'spouse' ); ?> />&nbsp;<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e( 'spouse' ); ?>
</label>
<label for="family">
<input class="valinp" type="radio" name="family" value="" id="family" <?php xfn_check('family'); ?> />&nbsp;<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('none') ?>
<input class="valinp" type="radio" name="family" value="" id="family" <?php xfn_check( 'family' ); ?> />&nbsp;<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e( 'none' ); ?>
</label>
</fieldset></td>
</tr>
<tr>
<th scope="row"><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('romantic') ?></th>
<td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('romantic') ?> </span></legend>
<th scope="row"><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e( 'romantic' ); ?></th>
<td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e( 'romantic' ); ?> </span></legend>
<label for="muse">
<input class="valinp" type="checkbox" name="romantic" value="muse" id="muse" <?php xfn_check('romantic', 'muse'); ?> />&nbsp;<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('muse') ?>
<input class="valinp" type="checkbox" name="romantic" value="muse" id="muse" <?php xfn_check( 'romantic', 'muse' ); ?> />&nbsp;<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e( 'muse' ); ?>
</label>
<label for="crush">
<input class="valinp" type="checkbox" name="romantic" value="crush" id="crush" <?php xfn_check('romantic', 'crush'); ?> />&nbsp;<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('crush') ?>
<input class="valinp" type="checkbox" name="romantic" value="crush" id="crush" <?php xfn_check( 'romantic', 'crush' ); ?> />&nbsp;<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e( 'crush' ); ?>
</label>
<label for="date">
<input class="valinp" type="checkbox" name="romantic" value="date" id="date" <?php xfn_check('romantic', 'date'); ?> />&nbsp;<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('date') ?>
<input class="valinp" type="checkbox" name="romantic" value="date" id="date" <?php xfn_check( 'romantic', 'date' ); ?> />&nbsp;<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e( 'date' ); ?>
</label>
<label for="romantic">
<input class="valinp" type="checkbox" name="romantic" value="sweetheart" id="romantic" <?php xfn_check('romantic', 'sweetheart'); ?> />&nbsp;<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('sweetheart') ?>
<input class="valinp" type="checkbox" name="romantic" value="sweetheart" id="romantic" <?php xfn_check( 'romantic', 'sweetheart' ); ?> />&nbsp;<?php /* translators: xfn: http://gmpg.org/xfn/ */ _e( 'sweetheart' ); ?>
</label>
</fieldset></td>
</tr>
@ -1229,28 +1294,30 @@ function link_advanced_meta_box($link) {
?>
<table class="links-table" cellpadding="0">
<tr>
<th scope="row"><label for="link_image"><?php _e('Image Address') ?></label></th>
<th scope="row"><label for="link_image"><?php _e( 'Image Address' ); ?></label></th>
<td><input type="text" name="link_image" class="code" id="link_image" maxlength="255" value="<?php echo ( isset( $link->link_image ) ? esc_attr( $link->link_image ) : '' ); ?>" /></td>
</tr>
<tr>
<th scope="row"><label for="rss_uri"><?php _e('RSS Address') ?></label></th>
<th scope="row"><label for="rss_uri"><?php _e( 'RSS Address' ); ?></label></th>
<td><input name="link_rss" class="code" type="text" id="rss_uri" maxlength="255" value="<?php echo ( isset( $link->link_rss ) ? esc_attr( $link->link_rss ) : '' ); ?>" /></td>
</tr>
<tr>
<th scope="row"><label for="link_notes"><?php _e('Notes') ?></label></th>
<th scope="row"><label for="link_notes"><?php _e( 'Notes' ); ?></label></th>
<td><textarea name="link_notes" id="link_notes" rows="10"><?php echo ( isset( $link->link_notes ) ? $link->link_notes : '' ); // textarea_escaped ?></textarea></td>
</tr>
<tr>
<th scope="row"><label for="link_rating"><?php _e('Rating') ?></label></th>
<th scope="row"><label for="link_rating"><?php _e( 'Rating' ); ?></label></th>
<td><select name="link_rating" id="link_rating" size="1">
<?php
for ( $r = 0; $r <= 10; $r++ ) {
echo '<option value="' . $r . '"';
if ( isset($link->link_rating) && $link->link_rating == $r )
if ( isset( $link->link_rating ) && $link->link_rating == $r ) {
echo ' selected="selected"';
}
echo( '>' . $r . '</option>' );
}
?></select>&nbsp;<?php _e('(Leave at 0 for no rating.)') ?>
?>
</select>&nbsp;<?php _e( '(Leave at 0 for no rating.)' ); ?>
</td>
</tr>
</table>
@ -1282,14 +1349,17 @@ function attachment_id3_data_meta_box( $post ) {
$meta = wp_get_attachment_metadata( $post->ID );
}
foreach ( wp_get_attachment_id3_keys( $post, 'edit' ) as $key => $label ) : ?>
foreach ( wp_get_attachment_id3_keys( $post, 'edit' ) as $key => $label ) :
?>
<p>
<label for="title"><?php echo $label ?></label><br />
<input type="text" name="id3_<?php echo esc_attr( $key ) ?>" id="id3_<?php echo esc_attr( $key ) ?>" class="large-text" value="<?php
<label for="title"><?php echo $label; ?></label><br />
<input type="text" name="id3_<?php echo esc_attr( $key ); ?>" id="id3_<?php echo esc_attr( $key ); ?>" class="large-text" value="
<?php
if ( ! empty( $meta[ $key ] ) ) {
echo esc_attr( $meta[ $key ] );
}
?>" />
?>
" />
</p>
<?php
endforeach;

View File

@ -164,13 +164,15 @@ function insert_with_markers( $filename, $marker, $insertion ) {
}
// Generate the new file data
$new_file_data = implode( "\n", array_merge(
$new_file_data = implode(
"\n", array_merge(
$pre_lines,
array( $start_marker ),
$insertion,
array( $end_marker ),
$post_lines
) );
)
);
// Write to the start of the file, and truncate it to that length
fseek( $fp, 0 );
@ -196,8 +198,9 @@ function insert_with_markers( $filename, $marker, $insertion ) {
* @global WP_Rewrite $wp_rewrite
*/
function save_mod_rewrite_rules() {
if ( is_multisite() )
if ( is_multisite() ) {
return;
}
global $wp_rewrite;
@ -229,8 +232,9 @@ function save_mod_rewrite_rules() {
* @return bool True if web.config was updated successfully
*/
function iis7_save_url_rewrite_rules() {
if ( is_multisite() )
if ( is_multisite() ) {
return;
}
global $wp_rewrite;
@ -263,8 +267,9 @@ function update_recently_edited( $file ) {
$oldfiles[] = $file;
$oldfiles = array_reverse( $oldfiles );
$oldfiles = array_unique( $oldfiles );
if ( 5 < count( $oldfiles ))
if ( 5 < count( $oldfiles ) ) {
array_pop( $oldfiles );
}
} else {
$oldfiles[] = $file;
}
@ -452,8 +457,9 @@ function wp_print_plugin_file_tree( $tree, $label = '', $level = 2, $size = 1, $
* @param string $value
*/
function update_home_siteurl( $old_value, $value ) {
if ( wp_installing() )
if ( wp_installing() ) {
return;
}
if ( is_multisite() && ms_is_switched() ) {
delete_option( 'rewrite_rules' );
@ -497,11 +503,12 @@ function wp_reset_vars( $vars ) {
*/
function show_message( $message ) {
if ( is_wp_error( $message ) ) {
if ( $message->get_error_data() && is_string( $message->get_error_data() ) )
if ( $message->get_error_data() && is_string( $message->get_error_data() ) ) {
$message = $message->get_error_message() . ': ' . $message->get_error_data();
else
} else {
$message = $message->get_error_message();
}
}
echo "<p>$message</p>\n";
wp_ob_end_flush_all();
flush();
@ -514,11 +521,13 @@ function show_message($message) {
* @return array
*/
function wp_doc_link_parse( $content ) {
if ( !is_string( $content ) || empty( $content ) )
if ( ! is_string( $content ) || empty( $content ) ) {
return array();
}
if ( !function_exists('token_get_all') )
if ( ! function_exists( 'token_get_all' ) ) {
return array();
}
$tokens = token_get_all( $content );
$count = count( $tokens );
@ -555,8 +564,9 @@ function wp_doc_link_parse( $content ) {
$out = array();
foreach ( $functions as $function ) {
if ( in_array( $function, $ignore_functions ) )
if ( in_array( $function, $ignore_functions ) ) {
continue;
}
$out[] = $function;
}
@ -573,23 +583,26 @@ function set_screen_options() {
if ( isset( $_POST['wp_screen_options'] ) && is_array( $_POST['wp_screen_options'] ) ) {
check_admin_referer( 'screen-options-nonce', 'screenoptionnonce' );
if ( !$user = wp_get_current_user() )
if ( ! $user = wp_get_current_user() ) {
return;
}
$option = $_POST['wp_screen_options']['option'];
$value = $_POST['wp_screen_options']['value'];
if ( $option != sanitize_key( $option ) )
if ( $option != sanitize_key( $option ) ) {
return;
}
$map_option = $option;
$type = str_replace( 'edit_', '', $map_option );
$type = str_replace( '_per_page', '', $type );
if ( in_array( $type, get_taxonomies() ) )
if ( in_array( $type, get_taxonomies() ) ) {
$map_option = 'edit_tags_per_page';
elseif ( in_array( $type, get_post_types() ) )
} elseif ( in_array( $type, get_post_types() ) ) {
$map_option = 'edit_per_page';
else
} else {
$option = str_replace( '-', '_', $option );
}
switch ( $map_option ) {
case 'edit_per_page':
@ -606,11 +619,11 @@ function set_screen_options() {
case 'themes_network_per_page':
case 'site_themes_network_per_page':
$value = (int) $value;
if ( $value < 1 || $value > 999 )
if ( $value < 1 || $value > 999 ) {
return;
}
break;
default:
/**
* Filters a screen option value before it is set.
*
@ -629,8 +642,9 @@ function set_screen_options() {
*/
$value = apply_filters( 'set-screen-option', false, $option, $value );
if ( false === $value )
if ( false === $value ) {
return;
}
break;
}
@ -655,22 +669,25 @@ function set_screen_options() {
* @param string $filename The file path to the configuration file
*/
function iis7_rewrite_rule_exists( $filename ) {
if ( ! file_exists($filename) )
if ( ! file_exists( $filename ) ) {
return false;
}
if ( ! class_exists( 'DOMDocument', false ) ) {
return false;
}
$doc = new DOMDocument();
if ( $doc->load($filename) === false )
if ( $doc->load( $filename ) === false ) {
return false;
}
$xpath = new DOMXPath( $doc );
$rules = $xpath->query( '/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]' );
if ( $rules->length == 0 )
if ( $rules->length == 0 ) {
return false;
else
} else {
return true;
}
}
/**
* Delete WordPress rewrite rule from web.config file if it exists there
@ -682,8 +699,9 @@ function iis7_rewrite_rule_exists($filename) {
*/
function iis7_delete_rewrite_rule( $filename ) {
// If configuration file does not exist then rules also do not exist so there is nothing to delete
if ( ! file_exists($filename) )
if ( ! file_exists( $filename ) ) {
return true;
}
if ( ! class_exists( 'DOMDocument', false ) ) {
return false;
@ -692,8 +710,9 @@ function iis7_delete_rewrite_rule($filename) {
$doc = new DOMDocument();
$doc->preserveWhiteSpace = false;
if ( $doc -> load($filename) === false )
if ( $doc->load( $filename ) === false ) {
return false;
}
$xpath = new DOMXPath( $doc );
$rules = $xpath->query( '/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]' );
if ( $rules->length > 0 ) {
@ -730,15 +749,17 @@ function iis7_add_rewrite_rule($filename, $rewrite_rule) {
$doc = new DOMDocument();
$doc->preserveWhiteSpace = false;
if ( $doc->load($filename) === false )
if ( $doc->load( $filename ) === false ) {
return false;
}
$xpath = new DOMXPath( $doc );
// First check if the rule already exists as in that case there is no need to re-add it
$wordpress_rules = $xpath->query( '/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]' );
if ( $wordpress_rules->length > 0 )
if ( $wordpress_rules->length > 0 ) {
return true;
}
// Check the XPath to the rewrite rule and create XML nodes if they do not exist
$xmlnodes = $xpath->query( '/configuration/system.webServer/rewrite/rules' );
@ -780,7 +801,7 @@ function iis7_add_rewrite_rule($filename, $rewrite_rule) {
$rule_fragment->appendXML( $rewrite_rule );
$rules_node->appendChild( $rule_fragment );
$doc->encoding = "UTF-8";
$doc->encoding = 'UTF-8';
$doc->formatOutput = true;
saveDomDocument( $doc, $filename );
@ -819,7 +840,14 @@ function admin_color_scheme_picker( $user_id ) {
if ( isset( $_wp_admin_css_colors['fresh'] ) ) {
// Set Default ('fresh') and Light should go first.
$_wp_admin_css_colors = array_filter( array_merge( array( 'fresh' => '', 'light' => '' ), $_wp_admin_css_colors ) );
$_wp_admin_css_colors = array_filter(
array_merge(
array(
'fresh' => '',
'light' => '',
), $_wp_admin_css_colors
)
);
}
$current_color = get_user_option( 'admin_color', $user_id );
@ -865,7 +893,6 @@ function admin_color_scheme_picker( $user_id ) {
}
/**
*
* @global array $_wp_admin_css_colors
*/
function wp_color_scheme_settings() {
@ -884,7 +911,11 @@ function wp_color_scheme_settings() {
$icon_colors = $_wp_admin_css_colors['fresh']->icon_colors;
} else {
// Fall back to the default set of icon colors if the default scheme is missing.
$icon_colors = array( 'base' => '#82878c', 'focus' => '#00a0d2', 'current' => '#fff' );
$icon_colors = array(
'base' => '#82878c',
'focus' => '#00a0d2',
'current' => '#fff',
);
}
echo '<script type="text/javascript">var _wpColorScheme = ' . wp_json_encode( array( 'icons' => $icon_colors ) ) . ";</script>\n";
@ -916,22 +947,25 @@ function wp_check_locked_posts( $response, $data, $screen_id ) {
if ( array_key_exists( 'wp-check-locked-posts', $data ) && is_array( $data['wp-check-locked-posts'] ) ) {
foreach ( $data['wp-check-locked-posts'] as $key ) {
if ( ! $post_id = absint( substr( $key, 5 ) ) )
if ( ! $post_id = absint( substr( $key, 5 ) ) ) {
continue;
}
if ( ( $user_id = wp_check_post_lock( $post_id ) ) && ( $user = get_userdata( $user_id ) ) && current_user_can( 'edit_post', $post_id ) ) {
$send = array( 'text' => sprintf( __( '%s is currently editing' ), $user->display_name ) );
if ( ( $avatar = get_avatar( $user->ID, 18 ) ) && preg_match( "|src='([^']+)'|", $avatar, $matches ) )
if ( ( $avatar = get_avatar( $user->ID, 18 ) ) && preg_match( "|src='([^']+)'|", $avatar, $matches ) ) {
$send['avatar_src'] = $matches[1];
}
$checked[ $key ] = $send;
}
}
}
if ( ! empty( $checked ) )
if ( ! empty( $checked ) ) {
$response['wp-check-locked-posts'] = $checked;
}
return $response;
}
@ -951,27 +985,31 @@ function wp_refresh_post_lock( $response, $data, $screen_id ) {
$received = $data['wp-refresh-post-lock'];
$send = array();
if ( ! $post_id = absint( $received['post_id'] ) )
if ( ! $post_id = absint( $received['post_id'] ) ) {
return $response;
}
if ( ! current_user_can('edit_post', $post_id) )
if ( ! current_user_can( 'edit_post', $post_id ) ) {
return $response;
}
if ( ( $user_id = wp_check_post_lock( $post_id ) ) && ( $user = get_userdata( $user_id ) ) ) {
$error = array(
'text' => sprintf( __( '%s has taken over and is currently editing.' ), $user->display_name )
'text' => sprintf( __( '%s has taken over and is currently editing.' ), $user->display_name ),
);
if ( $avatar = get_avatar( $user->ID, 64 ) ) {
if ( preg_match( "|src='([^']+)'|", $avatar, $matches ) )
if ( preg_match( "|src='([^']+)'|", $avatar, $matches ) ) {
$error['avatar_src'] = $matches[1];
}
}
$send['lock_error'] = $error;
} else {
if ( $new_lock = wp_set_post_lock( $post_id ) )
if ( $new_lock = wp_set_post_lock( $post_id ) ) {
$send['new_lock'] = implode( ':', $new_lock );
}
}
$response['wp-refresh-post-lock'] = $send;
}
@ -1051,14 +1089,23 @@ function heartbeat_autosave( $response, $data ) {
$saved = wp_autosave( $data['wp_autosave'] );
if ( is_wp_error( $saved ) ) {
$response['wp_autosave'] = array( 'success' => false, 'message' => $saved->get_error_message() );
$response['wp_autosave'] = array(
'success' => false,
'message' => $saved->get_error_message(),
);
} elseif ( empty( $saved ) ) {
$response['wp_autosave'] = array( 'success' => false, 'message' => __( 'Error while saving.' ) );
$response['wp_autosave'] = array(
'success' => false,
'message' => __( 'Error while saving.' ),
);
} else {
/* translators: draft saved date format, see https://secure.php.net/date */
$draft_saved_date_format = __( 'g:i:s a' );
/* translators: %s: date and time */
$response['wp_autosave'] = array( 'success' => true, 'message' => sprintf( __( 'Draft saved at %s.' ), date_i18n( $draft_saved_date_format ) ) );
$response['wp_autosave'] = array(
'success' => true,
'message' => sprintf( __( 'Draft saved at %s.' ), date_i18n( $draft_saved_date_format ) ),
);
}
}
@ -1158,7 +1205,8 @@ function update_option_new_admin_email( $old_value, $value ) {
$switched_locale = switch_to_locale( get_user_locale() );
/* translators: Do not translate USERNAME, ADMIN_URL, EMAIL, SITENAME, SITEURL: those are placeholders. */
$email_text = __( 'Howdy ###USERNAME###,
$email_text = __(
'Howdy ###USERNAME###,
You recently requested to have the administration email address on
your site changed.
@ -1173,7 +1221,8 @@ This email has been sent to ###EMAIL###
Regards,
All at ###SITENAME###
###SITEURL###' );
###SITEURL###'
);
/**
* Filters the text of the email sent when a change of site admin email address is attempted.

View File

@ -16,14 +16,17 @@
* @return array $_FILES array with 'error' key set if file exceeds quota. 'error' is empty otherwise.
*/
function check_upload_size( $file ) {
if ( get_site_option( 'upload_space_check_disabled' ) )
if ( get_site_option( 'upload_space_check_disabled' ) ) {
return $file;
}
if ( $file['error'] != '0' ) // there's already an error
if ( $file['error'] != '0' ) { // there's already an error
return $file;
}
if ( defined( 'WP_IMPORTING' ) )
if ( defined( 'WP_IMPORTING' ) ) {
return $file;
}
$space_left = get_upload_space_available();
@ -79,7 +82,12 @@ function wpmu_delete_blog( $blog_id, $drop = false ) {
*/
do_action( 'delete_blog', $blog_id, $drop );
$users = get_users( array( 'blog_id' => $blog_id, 'fields' => 'ids' ) );
$users = get_users(
array(
'blog_id' => $blog_id,
'fields' => 'ids',
)
);
// Remove users from this blog.
if ( ! empty( $users ) ) {
@ -150,8 +158,9 @@ function wpmu_delete_blog( $blog_id, $drop = false ) {
$dh = @opendir( $dir );
if ( $dh ) {
while ( ( $file = @readdir( $dh ) ) !== false ) {
if ( $file == '.' || $file == '..' )
if ( $file == '.' || $file == '..' ) {
continue;
}
if ( @is_dir( $dir . DIRECTORY_SEPARATOR . $file ) ) {
$stack[] = $dir . DIRECTORY_SEPARATOR . $file;
@ -166,9 +175,10 @@ function wpmu_delete_blog( $blog_id, $drop = false ) {
$stack = array_reverse( $stack ); // Last added dirs are deepest
foreach ( (array) $stack as $dir ) {
if ( $dir != $top_dir)
if ( $dir != $top_dir ) {
@rmdir( $dir );
}
}
clean_blog_cache( $blog );
}
@ -183,9 +193,10 @@ function wpmu_delete_blog( $blog_id, $drop = false ) {
*/
do_action( 'deleted_blog', $blog_id, $drop );
if ( $switch )
if ( $switch ) {
restore_current_blog();
}
}
/**
* Delete a user from the network and remove from all sites.
@ -209,8 +220,9 @@ function wpmu_delete_user( $id ) {
$id = (int) $id;
$user = new WP_User( $id );
if ( !$user->exists() )
if ( ! $user->exists() ) {
return false;
}
// Global super-administrators are protected, and cannot be deleted.
$_super_admins = get_super_admins();
@ -243,17 +255,19 @@ function wpmu_delete_user( $id ) {
$link_ids = $wpdb->get_col( $wpdb->prepare( "SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id ) );
if ( $link_ids ) {
foreach ( $link_ids as $link_id )
foreach ( $link_ids as $link_id ) {
wp_delete_link( $link_id );
}
}
restore_current_blog();
}
}
$meta = $wpdb->get_col( $wpdb->prepare( "SELECT umeta_id FROM $wpdb->usermeta WHERE user_id = %d", $id ) );
foreach ( $meta as $mid )
foreach ( $meta as $mid ) {
delete_metadata_by_mid( 'user', $mid );
}
$wpdb->delete( $wpdb->users, array( 'ID' => $id ) );
@ -274,8 +288,9 @@ function wpmu_delete_user( $id ) {
* @return bool True if user is over upload space quota, otherwise false.
*/
function upload_is_user_over_quota( $echo = true ) {
if ( get_site_option( 'upload_space_check_disabled' ) )
if ( get_site_option( 'upload_space_check_disabled' ) ) {
return false;
}
$space_allowed = get_space_allowed();
if ( ! is_numeric( $space_allowed ) ) {
@ -284,8 +299,9 @@ function upload_is_user_over_quota( $echo = true ) {
$space_used = get_space_used();
if ( ( $space_allowed - $space_used ) < 0 ) {
if ( $echo )
if ( $echo ) {
_e( 'Sorry, you have used your space allocation. Please delete some files to upload more files.' );
}
return true;
} else {
return false;
@ -313,10 +329,12 @@ function display_space_usage() {
$space .= __( 'MB' );
}
?>
<strong><?php
<strong>
<?php
/* translators: Storage space that's been used. 1: Percentage of used space, 2: Total space allowed in megabytes or gigabytes */
printf( __( 'Used: %1$s%% of %2$s' ), number_format( $percent_used ), $space );
?></strong>
?>
</strong>
<?php
}
@ -348,8 +366,9 @@ function upload_space_setting( $id ) {
$quota = get_option( 'blog_upload_space' );
restore_current_blog();
if ( !$quota )
if ( ! $quota ) {
$quota = '';
}
?>
<tr>
@ -381,8 +400,9 @@ function upload_space_setting( $id ) {
function update_user_status( $id, $pref, $value, $deprecated = null ) {
global $wpdb;
if ( null !== $deprecated )
if ( null !== $deprecated ) {
_deprecated_argument( __FUNCTION__, '3.0.2' );
}
$wpdb->update( $wpdb->users, array( sanitize_key( $pref ) => $value ), array( 'ID' => $id ) );
@ -425,8 +445,9 @@ function update_user_status( $id, $pref, $value, $deprecated = null ) {
function refresh_user_details( $id ) {
$id = (int) $id;
if ( !$user = get_userdata( $id ) )
if ( ! $user = get_userdata( $id ) ) {
return false;
}
clean_user_cache( $user );
@ -445,17 +466,192 @@ function refresh_user_details( $id ) {
function format_code_lang( $code = '' ) {
$code = strtolower( substr( $code, 0, 2 ) );
$lang_codes = array(
'aa' => 'Afar', 'ab' => 'Abkhazian', 'af' => 'Afrikaans', 'ak' => 'Akan', 'sq' => 'Albanian', 'am' => 'Amharic', 'ar' => 'Arabic', 'an' => 'Aragonese', 'hy' => 'Armenian', 'as' => 'Assamese', 'av' => 'Avaric', 'ae' => 'Avestan', 'ay' => 'Aymara', 'az' => 'Azerbaijani', 'ba' => 'Bashkir', 'bm' => 'Bambara', 'eu' => 'Basque', 'be' => 'Belarusian', 'bn' => 'Bengali',
'bh' => 'Bihari', 'bi' => 'Bislama', 'bs' => 'Bosnian', 'br' => 'Breton', 'bg' => 'Bulgarian', 'my' => 'Burmese', 'ca' => 'Catalan; Valencian', 'ch' => 'Chamorro', 'ce' => 'Chechen', 'zh' => 'Chinese', 'cu' => 'Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian; Old Church Slavonic', 'cv' => 'Chuvash', 'kw' => 'Cornish', 'co' => 'Corsican', 'cr' => 'Cree',
'cs' => 'Czech', 'da' => 'Danish', 'dv' => 'Divehi; Dhivehi; Maldivian', 'nl' => 'Dutch; Flemish', 'dz' => 'Dzongkha', 'en' => 'English', 'eo' => 'Esperanto', 'et' => 'Estonian', 'ee' => 'Ewe', 'fo' => 'Faroese', 'fj' => 'Fijjian', 'fi' => 'Finnish', 'fr' => 'French', 'fy' => 'Western Frisian', 'ff' => 'Fulah', 'ka' => 'Georgian', 'de' => 'German', 'gd' => 'Gaelic; Scottish Gaelic',
'ga' => 'Irish', 'gl' => 'Galician', 'gv' => 'Manx', 'el' => 'Greek, Modern', 'gn' => 'Guarani', 'gu' => 'Gujarati', 'ht' => 'Haitian; Haitian Creole', 'ha' => 'Hausa', 'he' => 'Hebrew', 'hz' => 'Herero', 'hi' => 'Hindi', 'ho' => 'Hiri Motu', 'hu' => 'Hungarian', 'ig' => 'Igbo', 'is' => 'Icelandic', 'io' => 'Ido', 'ii' => 'Sichuan Yi', 'iu' => 'Inuktitut', 'ie' => 'Interlingue',
'ia' => 'Interlingua (International Auxiliary Language Association)', 'id' => 'Indonesian', 'ik' => 'Inupiaq', 'it' => 'Italian', 'jv' => 'Javanese', 'ja' => 'Japanese', 'kl' => 'Kalaallisut; Greenlandic', 'kn' => 'Kannada', 'ks' => 'Kashmiri', 'kr' => 'Kanuri', 'kk' => 'Kazakh', 'km' => 'Central Khmer', 'ki' => 'Kikuyu; Gikuyu', 'rw' => 'Kinyarwanda', 'ky' => 'Kirghiz; Kyrgyz',
'kv' => 'Komi', 'kg' => 'Kongo', 'ko' => 'Korean', 'kj' => 'Kuanyama; Kwanyama', 'ku' => 'Kurdish', 'lo' => 'Lao', 'la' => 'Latin', 'lv' => 'Latvian', 'li' => 'Limburgan; Limburger; Limburgish', 'ln' => 'Lingala', 'lt' => 'Lithuanian', 'lb' => 'Luxembourgish; Letzeburgesch', 'lu' => 'Luba-Katanga', 'lg' => 'Ganda', 'mk' => 'Macedonian', 'mh' => 'Marshallese', 'ml' => 'Malayalam',
'mi' => 'Maori', 'mr' => 'Marathi', 'ms' => 'Malay', 'mg' => 'Malagasy', 'mt' => 'Maltese', 'mo' => 'Moldavian', 'mn' => 'Mongolian', 'na' => 'Nauru', 'nv' => 'Navajo; Navaho', 'nr' => 'Ndebele, South; South Ndebele', 'nd' => 'Ndebele, North; North Ndebele', 'ng' => 'Ndonga', 'ne' => 'Nepali', 'nn' => 'Norwegian Nynorsk; Nynorsk, Norwegian', 'nb' => 'Bokmål, Norwegian, Norwegian Bokmål',
'no' => 'Norwegian', 'ny' => 'Chichewa; Chewa; Nyanja', 'oc' => 'Occitan, Provençal', 'oj' => 'Ojibwa', 'or' => 'Oriya', 'om' => 'Oromo', 'os' => 'Ossetian; Ossetic', 'pa' => 'Panjabi; Punjabi', 'fa' => 'Persian', 'pi' => 'Pali', 'pl' => 'Polish', 'pt' => 'Portuguese', 'ps' => 'Pushto', 'qu' => 'Quechua', 'rm' => 'Romansh', 'ro' => 'Romanian', 'rn' => 'Rundi', 'ru' => 'Russian',
'sg' => 'Sango', 'sa' => 'Sanskrit', 'sr' => 'Serbian', 'hr' => 'Croatian', 'si' => 'Sinhala; Sinhalese', 'sk' => 'Slovak', 'sl' => 'Slovenian', 'se' => 'Northern Sami', 'sm' => 'Samoan', 'sn' => 'Shona', 'sd' => 'Sindhi', 'so' => 'Somali', 'st' => 'Sotho, Southern', 'es' => 'Spanish; Castilian', 'sc' => 'Sardinian', 'ss' => 'Swati', 'su' => 'Sundanese', 'sw' => 'Swahili',
'sv' => 'Swedish', 'ty' => 'Tahitian', 'ta' => 'Tamil', 'tt' => 'Tatar', 'te' => 'Telugu', 'tg' => 'Tajik', 'tl' => 'Tagalog', 'th' => 'Thai', 'bo' => 'Tibetan', 'ti' => 'Tigrinya', 'to' => 'Tonga (Tonga Islands)', 'tn' => 'Tswana', 'ts' => 'Tsonga', 'tk' => 'Turkmen', 'tr' => 'Turkish', 'tw' => 'Twi', 'ug' => 'Uighur; Uyghur', 'uk' => 'Ukrainian', 'ur' => 'Urdu', 'uz' => 'Uzbek',
've' => 'Venda', 'vi' => 'Vietnamese', 'vo' => 'Volapük', 'cy' => 'Welsh','wa' => 'Walloon','wo' => 'Wolof', 'xh' => 'Xhosa', 'yi' => 'Yiddish', 'yo' => 'Yoruba', 'za' => 'Zhuang; Chuang', 'zu' => 'Zulu' );
'aa' => 'Afar',
'ab' => 'Abkhazian',
'af' => 'Afrikaans',
'ak' => 'Akan',
'sq' => 'Albanian',
'am' => 'Amharic',
'ar' => 'Arabic',
'an' => 'Aragonese',
'hy' => 'Armenian',
'as' => 'Assamese',
'av' => 'Avaric',
'ae' => 'Avestan',
'ay' => 'Aymara',
'az' => 'Azerbaijani',
'ba' => 'Bashkir',
'bm' => 'Bambara',
'eu' => 'Basque',
'be' => 'Belarusian',
'bn' => 'Bengali',
'bh' => 'Bihari',
'bi' => 'Bislama',
'bs' => 'Bosnian',
'br' => 'Breton',
'bg' => 'Bulgarian',
'my' => 'Burmese',
'ca' => 'Catalan; Valencian',
'ch' => 'Chamorro',
'ce' => 'Chechen',
'zh' => 'Chinese',
'cu' => 'Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian; Old Church Slavonic',
'cv' => 'Chuvash',
'kw' => 'Cornish',
'co' => 'Corsican',
'cr' => 'Cree',
'cs' => 'Czech',
'da' => 'Danish',
'dv' => 'Divehi; Dhivehi; Maldivian',
'nl' => 'Dutch; Flemish',
'dz' => 'Dzongkha',
'en' => 'English',
'eo' => 'Esperanto',
'et' => 'Estonian',
'ee' => 'Ewe',
'fo' => 'Faroese',
'fj' => 'Fijjian',
'fi' => 'Finnish',
'fr' => 'French',
'fy' => 'Western Frisian',
'ff' => 'Fulah',
'ka' => 'Georgian',
'de' => 'German',
'gd' => 'Gaelic; Scottish Gaelic',
'ga' => 'Irish',
'gl' => 'Galician',
'gv' => 'Manx',
'el' => 'Greek, Modern',
'gn' => 'Guarani',
'gu' => 'Gujarati',
'ht' => 'Haitian; Haitian Creole',
'ha' => 'Hausa',
'he' => 'Hebrew',
'hz' => 'Herero',
'hi' => 'Hindi',
'ho' => 'Hiri Motu',
'hu' => 'Hungarian',
'ig' => 'Igbo',
'is' => 'Icelandic',
'io' => 'Ido',
'ii' => 'Sichuan Yi',
'iu' => 'Inuktitut',
'ie' => 'Interlingue',
'ia' => 'Interlingua (International Auxiliary Language Association)',
'id' => 'Indonesian',
'ik' => 'Inupiaq',
'it' => 'Italian',
'jv' => 'Javanese',
'ja' => 'Japanese',
'kl' => 'Kalaallisut; Greenlandic',
'kn' => 'Kannada',
'ks' => 'Kashmiri',
'kr' => 'Kanuri',
'kk' => 'Kazakh',
'km' => 'Central Khmer',
'ki' => 'Kikuyu; Gikuyu',
'rw' => 'Kinyarwanda',
'ky' => 'Kirghiz; Kyrgyz',
'kv' => 'Komi',
'kg' => 'Kongo',
'ko' => 'Korean',
'kj' => 'Kuanyama; Kwanyama',
'ku' => 'Kurdish',
'lo' => 'Lao',
'la' => 'Latin',
'lv' => 'Latvian',
'li' => 'Limburgan; Limburger; Limburgish',
'ln' => 'Lingala',
'lt' => 'Lithuanian',
'lb' => 'Luxembourgish; Letzeburgesch',
'lu' => 'Luba-Katanga',
'lg' => 'Ganda',
'mk' => 'Macedonian',
'mh' => 'Marshallese',
'ml' => 'Malayalam',
'mi' => 'Maori',
'mr' => 'Marathi',
'ms' => 'Malay',
'mg' => 'Malagasy',
'mt' => 'Maltese',
'mo' => 'Moldavian',
'mn' => 'Mongolian',
'na' => 'Nauru',
'nv' => 'Navajo; Navaho',
'nr' => 'Ndebele, South; South Ndebele',
'nd' => 'Ndebele, North; North Ndebele',
'ng' => 'Ndonga',
'ne' => 'Nepali',
'nn' => 'Norwegian Nynorsk; Nynorsk, Norwegian',
'nb' => 'Bokmål, Norwegian, Norwegian Bokmål',
'no' => 'Norwegian',
'ny' => 'Chichewa; Chewa; Nyanja',
'oc' => 'Occitan, Provençal',
'oj' => 'Ojibwa',
'or' => 'Oriya',
'om' => 'Oromo',
'os' => 'Ossetian; Ossetic',
'pa' => 'Panjabi; Punjabi',
'fa' => 'Persian',
'pi' => 'Pali',
'pl' => 'Polish',
'pt' => 'Portuguese',
'ps' => 'Pushto',
'qu' => 'Quechua',
'rm' => 'Romansh',
'ro' => 'Romanian',
'rn' => 'Rundi',
'ru' => 'Russian',
'sg' => 'Sango',
'sa' => 'Sanskrit',
'sr' => 'Serbian',
'hr' => 'Croatian',
'si' => 'Sinhala; Sinhalese',
'sk' => 'Slovak',
'sl' => 'Slovenian',
'se' => 'Northern Sami',
'sm' => 'Samoan',
'sn' => 'Shona',
'sd' => 'Sindhi',
'so' => 'Somali',
'st' => 'Sotho, Southern',
'es' => 'Spanish; Castilian',
'sc' => 'Sardinian',
'ss' => 'Swati',
'su' => 'Sundanese',
'sw' => 'Swahili',
'sv' => 'Swedish',
'ty' => 'Tahitian',
'ta' => 'Tamil',
'tt' => 'Tatar',
'te' => 'Telugu',
'tg' => 'Tajik',
'tl' => 'Tagalog',
'th' => 'Thai',
'bo' => 'Tibetan',
'ti' => 'Tigrinya',
'to' => 'Tonga (Tonga Islands)',
'tn' => 'Tswana',
'ts' => 'Tsonga',
'tk' => 'Turkmen',
'tr' => 'Turkish',
'tw' => 'Twi',
'ug' => 'Uighur; Uyghur',
'uk' => 'Ukrainian',
'ur' => 'Urdu',
'uz' => 'Uzbek',
've' => 'Venda',
'vi' => 'Vietnamese',
'vo' => 'Volapük',
'cy' => 'Welsh',
'wa' => 'Walloon',
'wo' => 'Wolof',
'xh' => 'Xhosa',
'yi' => 'Yiddish',
'yo' => 'Yoruba',
'za' => 'Zhuang; Chuang',
'zu' => 'Zulu',
);
/**
* Filters the language codes.
@ -500,18 +696,21 @@ function sync_category_tag_slugs( $term, $taxonomy ) {
* @access private
*/
function _access_denied_splash() {
if ( ! is_user_logged_in() || is_network_admin() )
if ( ! is_user_logged_in() || is_network_admin() ) {
return;
}
$blogs = get_blogs_of_user( get_current_user_id() );
if ( wp_list_filter( $blogs, array( 'userblog_id' => get_current_blog_id() ) ) )
if ( wp_list_filter( $blogs, array( 'userblog_id' => get_current_blog_id() ) ) ) {
return;
}
$blog_name = get_bloginfo( 'name' );
if ( empty( $blogs ) )
if ( empty( $blogs ) ) {
wp_die( sprintf( __( 'You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.' ), $blog_name ), 403 );
}
$output = '<p>' . sprintf( __( 'You attempted to access the "%1$s" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "%1$s" dashboard, please contact your network administrator.' ), $blog_name ) . '</p>';
$output .= '<p>' . __( 'If you reached this screen by accident and meant to visit one of your own sites, here are some shortcuts to help you find your way.' ) . '</p>';
@ -576,11 +775,11 @@ function mu_dropdown_languages( $lang_files = array(), $current = '' ) {
$translated = format_code_lang( $code_lang );
$output[ $translated ] = '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang, false ) . '> ' . esc_html( $translated ) . '</option>';
}
}
if ( $flag === false ) // WordPress english
$output[] = '<option value=""' . selected( $current, '', false ) . '>' . __( 'English' ) . "</option>";
if ( $flag === false ) { // WordPress english
$output[] = '<option value=""' . selected( $current, '', false ) . '>' . __( 'English' ) . '</option>';
}
// Order by name
uksort( $output, 'strnatcasecmp' );
@ -621,7 +820,7 @@ function site_admin_notice() {
}
if ( get_site_option( 'wpmu_upgrade_site' ) != $wp_db_version ) {
echo "<div class='update-nag'>" . sprintf( __( 'Thank you for Updating! Please visit the <a href="%s">Upgrade Network</a> page to update all your sites.' ), esc_url( network_admin_url( 'upgrade.php' ) ) ) . "</div>";
echo "<div class='update-nag'>" . sprintf( __( 'Thank you for Updating! Please visit the <a href="%s">Upgrade Network</a> page to update all your sites.' ), esc_url( network_admin_url( 'upgrade.php' ) ) ) . '</div>';
}
}
@ -638,14 +837,18 @@ function site_admin_notice() {
* @return array The new array of post data after checking for collisions.
*/
function avoid_blog_page_permalink_collision( $data, $postarr ) {
if ( is_subdomain_install() )
if ( is_subdomain_install() ) {
return $data;
if ( $data['post_type'] != 'page' )
}
if ( $data['post_type'] != 'page' ) {
return $data;
if ( !isset( $data['post_name'] ) || $data['post_name'] == '' )
}
if ( ! isset( $data['post_name'] ) || $data['post_name'] == '' ) {
return $data;
if ( !is_main_site() )
}
if ( ! is_main_site() ) {
return $data;
}
$post_name = $data['post_name'];
$c = 0;
@ -681,11 +884,16 @@ function choose_primary_blog() {
$found = false;
?>
<select name="primary_blog" id="primary_blog">
<?php foreach ( (array) $all_blogs as $blog ) {
if ( $primary_blog == $blog->userblog_id )
<?php
foreach ( (array) $all_blogs as $blog ) {
if ( $primary_blog == $blog->userblog_id ) {
$found = true;
?><option value="<?php echo $blog->userblog_id ?>"<?php selected( $primary_blog, $blog->userblog_id ); ?>><?php echo esc_url( get_home_url( $blog->userblog_id ) ) ?></option><?php
} ?>
}
?>
<option value="<?php echo $blog->userblog_id; ?>"<?php selected( $primary_blog, $blog->userblog_id ); ?>><?php echo esc_url( get_home_url( $blog->userblog_id ) ); ?></option>
<?php
}
?>
</select>
<?php
if ( ! $found ) {
@ -695,10 +903,11 @@ function choose_primary_blog() {
} elseif ( count( $all_blogs ) == 1 ) {
$blog = reset( $all_blogs );
echo esc_url( get_home_url( $blog->userblog_id ) );
if ( $primary_blog != $blog->userblog_id ) // Set the primary blog again if it's out of sync with blog list.
if ( $primary_blog != $blog->userblog_id ) { // Set the primary blog again if it's out of sync with blog list.
update_user_meta( get_current_user_id(), 'primary_blog', $blog->userblog_id );
}
} else {
echo "N/A";
echo 'N/A';
}
?>
</td>
@ -719,10 +928,11 @@ function choose_primary_blog() {
* @return bool True if network can be edited, otherwise false.
*/
function can_edit_network( $network_id ) {
if ( $network_id == get_current_network_id() )
if ( $network_id == get_current_network_id() ) {
$result = true;
else
} else {
$result = false;
}
/**
* Filters whether this network can be edited from this page.
@ -751,7 +961,6 @@ var tb_pathToImage = "<?php echo includes_url( 'js/thickbox/loadingAnimation.gif
}
/**
*
* @param array $users
*/
function confirm_delete_users( $users ) {
@ -773,9 +982,11 @@ function confirm_delete_users( $users ) {
<?php
wp_nonce_field( 'ms-users-delete' );
$site_admins = get_super_admins();
$admin_out = '<option value="' . esc_attr( $current_user->ID ) . '">' . $current_user->user_login . '</option>'; ?>
$admin_out = '<option value="' . esc_attr( $current_user->ID ) . '">' . $current_user->user_login . '</option>';
?>
<table class="form-table">
<?php foreach ( ( $allusers = (array) $_POST['allusers'] ) as $user_id ) {
<?php
foreach ( ( $allusers = (array) $_POST['allusers'] ) as $user_id ) {
if ( $user_id != '' && $user_id != '0' ) {
$delete_user = get_userdata( $user_id );
@ -791,18 +1002,28 @@ function confirm_delete_users( $users ) {
<th scope="row"><?php echo $delete_user->user_login; ?>
<?php echo '<input type="hidden" name="user[]" value="' . esc_attr( $user_id ) . '" />' . "\n"; ?>
</th>
<?php $blogs = get_blogs_of_user( $user_id, true );
<?php
$blogs = get_blogs_of_user( $user_id, true );
if ( ! empty( $blogs ) ) {
?>
<td><fieldset><p><legend><?php printf(
<td><fieldset><p><legend>
<?php
printf(
/* translators: user login */
__( 'What should be done with content owned by %s?' ),
'<em>' . $delete_user->user_login . '</em>'
); ?></legend></p>
);
?>
</legend></p>
<?php
foreach ( (array) $blogs as $key => $details ) {
$blog_users = get_users( array( 'blog_id' => $details->userblog_id, 'fields' => array( 'ID', 'user_login' ) ) );
$blog_users = get_users(
array(
'blog_id' => $details->userblog_id,
'fields' => array( 'ID', 'user_login' ),
)
);
if ( is_array( $blog_users ) && ! empty( $blog_users ) ) {
$user_site = "<a href='" . esc_url( get_home_url( $details->userblog_id ) ) . "'>{$details->blogname}</a>";
$user_dropdown = '<label for="reassign_user" class="screen-reader-text">' . __( 'Select a user' ) . '</label>';
@ -821,16 +1042,16 @@ function confirm_delete_users( $users ) {
?>
<ul style="list-style:none;">
<li><?php printf( __( 'Site: %s' ), $user_site ); ?></li>
<li><label><input type="radio" id="delete_option0" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID ?>]" value="delete" checked="checked" />
<li><label><input type="radio" id="delete_option0" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID; ?>]" value="delete" checked="checked" />
<?php _e( 'Delete all content.' ); ?></label></li>
<li><label><input type="radio" id="delete_option1" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID ?>]" value="reassign" />
<li><label><input type="radio" id="delete_option1" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID; ?>]" value="reassign" />
<?php _e( 'Attribute all content to:' ); ?></label>
<?php echo $user_dropdown; ?></li>
</ul>
<?php
}
}
echo "</fieldset></td></tr>";
echo '</fieldset></td></tr>';
} else {
?>
<td><fieldset><p><legend><?php _e( 'User has no sites or content and will be deleted.' ); ?></legend></p>
@ -846,11 +1067,13 @@ function confirm_delete_users( $users ) {
/** This action is documented in wp-admin/users.php */
do_action( 'delete_user_form', $current_user, $allusers );
if ( 1 == count( $users ) ) : ?>
if ( 1 == count( $users ) ) :
?>
<p><?php _e( 'Once you hit &#8220;Confirm Deletion&#8221;, the user will be permanently removed.' ); ?></p>
<?php else : ?>
<p><?php _e( 'Once you hit &#8220;Confirm Deletion&#8221;, these users will be permanently removed.' ); ?></p>
<?php endif;
<?php
endif;
submit_button( __( 'Confirm Deletion' ), 'primary' );
?>
@ -915,19 +1138,39 @@ function network_edit_site_nav( $args = array() ) {
* }
* }
*/
$links = apply_filters( 'network_edit_site_nav_links', array(
'site-info' => array( 'label' => __( 'Info' ), 'url' => 'site-info.php', 'cap' => 'manage_sites' ),
'site-users' => array( 'label' => __( 'Users' ), 'url' => 'site-users.php', 'cap' => 'manage_sites' ),
'site-themes' => array( 'label' => __( 'Themes' ), 'url' => 'site-themes.php', 'cap' => 'manage_sites' ),
'site-settings' => array( 'label' => __( 'Settings' ), 'url' => 'site-settings.php', 'cap' => 'manage_sites' )
) );
$links = apply_filters(
'network_edit_site_nav_links', array(
'site-info' => array(
'label' => __( 'Info' ),
'url' => 'site-info.php',
'cap' => 'manage_sites',
),
'site-users' => array(
'label' => __( 'Users' ),
'url' => 'site-users.php',
'cap' => 'manage_sites',
),
'site-themes' => array(
'label' => __( 'Themes' ),
'url' => 'site-themes.php',
'cap' => 'manage_sites',
),
'site-settings' => array(
'label' => __( 'Settings' ),
'url' => 'site-settings.php',
'cap' => 'manage_sites',
),
)
);
// Parse arguments
$r = wp_parse_args( $args, array(
$r = wp_parse_args(
$args, array(
'blog_id' => isset( $_GET['blog_id'] ) ? (int) $_GET['blog_id'] : 0,
'links' => $links,
'selected' => 'site-info',
) );
)
);
// Setup the links array
$screen_links = array();
@ -980,7 +1223,7 @@ function get_site_screen_help_tab_args() {
'<p>' . __( '<strong>Info</strong> &mdash; The site URL is rarely edited as this can cause the site to not work properly. The Registered date and Last Updated date are displayed. Network admins can mark a site as archived, spam, deleted and mature, to remove from public listings or disable.' ) . '</p>' .
'<p>' . __( '<strong>Users</strong> &mdash; This displays the users associated with this site. You can also change their role, reset their password, or remove them from the site. Removing the user from the site does not remove the user from the network.' ) . '</p>' .
'<p>' . sprintf( __( '<strong>Themes</strong> &mdash; This area shows themes that are not already enabled across the network. Enabling a theme in this menu makes it accessible to this site. It does not activate the theme, but allows it to show in the site&#8217;s Appearance menu. To enable a theme for the entire network, see the <a href="%s">Network Themes</a> screen.' ), network_admin_url( 'themes.php' ) ) . '</p>' .
'<p>' . __('<strong>Settings</strong> &mdash; This page shows a list of all settings associated with this site. Some are created by WordPress and others are created by plugins you activate. Note that some fields are grayed out and say Serialized Data. You cannot modify these values due to the way the setting is stored in the database.') . '</p>'
'<p>' . __( '<strong>Settings</strong> &mdash; This page shows a list of all settings associated with this site. Some are created by WordPress and others are created by plugins you activate. Note that some fields are grayed out and say Serialized Data. You cannot modify these values due to the way the setting is stored in the database.' ) . '</p>',
);
}

View File

@ -65,9 +65,7 @@ function _wp_ajax_menu_quick_search( $request = array() ) {
echo "\n";
}
}
}
} elseif ( preg_match( '/quick-search-(posttype|taxonomy)-([a-zA-Z_-]*\b)/', $type, $matches ) ) {
if ( 'posttype' == $matches[1] && get_post_type_object( $matches[2] ) ) {
$post_type_obj = _wp_nav_menu_meta_box_object( get_post_type_object( $matches[2] ) );
@ -106,12 +104,15 @@ function _wp_ajax_menu_quick_search( $request = array() ) {
}
}
} elseif ( 'taxonomy' == $matches[1] ) {
$terms = get_terms( $matches[2], array(
$terms = get_terms(
$matches[2], array(
'name__like' => $query,
'number' => 10,
));
if ( empty( $terms ) || is_wp_error( $terms ) )
)
);
if ( empty( $terms ) || is_wp_error( $terms ) ) {
return;
}
foreach ( (array) $terms as $term ) {
if ( 'markup' == $response_format ) {
echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', array( $term ) ), 0, (object) $args );
@ -134,7 +135,7 @@ function _wp_ajax_menu_quick_search( $request = array() ) {
* Register nav menu meta boxes and advanced menu items.
*
* @since 3.0.0
**/
*/
function wp_nav_menu_setup() {
// Register meta boxes
wp_nav_menu_post_type_meta_boxes();
@ -147,9 +148,17 @@ function wp_nav_menu_setup() {
// If first time editing, disable advanced items by default.
if ( false === get_user_option( 'managenav-menuscolumnshidden' ) ) {
$user = wp_get_current_user();
update_user_option($user->ID, 'managenav-menuscolumnshidden',
array( 0 => 'link-target', 1 => 'css-classes', 2 => 'xfn', 3 => 'description', 4 => 'title-attribute', ),
true);
update_user_option(
$user->ID, 'managenav-menuscolumnshidden',
array(
0 => 'link-target',
1 => 'css-classes',
2 => 'xfn',
3 => 'description',
4 => 'title-attribute',
),
true
);
}
}
@ -159,12 +168,13 @@ function wp_nav_menu_setup() {
* @since 3.0.0
*
* @global array $wp_meta_boxes
**/
*/
function wp_initial_nav_menu_meta_boxes() {
global $wp_meta_boxes;
if ( get_user_option( 'metaboxhidden_nav-menus' ) !== false || ! is_array($wp_meta_boxes) )
if ( get_user_option( 'metaboxhidden_nav-menus' ) !== false || ! is_array( $wp_meta_boxes ) ) {
return;
}
$initial_meta_boxes = array( 'add-post-type-page', 'add-post-type-post', 'add-custom-links', 'add-category' );
$hidden_meta_boxes = array();
@ -193,8 +203,9 @@ function wp_initial_nav_menu_meta_boxes() {
function wp_nav_menu_post_type_meta_boxes() {
$post_types = get_post_types( array( 'show_in_nav_menus' => true ), 'object' );
if ( ! $post_types )
if ( ! $post_types ) {
return;
}
foreach ( $post_types as $post_type ) {
/**
@ -227,8 +238,9 @@ function wp_nav_menu_post_type_meta_boxes() {
function wp_nav_menu_taxonomy_meta_boxes() {
$taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'object' );
if ( !$taxonomies )
if ( ! $taxonomies ) {
return;
}
foreach ( $taxonomies as $tax ) {
/** This filter is documented in wp-admin/includes/nav-menu.php */
@ -253,8 +265,9 @@ function wp_nav_menu_taxonomy_meta_boxes() {
function wp_nav_menu_disabled_check( $nav_menu_selected_id ) {
global $one_theme_location_no_menus;
if ( $one_theme_location_no_menus )
if ( $one_theme_location_no_menus ) {
return false;
}
return disabled( $nav_menu_selected_id, 0 );
}
@ -332,11 +345,12 @@ function wp_nav_menu_item_post_type_meta_box( $object, $box ) {
'post_type' => $post_type_name,
'suppress_filters' => true,
'update_post_term_cache' => false,
'update_post_meta_cache' => false
'update_post_meta_cache' => false,
);
if ( isset( $box['args']->_default_query ) )
if ( isset( $box['args']->_default_query ) ) {
$args = array_merge( $args, (array) $box['args']->_default_query );
}
// @todo transient caching of these results with proper invalidation on updating of a post of this type
$get_posts = new WP_Query;
@ -348,7 +362,8 @@ function wp_nav_menu_item_post_type_meta_box( $object, $box ) {
$num_pages = $get_posts->max_num_pages;
$page_links = paginate_links( array(
$page_links = paginate_links(
array(
'base' => add_query_arg(
array(
$post_type_name . '-tab' => 'all',
@ -362,12 +377,16 @@ function wp_nav_menu_item_post_type_meta_box( $object, $box ) {
'next_text' => '<span aria-label="' . esc_attr__( 'Next page' ) . '">' . __( '&raquo;' ) . '</span>',
'before_page_number' => '<span class="screen-reader-text">' . __( 'Page' ) . '</span> ',
'total' => $num_pages,
'current' => $pagenum
));
'current' => $pagenum,
)
);
$db_fields = false;
if ( is_post_type_hierarchical( $post_type_name ) ) {
$db_fields = array( 'parent' => 'post_parent', 'id' => 'ID' );
$db_fields = array(
'parent' => 'post_parent',
'id' => 'ID',
);
}
$walker = new Walker_Nav_Menu_Checklist( $db_fields );
@ -416,12 +435,20 @@ function wp_nav_menu_item_post_type_meta_box( $object, $box ) {
</li>
</ul><!-- .posttype-tabs -->
<div id="tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent" class="tabs-panel <?php
<div id="tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent" class="tabs-panel
<?php
echo ( 'most-recent' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
?>">
?>
">
<ul id="<?php echo $post_type_name; ?>checklist-most-recent" class="categorychecklist form-no-clear">
<?php
$recent_args = array_merge( $args, array( 'orderby' => 'post_date', 'order' => 'DESC', 'posts_per_page' => 15 ) );
$recent_args = array_merge(
$args, array(
'orderby' => 'post_date',
'order' => 'DESC',
'posts_per_page' => 15,
)
);
$most_recent = $get_posts->query( $recent_args );
$args['walker'] = $walker;
@ -446,13 +473,22 @@ function wp_nav_menu_item_post_type_meta_box( $object, $box ) {
</ul>
</div><!-- /.tabs-panel -->
<div class="tabs-panel <?php
<div class="tabs-panel
<?php
echo ( 'search' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
?>" id="tabs-panel-posttype-<?php echo $post_type_name; ?>-search">
?>
" id="tabs-panel-posttype-<?php echo $post_type_name; ?>-search">
<?php
if ( isset( $_REQUEST[ 'quick-search-posttype-' . $post_type_name ] ) ) {
$searched = esc_attr( $_REQUEST[ 'quick-search-posttype-' . $post_type_name ] );
$search_results = get_posts( array( 's' => $searched, 'post_type' => $post_type_name, 'fields' => 'all', 'order' => 'DESC', ) );
$search_results = get_posts(
array(
's' => $searched,
'post_type' => $post_type_name,
'fields' => 'all',
'order' => 'DESC',
)
);
} else {
$searched = '';
$search_results = array();
@ -465,7 +501,7 @@ function wp_nav_menu_item_post_type_meta_box( $object, $box ) {
<?php submit_button( __( 'Search' ), 'small quick-search-submit hide-if-js', 'submit', false, array( 'id' => 'submit-quick-search-posttype-' . $post_type_name ) ); ?>
</p>
<ul id="<?php echo $post_type_name; ?>-search-checklist" data-wp-lists="list:<?php echo $post_type_name?>" class="categorychecklist form-no-clear">
<ul id="<?php echo $post_type_name; ?>-search-checklist" data-wp-lists="list:<?php echo $post_type_name; ?>" class="categorychecklist form-no-clear">
<?php if ( ! empty( $search_results ) && ! is_wp_error( $search_results ) ) : ?>
<?php
$args['walker'] = $walker;
@ -479,15 +515,17 @@ function wp_nav_menu_item_post_type_meta_box( $object, $box ) {
</ul>
</div><!-- /.tabs-panel -->
<div id="<?php echo $post_type_name; ?>-all" class="tabs-panel tabs-panel-view-all <?php
<div id="<?php echo $post_type_name; ?>-all" class="tabs-panel tabs-panel-view-all
<?php
echo ( 'all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
?>">
?>
">
<?php if ( ! empty( $page_links ) ) : ?>
<div class="add-menu-item-pagelinks">
<?php echo $page_links; ?>
</div>
<?php endif; ?>
<ul id="<?php echo $post_type_name; ?>checklist" data-wp-lists="list:<?php echo $post_type_name?>" class="categorychecklist form-no-clear">
<ul id="<?php echo $post_type_name; ?>checklist" data-wp-lists="list:<?php echo $post_type_name; ?>" class="categorychecklist form-no-clear">
<?php
$args['walker'] = $walker;
@ -503,7 +541,8 @@ function wp_nav_menu_item_post_type_meta_box( $object, $box ) {
array_unshift( $posts, $front_page_obj );
} else {
$_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval( $_nav_menu_placeholder ) - 1 : -1;
array_unshift( $posts, (object) array(
array_unshift(
$posts, (object) array(
'front_or_home' => true,
'ID' => 0,
'object_id' => $_nav_menu_placeholder,
@ -514,7 +553,8 @@ function wp_nav_menu_item_post_type_meta_box( $object, $box ) {
'post_type' => 'nav_menu_item',
'type' => 'custom',
'url' => home_url( '/' ),
) );
)
);
}
}
@ -522,7 +562,8 @@ function wp_nav_menu_item_post_type_meta_box( $object, $box ) {
if ( $post_type->has_archive ) {
$_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval( $_nav_menu_placeholder ) - 1 : -1;
array_unshift( $posts, (object) array(
array_unshift(
$posts, (object) array(
'ID' => 0,
'object_id' => $_nav_menu_placeholder,
'object' => $post_type_name,
@ -532,7 +573,8 @@ function wp_nav_menu_item_post_type_meta_box( $object, $box ) {
'post_type' => 'nav_menu_item',
'type' => 'post_type_archive',
'url' => get_post_type_archive_link( $post_type_name ),
) );
)
);
}
/**
@ -572,15 +614,19 @@ function wp_nav_menu_item_post_type_meta_box( $object, $box ) {
<p class="button-controls wp-clearfix">
<span class="list-controls">
<a href="<?php
echo esc_url( add_query_arg(
<a href="
<?php
echo esc_url(
add_query_arg(
array(
$post_type_name . '-tab' => 'all',
'selectall' => 1,
),
remove_query_arg( $removed_args )
));
?>#posttype-<?php echo $post_type_name; ?>" class="select-all aria-button-if-js"><?php _e( 'Select All' ); ?></a>
)
);
?>
#posttype-<?php echo $post_type_name; ?>" class="select-all aria-button-if-js"><?php _e( 'Select All' ); ?></a>
</span>
<span class="add-to-menu">
@ -640,9 +686,19 @@ function wp_nav_menu_item_taxonomy_meta_box( $object, $box ) {
return;
}
$num_pages = ceil( wp_count_terms( $taxonomy_name , array_merge( $args, array('number' => '', 'offset' => '') ) ) / $per_page );
$num_pages = ceil(
wp_count_terms(
$taxonomy_name, array_merge(
$args, array(
'number' => '',
'offset' => '',
)
)
) / $per_page
);
$page_links = paginate_links( array(
$page_links = paginate_links(
array(
'base' => add_query_arg(
array(
$taxonomy_name . '-tab' => 'all',
@ -656,12 +712,16 @@ function wp_nav_menu_item_taxonomy_meta_box( $object, $box ) {
'next_text' => '<span aria-label="' . esc_attr__( 'Next page' ) . '">' . __( '&raquo;' ) . '</span>',
'before_page_number' => '<span class="screen-reader-text">' . __( 'Page' ) . '</span> ',
'total' => $num_pages,
'current' => $pagenum
));
'current' => $pagenum,
)
);
$db_fields = false;
if ( is_taxonomy_hierarchical( $taxonomy_name ) ) {
$db_fields = array( 'parent' => 'parent', 'id' => 'term_id' );
$db_fields = array(
'parent' => 'parent',
'id' => 'term_id',
);
}
$walker = new Walker_Nav_Menu_Checklist( $db_fields );
@ -710,27 +770,38 @@ function wp_nav_menu_item_taxonomy_meta_box( $object, $box ) {
</li>
</ul><!-- .taxonomy-tabs -->
<div id="tabs-panel-<?php echo $taxonomy_name; ?>-pop" class="tabs-panel <?php
<div id="tabs-panel-<?php echo $taxonomy_name; ?>-pop" class="tabs-panel
<?php
echo ( 'most-used' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
?>">
?>
">
<ul id="<?php echo $taxonomy_name; ?>checklist-pop" class="categorychecklist form-no-clear" >
<?php
$popular_terms = get_terms( $taxonomy_name, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) );
$popular_terms = get_terms(
$taxonomy_name, array(
'orderby' => 'count',
'order' => 'DESC',
'number' => 10,
'hierarchical' => false,
)
);
$args['walker'] = $walker;
echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $popular_terms ), 0, (object) $args );
?>
</ul>
</div><!-- /.tabs-panel -->
<div id="tabs-panel-<?php echo $taxonomy_name; ?>-all" class="tabs-panel tabs-panel-view-all <?php
<div id="tabs-panel-<?php echo $taxonomy_name; ?>-all" class="tabs-panel tabs-panel-view-all
<?php
echo ( 'all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
?>">
?>
">
<?php if ( ! empty( $page_links ) ) : ?>
<div class="add-menu-item-pagelinks">
<?php echo $page_links; ?>
</div>
<?php endif; ?>
<ul id="<?php echo $taxonomy_name; ?>checklist" data-wp-lists="list:<?php echo $taxonomy_name?>" class="categorychecklist form-no-clear">
<ul id="<?php echo $taxonomy_name; ?>checklist" data-wp-lists="list:<?php echo $taxonomy_name; ?>" class="categorychecklist form-no-clear">
<?php
$args['walker'] = $walker;
echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $terms ), 0, (object) $args );
@ -743,13 +814,23 @@ function wp_nav_menu_item_taxonomy_meta_box( $object, $box ) {
<?php endif; ?>
</div><!-- /.tabs-panel -->
<div class="tabs-panel <?php
<div class="tabs-panel
<?php
echo ( 'search' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
?>" id="tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>">
?>
" id="tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>">
<?php
if ( isset( $_REQUEST[ 'quick-search-taxonomy-' . $taxonomy_name ] ) ) {
$searched = esc_attr( $_REQUEST[ 'quick-search-taxonomy-' . $taxonomy_name ] );
$search_results = get_terms( $taxonomy_name, array( 'name__like' => $searched, 'fields' => 'all', 'orderby' => 'count', 'order' => 'DESC', 'hierarchical' => false ) );
$search_results = get_terms(
$taxonomy_name, array(
'name__like' => $searched,
'fields' => 'all',
'orderby' => 'count',
'order' => 'DESC',
'hierarchical' => false,
)
);
} else {
$searched = '';
$search_results = array();
@ -762,7 +843,7 @@ function wp_nav_menu_item_taxonomy_meta_box( $object, $box ) {
<?php submit_button( __( 'Search' ), 'small quick-search-submit hide-if-js', 'submit', false, array( 'id' => 'submit-quick-search-taxonomy-' . $taxonomy_name ) ); ?>
</p>
<ul id="<?php echo $taxonomy_name; ?>-search-checklist" data-wp-lists="list:<?php echo $taxonomy_name?>" class="categorychecklist form-no-clear">
<ul id="<?php echo $taxonomy_name; ?>-search-checklist" data-wp-lists="list:<?php echo $taxonomy_name; ?>" class="categorychecklist form-no-clear">
<?php if ( ! empty( $search_results ) && ! is_wp_error( $search_results ) ) : ?>
<?php
$args['walker'] = $walker;
@ -778,15 +859,19 @@ function wp_nav_menu_item_taxonomy_meta_box( $object, $box ) {
<p class="button-controls wp-clearfix">
<span class="list-controls">
<a href="<?php
echo esc_url(add_query_arg(
<a href="
<?php
echo esc_url(
add_query_arg(
array(
$taxonomy_name . '-tab' => 'all',
'selectall' => 1,
),
remove_query_arg( $removed_args )
));
?>#taxonomy-<?php echo $taxonomy_name; ?>" class="select-all aria-button-if-js"><?php _e( 'Select All' ); ?></a>
)
);
?>
#taxonomy-<?php echo $taxonomy_name; ?>" class="select-all aria-button-if-js"><?php _e( 'Select All' ); ?></a>
</span>
<span class="add-to-menu">
@ -929,8 +1014,9 @@ function wp_get_nav_menu_to_edit( $menu_id = 0 ) {
$result .= '<p>' . __( 'Add menu items from the column on the left.' ) . '</p>';
$result .= '</div>';
if ( empty($menu_items) )
if ( empty( $menu_items ) ) {
return $result . ' <ul class="menu" id="menu-to-edit"> </ul>';
}
/**
* Filters the Walker class used when adding nav menu items.
@ -945,9 +1031,11 @@ function wp_get_nav_menu_to_edit( $menu_id = 0 ) {
if ( class_exists( $walker_class_name ) ) {
$walker = new $walker_class_name;
} else {
return new WP_Error( 'menu_walker_not_exist',
return new WP_Error(
'menu_walker_not_exist',
/* translators: %s: walker class name */
sprintf( __( 'The Walker class named %s does not exist.' ),
sprintf(
__( 'The Walker class named %s does not exist.' ),
'<strong>' . $walker_class_name . '</strong>'
)
);
@ -955,11 +1043,13 @@ function wp_get_nav_menu_to_edit( $menu_id = 0 ) {
$some_pending_menu_items = $some_invalid_menu_items = false;
foreach ( (array) $menu_items as $menu_item ) {
if ( isset( $menu_item->post_status ) && 'draft' == $menu_item->post_status )
if ( isset( $menu_item->post_status ) && 'draft' == $menu_item->post_status ) {
$some_pending_menu_items = true;
if ( ! empty( $menu_item->_invalid ) )
}
if ( ! empty( $menu_item->_invalid ) ) {
$some_invalid_menu_items = true;
}
}
if ( $some_pending_menu_items ) {
$result .= '<div class="notice notice-info notice-alt inline"><p>' . __( 'Click Save Menu to make pending menu items public.' ) . '</p></div>';
@ -1013,9 +1103,10 @@ function _wp_delete_orphaned_draft_menu_items() {
// Delete orphaned draft menu items.
$menu_items_to_delete = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts AS p LEFT JOIN $wpdb->postmeta AS m ON p.ID = m.post_id WHERE post_type = 'nav_menu_item' AND post_status = 'draft' AND meta_key = '_menu_item_orphaned' AND meta_value < %d", $delete_timestamp ) );
foreach ( (array) $menu_items_to_delete as $menu_item_id )
foreach ( (array) $menu_items_to_delete as $menu_item_id ) {
wp_delete_post( $menu_item_id, true );
}
}
/**
* Saves nav menu items
@ -1027,18 +1118,35 @@ function _wp_delete_orphaned_draft_menu_items() {
* @return array $messages The menu updated message
*/
function wp_nav_menu_update_menu_items( $nav_menu_selected_id, $nav_menu_selected_title ) {
$unsorted_menu_items = wp_get_nav_menu_items( $nav_menu_selected_id, array( 'orderby' => 'ID', 'output' => ARRAY_A, 'output_key' => 'ID', 'post_status' => 'draft,publish' ) );
$unsorted_menu_items = wp_get_nav_menu_items(
$nav_menu_selected_id, array(
'orderby' => 'ID',
'output' => ARRAY_A,
'output_key' => 'ID',
'post_status' => 'draft,publish',
)
);
$messages = array();
$menu_items = array();
// Index menu items by db ID
foreach ( $unsorted_menu_items as $_item )
foreach ( $unsorted_menu_items as $_item ) {
$menu_items[ $_item->db_id ] = $_item;
}
$post_fields = array(
'menu-item-db-id', 'menu-item-object-id', 'menu-item-object',
'menu-item-parent-id', 'menu-item-position', 'menu-item-type',
'menu-item-title', 'menu-item-url', 'menu-item-description',
'menu-item-attr-title', 'menu-item-target', 'menu-item-classes', 'menu-item-xfn'
'menu-item-db-id',
'menu-item-object-id',
'menu-item-object',
'menu-item-parent-id',
'menu-item-position',
'menu-item-type',
'menu-item-title',
'menu-item-url',
'menu-item-description',
'menu-item-attr-title',
'menu-item-target',
'menu-item-classes',
'menu-item-xfn',
);
wp_defer_term_counting( true );
@ -1047,12 +1155,14 @@ function wp_nav_menu_update_menu_items ( $nav_menu_selected_id, $nav_menu_select
foreach ( (array) $_POST['menu-item-db-id'] as $_key => $k ) {
// Menu item title can't be blank
if ( ! isset( $_POST['menu-item-title'][ $_key ] ) || '' == $_POST['menu-item-title'][ $_key ] )
if ( ! isset( $_POST['menu-item-title'][ $_key ] ) || '' == $_POST['menu-item-title'][ $_key ] ) {
continue;
}
$args = array();
foreach ( $post_fields as $field )
foreach ( $post_fields as $field ) {
$args[ $field ] = isset( $_POST[ $field ][ $_key ] ) ? $_POST[ $field ][ $_key ] : '';
}
$menu_item_db_id = wp_update_nav_menu_item( $nav_menu_selected_id, ( $_POST['menu-item-db-id'][ $_key ] != $_key ? 0 : $_key ), $args );
@ -1076,15 +1186,18 @@ function wp_nav_menu_update_menu_items ( $nav_menu_selected_id, $nav_menu_select
// Store 'auto-add' pages.
$auto_add = ! empty( $_POST['auto-add-pages'] );
$nav_menu_option = (array) get_option( 'nav_menu_options' );
if ( ! isset( $nav_menu_option['auto_add'] ) )
if ( ! isset( $nav_menu_option['auto_add'] ) ) {
$nav_menu_option['auto_add'] = array();
}
if ( $auto_add ) {
if ( ! in_array( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) )
if ( ! in_array( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) {
$nav_menu_option['auto_add'][] = $nav_menu_selected_id;
}
} else {
if ( false !== ( $key = array_search( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) )
if ( false !== ( $key = array_search( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) ) {
unset( $nav_menu_option['auto_add'][ $key ] );
}
}
// Remove nonexistent/deleted menus
$nav_menu_option['auto_add'] = array_intersect( $nav_menu_option['auto_add'], wp_get_nav_menus( array( 'fields' => 'ids' ) ) );
update_option( 'nav_menu_options', $nav_menu_option );
@ -1096,7 +1209,8 @@ function wp_nav_menu_update_menu_items ( $nav_menu_selected_id, $nav_menu_select
$messages[] = '<div id="message" class="updated notice is-dismissible"><p>' .
/* translators: %s: nav menu title */
sprintf( __( '%s has been updated.' ),
sprintf(
__( '%s has been updated.' ),
'<strong>' . $nav_menu_selected_title . '</strong>'
) . '</p></div>';

View File

@ -19,7 +19,7 @@
function network_domain_check() {
global $wpdb;
$sql = $wpdb->prepare( "SHOW TABLES LIKE %s", $wpdb->esc_like( $wpdb->site ) );
$sql = $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $wpdb->site ) );
if ( $wpdb->get_var( $sql ) ) {
return $wpdb->get_var( "SELECT domain FROM $wpdb->site ORDER BY id ASC LIMIT 1" );
}
@ -34,8 +34,9 @@ function network_domain_check() {
*/
function allow_subdomain_install() {
$domain = preg_replace( '|https?://([^/]+)|', '$1', get_option( 'home' ) );
if ( parse_url( get_option( 'home' ), PHP_URL_PATH ) || 'localhost' == $domain || preg_match( '|^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$|', $domain ) )
if ( parse_url( get_option( 'home' ), PHP_URL_PATH ) || 'localhost' == $domain || preg_match( '|^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$|', $domain ) ) {
return false;
}
return true;
}
@ -58,15 +59,18 @@ function allow_subdirectory_install() {
*
* @param bool $allow Whether to enable the subdirectory installation feature in Multisite. Default is false.
*/
if ( apply_filters( 'allow_subdirectory_install', false ) )
if ( apply_filters( 'allow_subdirectory_install', false ) ) {
return true;
}
if ( defined( 'ALLOW_SUBDIRECTORY_INSTALL' ) && ALLOW_SUBDIRECTORY_INSTALL )
if ( defined( 'ALLOW_SUBDIRECTORY_INSTALL' ) && ALLOW_SUBDIRECTORY_INSTALL ) {
return true;
}
$post = $wpdb->get_row( "SELECT ID FROM $wpdb->posts WHERE post_date < DATE_SUB(NOW(), INTERVAL 1 MONTH) AND post_status = 'publish'" );
if ( empty( $post ) )
if ( empty( $post ) ) {
return true;
}
return false;
}
@ -78,11 +82,13 @@ function allow_subdirectory_install() {
* @return string Base domain.
*/
function get_clean_basedomain() {
if ( $existing_domain = network_domain_check() )
if ( $existing_domain = network_domain_check() ) {
return $existing_domain;
}
$domain = preg_replace( '|https?://|', '', get_option( 'siteurl' ) );
if ( $slash = strpos( $domain, '/' ) )
if ( $slash = strpos( $domain, '/' ) ) {
$domain = substr( $domain, 0, $slash );
}
return $domain;
}
@ -147,8 +153,9 @@ function network_step1( $errors = false ) {
$error_codes = array();
if ( is_wp_error( $errors ) ) {
echo '<div class="error"><p><strong>' . __( 'ERROR: The network could not be created.' ) . '</strong></p>';
foreach ( $errors->get_error_messages() as $error )
foreach ( $errors->get_error_messages() as $error ) {
echo "<p>$error</p>";
}
echo '</div>';
$error_codes = $errors->get_error_codes();
}
@ -181,14 +188,16 @@ function network_step1( $errors = false ) {
if ( $got_mod_rewrite = got_mod_rewrite() ) { // dangerous assumptions
echo '<div class="updated inline"><p><strong>' . __( 'Note:' ) . '</strong> ';
/* translators: %s: mod_rewrite */
printf( __( 'Please make sure the Apache %s module is installed as it will be used at the end of this installation.' ),
printf(
__( 'Please make sure the Apache %s module is installed as it will be used at the end of this installation.' ),
'<code>mod_rewrite</code>'
);
echo '</p>';
} elseif ( $is_apache ) {
echo '<div class="error inline"><p><strong>' . __( 'Warning:' ) . '</strong> ';
/* translators: %s: mod_rewrite */
printf( __( 'It looks like the Apache %s module is not installed.' ),
printf(
__( 'It looks like the Apache %s module is not installed.' ),
'<code>mod_rewrite</code>'
);
echo '</p>';
@ -197,7 +206,8 @@ function network_step1( $errors = false ) {
if ( $got_mod_rewrite || $is_apache ) { // Protect against mod_rewrite mimicry (but ! Apache)
echo '<p>';
/* translators: 1: mod_rewrite, 2: mod_rewrite documentation URL, 3: Google search for mod_rewrite */
printf( __( 'If %1$s is disabled, ask your administrator to enable that module, or look at the <a href="%2$s">Apache documentation</a> or <a href="%3$s">elsewhere</a> for help setting it up.' ),
printf(
__( 'If %1$s is disabled, ask your administrator to enable that module, or look at the <a href="%2$s">Apache documentation</a> or <a href="%3$s">elsewhere</a> for help setting it up.' ),
'<code>mod_rewrite</code>',
'https://httpd.apache.org/docs/mod/mod_rewrite.html',
'https://www.google.com/search?q=apache+mod_rewrite'
@ -206,7 +216,8 @@ function network_step1( $errors = false ) {
}
}
if ( allow_subdomain_install() && allow_subdirectory_install() ) : ?>
if ( allow_subdomain_install() && allow_subdirectory_install() ) :
?>
<h3><?php esc_html_e( 'Addresses of Sites in your Network' ); ?></h3>
<p><?php _e( 'Please choose whether you would like sites in your WordPress network to use sub-domains or sub-directories.' ); ?>
<strong><?php _e( 'You cannot change this later.' ); ?></strong></p>
@ -215,48 +226,63 @@ function network_step1( $errors = false ) {
<table class="form-table">
<tr>
<th><label><input type="radio" name="subdomain_install" value="1"<?php checked( $subdomain_install ); ?> /> <?php _e( 'Sub-domains' ); ?></label></th>
<td><?php printf(
<td>
<?php
printf(
/* translators: 1: hostname */
_x( 'like <code>site1.%1$s</code> and <code>site2.%1$s</code>', 'subdomain examples' ),
$hostname
); ?></td>
);
?>
</td>
</tr>
<tr>
<th><label><input type="radio" name="subdomain_install" value="0"<?php checked( ! $subdomain_install ); ?> /> <?php _e( 'Sub-directories' ); ?></label></th>
<td><?php printf(
<td>
<?php
printf(
/* translators: 1: hostname */
_x( 'like <code>%1$s/site1</code> and <code>%1$s/site2</code>', 'subdirectory examples' ),
$hostname
); ?></td>
);
?>
</td>
</tr>
</table>
<?php
endif;
if ( WP_CONTENT_DIR != ABSPATH . 'wp-content' && ( allow_subdirectory_install() || ! allow_subdomain_install() ) )
if ( WP_CONTENT_DIR != ABSPATH . 'wp-content' && ( allow_subdirectory_install() || ! allow_subdomain_install() ) ) {
echo '<div class="error inline"><p><strong>' . __( 'Warning:' ) . '</strong> ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</p></div>';
}
$is_www = ( 0 === strpos( $hostname, 'www.' ) );
if ( $is_www ) :
?>
<h3><?php esc_html_e( 'Server Address' ); ?></h3>
<p><?php printf(
<p>
<?php
printf(
/* translators: 1: site url 2: host name 3. www */
__( 'We recommend you change your siteurl to %1$s before enabling the network feature. It will still be possible to visit your site using the %3$s prefix with an address like %2$s but any links will not have the %3$s prefix.' ),
'<code>' . substr( $hostname, 4 ) . '</code>',
'<code>' . $hostname . '</code>',
'<code>www</code>'
); ?></p>
);
?>
</p>
<table class="form-table">
<tr>
<th scope='row'><?php esc_html_e( 'Server Address' ); ?></th>
<td>
<?php printf(
<?php
printf(
/* translators: %s: host name */
__( 'The internet address of your network will be %s.' ),
'<code>' . $hostname . '</code>'
); ?>
);
?>
</td>
</tr>
</table>
@ -267,7 +293,8 @@ function network_step1( $errors = false ) {
<?php if ( 'localhost' == $hostname ) : ?>
<tr>
<th scope="row"><?php esc_html_e( 'Sub-directory Installation' ); ?></th>
<td><?php
<td>
<?php
printf(
/* translators: 1: localhost 2: localhost.localdomain */
__( 'Because you are using %1$s, the sites in your WordPress network must use sub-directories. Consider using %2$s if you wish to use sub-domains.' ),
@ -275,37 +302,47 @@ function network_step1( $errors = false ) {
'<code>localhost.localdomain</code>'
);
// Uh oh:
if ( !allow_subdirectory_install() )
if ( ! allow_subdirectory_install() ) {
echo ' <strong>' . __( 'Warning:' ) . ' ' . __( 'The main site in a sub-directory installation will need to use a modified permalink structure, potentially breaking existing links.' ) . '</strong>';
?></td>
}
?>
</td>
</tr>
<?php elseif ( ! allow_subdomain_install() ) : ?>
<tr>
<th scope="row"><?php esc_html_e( 'Sub-directory Installation' ); ?></th>
<td><?php
<td>
<?php
_e( 'Because your installation is in a directory, the sites in your WordPress network must use sub-directories.' );
// Uh oh:
if ( !allow_subdirectory_install() )
if ( ! allow_subdirectory_install() ) {
echo ' <strong>' . __( 'Warning:' ) . ' ' . __( 'The main site in a sub-directory installation will need to use a modified permalink structure, potentially breaking existing links.' ) . '</strong>';
?></td>
}
?>
</td>
</tr>
<?php elseif ( ! allow_subdirectory_install() ) : ?>
<tr>
<th scope="row"><?php esc_html_e( 'Sub-domain Installation' ); ?></th>
<td><?php _e( 'Because your installation is not new, the sites in your WordPress network must use sub-domains.' );
<td>
<?php
_e( 'Because your installation is not new, the sites in your WordPress network must use sub-domains.' );
echo ' <strong>' . __( 'The main site in a sub-directory installation will need to use a modified permalink structure, potentially breaking existing links.' ) . '</strong>';
?></td>
?>
</td>
</tr>
<?php endif; ?>
<?php if ( ! $is_www ) : ?>
<tr>
<th scope='row'><?php esc_html_e( 'Server Address' ); ?></th>
<td>
<?php printf(
<?php
printf(
/* translators: %s: host name */
__( 'The internet address of your network will be %s.' ),
'<code>' . $hostname . '</code>'
); ?>
);
?>
</td>
</tr>
<?php endif; ?>
@ -354,7 +391,6 @@ function network_step2( $errors = false ) {
$wp_siteurl_subdir = preg_replace( '#^' . preg_quote( $home_path, '#' ) . '#', '', $abspath_fix );
$rewrite_base = ! empty( $wp_siteurl_subdir ) ? ltrim( trailingslashit( $wp_siteurl_subdir ), '/' ) : '';
$location_of_wp_config = $abspath_fix;
if ( ! file_exists( ABSPATH . 'wp-config.php' ) && file_exists( dirname( ABSPATH ) . '/wp-config.php' ) ) {
$location_of_wp_config = dirname( $abspath_fix );
@ -362,14 +398,16 @@ function network_step2( $errors = false ) {
$location_of_wp_config = trailingslashit( $location_of_wp_config );
// Wildcard DNS message.
if ( is_wp_error( $errors ) )
if ( is_wp_error( $errors ) ) {
echo '<div class="error">' . $errors->get_error_message() . '</div>';
}
if ( $_POST ) {
if ( allow_subdomain_install() )
if ( allow_subdomain_install() ) {
$subdomain_install = allow_subdirectory_install() ? ! empty( $_POST['subdomain_install'] ) : true;
else
} else {
$subdomain_install = false;
}
} else {
if ( is_multisite() ) {
$subdomain_install = is_subdomain_install();
@ -393,7 +431,8 @@ function network_step2( $errors = false ) {
?>
<h3><?php esc_html_e( 'Enabling the Network' ); ?></h3>
<p><?php _e( 'Complete the following steps to enable the features for creating a network of sites.' ); ?></p>
<div class="updated inline"><p><?php
<div class="updated inline"><p>
<?php
if ( file_exists( $home_path . '.htaccess' ) ) {
echo '<strong>' . __( 'Caution:' ) . '</strong> ';
printf(
@ -418,12 +457,15 @@ function network_step2( $errors = false ) {
'<code>wp-config.php</code>'
);
}
?></p></div>
?>
</p></div>
<?php
}
?>
<ol>
<li><p><?php printf(
<li><p>
<?php
printf(
/* translators: 1: wp-config.php 2: location of wp-config file, 3: translated version of "That's all, stop editing! Happy blogging." */
__( 'Add the following to your %1$s file in %2$s <strong>above</strong> the line reading %3$s:' ),
'<code>wp-config.php</code>',
@ -434,7 +476,9 @@ function network_step2( $errors = false ) {
* https://i18n.svn.wordpress.org/<locale code>/branches/<wp version>/dist/wp-config-sample.php
*/
'<code>/* ' . __( 'That&#8217;s all, stop editing! Happy blogging.' ) . ' */</code>'
); ?></p>
);
?>
</p>
<textarea class="code" readonly="readonly" cols="100" rows="7">
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', <?php echo $subdomain_install ? 'true' : 'false'; ?>);
@ -444,11 +488,21 @@ define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);
</textarea>
<?php
$keys_salts = array( 'AUTH_KEY' => '', 'SECURE_AUTH_KEY' => '', 'LOGGED_IN_KEY' => '', 'NONCE_KEY' => '', 'AUTH_SALT' => '', 'SECURE_AUTH_SALT' => '', 'LOGGED_IN_SALT' => '', 'NONCE_SALT' => '' );
$keys_salts = array(
'AUTH_KEY' => '',
'SECURE_AUTH_KEY' => '',
'LOGGED_IN_KEY' => '',
'NONCE_KEY' => '',
'AUTH_SALT' => '',
'SECURE_AUTH_SALT' => '',
'LOGGED_IN_SALT' => '',
'NONCE_SALT' => '',
);
foreach ( $keys_salts as $c => $v ) {
if ( defined( $c ) )
if ( defined( $c ) ) {
unset( $keys_salts[ $c ] );
}
}
if ( ! empty( $keys_salts ) ) {
$keys_salts_str = '';
@ -550,14 +604,16 @@ define('BLOG_ID_CURRENT_SITE', 1);
'<code>' . $home_path . '</code>'
);
echo '</p>';
if ( ! $subdomain_install && WP_CONTENT_DIR != ABSPATH . 'wp-content' )
if ( ! $subdomain_install && WP_CONTENT_DIR != ABSPATH . 'wp-content' ) {
echo '<p><strong>' . __( 'Warning:' ) . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</strong></p>';
}
?>
<textarea class="code" readonly="readonly" cols="100" rows="20"><?php echo esc_textarea( $web_config_file ); ?>
</textarea></li>
</ol>
<?php else : // end iis7_supports_permalinks(). construct an htaccess file instead:
<?php
else : // end iis7_supports_permalinks(). construct an htaccess file instead:
$ms_files_rewriting = '';
if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) {
@ -590,16 +646,19 @@ EOF;
'<code>' . $home_path . '</code>'
);
echo '</p>';
if ( ! $subdomain_install && WP_CONTENT_DIR != ABSPATH . 'wp-content' )
if ( ! $subdomain_install && WP_CONTENT_DIR != ABSPATH . 'wp-content' ) {
echo '<p><strong>' . __( 'Warning:' ) . ' ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</strong></p>';
}
?>
<textarea class="code" readonly="readonly" cols="100" rows="<?php echo substr_count( $htaccess_file, "\n" ) + 1; ?>">
<?php echo esc_textarea( $htaccess_file ); ?></textarea></li>
</ol>
<?php endif; // end IIS/Apache code branches.
<?php
endif; // end IIS/Apache code branches.
if ( !is_multisite() ) { ?>
if ( ! is_multisite() ) {
?>
<p><?php _e( 'Once you complete these steps, your network is enabled and configured. You will have to log in again.' ); ?> <a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log In' ); ?></a></p>
<?php
}

View File

@ -65,7 +65,8 @@ function get_bloginfo() {}
/**
* @ignore
*/
function is_admin() {return true;}
function is_admin() {
return true;}
/**
* @ignore

View File

@ -145,16 +145,17 @@ function plugins_api( $action, $args = array() ) {
include( ABSPATH . WPINC . '/version.php' );
$url = $http_url = 'http://api.wordpress.org/plugins/info/1.0/';
if ( $ssl = wp_http_supports( array( 'ssl' ) ) )
if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) {
$url = set_url_scheme( $url, 'https' );
}
$http_args = array(
'timeout' => 15,
'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ),
'body' => array(
'action' => $action,
'request' => serialize( $args )
)
'request' => serialize( $args ),
),
);
$request = wp_remote_post( $url, $http_args );
@ -171,7 +172,8 @@ function plugins_api( $action, $args = array() ) {
}
if ( is_wp_error( $request ) ) {
$res = new WP_Error( 'plugins_api_failed',
$res = new WP_Error(
'plugins_api_failed',
sprintf(
/* translators: %s: support forums URL */
__( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
@ -182,7 +184,8 @@ function plugins_api( $action, $args = array() ) {
} else {
$res = maybe_unserialize( wp_remote_retrieve_body( $request ) );
if ( ! is_object( $res ) && ! is_array( $res ) ) {
$res = new WP_Error( 'plugins_api_failed',
$res = new WP_Error(
'plugins_api_failed',
sprintf(
/* translators: %s: support forums URL */
__( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
@ -218,13 +221,15 @@ function plugins_api( $action, $args = array() ) {
*/
function install_popular_tags( $args = array() ) {
$key = md5( serialize( $args ) );
if ( false !== ($tags = get_site_transient('poptags_' . $key) ) )
if ( false !== ( $tags = get_site_transient( 'poptags_' . $key ) ) ) {
return $tags;
}
$tags = plugins_api( 'hot_tags', $args );
if ( is_wp_error($tags) )
if ( is_wp_error( $tags ) ) {
return $tags;
}
set_site_transient( 'poptags_' . $key, $tags, 3 * HOUR_IN_SECONDS );
@ -241,8 +246,8 @@ function install_dashboard() {
<?php display_plugins_table(); ?>
<div class="plugins-popular-tags-wrapper">
<h2><?php _e( 'Popular tags' ) ?></h2>
<p><?php _e( 'You may also browse based on the most popular tags in the Plugin Directory:' ) ?></p>
<h2><?php _e( 'Popular tags' ); ?></h2>
<p><?php _e( 'You may also browse based on the most popular tags in the Plugin Directory:' ); ?></p>
<?php
$api_tags = install_popular_tags();
@ -260,11 +265,16 @@ function install_dashboard() {
'name' => $tag['name'],
'slug' => $tag['slug'],
'id' => sanitize_title_with_dashes( $tag['name'] ),
'count' => $tag['count']
'count' => $tag['count'],
);
$tags[ $tag['name'] ] = (object) $data;
}
echo wp_generate_tag_cloud($tags, array( 'single_text' => __('%s plugin'), 'multiple_text' => __('%s plugins') ) );
echo wp_generate_tag_cloud(
$tags, array(
'single_text' => __( '%s plugin' ),
'multiple_text' => __( '%s plugins' ),
)
);
}
echo '</p><br class="clear" /></div>';
}
@ -280,7 +290,8 @@ function install_dashboard() {
function install_search_form( $deprecated = true ) {
$type = isset( $_REQUEST['type'] ) ? wp_unslash( $_REQUEST['type'] ) : 'term';
$term = isset( $_REQUEST['s'] ) ? wp_unslash( $_REQUEST['s'] ) : '';
?><form class="search-form search-plugins" method="get">
?>
<form class="search-form search-plugins" method="get">
<input type="hidden" name="tab" value="search" />
<label class="screen-reader-text" for="typeselector"><?php _e( 'Search plugins by:' ); ?></label>
<select name="type" id="typeselector">
@ -289,14 +300,16 @@ function install_search_form( $deprecated = true ) {
<option value="tag"<?php selected( 'tag', $type ); ?>><?php _ex( 'Tag', 'Plugin Installer' ); ?></option>
</select>
<label><span class="screen-reader-text"><?php _e( 'Search Plugins' ); ?></span>
<input type="search" name="s" value="<?php echo esc_attr( $term ) ?>" class="wp-filter-search" placeholder="<?php esc_attr_e( 'Search plugins...' ); ?>" />
<input type="search" name="s" value="<?php echo esc_attr( $term ); ?>" class="wp-filter-search" placeholder="<?php esc_attr_e( 'Search plugins...' ); ?>" />
</label>
<?php submit_button( __( 'Search Plugins' ), 'hide-if-js', false, false, array( 'id' => 'search-submit' ) ); ?>
</form><?php
</form>
<?php
}
/**
* Upload from zip
*
* @since 2.8.0
*/
function install_plugins_upload() {
@ -315,8 +328,8 @@ function install_plugins_upload() {
/**
* Show a username form for the favorites page
* @since 3.5.0
*
* @since 3.5.0
*/
function install_plugins_favorites_form() {
$user = get_user_option( 'wporg_favorites' );
@ -387,8 +400,9 @@ function display_plugins_table() {
*/
function install_plugin_install_status( $api, $loop = false ) {
// This function is called recursively, $loop prevents further loops.
if ( is_array($api) )
if ( is_array( $api ) ) {
$api = (object) $api;
}
// Default to a "new" plugin
$status = 'install';
@ -406,8 +420,9 @@ function install_plugin_install_status($api, $loop = false) {
$status = 'update_available';
$update_file = $file;
$version = $plugin->new_version;
if ( current_user_can('update_plugins') )
if ( current_user_can( 'update_plugins' ) ) {
$url = wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' . $update_file ), 'upgrade-plugin_' . $update_file );
}
break;
}
}
@ -417,8 +432,9 @@ function install_plugin_install_status($api, $loop = false) {
if ( is_dir( WP_PLUGIN_DIR . '/' . $api->slug ) ) {
$installed_plugin = get_plugins( '/' . $api->slug );
if ( empty( $installed_plugin ) ) {
if ( current_user_can('install_plugins') )
if ( current_user_can( 'install_plugins' ) ) {
$url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $api->slug ), 'install-plugin_' . $api->slug );
}
} else {
$key = array_keys( $installed_plugin );
$key = reset( $key ); //Use the first plugin regardless of the name, Could have issues for multiple-plugins in one directory if they share different version numbers
@ -439,12 +455,14 @@ function install_plugin_install_status($api, $loop = false) {
}
} else {
// "install" & no directory with that slug
if ( current_user_can('install_plugins') )
if ( current_user_can( 'install_plugins' ) ) {
$url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $api->slug ), 'install-plugin_' . $api->slug );
}
}
if ( isset($_GET['from']) )
}
if ( isset( $_GET['from'] ) ) {
$url .= '&amp;from=' . urlencode( wp_unslash( $_GET['from'] ) );
}
$file = $update_file;
return compact( 'status', 'url', 'version', 'file' );
@ -464,29 +482,53 @@ function install_plugin_information() {
return;
}
$api = plugins_api( 'plugin_information', array(
$api = plugins_api(
'plugin_information', array(
'slug' => wp_unslash( $_REQUEST['plugin'] ),
'is_ssl' => is_ssl(),
'fields' => array(
'banners' => true,
'reviews' => true,
'downloaded' => false,
'active_installs' => true
'active_installs' => true,
),
)
) );
);
if ( is_wp_error( $api ) ) {
wp_die( $api );
}
$plugins_allowedtags = array(
'a' => array( 'href' => array(), 'title' => array(), 'target' => array() ),
'abbr' => array( 'title' => array() ), 'acronym' => array( 'title' => array() ),
'code' => array(), 'pre' => array(), 'em' => array(), 'strong' => array(),
'div' => array( 'class' => array() ), 'span' => array( 'class' => array() ),
'p' => array(), 'br' => array(), 'ul' => array(), 'ol' => array(), 'li' => array(),
'h1' => array(), 'h2' => array(), 'h3' => array(), 'h4' => array(), 'h5' => array(), 'h6' => array(),
'img' => array( 'src' => array(), 'class' => array(), 'alt' => array() ),
'a' => array(
'href' => array(),
'title' => array(),
'target' => array(),
),
'abbr' => array( 'title' => array() ),
'acronym' => array( 'title' => array() ),
'code' => array(),
'pre' => array(),
'em' => array(),
'strong' => array(),
'div' => array( 'class' => array() ),
'span' => array( 'class' => array() ),
'p' => array(),
'br' => array(),
'ul' => array(),
'ol' => array(),
'li' => array(),
'h1' => array(),
'h2' => array(),
'h3' => array(),
'h4' => array(),
'h5' => array(),
'h6' => array(),
'img' => array(
'src' => array(),
'class' => array(),
'alt' => array(),
),
'blockquote' => array( 'cite' => true ),
);
@ -497,7 +539,7 @@ function install_plugin_information() {
'screenshots' => _x( 'Screenshots', 'Plugin installer section title' ),
'changelog' => _x( 'Changelog', 'Plugin installer section title' ),
'reviews' => _x( 'Reviews', 'Plugin installer section title' ),
'other_notes' => _x( 'Other Notes', 'Plugin installer section title' )
'other_notes' => _x( 'Other Notes', 'Plugin installer section title' ),
);
// Sanitize HTML
@ -557,7 +599,12 @@ function install_plugin_information() {
}
$class = ( $section_name === $section ) ? ' class="current"' : '';
$href = add_query_arg( array('tab' => $tab, 'section' => $section_name) );
$href = add_query_arg(
array(
'tab' => $tab,
'section' => $section_name,
)
);
$href = esc_url( $href );
$san_section = esc_attr( $section_name );
echo "\t<a name='$san_section' href='$href' $class>$title</a>\n";
@ -591,7 +638,8 @@ function install_plugin_information() {
<?php } if ( ! empty( $api->tested ) ) { ?>
<li><strong><?php _e( 'Compatible up to:' ); ?></strong> <?php echo $api->tested; ?></li>
<?php } if ( isset( $api->active_installs ) ) { ?>
<li><strong><?php _e( 'Active Installations:' ); ?></strong> <?php
<li><strong><?php _e( 'Active Installations:' ); ?></strong>
<?php
if ( $api->active_installs >= 1000000 ) {
_ex( '1+ Million', 'Active plugin installations' );
} elseif ( 0 == $api->active_installs ) {
@ -599,7 +647,8 @@ function install_plugin_information() {
} else {
echo number_format_i18n( $api->active_installs ) . '+';
}
?></li>
?>
</li>
<?php } if ( ! empty( $api->slug ) && empty( $api->external ) ) { ?>
<li><a target="_blank" href="<?php echo __( 'https://wordpress.org/plugins/' ) . $api->slug; ?>/"><?php _e( 'WordPress.org Plugin Page &#187;' ); ?></a></li>
<?php } if ( ! empty( $api->homepage ) ) { ?>
@ -610,11 +659,21 @@ function install_plugin_information() {
</ul>
<?php if ( ! empty( $api->rating ) ) { ?>
<h3><?php _e( 'Average Rating' ); ?></h3>
<?php wp_star_rating( array( 'rating' => $api->rating, 'type' => 'percent', 'number' => $api->num_ratings ) ); ?>
<?php
wp_star_rating(
array(
'rating' => $api->rating,
'type' => 'percent',
'number' => $api->num_ratings,
)
);
?>
<p aria-hidden="true" class="fyi-description"><?php printf( _n( '(based on %s rating)', '(based on %s ratings)', $api->num_ratings ), number_format_i18n( $api->num_ratings ) ); ?></p>
<?php }
<?php
}
if ( ! empty( $api->ratings ) && array_sum( (array) $api->ratings ) > 0 ) { ?>
if ( ! empty( $api->ratings ) && array_sum( (array) $api->ratings ) > 0 ) {
?>
<h3><?php _e( 'Reviews' ); ?></h3>
<p class="fyi-description"><?php _e( 'Read all reviews on WordPress.org or write your own!' ); ?></p>
<?php
@ -622,10 +681,13 @@ function install_plugin_information() {
// Avoid div-by-zero.
$_rating = $api->num_ratings ? ( $ratecount / $api->num_ratings ) : 0;
/* translators: 1: number of stars (used to determine singular/plural), 2: number of reviews */
$aria_label = esc_attr( sprintf( _n( 'Reviews with %1$d star: %2$s. Opens in a new window.', 'Reviews with %1$d stars: %2$s. Opens in a new window.', $key ),
$aria_label = esc_attr(
sprintf(
_n( 'Reviews with %1$d star: %2$s. Opens in a new window.', 'Reviews with %1$d stars: %2$s. Opens in a new window.', $key ),
$key,
number_format_i18n( $ratecount )
) );
)
);
?>
<div class="counter-container">
<span class="counter-label">
@ -640,7 +702,8 @@ function install_plugin_information() {
<?php
}
}
if ( ! empty( $api->contributors ) ) { ?>
if ( ! empty( $api->contributors ) ) {
?>
<h3><?php _e( 'Contributors' ); ?></h3>
<ul class="contributors">
<?php

View File

@ -136,10 +136,11 @@ function _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup
$textdomain = 'default';
}
if ( $textdomain ) {
foreach ( array( 'Name', 'PluginURI', 'Description', 'Author', 'AuthorURI', 'Version' ) as $field )
foreach ( array( 'Name', 'PluginURI', 'Description', 'Author', 'AuthorURI', 'Version' ) as $field ) {
$plugin_data[ $field ] = translate( $plugin_data[ $field ], $textdomain );
}
}
}
// Sanitize fields
$allowed_tags = $allowed_tags_in_links = array(
@ -149,7 +150,10 @@ function _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup
'em' => true,
'strong' => true,
);
$allowed_tags['a'] = array( 'href' => true, 'title' => true );
$allowed_tags['a'] = array(
'href' => true,
'title' => true,
);
// Name is marked up inside <a> tags. Don't allow these.
// Author is too, but some plugins have used <a> here (omitting Author URI).
@ -167,17 +171,20 @@ function _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup
// Apply markup
if ( $markup ) {
if ( $plugin_data['PluginURI'] && $plugin_data['Name'] )
if ( $plugin_data['PluginURI'] && $plugin_data['Name'] ) {
$plugin_data['Title'] = '<a href="' . $plugin_data['PluginURI'] . '">' . $plugin_data['Name'] . '</a>';
}
if ( $plugin_data['AuthorURI'] && $plugin_data['Author'] )
if ( $plugin_data['AuthorURI'] && $plugin_data['Author'] ) {
$plugin_data['Author'] = '<a href="' . $plugin_data['AuthorURI'] . '">' . $plugin_data['Author'] . '</a>';
}
$plugin_data['Description'] = wptexturize( $plugin_data['Description'] );
if ( $plugin_data['Author'] )
if ( $plugin_data['Author'] ) {
$plugin_data['Description'] .= ' <cite>' . sprintf( __( 'By %s.' ), $plugin_data['Author'] ) . '</cite>';
}
}
return $plugin_data;
}
@ -239,54 +246,64 @@ function get_plugin_files( $plugin ) {
*/
function get_plugins( $plugin_folder = '' ) {
if ( ! $cache_plugins = wp_cache_get('plugins', 'plugins') )
if ( ! $cache_plugins = wp_cache_get( 'plugins', 'plugins' ) ) {
$cache_plugins = array();
}
if ( isset($cache_plugins[ $plugin_folder ]) )
if ( isset( $cache_plugins[ $plugin_folder ] ) ) {
return $cache_plugins[ $plugin_folder ];
}
$wp_plugins = array();
$plugin_root = WP_PLUGIN_DIR;
if ( !empty($plugin_folder) )
if ( ! empty( $plugin_folder ) ) {
$plugin_root .= $plugin_folder;
}
// Files in wp-content/plugins directory
$plugins_dir = @ opendir( $plugin_root );
$plugin_files = array();
if ( $plugins_dir ) {
while ( ( $file = readdir( $plugins_dir ) ) !== false ) {
if ( substr($file, 0, 1) == '.' )
if ( substr( $file, 0, 1 ) == '.' ) {
continue;
}
if ( is_dir( $plugin_root . '/' . $file ) ) {
$plugins_subdir = @ opendir( $plugin_root . '/' . $file );
if ( $plugins_subdir ) {
while ( ( $subfile = readdir( $plugins_subdir ) ) !== false ) {
if ( substr($subfile, 0, 1) == '.' )
if ( substr( $subfile, 0, 1 ) == '.' ) {
continue;
if ( substr($subfile, -4) == '.php' )
}
if ( substr( $subfile, -4 ) == '.php' ) {
$plugin_files[] = "$file/$subfile";
}
}
closedir( $plugins_subdir );
}
} else {
if ( substr($file, -4) == '.php' )
if ( substr( $file, -4 ) == '.php' ) {
$plugin_files[] = $file;
}
}
}
closedir( $plugins_dir );
}
if ( empty($plugin_files) )
if ( empty( $plugin_files ) ) {
return $wp_plugins;
}
foreach ( $plugin_files as $plugin_file ) {
if ( !is_readable( "$plugin_root/$plugin_file" ) )
if ( ! is_readable( "$plugin_root/$plugin_file" ) ) {
continue;
}
$plugin_data = get_plugin_data( "$plugin_root/$plugin_file", false, false ); //Do not apply markup/translate as it'll be cached.
if ( empty ( $plugin_data['Name'] ) )
if ( empty( $plugin_data['Name'] ) ) {
continue;
}
$wp_plugins[ plugin_basename( $plugin_file ) ] = $plugin_data;
}
@ -312,36 +329,42 @@ function get_mu_plugins() {
// Files in wp-content/mu-plugins directory
$plugin_files = array();
if ( ! is_dir( WPMU_PLUGIN_DIR ) )
if ( ! is_dir( WPMU_PLUGIN_DIR ) ) {
return $wp_plugins;
}
if ( $plugins_dir = @ opendir( WPMU_PLUGIN_DIR ) ) {
while ( ( $file = readdir( $plugins_dir ) ) !== false ) {
if ( substr( $file, -4 ) == '.php' )
if ( substr( $file, -4 ) == '.php' ) {
$plugin_files[] = $file;
}
}
} else {
return $wp_plugins;
}
@closedir( $plugins_dir );
if ( empty($plugin_files) )
if ( empty( $plugin_files ) ) {
return $wp_plugins;
}
foreach ( $plugin_files as $plugin_file ) {
if ( !is_readable( WPMU_PLUGIN_DIR . "/$plugin_file" ) )
if ( ! is_readable( WPMU_PLUGIN_DIR . "/$plugin_file" ) ) {
continue;
}
$plugin_data = get_plugin_data( WPMU_PLUGIN_DIR . "/$plugin_file", false, false ); //Do not apply markup/translate as it'll be cached.
if ( empty ( $plugin_data['Name'] ) )
if ( empty( $plugin_data['Name'] ) ) {
$plugin_data['Name'] = $plugin_file;
}
$wp_plugins[ $plugin_file ] = $plugin_data;
}
if ( isset( $wp_plugins['index.php'] ) && filesize( WPMU_PLUGIN_DIR . '/index.php') <= 30 ) // silence is golden
if ( isset( $wp_plugins['index.php'] ) && filesize( WPMU_PLUGIN_DIR . '/index.php' ) <= 30 ) { // silence is golden
unset( $wp_plugins['index.php'] );
}
uasort( $wp_plugins, '_sort_uname_callback' );
@ -373,24 +396,28 @@ function get_dropins() {
// These exist in the wp-content directory
if ( $plugins_dir = @ opendir( WP_CONTENT_DIR ) ) {
while ( ( $file = readdir( $plugins_dir ) ) !== false ) {
if ( isset( $_dropins[ $file ] ) )
if ( isset( $_dropins[ $file ] ) ) {
$plugin_files[] = $file;
}
}
} else {
return $dropins;
}
@closedir( $plugins_dir );
if ( empty($plugin_files) )
if ( empty( $plugin_files ) ) {
return $dropins;
}
foreach ( $plugin_files as $plugin_file ) {
if ( !is_readable( WP_CONTENT_DIR . "/$plugin_file" ) )
if ( ! is_readable( WP_CONTENT_DIR . "/$plugin_file" ) ) {
continue;
}
$plugin_data = get_plugin_data( WP_CONTENT_DIR . "/$plugin_file", false, false ); //Do not apply markup/translate as it'll be cached.
if ( empty( $plugin_data['Name'] ) )
if ( empty( $plugin_data['Name'] ) ) {
$plugin_data['Name'] = $plugin_file;
}
$dropins[ $plugin_file ] = $plugin_data;
}
@ -475,12 +502,14 @@ function is_plugin_inactive( $plugin ) {
* @return bool True, if active for the network, otherwise false.
*/
function is_plugin_active_for_network( $plugin ) {
if ( !is_multisite() )
if ( ! is_multisite() ) {
return false;
}
$plugins = get_site_option( 'active_sitewide_plugins' );
if ( isset($plugins[$plugin]) )
if ( isset( $plugins[ $plugin ] ) ) {
return true;
}
return false;
}
@ -499,8 +528,9 @@ function is_plugin_active_for_network( $plugin ) {
*/
function is_network_only_plugin( $plugin ) {
$plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
if ( $plugin_data )
if ( $plugin_data ) {
return $plugin_data['Network'];
}
return false;
}
@ -543,12 +573,14 @@ function activate_plugin( $plugin, $redirect = '', $network_wide = false, $silen
}
$valid = validate_plugin( $plugin );
if ( is_wp_error($valid) )
if ( is_wp_error( $valid ) ) {
return $valid;
}
if ( ( $network_wide && ! isset( $current[ $plugin ] ) ) || ( ! $network_wide && ! in_array( $plugin, $current ) ) ) {
if ( !empty($redirect) )
if ( ! empty( $redirect ) ) {
wp_redirect( add_query_arg( '_error_nonce', wp_create_nonce( 'plugin-activation-error_' . $plugin ), $redirect ) ); // we'll override this later if the plugin can be included without fatal error
}
ob_start();
wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $plugin );
$_wp_plugin_file = $plugin;
@ -637,15 +669,17 @@ function activate_plugin( $plugin, $redirect = '', $network_wide = false, $silen
* A value of null (the default) will deactivate plugins for both the site and the network.
*/
function deactivate_plugins( $plugins, $silent = false, $network_wide = null ) {
if ( is_multisite() )
if ( is_multisite() ) {
$network_current = get_site_option( 'active_sitewide_plugins', array() );
}
$current = get_option( 'active_plugins', array() );
$do_blog = $do_network = false;
foreach ( (array) $plugins as $plugin ) {
$plugin = plugin_basename( trim( $plugin ) );
if ( ! is_plugin_active($plugin) )
if ( ! is_plugin_active( $plugin ) ) {
continue;
}
$network_deactivating = false !== $network_wide && is_plugin_active_for_network( $plugin );
@ -714,11 +748,13 @@ function deactivate_plugins( $plugins, $silent = false, $network_wide = null ) {
}
}
if ( $do_blog )
if ( $do_blog ) {
update_option( 'active_plugins', $current );
if ( $do_network )
}
if ( $do_network ) {
update_site_option( 'active_sitewide_plugins', $network_current );
}
}
/**
* Activate multiple plugins.
@ -737,20 +773,24 @@ function deactivate_plugins( $plugins, $silent = false, $network_wide = null ) {
* @return bool|WP_Error True when finished or WP_Error if there were errors during a plugin activation.
*/
function activate_plugins( $plugins, $redirect = '', $network_wide = false, $silent = false ) {
if ( !is_array($plugins) )
if ( ! is_array( $plugins ) ) {
$plugins = array( $plugins );
}
$errors = array();
foreach ( $plugins as $plugin ) {
if ( !empty($redirect) )
if ( ! empty( $redirect ) ) {
$redirect = add_query_arg( 'plugin', $plugin, $redirect );
}
$result = activate_plugin( $plugin, $redirect, $network_wide, $silent );
if ( is_wp_error($result) )
if ( is_wp_error( $result ) ) {
$errors[ $plugin ] = $result;
}
}
if ( !empty($errors) )
if ( ! empty( $errors ) ) {
return new WP_Error( 'plugins_invalid', __( 'One of the plugins is invalid.' ), $errors );
}
return true;
}
@ -770,12 +810,14 @@ function activate_plugins( $plugins, $redirect = '', $network_wide = false, $sil
function delete_plugins( $plugins, $deprecated = '' ) {
global $wp_filesystem;
if ( empty($plugins) )
if ( empty( $plugins ) ) {
return false;
}
$checked = array();
foreach ( $plugins as $plugin )
foreach ( $plugins as $plugin ) {
$checked[] = 'checked[]=' . $plugin;
}
$url = wp_nonce_url( 'plugins.php?action=delete-selected&verify-delete=1&' . implode( '&', $checked ), 'bulk-plugins' );
@ -807,11 +849,13 @@ function delete_plugins( $plugins, $deprecated = '' ) {
return;
}
if ( ! is_object($wp_filesystem) )
if ( ! is_object( $wp_filesystem ) ) {
return new WP_Error( 'fs_unavailable', __( 'Could not access filesystem.' ) );
}
if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() )
if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
return new WP_Error( 'fs_error', __( 'Filesystem error.' ), $wp_filesystem->errors );
}
// Get the base plugin folder.
$plugins_dir = $wp_filesystem->wp_plugins_dir();
@ -925,8 +969,9 @@ function validate_active_plugins() {
$plugins = array_merge( $plugins, array_keys( $network_plugins ) );
}
if ( empty( $plugins ) )
if ( empty( $plugins ) ) {
return array();
}
$invalid = array();
@ -952,14 +997,17 @@ function validate_active_plugins() {
* @return WP_Error|int 0 on success, WP_Error on failure.
*/
function validate_plugin( $plugin ) {
if ( validate_file($plugin) )
if ( validate_file( $plugin ) ) {
return new WP_Error( 'plugin_invalid', __( 'Invalid plugin path.' ) );
if ( ! file_exists(WP_PLUGIN_DIR . '/' . $plugin) )
}
if ( ! file_exists( WP_PLUGIN_DIR . '/' . $plugin ) ) {
return new WP_Error( 'plugin_not_found', __( 'Plugin file does not exist.' ) );
}
$installed_plugins = get_plugins();
if ( ! isset($installed_plugins[$plugin]) )
if ( ! isset( $installed_plugins[ $plugin ] ) ) {
return new WP_Error( 'no_plugin_header', __( 'The plugin does not have a valid header.' ) );
}
return 0;
}
@ -975,8 +1023,9 @@ function is_uninstallable_plugin($plugin) {
$file = plugin_basename( $plugin );
$uninstallable_plugins = (array) get_option( 'uninstall_plugins' );
if ( isset( $uninstallable_plugins[$file] ) || file_exists( WP_PLUGIN_DIR . '/' . dirname($file) . '/uninstall.php' ) )
if ( isset( $uninstallable_plugins[ $file ] ) || file_exists( WP_PLUGIN_DIR . '/' . dirname( $file ) . '/uninstall.php' ) ) {
return true;
}
return false;
}
@ -1086,8 +1135,9 @@ function add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $func
$hookname = get_plugin_page_hookname( $menu_slug, '' );
if ( !empty( $function ) && !empty( $hookname ) && current_user_can( $capability ) )
if ( ! empty( $function ) && ! empty( $hookname ) && current_user_can( $capability ) ) {
add_action( $hookname, $function );
}
if ( empty( $icon_url ) ) {
$icon_url = 'dashicons-admin-generic';
@ -1151,8 +1201,9 @@ function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability,
$menu_slug = plugin_basename( $menu_slug );
$parent_slug = plugin_basename( $parent_slug );
if ( isset( $_wp_real_parent_file[$parent_slug] ) )
if ( isset( $_wp_real_parent_file[ $parent_slug ] ) ) {
$parent_slug = $_wp_real_parent_file[ $parent_slug ];
}
if ( ! current_user_can( $capability ) ) {
$_wp_submenu_nopriv[ $parent_slug ][ $menu_slug ] = true;
@ -1167,16 +1218,18 @@ function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability,
*/
if ( ! isset( $submenu[ $parent_slug ] ) && $menu_slug != $parent_slug ) {
foreach ( (array) $menu as $parent_menu ) {
if ( $parent_menu[2] == $parent_slug && current_user_can( $parent_menu[1] ) )
if ( $parent_menu[2] == $parent_slug && current_user_can( $parent_menu[1] ) ) {
$submenu[ $parent_slug ][] = array_slice( $parent_menu, 0, 4 );
}
}
}
$submenu[ $parent_slug ][] = array( $menu_title, $capability, $menu_slug, $page_title );
$hookname = get_plugin_page_hookname( $menu_slug, $parent_slug );
if (!empty ( $function ) && !empty ( $hookname ))
if ( ! empty( $function ) && ! empty( $hookname ) ) {
add_action( $hookname, $function );
}
$_registered_pages[ $hookname ] = true;
@ -1184,8 +1237,9 @@ function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability,
* Backward-compatibility for plugins using add_management page.
* See wp-admin/admin.php for redirect from edit.php to tools.php
*/
if ( 'tools.php' == $parent_slug )
if ( 'tools.php' == $parent_slug ) {
$_registered_pages[ get_plugin_page_hookname( $menu_slug, 'edit.php' ) ] = true;
}
// No parent as top level.
$_parent_pages[ $menu_slug ] = $parent_slug;
@ -1290,10 +1344,11 @@ function add_plugins_page( $page_title, $menu_title, $capability, $menu_slug, $f
* @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required.
*/
function add_users_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
if ( current_user_can('edit_users') )
if ( current_user_can( 'edit_users' ) ) {
$parent = 'users.php';
else
} else {
$parent = 'profile.php';
}
return add_submenu_page( $parent, $page_title, $menu_title, $capability, $menu_slug, $function );
}
/**
@ -1453,8 +1508,9 @@ function remove_menu_page( $menu_slug ) {
function remove_submenu_page( $menu_slug, $submenu_slug ) {
global $submenu;
if ( !isset( $submenu[$menu_slug] ) )
if ( ! isset( $submenu[ $menu_slug ] ) ) {
return false;
}
foreach ( $submenu[ $menu_slug ] as $i => $item ) {
if ( $submenu_slug == $item[2] ) {
@ -1495,8 +1551,9 @@ function menu_page_url($menu_slug, $echo = true) {
$url = esc_url( $url );
if ( $echo )
if ( $echo ) {
echo $url;
}
return $url;
}
@ -1505,7 +1562,6 @@ function menu_page_url($menu_slug, $echo = true) {
// Pluggable Menu Support -- Private
//
/**
*
* @global string $parent_file
* @global array $menu
* @global array $submenu
@ -1521,8 +1577,9 @@ function get_admin_page_parent( $parent = '' ) {
$plugin_page, $_wp_real_parent_file, $_wp_menu_nopriv, $_wp_submenu_nopriv;
if ( ! empty( $parent ) && 'admin.php' != $parent ) {
if ( isset( $_wp_real_parent_file[$parent] ) )
if ( isset( $_wp_real_parent_file[ $parent ] ) ) {
$parent = $_wp_real_parent_file[ $parent ];
}
return $parent;
}
@ -1530,30 +1587,34 @@ function get_admin_page_parent( $parent = '' ) {
foreach ( (array) $menu as $parent_menu ) {
if ( $parent_menu[2] == $plugin_page ) {
$parent_file = $plugin_page;
if ( isset( $_wp_real_parent_file[$parent_file] ) )
if ( isset( $_wp_real_parent_file[ $parent_file ] ) ) {
$parent_file = $_wp_real_parent_file[ $parent_file ];
}
return $parent_file;
}
}
if ( isset( $_wp_menu_nopriv[ $plugin_page ] ) ) {
$parent_file = $plugin_page;
if ( isset( $_wp_real_parent_file[$parent_file] ) )
if ( isset( $_wp_real_parent_file[ $parent_file ] ) ) {
$parent_file = $_wp_real_parent_file[ $parent_file ];
}
return $parent_file;
}
}
if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[ $pagenow ][ $plugin_page ] ) ) {
$parent_file = $pagenow;
if ( isset( $_wp_real_parent_file[$parent_file] ) )
if ( isset( $_wp_real_parent_file[ $parent_file ] ) ) {
$parent_file = $_wp_real_parent_file[ $parent_file ];
}
return $parent_file;
}
foreach ( array_keys( (array) $submenu ) as $parent ) {
foreach ( $submenu[ $parent ] as $submenu_array ) {
if ( isset( $_wp_real_parent_file[$parent] ) )
if ( isset( $_wp_real_parent_file[ $parent ] ) ) {
$parent = $_wp_real_parent_file[ $parent ];
}
if ( ! empty( $typenow ) && ( $submenu_array[2] == "$pagenow?post_type=$typenow" ) ) {
$parent_file = $parent;
return $parent;
@ -1567,13 +1628,13 @@ function get_admin_page_parent( $parent = '' ) {
}
}
if ( empty($parent_file) )
if ( empty( $parent_file ) ) {
$parent_file = '';
}
return '';
}
/**
*
* @global string $title
* @global array $menu
* @global array $submenu
@ -1584,8 +1645,9 @@ function get_admin_page_parent( $parent = '' ) {
function get_admin_page_title() {
global $title, $menu, $submenu, $pagenow, $plugin_page, $typenow;
if ( ! empty ( $title ) )
if ( ! empty( $title ) ) {
return $title;
}
$hook = get_plugin_page_hook( $plugin_page, $pagenow );
@ -1623,8 +1685,9 @@ function get_admin_page_title() {
return $submenu_array[3];
}
if ( $submenu_array[2] != $pagenow || isset( $_GET['page'] ) ) // not the current page
if ( $submenu_array[2] != $pagenow || isset( $_GET['page'] ) ) { // not the current page
continue;
}
if ( isset( $submenu_array[3] ) ) {
$title = $submenu_array[3];
@ -1640,8 +1703,7 @@ function get_admin_page_title() {
if ( isset( $plugin_page ) &&
( $plugin_page == $menu_array[2] ) &&
( $pagenow == 'admin.php' ) &&
( $parent1 == $menu_array[2] ) )
{
( $parent1 == $menu_array[2] ) ) {
$title = $menu_array[3];
return $menu_array[3];
}
@ -1661,14 +1723,14 @@ function get_admin_page_title() {
*/
function get_plugin_page_hook( $plugin_page, $parent_page ) {
$hook = get_plugin_page_hookname( $plugin_page, $parent_page );
if ( has_action($hook) )
if ( has_action( $hook ) ) {
return $hook;
else
} else {
return null;
}
}
/**
*
* @global array $admin_page_hooks
* @param string $plugin_page
* @param string $parent_page
@ -1695,7 +1757,6 @@ function get_plugin_page_hookname( $plugin_page, $parent_page ) {
}
/**
*
* @global string $pagenow
* @global array $menu
* @global array $submenu
@ -1710,64 +1771,77 @@ function user_can_access_admin_page() {
$parent = get_admin_page_parent();
if ( !isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$parent][$pagenow] ) )
return false;
if ( isset( $plugin_page ) ) {
if ( isset( $_wp_submenu_nopriv[$parent][$plugin_page] ) )
return false;
$hookname = get_plugin_page_hookname($plugin_page, $parent);
if ( !isset($_registered_pages[$hookname]) )
if ( ! isset( $plugin_page ) && isset( $_wp_submenu_nopriv[ $parent ][ $pagenow ] ) ) {
return false;
}
if ( isset( $plugin_page ) ) {
if ( isset( $_wp_submenu_nopriv[ $parent ][ $plugin_page ] ) ) {
return false;
}
$hookname = get_plugin_page_hookname( $plugin_page, $parent );
if ( ! isset( $_registered_pages[ $hookname ] ) ) {
return false;
}
}
if ( empty( $parent ) ) {
if ( isset( $_wp_menu_nopriv[$pagenow] ) )
if ( isset( $_wp_menu_nopriv[ $pagenow ] ) ) {
return false;
if ( isset( $_wp_submenu_nopriv[$pagenow][$pagenow] ) )
}
if ( isset( $_wp_submenu_nopriv[ $pagenow ][ $pagenow ] ) ) {
return false;
if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$pagenow][$plugin_page] ) )
}
if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[ $pagenow ][ $plugin_page ] ) ) {
return false;
if ( isset( $plugin_page ) && isset( $_wp_menu_nopriv[$plugin_page] ) )
}
if ( isset( $plugin_page ) && isset( $_wp_menu_nopriv[ $plugin_page ] ) ) {
return false;
}
foreach ( array_keys( $_wp_submenu_nopriv ) as $key ) {
if ( isset( $_wp_submenu_nopriv[$key][$pagenow] ) )
if ( isset( $_wp_submenu_nopriv[ $key ][ $pagenow ] ) ) {
return false;
if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$key][$plugin_page] ) )
}
if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[ $key ][ $plugin_page ] ) ) {
return false;
}
}
return true;
}
if ( isset( $plugin_page ) && ( $plugin_page == $parent ) && isset( $_wp_menu_nopriv[$plugin_page] ) )
if ( isset( $plugin_page ) && ( $plugin_page == $parent ) && isset( $_wp_menu_nopriv[ $plugin_page ] ) ) {
return false;
}
if ( isset( $submenu[ $parent ] ) ) {
foreach ( $submenu[ $parent ] as $submenu_array ) {
if ( isset( $plugin_page ) && ( $submenu_array[2] == $plugin_page ) ) {
if ( current_user_can( $submenu_array[1] ))
if ( current_user_can( $submenu_array[1] ) ) {
return true;
else
} else {
return false;
}
} elseif ( $submenu_array[2] == $pagenow ) {
if ( current_user_can( $submenu_array[1] ))
if ( current_user_can( $submenu_array[1] ) ) {
return true;
else
} else {
return false;
}
}
}
}
foreach ( $menu as $menu_array ) {
if ( $menu_array[2] == $parent ) {
if ( current_user_can( $menu_array[1] ))
if ( current_user_can( $menu_array[1] ) ) {
return true;
else
} else {
return false;
}
}
}
return true;
}
@ -1789,8 +1863,9 @@ function user_can_access_admin_page() {
function option_update_filter( $options ) {
global $new_whitelist_options;
if ( is_array( $new_whitelist_options ) )
if ( is_array( $new_whitelist_options ) ) {
$options = add_option_whitelist( $new_whitelist_options, $options );
}
return $options;
}
@ -1807,10 +1882,11 @@ function option_update_filter( $options ) {
* @return array
*/
function add_option_whitelist( $new_options, $options = '' ) {
if ( $options == '' )
if ( $options == '' ) {
global $whitelist_options;
else
} else {
$whitelist_options = $options;
}
foreach ( $new_options as $page => $keys ) {
foreach ( $keys as $key ) {
@ -1819,11 +1895,12 @@ function add_option_whitelist( $new_options, $options = '' ) {
$whitelist_options[ $page ][] = $key;
} else {
$pos = array_search( $key, $whitelist_options[ $page ] );
if ( $pos === false )
if ( $pos === false ) {
$whitelist_options[ $page ][] = $key;
}
}
}
}
return $whitelist_options;
}
@ -1840,20 +1917,22 @@ function add_option_whitelist( $new_options, $options = '' ) {
* @return array
*/
function remove_option_whitelist( $del_options, $options = '' ) {
if ( $options == '' )
if ( $options == '' ) {
global $whitelist_options;
else
} else {
$whitelist_options = $options;
}
foreach ( $del_options as $page => $keys ) {
foreach ( $keys as $key ) {
if ( isset( $whitelist_options[ $page ] ) && is_array( $whitelist_options[ $page ] ) ) {
$pos = array_search( $key, $whitelist_options[ $page ] );
if ( $pos !== false )
if ( $pos !== false ) {
unset( $whitelist_options[ $page ][ $pos ] );
}
}
}
}
return $whitelist_options;
}
@ -1879,8 +1958,9 @@ function settings_fields($option_group) {
* @param bool $clear_update_cache Whether to clear the Plugin updates cache
*/
function wp_clean_plugins_cache( $clear_update_cache = true ) {
if ( $clear_update_cache )
if ( $clear_update_cache ) {
delete_site_transient( 'update_plugins' );
}
wp_cache_delete( 'plugins', 'plugins' );
}

View File

@ -19,37 +19,45 @@
*/
function _wp_translate_postdata( $update = false, $post_data = null ) {
if ( empty($post_data) )
if ( empty( $post_data ) ) {
$post_data = &$_POST;
}
if ( $update )
if ( $update ) {
$post_data['ID'] = (int) $post_data['post_ID'];
}
$ptype = get_post_type_object( $post_data['post_type'] );
if ( $update && ! current_user_can( 'edit_post', $post_data['ID'] ) ) {
if ( 'page' == $post_data['post_type'] )
if ( 'page' == $post_data['post_type'] ) {
return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to edit pages as this user.' ) );
else
} else {
return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to edit posts as this user.' ) );
}
} elseif ( ! $update && ! current_user_can( $ptype->cap->create_posts ) ) {
if ( 'page' == $post_data['post_type'] )
if ( 'page' == $post_data['post_type'] ) {
return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to create pages as this user.' ) );
else
} else {
return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to create posts as this user.' ) );
}
}
if ( isset( $post_data['content'] ) )
if ( isset( $post_data['content'] ) ) {
$post_data['post_content'] = $post_data['content'];
}
if ( isset( $post_data['excerpt'] ) )
if ( isset( $post_data['excerpt'] ) ) {
$post_data['post_excerpt'] = $post_data['excerpt'];
}
if ( isset( $post_data['parent_id'] ) )
if ( isset( $post_data['parent_id'] ) ) {
$post_data['post_parent'] = (int) $post_data['parent_id'];
}
if ( isset($post_data['trackback_url']) )
if ( isset( $post_data['trackback_url'] ) ) {
$post_data['to_ping'] = $post_data['trackback_url'];
}
$post_data['user_ID'] = get_current_user_id();
@ -67,17 +75,19 @@ function _wp_translate_postdata( $update = false, $post_data = null ) {
&& ! current_user_can( $ptype->cap->edit_others_posts ) ) {
if ( $update ) {
if ( 'page' == $post_data['post_type'] )
if ( 'page' == $post_data['post_type'] ) {
return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to edit pages as this user.' ) );
else
return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to edit posts as this user.' ) );
} else {
if ( 'page' == $post_data['post_type'] )
return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to edit posts as this user.' ) );
}
} else {
if ( 'page' == $post_data['post_type'] ) {
return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to create pages as this user.' ) );
else
} else {
return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to create posts as this user.' ) );
}
}
}
if ( ! empty( $post_data['post_status'] ) ) {
$post_data['post_status'] = sanitize_key( $post_data['post_status'] );
@ -93,21 +103,27 @@ function _wp_translate_postdata( $update = false, $post_data = null ) {
}
// What to do based on which button they pressed
if ( isset($post_data['saveasdraft']) && '' != $post_data['saveasdraft'] )
if ( isset( $post_data['saveasdraft'] ) && '' != $post_data['saveasdraft'] ) {
$post_data['post_status'] = 'draft';
if ( isset($post_data['saveasprivate']) && '' != $post_data['saveasprivate'] )
}
if ( isset( $post_data['saveasprivate'] ) && '' != $post_data['saveasprivate'] ) {
$post_data['post_status'] = 'private';
if ( isset($post_data['publish']) && ( '' != $post_data['publish'] ) && ( !isset($post_data['post_status']) || $post_data['post_status'] != 'private' ) )
}
if ( isset( $post_data['publish'] ) && ( '' != $post_data['publish'] ) && ( ! isset( $post_data['post_status'] ) || $post_data['post_status'] != 'private' ) ) {
$post_data['post_status'] = 'publish';
if ( isset($post_data['advanced']) && '' != $post_data['advanced'] )
}
if ( isset( $post_data['advanced'] ) && '' != $post_data['advanced'] ) {
$post_data['post_status'] = 'draft';
if ( isset($post_data['pending']) && '' != $post_data['pending'] )
}
if ( isset( $post_data['pending'] ) && '' != $post_data['pending'] ) {
$post_data['post_status'] = 'pending';
}
if ( isset( $post_data['ID'] ) )
if ( isset( $post_data['ID'] ) ) {
$post_id = $post_data['ID'];
else
} else {
$post_id = false;
}
$previous_status = $post_id ? get_post_field( 'post_status', $post_id ) : false;
if ( isset( $post_data['post_status'] ) && 'private' == $post_data['post_status'] && ! current_user_can( $ptype->cap->publish_posts ) ) {
@ -118,9 +134,11 @@ function _wp_translate_postdata( $update = false, $post_data = null ) {
// Posts 'submitted for approval' present are submitted to $_POST the same as if they were being published.
// Change status from 'publish' to 'pending' if user lacks permissions to publish or to resave published posts.
if ( isset($post_data['post_status']) && (in_array( $post_data['post_status'], $published_statuses ) && !current_user_can( $ptype->cap->publish_posts )) )
if ( ! in_array( $previous_status, $published_statuses ) || !current_user_can( 'edit_post', $post_id ) )
if ( isset( $post_data['post_status'] ) && ( in_array( $post_data['post_status'], $published_statuses ) && ! current_user_can( $ptype->cap->publish_posts ) ) ) {
if ( ! in_array( $previous_status, $published_statuses ) || ! current_user_can( 'edit_post', $post_id ) ) {
$post_data['post_status'] = 'pending';
}
}
if ( ! isset( $post_data['post_status'] ) ) {
$post_data['post_status'] = 'auto-draft' === $previous_status ? 'draft' : $previous_status;
@ -130,11 +148,13 @@ function _wp_translate_postdata( $update = false, $post_data = null ) {
unset( $post_data['post_password'] );
}
if (!isset( $post_data['comment_status'] ))
if ( ! isset( $post_data['comment_status'] ) ) {
$post_data['comment_status'] = 'closed';
}
if (!isset( $post_data['ping_status'] ))
if ( ! isset( $post_data['ping_status'] ) ) {
$post_data['ping_status'] = 'closed';
}
foreach ( array( 'aa', 'mm', 'jj', 'hh', 'mn' ) as $timeunit ) {
if ( ! empty( $post_data[ 'hidden_' . $timeunit ] ) && $post_data[ 'hidden_' . $timeunit ] != $post_data[ $timeunit ] ) {
@ -157,7 +177,7 @@ function _wp_translate_postdata( $update = false, $post_data = null ) {
$hh = ( $hh > 23 ) ? $hh - 24 : $hh;
$mn = ( $mn > 59 ) ? $mn - 60 : $mn;
$ss = ( $ss > 59 ) ? $ss - 60 : $ss;
$post_data['post_date'] = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss );
$post_data['post_date'] = sprintf( '%04d-%02d-%02d %02d:%02d:%02d', $aa, $mm, $jj, $hh, $mn, $ss );
$valid_date = wp_checkdate( $mm, $jj, $aa, $post_data['post_date'] );
if ( ! $valid_date ) {
return new WP_Error( 'invalid_date', __( 'Invalid date.' ) );
@ -188,8 +208,9 @@ function _wp_translate_postdata( $update = false, $post_data = null ) {
function edit_post( $post_data = null ) {
global $wpdb;
if ( empty($post_data) )
if ( empty( $post_data ) ) {
$post_data = &$_POST;
}
// Clear out any data in internal vars.
unset( $post_data['filter'] );
@ -209,20 +230,27 @@ function edit_post( $post_data = null ) {
$ptype = get_post_type_object( $post_data['post_type'] );
if ( ! current_user_can( 'edit_post', $post_ID ) ) {
if ( 'page' == $post_data['post_type'] )
if ( 'page' == $post_data['post_type'] ) {
wp_die( __( 'Sorry, you are not allowed to edit this page.' ) );
else
} else {
wp_die( __( 'Sorry, you are not allowed to edit this post.' ) );
}
}
if ( post_type_supports( $ptype->name, 'revisions' ) ) {
$revisions = wp_get_post_revisions( $post_ID, array( 'order' => 'ASC', 'posts_per_page' => 1 ) );
$revisions = wp_get_post_revisions(
$post_ID, array(
'order' => 'ASC',
'posts_per_page' => 1,
)
);
$revision = current( $revisions );
// Check if the revisions have been upgraded
if ( $revisions && _wp_get_post_revision_version( $revision ) < 1 )
if ( $revisions && _wp_get_post_revision_version( $revision ) < 1 ) {
_wp_upgrade_revisions_of_post( $post, wp_get_post_revisions( $post_ID ) );
}
}
if ( isset( $post_data['visibility'] ) ) {
switch ( $post_data['visibility'] ) {
@ -241,31 +269,35 @@ function edit_post( $post_data = null ) {
}
$post_data = _wp_translate_postdata( true, $post_data );
if ( is_wp_error($post_data) )
if ( is_wp_error( $post_data ) ) {
wp_die( $post_data->get_error_message() );
}
// Post Formats
if ( isset( $post_data['post_format'] ) )
if ( isset( $post_data['post_format'] ) ) {
set_post_format( $post_ID, $post_data['post_format'] );
}
$format_meta_urls = array( 'url', 'link_url', 'quote_source_url' );
foreach ( $format_meta_urls as $format_meta_url ) {
$keyed = '_format_' . $format_meta_url;
if ( isset( $post_data[ $keyed ] ) )
if ( isset( $post_data[ $keyed ] ) ) {
update_post_meta( $post_ID, $keyed, wp_slash( esc_url_raw( wp_unslash( $post_data[ $keyed ] ) ) ) );
}
}
$format_keys = array( 'quote', 'quote_source_name', 'image', 'gallery', 'audio_embed', 'video_embed' );
foreach ( $format_keys as $key ) {
$keyed = '_format_' . $key;
if ( isset( $post_data[ $keyed ] ) ) {
if ( current_user_can( 'unfiltered_html' ) )
if ( current_user_can( 'unfiltered_html' ) ) {
update_post_meta( $post_ID, $keyed, $post_data[ $keyed ] );
else
} else {
update_post_meta( $post_ID, $keyed, wp_filter_post_kses( $post_data[ $keyed ] ) );
}
}
}
if ( 'attachment' === $post_data['post_type'] && preg_match( '#^(audio|video)/#', $post_data['post_mime_type'] ) ) {
$id3data = wp_get_attachment_metadata( $post_ID );
@ -284,26 +316,33 @@ function edit_post( $post_data = null ) {
// Meta Stuff
if ( isset( $post_data['meta'] ) && $post_data['meta'] ) {
foreach ( $post_data['meta'] as $key => $value ) {
if ( !$meta = get_post_meta_by_id( $key ) )
if ( ! $meta = get_post_meta_by_id( $key ) ) {
continue;
if ( $meta->post_id != $post_ID )
}
if ( $meta->post_id != $post_ID ) {
continue;
if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'edit_post_meta', $post_ID, $meta->meta_key ) )
}
if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'edit_post_meta', $post_ID, $meta->meta_key ) ) {
continue;
if ( is_protected_meta( $value['key'], 'post' ) || ! current_user_can( 'edit_post_meta', $post_ID, $value['key'] ) )
}
if ( is_protected_meta( $value['key'], 'post' ) || ! current_user_can( 'edit_post_meta', $post_ID, $value['key'] ) ) {
continue;
}
update_meta( $key, $value['key'], $value['value'] );
}
}
if ( isset( $post_data['deletemeta'] ) && $post_data['deletemeta'] ) {
foreach ( $post_data['deletemeta'] as $key => $value ) {
if ( !$meta = get_post_meta_by_id( $key ) )
if ( ! $meta = get_post_meta_by_id( $key ) ) {
continue;
if ( $meta->post_id != $post_ID )
}
if ( $meta->post_id != $post_ID ) {
continue;
if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'delete_post_meta', $post_ID, $meta->meta_key ) )
}
if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'delete_post_meta', $post_ID, $meta->meta_key ) ) {
continue;
}
delete_meta( $key );
}
}
@ -360,11 +399,12 @@ function edit_post( $post_data = null ) {
wp_set_post_lock( $post_ID );
if ( current_user_can( $ptype->cap->edit_others_posts ) && current_user_can( $ptype->cap->publish_posts ) ) {
if ( ! empty( $post_data['sticky'] ) )
if ( ! empty( $post_data['sticky'] ) ) {
stick_post( $post_ID );
else
} else {
unstick_post( $post_ID );
}
}
return $post_ID;
}
@ -385,20 +425,23 @@ function edit_post( $post_data = null ) {
function bulk_edit_posts( $post_data = null ) {
global $wpdb;
if ( empty($post_data) )
if ( empty( $post_data ) ) {
$post_data = &$_POST;
}
if ( isset($post_data['post_type']) )
if ( isset( $post_data['post_type'] ) ) {
$ptype = get_post_type_object( $post_data['post_type'] );
else
} else {
$ptype = get_post_type_object( 'post' );
}
if ( ! current_user_can( $ptype->cap->edit_posts ) ) {
if ( 'page' == $ptype->name )
if ( 'page' == $ptype->name ) {
wp_die( __( 'Sorry, you are not allowed to edit pages.' ) );
else
} else {
wp_die( __( 'Sorry, you are not allowed to edit posts.' ) );
}
}
if ( -1 == $post_data['_status'] ) {
$post_data['post_status'] = null;
@ -419,35 +462,47 @@ function bulk_edit_posts( $post_data = null ) {
$post_IDs = array_map( 'intval', (array) $post_data['post'] );
$reset = array(
'post_author', 'post_status', 'post_password',
'post_parent', 'page_template', 'comment_status',
'ping_status', 'keep_private', 'tax_input',
'post_category', 'sticky', 'post_format',
'post_author',
'post_status',
'post_password',
'post_parent',
'page_template',
'comment_status',
'ping_status',
'keep_private',
'tax_input',
'post_category',
'sticky',
'post_format',
);
foreach ( $reset as $field ) {
if ( isset($post_data[$field]) && ( '' == $post_data[$field] || -1 == $post_data[$field] ) )
if ( isset( $post_data[ $field ] ) && ( '' == $post_data[ $field ] || -1 == $post_data[ $field ] ) ) {
unset( $post_data[ $field ] );
}
}
if ( isset( $post_data['post_category'] ) ) {
if ( is_array($post_data['post_category']) && ! empty($post_data['post_category']) )
if ( is_array( $post_data['post_category'] ) && ! empty( $post_data['post_category'] ) ) {
$new_cats = array_map( 'absint', $post_data['post_category'] );
else
} else {
unset( $post_data['post_category'] );
}
}
$tax_input = array();
if ( isset( $post_data['tax_input'] ) ) {
foreach ( $post_data['tax_input'] as $tax_name => $terms ) {
if ( empty($terms) )
if ( empty( $terms ) ) {
continue;
}
if ( is_taxonomy_hierarchical( $tax_name ) ) {
$tax_input[ $tax_name ] = array_map( 'absint', $terms );
} else {
$comma = _x( ',', 'tag delimiter' );
if ( ',' !== $comma )
if ( ',' !== $comma ) {
$terms = str_replace( $comma, ',', $terms );
}
$tax_input[ $tax_name ] = explode( ',', trim( $terms, " \n\t\r\0\x0B," ) );
}
}
@ -492,15 +547,17 @@ function bulk_edit_posts( $post_data = null ) {
$tax_names = get_object_taxonomies( $post );
foreach ( $tax_names as $tax_name ) {
$taxonomy_obj = get_taxonomy( $tax_name );
if ( isset( $tax_input[$tax_name]) && current_user_can( $taxonomy_obj->cap->assign_terms ) )
if ( isset( $tax_input[ $tax_name ] ) && current_user_can( $taxonomy_obj->cap->assign_terms ) ) {
$new_terms = $tax_input[ $tax_name ];
else
} else {
$new_terms = array();
}
if ( $taxonomy_obj->hierarchical )
if ( $taxonomy_obj->hierarchical ) {
$current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array( 'fields' => 'ids' ) );
else
} else {
$current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array( 'fields' => 'names' ) );
}
$post_data['tax_input'][ $tax_name ] = array_merge( $current_terms, $new_terms );
}
@ -538,14 +595,19 @@ function bulk_edit_posts( $post_data = null ) {
$updated[] = wp_update_post( $post_data );
if ( isset( $post_data['sticky'] ) && current_user_can( $ptype->cap->edit_others_posts ) ) {
if ( 'sticky' == $post_data['sticky'] )
if ( 'sticky' == $post_data['sticky'] ) {
stick_post( $post_ID );
else
} else {
unstick_post( $post_ID );
}
}
}
return array( 'updated' => $updated, 'skipped' => $skipped, 'locked' => $locked );
return array(
'updated' => $updated,
'skipped' => $skipped,
'locked' => $locked,
);
}
/**
@ -559,22 +621,32 @@ function bulk_edit_posts( $post_data = null ) {
*/
function get_default_post_to_edit( $post_type = 'post', $create_in_db = false ) {
$post_title = '';
if ( !empty( $_REQUEST['post_title'] ) )
if ( ! empty( $_REQUEST['post_title'] ) ) {
$post_title = esc_html( wp_unslash( $_REQUEST['post_title'] ) );
}
$post_content = '';
if ( !empty( $_REQUEST['content'] ) )
if ( ! empty( $_REQUEST['content'] ) ) {
$post_content = esc_html( wp_unslash( $_REQUEST['content'] ) );
}
$post_excerpt = '';
if ( !empty( $_REQUEST['excerpt'] ) )
if ( ! empty( $_REQUEST['excerpt'] ) ) {
$post_excerpt = esc_html( wp_unslash( $_REQUEST['excerpt'] ) );
}
if ( $create_in_db ) {
$post_id = wp_insert_post( array( 'post_title' => __( 'Auto Draft' ), 'post_type' => $post_type, 'post_status' => 'auto-draft' ) );
$post_id = wp_insert_post(
array(
'post_title' => __( 'Auto Draft' ),
'post_type' => $post_type,
'post_status' => 'auto-draft',
)
);
$post = get_post( $post_id );
if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) && get_option( 'default_post_format' ) )
if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) && get_option( 'default_post_format' ) ) {
set_post_format( $post, get_option( 'default_post_format' ) );
}
} else {
$post = new stdClass;
$post->ID = 0;
@ -667,8 +739,9 @@ function post_exists($title, $content = '', $date = '') {
$args[] = $post_content;
}
if ( !empty ( $args ) )
if ( ! empty( $args ) ) {
return (int) $wpdb->get_var( $wpdb->prepare( $query, $args ) );
}
return 0;
}
@ -683,17 +756,19 @@ function post_exists($title, $content = '', $date = '') {
* @return int|WP_Error
*/
function wp_write_post() {
if ( isset($_POST['post_type']) )
if ( isset( $_POST['post_type'] ) ) {
$ptype = get_post_type_object( $_POST['post_type'] );
else
} else {
$ptype = get_post_type_object( 'post' );
}
if ( ! current_user_can( $ptype->cap->edit_posts ) ) {
if ( 'page' == $ptype->name )
if ( 'page' == $ptype->name ) {
return new WP_Error( 'edit_pages', __( 'Sorry, you are not allowed to create pages on this site.' ) );
else
} else {
return new WP_Error( 'edit_posts', __( 'Sorry, you are not allowed to create posts or drafts on this site.' ) );
}
}
$_POST['post_mime_type'] = '';
@ -701,8 +776,9 @@ function wp_write_post() {
unset( $_POST['filter'] );
// Edit don't write if we have a post id.
if ( isset( $_POST['post_ID'] ) )
if ( isset( $_POST['post_ID'] ) ) {
return edit_post();
}
if ( isset( $_POST['visibility'] ) ) {
switch ( $_POST['visibility'] ) {
@ -721,16 +797,19 @@ function wp_write_post() {
}
$translated = _wp_translate_postdata( false );
if ( is_wp_error($translated) )
if ( is_wp_error( $translated ) ) {
return $translated;
}
// Create the post.
$post_ID = wp_insert_post( $_POST );
if ( is_wp_error( $post_ID ) )
if ( is_wp_error( $post_ID ) ) {
return $post_ID;
}
if ( empty($post_ID) )
if ( empty( $post_ID ) ) {
return 0;
}
add_meta( $post_ID );
@ -753,11 +832,12 @@ function wp_write_post() {
*/
function write_post() {
$result = wp_write_post();
if ( is_wp_error( $result ) )
if ( is_wp_error( $result ) ) {
wp_die( $result->get_error_message() );
else
} else {
return $result;
}
}
//
// Post Meta
@ -777,22 +857,26 @@ function add_meta( $post_ID ) {
$metakeyselect = isset( $_POST['metakeyselect'] ) ? wp_unslash( trim( $_POST['metakeyselect'] ) ) : '';
$metakeyinput = isset( $_POST['metakeyinput'] ) ? wp_unslash( trim( $_POST['metakeyinput'] ) ) : '';
$metavalue = isset( $_POST['metavalue'] ) ? $_POST['metavalue'] : '';
if ( is_string( $metavalue ) )
if ( is_string( $metavalue ) ) {
$metavalue = trim( $metavalue );
}
if ( ( '0' === $metavalue || ! empty( $metavalue ) ) && ( ( ( '#NONE#' != $metakeyselect ) && ! empty( $metakeyselect ) ) || ! empty( $metakeyinput ) ) ) {
/*
* We have a key/value pair. If both the select and the input
* for the key have data, the input takes precedence.
*/
if ( '#NONE#' != $metakeyselect )
if ( '#NONE#' != $metakeyselect ) {
$metakey = $metakeyselect;
}
if ( $metakeyinput )
if ( $metakeyinput ) {
$metakey = $metakeyinput; // default
}
if ( is_protected_meta( $metakey, 'post' ) || ! current_user_can( 'add_post_meta', $post_ID, $metakey ) )
if ( is_protected_meta( $metakey, 'post' ) || ! current_user_can( 'add_post_meta', $post_ID, $metakey ) ) {
return false;
}
$metakey = wp_slash( $metakey );
@ -826,11 +910,13 @@ function delete_meta( $mid ) {
function get_meta_keys() {
global $wpdb;
$keys = $wpdb->get_col( "
$keys = $wpdb->get_col(
"
SELECT meta_key
FROM $wpdb->postmeta
GROUP BY meta_key
ORDER BY meta_key" );
ORDER BY meta_key"
);
return $keys;
}
@ -860,9 +946,13 @@ function get_post_meta_by_id( $mid ) {
function has_meta( $postid ) {
global $wpdb;
return $wpdb->get_results( $wpdb->prepare("SELECT meta_key, meta_value, meta_id, post_id
return $wpdb->get_results(
$wpdb->prepare(
"SELECT meta_key, meta_value, meta_id, post_id
FROM $wpdb->postmeta WHERE post_id = %d
ORDER BY meta_key,meta_id", $postid), ARRAY_A );
ORDER BY meta_key,meta_id", $postid
), ARRAY_A
);
}
/**
@ -900,12 +990,14 @@ function _fix_attachment_links( $post ) {
$content = $post['post_content'];
// Don't run if no pretty permalinks or post is not published, scheduled, or privately published.
if ( ! get_option( 'permalink_structure' ) || ! in_array( $post['post_status'], array( 'publish', 'future', 'private' ) ) )
if ( ! get_option( 'permalink_structure' ) || ! in_array( $post['post_status'], array( 'publish', 'future', 'private' ) ) ) {
return;
}
// Short if there aren't any links or no '?attachment_id=' strings (strpos cannot be zero)
if ( !strpos($content, '?attachment_id=') || !preg_match_all( '/<a ([^>]+)>[\s\S]+?<\/a>/', $content, $link_matches ) )
if ( ! strpos( $content, '?attachment_id=' ) || ! preg_match_all( '/<a ([^>]+)>[\s\S]+?<\/a>/', $content, $link_matches ) ) {
return;
}
$site_url = get_bloginfo( 'url' );
$site_url = substr( $site_url, (int) strpos( $site_url, '://' ) ); // remove the http(s)
@ -914,15 +1006,17 @@ function _fix_attachment_links( $post ) {
foreach ( $link_matches[1] as $key => $value ) {
if ( ! strpos( $value, '?attachment_id=' ) || ! strpos( $value, 'wp-att-' )
|| ! preg_match( '/href=(["\'])[^"\']*\?attachment_id=(\d+)[^"\']*\\1/', $value, $url_match )
|| !preg_match( '/rel=["\'][^"\']*wp-att-(\d+)/', $value, $rel_match ) )
|| ! preg_match( '/rel=["\'][^"\']*wp-att-(\d+)/', $value, $rel_match ) ) {
continue;
}
$quote = $url_match[1]; // the quote (single or double)
$url_id = (int) $url_match[2];
$rel_id = (int) $rel_match[1];
if ( !$url_id || !$rel_id || $url_id != $rel_id || strpos($url_match[0], $site_url) === false )
if ( ! $url_id || ! $rel_id || $url_id != $rel_id || strpos( $url_match[0], $site_url ) === false ) {
continue;
}
$link = $link_matches[0][ $key ];
$replace = str_replace( $url_match[0], 'href=' . $quote . get_attachment_link( $url_id ) . $quote, $link );
@ -962,16 +1056,18 @@ function get_available_post_statuses($type = 'post') {
* @return array
*/
function wp_edit_posts_query( $q = false ) {
if ( false === $q )
if ( false === $q ) {
$q = $_GET;
}
$q['m'] = isset( $q['m'] ) ? (int) $q['m'] : 0;
$q['cat'] = isset( $q['cat'] ) ? (int) $q['cat'] : 0;
$post_stati = get_post_stati();
if ( isset($q['post_type']) && in_array( $q['post_type'], get_post_types() ) )
if ( isset( $q['post_type'] ) && in_array( $q['post_type'], get_post_types() ) ) {
$post_type = $q['post_type'];
else
} else {
$post_type = 'post';
}
$avail_post_stati = get_available_post_statuses( $post_type );
@ -994,8 +1090,9 @@ function wp_edit_posts_query( $q = false ) {
$per_page = "edit_{$post_type}_per_page";
$posts_per_page = (int) get_user_option( $per_page );
if ( empty( $posts_per_page ) || $posts_per_page < 1 )
if ( empty( $posts_per_page ) || $posts_per_page < 1 ) {
$posts_per_page = 20;
}
/**
* Filters the number of items per page to show for a specific 'per_page' type.
@ -1033,8 +1130,9 @@ function wp_edit_posts_query( $q = false ) {
$query['fields'] = 'id=>parent';
}
if ( ! empty( $q['show_sticky'] ) )
if ( ! empty( $q['show_sticky'] ) ) {
$query['post__in'] = (array) get_option( 'sticky_posts' );
}
wp( $query );
@ -1187,8 +1285,9 @@ function postbox_classes( $id, $page ) {
*/
function get_sample_permalink( $id, $title = null, $name = null ) {
$post = get_post( $id );
if ( ! $post )
if ( ! $post ) {
return array( '', '' );
}
$ptype = get_post_type_object( $post->post_type );
@ -1204,8 +1303,9 @@ function get_sample_permalink($id, $title = null, $name = null) {
// If the user wants to set a new name -- override the current one
// Note: if empty name is supplied -- use the title instead, see #6072
if ( !is_null($name) )
if ( ! is_null( $name ) ) {
$post->post_name = sanitize_title( $name ? $name : $title, $post->ID );
}
$post->post_name = wp_unique_post_slug( $post->post_name, $post->ID, $post->post_status, $post->post_type, $post->post_parent );
@ -1227,8 +1327,9 @@ function get_sample_permalink($id, $title = null, $name = null) {
/** This filter is documented in wp-admin/edit-tag-form.php */
$uri = apply_filters( 'editable_slug', $uri, $post );
if ( !empty($uri) )
if ( ! empty( $uri ) ) {
$uri .= '/';
}
$permalink = str_replace( '%pagename%', "{$uri}%pagename%", $permalink );
}
@ -1265,8 +1366,9 @@ function get_sample_permalink($id, $title = null, $name = null) {
*/
function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) {
$post = get_post( $id );
if ( ! $post )
if ( ! $post ) {
return '';
}
list($permalink, $post_name) = get_sample_permalink( $post->ID, $new_title, $new_slug );
@ -1353,7 +1455,8 @@ function _wp_post_thumbnail_html( $thumbnail_id = null, $post = null ) {
$set_thumbnail_link = '<p class="hide-if-no-js"><a href="%s" id="set-post-thumbnail"%s class="thickbox">%s</a></p>';
$upload_iframe_src = get_upload_iframe_src( 'image', $post->ID );
$content = sprintf( $set_thumbnail_link,
$content = sprintf(
$set_thumbnail_link,
esc_url( $upload_iframe_src ),
'', // Empty when there's no featured image set, `aria-describedby` attribute otherwise.
esc_html( $post_type_object->labels->set_featured_image )
@ -1384,7 +1487,8 @@ function _wp_post_thumbnail_html( $thumbnail_id = null, $post = null ) {
$thumbnail_html = wp_get_attachment_image( $thumbnail_id, $size );
if ( ! empty( $thumbnail_html ) ) {
$content = sprintf( $set_thumbnail_link,
$content = sprintf(
$set_thumbnail_link,
esc_url( $upload_iframe_src ),
' aria-describedby="set-post-thumbnail-desc"',
$thumbnail_html
@ -1479,12 +1583,14 @@ function wp_set_post_lock( $post_id ) {
* @return none
*/
function _admin_notice_post_locked() {
if ( ! $post = get_post() )
if ( ! $post = get_post() ) {
return;
}
$user = null;
if ( $user_id = wp_check_post_lock( $post->ID ) )
if ( $user_id = wp_check_post_lock( $post->ID ) ) {
$user = get_userdata( $user_id );
}
if ( $user ) {
@ -1499,8 +1605,9 @@ function _admin_notice_post_locked() {
* @param WP_Post $post Post object.
* @param WP_User|bool $user WP_User object on success, false otherwise.
*/
if ( ! apply_filters( 'show_post_locked_dialog', true, $post, $user ) )
if ( ! apply_filters( 'show_post_locked_dialog', true, $post, $user ) ) {
return;
}
$locked = true;
} else {
@ -1514,8 +1621,9 @@ function _admin_notice_post_locked() {
} else {
$sendback = admin_url( 'edit.php' );
if ( 'post' != $post->post_type )
if ( 'post' != $post->post_type ) {
$sendback = add_query_arg( 'post_type', $post->post_type, $sendback );
}
$sendback_text = get_post_type_object( $post->post_type )->labels->all_items;
}
@ -1645,8 +1753,9 @@ function wp_create_post_autosave( $post_data ) {
}
$post_data = _wp_translate_postdata( true, $post_data );
if ( is_wp_error( $post_data ) )
if ( is_wp_error( $post_data ) ) {
return $post_data;
}
$post_author = get_current_user_id();
@ -1717,14 +1826,16 @@ function post_preview() {
} else {
$is_autosave = true;
if ( isset( $_POST['post_status'] ) && 'auto-draft' == $_POST['post_status'] )
if ( isset( $_POST['post_status'] ) && 'auto-draft' == $_POST['post_status'] ) {
$_POST['post_status'] = 'draft';
}
$saved_post_id = wp_create_post_autosave( $post->ID );
}
if ( is_wp_error( $saved_post_id ) )
if ( is_wp_error( $saved_post_id ) ) {
wp_die( $saved_post_id->get_error_message() );
}
$query_args = array();
@ -1757,8 +1868,9 @@ function post_preview() {
*/
function wp_autosave( $post_data ) {
// Back-compat
if ( ! defined( 'DOING_AUTOSAVE' ) )
if ( ! defined( 'DOING_AUTOSAVE' ) ) {
define( 'DOING_AUTOSAVE', true );
}
$post_id = (int) $post_data['post_id'];
$post_data['ID'] = $post_data['post_ID'] = $post_id;
@ -1773,11 +1885,13 @@ function wp_autosave( $post_data ) {
return new WP_Error( 'edit_posts', __( 'Sorry, you are not allowed to edit this item.' ) );
}
if ( 'auto-draft' == $post->post_status )
if ( 'auto-draft' == $post->post_status ) {
$post_data['post_status'] = 'draft';
}
if ( $post_data['post_type'] != 'page' && ! empty( $post_data['catslist'] ) )
if ( $post_data['post_type'] != 'page' && ! empty( $post_data['catslist'] ) ) {
$post_data['post_category'] = explode( ',', $post_data['catslist'] );
}
if ( ! wp_check_post_lock( $post->ID ) && get_current_user_id() == $post->post_author && ( 'auto-draft' == $post->post_status || 'draft' == $post->post_status ) ) {
// Drafts and auto-drafts are just overwritten by autosave for the same user if the post is not locked
@ -1878,11 +1992,13 @@ function taxonomy_meta_box_sanitize_cb_input( $taxonomy, $terms ) {
continue;
}
$_term = get_terms( $taxonomy, array(
$_term = get_terms(
$taxonomy, array(
'name' => $term,
'fields' => 'ids',
'hide_empty' => false,
) );
)
);
if ( ! empty( $_term ) ) {
$clean_terms[] = intval( $_term[0] );

View File

@ -20,26 +20,31 @@
* Or, false on failure.
*/
function wp_get_revision_ui_diff( $post, $compare_from, $compare_to ) {
if ( ! $post = get_post( $post ) )
if ( ! $post = get_post( $post ) ) {
return false;
}
if ( $compare_from ) {
if ( ! $compare_from = get_post( $compare_from ) )
if ( ! $compare_from = get_post( $compare_from ) ) {
return false;
}
} else {
// If we're dealing with the first revision...
$compare_from = false;
}
if ( ! $compare_to = get_post( $compare_to ) )
if ( ! $compare_to = get_post( $compare_to ) ) {
return false;
}
// If comparing revisions, make sure we're dealing with the right post parent.
// The parent post may be a 'revision' when revisions are disabled and we're looking at autosaves.
if ( $compare_from && $compare_from->post_parent !== $post->ID && $compare_from->ID !== $post->ID )
if ( $compare_from && $compare_from->post_parent !== $post->ID && $compare_from->ID !== $post->ID ) {
return false;
if ( $compare_to->post_parent !== $post->ID && $compare_to->ID !== $post->ID )
}
if ( $compare_to->post_parent !== $post->ID && $compare_to->ID !== $post->ID ) {
return false;
}
if ( $compare_from && strtotime( $compare_from->post_date_gmt ) > strtotime( $compare_to->post_date_gmt ) ) {
$temp = $compare_from;
@ -48,10 +53,12 @@ function wp_get_revision_ui_diff( $post, $compare_from, $compare_to ) {
}
// Add default title if title field is empty
if ( $compare_from && empty( $compare_from->post_title ) )
if ( $compare_from && empty( $compare_from->post_title ) ) {
$compare_from->post_title = __( '(no title)' );
if ( empty( $compare_to->post_title ) )
}
if ( empty( $compare_to->post_title ) ) {
$compare_to->post_title = __( '(no title)' );
}
$return = array();
@ -76,7 +83,7 @@ function wp_get_revision_ui_diff( $post, $compare_from, $compare_to ) {
$content_to = apply_filters( "_wp_post_revision_field_{$field}", $compare_to->$field, $field, $compare_to, 'to' );
$args = array(
'show_split_view' => true
'show_split_view' => true,
);
/**
@ -147,13 +154,19 @@ function wp_prepare_revisions_for_js( $post, $selected_revision_id, $from = null
$authors = array();
$now_gmt = time();
$revisions = wp_get_post_revisions( $post->ID, array( 'order' => 'ASC', 'check_enabled' => false ) );
$revisions = wp_get_post_revisions(
$post->ID, array(
'order' => 'ASC',
'check_enabled' => false,
)
);
// If revisions are disabled, we only want autosaves and the current post.
if ( ! wp_revisions_enabled( $post ) ) {
foreach ( $revisions as $revision_id => $revision ) {
if ( ! wp_is_post_autosave( $revision ) )
if ( ! wp_is_post_autosave( $revision ) ) {
unset( $revisions[ $revision_id ] );
}
}
$revisions = array( $post->ID => $post ) + $revisions;
}
@ -168,14 +181,18 @@ function wp_prepare_revisions_for_js( $post, $selected_revision_id, $from = null
$modified = strtotime( $revision->post_modified );
$modified_gmt = strtotime( $revision->post_modified_gmt . ' +0000' );
if ( $can_restore ) {
$restore_link = str_replace( '&amp;', '&', wp_nonce_url(
$restore_link = str_replace(
'&amp;', '&', wp_nonce_url(
add_query_arg(
array( 'revision' => $revision->ID,
'action' => 'restore' ),
array(
'revision' => $revision->ID,
'action' => 'restore',
),
admin_url( 'revision.php' )
),
"restore-post_{$revision->ID}"
) );
)
);
}
if ( ! isset( $authors[ $revision->post_author ] ) ) {
@ -288,10 +305,12 @@ function wp_prepare_revisions_for_js( $post, $selected_revision_id, $from = null
$from = absint( $from );
$diffs = array( array(
$diffs = array(
array(
'id' => $from . ':' . $selected_revision_id,
'fields' => wp_get_revision_ui_diff( $post->ID, $from, $selected_revision_id ),
));
),
);
return array(
'postId' => $post->ID,
@ -357,14 +376,32 @@ function wp_print_revision_templates() {
{{{ data.attributes.author.avatar }}}
<div class="author-info">
<# if ( data.attributes.autosave ) { #>
<span class="byline"><?php printf( __( 'Autosave by %s' ),
'<span class="author-name">{{ data.attributes.author.name }}</span>' ); ?></span>
<span class="byline">
<?php
printf(
__( 'Autosave by %s' ),
'<span class="author-name">{{ data.attributes.author.name }}</span>'
);
?>
</span>
<# } else if ( data.attributes.current ) { #>
<span class="byline"><?php printf( __( 'Current Revision by %s' ),
'<span class="author-name">{{ data.attributes.author.name }}</span>' ); ?></span>
<span class="byline">
<?php
printf(
__( 'Current Revision by %s' ),
'<span class="author-name">{{ data.attributes.author.name }}</span>'
);
?>
</span>
<# } else { #>
<span class="byline"><?php printf( __( 'Revision by %s' ),
'<span class="author-name">{{ data.attributes.author.name }}</span>' ); ?></span>
<span class="byline">
<?php
printf(
__( 'Revision by %s' ),
'<span class="author-name">{{ data.attributes.author.name }}</span>'
);
?>
</span>
<# } #>
<span class="time-ago">{{ data.attributes.timeAgo }}</span>
<span class="date">({{ data.attributes.dateShort }})</span>
@ -399,5 +436,6 @@ function wp_print_revision_templates() {
{{{ field.diff }}}
<# }); #>
</div>
</script><?php
</script>
<?php
}

View File

@ -38,8 +38,9 @@ function wp_get_db_schema( $scope = 'all', $blog_id = null ) {
$charset_collate = $wpdb->get_charset_collate();
if ( $blog_id && $blog_id != $wpdb->blogid )
if ( $blog_id && $blog_id != $wpdb->blogid ) {
$old_blog_id = $wpdb->set_blog_id( $blog_id );
}
// Engage multisite if in the middle of turning it on from network.php.
$is_multisite = is_multisite() || ( defined( 'WP_INSTALLING_NETWORK' ) && WP_INSTALLING_NETWORK );
@ -235,10 +236,11 @@ CREATE TABLE $wpdb->posts (
) $charset_collate;\n";
// Global tables
if ( $is_multisite )
if ( $is_multisite ) {
$global_tables = $users_multi_table . $usermeta_table;
else
} else {
$global_tables = $users_single_table . $usermeta_table;
}
// Multisite global tables.
$ms_global_tables = "CREATE TABLE $wpdb->blogs (
@ -315,8 +317,9 @@ CREATE TABLE $wpdb->signups (
break;
case 'global':
$queries = $global_tables;
if ( $is_multisite )
if ( $is_multisite ) {
$queries .= $ms_global_tables;
}
break;
case 'ms_global':
$queries = $ms_global_tables;
@ -324,13 +327,15 @@ CREATE TABLE $wpdb->signups (
case 'all':
default:
$queries = $global_tables . $blog_tables;
if ( $is_multisite )
if ( $is_multisite ) {
$queries .= $ms_global_tables;
}
break;
}
if ( isset( $old_blog_id ) )
if ( isset( $old_blog_id ) ) {
$wpdb->set_blog_id( $old_blog_id );
}
return $queries;
}
@ -386,10 +391,11 @@ function populate_options() {
* for all timezone strings supported by PHP.
*/
$offset_or_tz = _x( '0', 'default GMT offset or timezone string' );
if ( is_numeric( $offset_or_tz ) )
if ( is_numeric( $offset_or_tz ) ) {
$gmt_offset = $offset_or_tz;
elseif ( $offset_or_tz && in_array( $offset_or_tz, timezone_identifiers_list() ) )
} elseif ( $offset_or_tz && in_array( $offset_or_tz, timezone_identifiers_list() ) ) {
$timezone_string = $offset_or_tz;
}
$options = array(
'siteurl' => $guessurl,
@ -540,47 +546,115 @@ function populate_options() {
$insert = '';
foreach ( $options as $option => $value ) {
if ( in_array($option, $existing_options) )
if ( in_array( $option, $existing_options ) ) {
continue;
if ( in_array($option, $fat_options) )
}
if ( in_array( $option, $fat_options ) ) {
$autoload = 'no';
else
} else {
$autoload = 'yes';
if ( is_array($value) )
$value = serialize($value);
if ( !empty($insert) )
$insert .= ', ';
$insert .= $wpdb->prepare( "(%s, %s, %s)", $option, $value, $autoload );
}
if ( !empty($insert) )
if ( is_array( $value ) ) {
$value = serialize( $value );
}
if ( ! empty( $insert ) ) {
$insert .= ', ';
}
$insert .= $wpdb->prepare( '(%s, %s, %s)', $option, $value, $autoload );
}
if ( ! empty( $insert ) ) {
$wpdb->query( "INSERT INTO $wpdb->options (option_name, option_value, autoload) VALUES " . $insert );
}
// In case it is set, but blank, update "home".
if ( !__get_option('home') ) update_option('home', $guessurl);
if ( ! __get_option( 'home' ) ) {
update_option( 'home', $guessurl );
}
// Delete unused options.
$unusedoptions = array(
'blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory',
'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping',
'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers',
'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference',
'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char',
'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1',
'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5',
'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9',
'links_recently_updated_time', 'links_recently_updated_prepend', 'links_recently_updated_append',
'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat',
'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce',
'_wp_http_referer', 'Update', 'action', 'rich_editing', 'autosave_interval', 'deactivated_plugins',
'can_compress_scripts', 'page_uris', 'update_core', 'update_plugins', 'update_themes', 'doing_cron',
'random_seed', 'rss_excerpt_length', 'secret', 'use_linksupdate', 'default_comment_status_page',
'wporg_popular_tags', 'what_to_show', 'rss_language', 'language', 'enable_xmlrpc', 'enable_app',
'embed_autourls', 'default_post_edit_rows', 'gzipcompression', 'advanced_edit'
'blodotgsping_url',
'bodyterminator',
'emailtestonly',
'phoneemail_separator',
'smilies_directory',
'subjectprefix',
'use_bbcode',
'use_blodotgsping',
'use_phoneemail',
'use_quicktags',
'use_weblogsping',
'weblogs_cache_file',
'use_preview',
'use_htmltrans',
'smilies_directory',
'fileupload_allowedusers',
'use_phoneemail',
'default_post_status',
'default_post_category',
'archive_mode',
'time_difference',
'links_minadminlevel',
'links_use_adminlevels',
'links_rating_type',
'links_rating_char',
'links_rating_ignore_zero',
'links_rating_single_image',
'links_rating_image0',
'links_rating_image1',
'links_rating_image2',
'links_rating_image3',
'links_rating_image4',
'links_rating_image5',
'links_rating_image6',
'links_rating_image7',
'links_rating_image8',
'links_rating_image9',
'links_recently_updated_time',
'links_recently_updated_prepend',
'links_recently_updated_append',
'weblogs_cacheminutes',
'comment_allowed_tags',
'search_engine_friendly_urls',
'default_geourl_lat',
'default_geourl_lon',
'use_default_geourl',
'weblogs_xml_url',
'new_users_can_blog',
'_wpnonce',
'_wp_http_referer',
'Update',
'action',
'rich_editing',
'autosave_interval',
'deactivated_plugins',
'can_compress_scripts',
'page_uris',
'update_core',
'update_plugins',
'update_themes',
'doing_cron',
'random_seed',
'rss_excerpt_length',
'secret',
'use_linksupdate',
'default_comment_status_page',
'wporg_popular_tags',
'what_to_show',
'rss_language',
'language',
'enable_xmlrpc',
'enable_app',
'embed_autourls',
'default_post_edit_rows',
'gzipcompression',
'advanced_edit',
);
foreach ( $unusedoptions as $option )
foreach ( $unusedoptions as $option ) {
delete_option( $option );
}
// Delete obsolete magpie stuff.
$wpdb->query( "DELETE FROM $wpdb->options WHERE option_name REGEXP '^rss_[0-9a-f]{32}(_ts)?$'" );
@ -719,8 +793,9 @@ function populate_roles_210() {
$roles = array( 'administrator', 'editor' );
foreach ( $roles as $role ) {
$role = get_role( $role );
if ( empty($role) )
if ( empty( $role ) ) {
continue;
}
$role->add_cap( 'edit_others_pages' );
$role->add_cap( 'edit_published_pages' );
@ -850,8 +925,9 @@ if ( !function_exists( 'install_network' ) ) :
* @since 3.0.0
*/
function install_network() {
if ( ! defined( 'WP_INSTALLING_NETWORK' ) )
if ( ! defined( 'WP_INSTALLING_NETWORK' ) ) {
define( 'WP_INSTALLING_NETWORK', true );
}
dbDelta( wp_get_db_schema( 'global' ) );
}
@ -881,10 +957,12 @@ function populate_network( $network_id = 1, $domain = '', $email = '', $site_nam
global $wpdb, $current_site, $wp_db_version, $wp_rewrite;
$errors = new WP_Error();
if ( '' == $domain )
if ( '' == $domain ) {
$errors->add( 'empty_domain', __( 'You must provide a domain name.' ) );
if ( '' == $site_name )
}
if ( '' == $site_name ) {
$errors->add( 'empty_sitename', __( 'You must provide a name for your network of sites.' ) );
}
// Check for network collision.
$network_exists = false;
@ -898,11 +976,13 @@ function populate_network( $network_id = 1, $domain = '', $email = '', $site_nam
}
}
if ( ! is_email( $email ) )
if ( ! is_email( $email ) ) {
$errors->add( 'invalid_email', __( 'You must provide a valid email address.' ) );
}
if ( $errors->get_error_code() )
if ( $errors->get_error_code() ) {
return $errors;
}
// If a user with the provided email does not exist, default to the current user as the new network admin.
$site_user = get_user_by( 'email', $email );
@ -931,20 +1011,33 @@ function populate_network( $network_id = 1, $domain = '', $email = '', $site_nam
}
if ( 1 == $network_id ) {
$wpdb->insert( $wpdb->site, array( 'domain' => $domain, 'path' => $path ) );
$wpdb->insert(
$wpdb->site, array(
'domain' => $domain,
'path' => $path,
)
);
$network_id = $wpdb->insert_id;
} else {
$wpdb->insert( $wpdb->site, array( 'domain' => $domain, 'path' => $path, 'id' => $network_id ) );
$wpdb->insert(
$wpdb->site, array(
'domain' => $domain,
'path' => $path,
'id' => $network_id,
)
);
}
wp_cache_delete( 'networks_have_paths', 'site-options' );
if ( ! is_multisite() ) {
$site_admins = array( $site_user->user_login );
$users = get_users( array(
$users = get_users(
array(
'fields' => array( 'user_login' ),
'role' => 'administrator',
) );
)
);
if ( $users ) {
foreach ( $users as $user ) {
$site_admins[] = $user->user_login;
@ -957,7 +1050,8 @@ function populate_network( $network_id = 1, $domain = '', $email = '', $site_nam
}
/* translators: Do not translate USERNAME, SITE_NAME, BLOG_URL, PASSWORD: those are placeholders. */
$welcome_email = __( 'Howdy USERNAME,
$welcome_email = __(
'Howdy USERNAME,
Your new SITE_NAME site has been successfully set up at:
BLOG_URL
@ -970,17 +1064,36 @@ Log in here: BLOG_URLwp-login.php
We hope you enjoy your new site. Thanks!
--The Team @ SITE_NAME' );
--The Team @ SITE_NAME'
);
$misc_exts = array(
// Images.
'jpg', 'jpeg', 'png', 'gif',
'jpg',
'jpeg',
'png',
'gif',
// Video.
'mov', 'avi', 'mpg', '3gp', '3g2',
'mov',
'avi',
'mpg',
'3gp',
'3g2',
// "audio".
'midi', 'mid',
'midi',
'mid',
// Miscellaneous.
'pdf', 'doc', 'ppt', 'odt', 'pptx', 'docx', 'pps', 'ppsx', 'xls', 'xlsx', 'key',
'pdf',
'doc',
'ppt',
'odt',
'pptx',
'docx',
'pps',
'ppsx',
'xls',
'xlsx',
'key',
);
$audio_exts = wp_get_audio_extensions();
$video_exts = wp_get_video_extensions();
@ -1012,8 +1125,9 @@ We hope you enjoy your new site. Thanks!
'active_sitewide_plugins' => array(),
'WPLANG' => get_locale(),
);
if ( ! $subdomain_install )
if ( ! $subdomain_install ) {
$sitemeta['illegal_names'][] = 'blog';
}
/**
* Filters meta for a network on creation.
@ -1027,11 +1141,13 @@ We hope you enjoy your new site. Thanks!
$insert = '';
foreach ( $sitemeta as $meta_key => $meta_value ) {
if ( is_array( $meta_value ) )
if ( is_array( $meta_value ) ) {
$meta_value = serialize( $meta_value );
if ( !empty( $insert ) )
}
if ( ! empty( $insert ) ) {
$insert .= ', ';
$insert .= $wpdb->prepare( "( %d, %s, %s)", $network_id, $meta_key, $meta_value );
}
$insert .= $wpdb->prepare( '( %d, %s, %s)', $network_id, $meta_key, $meta_value );
}
$wpdb->query( "INSERT INTO $wpdb->sitemeta ( site_id, meta_key, meta_value ) VALUES " . $insert );
@ -1047,29 +1163,45 @@ We hope you enjoy your new site. Thanks!
$current_site->domain = $domain;
$current_site->path = $path;
$current_site->site_name = ucfirst( $domain );
$wpdb->insert( $wpdb->blogs, array( 'site_id' => $network_id, 'blog_id' => 1, 'domain' => $domain, 'path' => $path, 'registered' => current_time( 'mysql' ) ) );
$wpdb->insert(
$wpdb->blogs, array(
'site_id' => $network_id,
'blog_id' => 1,
'domain' => $domain,
'path' => $path,
'registered' => current_time( 'mysql' ),
)
);
$current_site->blog_id = $blog_id = $wpdb->insert_id;
update_user_meta( $site_user->ID, 'source_domain', $domain );
update_user_meta( $site_user->ID, 'primary_blog', $blog_id );
if ( $subdomain_install )
if ( $subdomain_install ) {
$wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
else
} else {
$wp_rewrite->set_permalink_structure( '/blog/%year%/%monthnum%/%day%/%postname%/' );
}
flush_rewrite_rules();
if ( ! $subdomain_install )
if ( ! $subdomain_install ) {
return true;
}
$vhost_ok = false;
$errstr = '';
$hostname = substr( md5( time() ), 0, 6 ) . '.' . $domain; // Very random hostname!
$page = wp_remote_get( 'http://' . $hostname, array( 'timeout' => 5, 'httpversion' => '1.1' ) );
if ( is_wp_error( $page ) )
$page = wp_remote_get(
'http://' . $hostname, array(
'timeout' => 5,
'httpversion' => '1.1',
)
);
if ( is_wp_error( $page ) ) {
$errstr = $page->get_error_message();
elseif ( 200 == wp_remote_retrieve_response_code( $page ) )
} elseif ( 200 == wp_remote_retrieve_response_code( $page ) ) {
$vhost_ok = true;
}
if ( ! $vhost_ok ) {
$msg = '<p><strong>' . __( 'Warning! Wildcard DNS may not be configured correctly!' ) . '</strong></p>';

View File

@ -17,8 +17,9 @@
* @return array Containing the headers in the format id => UI String
*/
function get_column_headers( $screen ) {
if ( is_string( $screen ) )
if ( is_string( $screen ) ) {
$screen = convert_to_screen( $screen );
}
static $column_headers = array();
@ -98,11 +99,13 @@ function get_hidden_columns( $screen ) {
function meta_box_prefs( $screen ) {
global $wp_meta_boxes;
if ( is_string( $screen ) )
if ( is_string( $screen ) ) {
$screen = convert_to_screen( $screen );
}
if ( empty($wp_meta_boxes[$screen->id]) )
if ( empty( $wp_meta_boxes[ $screen->id ] ) ) {
return;
}
$hidden = get_hidden_meta_boxes( $screen );
@ -112,11 +115,13 @@ function meta_box_prefs( $screen ) {
continue;
}
foreach ( $wp_meta_boxes[ $screen->id ][ $context ][ $priority ] as $box ) {
if ( false == $box || ! $box['title'] )
if ( false == $box || ! $box['title'] ) {
continue;
}
// Submit box cannot be hidden
if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] )
if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] ) {
continue;
}
$widget_title = $box['title'];
@ -144,8 +149,9 @@ function meta_box_prefs( $screen ) {
* @return array Hidden Meta Boxes
*/
function get_hidden_meta_boxes( $screen ) {
if ( is_string( $screen ) )
if ( is_string( $screen ) ) {
$screen = convert_to_screen( $screen );
}
$hidden = get_user_option( "metaboxhidden_{$screen->id}" );
@ -155,11 +161,12 @@ function get_hidden_meta_boxes( $screen ) {
if ( $use_defaults ) {
$hidden = array();
if ( 'post' == $screen->base ) {
if ( 'post' == $screen->post_type || 'page' == $screen->post_type || 'attachment' == $screen->post_type )
if ( 'post' == $screen->post_type || 'page' == $screen->post_type || 'attachment' == $screen->post_type ) {
$hidden = array( 'slugdiv', 'trackbacksdiv', 'postcustom', 'postexcerpt', 'commentstatusdiv', 'commentsdiv', 'authordiv', 'revisionsdiv' );
else
} else {
$hidden = array( 'slugdiv' );
}
}
/**
* Filters the default list of hidden meta boxes.
@ -196,8 +203,9 @@ function get_hidden_meta_boxes( $screen ) {
function add_screen_option( $option, $args = array() ) {
$current_screen = get_current_screen();
if ( ! $current_screen )
if ( ! $current_screen ) {
return;
}
$current_screen->add_option( $option, $args );
}
@ -214,8 +222,9 @@ function add_screen_option( $option, $args = array() ) {
function get_current_screen() {
global $current_screen;
if ( ! isset( $current_screen ) )
if ( ! isset( $current_screen ) ) {
return null;
}
return $current_screen;
}

View File

@ -23,8 +23,9 @@
*/
function category_exists( $cat_name, $parent = null ) {
$id = term_exists( $cat_name, 'category', $parent );
if ( is_array($id) )
if ( is_array( $id ) ) {
$id = $id['term_id'];
}
return $id;
}
@ -52,10 +53,16 @@ function get_category_to_edit( $id ) {
* @return int|WP_Error
*/
function wp_create_category( $cat_name, $parent = 0 ) {
if ( $id = category_exists($cat_name, $parent) )
if ( $id = category_exists( $cat_name, $parent ) ) {
return $id;
}
return wp_insert_category( array('cat_name' => $cat_name, 'category_parent' => $parent) );
return wp_insert_category(
array(
'cat_name' => $cat_name,
'category_parent' => $parent,
)
);
}
/**
@ -77,8 +84,9 @@ function wp_create_categories( $categories, $post_id = '' ) {
}
}
if ( $post_id )
if ( $post_id ) {
wp_set_post_categories( $post_id, $cat_ids );
}
return $cat_ids;
}
@ -106,7 +114,14 @@ function wp_create_categories( $categories, $post_id = '' ) {
* depending on param $wp_error.
*/
function wp_insert_category( $catarr, $wp_error = false ) {
$cat_defaults = array( 'cat_ID' => 0, 'taxonomy' => 'category', 'cat_name' => '', 'category_description' => '', 'category_nicename' => '', 'category_parent' => '' );
$cat_defaults = array(
'cat_ID' => 0,
'taxonomy' => 'category',
'cat_name' => '',
'category_description' => '',
'category_nicename' => '',
'category_parent' => '',
);
$catarr = wp_parse_args( $catarr, $cat_defaults );
if ( trim( $catarr['cat_name'] ) == '' ) {
@ -168,8 +183,9 @@ function wp_insert_category( $catarr, $wp_error = false ) {
function wp_update_category( $catarr ) {
$cat_ID = (int) $catarr['cat_ID'];
if ( isset($catarr['category_parent']) && ($cat_ID == $catarr['category_parent']) )
if ( isset( $catarr['category_parent'] ) && ( $cat_ID == $catarr['category_parent'] ) ) {
return false;
}
// First, get all of the original fields
$category = get_term( $cat_ID, 'category', ARRAY_A );
@ -236,8 +252,9 @@ function get_tags_to_edit( $post_id, $taxonomy = 'post_tag' ) {
*/
function get_terms_to_edit( $post_id, $taxonomy = 'post_tag' ) {
$post_id = (int) $post_id;
if ( !$post_id )
if ( ! $post_id ) {
return false;
}
$terms = get_object_term_cache( $post_id, $taxonomy );
if ( false === $terms ) {
@ -283,8 +300,9 @@ function get_terms_to_edit( $post_id, $taxonomy = 'post_tag' ) {
* @return array|WP_Error
*/
function wp_create_term( $tag_name, $taxonomy = 'post_tag' ) {
if ( $id = term_exists($tag_name, $taxonomy) )
if ( $id = term_exists( $tag_name, $taxonomy ) ) {
return $id;
}
return wp_insert_term( $tag_name, $taxonomy );
}

View File

@ -38,14 +38,16 @@ require_once( ABSPATH . 'wp-admin/includes/class-wp-internal-pointers.php' );
* the top of the list. Default true.
*/
function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null, $checked_ontop = true ) {
wp_terms_checklist( $post_id, array(
wp_terms_checklist(
$post_id, array(
'taxonomy' => 'category',
'descendants_and_self' => $descendants_and_self,
'selected_cats' => $selected_cats,
'popular_cats' => $popular_cats,
'walker' => $walker,
'checked_ontop' => $checked_ontop
) );
'checked_ontop' => $checked_ontop,
)
);
}
/**
@ -125,20 +127,24 @@ function wp_terms_checklist( $post_id = 0, $args = array() ) {
if ( is_array( $r['popular_cats'] ) ) {
$args['popular_cats'] = $r['popular_cats'];
} else {
$args['popular_cats'] = get_terms( $taxonomy, array(
$args['popular_cats'] = get_terms(
$taxonomy, array(
'fields' => 'ids',
'orderby' => 'count',
'order' => 'DESC',
'number' => 10,
'hierarchical' => false
) );
'hierarchical' => false,
)
);
}
if ( $descendants_and_self ) {
$categories = (array) get_terms( $taxonomy, array(
$categories = (array) get_terms(
$taxonomy, array(
'child_of' => $descendants_and_self,
'hierarchical' => 0,
'hide_empty' => 0
) );
'hide_empty' => 0,
)
);
$self = get_term( $descendants_and_self, $taxonomy );
array_unshift( $categories, $self );
} else {
@ -191,20 +197,29 @@ function wp_terms_checklist( $post_id = 0, $args = array() ) {
function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) {
$post = get_post();
if ( $post && $post->ID )
if ( $post && $post->ID ) {
$checked_terms = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
else
} else {
$checked_terms = array();
}
$terms = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number, 'hierarchical' => false ) );
$terms = get_terms(
$taxonomy, array(
'orderby' => 'count',
'order' => 'DESC',
'number' => $number,
'hierarchical' => false,
)
);
$tax = get_taxonomy( $taxonomy );
$popular_ids = array();
foreach ( (array) $terms as $term ) {
$popular_ids[] = $term->term_id;
if ( !$echo ) // Hack for Ajax use.
if ( ! $echo ) { // Hack for Ajax use.
continue;
}
$id = "popular-$taxonomy-$term->term_id";
$checked = in_array( $term->term_id, $checked_terms ) ? 'checked="checked"' : '';
?>
@ -246,10 +261,16 @@ function wp_link_category_checklist( $link_id = 0 ) {
$checked_categories[] = $default;
}
$categories = get_terms( 'link_category', array( 'orderby' => 'name', 'hide_empty' => 0 ) );
$categories = get_terms(
'link_category', array(
'orderby' => 'name',
'hide_empty' => 0,
)
);
if ( empty( $categories ) )
if ( empty( $categories ) ) {
return;
}
foreach ( $categories as $category ) {
$cat_id = $category->term_id;
@ -257,7 +278,7 @@ function wp_link_category_checklist( $link_id = 0 ) {
/** This filter is documented in wp-includes/category-template.php */
$name = esc_html( apply_filters( 'the_category', $category->name, '', '' ) );
$checked = in_array( $cat_id, $checked_categories ) ? ' checked="checked"' : '';
echo '<li id="link-category-', $cat_id, '"><label for="in-link-category-', $cat_id, '" class="selectit"><input value="', $cat_id, '" type="checkbox" name="link_category[]" id="in-link-category-', $cat_id, '"', $checked, '/> ', $name, "</label></li>";
echo '<li id="link-category-', $cat_id, '"><label for="in-link-category-', $cat_id, '" class="selectit"><input value="', $cat_id, '" type="checkbox" name="link_category[]" id="in-link-category-', $cat_id, '"', $checked, '/> ', $name, '</label></li>';
}
}
@ -270,8 +291,9 @@ function wp_link_category_checklist( $link_id = 0 ) {
*/
function get_inline_data( $post ) {
$post_type_object = get_post_type_object( $post->post_type );
if ( ! current_user_can( 'edit_post', $post->ID ) )
if ( ! current_user_can( 'edit_post', $post->ID ) ) {
return;
}
$title = esc_textarea( trim( $post->post_title ) );
@ -331,11 +353,13 @@ function get_inline_data($post) {
}
}
if ( !$post_type_object->hierarchical )
if ( ! $post_type_object->hierarchical ) {
echo '<div class="sticky">' . ( is_sticky( $post->ID ) ? 'sticky' : '' ) . '</div>';
}
if ( post_type_supports( $post->post_type, 'post-formats' ) )
if ( post_type_supports( $post->post_type, 'post-formats' ) ) {
echo '<div class="post_format">' . esc_html( get_post_format( $post->ID ) ) . '</div>';
}
echo '</div>';
}
@ -369,7 +393,13 @@ function wp_comment_reply( $position = 1, $checkbox = false, $mode = 'single', $
* @param string $content The reply-to form content.
* @param array $args An array of default args.
*/
$content = apply_filters( 'wp_comment_reply', '', array( 'position' => $position, 'checkbox' => $checkbox, 'mode' => $mode ) );
$content = apply_filters(
'wp_comment_reply', '', array(
'position' => $position,
'checkbox' => $checkbox,
'mode' => $mode,
)
);
if ( ! empty( $content ) ) {
echo $content;
@ -402,23 +432,29 @@ function wp_comment_reply( $position = 1, $checkbox = false, $mode = 'single', $
<label for="replycontent" class="screen-reader-text"><?php _e( 'Comment' ); ?></label>
<?php
$quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close' );
wp_editor( '', 'replycontent', array( 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings ) );
wp_editor(
'', 'replycontent', array(
'media_buttons' => false,
'tinymce' => false,
'quicktags' => $quicktags_settings,
)
);
?>
</div>
<div id="edithead" style="display:none;">
<div class="inside">
<label for="author-name"><?php _e( 'Name' ) ?></label>
<label for="author-name"><?php _e( 'Name' ); ?></label>
<input type="text" name="newcomment_author" size="50" value="" id="author-name" />
</div>
<div class="inside">
<label for="author-email"><?php _e('Email') ?></label>
<label for="author-email"><?php _e( 'Email' ); ?></label>
<input type="text" name="newcomment_author_email" size="50" value="" id="author-email" />
</div>
<div class="inside">
<label for="author-url"><?php _e('URL') ?></label>
<label for="author-url"><?php _e( 'URL' ); ?></label>
<input type="text" id="author-url" name="newcomment_author_url" class="code" size="103" value="" />
</div>
</div>
@ -448,8 +484,9 @@ function wp_comment_reply( $position = 1, $checkbox = false, $mode = 'single', $
<input type="hidden" name="mode" id="mode" value="<?php echo esc_attr( $mode ); ?>" />
<?php
wp_nonce_field( 'replyto-comment', '_ajax_nonce-replyto-comment', false );
if ( current_user_can( 'unfiltered_html' ) )
if ( current_user_can( 'unfiltered_html' ) ) {
wp_nonce_field( 'unfiltered-html-comment', '_wp_unfiltered_html_comment', false );
}
?>
</fieldset>
<?php if ( $table_row ) : ?>
@ -506,14 +543,15 @@ function list_meta( $meta ) {
<table id="list-table">
<thead>
<tr>
<th class="left"><?php _ex( 'Name', 'meta name' ) ?></th>
<th><?php _e( 'Value' ) ?></th>
<th class="left"><?php _ex( 'Name', 'meta name' ); ?></th>
<th><?php _e( 'Value' ); ?></th>
</tr>
</thead>
<tbody id='the-list' data-wp-lists='list:meta'>
<?php
foreach ( $meta as $entry )
foreach ( $meta as $entry ) {
echo _list_meta_row( $entry, $count );
}
?>
</tbody>
</table>
@ -534,11 +572,13 @@ function list_meta( $meta ) {
function _list_meta_row( $entry, &$count ) {
static $update_nonce = '';
if ( is_protected_meta( $entry['meta_key'], 'post' ) )
if ( is_protected_meta( $entry['meta_key'], 'post' ) ) {
return '';
}
if ( ! $update_nonce )
if ( ! $update_nonce ) {
$update_nonce = wp_create_nonce( 'add-meta' );
}
$r = '';
++ $count;
@ -567,9 +607,9 @@ function _list_meta_row( $entry, &$count ) {
$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 .= "</div>";
$r .= '</div>';
$r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false );
$r .= "</td>";
$r .= '</td>';
$r .= "\n\t\t<td><label class='screen-reader-text' for='meta-{$entry['meta_id']}-value'>" . __( 'Value' ) . "</label><textarea name='meta[{$entry['meta_id']}][value]' id='meta-{$entry['meta_id']}-value' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>\n\t</tr>";
return $r;
@ -627,12 +667,12 @@ function meta_form( $post = null ) {
$meta_key_input_id = 'metakeyinput';
}
?>
<p><strong><?php _e( 'Add New Custom Field:' ) ?></strong></p>
<p><strong><?php _e( 'Add New Custom Field:' ); ?></strong></p>
<table id="newmeta">
<thead>
<tr>
<th class="left"><label for="<?php echo $meta_key_input_id; ?>"><?php _ex( 'Name', 'meta name' ) ?></label></th>
<th><label for="metavalue"><?php _e( 'Value' ) ?></label></th>
<th class="left"><label for="<?php echo $meta_key_input_id; ?>"><?php _ex( 'Name', 'meta name' ); ?></label></th>
<th><label for="metavalue"><?php _e( 'Value' ); ?></label></th>
</tr>
</thead>
@ -645,9 +685,10 @@ function meta_form( $post = null ) {
<?php
foreach ( $keys as $key ) {
if ( is_protected_meta( $key, 'post' ) || ! current_user_can( 'add_post_meta', $post->ID, $key ) )
if ( is_protected_meta( $key, 'post' ) || ! current_user_can( 'add_post_meta', $post->ID, $key ) ) {
continue;
echo "\n<option value='" . esc_attr($key) . "'>" . esc_html($key) . "</option>";
}
echo "\n<option value='" . esc_attr( $key ) . "'>" . esc_html( $key ) . '</option>';
}
?>
</select>
@ -664,7 +705,14 @@ function meta_form( $post = null ) {
<tr><td colspan="2">
<div class="submit">
<?php submit_button( __( 'Add Custom Field' ), '', 'addmeta', false, array( 'id' => 'newmeta-submit', 'data-wp-lists' => 'add:the-list:newmeta' ) ); ?>
<?php
submit_button(
__( 'Add Custom Field' ), '', 'addmeta', false, array(
'id' => 'newmeta-submit',
'data-wp-lists' => 'add:the-list:newmeta',
)
);
?>
</div>
<?php wp_nonce_field( 'add-meta', '_ajax_nonce-add-meta', false ); ?>
</td></tr>
@ -692,12 +740,14 @@ function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
global $wp_locale;
$post = get_post();
if ( $for_post )
if ( $for_post ) {
$edit = ! ( in_array( $post->post_status, array( 'draft', 'pending' ) ) && ( ! $post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt ) );
}
$tab_index_attribute = '';
if ( (int) $tab_index > 0 )
if ( (int) $tab_index > 0 ) {
$tab_index_attribute = " tabindex=\"$tab_index\"";
}
// todo: Remove this?
// echo '<label for="timestamp" style="display: block;"><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp"'.$tab_index_attribute.' /> '.__( 'Edit timestamp' ).'</label><br />';
@ -738,7 +788,9 @@ function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
echo '</div><input type="hidden" id="ss" name="ss" value="' . $ss . '" />';
if ( $multi ) return;
if ( $multi ) {
return;
}
echo "\n\n";
$map = array(
@ -778,7 +830,7 @@ function page_template_dropdown( $default = '', $post_type = 'page' ) {
ksort( $templates );
foreach ( array_keys( $templates ) as $template ) {
$selected = selected( $default, $templates[ $template ], false );
echo "\n\t<option value='" . esc_attr( $templates[ $template ] ) . "' $selected>" . esc_html( $template ) . "</option>";
echo "\n\t<option value='" . esc_attr( $templates[ $template ] ) . "' $selected>" . esc_html( $template ) . '</option>';
}
}
@ -805,13 +857,14 @@ function parent_dropdown( $default = 0, $parent = 0, $level = 0, $post = null )
if ( $items ) {
foreach ( $items as $item ) {
// A page cannot be its own parent.
if ( $post && $post->ID && $item->ID == $post->ID )
if ( $post && $post->ID && $item->ID == $post->ID ) {
continue;
}
$pad = str_repeat( '&nbsp;', $level * 3 );
$selected = selected( $default, $item->ID, false );
echo "\n\t<option class='level-$level' value='$item->ID' $selected>$pad " . esc_html($item->post_title) . "</option>";
echo "\n\t<option class='level-$level' value='$item->ID' $selected>$pad " . esc_html( $item->post_title ) . '</option>';
parent_dropdown( $default, $item->ID, $level + 1 );
}
} else {
@ -866,8 +919,10 @@ function wp_import_upload_form( $action ) {
$size = size_format( $bytes );
$upload_dir = wp_upload_dir();
if ( ! empty( $upload_dir['error'] ) ) :
?><div class="error"><p><?php _e('Before you can upload your import file, you will need to fix the following error:'); ?></p>
<p><strong><?php echo $upload_dir['error']; ?></strong></p></div><?php
?>
<div class="error"><p><?php _e( 'Before you can upload your import file, you will need to fix the following error:' ); ?></p>
<p><strong><?php echo $upload_dir['error']; ?></strong></p></div>
<?php
else :
?>
<form enctype="multipart/form-data" id="import-upload-form" method="post" class="wp-upload-form" action="<?php echo esc_url( wp_nonce_url( $action, 'import-upload' ) ); ?>">
@ -933,23 +988,28 @@ function add_meta_box( $id, $title, $callback, $screen = null, $context = 'advan
$page = $screen->id;
if ( !isset($wp_meta_boxes) )
if ( ! isset( $wp_meta_boxes ) ) {
$wp_meta_boxes = array();
if ( !isset($wp_meta_boxes[$page]) )
}
if ( ! isset( $wp_meta_boxes[ $page ] ) ) {
$wp_meta_boxes[ $page ] = array();
if ( !isset($wp_meta_boxes[$page][$context]) )
}
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]) )
if ( ! isset( $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ] ) ) {
continue;
}
// If a core box was previously added or removed by a plugin, don't add.
if ( 'core' == $priority ) {
// If core box previously deleted, don't add
if ( false === $wp_meta_boxes[$page][$a_context][$a_priority][$id] )
if ( false === $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ] ) {
return;
}
/*
* If box was added with default priority, give it core priority to
@ -974,18 +1034,26 @@ function add_meta_box( $id, $title, $callback, $screen = null, $context = 'advan
$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 )
if ( $priority != $a_priority || $context != $a_context ) {
unset( $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ] );
}
}
}
if ( empty($priority) )
if ( empty( $priority ) ) {
$priority = 'low';
}
if ( !isset($wp_meta_boxes[$page][$context][$priority]) )
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);
$wp_meta_boxes[ $page ][ $context ][ $priority ][ $id ] = array(
'id' => $id,
'title' => $title,
'callback' => $callback,
'args' => $callback_args,
);
}
/**
@ -1009,10 +1077,11 @@ function do_meta_boxes( $screen, $context, $object ) {
global $wp_meta_boxes;
static $already_sorted = false;
if ( empty( $screen ) )
if ( empty( $screen ) ) {
$screen = get_current_screen();
elseif ( is_string( $screen ) )
} elseif ( is_string( $screen ) ) {
$screen = convert_to_screen( $screen );
}
$page = $screen->id;
@ -1039,8 +1108,9 @@ function do_meta_boxes( $screen, $context, $object ) {
foreach ( array( 'high', 'sorted', 'core', 'default', 'low' ) as $priority ) {
if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) {
foreach ( (array) $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) {
if ( false == $box || ! $box['title'] )
if ( false == $box || ! $box['title'] ) {
continue;
}
$i++;
$hidden_class = in_array( $box['id'], $hidden ) ? ' hide-if-js' : '';
echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes( $box['id'], $page ) . $hidden_class . '" ' . '>' . "\n";
@ -1068,7 +1138,7 @@ function do_meta_boxes( $screen, $context, $object ) {
}
}
echo "</div>";
echo '</div>';
return $i;
@ -1111,16 +1181,20 @@ function remove_meta_box( $id, $screen, $context ) {
$page = $screen->id;
if ( !isset($wp_meta_boxes) )
if ( ! isset( $wp_meta_boxes ) ) {
$wp_meta_boxes = array();
if ( !isset($wp_meta_boxes[$page]) )
}
if ( ! isset( $wp_meta_boxes[ $page ] ) ) {
$wp_meta_boxes[ $page ] = array();
if ( !isset($wp_meta_boxes[$page][$context]) )
}
if ( ! isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
$wp_meta_boxes[ $page ][ $context ] = array();
}
foreach ( array('high', 'core', 'default', 'low') as $priority )
foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) {
$wp_meta_boxes[ $page ][ $context ][ $priority ][ $id ] = false;
}
}
/**
* Meta Box Accordion Template Function
@ -1143,10 +1217,11 @@ function do_accordion_sections( $screen, $context, $object ) {
wp_enqueue_script( 'accordion' );
if ( empty( $screen ) )
if ( empty( $screen ) ) {
$screen = get_current_screen();
elseif ( is_string( $screen ) )
} elseif ( is_string( $screen ) ) {
$screen = convert_to_screen( $screen );
}
$page = $screen->id;
@ -1162,8 +1237,9 @@ function do_accordion_sections( $screen, $context, $object ) {
foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) {
if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) {
foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) {
if ( false == $box || ! $box['title'] )
if ( false == $box || ! $box['title'] ) {
continue;
}
$i++;
$hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : '';
@ -1222,9 +1298,11 @@ function add_settings_section($id, $title, $callback, $page) {
global $wp_settings_sections;
if ( 'misc' == $page ) {
_deprecated_argument( __FUNCTION__, '3.0.0',
_deprecated_argument(
__FUNCTION__, '3.0.0',
/* translators: %s: misc */
sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ),
sprintf(
__( 'The "%s" options group has been removed. Use another settings group.' ),
'misc'
)
);
@ -1232,16 +1310,22 @@ function add_settings_section($id, $title, $callback, $page) {
}
if ( 'privacy' == $page ) {
_deprecated_argument( __FUNCTION__, '3.5.0',
_deprecated_argument(
__FUNCTION__, '3.5.0',
/* translators: %s: privacy */
sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ),
sprintf(
__( 'The "%s" options group has been removed. Use another settings group.' ),
'privacy'
)
);
$page = 'reading';
}
$wp_settings_sections[$page][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback);
$wp_settings_sections[ $page ][ $id ] = array(
'id' => $id,
'title' => $title,
'callback' => $callback,
);
}
/**
@ -1283,9 +1367,11 @@ function add_settings_field($id, $title, $callback, $page, $section = 'default',
global $wp_settings_fields;
if ( 'misc' == $page ) {
_deprecated_argument( __FUNCTION__, '3.0.0',
_deprecated_argument(
__FUNCTION__, '3.0.0',
/* translators: %s: misc */
sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ),
sprintf(
__( 'The "%s" options group has been removed. Use another settings group.' ),
'misc'
)
);
@ -1293,16 +1379,23 @@ function add_settings_field($id, $title, $callback, $page, $section = 'default',
}
if ( 'privacy' == $page ) {
_deprecated_argument( __FUNCTION__, '3.5.0',
_deprecated_argument(
__FUNCTION__, '3.5.0',
/* translators: %s: privacy */
sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ),
sprintf(
__( 'The "%s" options group has been removed. Use another settings group.' ),
'privacy'
)
);
$page = 'reading';
}
$wp_settings_fields[$page][$section][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $args);
$wp_settings_fields[ $page ][ $section ][ $id ] = array(
'id' => $id,
'title' => $title,
'callback' => $callback,
'args' => $args,
);
}
/**
@ -1321,18 +1414,22 @@ function add_settings_field($id, $title, $callback, $page, $section = 'default',
function do_settings_sections( $page ) {
global $wp_settings_sections, $wp_settings_fields;
if ( ! isset( $wp_settings_sections[$page] ) )
if ( ! isset( $wp_settings_sections[ $page ] ) ) {
return;
}
foreach ( (array) $wp_settings_sections[ $page ] as $section ) {
if ( $section['title'] )
if ( $section['title'] ) {
echo "<h2>{$section['title']}</h2>\n";
}
if ( $section['callback'] )
if ( $section['callback'] ) {
call_user_func( $section['callback'], $section );
}
if ( ! isset( $wp_settings_fields ) || !isset( $wp_settings_fields[$page] ) || !isset( $wp_settings_fields[$page][$section['id']] ) )
if ( ! isset( $wp_settings_fields ) || ! isset( $wp_settings_fields[ $page ] ) || ! isset( $wp_settings_fields[ $page ][ $section['id'] ] ) ) {
continue;
}
echo '<table class="form-table">';
do_settings_fields( $page, $section['id'] );
echo '</table>';
@ -1356,8 +1453,9 @@ function do_settings_sections( $page ) {
function do_settings_fields( $page, $section ) {
global $wp_settings_fields;
if ( ! isset( $wp_settings_fields[$page][$section] ) )
if ( ! isset( $wp_settings_fields[ $page ][ $section ] ) ) {
return;
}
foreach ( (array) $wp_settings_fields[ $page ][ $section ] as $field ) {
$class = '';
@ -1412,7 +1510,7 @@ function add_settings_error( $setting, $code, $message, $type = 'error' ) {
'setting' => $setting,
'code' => $code,
'message' => $message,
'type' => $type
'type' => $type,
);
}
@ -1447,8 +1545,9 @@ function get_settings_errors( $setting = '', $sanitize = false ) {
* This allows the $sanitize_callback from register_setting() to run, adding
* any settings errors you want to show by default.
*/
if ( $sanitize )
if ( $sanitize ) {
sanitize_option( $setting, get_option( $setting ) );
}
// If settings were passed back from options.php then use them.
if ( isset( $_GET['settings-updated'] ) && $_GET['settings-updated'] && get_transient( 'settings_errors' ) ) {
@ -1465,9 +1564,10 @@ function get_settings_errors( $setting = '', $sanitize = false ) {
if ( $setting ) {
$setting_errors = array();
foreach ( (array) $wp_settings_errors as $key => $details ) {
if ( $setting == $details['setting'] )
if ( $setting == $details['setting'] ) {
$setting_errors[] = $wp_settings_errors[ $key ];
}
}
return $setting_errors;
}
@ -1503,13 +1603,15 @@ function get_settings_errors( $setting = '', $sanitize = false ) {
*/
function settings_errors( $setting = '', $sanitize = false, $hide_on_update = false ) {
if ( $hide_on_update && ! empty( $_GET['settings-updated'] ) )
if ( $hide_on_update && ! empty( $_GET['settings-updated'] ) ) {
return;
}
$settings_errors = get_settings_errors( $setting, $sanitize );
if ( empty( $settings_errors ) )
if ( empty( $settings_errors ) ) {
return;
}
$output = '';
foreach ( $settings_errors as $key => $details ) {
@ -1568,9 +1670,10 @@ function find_posts_div($found_action = '') {
*/
function the_post_password() {
$post = get_post();
if ( isset( $post->post_password ) )
if ( isset( $post->post_password ) ) {
echo esc_attr( $post->post_password );
}
}
/**
* Get the post title.
@ -1585,8 +1688,9 @@ function the_post_password() {
*/
function _draft_or_post_title( $post = 0 ) {
$title = get_the_title( $post );
if ( empty( $title ) )
if ( empty( $title ) ) {
$title = __( '(no title)' );
}
return esc_html( $title );
}
@ -1624,7 +1728,7 @@ function iframe_header( $title = '', $deprecated = false ) {
@header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
_wp_admin_html_begin();
?>
<title><?php bloginfo('name') ?> &rsaquo; <?php echo $title ?> &#8212; <?php _e('WordPress'); ?></title>
<title><?php bloginfo( 'name' ); ?> &rsaquo; <?php echo $title; ?> &#8212; <?php _e( 'WordPress' ); ?></title>
<?php
wp_enqueue_style( 'colors' );
?>
@ -1663,8 +1767,9 @@ do_action( 'admin_head' );
$admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_user_locale() ) ) );
if ( is_rtl() )
if ( is_rtl() ) {
$admin_body_class .= ' rtl';
}
?>
</head>
@ -1672,11 +1777,16 @@ if ( is_rtl() )
/** This filter is documented in wp-admin/admin-header.php */
$admin_body_classes = apply_filters( 'admin_body_class', '' );
?>
<body<?php
<body
<?php
/**
* @global string $body_id
*/
if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?> class="wp-admin wp-core-ui no-js iframe <?php echo $admin_body_classes . ' ' . $admin_body_class; ?>">
if ( isset( $GLOBALS['body_id'] ) ) {
echo ' id="' . $GLOBALS['body_id'] . '"';
}
?>
class="wp-admin wp-core-ui no-js iframe <?php echo $admin_body_classes . ' ' . $admin_body_class; ?>">
<script type="text/javascript">
(function(){
var c = document.body.className;
@ -1723,20 +1833,22 @@ function iframe_footer() {
}
/**
*
* @param WP_Post $post
*/
function _post_states( $post ) {
$post_states = array();
if ( isset( $_REQUEST['post_status'] ) )
if ( isset( $_REQUEST['post_status'] ) ) {
$post_status = $_REQUEST['post_status'];
else
} else {
$post_status = '';
}
if ( !empty($post->post_password) )
if ( ! empty( $post->post_password ) ) {
$post_states['protected'] = __( 'Password protected' );
if ( 'private' == $post->post_status && 'private' != $post_status )
}
if ( 'private' == $post->post_status && 'private' != $post_status ) {
$post_states['private'] = __( 'Private' );
}
if ( 'draft' === $post->post_status ) {
if ( get_post_meta( $post->ID, '_customize_changeset_uuid', true ) ) {
$post_states[] = __( 'Customization Draft' );
@ -1746,10 +1858,12 @@ function _post_states($post) {
} elseif ( 'trash' === $post->post_status && get_post_meta( $post->ID, '_customize_changeset_uuid', true ) ) {
$post_states[] = __( 'Customization Draft' );
}
if ( 'pending' == $post->post_status && 'pending' != $post_status )
if ( 'pending' == $post->post_status && 'pending' != $post_status ) {
$post_states['pending'] = _x( 'Pending', 'post status' );
if ( is_sticky($post->ID) )
}
if ( is_sticky( $post->ID ) ) {
$post_states['sticky'] = __( 'Sticky' );
}
if ( 'future' === $post->post_status ) {
$post_states['scheduled'] = __( 'Scheduled' );
@ -1790,7 +1904,6 @@ function _post_states($post) {
}
/**
*
* @param WP_Post $post
*/
function _media_states( $post ) {
@ -1978,14 +2091,16 @@ function submit_button( $text = null, $type = 'primary', $name = 'submit', $wrap
* @return string Submit button HTML.
*/
function get_submit_button( $text = '', $type = 'primary large', $name = 'submit', $wrap = true, $other_attributes = '' ) {
if ( ! is_array( $type ) )
if ( ! is_array( $type ) ) {
$type = explode( ' ', $type );
}
$button_shorthand = array( 'primary', 'small', 'large' );
$classes = array( 'button' );
foreach ( $type as $t ) {
if ( 'secondary' === $t || 'button-secondary' === $t )
if ( 'secondary' === $t || 'button-secondary' === $t ) {
continue;
}
$classes[] = in_array( $t, $button_shorthand ) ? 'button-' . $t : $t;
}
// Remove empty items, remove duplicate items, and finally build a string.
@ -2024,7 +2139,6 @@ function get_submit_button( $text = '', $type = 'primary large', $name = 'submit
}
/**
*
* @global bool $is_IE
*/
function _wp_admin_html_begin() {
@ -2032,26 +2146,31 @@ function _wp_admin_html_begin() {
$admin_html_class = ( is_admin_bar_showing() ) ? 'wp-toolbar' : '';
if ( $is_IE )
if ( $is_IE ) {
@header( 'X-UA-Compatible: IE=edge' );
}
?>
<!DOCTYPE html>
<!--[if IE 8]>
<html xmlns="http://www.w3.org/1999/xhtml" class="ie8 <?php echo $admin_html_class; ?>" <?php
<html xmlns="http://www.w3.org/1999/xhtml" class="ie8 <?php echo $admin_html_class; ?>"
<?php
/**
* Fires inside the HTML tag in the admin header.
*
* @since 2.2.0
*/
do_action( 'admin_xml_ns' );
?> <?php language_attributes(); ?>>
?>
<?php language_attributes(); ?>>
<![endif]-->
<!--[if !(IE 8) ]><!-->
<html xmlns="http://www.w3.org/1999/xhtml" class="<?php echo $admin_html_class; ?>" <?php
<html xmlns="http://www.w3.org/1999/xhtml" class="<?php echo $admin_html_class; ?>"
<?php
/** This action is documented in wp-admin/includes/template.php */
do_action( 'admin_xml_ns' );
?> <?php language_attributes(); ?>>
?>
<?php language_attributes(); ?>>
<!--<![endif]-->
<head>
<meta http-equiv="Content-Type" content="<?php bloginfo( 'html_type' ); ?>; charset=<?php echo get_option( 'blog_charset' ); ?>" />
@ -2079,7 +2198,10 @@ function convert_to_screen( $hook_name ) {
),
'3.3.0'
);
return (object) array( 'id' => '_invalid', 'base' => '_are_belong_to_us' );
return (object) array(
'id' => '_invalid',
'base' => '_are_belong_to_us',
);
}
return WP_Screen::get( $hook_name );

View File

@ -6,17 +6,48 @@
* @subpackage Administration
*/
$themes_allowedtags = array('a' => array('href' => array(), 'title' => array(), 'target' => array()),
'abbr' => array('title' => array()), 'acronym' => array('title' => array()),
'code' => array(), 'pre' => array(), 'em' => array(), 'strong' => array(),
'div' => array(), 'p' => array(), 'ul' => array(), 'ol' => array(), 'li' => array(),
'h1' => array(), 'h2' => array(), 'h3' => array(), 'h4' => array(), 'h5' => array(), 'h6' => array(),
'img' => array('src' => array(), 'class' => array(), 'alt' => array())
$themes_allowedtags = array(
'a' => array(
'href' => array(),
'title' => array(),
'target' => array(),
),
'abbr' => array( 'title' => array() ),
'acronym' => array( 'title' => array() ),
'code' => array(),
'pre' => array(),
'em' => array(),
'strong' => array(),
'div' => array(),
'p' => array(),
'ul' => array(),
'ol' => array(),
'li' => array(),
'h1' => array(),
'h2' => array(),
'h3' => array(),
'h4' => array(),
'h5' => array(),
'h6' => array(),
'img' => array(
'src' => array(),
'class' => array(),
'alt' => array(),
),
);
$theme_field_defaults = array( 'description' => true, 'sections' => false, 'tested' => true, 'requires' => true,
'rating' => true, 'downloaded' => true, 'downloadlink' => true, 'last_updated' => true, 'homepage' => true,
'tags' => true, 'num_ratings' => true
$theme_field_defaults = array(
'description' => true,
'sections' => false,
'tested' => true,
'requires' => true,
'rating' => true,
'downloaded' => true,
'downloadlink' => true,
'last_updated' => true,
'homepage' => true,
'tags' => true,
'num_ratings' => true,
);
/**
@ -31,15 +62,18 @@ $theme_field_defaults = array( 'description' => true, 'sections' => false, 'test
function install_themes_feature_list() {
_deprecated_function( __FUNCTION__, '3.1.0', 'get_theme_feature_list()' );
if ( !$cache = get_transient( 'wporg_theme_feature_list' ) )
if ( ! $cache = get_transient( 'wporg_theme_feature_list' ) ) {
set_transient( 'wporg_theme_feature_list', array(), 3 * HOUR_IN_SECONDS );
}
if ( $cache )
if ( $cache ) {
return $cache;
}
$feature_list = themes_api( 'feature_list', array() );
if ( is_wp_error( $feature_list ) )
if ( is_wp_error( $feature_list ) ) {
return array();
}
set_transient( 'wporg_theme_feature_list', $feature_list, 3 * HOUR_IN_SECONDS );
@ -56,19 +90,21 @@ function install_themes_feature_list() {
function install_theme_search_form( $type_selector = true ) {
$type = isset( $_REQUEST['type'] ) ? wp_unslash( $_REQUEST['type'] ) : 'term';
$term = isset( $_REQUEST['s'] ) ? wp_unslash( $_REQUEST['s'] ) : '';
if ( ! $type_selector )
if ( ! $type_selector ) {
echo '<p class="install-help">' . __( 'Search for themes by keyword.' ) . '</p>';
}
?>
<form id="search-themes" method="get">
<input type="hidden" name="tab" value="search" />
<?php if ( $type_selector ) : ?>
<label class="screen-reader-text" for="typeselector"><?php _e( 'Type of search' ); ?></label>
<select name="type" id="typeselector">
<option value="term" <?php selected('term', $type) ?>><?php _e('Keyword'); ?></option>
<option value="author" <?php selected('author', $type) ?>><?php _e('Author'); ?></option>
<option value="tag" <?php selected('tag', $type) ?>><?php _ex('Tag', 'Theme Installer'); ?></option>
<option value="term" <?php selected( 'term', $type ); ?>><?php _e( 'Keyword' ); ?></option>
<option value="author" <?php selected( 'author', $type ); ?>><?php _e( 'Author' ); ?></option>
<option value="tag" <?php selected( 'tag', $type ); ?>><?php _ex( 'Tag', 'Theme Installer' ); ?></option>
</select>
<label class="screen-reader-text" for="s"><?php
<label class="screen-reader-text" for="s">
<?php
switch ( $type ) {
case 'term':
_e( 'Search by keyword' );
@ -80,11 +116,12 @@ function install_theme_search_form( $type_selector = true ) {
_e( 'Search by tag' );
break;
}
?></label>
?>
</label>
<?php else : ?>
<label class="screen-reader-text" for="s"><?php _e( 'Search by keyword' ); ?></label>
<?php endif; ?>
<input type="search" name="s" id="s" size="30" value="<?php echo esc_attr($term) ?>" autofocus="autofocus" />
<input type="search" name="s" id="s" size="30" value="<?php echo esc_attr( $term ); ?>" autofocus="autofocus" />
<?php submit_button( __( 'Search' ), '', 'search', false ); ?>
</form>
<?php
@ -98,7 +135,7 @@ function install_theme_search_form( $type_selector = true ) {
function install_themes_dashboard() {
install_theme_search_form( false );
?>
<h4><?php _e('Feature Filter') ?></h4>
<h4><?php _e( 'Feature Filter' ); ?></h4>
<p class="install-help"><?php _e( 'Find a theme based on specific features.' ); ?></p>
<form method="get">
@ -126,7 +163,8 @@ function install_themes_dashboard() {
</ol>
<br class="clear" />
<?php
} ?>
}
?>
</div>
<br class="clear" />
@ -199,8 +237,9 @@ function install_theme_information() {
$theme = themes_api( 'theme_information', array( 'slug' => wp_unslash( $_REQUEST['theme'] ) ) );
if ( is_wp_error( $theme ) )
if ( is_wp_error( $theme ) ) {
wp_die( $theme );
}
iframe_header( __( 'Theme Installation' ) );
if ( ! isset( $wp_list_table ) ) {

View File

@ -20,8 +20,9 @@
function delete_theme( $stylesheet, $redirect = '' ) {
global $wp_filesystem;
if ( empty($stylesheet) )
if ( empty( $stylesheet ) ) {
return false;
}
if ( empty( $redirect ) ) {
$redirect = wp_nonce_url( 'themes.php?action=delete&stylesheet=' . urlencode( $stylesheet ), 'delete-theme_' . $stylesheet );
@ -55,11 +56,13 @@ function delete_theme($stylesheet, $redirect = '') {
return;
}
if ( ! is_object($wp_filesystem) )
if ( ! is_object( $wp_filesystem ) ) {
return new WP_Error( 'fs_unavailable', __( 'Could not access filesystem.' ) );
}
if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() )
if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
return new WP_Error( 'fs_error', __( 'Filesystem error.' ), $wp_filesystem->errors );
}
// Get the base plugin folder.
$themes_dir = $wp_filesystem->wp_themes_dir();
@ -155,11 +158,13 @@ function theme_update_available( $theme ) {
function get_theme_update_available( $theme ) {
static $themes_update = null;
if ( !current_user_can('update_themes' ) )
if ( ! current_user_can( 'update_themes' ) ) {
return false;
}
if ( !isset($themes_update) )
if ( ! isset( $themes_update ) ) {
$themes_update = get_site_transient( 'update_themes' );
}
if ( ! ( $theme instanceof WP_Theme ) ) {
return false;
@ -172,16 +177,24 @@ function get_theme_update_available( $theme ) {
if ( isset( $themes_update->response[ $stylesheet ] ) ) {
$update = $themes_update->response[ $stylesheet ];
$theme_name = $theme->display( 'Name' );
$details_url = add_query_arg(array('TB_iframe' => 'true', 'width' => 1024, 'height' => 800), $update['url']); //Theme browser inside WP? replace this, Also, theme preview JS will override this on the available list.
$details_url = add_query_arg(
array(
'TB_iframe' => 'true',
'width' => 1024,
'height' => 800,
), $update['url']
); //Theme browser inside WP? replace this, Also, theme preview JS will override this on the available list.
$update_url = wp_nonce_url( admin_url( 'update.php?action=upgrade-theme&amp;theme=' . urlencode( $stylesheet ) ), 'upgrade-theme_' . $stylesheet );
if ( ! is_multisite() ) {
if ( ! current_user_can( 'update_themes' ) ) {
/* translators: 1: theme name, 2: theme details URL, 3: additional link attributes, 4: version number */
$html = sprintf( '<p><strong>' . __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>.' ) . '</strong></p>',
$html = sprintf(
'<p><strong>' . __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>.' ) . '</strong></p>',
$theme_name,
esc_url( $details_url ),
sprintf( 'class="thickbox open-plugin-details-modal" aria-label="%s"',
sprintf(
'class="thickbox open-plugin-details-modal" aria-label="%s"',
/* translators: 1: theme name, 2: version number */
esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme_name, $update['new_version'] ) )
),
@ -189,10 +202,12 @@ function get_theme_update_available( $theme ) {
);
} elseif ( empty( $update['package'] ) ) {
/* translators: 1: theme name, 2: theme details URL, 3: additional link attributes, 4: version number */
$html = sprintf( '<p><strong>' . __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>. <em>Automatic update is unavailable for this theme.</em>' ) . '</strong></p>',
$html = sprintf(
'<p><strong>' . __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>. <em>Automatic update is unavailable for this theme.</em>' ) . '</strong></p>',
$theme_name,
esc_url( $details_url ),
sprintf( 'class="thickbox open-plugin-details-modal" aria-label="%s"',
sprintf(
'class="thickbox open-plugin-details-modal" aria-label="%s"',
/* translators: 1: theme name, 2: version number */
esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme_name, $update['new_version'] ) )
),
@ -200,16 +215,19 @@ function get_theme_update_available( $theme ) {
);
} else {
/* translators: 1: theme name, 2: theme details URL, 3: additional link attributes, 4: version number, 5: update URL, 6: additional link attributes */
$html = sprintf( '<p><strong>' . __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a> or <a href="%5$s" %6$s>update now</a>.' ) . '</strong></p>',
$html = sprintf(
'<p><strong>' . __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a> or <a href="%5$s" %6$s>update now</a>.' ) . '</strong></p>',
$theme_name,
esc_url( $details_url ),
sprintf( 'class="thickbox open-plugin-details-modal" aria-label="%s"',
sprintf(
'class="thickbox open-plugin-details-modal" aria-label="%s"',
/* translators: 1: theme name, 2: version number */
esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme_name, $update['new_version'] ) )
),
$update['new_version'],
$update_url,
sprintf( 'aria-label="%s" id="update-theme" data-slug="%s"',
sprintf(
'aria-label="%s" id="update-theme" data-slug="%s"',
/* translators: %s: theme name */
esc_attr( sprintf( __( 'Update %s now' ), $theme_name ) ),
$stylesheet
@ -270,24 +288,28 @@ function get_theme_feature_list( $api = true ) {
'four-columns' => __( 'Four Columns' ),
'left-sidebar' => __( 'Left Sidebar' ),
'right-sidebar' => __( 'Right Sidebar' ),
)
),
);
if ( ! $api || ! current_user_can( 'install_themes' ) )
return $features;
if ( !$feature_list = get_site_transient( 'wporg_theme_feature_list' ) )
set_site_transient( 'wporg_theme_feature_list', array(), 3 * HOUR_IN_SECONDS );
if ( !$feature_list ) {
$feature_list = themes_api( 'feature_list', array() );
if ( is_wp_error( $feature_list ) )
if ( ! $api || ! current_user_can( 'install_themes' ) ) {
return $features;
}
if ( !$feature_list )
if ( ! $feature_list = get_site_transient( 'wporg_theme_feature_list' ) ) {
set_site_transient( 'wporg_theme_feature_list', array(), 3 * HOUR_IN_SECONDS );
}
if ( ! $feature_list ) {
$feature_list = themes_api( 'feature_list', array() );
if ( is_wp_error( $feature_list ) ) {
return $features;
}
}
if ( ! $feature_list ) {
return $features;
}
set_site_transient( 'wporg_theme_feature_list', $feature_list, 3 * HOUR_IN_SECONDS );
@ -300,17 +322,19 @@ function get_theme_feature_list( $api = true ) {
// Loop over the wporg canonical list and apply translations
$wporg_features = array();
foreach ( (array) $feature_list as $feature_category => $feature_items ) {
if ( isset($category_translations[$feature_category]) )
if ( isset( $category_translations[ $feature_category ] ) ) {
$feature_category = $category_translations[ $feature_category ];
}
$wporg_features[ $feature_category ] = array();
foreach ( $feature_items as $feature ) {
if ( isset($features[$feature_category][$feature]) )
if ( isset( $features[ $feature_category ][ $feature ] ) ) {
$wporg_features[ $feature_category ][ $feature ] = $features[ $feature_category ][ $feature ];
else
} else {
$wporg_features[ $feature_category ][ $feature ] = $feature;
}
}
}
return $wporg_features;
}
@ -445,15 +469,16 @@ function themes_api( $action, $args = array() ) {
include( ABSPATH . WPINC . '/version.php' );
$url = $http_url = 'http://api.wordpress.org/themes/info/1.0/';
if ( $ssl = wp_http_supports( array( 'ssl' ) ) )
if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) {
$url = set_url_scheme( $url, 'https' );
}
$http_args = array(
'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ),
'body' => array(
'action' => $action,
'request' => serialize( $args )
)
'request' => serialize( $args ),
),
);
$request = wp_remote_post( $url, $http_args );
@ -472,7 +497,8 @@ function themes_api( $action, $args = array() ) {
}
if ( is_wp_error( $request ) ) {
$res = new WP_Error( 'themes_api_failed',
$res = new WP_Error(
'themes_api_failed',
sprintf(
/* translators: %s: support forums URL */
__( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
@ -483,7 +509,8 @@ function themes_api( $action, $args = array() ) {
} else {
$res = maybe_unserialize( wp_remote_retrieve_body( $request ) );
if ( ! is_object( $res ) && ! is_array( $res ) ) {
$res = new WP_Error( 'themes_api_failed',
$res = new WP_Error(
'themes_api_failed',
sprintf(
/* translators: %s: support forums URL */
__( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
@ -574,12 +601,14 @@ function wp_prepare_themes_for_js( $themes = null ) {
$customize_action = null;
if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
$customize_action = esc_url( add_query_arg(
$customize_action = esc_url(
add_query_arg(
array(
'return' => urlencode( esc_url_raw( remove_query_arg( wp_removable_query_args(), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) ),
),
wp_customize_url( $slug )
) );
)
);
}
$prepared_themes[ $slug ] = array(

View File

@ -69,7 +69,8 @@ function translations_api( $type, $args = null ) {
}
if ( is_wp_error( $request ) ) {
$res = new WP_Error( 'translations_api_failed',
$res = new WP_Error(
'translations_api_failed',
sprintf(
/* translators: %s: support forums URL */
__( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
@ -80,7 +81,8 @@ function translations_api( $type, $args = null ) {
} else {
$res = json_decode( wp_remote_retrieve_body( $request ), true );
if ( ! is_object( $res ) && ! is_array( $res ) ) {
$res = new WP_Error( 'translations_api_failed',
$res = new WP_Error(
'translations_api_failed',
sprintf(
/* translators: %s: support forums URL */
__( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
@ -162,24 +164,28 @@ function wp_install_language_form( $languages ) {
if ( ! empty( $wp_local_package ) && isset( $languages[ $wp_local_package ] ) ) {
if ( isset( $languages[ $wp_local_package ] ) ) {
$language = $languages[ $wp_local_package ];
printf( '<option value="%s" lang="%s" data-continue="%s"%s>%s</option>' . "\n",
printf(
'<option value="%s" lang="%s" data-continue="%s"%s>%s</option>' . "\n",
esc_attr( $language['language'] ),
esc_attr( current( $language['iso'] ) ),
esc_attr( $language['strings']['continue'] ),
in_array( $language['language'], $installed_languages ) ? ' data-installed="1"' : '',
esc_html( $language['native_name'] ) );
esc_html( $language['native_name'] )
);
unset( $languages[ $wp_local_package ] );
}
}
foreach ( $languages as $language ) {
printf( '<option value="%s" lang="%s" data-continue="%s"%s>%s</option>' . "\n",
printf(
'<option value="%s" lang="%s" data-continue="%s"%s>%s</option>' . "\n",
esc_attr( $language['language'] ),
esc_attr( current( $language['iso'] ) ),
esc_attr( $language['strings']['continue'] ),
in_array( $language['language'], $installed_languages ) ? ' data-installed="1"' : '',
esc_html( $language['native_name'] ) );
esc_html( $language['native_name'] )
);
}
echo "</select>\n";
echo '<p class="step"><span class="spinner"></span><input id="language-continue" type="submit" class="button button-primary button-large" value="Continue" /></p>';

View File

@ -872,7 +872,6 @@ function update_core($from, $to) {
return new WP_Error( 'insane_distro', __( 'The update could not be unpacked' ) );
}
/*
* Import $wp_version, $required_php_version, and $required_mysql_version from the new version.
* DO NOT globalise any variables imported from `version-current.php` in this function.
@ -894,20 +893,23 @@ function update_core($from, $to) {
$old_wp_version = $GLOBALS['wp_version']; // The version of WordPress we're updating from
$development_build = ( false !== strpos( $old_wp_version . $wp_version, '-' ) ); // a dash in the version indicates a Development release
$php_compat = version_compare( $php_version, $required_php_version, '>=' );
if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) )
if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) ) {
$mysql_compat = true;
else
} else {
$mysql_compat = version_compare( $mysql_version, $required_mysql_version, '>=' );
}
if ( !$mysql_compat || !$php_compat )
if ( ! $mysql_compat || ! $php_compat ) {
$wp_filesystem->delete( $from, true );
}
if ( !$mysql_compat && !$php_compat )
if ( ! $mysql_compat && ! $php_compat ) {
return new WP_Error( 'php_mysql_not_compatible', sprintf( __( 'The update cannot be installed because WordPress %1$s requires PHP version %2$s or higher and MySQL version %3$s or higher. You are running PHP version %4$s and MySQL version %5$s.' ), $wp_version, $required_php_version, $required_mysql_version, $php_version, $mysql_version ) );
elseif ( !$php_compat )
} elseif ( ! $php_compat ) {
return new WP_Error( 'php_not_compatible', sprintf( __( 'The update cannot be installed because WordPress %1$s requires PHP version %2$s or higher. You are running version %3$s.' ), $wp_version, $required_php_version, $php_version ) );
elseif ( !$mysql_compat )
} elseif ( ! $mysql_compat ) {
return new WP_Error( 'mysql_not_compatible', sprintf( __( 'The update cannot be installed because WordPress %1$s requires MySQL version %2$s or higher. You are running version %3$s.' ), $wp_version, $required_mysql_version, $mysql_version ) );
}
/** This filter is documented in wp-admin/includes/update-core.php */
apply_filters( 'update_feedback', __( 'Preparing to install the latest version&#8230;' ) );
@ -923,25 +925,31 @@ function update_core($from, $to) {
$working_dir_local = WP_CONTENT_DIR . '/upgrade/' . basename( $from ) . $distro;
$checksums = get_core_checksums( $wp_version, isset( $wp_local_package ) ? $wp_local_package : 'en_US' );
if ( is_array( $checksums ) && isset( $checksums[ $wp_version ] ) )
if ( is_array( $checksums ) && isset( $checksums[ $wp_version ] ) ) {
$checksums = $checksums[ $wp_version ]; // Compat code for 3.7-beta2
}
if ( is_array( $checksums ) ) {
foreach ( $checksums as $file => $checksum ) {
if ( 'wp-content' == substr( $file, 0, 10 ) )
if ( 'wp-content' == substr( $file, 0, 10 ) ) {
continue;
if ( ! file_exists( ABSPATH . $file ) )
}
if ( ! file_exists( ABSPATH . $file ) ) {
continue;
if ( ! file_exists( $working_dir_local . $file ) )
}
if ( ! file_exists( $working_dir_local . $file ) ) {
continue;
if ( '.' === dirname( $file ) && in_array( pathinfo( $file, PATHINFO_EXTENSION ), array( 'html', 'txt' ) ) )
}
if ( '.' === dirname( $file ) && in_array( pathinfo( $file, PATHINFO_EXTENSION ), array( 'html', 'txt' ) ) ) {
continue;
if ( md5_file( ABSPATH . $file ) === $checksum )
}
if ( md5_file( ABSPATH . $file ) === $checksum ) {
$skip[] = $file;
else
} else {
$check_is_writable[ $file ] = ABSPATH . $file;
}
}
}
}
// If we're using the direct method, we can predict write failures that are due to permissions.
if ( $check_is_writable && 'direct' === $wp_filesystem->method ) {
@ -951,17 +959,19 @@ function update_core($from, $to) {
foreach ( $files_not_writable as $relative_file_not_writable => $file_not_writable ) {
// If the writable check failed, chmod file to 0644 and try again, same as copy_dir().
$wp_filesystem->chmod( $file_not_writable, FS_CHMOD_FILE );
if ( $wp_filesystem->is_writable( $file_not_writable ) )
if ( $wp_filesystem->is_writable( $file_not_writable ) ) {
unset( $files_not_writable[ $relative_file_not_writable ] );
}
}
// Store package-relative paths (the key) of non-writable files in the WP_Error object.
$error_data = version_compare( $old_wp_version, '3.7-beta2', '>' ) ? array_keys( $files_not_writable ) : '';
if ( $files_not_writable )
if ( $files_not_writable ) {
return new WP_Error( 'files_not_writable', __( 'The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.' ), implode( ', ', $error_data ) );
}
}
}
/** This filter is documented in wp-admin/includes/update-core.php */
apply_filters( 'update_feedback', __( 'Enabling Maintenance mode&#8230;' ) );
@ -975,8 +985,9 @@ function update_core($from, $to) {
apply_filters( 'update_feedback', __( 'Copying the required files&#8230;' ) );
// Copy new versions of WP files into place.
$result = _copy_dir( $from . $distro, $to, $skip );
if ( is_wp_error( $result ) )
if ( is_wp_error( $result ) ) {
$result = new WP_Error( $result->get_error_code(), $result->get_error_message(), substr( $result->get_error_data(), strlen( $to ) ) );
}
// Since we know the core files have copied over, we can now copy the version file
if ( ! is_wp_error( $result ) ) {
@ -992,28 +1003,32 @@ function update_core($from, $to) {
$failed = array();
if ( isset( $checksums ) && is_array( $checksums ) ) {
foreach ( $checksums as $file => $checksum ) {
if ( 'wp-content' == substr( $file, 0, 10 ) )
if ( 'wp-content' == substr( $file, 0, 10 ) ) {
continue;
if ( ! file_exists( $working_dir_local . $file ) )
}
if ( ! file_exists( $working_dir_local . $file ) ) {
continue;
}
if ( '.' === dirname( $file ) && in_array( pathinfo( $file, PATHINFO_EXTENSION ), array( 'html', 'txt' ) ) ) {
$skip[] = $file;
continue;
}
if ( file_exists( ABSPATH . $file ) && md5_file( ABSPATH . $file ) == $checksum )
if ( file_exists( ABSPATH . $file ) && md5_file( ABSPATH . $file ) == $checksum ) {
$skip[] = $file;
else
} else {
$failed[] = $file;
}
}
}
// Some files didn't copy properly
if ( ! empty( $failed ) ) {
$total_size = 0;
foreach ( $failed as $file ) {
if ( file_exists( $working_dir_local . $file ) )
if ( file_exists( $working_dir_local . $file ) ) {
$total_size += filesize( $working_dir_local . $file );
}
}
// If we don't have enough free space, it isn't worth trying again.
// Unlikely to be hit due to the check in unzip_file().
@ -1022,18 +1037,20 @@ function update_core($from, $to) {
$result = new WP_Error( 'disk_full', __( 'There is not enough free disk space to complete the update.' ) );
} else {
$result = _copy_dir( $from . $distro, $to, $skip );
if ( is_wp_error( $result ) )
if ( is_wp_error( $result ) ) {
$result = new WP_Error( $result->get_error_code() . '_retry', $result->get_error_message(), substr( $result->get_error_data(), strlen( $to ) ) );
}
}
}
// Custom Content Directory needs updating now.
// Copy Languages
if ( ! is_wp_error( $result ) && $wp_filesystem->is_dir( $from . $distro . 'wp-content/languages' ) ) {
if ( WP_LANG_DIR != ABSPATH . WPINC . '/languages' || @is_dir(WP_LANG_DIR) )
if ( WP_LANG_DIR != ABSPATH . WPINC . '/languages' || @is_dir( WP_LANG_DIR ) ) {
$lang_dir = WP_LANG_DIR;
else
} else {
$lang_dir = WP_CONTENT_DIR . '/languages';
}
if ( ! @is_dir( $lang_dir ) && 0 === strpos( $lang_dir, ABSPATH ) ) { // Check the language directory exists first
$wp_filesystem->mkdir( $to . str_replace( ABSPATH, '', $lang_dir ), FS_CHMOD_DIR ); // If it's within the ABSPATH we can handle it here, otherwise they're out of luck.
@ -1044,11 +1061,12 @@ function update_core($from, $to) {
$wp_lang_dir = $wp_filesystem->find_folder( $lang_dir );
if ( $wp_lang_dir ) {
$result = copy_dir( $from . $distro . 'wp-content/languages/', $wp_lang_dir );
if ( is_wp_error( $result ) )
if ( is_wp_error( $result ) ) {
$result = new WP_Error( $result->get_error_code() . '_languages', $result->get_error_message(), substr( $result->get_error_data(), strlen( $wp_lang_dir ) ) );
}
}
}
}
/** This filter is documented in wp-admin/includes/update-core.php */
apply_filters( 'update_feedback', __( 'Disabling Maintenance mode&#8230;' ) );
@ -1073,33 +1091,39 @@ function update_core($from, $to) {
list($type, $filename) = explode( '/', $file, 2 );
// Check to see if the bundled items exist before attempting to copy them
if ( ! $wp_filesystem->exists( $from . $distro . 'wp-content/' . $file ) )
if ( ! $wp_filesystem->exists( $from . $distro . 'wp-content/' . $file ) ) {
continue;
}
if ( 'plugins' == $type )
if ( 'plugins' == $type ) {
$dest = $wp_filesystem->wp_plugins_dir();
elseif ( 'themes' == $type )
} elseif ( 'themes' == $type ) {
$dest = trailingslashit( $wp_filesystem->wp_themes_dir() ); // Back-compat, ::wp_themes_dir() did not return trailingslash'd pre-3.2
else
} else {
continue;
}
if ( ! $directory ) {
if ( ! $development_build && $wp_filesystem->exists( $dest . $filename ) )
if ( ! $development_build && $wp_filesystem->exists( $dest . $filename ) ) {
continue;
}
if ( ! $wp_filesystem->copy($from . $distro . 'wp-content/' . $file, $dest . $filename, FS_CHMOD_FILE) )
if ( ! $wp_filesystem->copy( $from . $distro . 'wp-content/' . $file, $dest . $filename, FS_CHMOD_FILE ) ) {
$result = new WP_Error( "copy_failed_for_new_bundled_$type", __( 'Could not copy file.' ), $dest . $filename );
}
} else {
if ( ! $development_build && $wp_filesystem->is_dir( $dest . $filename ) )
if ( ! $development_build && $wp_filesystem->is_dir( $dest . $filename ) ) {
continue;
}
$wp_filesystem->mkdir( $dest . $filename, FS_CHMOD_DIR );
$_result = copy_dir( $from . $distro . 'wp-content/' . $file, $dest . $filename );
// If a error occurs partway through this final step, keep the error flowing through, but keep process going.
if ( is_wp_error( $_result ) ) {
if ( ! is_wp_error( $result ) )
if ( ! is_wp_error( $result ) ) {
$result = new WP_Error;
}
$result->add( $_result->get_error_code() . "_$type", $_result->get_error_message(), substr( $_result->get_error_data(), strlen( $dest ) ) );
}
}
@ -1116,8 +1140,9 @@ function update_core($from, $to) {
// Remove old files
foreach ( $_old_files as $old_file ) {
$old_file = $to . $old_file;
if ( !$wp_filesystem->exists($old_file) )
if ( ! $wp_filesystem->exists( $old_file ) ) {
continue;
}
$wp_filesystem->delete( $old_file, true );
}
@ -1142,10 +1167,11 @@ function update_core($from, $to) {
$wp_filesystem->delete( $from, true );
// Force refresh of update information
if ( function_exists('delete_site_transient') )
if ( function_exists( 'delete_site_transient' ) ) {
delete_site_transient( 'update_core' );
else
} else {
delete_option( 'update_core' );
}
/**
* Fires after WordPress core has been successfully updated.
@ -1157,8 +1183,9 @@ function update_core($from, $to) {
do_action( '_core_updated_successfully', $wp_version );
// Clear the option that blocks auto updates after failures, now that we've been successful.
if ( function_exists( 'delete_site_option' ) )
if ( function_exists( 'delete_site_option' ) ) {
delete_site_option( 'auto_core_update_failed' );
}
return $wp_version;
}
@ -1191,21 +1218,24 @@ function _copy_dir($from, $to, $skip_list = array() ) {
$to = trailingslashit( $to );
foreach ( (array) $dirlist as $filename => $fileinfo ) {
if ( in_array( $filename, $skip_list ) )
if ( in_array( $filename, $skip_list ) ) {
continue;
}
if ( 'f' == $fileinfo['type'] ) {
if ( ! $wp_filesystem->copy( $from . $filename, $to . $filename, true, FS_CHMOD_FILE ) ) {
// If copy failed, chmod file to 0644 and try again.
$wp_filesystem->chmod( $to . $filename, FS_CHMOD_FILE );
if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) )
if ( ! $wp_filesystem->copy( $from . $filename, $to . $filename, true, FS_CHMOD_FILE ) ) {
return new WP_Error( 'copy_failed__copy_dir', __( 'Could not copy file.' ), $to . $filename );
}
}
} elseif ( 'd' == $fileinfo['type'] ) {
if ( ! $wp_filesystem->is_dir( $to . $filename ) ) {
if ( !$wp_filesystem->mkdir($to . $filename, FS_CHMOD_DIR) )
if ( ! $wp_filesystem->mkdir( $to . $filename, FS_CHMOD_DIR ) ) {
return new WP_Error( 'mkdir_failed__copy_dir', __( 'Could not create directory.' ), $to . $filename );
}
}
/*
* Generate the $sub_skip_list for the subdirectory as a sub-set
@ -1213,15 +1243,17 @@ function _copy_dir($from, $to, $skip_list = array() ) {
*/
$sub_skip_list = array();
foreach ( $skip_list as $skip_item ) {
if ( 0 === strpos( $skip_item, $filename . '/' ) )
if ( 0 === strpos( $skip_item, $filename . '/' ) ) {
$sub_skip_list[] = preg_replace( '!^' . preg_quote( $filename, '!' ) . '/!i', '', $skip_item );
}
}
$result = _copy_dir( $from . $filename, $to . $filename, $sub_skip_list );
if ( is_wp_error($result) )
if ( is_wp_error( $result ) ) {
return $result;
}
}
}
return true;
}
@ -1241,15 +1273,18 @@ function _copy_dir($from, $to, $skip_list = array() ) {
function _redirect_to_about_wordpress( $new_version ) {
global $wp_version, $pagenow, $action;
if ( version_compare( $wp_version, '3.4-RC1', '>=' ) )
if ( version_compare( $wp_version, '3.4-RC1', '>=' ) ) {
return;
}
// Ensure we only run this on the update-core.php page. The Core_Upgrader may be used in other contexts.
if ( 'update-core.php' != $pagenow )
if ( 'update-core.php' != $pagenow ) {
return;
}
if ( 'do-core-upgrade' != $action && 'do-core-reinstall' != $action )
if ( 'do-core-upgrade' != $action && 'do-core-reinstall' != $action ) {
return;
}
// Load the updated default text localization domain for new strings.
load_default_textdomain();

Some files were not shown because too many files have changed in this diff Show More