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:
parent
62be7ad218
commit
aaf99e6913
|
@ -11,7 +11,7 @@
|
|||
*
|
||||
* @var bool
|
||||
*/
|
||||
define('WP_USE_THEMES', true);
|
||||
define( 'WP_USE_THEMES', true );
|
||||
|
||||
/** Loads the WordPress Environment and Template */
|
||||
require( dirname( __FILE__ ) . '/wp-blog-header.php' );
|
||||
|
|
|
@ -9,17 +9,18 @@
|
|||
define( 'WP_INSTALLING', true );
|
||||
|
||||
/** Sets up the WordPress Environment. */
|
||||
require( dirname(__FILE__) . '/wp-load.php' );
|
||||
require( dirname( __FILE__ ) . '/wp-load.php' );
|
||||
|
||||
require( dirname( __FILE__ ) . '/wp-blog-header.php' );
|
||||
|
||||
if ( !is_multisite() ) {
|
||||
if ( ! is_multisite() ) {
|
||||
wp_redirect( wp_registration_url() );
|
||||
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;
|
||||
|
@ -43,10 +44,10 @@ function do_activate_header() {
|
|||
* Fires before the Site Activation page is loaded.
|
||||
*
|
||||
* Fires on the {@see 'wp_head'} action.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
do_action( 'activate_wp_head' );
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
do_action( 'activate_wp_head' );
|
||||
}
|
||||
add_action( 'wp_head', 'do_activate_header' );
|
||||
|
||||
|
@ -73,28 +74,29 @@ get_header( 'wp-activate' );
|
|||
|
||||
<div id="signup-content" class="widecolumn">
|
||||
<div class="wp-activate-container">
|
||||
<?php if ( empty($_GET['key']) && empty($_POST['key']) ) { ?>
|
||||
<?php if ( empty( $_GET['key'] ) && empty( $_POST['key'] ) ) { ?>
|
||||
|
||||
<h2><?php _e('Activation Key Required') ?></h2>
|
||||
<form name="activateform" id="activateform" method="post" action="<?php echo network_site_url('wp-activate.php'); ?>">
|
||||
<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>
|
||||
<br /><input type="text" name="key" id="key" value="" size="50" />
|
||||
<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 );
|
||||
if ( is_wp_error($result) ) {
|
||||
if ( 'already_active' == $result->get_error_code() || 'blog_taken' == $result->get_error_code() ) {
|
||||
$signup = $result->get_error_data();
|
||||
?>
|
||||
<h2><?php _e('Your account is now active!'); ?></h2>
|
||||
$key = ! empty( $_GET['key'] ) ? $_GET['key'] : $_POST['key'];
|
||||
$result = wpmu_activate_signup( $key );
|
||||
if ( is_wp_error( $result ) ) {
|
||||
if ( 'already_active' == $result->get_error_code() || 'blog_taken' == $result->get_error_code() ) {
|
||||
$signup = $result->get_error_data();
|
||||
?>
|
||||
<h2><?php _e( 'Your account is now active!' ); ?></h2>
|
||||
<?php
|
||||
echo '<p class="lead-in">';
|
||||
if ( $signup->domain . $signup->path == '' ) {
|
||||
|
@ -117,40 +119,46 @@ get_header( 'wp-activate' );
|
|||
);
|
||||
}
|
||||
echo '</p>';
|
||||
} else {
|
||||
?>
|
||||
<h2><?php _e( 'An error occurred during the activation' ); ?></h2>
|
||||
} else {
|
||||
?>
|
||||
<h2><?php _e( 'An error occurred during the activation' ); ?></h2>
|
||||
<p><?php echo $result->get_error_message(); ?></p>
|
||||
<?php
|
||||
}
|
||||
} else {
|
||||
$url = isset( $result['blog_id'] ) ? get_home_url( (int) $result['blog_id'] ) : '';
|
||||
$user = get_userdata( (int) $result['user_id'] );
|
||||
?>
|
||||
<h2><?php _e('Your account is now active!'); ?></h2>
|
||||
}
|
||||
} else {
|
||||
$url = isset( $result['blog_id'] ) ? get_home_url( (int) $result['blog_id'] ) : '';
|
||||
$user = get_userdata( (int) $result['user_id'] );
|
||||
?>
|
||||
<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('Password:'); ?></span> <?php echo $result['password']; ?></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>
|
||||
<?php else: ?>
|
||||
<p class="view"><?php
|
||||
?>
|
||||
</p>
|
||||
<?php else : ?>
|
||||
<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;
|
||||
}
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -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' );
|
||||
|
|
|
@ -77,7 +77,7 @@ include( ABSPATH . 'wp-admin/admin-header.php' );
|
|||
<img src="https://s.w.org/images/core/4.9/locking.svg" alt="">
|
||||
</div>
|
||||
<h3><?php _e( 'Design Locking To Guard Your Changes' ); ?></h3>
|
||||
<p><?php _e( 'Ever encounter a scenario where two designers walk into a project and designer A overrides designer B’s beautiful changes? WordPress 4.9’s design lock feature (similar to post locking) secures your draft design so that no one can make changes to it or erase all your hard work.' );?></p>
|
||||
<p><?php _e( 'Ever encounter a scenario where two designers walk into a project and designer A overrides designer B’s beautiful changes? WordPress 4.9’s design lock feature (similar to post locking) secures your draft design so that no one can make changes to it or erase all your hard work.' ); ?></p>
|
||||
</div>
|
||||
<div class="section-item">
|
||||
<div class="inline-svg">
|
||||
|
@ -114,7 +114,7 @@ include( ABSPATH . 'wp-admin/admin-header.php' );
|
|||
<img src="https://s.w.org/images/core/4.9/warning.svg" alt="">
|
||||
</div>
|
||||
<h3><?php _e( 'Warning: Potential Danger Ahead!' ); ?></h3>
|
||||
<p><?php _e( 'When you edit themes and plugins directly, WordPress 4.9 will politely warn you that this is a dangerous practice. It will recommend that you backup your files before saving, so they don’t get overwritten by the next update. Take the safe route: your future self will thank you. Your team and customers will thank you.' );?></p>
|
||||
<p><?php _e( 'When you edit themes and plugins directly, WordPress 4.9 will politely warn you that this is a dangerous practice. It will recommend that you backup your files before saving, so they don’t get overwritten by the next update. Take the safe route: your future self will thank you. Your team and customers will thank you.' ); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -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’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’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' ),
|
||||
'😊'
|
||||
);
|
||||
?></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’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>.' );
|
||||
|
|
|
@ -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,39 +45,104 @@ 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
|
||||
$core_actions_post_deprecated = array( 'wp-fullscreen-save-post', 'press-this-save-post', 'press-this-add-category' );
|
||||
$core_actions_post = array_merge( $core_actions_post, $core_actions_post_deprecated );
|
||||
$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 );
|
||||
|
||||
|
|
|
@ -7,8 +7,9 @@
|
|||
*/
|
||||
|
||||
// don't load directly
|
||||
if ( !defined('ABSPATH') )
|
||||
die('-1');
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
die( '-1' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @global string $hook_suffix
|
||||
|
@ -99,9 +100,10 @@ do_action( 'admin_print_footer_scripts' );
|
|||
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 ( function_exists( 'get_site_option' ) ) {
|
||||
if ( false === get_site_option( 'can_compress_scripts' ) ) {
|
||||
compression_test();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
* @subpackage Administration
|
||||
*/
|
||||
|
||||
_deprecated_file( basename(__FILE__), '2.5.0', 'wp-admin/includes/admin.php' );
|
||||
_deprecated_file( basename( __FILE__ ), '2.5.0', 'wp-admin/includes/admin.php' );
|
||||
|
||||
/** WordPress Administration API: Includes all Administration functions. */
|
||||
require_once(ABSPATH . 'wp-admin/includes/admin.php');
|
||||
require_once( ABSPATH . 'wp-admin/includes/admin.php' );
|
||||
|
|
|
@ -6,9 +6,10 @@
|
|||
* @subpackage Administration
|
||||
*/
|
||||
|
||||
@header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
|
||||
if ( ! defined( 'WP_ADMIN' ) )
|
||||
@header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
|
||||
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 ) );
|
||||
|
@ -69,10 +71,10 @@ _wp_admin_html_begin();
|
|||
|
||||
wp_enqueue_style( 'colors' );
|
||||
wp_enqueue_style( 'ie' );
|
||||
wp_enqueue_script('utils');
|
||||
wp_enqueue_script( 'utils' );
|
||||
wp_enqueue_script( 'svg-painter' );
|
||||
|
||||
$admin_body_class = preg_replace('/[^a-z0-9_-]+/i', '-', $hook_suffix);
|
||||
$admin_body_class = preg_replace( '/[^a-z0-9_-]+/i', '-', $hook_suffix );
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
|
||||
|
@ -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';
|
||||
|
||||
|
@ -207,7 +218,7 @@ if ( current_user_can( 'customize' ) ) {
|
|||
?>
|
||||
|
||||
<div id="wpwrap">
|
||||
<?php require(ABSPATH . 'wp-admin/menu-header.php'); ?>
|
||||
<?php require( ABSPATH . 'wp-admin/menu-header.php' ); ?>
|
||||
<div id="wpcontent">
|
||||
|
||||
<?php
|
||||
|
@ -221,13 +232,13 @@ do_action( 'in_admin_header' );
|
|||
|
||||
<div id="wpbody" role="main">
|
||||
<?php
|
||||
unset($title_class, $blog_name, $total_update_count, $update_title);
|
||||
unset( $title_class, $blog_name, $total_update_count, $update_title );
|
||||
|
||||
$current_screen->set_parentage( $parent_file );
|
||||
|
||||
?>
|
||||
|
||||
<div id="wpbody-content" aria-label="<?php esc_attr_e('Main content'); ?>" tabindex="0">
|
||||
<div id="wpbody-content" aria-label="<?php esc_attr_e( 'Main content' ); ?>" tabindex="0">
|
||||
<?php
|
||||
|
||||
$current_screen->render_screen_meta();
|
||||
|
@ -262,5 +273,6 @@ if ( is_network_admin() ) {
|
|||
*/
|
||||
do_action( 'all_admin_notices' );
|
||||
|
||||
if ( $parent_file == 'options-general.php' )
|
||||
require(ABSPATH . 'wp-admin/options-head.php');
|
||||
if ( $parent_file == 'options-general.php' ) {
|
||||
require( ABSPATH . 'wp-admin/options-head.php' );
|
||||
}
|
||||
|
|
|
@ -13,15 +13,16 @@ if ( ! defined( 'WP_ADMIN' ) ) {
|
|||
define( 'WP_ADMIN', true );
|
||||
}
|
||||
|
||||
if ( defined('ABSPATH') )
|
||||
require_once(ABSPATH . 'wp-load.php');
|
||||
else
|
||||
if ( defined( 'ABSPATH' ) ) {
|
||||
require_once( ABSPATH . 'wp-load.php' );
|
||||
} else {
|
||||
require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );
|
||||
}
|
||||
|
||||
/** Allow for cross-domain requests (from the front end). */
|
||||
send_origin_headers();
|
||||
|
||||
require_once(ABSPATH . 'wp-admin/includes/admin.php');
|
||||
require_once( ABSPATH . 'wp-admin/includes/admin.php' );
|
||||
|
||||
nocache_headers();
|
||||
|
||||
|
|
|
@ -15,26 +15,29 @@ if ( ! defined( 'WP_ADMIN' ) ) {
|
|||
define( 'WP_ADMIN', true );
|
||||
}
|
||||
|
||||
if ( ! defined('WP_NETWORK_ADMIN') )
|
||||
define('WP_NETWORK_ADMIN', false);
|
||||
|
||||
if ( ! defined('WP_USER_ADMIN') )
|
||||
define('WP_USER_ADMIN', false);
|
||||
|
||||
if ( ! WP_NETWORK_ADMIN && ! WP_USER_ADMIN ) {
|
||||
define('WP_BLOG_ADMIN', true);
|
||||
if ( ! defined( 'WP_NETWORK_ADMIN' ) ) {
|
||||
define( 'WP_NETWORK_ADMIN', false );
|
||||
}
|
||||
|
||||
if ( isset($_GET['import']) && !defined('WP_LOAD_IMPORTERS') )
|
||||
define('WP_LOAD_IMPORTERS', true);
|
||||
if ( ! defined( 'WP_USER_ADMIN' ) ) {
|
||||
define( 'WP_USER_ADMIN', false );
|
||||
}
|
||||
|
||||
require_once(dirname(dirname(__FILE__)) . '/wp-load.php');
|
||||
if ( ! WP_NETWORK_ADMIN && ! WP_USER_ADMIN ) {
|
||||
define( 'WP_BLOG_ADMIN', true );
|
||||
}
|
||||
|
||||
if ( isset( $_GET['import'] ) && ! defined( 'WP_LOAD_IMPORTERS' ) ) {
|
||||
define( 'WP_LOAD_IMPORTERS', true );
|
||||
}
|
||||
|
||||
require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );
|
||||
|
||||
nocache_headers();
|
||||
|
||||
if ( get_option('db_upgraded') ) {
|
||||
if ( get_option( 'db_upgraded' ) ) {
|
||||
flush_rewrite_rules();
|
||||
update_option( 'db_upgraded', false );
|
||||
update_option( 'db_upgraded', false );
|
||||
|
||||
/**
|
||||
* Fires on the next page load after a successful DB upgrade.
|
||||
|
@ -42,25 +45,25 @@ if ( get_option('db_upgraded') ) {
|
|||
* @since 2.8.0
|
||||
*/
|
||||
do_action( 'after_db_upgrade' );
|
||||
} elseif ( get_option('db_version') != $wp_db_version && empty($_POST) ) {
|
||||
if ( !is_multisite() ) {
|
||||
} elseif ( get_option( 'db_version' ) != $wp_db_version && empty( $_POST ) ) {
|
||||
if ( ! is_multisite() ) {
|
||||
wp_redirect( admin_url( 'upgrade.php?_wp_http_referer=' . urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) );
|
||||
exit;
|
||||
|
||||
/**
|
||||
* Filters whether to attempt to perform the multisite DB upgrade routine.
|
||||
*
|
||||
* In single site, the user would be redirected to wp-admin/upgrade.php.
|
||||
* In multisite, the DB upgrade routine is automatically fired, but only
|
||||
* when this filter returns true.
|
||||
*
|
||||
* If the network is 50 sites or less, it will run every time. Otherwise,
|
||||
* it will throttle itself to reduce load.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param bool $do_mu_upgrade Whether to perform the Multisite upgrade routine. Default true.
|
||||
*/
|
||||
/**
|
||||
* Filters whether to attempt to perform the multisite DB upgrade routine.
|
||||
*
|
||||
* In single site, the user would be redirected to wp-admin/upgrade.php.
|
||||
* In multisite, the DB upgrade routine is automatically fired, but only
|
||||
* when this filter returns true.
|
||||
*
|
||||
* If the network is 50 sites or less, it will run every time. Otherwise,
|
||||
* it will throttle itself to reduce load.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param bool $do_mu_upgrade Whether to perform the Multisite upgrade routine. Default true.
|
||||
*/
|
||||
} elseif ( apply_filters( 'do_mu_upgrade', true ) ) {
|
||||
$c = get_blog_count();
|
||||
|
||||
|
@ -68,24 +71,30 @@ if ( get_option('db_upgraded') ) {
|
|||
* If there are 50 or fewer sites, run every time. Otherwise, throttle to reduce load:
|
||||
* attempt to do no more than threshold value, with some +/- allowed.
|
||||
*/
|
||||
if ( $c <= 50 || ( $c > 50 && mt_rand( 0, (int)( $c / 50 ) ) == 1 ) ) {
|
||||
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);
|
||||
unset( $response );
|
||||
}
|
||||
unset($c);
|
||||
unset( $c );
|
||||
}
|
||||
}
|
||||
|
||||
require_once(ABSPATH . 'wp-admin/includes/admin.php');
|
||||
require_once( ABSPATH . 'wp-admin/includes/admin.php' );
|
||||
|
||||
auth_redirect();
|
||||
|
||||
// Schedule trash collection
|
||||
if ( ! wp_next_scheduled( 'wp_scheduled_delete' ) && ! wp_installing() )
|
||||
wp_schedule_event(time(), 'daily', 'wp_scheduled_delete');
|
||||
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() ) {
|
||||
|
@ -117,27 +126,30 @@ $page_hook = null;
|
|||
|
||||
$editing = false;
|
||||
|
||||
if ( isset($_GET['page']) ) {
|
||||
if ( isset( $_GET['page'] ) ) {
|
||||
$plugin_page = wp_unslash( $_GET['page'] );
|
||||
$plugin_page = plugin_basename($plugin_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 )
|
||||
require(ABSPATH . 'wp-admin/network/menu.php');
|
||||
elseif ( WP_USER_ADMIN )
|
||||
require(ABSPATH . 'wp-admin/user/menu.php');
|
||||
else
|
||||
require(ABSPATH . 'wp-admin/menu.php');
|
||||
if ( WP_NETWORK_ADMIN ) {
|
||||
require( ABSPATH . 'wp-admin/network/menu.php' );
|
||||
} elseif ( WP_USER_ADMIN ) {
|
||||
require( ABSPATH . 'wp-admin/user/menu.php' );
|
||||
} else {
|
||||
require( ABSPATH . 'wp-admin/menu.php' );
|
||||
}
|
||||
|
||||
if ( current_user_can( 'manage_options' ) ) {
|
||||
wp_raise_memory_limit( 'admin' );
|
||||
|
@ -155,26 +167,28 @@ if ( current_user_can( 'manage_options' ) ) {
|
|||
*/
|
||||
do_action( 'admin_init' );
|
||||
|
||||
if ( isset($plugin_page) ) {
|
||||
if ( !empty($typenow) )
|
||||
if ( isset( $plugin_page ) ) {
|
||||
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);
|
||||
}
|
||||
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') ) {
|
||||
if ( empty( $page_hook ) && 'edit.php' == $pagenow && '' != get_plugin_page_hook( $plugin_page, 'tools.php' ) ) {
|
||||
// There could be plugin specific params on the URL, so we need the whole query string
|
||||
if ( !empty($_SERVER[ 'QUERY_STRING' ]) )
|
||||
$query_string = $_SERVER[ 'QUERY_STRING' ];
|
||||
else
|
||||
if ( ! empty( $_SERVER['QUERY_STRING'] ) ) {
|
||||
$query_string = $_SERVER['QUERY_STRING'];
|
||||
} else {
|
||||
$query_string = 'page=' . $plugin_page;
|
||||
wp_redirect( admin_url('tools.php?' . $query_string) );
|
||||
}
|
||||
wp_redirect( admin_url( 'tools.php?' . $query_string ) );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
unset($the_parent);
|
||||
unset( $the_parent );
|
||||
}
|
||||
|
||||
$hook_suffix = '';
|
||||
|
@ -189,7 +203,7 @@ if ( isset( $page_hook ) ) {
|
|||
set_current_screen();
|
||||
|
||||
// Handle plugin admin pages.
|
||||
if ( isset($plugin_page) ) {
|
||||
if ( isset( $plugin_page ) ) {
|
||||
if ( $page_hook ) {
|
||||
/**
|
||||
* Fires before a particular screen is loaded.
|
||||
|
@ -212,8 +226,9 @@ if ( isset($plugin_page) ) {
|
|||
* @since 2.1.0
|
||||
*/
|
||||
do_action( "load-{$page_hook}" );
|
||||
if (! isset($_GET['noheader']))
|
||||
require_once(ABSPATH . 'wp-admin/admin-header.php');
|
||||
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") ) )
|
||||
wp_die(sprintf(__('Cannot load %s.'), htmlentities($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,16 +260,18 @@ if ( isset($plugin_page) ) {
|
|||
*/
|
||||
do_action( "load-{$plugin_page}" );
|
||||
|
||||
if ( !isset($_GET['noheader']))
|
||||
require_once(ABSPATH . 'wp-admin/admin-header.php');
|
||||
if ( ! isset( $_GET['noheader'] ) ) {
|
||||
require_once( ABSPATH . 'wp-admin/admin-header.php' );
|
||||
}
|
||||
|
||||
if ( file_exists(WPMU_PLUGIN_DIR . "/$plugin_page") )
|
||||
include(WPMU_PLUGIN_DIR . "/$plugin_page");
|
||||
else
|
||||
include(WP_PLUGIN_DIR . "/$plugin_page");
|
||||
if ( file_exists( WPMU_PLUGIN_DIR . "/$plugin_page" ) ) {
|
||||
include( WPMU_PLUGIN_DIR . "/$plugin_page" );
|
||||
} else {
|
||||
include( WP_PLUGIN_DIR . "/$plugin_page" );
|
||||
}
|
||||
}
|
||||
|
||||
include(ABSPATH . 'wp-admin/admin-footer.php');
|
||||
include( ABSPATH . 'wp-admin/admin-footer.php' );
|
||||
|
||||
exit();
|
||||
} elseif ( isset( $_GET['import'] ) ) {
|
||||
|
@ -264,12 +282,12 @@ if ( isset($plugin_page) ) {
|
|||
wp_die( __( 'Sorry, you are not allowed to import content.' ) );
|
||||
}
|
||||
|
||||
if ( validate_file($importer) ) {
|
||||
if ( validate_file( $importer ) ) {
|
||||
wp_redirect( admin_url( 'import.php?invalid=' . $importer ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! isset($wp_importers[$importer]) || ! is_callable($wp_importers[$importer][2]) ) {
|
||||
if ( ! isset( $wp_importers[ $importer ] ) || ! is_callable( $wp_importers[ $importer ][2] ) ) {
|
||||
wp_redirect( admin_url( 'import.php?invalid=' . $importer ) );
|
||||
exit;
|
||||
}
|
||||
|
@ -283,16 +301,17 @@ if ( isset($plugin_page) ) {
|
|||
*/
|
||||
do_action( "load-importer-{$importer}" );
|
||||
|
||||
$parent_file = 'tools.php';
|
||||
$parent_file = 'tools.php';
|
||||
$submenu_file = 'import.php';
|
||||
$title = __('Import');
|
||||
$title = __( 'Import' );
|
||||
|
||||
if (! isset($_GET['noheader']))
|
||||
require_once(ABSPATH . 'wp-admin/admin-header.php');
|
||||
if ( ! isset( $_GET['noheader'] ) ) {
|
||||
require_once( ABSPATH . 'wp-admin/admin-header.php' );
|
||||
}
|
||||
|
||||
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
|
||||
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
||||
|
||||
define('WP_IMPORTING', true);
|
||||
define( 'WP_IMPORTING', true );
|
||||
|
||||
/**
|
||||
* Whether to filter imported data through kses on import.
|
||||
|
@ -308,12 +327,12 @@ if ( isset($plugin_page) ) {
|
|||
kses_init_filters(); // Always filter imported data with kses on multisite.
|
||||
}
|
||||
|
||||
call_user_func($wp_importers[$importer][2]);
|
||||
call_user_func( $wp_importers[ $importer ][2] );
|
||||
|
||||
include(ABSPATH . 'wp-admin/admin-footer.php');
|
||||
include( ABSPATH . 'wp-admin/admin-footer.php' );
|
||||
|
||||
// Make sure rules are flushed
|
||||
flush_rewrite_rules(false);
|
||||
flush_rewrite_rules( false );
|
||||
|
||||
exit();
|
||||
} else {
|
||||
|
@ -336,16 +355,18 @@ 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' )
|
||||
}
|
||||
} elseif ( $pagenow == 'edit-tags.php' ) {
|
||||
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 ) {
|
||||
}
|
||||
} elseif ( 'term.php' === $pagenow ) {
|
||||
do_action( 'load-edit-tags.php' );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,51 +39,60 @@ 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'] ) {
|
||||
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 ) )
|
||||
case 3:
|
||||
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.
|
||||
$file = get_attached_file( $post->ID );
|
||||
$file = get_attached_file( $post->ID );
|
||||
$title = $post->post_title ? $post->post_title : wp_basename( $file );
|
||||
echo '<div class="filename new"><span class="title">' . esc_html( wp_html_excerpt( $title, 60, '…' ) ) . '</span></div>';
|
||||
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 ));
|
||||
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,
|
||||
)
|
||||
);
|
||||
break;
|
||||
default:
|
||||
add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2);
|
||||
echo get_media_item($id);
|
||||
add_filter( 'attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2 );
|
||||
echo get_media_item( $id );
|
||||
break;
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
check_admin_referer('media-form');
|
||||
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) ) {
|
||||
if ( is_wp_error( $id ) ) {
|
||||
echo '<div class="error-div error">
|
||||
<a class="dismiss" href="#" onclick="jQuery(this).parents(\'div.media-item\').slideUp(200, function(){jQuery(this).remove();});">' . __('Dismiss') . '</a>
|
||||
<strong>' . sprintf(__('“%s” has failed to upload.'), esc_html($_FILES['async-upload']['name']) ) . '</strong><br />' .
|
||||
esc_html($id->get_error_message()) . '</div>';
|
||||
<a class="dismiss" href="#" onclick="jQuery(this).parents(\'div.media-item\').slideUp(200, function(){jQuery(this).remove();});">' . __( 'Dismiss' ) . '</a>
|
||||
<strong>' . sprintf( __( '“%s” has failed to upload.' ), esc_html( $_FILES['async-upload']['name'] ) ) . '</strong><br />' .
|
||||
esc_html( $id->get_error_message() ) . '</div>';
|
||||
exit;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,136 +9,143 @@
|
|||
/** Load WordPress Bootstrap */
|
||||
require_once( dirname( __FILE__ ) . '/admin.php' );
|
||||
|
||||
$parent_file = 'edit-comments.php';
|
||||
$parent_file = 'edit-comments.php';
|
||||
$submenu_file = 'edit-comments.php';
|
||||
|
||||
/**
|
||||
* @global string $action
|
||||
*/
|
||||
global $action;
|
||||
wp_reset_vars( array('action') );
|
||||
wp_reset_vars( array( 'action' ) );
|
||||
|
||||
if ( isset( $_POST['deletecomment'] ) )
|
||||
if ( isset( $_POST['deletecomment'] ) ) {
|
||||
$action = 'deletecomment';
|
||||
|
||||
if ( 'cdc' == $action )
|
||||
$action = 'delete';
|
||||
elseif ( 'mac' == $action )
|
||||
$action = 'approve';
|
||||
|
||||
if ( isset( $_GET['dt'] ) ) {
|
||||
if ( 'spam' == $_GET['dt'] )
|
||||
$action = 'spam';
|
||||
elseif ( 'trash' == $_GET['dt'] )
|
||||
$action = 'trash';
|
||||
}
|
||||
|
||||
switch( $action ) {
|
||||
if ( 'cdc' == $action ) {
|
||||
$action = 'delete';
|
||||
} elseif ( 'mac' == $action ) {
|
||||
$action = 'approve';
|
||||
}
|
||||
|
||||
case 'editcomment' :
|
||||
$title = __('Edit Comment');
|
||||
|
||||
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>'
|
||||
) );
|
||||
|
||||
get_current_screen()->set_help_sidebar(
|
||||
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
|
||||
'<p>' . __( '<a href="https://codex.wordpress.org/Administration_Screens#Comments">Documentation on Comments</a>' ) . '</p>' .
|
||||
'<p>' . __( '<a href="https://wordpress.org/support/">Support Forums</a>' ) . '</p>'
|
||||
);
|
||||
|
||||
wp_enqueue_script('comment');
|
||||
require_once( ABSPATH . 'wp-admin/admin-header.php' );
|
||||
|
||||
$comment_id = absint( $_GET['c'] );
|
||||
|
||||
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 ) )
|
||||
comment_footer_die( __('Sorry, you are not allowed to edit this comment.') );
|
||||
|
||||
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 );
|
||||
|
||||
include( ABSPATH . 'wp-admin/edit-form-comment.php' );
|
||||
|
||||
break;
|
||||
|
||||
case 'delete' :
|
||||
case 'approve' :
|
||||
case 'trash' :
|
||||
case 'spam' :
|
||||
|
||||
$title = __('Moderate Comment');
|
||||
|
||||
$comment_id = absint( $_GET['c'] );
|
||||
|
||||
if ( ! $comment = get_comment( $comment_id ) ) {
|
||||
wp_redirect( admin_url('edit-comments.php?error=1') );
|
||||
die();
|
||||
if ( isset( $_GET['dt'] ) ) {
|
||||
if ( 'spam' == $_GET['dt'] ) {
|
||||
$action = 'spam';
|
||||
} elseif ( 'trash' == $_GET['dt'] ) {
|
||||
$action = 'trash';
|
||||
}
|
||||
}
|
||||
|
||||
if ( !current_user_can( 'edit_comment', $comment->comment_ID ) ) {
|
||||
wp_redirect( admin_url('edit-comments.php?error=2') );
|
||||
die();
|
||||
}
|
||||
switch ( $action ) {
|
||||
|
||||
// No need to re-approve/re-trash/re-spam a comment.
|
||||
if ( $action == str_replace( '1', 'approve', $comment->comment_approved ) ) {
|
||||
wp_redirect( admin_url( 'edit-comments.php?same=' . $comment_id ) );
|
||||
die();
|
||||
}
|
||||
case 'editcomment':
|
||||
$title = __( 'Edit Comment' );
|
||||
|
||||
require_once( ABSPATH . 'wp-admin/admin-header.php' );
|
||||
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>',
|
||||
)
|
||||
);
|
||||
|
||||
$formaction = $action . 'comment';
|
||||
$nonce_action = 'approve' == $action ? 'approve-comment_' : 'delete-comment_';
|
||||
$nonce_action .= $comment_id;
|
||||
get_current_screen()->set_help_sidebar(
|
||||
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
|
||||
'<p>' . __( '<a href="https://codex.wordpress.org/Administration_Screens#Comments">Documentation on Comments</a>' ) . '</p>' .
|
||||
'<p>' . __( '<a href="https://wordpress.org/support/">Support Forums</a>' ) . '</p>'
|
||||
);
|
||||
|
||||
?>
|
||||
<div class="wrap">
|
||||
wp_enqueue_script( 'comment' );
|
||||
require_once( ABSPATH . 'wp-admin/admin-header.php' );
|
||||
|
||||
<h1><?php echo esc_html( $title ); ?></h1>
|
||||
$comment_id = absint( $_GET['c'] );
|
||||
|
||||
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 ) ) {
|
||||
comment_footer_die( __( 'Sorry, you are not allowed to edit this comment.' ) );
|
||||
}
|
||||
|
||||
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 );
|
||||
|
||||
include( ABSPATH . 'wp-admin/edit-form-comment.php' );
|
||||
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
case 'approve':
|
||||
case 'trash':
|
||||
case 'spam':
|
||||
$title = __( 'Moderate Comment' );
|
||||
|
||||
$comment_id = absint( $_GET['c'] );
|
||||
|
||||
if ( ! $comment = get_comment( $comment_id ) ) {
|
||||
wp_redirect( admin_url( 'edit-comments.php?error=1' ) );
|
||||
die();
|
||||
}
|
||||
|
||||
if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) ) {
|
||||
wp_redirect( admin_url( 'edit-comments.php?error=2' ) );
|
||||
die();
|
||||
}
|
||||
|
||||
// No need to re-approve/re-trash/re-spam a comment.
|
||||
if ( $action == str_replace( '1', 'approve', $comment->comment_approved ) ) {
|
||||
wp_redirect( admin_url( 'edit-comments.php?same=' . $comment_id ) );
|
||||
die();
|
||||
}
|
||||
|
||||
require_once( ABSPATH . 'wp-admin/admin-header.php' );
|
||||
|
||||
$formaction = $action . 'comment';
|
||||
$nonce_action = 'approve' == $action ? 'approve-comment_' : 'delete-comment_';
|
||||
$nonce_action .= $comment_id;
|
||||
|
||||
?>
|
||||
<div class="wrap">
|
||||
|
||||
<h1><?php echo esc_html( $title ); ?></h1>
|
||||
|
||||
<?php
|
||||
switch ( $action ) {
|
||||
case 'spam' :
|
||||
$caution_msg = __('You are about to mark the following comment as spam:');
|
||||
case 'spam':
|
||||
$caution_msg = __( 'You are about to mark the following comment as spam:' );
|
||||
$button = _x( 'Mark as Spam', 'comment' );
|
||||
break;
|
||||
case 'trash' :
|
||||
$caution_msg = __('You are about to move the following comment to the Trash:');
|
||||
$button = __('Move to Trash');
|
||||
case 'trash':
|
||||
$caution_msg = __( 'You are about to move the following comment to the Trash:' );
|
||||
$button = __( 'Move to Trash' );
|
||||
break;
|
||||
case 'delete' :
|
||||
$caution_msg = __('You are about to delete the following comment:');
|
||||
$button = __('Permanently Delete Comment');
|
||||
case 'delete':
|
||||
$caution_msg = __( 'You are about to delete the following comment:' );
|
||||
$button = __( 'Permanently Delete Comment' );
|
||||
break;
|
||||
default :
|
||||
$caution_msg = __('You are about to approve the following comment:');
|
||||
$button = __('Approve Comment');
|
||||
default:
|
||||
$caution_msg = __( 'You are about to approve the following comment:' );
|
||||
$button = __( 'Approve Comment' );
|
||||
break;
|
||||
}
|
||||
|
||||
if ( $comment->comment_approved != '0' ) { // if not unapproved
|
||||
$message = '';
|
||||
switch ( $comment->comment_approved ) {
|
||||
case '1' :
|
||||
$message = __('This comment is currently approved.');
|
||||
case '1':
|
||||
$message = __( 'This comment is currently approved.' );
|
||||
break;
|
||||
case 'spam' :
|
||||
$message = __('This comment is currently marked as spam.');
|
||||
case 'spam':
|
||||
$message = __( 'This comment is currently marked as spam.' );
|
||||
break;
|
||||
case 'trash' :
|
||||
$message = __('This comment is currently in the Trash.');
|
||||
case 'trash':
|
||||
$message = __( 'This comment is currently in the Trash.' );
|
||||
break;
|
||||
}
|
||||
if ( $message ) {
|
||||
|
@ -150,18 +157,18 @@ if ( $comment->comment_approved != '0' ) { // if not unapproved
|
|||
|
||||
<table class="form-table comment-ays">
|
||||
<tr>
|
||||
<th scope="row"><?php _e('Author'); ?></th>
|
||||
<th scope="row"><?php _e( 'Author' ); ?></th>
|
||||
<td><?php comment_author( $comment ); ?></td>
|
||||
</tr>
|
||||
<?php if ( get_comment_author_email( $comment ) ) { ?>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('Email'); ?></th>
|
||||
<th scope="row"><?php _e( 'Email' ); ?></th>
|
||||
<td><?php comment_author_email( $comment ); ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<?php if ( get_comment_author_url( $comment ) ) { ?>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('URL'); ?></th>
|
||||
<th scope="row"><?php _e( 'URL' ); ?></th>
|
||||
<td><a href="<?php comment_author_url( $comment ); ?>"><?php comment_author_url( $comment ); ?></a></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
@ -170,163 +177,177 @@ if ( $comment->comment_approved != '0' ) { // if not unapproved
|
|||
<td>
|
||||
<?php
|
||||
$post_id = $comment->comment_post_ID;
|
||||
if ( current_user_can( 'edit_post', $post_id ) ) {
|
||||
$post_link = "<a href='" . esc_url( get_edit_post_link( $post_id ) ) . "'>";
|
||||
$post_link .= esc_html( get_the_title( $post_id ) ) . '</a>';
|
||||
} else {
|
||||
$post_link = esc_html( get_the_title( $post_id ) );
|
||||
}
|
||||
if ( current_user_can( 'edit_post', $post_id ) ) {
|
||||
$post_link = "<a href='" . esc_url( get_edit_post_link( $post_id ) ) . "'>";
|
||||
$post_link .= esc_html( get_the_title( $post_id ) ) . '</a>';
|
||||
} else {
|
||||
$post_link = esc_html( get_the_title( $post_id ) );
|
||||
}
|
||||
echo $post_link;
|
||||
|
||||
if ( $comment->comment_parent ) {
|
||||
$parent = get_comment( $comment->comment_parent );
|
||||
$parent_link = esc_url( get_comment_link( $parent ) );
|
||||
$name = get_comment_author( $parent );
|
||||
printf(
|
||||
/* translators: %s: comment link */
|
||||
' | ' . __( 'In reply to %s.' ),
|
||||
'<a href="' . $parent_link . '">' . $name . '</a>'
|
||||
);
|
||||
}
|
||||
if ( $comment->comment_parent ) {
|
||||
$parent = get_comment( $comment->comment_parent );
|
||||
$parent_link = esc_url( get_comment_link( $parent ) );
|
||||
$name = get_comment_author( $parent );
|
||||
printf(
|
||||
/* translators: %s: comment link */
|
||||
' | ' . __( 'In reply to %s.' ),
|
||||
'<a href="' . $parent_link . '">' . $name . '</a>'
|
||||
);
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php _e( 'Submitted on' ); ?></th>
|
||||
<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 )
|
||||
);
|
||||
if ( 'approved' === wp_get_comment_status( $comment ) && ! empty ( $comment->comment_post_ID ) ) {
|
||||
echo '<a href="' . esc_url( get_comment_link( $comment ) ) . '">' . $submitted . '</a>';
|
||||
} else {
|
||||
echo $submitted;
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php /* translators: field name in comment form */ _ex('Comment', 'noun'); ?></th>
|
||||
<td class="comment-content">
|
||||
if ( 'approved' === wp_get_comment_status( $comment ) && ! empty( $comment->comment_post_ID ) ) {
|
||||
echo '<a href="' . esc_url( get_comment_link( $comment ) ) . '">' . $submitted . '</a>';
|
||||
} else {
|
||||
echo $submitted;
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php /* translators: field name in comment form */ _ex( 'Comment', 'noun' ); ?></th>
|
||||
<td class="comment-content">
|
||||
<?php comment_text( $comment ); ?>
|
||||
<p class="edit-comment"><a href="<?php echo admin_url( "comment.php?action=editcomment&c={$comment->comment_ID}" ); ?>"><?php esc_html_e( 'Edit' ); ?></a></p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<form action="comment.php" method="get" class="comment-ays-submit">
|
||||
<form action="comment.php" method="get" class="comment-ays-submit">
|
||||
|
||||
<p>
|
||||
<p>
|
||||
<?php submit_button( $button, 'primary', 'submit', false ); ?>
|
||||
<a href="<?php echo admin_url('edit-comments.php'); ?>" class="button-cancel"><?php esc_html_e( 'Cancel' ); ?></a>
|
||||
</p>
|
||||
<a href="<?php echo admin_url( 'edit-comments.php' ); ?>" class="button-cancel"><?php esc_html_e( 'Cancel' ); ?></a>
|
||||
</p>
|
||||
|
||||
<?php wp_nonce_field( $nonce_action ); ?>
|
||||
<input type="hidden" name="action" value="<?php echo esc_attr($formaction); ?>" />
|
||||
<input type="hidden" name="c" value="<?php echo esc_attr($comment->comment_ID); ?>" />
|
||||
<input type="hidden" name="noredir" value="1" />
|
||||
</form>
|
||||
<?php wp_nonce_field( $nonce_action ); ?>
|
||||
<input type="hidden" name="action" value="<?php echo esc_attr( $formaction ); ?>" />
|
||||
<input type="hidden" name="c" value="<?php echo esc_attr( $comment->comment_ID ); ?>" />
|
||||
<input type="hidden" name="noredir" value="1" />
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<?php
|
||||
break;
|
||||
</div>
|
||||
<?php
|
||||
break;
|
||||
|
||||
case 'deletecomment' :
|
||||
case 'trashcomment' :
|
||||
case 'untrashcomment' :
|
||||
case 'spamcomment' :
|
||||
case 'unspamcomment' :
|
||||
case 'approvecomment' :
|
||||
case 'unapprovecomment' :
|
||||
$comment_id = absint( $_REQUEST['c'] );
|
||||
case 'deletecomment':
|
||||
case 'trashcomment':
|
||||
case 'untrashcomment':
|
||||
case 'spamcomment':
|
||||
case 'unspamcomment':
|
||||
case 'approvecomment':
|
||||
case 'unapprovecomment':
|
||||
$comment_id = absint( $_REQUEST['c'] );
|
||||
|
||||
if ( in_array( $action, array( 'approvecomment', 'unapprovecomment' ) ) )
|
||||
check_admin_referer( 'approve-comment_' . $comment_id );
|
||||
else
|
||||
check_admin_referer( 'delete-comment_' . $comment_id );
|
||||
if ( in_array( $action, array( 'approvecomment', 'unapprovecomment' ) ) ) {
|
||||
check_admin_referer( 'approve-comment_' . $comment_id );
|
||||
} else {
|
||||
check_admin_referer( 'delete-comment_' . $comment_id );
|
||||
}
|
||||
|
||||
$noredir = isset($_REQUEST['noredir']);
|
||||
$noredir = isset( $_REQUEST['noredir'] );
|
||||
|
||||
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 ) )
|
||||
comment_footer_die( __('Sorry, you are not allowed to edit comments on this post.') );
|
||||
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 ) ) {
|
||||
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') )
|
||||
$redir = wp_get_referer();
|
||||
elseif ( '' != wp_get_original_referer() && ! $noredir )
|
||||
$redir = wp_get_original_referer();
|
||||
elseif ( in_array( $action, array( 'approvecomment', 'unapprovecomment' ) ) )
|
||||
$redir = admin_url('edit-comments.php?p=' . absint( $comment->comment_post_ID ) );
|
||||
else
|
||||
$redir = admin_url('edit-comments.php');
|
||||
if ( '' != wp_get_referer() && ! $noredir && false === strpos( wp_get_referer(), 'comment.php' ) ) {
|
||||
$redir = wp_get_referer();
|
||||
} elseif ( '' != wp_get_original_referer() && ! $noredir ) {
|
||||
$redir = wp_get_original_referer();
|
||||
} elseif ( in_array( $action, array( 'approvecomment', 'unapprovecomment' ) ) ) {
|
||||
$redir = admin_url( 'edit-comments.php?p=' . absint( $comment->comment_post_ID ) );
|
||||
} else {
|
||||
$redir = admin_url( 'edit-comments.php' );
|
||||
}
|
||||
|
||||
$redir = remove_query_arg( array('spammed', 'unspammed', 'trashed', 'untrashed', 'deleted', 'ids', 'approved', 'unapproved'), $redir );
|
||||
$redir = remove_query_arg( array( 'spammed', 'unspammed', 'trashed', 'untrashed', 'deleted', 'ids', 'approved', 'unapproved' ), $redir );
|
||||
|
||||
switch ( $action ) {
|
||||
case 'deletecomment' :
|
||||
wp_delete_comment( $comment );
|
||||
$redir = add_query_arg( array('deleted' => '1'), $redir );
|
||||
break;
|
||||
case 'trashcomment' :
|
||||
wp_trash_comment( $comment );
|
||||
$redir = add_query_arg( array('trashed' => '1', 'ids' => $comment_id), $redir );
|
||||
break;
|
||||
case 'untrashcomment' :
|
||||
wp_untrash_comment( $comment );
|
||||
$redir = add_query_arg( array('untrashed' => '1'), $redir );
|
||||
break;
|
||||
case 'spamcomment' :
|
||||
wp_spam_comment( $comment );
|
||||
$redir = add_query_arg( array('spammed' => '1', 'ids' => $comment_id), $redir );
|
||||
break;
|
||||
case 'unspamcomment' :
|
||||
wp_unspam_comment( $comment );
|
||||
$redir = add_query_arg( array('unspammed' => '1'), $redir );
|
||||
break;
|
||||
case 'approvecomment' :
|
||||
wp_set_comment_status( $comment, 'approve' );
|
||||
$redir = add_query_arg( array( 'approved' => 1 ), $redir );
|
||||
break;
|
||||
case 'unapprovecomment' :
|
||||
wp_set_comment_status( $comment, 'hold' );
|
||||
$redir = add_query_arg( array( 'unapproved' => 1 ), $redir );
|
||||
break;
|
||||
}
|
||||
switch ( $action ) {
|
||||
case 'deletecomment':
|
||||
wp_delete_comment( $comment );
|
||||
$redir = add_query_arg( array( 'deleted' => '1' ), $redir );
|
||||
break;
|
||||
case 'trashcomment':
|
||||
wp_trash_comment( $comment );
|
||||
$redir = add_query_arg(
|
||||
array(
|
||||
'trashed' => '1',
|
||||
'ids' => $comment_id,
|
||||
), $redir
|
||||
);
|
||||
break;
|
||||
case 'untrashcomment':
|
||||
wp_untrash_comment( $comment );
|
||||
$redir = add_query_arg( array( 'untrashed' => '1' ), $redir );
|
||||
break;
|
||||
case 'spamcomment':
|
||||
wp_spam_comment( $comment );
|
||||
$redir = add_query_arg(
|
||||
array(
|
||||
'spammed' => '1',
|
||||
'ids' => $comment_id,
|
||||
), $redir
|
||||
);
|
||||
break;
|
||||
case 'unspamcomment':
|
||||
wp_unspam_comment( $comment );
|
||||
$redir = add_query_arg( array( 'unspammed' => '1' ), $redir );
|
||||
break;
|
||||
case 'approvecomment':
|
||||
wp_set_comment_status( $comment, 'approve' );
|
||||
$redir = add_query_arg( array( 'approved' => 1 ), $redir );
|
||||
break;
|
||||
case 'unapprovecomment':
|
||||
wp_set_comment_status( $comment, 'hold' );
|
||||
$redir = add_query_arg( array( 'unapproved' => 1 ), $redir );
|
||||
break;
|
||||
}
|
||||
|
||||
wp_redirect( $redir );
|
||||
die;
|
||||
wp_redirect( $redir );
|
||||
die;
|
||||
|
||||
case 'editedcomment' :
|
||||
case 'editedcomment':
|
||||
$comment_id = absint( $_POST['comment_ID'] );
|
||||
$comment_post_id = absint( $_POST['comment_post_ID'] );
|
||||
|
||||
$comment_id = absint( $_POST['comment_ID'] );
|
||||
$comment_post_id = absint( $_POST['comment_post_ID'] );
|
||||
check_admin_referer( 'update-comment_' . $comment_id );
|
||||
|
||||
check_admin_referer( 'update-comment_' . $comment_id );
|
||||
edit_comment();
|
||||
|
||||
edit_comment();
|
||||
$location = ( empty( $_POST['referredby'] ) ? "edit-comments.php?p=$comment_post_id" : $_POST['referredby'] ) . '#comment-' . $comment_id;
|
||||
|
||||
$location = ( empty( $_POST['referredby'] ) ? "edit-comments.php?p=$comment_post_id" : $_POST['referredby'] ) . '#comment-' . $comment_id;
|
||||
/**
|
||||
* Filters the URI the user is redirected to after editing a comment in the admin.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*
|
||||
* @param string $location The URI the user will be redirected to.
|
||||
* @param int $comment_id The ID of the comment being edited.
|
||||
*/
|
||||
$location = apply_filters( 'comment_edit_redirect', $location, $comment_id );
|
||||
wp_redirect( $location );
|
||||
|
||||
/**
|
||||
* Filters the URI the user is redirected to after editing a comment in the admin.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*
|
||||
* @param string $location The URI the user will be redirected to.
|
||||
* @param int $comment_id The ID of the comment being edited.
|
||||
*/
|
||||
$location = apply_filters( 'comment_edit_redirect', $location, $comment_id );
|
||||
wp_redirect( $location );
|
||||
exit();
|
||||
|
||||
exit();
|
||||
|
||||
default:
|
||||
wp_die( __('Unknown action.') );
|
||||
default:
|
||||
wp_die( __( 'Unknown action.' ) );
|
||||
|
||||
} // end switch
|
||||
|
||||
|
|
|
@ -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,15 +67,16 @@ 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' :
|
||||
case 'list':
|
||||
array_walk( $group_data['data'], '_wp_credits_add_profile_link', $credits['data']['profiles'] );
|
||||
echo '<p class="wp-credits-list">' . wp_sprintf( '%l.', $group_data['data'] ) . "</p>\n\n";
|
||||
break;
|
||||
case 'libraries' :
|
||||
case 'libraries':
|
||||
array_walk( $group_data['data'], '_wp_credits_build_object_link' );
|
||||
echo '<p class="wp-credits-list">' . wp_sprintf( '%l.', $group_data['data'] ) . "</p>\n\n";
|
||||
break;
|
||||
|
@ -85,28 +87,32 @@ foreach ( $credits['groups'] as $group_slug => $group_data ) {
|
|||
foreach ( $group_data['data'] as $person_data ) {
|
||||
echo '<li class="wp-person" id="wp-person-' . esc_attr( $person_data[2] ) . '">' . "\n\t";
|
||||
echo '<a href="' . esc_url( sprintf( $credits['data']['profiles'], $person_data[2] ) ) . '" class="web">';
|
||||
$size = 'compact' == $group_data['type'] ? 30 : 60;
|
||||
$data = get_avatar_data( $person_data[1] . '@md5.gravatar.com', array( 'size' => $size ) );
|
||||
$size *= 2;
|
||||
$size = 'compact' == $group_data['type'] ? 30 : 60;
|
||||
$data = get_avatar_data( $person_data[1] . '@md5.gravatar.com', array( 'size' => $size ) );
|
||||
$size *= 2;
|
||||
$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";
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<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>
|
||||
|
|
|
@ -44,8 +44,8 @@ class Custom_Background {
|
|||
* @param callable $admin_header_callback
|
||||
* @param callable $admin_image_div_callback Optional custom image div output callback.
|
||||
*/
|
||||
public function __construct($admin_header_callback = '', $admin_image_div_callback = '') {
|
||||
$this->admin_header_callback = $admin_header_callback;
|
||||
public function __construct( $admin_header_callback = '', $admin_image_div_callback = '' ) {
|
||||
$this->admin_header_callback = $admin_header_callback;
|
||||
$this->admin_image_div_callback = $admin_image_div_callback;
|
||||
|
||||
add_action( 'admin_menu', array( $this, 'init' ) );
|
||||
|
@ -82,15 +82,17 @@ class Custom_Background {
|
|||
* @since 3.0.0
|
||||
*/
|
||||
public function admin_load() {
|
||||
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’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 “Choose Image” 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. “#ff0000” for red, or by choosing a color using the color picker.' ) . '</p>' .
|
||||
'<p>' . __( 'Don’t forget to click on the Save Changes button when you are finished.' ) . '</p>'
|
||||
) );
|
||||
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’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 “Choose Image” 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. “#ff0000” for red, or by choosing a color using the color picker.' ) . '</p>' .
|
||||
'<p>' . __( 'Don’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>' .
|
||||
|
@ -99,8 +101,8 @@ class Custom_Background {
|
|||
);
|
||||
|
||||
wp_enqueue_media();
|
||||
wp_enqueue_script('custom-background');
|
||||
wp_enqueue_style('wp-color-picker');
|
||||
wp_enqueue_script( 'custom-background' );
|
||||
wp_enqueue_style( 'wp-color-picker' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -109,22 +111,23 @@ 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');
|
||||
remove_theme_mod('background_image');
|
||||
remove_theme_mod('background_image_thumb');
|
||||
if ( isset( $_POST['reset-background'] ) ) {
|
||||
check_admin_referer( 'custom-background-reset', '_wpnonce-custom-background-reset' );
|
||||
remove_theme_mod( 'background_image' );
|
||||
remove_theme_mod( 'background_image_thumb' );
|
||||
$this->updated = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if ( isset($_POST['remove-background']) ) {
|
||||
if ( isset( $_POST['remove-background'] ) ) {
|
||||
// @TODO: Uploaded files are not removed here.
|
||||
check_admin_referer('custom-background-remove', '_wpnonce-custom-background-remove');
|
||||
set_theme_mod('background_image', '');
|
||||
set_theme_mod('background_image_thumb', '');
|
||||
check_admin_referer( 'custom-background-remove', '_wpnonce-custom-background-remove' );
|
||||
set_theme_mod( 'background_image', '' );
|
||||
set_theme_mod( 'background_image_thumb', '' );
|
||||
$this->updated = true;
|
||||
wp_safe_redirect( $_POST['_wp_http_referer'] );
|
||||
return;
|
||||
|
@ -199,13 +202,14 @@ class Custom_Background {
|
|||
set_theme_mod( 'background_attachment', $attachment );
|
||||
}
|
||||
|
||||
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 )
|
||||
set_theme_mod('background_color', $color);
|
||||
else
|
||||
set_theme_mod('background_color', '');
|
||||
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 ) {
|
||||
set_theme_mod( 'background_color', $color );
|
||||
} else {
|
||||
set_theme_mod( 'background_color', '' );
|
||||
}
|
||||
}
|
||||
|
||||
$this->updated = true;
|
||||
|
@ -252,17 +256,18 @@ 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 ) {
|
||||
$background_image_thumb = esc_url( set_url_scheme( get_theme_mod( 'background_image_thumb', str_replace( '%', '%%', $background_image_thumb ) ) ) );
|
||||
$background_position_x = get_theme_mod( 'background_position_x', get_theme_support( 'custom-background', 'default-position-x' ) );
|
||||
$background_position_y = get_theme_mod( 'background_position_y', get_theme_support( 'custom-background', 'default-position-y' ) );
|
||||
$background_size = get_theme_mod( 'background_size', get_theme_support( 'custom-background', 'default-size' ) );
|
||||
$background_repeat = get_theme_mod( 'background_repeat', get_theme_support( 'custom-background', 'default-repeat' ) );
|
||||
$background_attachment = get_theme_mod( 'background_attachment', get_theme_support( 'custom-background', 'default-attachment' ) );
|
||||
$background_position_x = get_theme_mod( 'background_position_x', get_theme_support( 'custom-background', 'default-position-x' ) );
|
||||
$background_position_y = get_theme_mod( 'background_position_y', get_theme_support( 'custom-background', 'default-position-y' ) );
|
||||
$background_size = get_theme_mod( 'background_size', get_theme_support( 'custom-background', 'default-size' ) );
|
||||
$background_repeat = get_theme_mod( 'background_repeat', get_theme_support( 'custom-background', 'default-repeat' ) );
|
||||
$background_attachment = get_theme_mod( 'background_attachment', get_theme_support( 'custom-background', 'default-attachment' ) );
|
||||
|
||||
// Background-image URL must be single quote, see below.
|
||||
$background_styles .= " background-image: url('$background_image_thumb');"
|
||||
|
@ -284,12 +289,12 @@ class Custom_Background {
|
|||
|
||||
<?php if ( get_background_image() ) : ?>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('Remove Image'); ?></th>
|
||||
<th scope="row"><?php _e( 'Remove Image' ); ?></th>
|
||||
<td>
|
||||
<form method="post">
|
||||
<?php wp_nonce_field('custom-background-remove', '_wpnonce-custom-background-remove'); ?>
|
||||
<?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>
|
||||
|
@ -298,20 +303,20 @@ class Custom_Background {
|
|||
<?php $default_image = get_theme_support( 'custom-background', 'default-image' ); ?>
|
||||
<?php if ( $default_image && get_background_image() != $default_image ) : ?>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('Restore Original Image'); ?></th>
|
||||
<th scope="row"><?php _e( 'Restore Original Image' ); ?></th>
|
||||
<td>
|
||||
<form method="post">
|
||||
<?php wp_nonce_field('custom-background-reset', '_wpnonce-custom-background-reset'); ?>
|
||||
<?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>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( current_user_can( 'upload_files' ) ): ?>
|
||||
<?php if ( current_user_can( 'upload_files' ) ) : ?>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('Select Image'); ?></th>
|
||||
<th scope="row"><?php _e( 'Select Image' ); ?></th>
|
||||
<td><form enctype="multipart/form-data" id="upload-form" class="wp-upload-form" method="post">
|
||||
<p>
|
||||
<label for="upload"><?php _e( 'Choose an image from your computer:' ); ?></label><br />
|
||||
|
@ -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,16 +448,17 @@ $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>
|
||||
</table>
|
||||
|
||||
<?php wp_nonce_field('custom-background'); ?>
|
||||
<?php wp_nonce_field( 'custom-background' ); ?>
|
||||
<?php submit_button( null, 'primary', 'save-background-options' ); ?>
|
||||
</form>
|
||||
|
||||
|
@ -439,47 +472,50 @@ 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);
|
||||
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'] ) )
|
||||
$wp_filetype = wp_check_filetype_and_ext( $uploaded_file['tmp_name'], $uploaded_file['name'] );
|
||||
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);
|
||||
$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'];
|
||||
$file = $file['file'];
|
||||
$filename = basename($file);
|
||||
$url = $file['url'];
|
||||
$type = $file['type'];
|
||||
$file = $file['file'];
|
||||
$filename = basename( $file );
|
||||
|
||||
// Construct the object array
|
||||
$object = array(
|
||||
'post_title' => $filename,
|
||||
'post_content' => $url,
|
||||
'post_title' => $filename,
|
||||
'post_content' => $url,
|
||||
'post_mime_type' => $type,
|
||||
'guid' => $url,
|
||||
'context' => 'custom-background'
|
||||
'guid' => $url,
|
||||
'context' => 'custom-background',
|
||||
);
|
||||
|
||||
// Save the data
|
||||
$id = wp_insert_attachment($object, $file);
|
||||
$id = wp_insert_attachment( $object, $file );
|
||||
|
||||
// Add the meta-data
|
||||
wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) );
|
||||
update_post_meta( $id, '_wp_attachment_is_custom_background', get_option('stylesheet' ) );
|
||||
update_post_meta( $id, '_wp_attachment_is_custom_background', get_option( 'stylesheet' ) );
|
||||
|
||||
set_theme_mod('background_image', esc_url_raw($url));
|
||||
set_theme_mod( 'background_image', esc_url_raw( $url ) );
|
||||
|
||||
$thumbnail = wp_get_attachment_image_src( $id, 'thumbnail' );
|
||||
set_theme_mod('background_image_thumb', esc_url_raw( $thumbnail[0] ) );
|
||||
set_theme_mod( 'background_image_thumb', esc_url_raw( $thumbnail[0] ) );
|
||||
|
||||
/** This action is documented in wp-admin/custom-header.php */
|
||||
do_action( 'wp_create_file_in_uploads', $file, $id ); // For replication
|
||||
|
@ -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,21 +570,32 @@ 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;
|
||||
$attachment_id = absint($_POST['attachment_id']);
|
||||
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')) ));
|
||||
$size = 'thumbnail';
|
||||
if ( in_array( $_POST['size'], $sizes ) )
|
||||
$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 ) ) {
|
||||
$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 );
|
||||
update_post_meta( $attachment_id, '_wp_attachment_is_custom_background', get_option( 'stylesheet' ) );
|
||||
$url = wp_get_attachment_image_src( $attachment_id, $size );
|
||||
$thumbnail = wp_get_attachment_image_src( $attachment_id, 'thumbnail' );
|
||||
set_theme_mod( 'background_image', esc_url_raw( $url[0] ) );
|
||||
set_theme_mod( 'background_image_thumb', esc_url_raw( $thumbnail[0] ) );
|
||||
|
|
|
@ -52,16 +52,16 @@ class Custom_Image_Header {
|
|||
* @param callable $admin_header_callback
|
||||
* @param callable $admin_image_div_callback Optional custom image div output callback.
|
||||
*/
|
||||
public function __construct($admin_header_callback, $admin_image_div_callback = '') {
|
||||
$this->admin_header_callback = $admin_header_callback;
|
||||
public function __construct( $admin_header_callback, $admin_image_div_callback = '' ) {
|
||||
$this->admin_header_callback = $admin_header_callback;
|
||||
$this->admin_image_div_callback = $admin_image_div_callback;
|
||||
|
||||
add_action( 'admin_menu', array( $this, 'init' ) );
|
||||
|
||||
add_action( 'customize_save_after', array( $this, 'customize_set_last_used' ) );
|
||||
add_action( 'wp_ajax_custom-header-crop', array( $this, 'ajax_header_crop' ) );
|
||||
add_action( 'wp_ajax_custom-header-add', array( $this, 'ajax_header_add' ) );
|
||||
add_action( 'wp_ajax_custom-header-remove', array( $this, 'ajax_header_remove' ) );
|
||||
add_action( 'customize_save_after', array( $this, 'customize_set_last_used' ) );
|
||||
add_action( 'wp_ajax_custom-header-crop', array( $this, 'ajax_header_crop' ) );
|
||||
add_action( 'wp_ajax_custom-header-add', array( $this, 'ajax_header_add' ) );
|
||||
add_action( 'wp_ajax_custom-header-remove', array( $this, 'ajax_header_remove' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -91,32 +91,38 @@ class Custom_Image_Header {
|
|||
* @since 3.0.0
|
||||
*/
|
||||
public function help() {
|
||||
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’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(
|
||||
'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’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(
|
||||
'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 “Choose Image” button.' ) . '</p>' .
|
||||
'<p>' . __( 'Some themes come with additional header images bundled. If you see multiple images displayed, select the one you’d like and click the “Save Changes” 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 “Random” radio button next to the Uploaded Images or Default Images section to enable this feature.') . '</p>' .
|
||||
'<p>' . __( 'If you don’t want a header image to be displayed on your site at all, click the “Remove Header Image” 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 “Save Changes”.') . '</p>'
|
||||
) );
|
||||
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 “Choose Image” button.' ) . '</p>' .
|
||||
'<p>' . __( 'Some themes come with additional header images bundled. If you see multiple images displayed, select the one you’d like and click the “Save Changes” 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 “Random” radio button next to the Uploaded Images or Default Images section to enable this feature.' ) . '</p>' .
|
||||
'<p>' . __( 'If you don’t want a header image to be displayed on your site at all, click the “Remove Header Image” 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 “Save Changes”.' ) . '</p>',
|
||||
)
|
||||
);
|
||||
|
||||
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. “#ff0000” for red, or by choosing a color using the color picker.' ) . '</p>' .
|
||||
'<p>' . __( 'Don’t forget to click “Save Changes” when you’re done!') . '</p>'
|
||||
) );
|
||||
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. “#ff0000” for red, or by choosing a color using the color picker.' ) . '</p>' .
|
||||
'<p>' . __( 'Don’t forget to click “Save Changes” when you’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,10 +165,11 @@ 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');
|
||||
wp_enqueue_script( 'imgareaselect' );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -172,10 +181,11 @@ 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 )
|
||||
wp_enqueue_style('imgareaselect');
|
||||
} elseif ( 2 == $step ) {
|
||||
wp_enqueue_style( 'imgareaselect' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
|
||||
|
@ -210,11 +222,12 @@ class Custom_Image_Header {
|
|||
} elseif ( isset( $_POST['text-color'] ) ) {
|
||||
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 )
|
||||
set_theme_mod('header_textcolor', $color);
|
||||
elseif ( ! $color )
|
||||
$color = preg_replace( '/[^0-9a-fA-F]/', '', $_POST['text-color'] );
|
||||
if ( strlen( $color ) == 6 || strlen( $color ) == 3 ) {
|
||||
set_theme_mod( 'header_textcolor', $color );
|
||||
} elseif ( ! $color ) {
|
||||
set_theme_mod( 'header_textcolor', 'blank' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $_POST['default-header'] ) ) {
|
||||
|
@ -234,19 +247,20 @@ 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;
|
||||
}
|
||||
|
||||
$this->default_headers = $_wp_default_headers;
|
||||
$template_directory_uri = get_template_directory_uri();
|
||||
$this->default_headers = $_wp_default_headers;
|
||||
$template_directory_uri = get_template_directory_uri();
|
||||
$stylesheet_directory_uri = get_stylesheet_directory_uri();
|
||||
foreach ( array_keys($this->default_headers) as $header ) {
|
||||
$this->default_headers[$header]['url'] = sprintf( $this->default_headers[$header]['url'], $template_directory_uri, $stylesheet_directory_uri );
|
||||
$this->default_headers[$header]['thumbnail_url'] = sprintf( $this->default_headers[$header]['thumbnail_url'], $template_directory_uri, $stylesheet_directory_uri );
|
||||
foreach ( array_keys( $this->default_headers ) as $header ) {
|
||||
$this->default_headers[ $header ]['url'] = sprintf( $this->default_headers[ $header ]['url'], $template_directory_uri, $stylesheet_directory_uri );
|
||||
$this->default_headers[ $header ]['thumbnail_url'] = sprintf( $this->default_headers[ $header ]['thumbnail_url'], $template_directory_uri, $stylesheet_directory_uri );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -266,7 +280,7 @@ class Custom_Image_Header {
|
|||
$headers = $this->default_headers;
|
||||
} else {
|
||||
$headers = get_uploaded_header_images();
|
||||
$type = 'uploaded';
|
||||
$type = 'uploaded';
|
||||
}
|
||||
|
||||
if ( 1 < count( $headers ) ) {
|
||||
|
@ -280,14 +294,15 @@ class Custom_Image_Header {
|
|||
echo '<div class="available-headers">';
|
||||
foreach ( $headers as $header_key => $header ) {
|
||||
$header_thumbnail = $header['thumbnail_url'];
|
||||
$header_url = $header['url'];
|
||||
$header_alt_text = empty( $header['alt_text'] ) ? '' : $header['alt_text'];
|
||||
$header_url = $header['url'];
|
||||
$header_alt_text = empty( $header['alt_text'] ) ? '' : $header['alt_text'];
|
||||
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 '<img src="' . set_url_scheme( $header_thumbnail ) . '" alt="' . esc_attr( $header_alt_text ) . '"' . $width . ' /></label>';
|
||||
echo '</div>';
|
||||
}
|
||||
echo '<div class="clear"></div></div>';
|
||||
|
@ -300,10 +315,11 @@ 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();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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);
|
||||
|
@ -484,27 +502,30 @@ class Custom_Image_Header {
|
|||
call_user_func( $this->admin_image_div_callback );
|
||||
} else {
|
||||
$custom_header = get_custom_header();
|
||||
$header_image = get_header_image();
|
||||
$header_image = get_header_image();
|
||||
|
||||
if ( $header_image ) {
|
||||
$header_image_style = 'background-image:url(' . esc_url( $header_image ) . ');';
|
||||
} else {
|
||||
} else {
|
||||
$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>
|
||||
<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>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
@ -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 × %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.' ) . ' ',
|
||||
|
@ -542,9 +564,10 @@ class Custom_Image_Header {
|
|||
get_theme_support( 'custom-header', 'height' )
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
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.' ) . ' ',
|
||||
|
@ -564,9 +588,11 @@ class Custom_Image_Header {
|
|||
get_theme_support( 'custom-header', 'height' )
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
?></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(
|
||||
'page' => 'custom-header',
|
||||
'step' => 2,
|
||||
'_wpnonce-custom-header-upload' => wp_create_nonce('custom-header-upload'),
|
||||
), admin_url('themes.php') ) );
|
||||
$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' )
|
||||
)
|
||||
);
|
||||
?>
|
||||
<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‘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( 'If you don‘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>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
$this->show_header_selector( 'default' );
|
||||
$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.
|
||||
|
@ -716,7 +755,7 @@ wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?>
|
|||
* @since 2.1.0
|
||||
*/
|
||||
public function step_2() {
|
||||
check_admin_referer('custom-header-upload', '_wpnonce-custom-header-upload');
|
||||
check_admin_referer( 'custom-header-upload', '_wpnonce-custom-header-upload' );
|
||||
if ( ! current_theme_supports( 'custom-header', 'uploads' ) ) {
|
||||
wp_die(
|
||||
'<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' .
|
||||
|
@ -727,41 +766,43 @@ wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?>
|
|||
|
||||
if ( empty( $_POST ) && isset( $_GET['file'] ) ) {
|
||||
$attachment_id = absint( $_GET['file'] );
|
||||
$file = get_attached_file( $attachment_id, true );
|
||||
$url = wp_get_attachment_image_src( $attachment_id, 'full' );
|
||||
$url = $url[0];
|
||||
$file = get_attached_file( $attachment_id, true );
|
||||
$url = wp_get_attachment_image_src( $attachment_id, 'full' );
|
||||
$url = $url[0];
|
||||
} elseif ( isset( $_POST ) ) {
|
||||
$data = $this->step_2_manage_upload();
|
||||
$data = $this->step_2_manage_upload();
|
||||
$attachment_id = $data['attachment_id'];
|
||||
$file = $data['file'];
|
||||
$url = $data['url'];
|
||||
$file = $data['file'];
|
||||
$url = $data['url'];
|
||||
}
|
||||
|
||||
if ( file_exists( $file ) ) {
|
||||
list( $width, $height, $type, $attr ) = getimagesize( $file );
|
||||
} else {
|
||||
$data = wp_get_attachment_metadata( $attachment_id );
|
||||
$height = isset( $data[ 'height' ] ) ? $data[ 'height' ] : 0;
|
||||
$width = isset( $data[ 'width' ] ) ? $data[ 'width' ] : 0;
|
||||
$data = wp_get_attachment_metadata( $attachment_id );
|
||||
$height = isset( $data['height'] ) ? $data['height'] : 0;
|
||||
$width = isset( $data['width'] ) ? $data['width'] : 0;
|
||||
unset( $data );
|
||||
}
|
||||
|
||||
$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' ) );
|
||||
|
||||
|
@ -778,15 +819,16 @@ wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?>
|
|||
return $this->finished();
|
||||
} 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 ) )
|
||||
$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 ) ) {
|
||||
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
|
||||
|
||||
$url = str_replace(basename($url), basename($image), $url);
|
||||
$width = $width / $oitar;
|
||||
$url = str_replace( basename( $url ), basename( $image ), $url );
|
||||
$width = $width / $oitar;
|
||||
$height = $height / $oitar;
|
||||
} else {
|
||||
$oitar = 1;
|
||||
|
@ -796,9 +838,9 @@ wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?>
|
|||
<div class="wrap">
|
||||
<h1><?php _e( 'Crop Header Image' ); ?></h1>
|
||||
|
||||
<form method="post" action="<?php echo esc_url(add_query_arg('step', 3)); ?>">
|
||||
<p class="hide-if-no-js"><?php _e('Choose the part of the image you want to use as your header.'); ?></p>
|
||||
<p class="hide-if-js"><strong><?php _e( 'You need JavaScript to choose a part of the image.'); ?></strong></p>
|
||||
<form method="post" action="<?php echo esc_url( add_query_arg( 'step', 3 ) ); ?>">
|
||||
<p class="hide-if-no-js"><?php _e( 'Choose the part of the image you want to use as your header.' ); ?></p>
|
||||
<p class="hide-if-js"><strong><?php _e( 'You need JavaScript to choose a part of the image.' ); ?></strong></p>
|
||||
|
||||
<div id="crop_image" style="position: relative">
|
||||
<img src="<?php echo esc_url( $url ); ?>" id="upload" width="<?php echo $width; ?>" height="<?php echo $height; ?>" alt="" />
|
||||
|
@ -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>
|
||||
|
@ -834,22 +877,24 @@ wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?>
|
|||
* @since 3.4.0
|
||||
*/
|
||||
public function step_2_manage_upload() {
|
||||
$overrides = array('test_form' => false);
|
||||
$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'] ) )
|
||||
$wp_filetype = wp_check_filetype_and_ext( $uploaded_file['tmp_name'], $uploaded_file['name'] );
|
||||
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);
|
||||
$file = wp_handle_upload( $uploaded_file, $overrides );
|
||||
|
||||
if ( isset($file['error']) )
|
||||
wp_die( $file['error'], __( 'Image Upload Error' ) );
|
||||
if ( isset( $file['error'] ) ) {
|
||||
wp_die( $file['error'], __( 'Image Upload Error' ) );
|
||||
}
|
||||
|
||||
$url = $file['url'];
|
||||
$type = $file['type'];
|
||||
$file = $file['file'];
|
||||
$filename = basename($file);
|
||||
$url = $file['url'];
|
||||
$type = $file['type'];
|
||||
$file = $file['file'];
|
||||
$filename = basename( $file );
|
||||
|
||||
// Construct the object array
|
||||
$object = array(
|
||||
|
@ -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
|
||||
|
@ -892,39 +937,44 @@ wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?>
|
|||
}
|
||||
|
||||
if ( $_POST['oitar'] > 1 ) {
|
||||
$_POST['x1'] = $_POST['x1'] * $_POST['oitar'];
|
||||
$_POST['y1'] = $_POST['y1'] * $_POST['oitar'];
|
||||
$_POST['width'] = $_POST['width'] * $_POST['oitar'];
|
||||
$_POST['x1'] = $_POST['x1'] * $_POST['oitar'];
|
||||
$_POST['y1'] = $_POST['y1'] * $_POST['oitar'];
|
||||
$_POST['width'] = $_POST['width'] * $_POST['oitar'];
|
||||
$_POST['height'] = $_POST['height'] * $_POST['oitar'];
|
||||
}
|
||||
|
||||
$attachment_id = absint( $_POST['attachment_id'] );
|
||||
$original = get_attached_file($attachment_id);
|
||||
$original = get_attached_file( $attachment_id );
|
||||
|
||||
$dimensions = $this->get_header_dimensions( array(
|
||||
'height' => $_POST['height'],
|
||||
'width' => $_POST['width'],
|
||||
) );
|
||||
$height = $dimensions['dst_height'];
|
||||
$width = $dimensions['dst_width'];
|
||||
$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,15 +1011,17 @@ 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') )
|
||||
wp_die(__('Sorry, you are not allowed to customize headers.'));
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1003,16 +1055,17 @@ wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?>
|
|||
* @since 3.4.0
|
||||
*
|
||||
* @param mixed $choice Which header image to select. Allows for values of 'random-default-image',
|
||||
* for randomly cycling among the default images; 'random-uploaded-image', for randomly cycling
|
||||
* among the uploaded images; the key of a default image registered for that theme; and
|
||||
* the key of an image uploaded for that theme (the attachment ID of the image).
|
||||
* for randomly cycling among the default images; 'random-uploaded-image', for randomly cycling
|
||||
* among the uploaded images; the key of a default image registered for that theme; and
|
||||
* the key of an image uploaded for that theme (the attachment ID of the image).
|
||||
* Or an array of arguments: attachment_id, url, width, height. All are required.
|
||||
*/
|
||||
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,10 +1095,11 @@ 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'] ) );
|
||||
|
@ -1099,15 +1153,18 @@ wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?>
|
|||
* @return array dst_height and dst_width of header image.
|
||||
*/
|
||||
final public function get_header_dimensions( $dimensions ) {
|
||||
$max_width = 0;
|
||||
$width = absint( $dimensions['width'] );
|
||||
$height = absint( $dimensions['height'] );
|
||||
$theme_height = get_theme_support( 'custom-header', 'height' );
|
||||
$theme_width = get_theme_support( 'custom-header', 'width' );
|
||||
$has_flex_width = current_theme_supports( 'custom-header', 'flex-width' );
|
||||
$max_width = 0;
|
||||
$width = absint( $dimensions['width'] );
|
||||
$height = absint( $dimensions['height'] );
|
||||
$theme_height = get_theme_support( 'custom-header', 'height' );
|
||||
$theme_width = get_theme_support( 'custom-header', 'width' );
|
||||
$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 );
|
||||
$has_max_width = current_theme_supports( 'custom-header', 'max-width' );
|
||||
$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;
|
||||
}
|
||||
|
||||
|
@ -1152,20 +1205,20 @@ wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?>
|
|||
* @return array Attachment object.
|
||||
*/
|
||||
final public function create_attachment_object( $cropped, $parent_attachment_id ) {
|
||||
$parent = get_post( $parent_attachment_id );
|
||||
$parent = get_post( $parent_attachment_id );
|
||||
$parent_url = wp_get_attachment_url( $parent->ID );
|
||||
$url = str_replace( basename( $parent_url ), basename( $cropped ), $parent_url );
|
||||
$url = str_replace( basename( $parent_url ), basename( $cropped ), $parent_url );
|
||||
|
||||
$size = @getimagesize( $cropped );
|
||||
$size = @getimagesize( $cropped );
|
||||
$image_type = ( $size ) ? $size['mime'] : 'image/jpeg';
|
||||
|
||||
$object = array(
|
||||
'ID' => $parent_attachment_id,
|
||||
'post_title' => basename($cropped),
|
||||
'ID' => $parent_attachment_id,
|
||||
'post_title' => basename( $cropped ),
|
||||
'post_mime_type' => $image_type,
|
||||
'guid' => $url,
|
||||
'context' => 'custom-header',
|
||||
'post_parent' => $parent_attachment_id,
|
||||
'guid' => $url,
|
||||
'context' => 'custom-header',
|
||||
'post_parent' => $parent_attachment_id,
|
||||
);
|
||||
|
||||
return $object;
|
||||
|
@ -1185,7 +1238,7 @@ wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?>
|
|||
unset( $object['post_parent'] );
|
||||
|
||||
$attachment_id = wp_insert_attachment( $object, $cropped );
|
||||
$metadata = wp_generate_attachment_metadata( $attachment_id, $cropped );
|
||||
$metadata = wp_generate_attachment_metadata( $attachment_id, $cropped );
|
||||
|
||||
// If this is a crop, save the original attachment ID as metadata.
|
||||
if ( $parent_id ) {
|
||||
|
@ -1227,10 +1280,12 @@ wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?>
|
|||
|
||||
$crop_details = $_POST['cropDetails'];
|
||||
|
||||
$dimensions = $this->get_header_dimensions( array(
|
||||
'height' => $crop_details['height'],
|
||||
'width' => $crop_details['width'],
|
||||
) );
|
||||
$dimensions = $this->get_header_dimensions(
|
||||
array(
|
||||
'height' => $crop_details['height'],
|
||||
'width' => $crop_details['width'],
|
||||
)
|
||||
);
|
||||
|
||||
$attachment_id = absint( $_POST['id'] );
|
||||
|
||||
|
@ -1264,9 +1319,10 @@ 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['width'] = $dimensions['dst_width'];
|
||||
$object['height'] = $dimensions['dst_height'];
|
||||
$object['url'] = wp_get_attachment_url( $new_attachment_id );
|
||||
|
||||
$object['width'] = $dimensions['dst_width'];
|
||||
$object['height'] = $dimensions['dst_height'];
|
||||
|
||||
wp_send_json_success( $object );
|
||||
}
|
||||
|
@ -1347,7 +1403,7 @@ wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?>
|
|||
}
|
||||
|
||||
$attachment_id = $data['attachment_id'];
|
||||
$key = '_wp_attachment_custom_header_last_used_' . get_stylesheet();
|
||||
$key = '_wp_attachment_custom_header_last_used_' . get_stylesheet();
|
||||
update_post_meta( $attachment_id, $key, time() );
|
||||
}
|
||||
|
||||
|
@ -1368,7 +1424,7 @@ wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?>
|
|||
return $this->default_headers; // easy peasy.
|
||||
}
|
||||
|
||||
$default = sprintf( $default, get_template_directory_uri(), get_stylesheet_directory_uri() );
|
||||
$default = sprintf( $default, get_template_directory_uri(), get_stylesheet_directory_uri() );
|
||||
$already_has_default = false;
|
||||
|
||||
foreach ( $this->default_headers as $k => $h ) {
|
||||
|
@ -1383,11 +1439,11 @@ wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?>
|
|||
}
|
||||
|
||||
// If the one true image isn't included in the default set, prepend it.
|
||||
$header_images = array();
|
||||
$header_images = array();
|
||||
$header_images['default'] = array(
|
||||
'url' => $default,
|
||||
'thumbnail_url' => $default,
|
||||
'description' => 'Default'
|
||||
'description' => 'Default',
|
||||
);
|
||||
|
||||
// The rest of the set comes after.
|
||||
|
@ -1404,12 +1460,12 @@ wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); ?>
|
|||
public function get_uploaded_header_images() {
|
||||
$header_images = get_uploaded_header_images();
|
||||
$timestamp_key = '_wp_attachment_custom_header_last_used_' . get_stylesheet();
|
||||
$alt_text_key = '_wp_attachment_image_alt';
|
||||
$alt_text_key = '_wp_attachment_image_alt';
|
||||
|
||||
foreach ( $header_images as &$header_image ) {
|
||||
$header_meta = get_post_meta( $header_image['attachment_id'] );
|
||||
$header_meta = get_post_meta( $header_image['attachment_id'] );
|
||||
$header_image['timestamp'] = isset( $header_meta[ $timestamp_key ] ) ? $header_meta[ $timestamp_key ] : '';
|
||||
$header_image['alt_text'] = isset( $header_meta[ $alt_text_key ] ) ? $header_meta[ $alt_text_key ] : '';
|
||||
$header_image['alt_text'] = isset( $header_meta[ $alt_text_key ] ) ? $header_meta[ $alt_text_key ] : '';
|
||||
}
|
||||
|
||||
return $header_images;
|
||||
|
|
|
@ -51,11 +51,11 @@ if ( $wp_customize->changeset_post_id() ) {
|
|||
*
|
||||
* By opening an Ajax request, this is avoided and the changeset is published. See #39221.
|
||||
*/
|
||||
$nonces = $wp_customize->get_nonces();
|
||||
$nonces = $wp_customize->get_nonces();
|
||||
$request_args = array(
|
||||
'nonce' => $nonces['save'],
|
||||
'customize_changeset_uuid' => $wp_customize->changeset_uuid(),
|
||||
'wp_customize' => 'on',
|
||||
'nonce' => $nonces['save'],
|
||||
'customize_changeset_uuid' => $wp_customize->changeset_uuid(),
|
||||
'wp_customize' => 'on',
|
||||
'customize_changeset_status' => 'publish',
|
||||
);
|
||||
ob_start();
|
||||
|
@ -96,13 +96,13 @@ if ( ! empty( $autofocus ) && is_array( $autofocus ) ) {
|
|||
$wp_customize->set_autofocus( wp_unslash( $autofocus ) );
|
||||
}
|
||||
|
||||
$registered = $wp_scripts->registered;
|
||||
$wp_scripts = new WP_Scripts;
|
||||
$registered = $wp_scripts->registered;
|
||||
$wp_scripts = new WP_Scripts;
|
||||
$wp_scripts->registered = $registered;
|
||||
|
||||
add_action( 'customize_controls_print_scripts', 'print_head_scripts', 20 );
|
||||
add_action( 'customize_controls_print_footer_scripts', '_wp_footer_scripts' );
|
||||
add_action( 'customize_controls_print_styles', 'print_admin_styles', 20 );
|
||||
add_action( 'customize_controls_print_scripts', 'print_head_scripts', 20 );
|
||||
add_action( 'customize_controls_print_footer_scripts', '_wp_footer_scripts' );
|
||||
add_action( 'customize_controls_print_styles', 'print_admin_styles', 20 );
|
||||
|
||||
/**
|
||||
* Fires when Customizer controls are initialized, before scripts are enqueued.
|
||||
|
@ -123,7 +123,7 @@ wp_enqueue_style( 'customize-controls' );
|
|||
do_action( 'customize_controls_enqueue_scripts' );
|
||||
|
||||
// Let's roll.
|
||||
@header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
|
||||
@header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
|
||||
|
||||
wp_user_settings();
|
||||
_wp_admin_html_begin();
|
||||
|
@ -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…' ) );
|
||||
|
||||
?><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">
|
||||
|
@ -233,12 +240,12 @@ do_action( 'customize_controls_print_scripts' );
|
|||
continue;
|
||||
}
|
||||
$active = ! empty( $settings['default'] );
|
||||
$class = 'preview-' . $device;
|
||||
$class = 'preview-' . $device;
|
||||
if ( $active ) {
|
||||
$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; ?>
|
||||
|
|
|
@ -16,22 +16,22 @@ if ( ! current_user_can( 'edit_posts' ) ) {
|
|||
);
|
||||
}
|
||||
|
||||
$wp_list_table = _get_list_table('WP_Comments_List_Table');
|
||||
$pagenum = $wp_list_table->get_pagenum();
|
||||
$wp_list_table = _get_list_table( 'WP_Comments_List_Table' );
|
||||
$pagenum = $wp_list_table->get_pagenum();
|
||||
|
||||
$doaction = $wp_list_table->current_action();
|
||||
|
||||
if ( $doaction ) {
|
||||
check_admin_referer( 'bulk-comments' );
|
||||
|
||||
if ( 'delete_all' == $doaction && !empty( $_REQUEST['pagegen_timestamp'] ) ) {
|
||||
if ( 'delete_all' == $doaction && ! empty( $_REQUEST['pagegen_timestamp'] ) ) {
|
||||
$comment_status = wp_unslash( $_REQUEST['comment_status'] );
|
||||
$delete_time = wp_unslash( $_REQUEST['pagegen_timestamp'] );
|
||||
$comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_approved = %s AND %s > comment_date_gmt", $comment_status, $delete_time ) );
|
||||
$doaction = 'delete';
|
||||
$delete_time = wp_unslash( $_REQUEST['pagegen_timestamp'] );
|
||||
$comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_approved = %s AND %s > comment_date_gmt", $comment_status, $delete_time ) );
|
||||
$doaction = 'delete';
|
||||
} elseif ( isset( $_REQUEST['delete_comments'] ) ) {
|
||||
$comment_ids = $_REQUEST['delete_comments'];
|
||||
$doaction = ( $_REQUEST['action'] != -1 ) ? $_REQUEST['action'] : $_REQUEST['action2'];
|
||||
$doaction = ( $_REQUEST['action'] != -1 ) ? $_REQUEST['action'] : $_REQUEST['action2'];
|
||||
} elseif ( isset( $_REQUEST['ids'] ) ) {
|
||||
$comment_ids = array_map( 'absint', explode( ',', $_REQUEST['ids'] ) );
|
||||
} elseif ( wp_get_referer() ) {
|
||||
|
@ -47,35 +47,36 @@ 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' :
|
||||
case 'approve':
|
||||
wp_set_comment_status( $comment_id, 'approve' );
|
||||
$approved++;
|
||||
break;
|
||||
case 'unapprove' :
|
||||
case 'unapprove':
|
||||
wp_set_comment_status( $comment_id, 'hold' );
|
||||
$unapproved++;
|
||||
break;
|
||||
case 'spam' :
|
||||
case 'spam':
|
||||
wp_spam_comment( $comment_id );
|
||||
$spammed++;
|
||||
break;
|
||||
case 'unspam' :
|
||||
case 'unspam':
|
||||
wp_unspam_comment( $comment_id );
|
||||
$unspammed++;
|
||||
break;
|
||||
case 'trash' :
|
||||
case 'trash':
|
||||
wp_trash_comment( $comment_id );
|
||||
$trashed++;
|
||||
break;
|
||||
case 'untrash' :
|
||||
case 'untrash':
|
||||
wp_untrash_comment( $comment_id );
|
||||
$untrashed++;
|
||||
break;
|
||||
case 'delete' :
|
||||
case 'delete':
|
||||
wp_delete_comment( $comment_id );
|
||||
$deleted++;
|
||||
break;
|
||||
|
@ -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;
|
||||
|
@ -130,21 +139,23 @@ if ( $doaction ) {
|
|||
|
||||
$wp_list_table->prepare_items();
|
||||
|
||||
wp_enqueue_script('admin-comments');
|
||||
wp_enqueue_script( 'admin-comments' );
|
||||
enqueue_comment_hotkeys_js();
|
||||
|
||||
if ( $post_id ) {
|
||||
$comments_count = wp_count_comments( $post_id );
|
||||
$comments_count = wp_count_comments( $post_id );
|
||||
$draft_or_post_title = wp_html_excerpt( _draft_or_post_title( $post_id ), 50, '…' );
|
||||
if ( $comments_count->moderated > 0 ) {
|
||||
/* translators: 1: comments count 2: post title */
|
||||
$title = sprintf( __( 'Comments (%1$s) on “%2$s”' ),
|
||||
$title = sprintf(
|
||||
__( 'Comments (%1$s) on “%2$s”' ),
|
||||
number_format_i18n( $comments_count->moderated ),
|
||||
$draft_or_post_title
|
||||
);
|
||||
} else {
|
||||
/* translators: %s: post title */
|
||||
$title = sprintf( __( 'Comments on “%s”' ),
|
||||
$title = sprintf(
|
||||
__( 'Comments on “%s”' ),
|
||||
$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,23 +174,27 @@ if ( $post_id ) {
|
|||
|
||||
add_screen_option( 'per_page' );
|
||||
|
||||
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(
|
||||
'id' => 'moderating-comments',
|
||||
'title' => __('Moderating Comments'),
|
||||
'content' =>
|
||||
'<p>' . __( 'A red bar on the left means the comment is waiting for you to moderate it.' ) . '</p>' .
|
||||
'<p>' . __( 'In the <strong>Author</strong> column, in addition to the author’s name, email address, and blog URL, the commenter’s IP address is shown. Clicking on this link will show you all the comments made from this IP address.' ) . '</p>' .
|
||||
'<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>'
|
||||
) );
|
||||
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(
|
||||
'id' => 'moderating-comments',
|
||||
'title' => __( 'Moderating Comments' ),
|
||||
'content' =>
|
||||
'<p>' . __( 'A red bar on the left means the comment is waiting for you to moderate it.' ) . '</p>' .
|
||||
'<p>' . __( 'In the <strong>Author</strong> column, in addition to the author’s name, email address, and blog URL, the commenter’s IP address is shown. Clicking on this link will show you all the comments made from this IP address.' ) . '</p>' .
|
||||
'<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>',
|
||||
)
|
||||
);
|
||||
|
||||
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(
|
||||
'heading_views' => __( 'Filter comments list' ),
|
||||
'heading_pagination' => __( 'Comments list navigation' ),
|
||||
'heading_list' => __( 'Comments list' ),
|
||||
) );
|
||||
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 “%s”' ),
|
||||
sprintf( '<a href="%1$s">%2$s</a>',
|
||||
printf(
|
||||
__( 'Comments on “%s”' ),
|
||||
sprintf(
|
||||
'<a href="%1$s">%2$s</a>',
|
||||
get_edit_post_link( $post_id ),
|
||||
wp_html_excerpt( _draft_or_post_title( $post_id ), 50, '…' )
|
||||
)
|
||||
|
@ -210,13 +231,15 @@ if ( $post_id ) {
|
|||
} else {
|
||||
_e( 'Comments' );
|
||||
}
|
||||
?></h1>
|
||||
?>
|
||||
</h1>
|
||||
|
||||
<?php
|
||||
if ( isset($_REQUEST['s']) && strlen( $_REQUEST['s'] ) ) {
|
||||
if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) {
|
||||
echo '<span class="subtitle">';
|
||||
/* translators: %s: search keywords */
|
||||
printf( __( 'Search results for “%s”' ),
|
||||
printf(
|
||||
__( 'Search results for “%s”' ),
|
||||
wp_html_excerpt( esc_html( wp_unslash( $_REQUEST['s'] ) ), 50, '…' )
|
||||
);
|
||||
echo '</span>';
|
||||
|
@ -227,28 +250,29 @@ if ( isset($_REQUEST['s']) && strlen( $_REQUEST['s'] ) ) {
|
|||
|
||||
<?php
|
||||
if ( isset( $_REQUEST['error'] ) ) {
|
||||
$error = (int) $_REQUEST['error'];
|
||||
$error = (int) $_REQUEST['error'];
|
||||
$error_msg = '';
|
||||
switch ( $error ) {
|
||||
case 1 :
|
||||
case 1:
|
||||
$error_msg = __( 'Invalid comment ID.' );
|
||||
break;
|
||||
case 2 :
|
||||
case 2:
|
||||
$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;
|
||||
$deleted = isset( $_REQUEST['deleted'] ) ? (int) $_REQUEST['deleted'] : 0;
|
||||
$trashed = isset( $_REQUEST['trashed'] ) ? (int) $_REQUEST['trashed'] : 0;
|
||||
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;
|
||||
$deleted = isset( $_REQUEST['deleted'] ) ? (int) $_REQUEST['deleted'] : 0;
|
||||
$trashed = isset( $_REQUEST['trashed'] ) ? (int) $_REQUEST['trashed'] : 0;
|
||||
$untrashed = isset( $_REQUEST['untrashed'] ) ? (int) $_REQUEST['untrashed'] : 0;
|
||||
$spammed = isset( $_REQUEST['spammed'] ) ? (int) $_REQUEST['spammed'] : 0;
|
||||
$spammed = isset( $_REQUEST['spammed'] ) ? (int) $_REQUEST['spammed'] : 0;
|
||||
$unspammed = isset( $_REQUEST['unspammed'] ) ? (int) $_REQUEST['unspammed'] : 0;
|
||||
$same = isset( $_REQUEST['same'] ) ? (int) $_REQUEST['same'] : 0;
|
||||
$same = isset( $_REQUEST['same'] ) ? (int) $_REQUEST['same'] : 0;
|
||||
|
||||
if ( $approved > 0 || $deleted > 0 || $trashed > 0 || $untrashed > 0 || $spammed > 0 || $unspammed > 0 || $same > 0 ) {
|
||||
if ( $approved > 0 ) {
|
||||
|
@ -257,9 +281,9 @@ if ( isset($_REQUEST['approved']) || isset($_REQUEST['deleted']) || isset($_REQU
|
|||
}
|
||||
|
||||
if ( $spammed > 0 ) {
|
||||
$ids = isset($_REQUEST['ids']) ? $_REQUEST['ids'] : 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 ) {
|
||||
|
@ -268,9 +292,9 @@ if ( isset($_REQUEST['approved']) || isset($_REQUEST['deleted']) || isset($_REQU
|
|||
}
|
||||
|
||||
if ( $trashed > 0 ) {
|
||||
$ids = isset($_REQUEST['ids']) ? $_REQUEST['ids'] : 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 ) {
|
||||
|
@ -285,13 +309,13 @@ if ( isset($_REQUEST['approved']) || isset($_REQUEST['deleted']) || isset($_REQU
|
|||
|
||||
if ( $same > 0 && $comment = get_comment( $same ) ) {
|
||||
switch ( $comment->comment_approved ) {
|
||||
case '1' :
|
||||
$messages[] = __('This comment is already approved.') . ' <a href="' . esc_url( admin_url( "comment.php?action=editcomment&c=$same" ) ) . '">' . __( 'Edit comment' ) . '</a>';
|
||||
case '1':
|
||||
$messages[] = __( 'This comment is already approved.' ) . ' <a href="' . esc_url( admin_url( "comment.php?action=editcomment&c=$same" ) ) . '">' . __( 'Edit comment' ) . '</a>';
|
||||
break;
|
||||
case 'trash' :
|
||||
case 'trash':
|
||||
$messages[] = __( 'This comment is already in the Trash.' ) . ' <a href="' . esc_url( admin_url( 'edit-comments.php?comment_status=trash' ) ) . '"> ' . __( 'View Trash' ) . '</a>';
|
||||
break;
|
||||
case 'spam' :
|
||||
case 'spam':
|
||||
$messages[] = __( 'This comment is already marked as spam.' ) . ' <a href="' . esc_url( admin_url( "comment.php?action=editcomment&c=$same" ) ) . '">' . __( 'Edit comment' ) . '</a>';
|
||||
break;
|
||||
}
|
||||
|
@ -311,14 +335,14 @@ if ( isset($_REQUEST['approved']) || isset($_REQUEST['deleted']) || isset($_REQU
|
|||
<?php if ( $post_id ) : ?>
|
||||
<input type="hidden" name="p" value="<?php echo esc_attr( intval( $post_id ) ); ?>" />
|
||||
<?php endif; ?>
|
||||
<input type="hidden" name="comment_status" value="<?php echo esc_attr($comment_status); ?>" />
|
||||
<input type="hidden" name="pagegen_timestamp" value="<?php echo esc_attr(current_time('mysql', 1)); ?>" />
|
||||
<input type="hidden" name="comment_status" value="<?php echo esc_attr( $comment_status ); ?>" />
|
||||
<input type="hidden" name="pagegen_timestamp" value="<?php echo esc_attr( current_time( 'mysql', 1 ) ); ?>" />
|
||||
|
||||
<input type="hidden" name="_total" value="<?php echo esc_attr( $wp_list_table->get_pagination_arg('total_items') ); ?>" />
|
||||
<input type="hidden" name="_per_page" value="<?php echo esc_attr( $wp_list_table->get_pagination_arg('per_page') ); ?>" />
|
||||
<input type="hidden" name="_page" value="<?php echo esc_attr( $wp_list_table->get_pagination_arg('page') ); ?>" />
|
||||
<input type="hidden" name="_total" value="<?php echo esc_attr( $wp_list_table->get_pagination_arg( 'total_items' ) ); ?>" />
|
||||
<input type="hidden" name="_per_page" value="<?php echo esc_attr( $wp_list_table->get_pagination_arg( 'per_page' ) ); ?>" />
|
||||
<input type="hidden" name="_page" value="<?php echo esc_attr( $wp_list_table->get_pagination_arg( 'page' ) ); ?>" />
|
||||
|
||||
<?php if ( isset($_REQUEST['paged']) ) { ?>
|
||||
<?php if ( isset( $_REQUEST['paged'] ) ) { ?>
|
||||
<input type="hidden" name="paged" value="<?php echo esc_attr( absint( $_REQUEST['paged'] ) ); ?>" />
|
||||
<?php } ?>
|
||||
|
||||
|
@ -329,6 +353,6 @@ if ( isset($_REQUEST['approved']) || isset($_REQUEST['deleted']) || isset($_REQU
|
|||
<div id="ajax-response"></div>
|
||||
|
||||
<?php
|
||||
wp_comment_reply('-1', true, 'detail');
|
||||
wp_comment_reply( '-1', true, 'detail' );
|
||||
wp_comment_trashnotice();
|
||||
include( ABSPATH . 'wp-admin/admin-footer.php' ); ?>
|
||||
|
|
|
@ -7,8 +7,9 @@
|
|||
*/
|
||||
|
||||
// don't load directly
|
||||
if ( !defined('ABSPATH') )
|
||||
die('-1');
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
die( '-1' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @global string $post_type
|
||||
|
@ -20,15 +21,21 @@ 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 );
|
||||
}
|
||||
|
||||
wp_enqueue_script('post');
|
||||
wp_enqueue_script( 'post' );
|
||||
$_wp_editor_expand = $_content_editor_dfw = false;
|
||||
|
||||
/**
|
||||
|
@ -44,22 +51,24 @@ if ( post_type_supports( $post_type, 'editor' ) && ! wp_is_mobile() &&
|
|||
! ( $is_IE && preg_match( '/MSIE [5678]/', $_SERVER['HTTP_USER_AGENT'] ) ) &&
|
||||
apply_filters( 'wp_editor_expand', true, $post_type ) ) {
|
||||
|
||||
wp_enqueue_script('editor-expand');
|
||||
wp_enqueue_script( 'editor-expand' );
|
||||
$_content_editor_dfw = true;
|
||||
$_wp_editor_expand = ( get_user_setting( 'editor_expand', 'on' ) === 'on' );
|
||||
$_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
|
||||
*/
|
||||
$post_ID = isset($post_ID) ? (int) $post_ID : 0;
|
||||
$user_ID = isset($user_ID) ? (int) $user_ID : 0;
|
||||
$action = isset($action) ? $action : '';
|
||||
$post_ID = isset( $post_ID ) ? (int) $post_ID : 0;
|
||||
$user_ID = isset( $user_ID ) ? (int) $user_ID : 0;
|
||||
$action = isset( $action ) ? $action : '';
|
||||
|
||||
if ( $post_ID == get_option( 'page_for_posts' ) && empty( $post->post_content ) ) {
|
||||
add_action( 'edit_form_after_title', '_wp_posts_page_notice' );
|
||||
|
@ -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' )
|
||||
);
|
||||
|
@ -144,31 +159,31 @@ if ( $viewable ) {
|
|||
$scheduled_date = date_i18n( __( 'M j, Y @ H:i' ), strtotime( $post->post_date ) );
|
||||
|
||||
$messages['post'] = array(
|
||||
0 => '', // Unused. Messages start at index 1.
|
||||
1 => __( 'Post updated.' ) . $view_post_link_html,
|
||||
2 => __( 'Custom field updated.' ),
|
||||
3 => __( 'Custom field deleted.' ),
|
||||
4 => __( 'Post updated.' ),
|
||||
0 => '', // Unused. Messages start at index 1.
|
||||
1 => __( 'Post updated.' ) . $view_post_link_html,
|
||||
2 => __( 'Custom field updated.' ),
|
||||
3 => __( 'Custom field deleted.' ),
|
||||
4 => __( 'Post updated.' ),
|
||||
/* translators: %s: date and time of the revision */
|
||||
5 => isset($_GET['revision']) ? sprintf( __( 'Post restored to revision from %s.' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
|
||||
6 => __( 'Post published.' ) . $view_post_link_html,
|
||||
7 => __( 'Post saved.' ),
|
||||
8 => __( 'Post submitted.' ) . $preview_post_link_html,
|
||||
9 => sprintf( __( 'Post scheduled for: %s.' ), '<strong>' . $scheduled_date . '</strong>' ) . $scheduled_post_link_html,
|
||||
5 => isset( $_GET['revision'] ) ? sprintf( __( 'Post restored to revision from %s.' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
|
||||
6 => __( 'Post published.' ) . $view_post_link_html,
|
||||
7 => __( 'Post saved.' ),
|
||||
8 => __( 'Post submitted.' ) . $preview_post_link_html,
|
||||
9 => sprintf( __( 'Post scheduled for: %s.' ), '<strong>' . $scheduled_date . '</strong>' ) . $scheduled_post_link_html,
|
||||
10 => __( 'Post draft updated.' ) . $preview_post_link_html,
|
||||
);
|
||||
$messages['page'] = array(
|
||||
0 => '', // Unused. Messages start at index 1.
|
||||
1 => __( 'Page updated.' ) . $view_page_link_html,
|
||||
2 => __( 'Custom field updated.' ),
|
||||
3 => __( 'Custom field deleted.' ),
|
||||
4 => __( 'Page updated.' ),
|
||||
0 => '', // Unused. Messages start at index 1.
|
||||
1 => __( 'Page updated.' ) . $view_page_link_html,
|
||||
2 => __( 'Custom field updated.' ),
|
||||
3 => __( 'Custom field deleted.' ),
|
||||
4 => __( 'Page updated.' ),
|
||||
/* translators: %s: date and time of the revision */
|
||||
5 => isset($_GET['revision']) ? sprintf( __( 'Page restored to revision from %s.' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
|
||||
6 => __( 'Page published.' ) . $view_page_link_html,
|
||||
7 => __( 'Page saved.' ),
|
||||
8 => __( 'Page submitted.' ) . $preview_page_link_html,
|
||||
9 => sprintf( __( 'Page scheduled for: %s.' ), '<strong>' . $scheduled_date . '</strong>' ) . $scheduled_page_link_html,
|
||||
5 => isset( $_GET['revision'] ) ? sprintf( __( 'Page restored to revision from %s.' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
|
||||
6 => __( 'Page published.' ) . $view_page_link_html,
|
||||
7 => __( 'Page saved.' ),
|
||||
8 => __( 'Page submitted.' ) . $preview_page_link_html,
|
||||
9 => sprintf( __( 'Page scheduled for: %s.' ), '<strong>' . $scheduled_date . '</strong>' ) . $scheduled_page_link_html,
|
||||
10 => __( 'Page draft updated.' ) . $preview_page_link_html,
|
||||
);
|
||||
$messages['attachment'] = array_fill( 1, 10, __( 'Media file updated.' ) ); // Hack, for now.
|
||||
|
@ -183,28 +198,30 @@ $messages['attachment'] = array_fill( 1, 10, __( 'Media file updated.' ) ); // H
|
|||
$messages = apply_filters( 'post_updated_messages', $messages );
|
||||
|
||||
$message = false;
|
||||
if ( isset($_GET['message']) ) {
|
||||
if ( isset( $_GET['message'] ) ) {
|
||||
$_GET['message'] = absint( $_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']]) )
|
||||
$message = $messages['post'][$_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'] ] ) ) {
|
||||
$message = $messages['post'][ $_GET['message'] ];
|
||||
}
|
||||
}
|
||||
|
||||
$notice = false;
|
||||
$notice = false;
|
||||
$form_extra = '';
|
||||
if ( 'auto-draft' == $post->post_status ) {
|
||||
if ( 'edit' == $action )
|
||||
if ( 'edit' == $action ) {
|
||||
$post->post_title = '';
|
||||
$autosave = false;
|
||||
}
|
||||
$autosave = false;
|
||||
$form_extra .= "<input type='hidden' id='auto_draft' name='auto_draft' value='1' />";
|
||||
} else {
|
||||
$autosave = wp_get_post_autosave( $post_ID );
|
||||
}
|
||||
|
||||
$form_action = 'editpost';
|
||||
$form_action = 'editpost';
|
||||
$nonce_action = 'update-post_' . $post_ID;
|
||||
$form_extra .= "<input type='hidden' id='post_ID' name='post_ID' value='" . esc_attr($post_ID) . "' />";
|
||||
$form_extra .= "<input type='hidden' id='post_ID' name='post_ID' value='" . esc_attr( $post_ID ) . "' />";
|
||||
|
||||
// Detect if there exists an autosave newer than the post and if that autosave is different than the post
|
||||
if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) {
|
||||
|
@ -215,33 +232,37 @@ 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);
|
||||
}
|
||||
unset( $autosave_field, $_autosave_field );
|
||||
}
|
||||
|
||||
$post_type_object = get_post_type_object($post_type);
|
||||
$post_type_object = get_post_type_object( $post_type );
|
||||
|
||||
// All meta boxes should be defined and added before the first do_meta_boxes() call (or potentially during the do_meta_boxes action).
|
||||
require_once( ABSPATH . 'wp-admin/includes/meta-boxes.php' );
|
||||
|
||||
|
||||
$publish_callback_args = null;
|
||||
if ( post_type_supports($post_type, 'revisions') && 'auto-draft' != $post->post_status ) {
|
||||
if ( post_type_supports( $post_type, 'revisions' ) && 'auto-draft' != $post->post_status ) {
|
||||
$revisions = wp_get_post_revisions( $post_ID );
|
||||
|
||||
// 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 ) );
|
||||
add_meta_box('revisionsdiv', __('Revisions'), 'post_revisions_meta_box', null, 'normal', 'core');
|
||||
$publish_callback_args = array(
|
||||
'revisions_count' => count( $revisions ),
|
||||
'revision_id' => key( $revisions ),
|
||||
);
|
||||
add_meta_box( 'revisionsdiv', __( 'Revisions' ), 'post_revisions_meta_box', null, 'normal', 'core' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'attachment' == $post_type ) {
|
||||
wp_enqueue_script( 'image-edit' );
|
||||
wp_enqueue_style( 'imgareaselect' );
|
||||
add_meta_box( 'submitdiv', __('Save'), 'attachment_submit_meta_box', null, 'side', 'core' );
|
||||
add_meta_box( 'submitdiv', __( 'Save' ), 'attachment_submit_meta_box', null, 'side', 'core' );
|
||||
add_action( 'edit_form_after_title', 'edit_form_image_editor' );
|
||||
|
||||
if ( wp_attachment_is( 'audio', $post ) ) {
|
||||
|
@ -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' ) )
|
||||
add_meta_box('postimagediv', esc_html( $post_type_object->labels->featured_image ), 'post_thumbnail_meta_box', null, 'side', 'low');
|
||||
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') )
|
||||
add_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', null, 'normal', 'core');
|
||||
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') )
|
||||
add_meta_box('trackbacksdiv', __('Send Trackbacks'), 'post_trackback_meta_box', null, 'normal', 'core');
|
||||
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') )
|
||||
add_meta_box('postcustom', __('Custom Fields'), 'post_custom_meta_box', null, 'normal', 'core');
|
||||
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 ) ) )
|
||||
add_meta_box('slugdiv', __('Slug'), 'post_slug_meta_box', null, 'normal', 'core');
|
||||
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,18 +390,25 @@ 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>';
|
||||
$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(
|
||||
'id' => 'customize-display',
|
||||
'title' => __('Customizing This Display'),
|
||||
'content' => $customize_display,
|
||||
) );
|
||||
get_current_screen()->add_help_tab(
|
||||
array(
|
||||
'id' => 'customize-display',
|
||||
'title' => __( 'Customizing This Display' ),
|
||||
'content' => $customize_display,
|
||||
)
|
||||
);
|
||||
|
||||
$title_and_editor = '<p>' . __('<strong>Title</strong> — Enter a title for your post. After you enter a title, you’ll see the permalink below, which you can edit.') . '</p>';
|
||||
$title_and_editor = '<p>' . __( '<strong>Title</strong> — Enter a title for your post. After you enter a title, you’ll see the permalink below, which you can edit.' ) . '</p>';
|
||||
$title_and_editor .= '<p>' . __( '<strong>Post editor</strong> — 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>';
|
||||
$title_and_editor .= '<p>' . __( 'Visual mode gives you an editor that is similar to a word processor. Click the Toolbar Toggle button to get a second row of controls.' ) . '</p>';
|
||||
$title_and_editor .= '<p>' . __( 'The Text mode allows you to enter HTML along with your post text. Note that <p> and <br> tags are converted to line breaks when switching to the Text editor to make it less cluttered. When you type, a single line break can be used instead of typing <br>, and two line breaks instead of paragraph tags. The line breaks are converted back to tags automatically.' ) . '</p>';
|
||||
|
@ -380,65 +416,73 @@ 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’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(
|
||||
'id' => 'title-post-editor',
|
||||
'title' => __('Title and Post Editor'),
|
||||
'content' => $title_and_editor,
|
||||
) );
|
||||
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>' .
|
||||
'<p><strong>' . __('For more information:') . '</strong></p>' .
|
||||
'<p>' . __('<a href="https://codex.wordpress.org/Posts_Add_New_Screen">Documentation on Writing and Editing Posts</a>') . '</p>' .
|
||||
'<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>'
|
||||
'<p>' . sprintf( __( 'You can also create posts with the <a href="%s">Press This bookmarklet</a>.' ), 'tools.php' ) . '</p>' .
|
||||
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
|
||||
'<p>' . __( '<a href="https://codex.wordpress.org/Posts_Add_New_Screen">Documentation on Writing and Editing Posts</a>' ) . '</p>' .
|
||||
'<p>' . __( '<a href="https://wordpress.org/support/">Support Forums</a>' ) . '</p>'
|
||||
);
|
||||
} elseif ( 'page' == $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 “Parent” 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>';
|
||||
$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 “Parent” 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(
|
||||
'id' => 'about-pages',
|
||||
'title' => __('About Pages'),
|
||||
'content' => $about_pages,
|
||||
) );
|
||||
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>' .
|
||||
'<p>' . __('<a href="https://codex.wordpress.org/Pages_Add_New_Screen">Documentation on Adding New Pages</a>') . '</p>' .
|
||||
'<p>' . __('<a href="https://codex.wordpress.org/Pages_Screen#Editing_Individual_Pages">Documentation on Editing Pages</a>') . '</p>' .
|
||||
'<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>'
|
||||
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
|
||||
'<p>' . __( '<a href="https://codex.wordpress.org/Pages_Add_New_Screen">Documentation on Adding New Pages</a>' ) . '</p>' .
|
||||
'<p>' . __( '<a href="https://codex.wordpress.org/Pages_Screen#Editing_Individual_Pages">Documentation on Editing Pages</a>' ) . '</p>' .
|
||||
'<p>' . __( '<a href="https://wordpress.org/support/">Support Forums</a>' ) . '</p>'
|
||||
);
|
||||
} elseif ( 'attachment' == $post_type ) {
|
||||
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>'
|
||||
) );
|
||||
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>',
|
||||
)
|
||||
);
|
||||
|
||||
get_current_screen()->set_help_sidebar(
|
||||
'<p><strong>' . __('For more information:') . '</strong></p>' .
|
||||
'<p>' . __('<a href="https://codex.wordpress.org/Media_Add_New_Screen#Edit_Media">Documentation on Edit Media</a>') . '</p>' .
|
||||
'<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>'
|
||||
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
|
||||
'<p>' . __( '<a href="https://codex.wordpress.org/Media_Add_New_Screen#Edit_Media">Documentation on Edit Media</a>' ) . '</p>' .
|
||||
'<p>' . __( '<a href="https://wordpress.org/support/">Support Forums</a>' ) . '</p>'
|
||||
);
|
||||
}
|
||||
|
||||
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 “Create a new gallery” button.' ) . '</p>';
|
||||
$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 “Create a new gallery” 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(
|
||||
'id' => 'inserting-media',
|
||||
'title' => __( 'Inserting Media' ),
|
||||
'content' => $inserting_media,
|
||||
) );
|
||||
get_current_screen()->add_help_tab(
|
||||
array(
|
||||
'id' => 'inserting-media',
|
||||
'title' => __( 'Inserting Media' ),
|
||||
'content' => $inserting_media,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ( 'post' == $post_type ) {
|
||||
$publish_box = '<p>' . __('Several boxes on this screen contain settings for how your content will be published, including:') . '</p>';
|
||||
$publish_box = '<p>' . __( 'Several boxes on this screen contain settings for how your content will be published, including:' ) . '</p>';
|
||||
$publish_box .= '<ul><li>' .
|
||||
__( '<strong>Publish</strong> — You can set the terms of publishing your post in the Publish box. For Status, Visibility, and Publish (immediately), click on the Edit link to reveal more options. Visibility includes options for password-protecting a post or making it stay at the top of your blog indefinitely (sticky). The Password protected option allows you to set an arbitrary password for each post. The Private option hides the post from everyone except editors and administrators. Publish (immediately) allows you to set a future or past date and time, so you can schedule a post to be published in the future or backdate a post.' ) .
|
||||
'</li>';
|
||||
|
@ -454,39 +498,47 @@ if ( 'post' == $post_type ) {
|
|||
|
||||
$publish_box .= '</ul>';
|
||||
|
||||
get_current_screen()->add_help_tab( array(
|
||||
'id' => 'publish-box',
|
||||
'title' => __('Publish Settings'),
|
||||
'content' => $publish_box,
|
||||
) );
|
||||
get_current_screen()->add_help_tab(
|
||||
array(
|
||||
'id' => 'publish-box',
|
||||
'title' => __( 'Publish Settings' ),
|
||||
'content' => $publish_box,
|
||||
)
|
||||
);
|
||||
|
||||
$discussion_settings = '<p>' . __('<strong>Send Trackbacks</strong> — Trackbacks are a way to notify legacy blog systems that you’ve linked to them. Enter the URL(s) you want to send trackbacks. If you link to other WordPress sites they’ll be notified automatically using pingbacks, and this field is unnecessary.') . '</p>';
|
||||
$discussion_settings .= '<p>' . __('<strong>Discussion</strong> — 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>';
|
||||
$discussion_settings = '<p>' . __( '<strong>Send Trackbacks</strong> — Trackbacks are a way to notify legacy blog systems that you’ve linked to them. Enter the URL(s) you want to send trackbacks. If you link to other WordPress sites they’ll be notified automatically using pingbacks, and this field is unnecessary.' ) . '</p>';
|
||||
$discussion_settings .= '<p>' . __( '<strong>Discussion</strong> — 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(
|
||||
'id' => 'discussion-settings',
|
||||
'title' => __('Discussion Settings'),
|
||||
'content' => $discussion_settings,
|
||||
) );
|
||||
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> — You can arrange your pages in hierarchies. For example, you could have an “About” page that has “Life Story” and “My Dog” pages under it. There are no limits to how many levels you can nest pages.') . '</p>' .
|
||||
'<p>' . __('<strong>Template</strong> — Some themes have custom templates you can use for certain pages that might have additional features or custom layouts. If so, you’ll see them in this dropdown menu.') . '</p>' .
|
||||
'<p>' . __('<strong>Order</strong> — Pages are usually ordered alphabetically, but you can choose your own order by entering a number (1 for first, etc.) in this field.') . '</p>';
|
||||
$page_attributes = '<p>' . __( '<strong>Parent</strong> — You can arrange your pages in hierarchies. For example, you could have an “About” page that has “Life Story” and “My Dog” pages under it. There are no limits to how many levels you can nest pages.' ) . '</p>' .
|
||||
'<p>' . __( '<strong>Template</strong> — Some themes have custom templates you can use for certain pages that might have additional features or custom layouts. If so, you’ll see them in this dropdown menu.' ) . '</p>' .
|
||||
'<p>' . __( '<strong>Order</strong> — 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(
|
||||
'id' => 'page-attributes',
|
||||
'title' => __('Page Attributes'),
|
||||
'content' => $page_attributes,
|
||||
) );
|
||||
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’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 ) ?>" />
|
||||
?>
|
||||
>
|
||||
<?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="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 ) )
|
||||
wp_original_referer_field(true, 'previous');
|
||||
if ( 'draft' != get_post_status( $post ) ) {
|
||||
wp_original_referer_field( true, 'previous' );
|
||||
}
|
||||
|
||||
echo $form_extra;
|
||||
|
||||
|
@ -550,13 +605,14 @@ 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'; ?>">
|
||||
<div id="post-body-content">
|
||||
|
||||
<?php if ( post_type_supports($post_type, 'title') ) { ?>
|
||||
<?php if ( post_type_supports( $post_type, 'title' ) ) { ?>
|
||||
<div id="titlediv">
|
||||
<div id="titlewrap">
|
||||
<?php
|
||||
|
@ -586,28 +642,29 @@ do_action( 'edit_form_before_permalink', $post );
|
|||
<div class="inside">
|
||||
<?php
|
||||
if ( $viewable ) :
|
||||
$sample_permalink_html = $post_type_object->public ? get_sample_permalink_html($post->ID) : '';
|
||||
$sample_permalink_html = $post_type_object->public ? get_sample_permalink_html( $post->ID ) : '';
|
||||
|
||||
// As of 4.4, the Get Shortlink button is hidden by default.
|
||||
if ( has_filter( 'pre_get_shortlink' ) || has_filter( 'get_shortlink' ) ) {
|
||||
$shortlink = wp_get_shortlink($post->ID, 'post');
|
||||
// As of 4.4, the Get Shortlink button is hidden by default.
|
||||
if ( has_filter( 'pre_get_shortlink' ) || has_filter( 'get_shortlink' ) ) {
|
||||
$shortlink = wp_get_shortlink( $post->ID, 'post' );
|
||||
|
||||
if ( !empty( $shortlink ) && $shortlink !== $permalink && $permalink !== home_url('?page_id=' . $post->ID) ) {
|
||||
$sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr( $shortlink ) . '" /><button type="button" class="button button-small" onclick="prompt('URL:', jQuery(\'#shortlink\').val());">' . __( 'Get Shortlink' ) . '</button>';
|
||||
if ( ! empty( $shortlink ) && $shortlink !== $permalink && $permalink !== home_url( '?page_id=' . $post->ID ) ) {
|
||||
$sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr( $shortlink ) . '" /><button type="button" class="button button-small" onclick="prompt('URL:', jQuery(\'#shortlink\').val());">' . __( 'Get Shortlink' ) . '</button>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $post_type_object->public && ! ( 'pending' == get_post_status( $post ) && !current_user_can( $post_type_object->cap->publish_posts ) ) ) {
|
||||
$has_sample_permalink = $sample_permalink_html && 'auto-draft' != $post->post_status;
|
||||
?>
|
||||
if ( $post_type_object->public && ! ( 'pending' == get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) ) ) {
|
||||
$has_sample_permalink = $sample_permalink_html && 'auto-draft' != $post->post_status;
|
||||
?>
|
||||
<div id="edit-slug-box" class="hide-if-no-js">
|
||||
<?php
|
||||
if ( $has_sample_permalink )
|
||||
echo $sample_permalink_html;
|
||||
if ( $has_sample_permalink ) {
|
||||
echo $sample_permalink_html;
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
<?php
|
||||
}
|
||||
endif;
|
||||
?>
|
||||
</div>
|
||||
|
@ -626,7 +683,7 @@ wp_nonce_field( 'samplepermalink', 'samplepermalinknonce', false );
|
|||
*/
|
||||
do_action( 'edit_form_after_title', $post );
|
||||
|
||||
if ( post_type_supports($post_type, 'editor') ) {
|
||||
if ( post_type_supports( $post_type, 'editor' ) ) {
|
||||
$_wp_editor_expand_class = '';
|
||||
if ( $_wp_editor_expand ) {
|
||||
$_wp_editor_expand_class = ' wp-editor-expand';
|
||||
|
@ -634,40 +691,46 @@ 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(
|
||||
'_content_editor_dfw' => $_content_editor_dfw,
|
||||
'drag_drop_upload' => true,
|
||||
'tabfocus_elements' => 'content-html,save-post',
|
||||
'editor_height' => 300,
|
||||
'tinymce' => array(
|
||||
'resize' => false,
|
||||
'wp_autoresize_on' => $_wp_editor_expand,
|
||||
'add_unload_trigger' => false,
|
||||
'wp_keep_scroll_position' => ! $is_IE,
|
||||
),
|
||||
) ); ?>
|
||||
<?php
|
||||
wp_editor(
|
||||
$post->post_content, 'content', array(
|
||||
'_content_editor_dfw' => $_content_editor_dfw,
|
||||
'drag_drop_upload' => true,
|
||||
'tabfocus_elements' => 'content-html,save-post',
|
||||
'editor_height' => 300,
|
||||
'tinymce' => array(
|
||||
'resize' => false,
|
||||
'wp_autoresize_on' => $_wp_editor_expand,
|
||||
'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">
|
||||
<span class="autosave-message"> </span>
|
||||
<?php
|
||||
if ( 'auto-draft' != $post->post_status ) {
|
||||
echo '<span id="last-edit">';
|
||||
if ( $last_user = get_userdata( get_post_meta( $post_ID, '_edit_last', true ) ) ) {
|
||||
/* translators: 1: Name of most recent post author, 2: Post edited date, 3: Post edited time */
|
||||
printf( __( 'Last edited by %1$s on %2$s at %3$s' ), esc_html( $last_user->display_name ), mysql2date( __( 'F j, Y' ), $post->post_modified ), mysql2date( __( 'g:i a' ), $post->post_modified ) );
|
||||
} else {
|
||||
/* translators: 1: Post edited date, 2: Post edited time */
|
||||
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>';
|
||||
} ?>
|
||||
if ( 'auto-draft' != $post->post_status ) {
|
||||
echo '<span id="last-edit">';
|
||||
if ( $last_user = get_userdata( get_post_meta( $post_ID, '_edit_last', true ) ) ) {
|
||||
/* translators: 1: Name of most recent post author, 2: Post edited date, 3: Post edited time */
|
||||
printf( __( 'Last edited by %1$s on %2$s at %3$s' ), esc_html( $last_user->display_name ), mysql2date( __( 'F j, Y' ), $post->post_modified ), mysql2date( __( 'g:i a' ), $post->post_modified ) );
|
||||
} else {
|
||||
/* translators: 1: Post edited date, 2: Post edited time */
|
||||
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'.
|
||||
*
|
||||
|
@ -708,14 +770,14 @@ else {
|
|||
}
|
||||
|
||||
|
||||
do_meta_boxes($post_type, 'side', $post);
|
||||
do_meta_boxes( $post_type, 'side', $post );
|
||||
|
||||
?>
|
||||
</div>
|
||||
<div id="postbox-container-2" class="postbox-container">
|
||||
<?php
|
||||
|
||||
do_meta_boxes(null, 'normal', $post);
|
||||
do_meta_boxes( null, 'normal', $post );
|
||||
|
||||
if ( 'page' == $post_type ) {
|
||||
/**
|
||||
|
@ -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'.
|
||||
*
|
||||
|
@ -739,7 +800,7 @@ else {
|
|||
}
|
||||
|
||||
|
||||
do_meta_boxes(null, 'advanced', $post);
|
||||
do_meta_boxes( null, 'advanced', $post );
|
||||
|
||||
?>
|
||||
</div>
|
||||
|
@ -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 ) : ?>
|
||||
|
|
|
@ -7,11 +7,12 @@
|
|||
*/
|
||||
|
||||
// don't load directly
|
||||
if ( !defined('ABSPATH') )
|
||||
die('-1');
|
||||
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>
|
||||
|
@ -52,7 +53,7 @@ if ( 'approved' === wp_get_comment_status( $comment ) && $comment->comment_post_
|
|||
<tr>
|
||||
<td class="first"><label for="newcomment_author_url"><?php _e( 'URL:' ); ?></label></td>
|
||||
<td>
|
||||
<input type="text" id="newcomment_author_url" name="newcomment_author_url" size="30" class="code" value="<?php echo esc_attr($comment->comment_author_url); ?>" />
|
||||
<input type="text" id="newcomment_author_url" name="newcomment_author_url" size="30" class="code" value="<?php echo esc_attr( $comment->comment_author_url ); ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
@ -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>
|
||||
|
@ -109,7 +119,7 @@ printf(
|
|||
<?php
|
||||
$post_id = $comment->comment_post_ID;
|
||||
if ( current_user_can( 'edit_post', $post_id ) ) {
|
||||
$post_link = "<a href='" . esc_url( get_edit_post_link( $post_id ) ) . "'>";
|
||||
$post_link = "<a href='" . esc_url( get_edit_post_link( $post_id ) ) . "'>";
|
||||
$post_link .= esc_html( get_the_title( $post_id ) ) . '</a>';
|
||||
} else {
|
||||
$post_link = esc_html( get_the_title( $post_id ) );
|
||||
|
@ -117,29 +127,35 @@ 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
|
||||
if ( $comment->comment_parent ) :
|
||||
$parent = get_comment( $comment->comment_parent );
|
||||
$parent = get_comment( $comment->comment_parent );
|
||||
if ( $parent ) :
|
||||
$parent_link = esc_url( get_comment_link( $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' ) . "&c=$comment->comment_ID&_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' ) . "&c=$comment->comment_ID&_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 ); ?>
|
||||
|
@ -185,16 +201,16 @@ do_action( 'add_meta_boxes', 'comment', $comment );
|
|||
*/
|
||||
do_action( 'add_meta_boxes_comment', $comment );
|
||||
|
||||
do_meta_boxes(null, 'normal', $comment);
|
||||
do_meta_boxes( null, 'normal', $comment );
|
||||
|
||||
$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'); ?>
|
||||
<?php wp_original_referer_field( true, 'previous' ); ?>
|
||||
<input type="hidden" name="noredir" value="1" />
|
||||
|
||||
</div><!-- /post-body -->
|
||||
|
@ -206,4 +222,5 @@ $referer = wp_get_referer();
|
|||
<script type="text/javascript">
|
||||
try{document.post.name.focus();}catch(e){}
|
||||
</script>
|
||||
<?php endif;
|
||||
<?php
|
||||
endif;
|
||||
|
|
|
@ -7,28 +7,29 @@
|
|||
*/
|
||||
|
||||
// don't load directly
|
||||
if ( !defined('ABSPATH') )
|
||||
die('-1');
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
die( '-1' );
|
||||
}
|
||||
|
||||
if ( ! empty($link_id) ) {
|
||||
$heading = sprintf( __( '<a href="%s">Links</a> / Edit Link' ), 'link-manager.php' );
|
||||
$submit_text = __('Update Link');
|
||||
$form_name = 'editlink';
|
||||
if ( ! empty( $link_id ) ) {
|
||||
$heading = sprintf( __( '<a href="%s">Links</a> / Edit Link' ), 'link-manager.php' );
|
||||
$submit_text = __( 'Update Link' );
|
||||
$form_name = 'editlink';
|
||||
$nonce_action = 'update-bookmark_' . $link_id;
|
||||
} else {
|
||||
$heading = sprintf( __( '<a href="%s">Links</a> / Add New Link' ), 'link-manager.php' );
|
||||
$submit_text = __('Add Link');
|
||||
$form_name = 'addlink';
|
||||
$heading = sprintf( __( '<a href="%s">Links</a> / Add New Link' ), 'link-manager.php' );
|
||||
$submit_text = __( 'Add Link' );
|
||||
$form_name = 'addlink';
|
||||
$nonce_action = 'add-bookmark';
|
||||
}
|
||||
|
||||
require_once( ABSPATH . 'wp-admin/includes/meta-boxes.php' );
|
||||
|
||||
add_meta_box('linksubmitdiv', __('Save'), 'link_submit_meta_box', null, 'side', 'core');
|
||||
add_meta_box('linkcategorydiv', __('Categories'), 'link_categories_meta_box', null, 'normal', 'core');
|
||||
add_meta_box('linktargetdiv', __('Target'), 'link_target_meta_box', null, 'normal', 'core');
|
||||
add_meta_box('linkxfndiv', __('Link Relationship (XFN)'), 'link_xfn_meta_box', null, 'normal', 'core');
|
||||
add_meta_box('linkadvanceddiv', __('Advanced'), 'link_advanced_meta_box', null, 'normal', 'core');
|
||||
add_meta_box( 'linksubmitdiv', __( 'Save' ), 'link_submit_meta_box', null, 'side', 'core' );
|
||||
add_meta_box( 'linkcategorydiv', __( 'Categories' ), 'link_categories_meta_box', null, 'normal', 'core' );
|
||||
add_meta_box( 'linktargetdiv', __( 'Target' ), 'link_target_meta_box', null, 'normal', 'core' );
|
||||
add_meta_box( 'linkxfndiv', __( 'Link Relationship (XFN)' ), 'link_xfn_meta_box', null, 'normal', 'core' );
|
||||
add_meta_box( 'linkadvanceddiv', __( 'Advanced' ), 'link_advanced_meta_box', null, 'normal', 'core' );
|
||||
|
||||
/** This action is documented in wp-admin/edit-form-advanced.php */
|
||||
do_action( 'add_meta_boxes', 'link', $link );
|
||||
|
@ -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(
|
||||
'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’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’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>'
|
||||
) );
|
||||
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’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’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>',
|
||||
)
|
||||
);
|
||||
|
||||
get_current_screen()->set_help_sidebar(
|
||||
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
|
||||
|
@ -70,16 +78,18 @@ 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>
|
||||
|
||||
<hr class="wp-header-end">
|
||||
|
||||
<?php if ( isset( $_GET['added'] ) ) : ?>
|
||||
<div id="message" class="updated notice is-dismissible"><p><?php _e('Link added.'); ?></p></div>
|
||||
<div id="message" class="updated notice is-dismissible"><p><?php _e( 'Link added.' ); ?></p></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<form name="<?php echo esc_attr( $form_name ); ?>" id="<?php echo esc_attr( $form_name ); ?>" method="post" action="link.php">
|
||||
|
@ -90,33 +100,34 @@ 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>
|
||||
<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>
|
||||
</div>
|
||||
</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> — don’t forget the <code>http://</code>'); ?></p>
|
||||
<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> — don’t forget the <code>http://</code>' ); ?></p>
|
||||
</div>
|
||||
</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>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- /post-body-content -->
|
||||
|
@ -133,19 +144,20 @@ $side_meta_boxes = do_meta_boxes( 'link', 'side', $link );
|
|||
<div id="postbox-container-2" class="postbox-container">
|
||||
<?php
|
||||
|
||||
do_meta_boxes(null, 'normal', $link);
|
||||
do_meta_boxes( null, 'normal', $link );
|
||||
|
||||
do_meta_boxes(null, 'advanced', $link);
|
||||
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 ?>" />
|
||||
<?php else: ?>
|
||||
<input type="hidden" name="cat_id" value="<?php echo (int) $cat_id; ?>" />
|
||||
<?php else : ?>
|
||||
<input type="hidden" name="action" value="add" />
|
||||
<?php endif; ?>
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
// Back compat hooks
|
||||
if ( 'category' == $taxonomy ) {
|
||||
/**
|
||||
* Fires before the Edit Category form.
|
||||
* Fires before the Edit Category form.
|
||||
*
|
||||
* @since 2.1.0
|
||||
* @deprecated 3.0.0 Use {$taxonomy}_pre_edit_form instead.
|
||||
|
@ -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
|
||||
echo esc_html( $tax->labels->back_to_items );
|
||||
?></a></p>
|
||||
<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>
|
||||
<?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 );
|
||||
|
@ -123,9 +127,9 @@ if ( isset( $tag->name ) ) {
|
|||
<tr class="form-field form-required term-name-wrap">
|
||||
<th scope="row"><label for="name"><?php _ex( 'Name', 'term name' ); ?></label></th>
|
||||
<td><input name="name" id="name" type="text" value="<?php echo $tag_name_value; ?>" size="40" aria-required="true" />
|
||||
<p class="description"><?php _e('The name is how it appears on your site.'); ?></p></td>
|
||||
<p class="description"><?php _e( 'The name is how it appears on your site.' ); ?></p></td>
|
||||
</tr>
|
||||
<?php if ( !global_terms_enabled() ) { ?>
|
||||
<?php if ( ! global_terms_enabled() ) { ?>
|
||||
<tr class="form-field term-slug-wrap">
|
||||
<th scope="row"><label for="slug"><?php _e( 'Slug' ); ?></label></th>
|
||||
<?php
|
||||
|
@ -145,10 +149,10 @@ if ( isset( $tag->name ) ) {
|
|||
$slug = isset( $tag->slug ) ? apply_filters( 'editable_slug', $tag->slug, $tag ) : '';
|
||||
?>
|
||||
<td><input name="slug" id="slug" type="text" value="<?php echo esc_attr( $slug ); ?>" size="40" />
|
||||
<p class="description"><?php _e('The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.'); ?></p></td>
|
||||
<p class="description"><?php _e( 'The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.' ); ?></p></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<?php if ( is_taxonomy_hierarchical($taxonomy) ) : ?>
|
||||
<?php if ( is_taxonomy_hierarchical( $taxonomy ) ) : ?>
|
||||
<tr class="form-field term-parent-wrap">
|
||||
<th scope="row"><label for="parent"><?php echo esc_html( $tax->labels->parent_item ); ?></label></th>
|
||||
<td>
|
||||
|
@ -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 : ?>
|
||||
|
@ -179,7 +184,7 @@ if ( isset( $tag->name ) ) {
|
|||
<tr class="form-field term-description-wrap">
|
||||
<th scope="row"><label for="description"><?php _e( 'Description' ); ?></label></th>
|
||||
<td><textarea name="description" id="description" rows="5" cols="50" class="large-text"><?php echo $tag->description; // textarea_escaped ?></textarea>
|
||||
<p class="description"><?php _e('The description is not prominent by default; however, some themes may show it.'); ?></p></td>
|
||||
<p class="description"><?php _e( 'The description is not prominent by default; however, some themes may show it.' ); ?></p></td>
|
||||
</tr>
|
||||
<?php
|
||||
// Back compat hooks
|
||||
|
@ -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;
|
||||
|
|
|
@ -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.' ) );
|
||||
|
@ -36,149 +38,168 @@ if ( ! current_user_can( $tax->cap->manage_terms ) ) {
|
|||
*/
|
||||
global $post_type;
|
||||
|
||||
$wp_list_table = _get_list_table('WP_Terms_List_Table');
|
||||
$pagenum = $wp_list_table->get_pagenum();
|
||||
$wp_list_table = _get_list_table( 'WP_Terms_List_Table' );
|
||||
$pagenum = $wp_list_table->get_pagenum();
|
||||
|
||||
$title = $tax->labels->name;
|
||||
|
||||
if ( 'post' != $post_type ) {
|
||||
$parent_file = ( 'attachment' == $post_type ) ? 'upload.php' : "edit.php?post_type=$post_type";
|
||||
$parent_file = ( 'attachment' == $post_type ) ? 'upload.php' : "edit.php?post_type=$post_type";
|
||||
$submenu_file = "edit-tags.php?taxonomy=$taxonomy&post_type=$post_type";
|
||||
} elseif ( 'link_category' == $tax->name ) {
|
||||
$parent_file = 'link-manager.php';
|
||||
$parent_file = 'link-manager.php';
|
||||
$submenu_file = 'edit-tags.php?taxonomy=link_category';
|
||||
} else {
|
||||
$parent_file = 'edit.php';
|
||||
$parent_file = 'edit.php';
|
||||
$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(
|
||||
'heading_pagination' => $tax->labels->items_list_navigation,
|
||||
'heading_list' => $tax->labels->items_list,
|
||||
) );
|
||||
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();
|
||||
$referer = wp_get_referer();
|
||||
if ( ! $referer ) { // For POST requests.
|
||||
$referer = wp_unslash( $_SERVER['REQUEST_URI'] );
|
||||
}
|
||||
$referer = remove_query_arg( array( '_wp_http_referer', '_wpnonce', 'error', 'message', 'paged' ), $referer );
|
||||
switch ( $wp_list_table->current_action() ) {
|
||||
|
||||
case 'add-tag':
|
||||
check_admin_referer( 'add-tag', '_wpnonce_add-tag' );
|
||||
case 'add-tag':
|
||||
check_admin_referer( 'add-tag', '_wpnonce_add-tag' );
|
||||
|
||||
if ( ! current_user_can( $tax->cap->edit_terms ) ) {
|
||||
wp_die(
|
||||
'<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' .
|
||||
'<p>' . __( 'Sorry, you are not allowed to create terms in this taxonomy.' ) . '</p>',
|
||||
403
|
||||
);
|
||||
}
|
||||
if ( ! current_user_can( $tax->cap->edit_terms ) ) {
|
||||
wp_die(
|
||||
'<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' .
|
||||
'<p>' . __( 'Sorry, you are not allowed to create terms in this taxonomy.' ) . '</p>',
|
||||
403
|
||||
);
|
||||
}
|
||||
|
||||
$ret = wp_insert_term( $_POST['tag-name'], $taxonomy, $_POST );
|
||||
if ( $ret && !is_wp_error( $ret ) )
|
||||
$location = add_query_arg( 'message', 1, $referer );
|
||||
else
|
||||
$location = add_query_arg( array( 'error' => true, 'message' => 4 ), $referer );
|
||||
$ret = wp_insert_term( $_POST['tag-name'], $taxonomy, $_POST );
|
||||
if ( $ret && ! is_wp_error( $ret ) ) {
|
||||
$location = add_query_arg( 'message', 1, $referer );
|
||||
} else {
|
||||
$location = add_query_arg(
|
||||
array(
|
||||
'error' => true,
|
||||
'message' => 4,
|
||||
), $referer
|
||||
);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
if ( ! isset( $_REQUEST['tag_ID'] ) ) {
|
||||
break;
|
||||
}
|
||||
|
||||
$tag_ID = (int) $_REQUEST['tag_ID'];
|
||||
check_admin_referer( 'delete-tag_' . $tag_ID );
|
||||
case 'delete':
|
||||
if ( ! isset( $_REQUEST['tag_ID'] ) ) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ( ! current_user_can( 'delete_term', $tag_ID ) ) {
|
||||
wp_die(
|
||||
'<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' .
|
||||
'<p>' . __( 'Sorry, you are not allowed to delete this item.' ) . '</p>',
|
||||
403
|
||||
);
|
||||
}
|
||||
$tag_ID = (int) $_REQUEST['tag_ID'];
|
||||
check_admin_referer( 'delete-tag_' . $tag_ID );
|
||||
|
||||
wp_delete_term( $tag_ID, $taxonomy );
|
||||
if ( ! current_user_can( 'delete_term', $tag_ID ) ) {
|
||||
wp_die(
|
||||
'<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' .
|
||||
'<p>' . __( 'Sorry, you are not allowed to delete this item.' ) . '</p>',
|
||||
403
|
||||
);
|
||||
}
|
||||
|
||||
$location = add_query_arg( 'message', 2, $referer );
|
||||
|
||||
// When deleting a term, prevent the action from redirecting back to a term that no longer exists.
|
||||
$location = remove_query_arg( array( 'tag_ID', 'action' ), $location );
|
||||
|
||||
break;
|
||||
|
||||
case 'bulk-delete':
|
||||
check_admin_referer( 'bulk-tags' );
|
||||
|
||||
if ( ! current_user_can( $tax->cap->delete_terms ) ) {
|
||||
wp_die(
|
||||
'<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' .
|
||||
'<p>' . __( 'Sorry, you are not allowed to delete these items.' ) . '</p>',
|
||||
403
|
||||
);
|
||||
}
|
||||
|
||||
$tags = (array) $_REQUEST['delete_tags'];
|
||||
foreach ( $tags as $tag_ID ) {
|
||||
wp_delete_term( $tag_ID, $taxonomy );
|
||||
}
|
||||
|
||||
$location = add_query_arg( 'message', 6, $referer );
|
||||
$location = add_query_arg( 'message', 2, $referer );
|
||||
|
||||
break;
|
||||
// When deleting a term, prevent the action from redirecting back to a term that no longer exists.
|
||||
$location = remove_query_arg( array( 'tag_ID', 'action' ), $location );
|
||||
|
||||
case 'edit':
|
||||
if ( ! isset( $_REQUEST['tag_ID'] ) ) {
|
||||
break;
|
||||
}
|
||||
|
||||
$term_id = (int) $_REQUEST['tag_ID'];
|
||||
$term = get_term( $term_id );
|
||||
case 'bulk-delete':
|
||||
check_admin_referer( 'bulk-tags' );
|
||||
|
||||
if ( ! $term instanceof WP_Term ) {
|
||||
wp_die( __( 'You attempted to edit an item that doesn’t exist. Perhaps it was deleted?' ) );
|
||||
}
|
||||
if ( ! current_user_can( $tax->cap->delete_terms ) ) {
|
||||
wp_die(
|
||||
'<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' .
|
||||
'<p>' . __( 'Sorry, you are not allowed to delete these items.' ) . '</p>',
|
||||
403
|
||||
);
|
||||
}
|
||||
|
||||
wp_redirect( esc_url_raw( get_edit_term_link( $term_id, $taxonomy, $post_type ) ) );
|
||||
exit;
|
||||
$tags = (array) $_REQUEST['delete_tags'];
|
||||
foreach ( $tags as $tag_ID ) {
|
||||
wp_delete_term( $tag_ID, $taxonomy );
|
||||
}
|
||||
|
||||
case 'editedtag':
|
||||
$tag_ID = (int) $_POST['tag_ID'];
|
||||
check_admin_referer( 'update-tag_' . $tag_ID );
|
||||
$location = add_query_arg( 'message', 6, $referer );
|
||||
|
||||
if ( ! current_user_can( 'edit_term', $tag_ID ) ) {
|
||||
wp_die(
|
||||
'<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' .
|
||||
'<p>' . __( 'Sorry, you are not allowed to edit this item.' ) . '</p>',
|
||||
403
|
||||
);
|
||||
}
|
||||
|
||||
$tag = get_term( $tag_ID, $taxonomy );
|
||||
if ( ! $tag )
|
||||
wp_die( __( 'You attempted to edit an item that doesn’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 );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if ( ! $wp_list_table->current_action() || ! isset( $_REQUEST['delete_tags'] ) ) {
|
||||
break;
|
||||
}
|
||||
check_admin_referer( 'bulk-tags' );
|
||||
$tags = (array) $_REQUEST['delete_tags'];
|
||||
/** This action is documented in wp-admin/edit-comments.php */
|
||||
$location = apply_filters( 'handle_bulk_actions-' . get_current_screen()->id, $location, $wp_list_table->current_action(), $tags );
|
||||
break;
|
||||
|
||||
case 'edit':
|
||||
if ( ! isset( $_REQUEST['tag_ID'] ) ) {
|
||||
break;
|
||||
}
|
||||
|
||||
$term_id = (int) $_REQUEST['tag_ID'];
|
||||
$term = get_term( $term_id );
|
||||
|
||||
if ( ! $term instanceof WP_Term ) {
|
||||
wp_die( __( 'You attempted to edit an item that doesn’t exist. Perhaps it was deleted?' ) );
|
||||
}
|
||||
|
||||
wp_redirect( esc_url_raw( get_edit_term_link( $term_id, $taxonomy, $post_type ) ) );
|
||||
exit;
|
||||
|
||||
case 'editedtag':
|
||||
$tag_ID = (int) $_POST['tag_ID'];
|
||||
check_admin_referer( 'update-tag_' . $tag_ID );
|
||||
|
||||
if ( ! current_user_can( 'edit_term', $tag_ID ) ) {
|
||||
wp_die(
|
||||
'<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' .
|
||||
'<p>' . __( 'Sorry, you are not allowed to edit this item.' ) . '</p>',
|
||||
403
|
||||
);
|
||||
}
|
||||
|
||||
$tag = get_term( $tag_ID, $taxonomy );
|
||||
if ( ! $tag ) {
|
||||
wp_die( __( 'You attempted to edit an item that doesn’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
|
||||
);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if ( ! $wp_list_table->current_action() || ! isset( $_REQUEST['delete_tags'] ) ) {
|
||||
break;
|
||||
}
|
||||
check_admin_referer( 'bulk-tags' );
|
||||
$tags = (array) $_REQUEST['delete_tags'];
|
||||
/** This action is documented in wp-admin/edit-comments.php */
|
||||
$location = apply_filters( 'handle_bulk_actions-' . get_current_screen()->id, $location, $wp_list_table->current_action(), $tags );
|
||||
break;
|
||||
}
|
||||
|
||||
if ( ! $location && ! empty( $_REQUEST['_wp_http_referer'] ) ) {
|
||||
|
@ -210,66 +231,77 @@ if ( $pagenum > $total_pages && $total_pages > 0 ) {
|
|||
exit;
|
||||
}
|
||||
|
||||
wp_enqueue_script('admin-tags');
|
||||
if ( current_user_can($tax->cap->edit_terms) )
|
||||
wp_enqueue_script('inline-edit-tax');
|
||||
wp_enqueue_script( 'admin-tags' );
|
||||
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 )
|
||||
$help = '<p>' . sprintf(__( 'You can use categories to define sections of your site and group related posts. The default category is “Uncategorized” until you change it in your <a href="%s">writing settings</a>.' ) , 'options-writing.php' ) . '</p>';
|
||||
elseif ( 'link_category' == $taxonomy )
|
||||
if ( 'category' == $taxonomy || 'link_category' == $taxonomy || 'post_tag' == $taxonomy ) {
|
||||
$help = '';
|
||||
if ( 'category' == $taxonomy ) {
|
||||
$help = '<p>' . sprintf( __( 'You can use categories to define sections of your site and group related posts. The default category is “Uncategorized” until you change it in your <a href="%s">writing settings</a>.' ), 'options-writing.php' ) . '</p>';
|
||||
} 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’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
|
||||
$help .='<p>' . __( 'What’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>';
|
||||
} else {
|
||||
$help .= '<p>' . __( 'What’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(
|
||||
'id' => 'overview',
|
||||
'title' => __('Overview'),
|
||||
'content' => $help,
|
||||
) );
|
||||
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’ll fill in the following fields:' ) . '</p>';
|
||||
else
|
||||
} else {
|
||||
$help = '<p>' . __( 'When adding a new tag on this screen, you’ll fill in the following fields:' ) . '</p>';
|
||||
}
|
||||
|
||||
$help .= '<ul>' .
|
||||
'<li>' . __( '<strong>Name</strong> — The name is how it appears on your site.' ) . '</li>';
|
||||
|
||||
if ( ! global_terms_enabled() )
|
||||
if ( ! global_terms_enabled() ) {
|
||||
$help .= '<li>' . __( '<strong>Slug</strong> — The “slug” 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> — 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> — 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(
|
||||
'id' => 'adding-terms',
|
||||
'title' => 'category' == $taxonomy ? __( 'Adding Categories' ) : __( 'Adding Tags' ),
|
||||
'content' => $help,
|
||||
) );
|
||||
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>';
|
||||
$help .= '<p>' . __( '<a href="https://wordpress.org/support/">Support Forums</a>' ) . '</p>';
|
||||
|
||||
get_current_screen()->set_help_sidebar( $help );
|
||||
|
||||
|
@ -305,13 +337,15 @@ 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">
|
||||
<input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy); ?>" />
|
||||
<input type="hidden" name="post_type" value="<?php echo esc_attr($post_type); ?>" />
|
||||
<input type="hidden" name="taxonomy" value="<?php echo esc_attr( $taxonomy ); ?>" />
|
||||
<input type="hidden" name="post_type" value="<?php echo esc_attr( $post_type ); ?>" />
|
||||
|
||||
<?php $wp_list_table->search_box( $tax->labels->search_items, 'tag' ); ?>
|
||||
|
||||
|
@ -324,10 +358,10 @@ endif; ?>
|
|||
|
||||
<?php
|
||||
|
||||
if ( current_user_can($tax->cap->edit_terms) ) {
|
||||
if ( current_user_can( $tax->cap->edit_terms ) ) {
|
||||
if ( 'category' == $taxonomy ) {
|
||||
/**
|
||||
* Fires before the Add Category form.
|
||||
* Fires before the Add Category form.
|
||||
*
|
||||
* @since 2.1.0
|
||||
* @deprecated 3.0.0 Use {$taxonomy}_pre_add_form instead.
|
||||
|
@ -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,26 +415,27 @@ 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); ?>" />
|
||||
<input type="hidden" name="post_type" value="<?php echo esc_attr($post_type); ?>" />
|
||||
<?php wp_nonce_field('add-tag', '_wpnonce_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 ); ?>" />
|
||||
<input type="hidden" name="post_type" value="<?php echo esc_attr( $post_type ); ?>" />
|
||||
<?php wp_nonce_field( 'add-tag', '_wpnonce_add-tag' ); ?>
|
||||
|
||||
<div class="form-field form-required term-name-wrap">
|
||||
<label for="tag-name"><?php _ex( 'Name', 'term name' ); ?></label>
|
||||
<input name="tag-name" id="tag-name" type="text" value="" size="40" aria-required="true" />
|
||||
<p><?php _e('The name is how it appears on your site.'); ?></p>
|
||||
<p><?php _e( 'The name is how it appears on your site.' ); ?></p>
|
||||
</div>
|
||||
<?php if ( ! global_terms_enabled() ) : ?>
|
||||
<div class="form-field term-slug-wrap">
|
||||
<label for="tag-slug"><?php _e( 'Slug' ); ?></label>
|
||||
<input name="slug" id="tag-slug" type="text" value="" size="40" />
|
||||
<p><?php _e('The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.'); ?></p>
|
||||
<p><?php _e( 'The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.' ); ?></p>
|
||||
</div>
|
||||
<?php endif; // global_terms_enabled() ?>
|
||||
<?php if ( is_taxonomy_hierarchical($taxonomy) ) : ?>
|
||||
<?php if ( is_taxonomy_hierarchical( $taxonomy ) ) : ?>
|
||||
<div class="form-field term-parent-wrap">
|
||||
<label for="parent"><?php echo esc_html( $tax->labels->parent_item ); ?></label>
|
||||
<?php
|
||||
|
@ -448,7 +484,7 @@ do_action( "{$taxonomy}_term_new_form_tag" );
|
|||
<div class="form-field term-description-wrap">
|
||||
<label for="tag-description"><?php _e( 'Description' ); ?></label>
|
||||
<textarea name="description" id="tag-description" rows="5" cols="40"></textarea>
|
||||
<p><?php _e('The description is not prominent by default; however, some themes may show it.'); ?></p>
|
||||
<p><?php _e( 'The description is not prominent by default; however, some themes may show it.' ); ?></p>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
@ -547,19 +583,20 @@ do_action( "{$taxonomy}_add_form", $taxonomy );
|
|||
/* translators: %s: default category */
|
||||
__( 'Deleting a category does not delete the posts in that category. Instead, posts that were only assigned to the deleted category are set to the category %s.' ),
|
||||
/** This filter is documented in wp-includes/category-template.php */
|
||||
'<strong>' . apply_filters( 'the_category', get_cat_name( get_option( 'default_category') ), '', '' ) . '</strong>'
|
||||
'<strong>' . apply_filters( 'the_category', get_cat_name( get_option( 'default_category' ) ), '', '' ) . '</strong>'
|
||||
);
|
||||
?>
|
||||
</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>
|
||||
<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.
|
||||
|
|
|
@ -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.' ) );
|
||||
|
@ -28,11 +29,12 @@ if ( 'attachment' === $typenow ) {
|
|||
*/
|
||||
global $post_type, $post_type_object;
|
||||
|
||||
$post_type = $typenow;
|
||||
$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(
|
||||
|
@ -42,8 +44,8 @@ if ( ! current_user_can( $post_type_object->cap->edit_posts ) ) {
|
|||
);
|
||||
}
|
||||
|
||||
$wp_list_table = _get_list_table('WP_Posts_List_Table');
|
||||
$pagenum = $wp_list_table->get_pagenum();
|
||||
$wp_list_table = _get_list_table( 'WP_Posts_List_Table' );
|
||||
$pagenum = $wp_list_table->get_pagenum();
|
||||
|
||||
// Back-compat for viewing comments of an entry
|
||||
foreach ( array( 'p', 'attachment_id', 'page_id' ) as $_redirect ) {
|
||||
|
@ -55,30 +57,32 @@ foreach ( array( 'p', 'attachment_id', 'page_id' ) as $_redirect ) {
|
|||
unset( $_redirect );
|
||||
|
||||
if ( 'post' != $post_type ) {
|
||||
$parent_file = "edit.php?post_type=$post_type";
|
||||
$submenu_file = "edit.php?post_type=$post_type";
|
||||
$parent_file = "edit.php?post_type=$post_type";
|
||||
$submenu_file = "edit.php?post_type=$post_type";
|
||||
$post_new_file = "post-new.php?post_type=$post_type";
|
||||
} else {
|
||||
$parent_file = 'edit.php';
|
||||
$submenu_file = 'edit.php';
|
||||
$parent_file = 'edit.php';
|
||||
$submenu_file = 'edit.php';
|
||||
$post_new_file = 'post-new.php';
|
||||
}
|
||||
|
||||
$doaction = $wp_list_table->current_action();
|
||||
|
||||
if ( $doaction ) {
|
||||
check_admin_referer('bulk-posts');
|
||||
check_admin_referer( 'bulk-posts' );
|
||||
|
||||
$sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'locked', 'ids'), wp_get_referer() );
|
||||
if ( ! $sendback )
|
||||
$sendback = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'locked', 'ids' ), wp_get_referer() );
|
||||
if ( ! $sendback ) {
|
||||
$sendback = admin_url( $parent_file );
|
||||
}
|
||||
$sendback = add_query_arg( 'paged', $pagenum, $sendback );
|
||||
if ( strpos($sendback, 'post.php') !== false )
|
||||
$sendback = admin_url($post_new_file);
|
||||
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).
|
||||
$post_status = preg_replace('/[^a-z0-9_-]+/i', '', $_REQUEST['post_status']);
|
||||
$post_status = preg_replace( '/[^a-z0-9_-]+/i', '', $_REQUEST['post_status'] );
|
||||
// Validate the post status exists.
|
||||
if ( get_post_status_object( $post_status ) ) {
|
||||
$post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type=%s AND post_status = %s", $post_type, $post_status ) );
|
||||
|
@ -88,11 +92,11 @@ if ( $doaction ) {
|
|||
$post_ids = $_REQUEST['media'];
|
||||
} elseif ( isset( $_REQUEST['ids'] ) ) {
|
||||
$post_ids = explode( ',', $_REQUEST['ids'] );
|
||||
} elseif ( !empty( $_REQUEST['post'] ) ) {
|
||||
$post_ids = array_map('intval', $_REQUEST['post']);
|
||||
} elseif ( ! empty( $_REQUEST['post'] ) ) {
|
||||
$post_ids = array_map( 'intval', $_REQUEST['post'] );
|
||||
}
|
||||
|
||||
if ( !isset( $post_ids ) ) {
|
||||
if ( ! isset( $post_ids ) ) {
|
||||
wp_redirect( $sendback );
|
||||
exit;
|
||||
}
|
||||
|
@ -102,63 +106,76 @@ if ( $doaction ) {
|
|||
$trashed = $locked = 0;
|
||||
|
||||
foreach ( (array) $post_ids as $post_id ) {
|
||||
if ( !current_user_can( 'delete_post', $post_id) )
|
||||
wp_die( __('Sorry, you are not allowed to move this item to the Trash.') );
|
||||
if ( ! 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) )
|
||||
wp_die( __('Error in moving to Trash.') );
|
||||
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) )
|
||||
wp_die( __('Sorry, you are not allowed to restore this item from the Trash.') );
|
||||
if ( ! current_user_can( 'delete_post', $post_id ) ) {
|
||||
wp_die( __( 'Sorry, you are not allowed to restore this item from the Trash.' ) );
|
||||
}
|
||||
|
||||
if ( !wp_untrash_post($post_id) )
|
||||
wp_die( __('Error in restoring from Trash.') );
|
||||
if ( ! wp_untrash_post( $post_id ) ) {
|
||||
wp_die( __( 'Error in restoring from Trash.' ) );
|
||||
}
|
||||
|
||||
$untrashed++;
|
||||
}
|
||||
$sendback = add_query_arg('untrashed', $untrashed, $sendback);
|
||||
$sendback = add_query_arg( 'untrashed', $untrashed, $sendback );
|
||||
break;
|
||||
case 'delete':
|
||||
$deleted = 0;
|
||||
foreach ( (array) $post_ids as $post_id ) {
|
||||
$post_del = get_post($post_id);
|
||||
$post_del = get_post( $post_id );
|
||||
|
||||
if ( !current_user_can( 'delete_post', $post_id ) )
|
||||
wp_die( __('Sorry, you are not allowed to delete this item.') );
|
||||
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) )
|
||||
wp_die( __('Error in deleting.') );
|
||||
if ( ! wp_delete_attachment( $post_id ) ) {
|
||||
wp_die( __( 'Error in deleting.' ) );
|
||||
}
|
||||
} else {
|
||||
if ( !wp_delete_post($post_id) )
|
||||
wp_die( __('Error in deleting.') );
|
||||
if ( ! wp_delete_post( $post_id ) ) {
|
||||
wp_die( __( 'Error in deleting.' ) );
|
||||
}
|
||||
}
|
||||
$deleted++;
|
||||
}
|
||||
$sendback = add_query_arg('deleted', $deleted, $sendback);
|
||||
$sendback = add_query_arg( 'deleted', $deleted, $sendback );
|
||||
break;
|
||||
case 'edit':
|
||||
if ( isset($_REQUEST['bulk_edit']) ) {
|
||||
$done = bulk_edit_posts($_REQUEST);
|
||||
if ( isset( $_REQUEST['bulk_edit'] ) ) {
|
||||
$done = bulk_edit_posts( $_REQUEST );
|
||||
|
||||
if ( is_array($done) ) {
|
||||
if ( is_array( $done ) ) {
|
||||
$done['updated'] = count( $done['updated'] );
|
||||
$done['skipped'] = count( $done['skipped'] );
|
||||
$done['locked'] = count( $done['locked'] );
|
||||
$sendback = add_query_arg( $done, $sendback );
|
||||
$done['locked'] = count( $done['locked'] );
|
||||
$sendback = add_query_arg( $done, $sendback );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -168,107 +185,126 @@ if ( $doaction ) {
|
|||
break;
|
||||
}
|
||||
|
||||
$sendback = remove_query_arg( array('action', 'action2', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view'), $sendback );
|
||||
$sendback = remove_query_arg( array( 'action', 'action2', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view' ), $sendback );
|
||||
|
||||
wp_redirect($sendback);
|
||||
wp_redirect( $sendback );
|
||||
exit();
|
||||
} elseif ( ! empty($_REQUEST['_wp_http_referer']) ) {
|
||||
wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), wp_unslash($_SERVER['REQUEST_URI']) ) );
|
||||
} elseif ( ! empty( $_REQUEST['_wp_http_referer'] ) ) {
|
||||
wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), wp_unslash( $_SERVER['REQUEST_URI'] ) ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
$wp_list_table->prepare_items();
|
||||
|
||||
wp_enqueue_script('inline-edit-post');
|
||||
wp_enqueue_script('heartbeat');
|
||||
wp_enqueue_script( 'inline-edit-post' );
|
||||
wp_enqueue_script( 'heartbeat' );
|
||||
|
||||
$title = $post_type_object->labels->name;
|
||||
|
||||
if ( 'post' == $post_type ) {
|
||||
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(
|
||||
'id' => 'screen-content',
|
||||
'title' => __('Screen Content'),
|
||||
'content' =>
|
||||
'<p>' . __('You can customize the display of this screen’s contents in a number of ways:') . '</p>' .
|
||||
'<ul>' .
|
||||
'<li>' . __('You can hide/display columns based on your needs and decide how many posts to list per screen using the Screen Options tab.') . '</li>' .
|
||||
'<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(
|
||||
'id' => 'action-links',
|
||||
'title' => __('Available Actions'),
|
||||
'content' =>
|
||||
'<p>' . __('Hovering over a row in the posts list will display action links that allow you to manage your post. You can perform the following actions:') . '</p>' .
|
||||
'<ul>' .
|
||||
'<li>' . __('<strong>Edit</strong> takes you to the editing screen for that post. You can also reach that screen by clicking on the post title.') . '</li>' .
|
||||
'<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’s status.') . '</li>' .
|
||||
'</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>'
|
||||
) );
|
||||
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(
|
||||
'id' => 'screen-content',
|
||||
'title' => __( 'Screen Content' ),
|
||||
'content' =>
|
||||
'<p>' . __( 'You can customize the display of this screen’s contents in a number of ways:' ) . '</p>' .
|
||||
'<ul>' .
|
||||
'<li>' . __( 'You can hide/display columns based on your needs and decide how many posts to list per screen using the Screen Options tab.' ) . '</li>' .
|
||||
'<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(
|
||||
'id' => 'action-links',
|
||||
'title' => __( 'Available Actions' ),
|
||||
'content' =>
|
||||
'<p>' . __( 'Hovering over a row in the posts list will display action links that allow you to manage your post. You can perform the following actions:' ) . '</p>' .
|
||||
'<ul>' .
|
||||
'<li>' . __( '<strong>Edit</strong> takes you to the editing screen for that post. You can also reach that screen by clicking on the post title.' ) . '</li>' .
|
||||
'<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’s status.' ) . '</li>' .
|
||||
'</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>',
|
||||
)
|
||||
);
|
||||
|
||||
get_current_screen()->set_help_sidebar(
|
||||
'<p><strong>' . __('For more information:') . '</strong></p>' .
|
||||
'<p>' . __('<a href="https://codex.wordpress.org/Posts_Screen">Documentation on Managing Posts</a>') . '</p>' .
|
||||
'<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>'
|
||||
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
|
||||
'<p>' . __( '<a href="https://codex.wordpress.org/Posts_Screen">Documentation on Managing Posts</a>' ) . '</p>' .
|
||||
'<p>' . __( '<a href="https://wordpress.org/support/">Support Forums</a>' ) . '</p>'
|
||||
);
|
||||
|
||||
} elseif ( 'page' == $post_type ) {
|
||||
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 “Parent” 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>'
|
||||
) );
|
||||
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 “Parent” 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>',
|
||||
)
|
||||
);
|
||||
|
||||
get_current_screen()->set_help_sidebar(
|
||||
'<p><strong>' . __('For more information:') . '</strong></p>' .
|
||||
'<p>' . __('<a href="https://codex.wordpress.org/Pages_Screen">Documentation on Managing Pages</a>') . '</p>' .
|
||||
'<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>'
|
||||
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
|
||||
'<p>' . __( '<a href="https://codex.wordpress.org/Pages_Screen">Documentation on Managing Pages</a>' ) . '</p>' .
|
||||
'<p>' . __( '<a href="https://wordpress.org/support/">Support Forums</a>' ) . '</p>'
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
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,
|
||||
) );
|
||||
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,
|
||||
'locked' => isset( $_REQUEST['locked'] ) ? absint( $_REQUEST['locked'] ) : 0,
|
||||
'deleted' => isset( $_REQUEST['deleted'] ) ? absint( $_REQUEST['deleted'] ) : 0,
|
||||
'trashed' => isset( $_REQUEST['trashed'] ) ? absint( $_REQUEST['trashed'] ) : 0,
|
||||
'updated' => isset( $_REQUEST['updated'] ) ? absint( $_REQUEST['updated'] ) : 0,
|
||||
'locked' => isset( $_REQUEST['locked'] ) ? absint( $_REQUEST['locked'] ) : 0,
|
||||
'deleted' => isset( $_REQUEST['deleted'] ) ? absint( $_REQUEST['deleted'] ) : 0,
|
||||
'trashed' => isset( $_REQUEST['trashed'] ) ? absint( $_REQUEST['trashed'] ) : 0,
|
||||
'untrashed' => isset( $_REQUEST['untrashed'] ) ? absint( $_REQUEST['untrashed'] ) : 0,
|
||||
);
|
||||
|
||||
$bulk_messages = array();
|
||||
$bulk_messages = array();
|
||||
$bulk_messages['post'] = array(
|
||||
'updated' => _n( '%s post updated.', '%s posts updated.', $bulk_counts['updated'] ),
|
||||
'locked' => ( 1 == $bulk_counts['locked'] ) ? __( '1 post not updated, somebody is editing it.' ) :
|
||||
|
@ -298,14 +334,16 @@ $bulk_messages['page'] = array(
|
|||
* @param array $bulk_counts Array of item counts for each message, used to build internationalized strings.
|
||||
*/
|
||||
$bulk_messages = apply_filters( 'bulk_post_updated_messages', $bulk_messages, $bulk_counts );
|
||||
$bulk_counts = array_filter( $bulk_counts );
|
||||
$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>';
|
||||
$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>';
|
||||
}
|
||||
}
|
||||
|
||||
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'] );
|
||||
|
@ -348,7 +388,7 @@ $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'locked', 'skipped', 'updated
|
|||
|
||||
<?php $wp_list_table->search_box( $post_type_object->labels->search_items, 'post' ); ?>
|
||||
|
||||
<input type="hidden" name="post_status" class="post_status_page" value="<?php echo !empty($_REQUEST['post_status']) ? esc_attr($_REQUEST['post_status']) : 'all'; ?>" />
|
||||
<input type="hidden" name="post_status" class="post_status_page" value="<?php echo ! empty( $_REQUEST['post_status'] ) ? esc_attr( $_REQUEST['post_status'] ) : 'all'; ?>" />
|
||||
<input type="hidden" name="post_type" class="post_type_page" value="<?php echo $post_type; ?>" />
|
||||
|
||||
<?php if ( ! empty( $_REQUEST['author'] ) ) { ?>
|
||||
|
@ -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>
|
||||
|
|
|
@ -9,12 +9,13 @@
|
|||
/** Load WordPress Bootstrap */
|
||||
require_once( dirname( __FILE__ ) . '/admin.php' );
|
||||
|
||||
if ( !current_user_can('export') )
|
||||
wp_die(__('Sorry, you are not allowed to export the content of this site.'));
|
||||
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' );
|
||||
$title = __('Export');
|
||||
$title = __( 'Export' );
|
||||
|
||||
/**
|
||||
* Display JavaScript on the page.
|
||||
|
@ -25,34 +26,36 @@ function export_add_js() {
|
|||
?>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($){
|
||||
var form = $('#export-filters'),
|
||||
filters = form.find('.export-filters');
|
||||
filters.hide();
|
||||
form.find('input:radio').change(function() {
|
||||
var form = $('#export-filters'),
|
||||
filters = form.find('.export-filters');
|
||||
filters.hide();
|
||||
form.find('input:radio').change(function() {
|
||||
filters.slideUp('fast');
|
||||
switch ( $(this).val() ) {
|
||||
case 'attachment': $('#attachment-filters').slideDown(); break;
|
||||
case 'posts': $('#post-filters').slideDown(); break;
|
||||
case 'pages': $('#page-filters').slideDown(); break;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
add_action( 'admin_head', 'export_add_js' );
|
||||
|
||||
get_current_screen()->add_help_tab( array(
|
||||
'id' => 'overview',
|
||||
'title' => __('Overview'),
|
||||
'content' => '<p>' . __('You can export a file of your site’s content in order to import it into another installation or platform. The export file will be an XML file format called WXR. Posts, pages, comments, custom fields, categories, and tags can be included. You can choose for the WXR file to include only certain posts or pages by setting the dropdown filters to limit the export by category, author, date range by month, or publishing status.') . '</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()->add_help_tab(
|
||||
array(
|
||||
'id' => 'overview',
|
||||
'title' => __( 'Overview' ),
|
||||
'content' => '<p>' . __( 'You can export a file of your site’s content in order to import it into another installation or platform. The export file will be an XML file format called WXR. Posts, pages, comments, custom fields, categories, and tags can be included. You can choose for the WXR file to include only certain posts or pages by setting the dropdown filters to limit the export by category, author, date range by month, or publishing status.' ) . '</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>' .
|
||||
'<p>' . __('<a href="https://codex.wordpress.org/Tools_Export_Screen">Documentation on Export</a>') . '</p>' .
|
||||
'<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>'
|
||||
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
|
||||
'<p>' . __( '<a href="https://codex.wordpress.org/Tools_Export_Screen">Documentation on Export</a>' ) . '</p>' .
|
||||
'<p>' . __( '<a href="https://wordpress.org/support/">Support Forums</a>' ) . '</p>'
|
||||
);
|
||||
|
||||
// If the 'download' URL parameter is set, a WXR export file is baked and returned.
|
||||
|
@ -64,41 +67,45 @@ 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'];
|
||||
$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'];
|
||||
$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';
|
||||
|
||||
if ( $_GET['attachment_start_date'] || $_GET['attachment_end_date'] ) {
|
||||
$args['start_date'] = $_GET['attachment_start_date'];
|
||||
$args['end_date'] = $_GET['attachment_end_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>';
|
||||
|
@ -154,9 +167,9 @@ function export_date_options( $post_type = 'post' ) {
|
|||
<div class="wrap">
|
||||
<h1><?php echo esc_html( $title ); ?></h1>
|
||||
|
||||
<p><?php _e('When you click the button below WordPress will create an XML file for you to save to your computer.'); ?></p>
|
||||
<p><?php _e('This format, which we call WordPress eXtended RSS or WXR, will contain your posts, pages, comments, custom fields, categories, and tags.'); ?></p>
|
||||
<p><?php _e('Once you’ve saved the download file, you can use the Import function in another WordPress installation to import the content from this site.'); ?></p>
|
||||
<p><?php _e( 'When you click the button below WordPress will create an XML file for you to save to your computer.' ); ?></p>
|
||||
<p><?php _e( 'This format, which we call WordPress eXtended RSS or WXR, will contain your posts, pages, comments, custom fields, categories, and tags.' ); ?></p>
|
||||
<p><?php _e( 'Once you’ve saved the download file, you can use the Import function in another WordPress installation to import the content from this site.' ); ?></p>
|
||||
|
||||
<h2><?php _e( 'Choose what to export' ); ?></h2>
|
||||
<form method="get" id="export-filters">
|
||||
|
@ -170,20 +183,23 @@ function export_date_options( $post_type = 'post' ) {
|
|||
<ul id="post-filters" class="export-filters">
|
||||
<li>
|
||||
<label><span class="label-responsive"><?php _e( 'Categories:' ); ?></span>
|
||||
<?php wp_dropdown_categories( array( 'show_option_all' => __('All') ) ); ?>
|
||||
<?php wp_dropdown_categories( array( 'show_option_all' => __( 'All' ) ) ); ?>
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<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(
|
||||
'include' => $authors,
|
||||
'name' => 'post_author',
|
||||
'multi' => true,
|
||||
'show_option_all' => __( 'All' ),
|
||||
'show' => 'display_name_with_login',
|
||||
) ); ?>
|
||||
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(
|
||||
'include' => $authors,
|
||||
'name' => 'page_author',
|
||||
'multi' => true,
|
||||
'show_option_all' => __( 'All' ),
|
||||
'show' => 'display_name_with_login',
|
||||
) ); ?>
|
||||
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; ?>
|
||||
|
||||
|
@ -287,7 +315,7 @@ function export_date_options( $post_type = 'post' ) {
|
|||
do_action( 'export_filters' );
|
||||
?>
|
||||
|
||||
<?php submit_button( __('Download Export File') ); ?>
|
||||
<?php submit_button( __( 'Download Export File' ) ); ?>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -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’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/' );
|
||||
$themes_url = current_user_can( 'switch_themes' ) ? admin_url( 'themes.php' ) : __( 'https://wordpress.org/themes/' );
|
||||
|
||||
printf( __( 'Every plugin and theme in WordPress.org’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’s GPL</a> first. If they don’t respect the WordPress license, we don’t recommend them.' ), $plugins_url, $themes_url, 'https://wordpress.org/about/license/' ); ?></p>
|
||||
printf( __( 'Every plugin and theme in WordPress.org’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’s GPL</a> first. If they don’t respect the WordPress license, we don’t recommend them.' ), $plugins_url, $themes_url, 'https://wordpress.org/about/license/' );
|
||||
?>
|
||||
</p>
|
||||
|
||||
<p><?php _e( 'Don’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>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* @subpackage Administration
|
||||
*/
|
||||
|
||||
define('WP_LOAD_IMPORTERS', true);
|
||||
define( 'WP_LOAD_IMPORTERS', true );
|
||||
|
||||
/** Load WordPress Bootstrap */
|
||||
require_once( dirname( __FILE__ ) . '/admin.php' );
|
||||
|
@ -15,26 +15,28 @@ if ( ! current_user_can( 'import' ) ) {
|
|||
wp_die( __( 'Sorry, you are not allowed to import content.' ) );
|
||||
}
|
||||
|
||||
$title = __('Import');
|
||||
$title = __( 'Import' );
|
||||
|
||||
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()->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>' .
|
||||
'<p>' . __('<a href="https://codex.wordpress.org/Tools_Import_Screen">Documentation on Import</a>') . '</p>' .
|
||||
'<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>'
|
||||
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
|
||||
'<p>' . __( '<a href="https://codex.wordpress.org/Tools_Import_Screen">Documentation on Import</a>' ) . '</p>' .
|
||||
'<p>' . __( '<a href="https://wordpress.org/support/">Support Forums</a>' ) . '</p>'
|
||||
);
|
||||
|
||||
if ( current_user_can( 'install_plugins' ) ) {
|
||||
// List of popular importer plugins from the WordPress.org API.
|
||||
$popular_importers = wp_get_popular_importers();
|
||||
} else {
|
||||
$popular_importers = array();
|
||||
$popular_importers = array();
|
||||
}
|
||||
|
||||
// Detect and redirect invalid importers like 'movabletype', which is registered as 'mt'
|
||||
|
@ -59,13 +61,15 @@ $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
|
||||
/* translators: %s: importer slug */
|
||||
printf( __( 'The %s importer is invalid or is not installed.' ), '<strong>' . esc_html( $_GET['invalid'] ) . '</strong>' );
|
||||
?></p>
|
||||
<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>
|
||||
</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>
|
||||
<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>
|
||||
|
||||
<?php
|
||||
// Registered (already installed) importers. They're stored in the global $wp_importers.
|
||||
|
@ -73,17 +77,23 @@ $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 ) ) {
|
||||
echo '<p>' . __('No importers are available.') . '</p>'; // TODO: make more helpful
|
||||
echo '<p>' . __( 'No importers are available.' ) . '</p>'; // TODO: make more helpful
|
||||
} else {
|
||||
uasort( $importers, '_usort_by_first_member' );
|
||||
?>
|
||||
|
@ -91,7 +101,7 @@ if ( empty( $importers ) ) {
|
|||
|
||||
<?php
|
||||
foreach ( $importers as $importer_id => $data ) {
|
||||
$plugin_slug = $action = '';
|
||||
$plugin_slug = $action = '';
|
||||
$is_plugin_installed = false;
|
||||
|
||||
if ( isset( $data['install'] ) ) {
|
||||
|
@ -101,14 +111,18 @@ if ( empty( $importers ) ) {
|
|||
// Looks like an importer is installed, but not active.
|
||||
$plugins = get_plugins( '/' . $plugin_slug );
|
||||
if ( ! empty( $plugins ) ) {
|
||||
$keys = array_keys( $plugins );
|
||||
$keys = array_keys( $plugins );
|
||||
$plugin_file = $plugin_slug . '/' . $keys[0];
|
||||
$url = wp_nonce_url( add_query_arg( array(
|
||||
'action' => 'activate',
|
||||
'plugin' => $plugin_file,
|
||||
'from' => 'import',
|
||||
), admin_url( 'plugins.php' ) ), 'activate-plugin_' . $plugin_file );
|
||||
$action = sprintf(
|
||||
$url = wp_nonce_url(
|
||||
add_query_arg(
|
||||
array(
|
||||
'action' => 'activate',
|
||||
'plugin' => $plugin_file,
|
||||
'from' => 'import',
|
||||
), admin_url( 'plugins.php' )
|
||||
), 'activate-plugin_' . $plugin_file
|
||||
);
|
||||
$action = sprintf(
|
||||
'<a href="%s" aria-label="%s">%s</a>',
|
||||
esc_url( $url ),
|
||||
/* translators: %s: Importer name */
|
||||
|
@ -122,11 +136,15 @@ if ( empty( $importers ) ) {
|
|||
|
||||
if ( empty( $action ) ) {
|
||||
if ( is_main_site() ) {
|
||||
$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 );
|
||||
$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
|
||||
);
|
||||
$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(
|
||||
'import' => $importer_id,
|
||||
), self_admin_url( 'admin.php' ) );
|
||||
$url = add_query_arg(
|
||||
array(
|
||||
'import' => $importer_id,
|
||||
), 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(
|
||||
'tab' => 'plugin-information',
|
||||
'plugin' => $plugin_slug,
|
||||
'from' => 'import',
|
||||
'TB_iframe' => 'true',
|
||||
'width' => 600,
|
||||
'height' => 550,
|
||||
), network_admin_url( 'plugin-install.php' ) );
|
||||
$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' )
|
||||
);
|
||||
$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') )
|
||||
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>';
|
||||
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>
|
||||
|
|
|
@ -19,16 +19,16 @@ add_action( 'attachment_submitbox_misc_actions', 'attachment_submitbox_metadata'
|
|||
add_action( 'media_upload_image', 'wp_media_upload_handler' );
|
||||
add_action( 'media_upload_audio', 'wp_media_upload_handler' );
|
||||
add_action( 'media_upload_video', 'wp_media_upload_handler' );
|
||||
add_action( 'media_upload_file', 'wp_media_upload_handler' );
|
||||
add_action( 'media_upload_file', 'wp_media_upload_handler' );
|
||||
|
||||
add_action( 'post-plupload-upload-ui', 'media_upload_flash_bypass' );
|
||||
|
||||
add_action( 'post-html-upload-ui', 'media_upload_html_bypass' );
|
||||
add_action( 'post-html-upload-ui', 'media_upload_html_bypass' );
|
||||
|
||||
add_filter( 'async_upload_image', 'get_media_item', 10, 2 );
|
||||
add_filter( 'async_upload_audio', 'get_media_item', 10, 2 );
|
||||
add_filter( 'async_upload_video', 'get_media_item', 10, 2 );
|
||||
add_filter( 'async_upload_file', 'get_media_item', 10, 2 );
|
||||
add_filter( 'async_upload_file', 'get_media_item', 10, 2 );
|
||||
|
||||
add_filter( 'attachment_fields_to_save', 'image_attachment_fields_to_save', 10, 2 );
|
||||
|
||||
|
@ -38,33 +38,33 @@ add_filter( 'media_upload_library', 'media_upload_library' );
|
|||
add_filter( 'media_upload_tabs', 'update_gallery_tab' );
|
||||
|
||||
// Misc hooks.
|
||||
add_action( 'admin_init', 'wp_admin_headers' );
|
||||
add_action( 'login_init', 'wp_admin_headers' );
|
||||
add_action( 'admin_head', 'wp_admin_canonical_url' );
|
||||
add_action( 'admin_init', 'wp_admin_headers' );
|
||||
add_action( 'login_init', 'wp_admin_headers' );
|
||||
add_action( 'admin_head', 'wp_admin_canonical_url' );
|
||||
add_action( 'admin_head', 'wp_color_scheme_settings' );
|
||||
add_action( 'admin_head', 'wp_site_icon' );
|
||||
add_action( 'admin_head', '_ipad_meta' );
|
||||
add_action( 'admin_head', 'wp_site_icon' );
|
||||
add_action( 'admin_head', '_ipad_meta' );
|
||||
|
||||
// Prerendering.
|
||||
if ( ! is_customize_preview() ) {
|
||||
add_filter( 'admin_print_styles', 'wp_resource_hints', 1 );
|
||||
}
|
||||
|
||||
add_action( 'admin_print_scripts-post.php', 'wp_page_reload_on_back_button_js' );
|
||||
add_action( 'admin_print_scripts-post.php', 'wp_page_reload_on_back_button_js' );
|
||||
add_action( 'admin_print_scripts-post-new.php', 'wp_page_reload_on_back_button_js' );
|
||||
|
||||
add_action( 'update_option_home', 'update_home_siteurl', 10, 2 );
|
||||
add_action( 'update_option_siteurl', 'update_home_siteurl', 10, 2 );
|
||||
add_action( 'update_option_home', 'update_home_siteurl', 10, 2 );
|
||||
add_action( 'update_option_siteurl', 'update_home_siteurl', 10, 2 );
|
||||
add_action( 'update_option_page_on_front', 'update_home_siteurl', 10, 2 );
|
||||
add_action( 'update_option_admin_email', 'wp_site_admin_email_change_notification', 10, 3 );
|
||||
add_action( 'update_option_admin_email', 'wp_site_admin_email_change_notification', 10, 3 );
|
||||
|
||||
add_action( 'add_option_new_admin_email', 'update_option_new_admin_email', 10, 2 );
|
||||
add_action( 'add_option_new_admin_email', 'update_option_new_admin_email', 10, 2 );
|
||||
add_action( 'update_option_new_admin_email', 'update_option_new_admin_email', 10, 2 );
|
||||
|
||||
add_filter( 'heartbeat_received', 'wp_check_locked_posts', 10, 3 );
|
||||
add_filter( 'heartbeat_received', 'wp_refresh_post_lock', 10, 3 );
|
||||
add_filter( 'wp_refresh_nonces', 'wp_refresh_post_nonces', 10, 3 );
|
||||
add_filter( 'heartbeat_received', 'heartbeat_autosave', 500, 2 );
|
||||
add_filter( 'heartbeat_received', 'wp_check_locked_posts', 10, 3 );
|
||||
add_filter( 'heartbeat_received', 'wp_refresh_post_lock', 10, 3 );
|
||||
add_filter( 'wp_refresh_nonces', 'wp_refresh_post_nonces', 10, 3 );
|
||||
add_filter( 'heartbeat_received', 'heartbeat_autosave', 500, 2 );
|
||||
|
||||
add_filter( 'heartbeat_settings', 'wp_heartbeat_set_suspension' );
|
||||
|
||||
|
@ -75,19 +75,19 @@ add_action( 'admin_head-nav-menus.php', '_wp_delete_orphaned_draft_menu_items' )
|
|||
add_filter( 'whitelist_options', 'option_update_filter' );
|
||||
|
||||
// Plugin Install hooks.
|
||||
add_action( 'install_plugins_featured', 'install_dashboard' );
|
||||
add_action( 'install_plugins_upload', 'install_plugins_upload' );
|
||||
add_action( 'install_plugins_search', 'display_plugins_table' );
|
||||
add_action( 'install_plugins_popular', 'display_plugins_table' );
|
||||
add_action( 'install_plugins_recommended', 'display_plugins_table' );
|
||||
add_action( 'install_plugins_new', 'display_plugins_table' );
|
||||
add_action( 'install_plugins_beta', 'display_plugins_table' );
|
||||
add_action( 'install_plugins_favorites', 'display_plugins_table' );
|
||||
add_action( 'install_plugins_featured', 'install_dashboard' );
|
||||
add_action( 'install_plugins_upload', 'install_plugins_upload' );
|
||||
add_action( 'install_plugins_search', 'display_plugins_table' );
|
||||
add_action( 'install_plugins_popular', 'display_plugins_table' );
|
||||
add_action( 'install_plugins_recommended', 'display_plugins_table' );
|
||||
add_action( 'install_plugins_new', 'display_plugins_table' );
|
||||
add_action( 'install_plugins_beta', 'display_plugins_table' );
|
||||
add_action( 'install_plugins_favorites', 'display_plugins_table' );
|
||||
add_action( 'install_plugins_pre_plugin-information', 'install_plugin_information' );
|
||||
|
||||
// Template hooks.
|
||||
add_action( 'admin_enqueue_scripts', array( 'WP_Internal_Pointers', 'enqueue_scripts' ) );
|
||||
add_action( 'user_register', array( 'WP_Internal_Pointers', 'dismiss_pointers_for_new_users' ) );
|
||||
add_action( 'admin_enqueue_scripts', array( 'WP_Internal_Pointers', 'enqueue_scripts' ) );
|
||||
add_action( 'user_register', array( 'WP_Internal_Pointers', 'dismiss_pointers_for_new_users' ) );
|
||||
|
||||
// Theme hooks.
|
||||
add_action( 'customize_controls_print_footer_scripts', 'customize_themes_print_templates' );
|
||||
|
@ -115,7 +115,7 @@ add_action( 'personal_options_update', 'send_confirmation_on_profile_email' );
|
|||
add_action( 'load-plugins.php', 'wp_plugin_update_rows', 20 ); // After wp_update_plugins() is called.
|
||||
add_action( 'load-themes.php', 'wp_theme_update_rows', 20 ); // After wp_update_themes() is called.
|
||||
|
||||
add_action( 'admin_notices', 'update_nag', 3 );
|
||||
add_action( 'admin_notices', 'update_nag', 3 );
|
||||
add_action( 'admin_notices', 'maintenance_nag', 10 );
|
||||
|
||||
add_filter( 'update_footer', 'core_update_footer' );
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* @since 2.3.0
|
||||
*/
|
||||
|
||||
if ( ! defined('WP_ADMIN') ) {
|
||||
if ( ! defined( 'WP_ADMIN' ) ) {
|
||||
/*
|
||||
* This file is being included from a file other than wp-admin/admin.php, so
|
||||
* some setup was skipped. Make sure the admin message catalog is loaded since
|
||||
|
@ -17,71 +17,71 @@ if ( ! defined('WP_ADMIN') ) {
|
|||
}
|
||||
|
||||
/** WordPress Administration Hooks */
|
||||
require_once(ABSPATH . 'wp-admin/includes/admin-filters.php');
|
||||
require_once( ABSPATH . 'wp-admin/includes/admin-filters.php' );
|
||||
|
||||
/** WordPress Bookmark Administration API */
|
||||
require_once(ABSPATH . 'wp-admin/includes/bookmark.php');
|
||||
require_once( ABSPATH . 'wp-admin/includes/bookmark.php' );
|
||||
|
||||
/** WordPress Comment Administration API */
|
||||
require_once(ABSPATH . 'wp-admin/includes/comment.php');
|
||||
require_once( ABSPATH . 'wp-admin/includes/comment.php' );
|
||||
|
||||
/** WordPress Administration File API */
|
||||
require_once(ABSPATH . 'wp-admin/includes/file.php');
|
||||
require_once( ABSPATH . 'wp-admin/includes/file.php' );
|
||||
|
||||
/** WordPress Image Administration API */
|
||||
require_once(ABSPATH . 'wp-admin/includes/image.php');
|
||||
require_once( ABSPATH . 'wp-admin/includes/image.php' );
|
||||
|
||||
/** WordPress Media Administration API */
|
||||
require_once(ABSPATH . 'wp-admin/includes/media.php');
|
||||
require_once( ABSPATH . 'wp-admin/includes/media.php' );
|
||||
|
||||
/** WordPress Import Administration API */
|
||||
require_once(ABSPATH . 'wp-admin/includes/import.php');
|
||||
require_once( ABSPATH . 'wp-admin/includes/import.php' );
|
||||
|
||||
/** WordPress Misc Administration API */
|
||||
require_once(ABSPATH . 'wp-admin/includes/misc.php');
|
||||
require_once( ABSPATH . 'wp-admin/includes/misc.php' );
|
||||
|
||||
/** WordPress Options Administration API */
|
||||
require_once(ABSPATH . 'wp-admin/includes/options.php');
|
||||
require_once( ABSPATH . 'wp-admin/includes/options.php' );
|
||||
|
||||
/** WordPress Plugin Administration API */
|
||||
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
|
||||
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
||||
|
||||
/** WordPress Post Administration API */
|
||||
require_once(ABSPATH . 'wp-admin/includes/post.php');
|
||||
require_once( ABSPATH . 'wp-admin/includes/post.php' );
|
||||
|
||||
/** WordPress Administration Screen API */
|
||||
require_once(ABSPATH . 'wp-admin/includes/class-wp-screen.php');
|
||||
require_once(ABSPATH . 'wp-admin/includes/screen.php');
|
||||
require_once( ABSPATH . 'wp-admin/includes/class-wp-screen.php' );
|
||||
require_once( ABSPATH . 'wp-admin/includes/screen.php' );
|
||||
|
||||
/** WordPress Taxonomy Administration API */
|
||||
require_once(ABSPATH . 'wp-admin/includes/taxonomy.php');
|
||||
require_once( ABSPATH . 'wp-admin/includes/taxonomy.php' );
|
||||
|
||||
/** WordPress Template Administration API */
|
||||
require_once(ABSPATH . 'wp-admin/includes/template.php');
|
||||
require_once( ABSPATH . 'wp-admin/includes/template.php' );
|
||||
|
||||
/** WordPress List Table Administration API and base class */
|
||||
require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
|
||||
require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table-compat.php');
|
||||
require_once(ABSPATH . 'wp-admin/includes/list-table.php');
|
||||
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
|
||||
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table-compat.php' );
|
||||
require_once( ABSPATH . 'wp-admin/includes/list-table.php' );
|
||||
|
||||
/** WordPress Theme Administration API */
|
||||
require_once(ABSPATH . 'wp-admin/includes/theme.php');
|
||||
require_once( ABSPATH . 'wp-admin/includes/theme.php' );
|
||||
|
||||
/** WordPress User Administration API */
|
||||
require_once(ABSPATH . 'wp-admin/includes/user.php');
|
||||
require_once( ABSPATH . 'wp-admin/includes/user.php' );
|
||||
|
||||
/** WordPress Site Icon API */
|
||||
require_once(ABSPATH . 'wp-admin/includes/class-wp-site-icon.php');
|
||||
require_once( ABSPATH . 'wp-admin/includes/class-wp-site-icon.php' );
|
||||
|
||||
/** WordPress Update Administration API */
|
||||
require_once(ABSPATH . 'wp-admin/includes/update.php');
|
||||
require_once( ABSPATH . 'wp-admin/includes/update.php' );
|
||||
|
||||
/** WordPress Deprecated Administration API */
|
||||
require_once(ABSPATH . 'wp-admin/includes/deprecated.php');
|
||||
require_once( ABSPATH . 'wp-admin/includes/deprecated.php' );
|
||||
|
||||
/** WordPress Multisite support API */
|
||||
if ( is_multisite() ) {
|
||||
require_once(ABSPATH . 'wp-admin/includes/ms-admin-filters.php');
|
||||
require_once(ABSPATH . 'wp-admin/includes/ms.php');
|
||||
require_once(ABSPATH . 'wp-admin/includes/ms-deprecated.php');
|
||||
require_once( ABSPATH . 'wp-admin/includes/ms-admin-filters.php' );
|
||||
require_once( ABSPATH . 'wp-admin/includes/ms.php' );
|
||||
require_once( ABSPATH . 'wp-admin/includes/ms-deprecated.php' );
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -34,15 +34,16 @@ function edit_link( $link_id = 0 ) {
|
|||
);
|
||||
}
|
||||
|
||||
$_POST['link_url'] = esc_html( $_POST['link_url'] );
|
||||
$_POST['link_url'] = esc_url($_POST['link_url']);
|
||||
$_POST['link_name'] = esc_html( $_POST['link_name'] );
|
||||
$_POST['link_url'] = esc_html( $_POST['link_url'] );
|
||||
$_POST['link_url'] = esc_url( $_POST['link_url'] );
|
||||
$_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'] )
|
||||
$_POST['link_rss'] = esc_url( $_POST['link_rss'] );
|
||||
if ( ! isset( $_POST['link_visible'] ) || 'N' != $_POST['link_visible'] ) {
|
||||
$_POST['link_visible'] = 'Y';
|
||||
}
|
||||
|
||||
if ( !empty( $link_id ) ) {
|
||||
if ( ! empty( $link_id ) ) {
|
||||
$_POST['link_id'] = $link_id;
|
||||
return wp_update_link( $_POST );
|
||||
} else {
|
||||
|
@ -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';
|
||||
|
||||
|
@ -122,7 +125,7 @@ function wp_delete_link( $link_id ) {
|
|||
* @return array The requested link's categories
|
||||
*/
|
||||
function wp_get_link_cats( $link_id = 0 ) {
|
||||
$cats = wp_get_object_terms( $link_id, 'link_category', array('fields' => 'ids') );
|
||||
$cats = wp_get_object_terms( $link_id, 'link_category', array( 'fields' => 'ids' ) );
|
||||
return array_unique( $cats );
|
||||
}
|
||||
|
||||
|
@ -152,10 +155,15 @@ 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' ) );
|
||||
$r = wp_unslash( sanitize_bookmark( $args, 'db' ) );
|
||||
|
||||
$link_id = $r['link_id'];
|
||||
$link_name = $r['link_name'];
|
||||
|
@ -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,13 +286,14 @@ 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 );
|
||||
$linkdata = array_merge( $link, $linkdata );
|
||||
$linkdata['link_category'] = $link_cats;
|
||||
|
||||
return wp_insert_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' );
|
||||
|
|
|
@ -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(
|
||||
'a' => array(
|
||||
'href' => true
|
||||
),
|
||||
'br' => true,
|
||||
'em' => true,
|
||||
'strong' => true,
|
||||
) );
|
||||
$string = wp_kses(
|
||||
$string, array(
|
||||
'a' => array(
|
||||
'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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,23 +20,21 @@ class Bulk_Plugin_Upgrader_Skin extends Bulk_Upgrader_Skin {
|
|||
|
||||
public function add_strings() {
|
||||
parent::add_strings();
|
||||
$this->upgrader->strings['skin_before_update_header'] = __('Updating Plugin %1$s (%2$d/%3$d)');
|
||||
$this->upgrader->strings['skin_before_update_header'] = __( 'Updating Plugin %1$s (%2$d/%3$d)' );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $title
|
||||
*/
|
||||
public function before($title = '') {
|
||||
parent::before($this->plugin_info['Title']);
|
||||
public function before( $title = '' ) {
|
||||
parent::before( $this->plugin_info['Title'] );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $title
|
||||
*/
|
||||
public function after($title = '') {
|
||||
parent::after($this->plugin_info['Title']);
|
||||
public function after( $title = '' ) {
|
||||
parent::after( $this->plugin_info['Title'] );
|
||||
$this->decrement_update_count( 'plugin' );
|
||||
}
|
||||
|
||||
|
@ -44,12 +42,13 @@ class Bulk_Plugin_Upgrader_Skin extends Bulk_Upgrader_Skin {
|
|||
*/
|
||||
public function bulk_footer() {
|
||||
parent::bulk_footer();
|
||||
$update_actions = array(
|
||||
$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) )
|
||||
$this->feedback(implode(' | ', (array)$update_actions));
|
||||
if ( ! empty( $update_actions ) ) {
|
||||
$this->feedback( implode( ' | ', (array) $update_actions ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,23 +20,21 @@ class Bulk_Theme_Upgrader_Skin extends Bulk_Upgrader_Skin {
|
|||
|
||||
public function add_strings() {
|
||||
parent::add_strings();
|
||||
$this->upgrader->strings['skin_before_update_header'] = __('Updating Theme %1$s (%2$d/%3$d)');
|
||||
$this->upgrader->strings['skin_before_update_header'] = __( 'Updating Theme %1$s (%2$d/%3$d)' );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $title
|
||||
*/
|
||||
public function before($title = '') {
|
||||
parent::before( $this->theme_info->display('Name') );
|
||||
public function before( $title = '' ) {
|
||||
parent::before( $this->theme_info->display( 'Name' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $title
|
||||
*/
|
||||
public function after($title = '') {
|
||||
parent::after( $this->theme_info->display('Name') );
|
||||
public function after( $title = '' ) {
|
||||
parent::after( $this->theme_info->display( 'Name' ) );
|
||||
$this->decrement_update_count( 'theme' );
|
||||
}
|
||||
|
||||
|
@ -44,12 +42,13 @@ class Bulk_Theme_Upgrader_Skin extends Bulk_Upgrader_Skin {
|
|||
*/
|
||||
public function bulk_footer() {
|
||||
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>'
|
||||
$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>',
|
||||
);
|
||||
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) )
|
||||
$this->feedback(implode(' | ', (array)$update_actions));
|
||||
if ( ! empty( $update_actions ) ) {
|
||||
$this->feedback( implode( ' | ', (array) $update_actions ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,52 +23,56 @@ class Bulk_Upgrader_Skin extends WP_Upgrader_Skin {
|
|||
public $error = false;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $args
|
||||
*/
|
||||
public function __construct($args = array()) {
|
||||
$defaults = array( 'url' => '', 'nonce' => '' );
|
||||
$args = wp_parse_args($args, $defaults);
|
||||
public function __construct( $args = array() ) {
|
||||
$defaults = array(
|
||||
'url' => '',
|
||||
'nonce' => '',
|
||||
);
|
||||
$args = wp_parse_args( $args, $defaults );
|
||||
|
||||
parent::__construct($args);
|
||||
parent::__construct( $args );
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public function add_strings() {
|
||||
$this->upgrader->strings['skin_upgrade_start'] = __('The update process is starting. This process may take a while on some hosts, so please be patient.');
|
||||
$this->upgrader->strings['skin_upgrade_start'] = __( 'The update process is starting. This process may take a while on some hosts, so please be patient.' );
|
||||
/* translators: 1: Title of an update, 2: Error message */
|
||||
$this->upgrader->strings['skin_update_failed_error'] = __('An error occurred while updating %1$s: %2$s');
|
||||
$this->upgrader->strings['skin_update_failed_error'] = __( 'An error occurred while updating %1$s: %2$s' );
|
||||
/* translators: 1: Title of an update */
|
||||
$this->upgrader->strings['skin_update_failed'] = __('The update of %1$s failed.');
|
||||
$this->upgrader->strings['skin_update_failed'] = __( 'The update of %1$s failed.' );
|
||||
/* translators: 1: Title of an update */
|
||||
$this->upgrader->strings['skin_update_successful'] = __( '%1$s updated successfully.' );
|
||||
$this->upgrader->strings['skin_upgrade_end'] = __('All updates have been completed.');
|
||||
$this->upgrader->strings['skin_upgrade_end'] = __( 'All updates have been completed.' );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $string
|
||||
*/
|
||||
public function feedback($string) {
|
||||
if ( isset( $this->upgrader->strings[$string] ) )
|
||||
$string = $this->upgrader->strings[$string];
|
||||
public function feedback( $string ) {
|
||||
if ( isset( $this->upgrader->strings[ $string ] ) ) {
|
||||
$string = $this->upgrader->strings[ $string ];
|
||||
}
|
||||
|
||||
if ( strpos($string, '%') !== false ) {
|
||||
if ( strpos( $string, '%' ) !== false ) {
|
||||
$args = func_get_args();
|
||||
$args = array_splice($args, 1);
|
||||
$args = array_splice( $args, 1 );
|
||||
if ( $args ) {
|
||||
$args = array_map( 'strip_tags', $args );
|
||||
$args = array_map( 'esc_html', $args );
|
||||
$string = vsprintf($string, $args);
|
||||
$args = array_map( 'strip_tags', $args );
|
||||
$args = array_map( 'esc_html', $args );
|
||||
$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,65 +88,64 @@ 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] ) )
|
||||
$this->error = $this->upgrader->strings[$error];
|
||||
public function error( $error ) {
|
||||
if ( is_string( $error ) && isset( $this->upgrader->strings[ $error ] ) ) {
|
||||
$this->error = $this->upgrader->strings[ $error ];
|
||||
}
|
||||
|
||||
if ( is_wp_error($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);
|
||||
$this->error = implode( ', ', $messages );
|
||||
}
|
||||
echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').hide();</script>';
|
||||
echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js( $this->upgrader->update_current ) . '\').hide();</script>';
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public function bulk_header() {
|
||||
$this->feedback('skin_upgrade_start');
|
||||
$this->feedback( 'skin_upgrade_start' );
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public function bulk_footer() {
|
||||
$this->feedback('skin_upgrade_end');
|
||||
$this->feedback( 'skin_upgrade_end' );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $title
|
||||
*/
|
||||
public function before($title = '') {
|
||||
public function before( $title = '' ) {
|
||||
$this->in_loop = true;
|
||||
printf( '<h2>' . $this->upgrader->strings['skin_before_update_header'] . ' <span class="spinner waiting-' . $this->upgrader->update_current . '"></span></h2>', $title, $this->upgrader->update_current, $this->upgrader->update_count );
|
||||
echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').css("display", "inline-block");</script>';
|
||||
echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js( $this->upgrader->update_current ) . '\').css("display", "inline-block");</script>';
|
||||
// This progress messages div gets moved via JavaScript when clicking on "Show details.".
|
||||
echo '<div class="update-messages hide-if-js" id="progress-' . esc_attr($this->upgrader->update_current) . '"><p>';
|
||||
echo '<div class="update-messages hide-if-js" id="progress-' . esc_attr( $this->upgrader->update_current ) . '"><p>';
|
||||
$this->flush_output();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $title
|
||||
*/
|
||||
public function after($title = '') {
|
||||
public function after( $title = '' ) {
|
||||
echo '</p></div>';
|
||||
if ( $this->error || ! $this->result ) {
|
||||
if ( $this->error ) {
|
||||
echo '<div class="error"><p>' . sprintf($this->upgrader->strings['skin_update_failed_error'], $title, '<strong>' . $this->error . '</strong>' ) . '</p></div>';
|
||||
echo '<div class="error"><p>' . sprintf( $this->upgrader->strings['skin_update_failed_error'], $title, '<strong>' . $this->error . '</strong>' ) . '</p></div>';
|
||||
} else {
|
||||
echo '<div class="error"><p>' . sprintf($this->upgrader->strings['skin_update_failed'], $title) . '</p></div>';
|
||||
echo '<div class="error"><p>' . sprintf( $this->upgrader->strings['skin_update_failed'], $title ) . '</p></div>';
|
||||
}
|
||||
|
||||
echo '<script type="text/javascript">jQuery(\'#progress-' . esc_js($this->upgrader->update_current) . '\').show();</script>';
|
||||
echo '<script type="text/javascript">jQuery(\'#progress-' . esc_js( $this->upgrader->update_current ) . '\').show();</script>';
|
||||
}
|
||||
if ( $this->result && ! is_wp_error( $this->result ) ) {
|
||||
if ( ! $this->error ) {
|
||||
|
@ -152,7 +155,7 @@ class Bulk_Upgrader_Skin extends WP_Upgrader_Skin {
|
|||
'</p></div>';
|
||||
}
|
||||
|
||||
echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').hide();</script>';
|
||||
echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js( $this->upgrader->update_current ) . '\').hide();</script>';
|
||||
}
|
||||
|
||||
$this->reset();
|
||||
|
@ -163,7 +166,7 @@ class Bulk_Upgrader_Skin extends WP_Upgrader_Skin {
|
|||
*/
|
||||
public function reset() {
|
||||
$this->in_loop = false;
|
||||
$this->error = false;
|
||||
$this->error = false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -26,15 +26,15 @@ class Core_Upgrader extends WP_Upgrader {
|
|||
* @since 2.8.0
|
||||
*/
|
||||
public function upgrade_strings() {
|
||||
$this->strings['up_to_date'] = __('WordPress is at the latest version.');
|
||||
$this->strings['locked'] = __('Another update is currently in progress.');
|
||||
$this->strings['no_package'] = __('Update package not available.');
|
||||
$this->strings['up_to_date'] = __( 'WordPress is at the latest version.' );
|
||||
$this->strings['locked'] = __( 'Another update is currently in progress.' );
|
||||
$this->strings['no_package'] = __( 'Update package not available.' );
|
||||
/* translators: %s: package URL */
|
||||
$this->strings['downloading_package'] = sprintf( __( 'Downloading update from %s…' ), '<span class="code">%s</span>' );
|
||||
$this->strings['unpack_package'] = __('Unpacking the update…');
|
||||
$this->strings['copy_failed'] = __('Could not copy files.');
|
||||
$this->strings['copy_failed_space'] = __('Could not copy files. You may have run out of disk space.' );
|
||||
$this->strings['start_rollback'] = __( 'Attempting to roll back to previous version.' );
|
||||
$this->strings['downloading_package'] = sprintf( __( 'Downloading update from %s…' ), '<span class="code">%s</span>' );
|
||||
$this->strings['unpack_package'] = __( 'Unpacking the update…' );
|
||||
$this->strings['copy_failed'] = __( 'Could not copy files.' );
|
||||
$this->strings['copy_failed_space'] = __( 'Could not copy files. You may have run out of disk space.' );
|
||||
$this->strings['start_rollback'] = __( 'Attempting to roll back to previous version.' );
|
||||
$this->strings['rollback_was_required'] = __( 'Due to an error during updating, WordPress has rolled back to your previous version.' );
|
||||
}
|
||||
|
||||
|
@ -66,10 +66,10 @@ class Core_Upgrader extends WP_Upgrader {
|
|||
|
||||
$start_time = time();
|
||||
|
||||
$defaults = array(
|
||||
'pre_check_md5' => true,
|
||||
'attempt_rollback' => false,
|
||||
'do_rollback' => false,
|
||||
$defaults = array(
|
||||
'pre_check_md5' => true,
|
||||
'attempt_rollback' => false,
|
||||
'do_rollback' => false,
|
||||
'allow_relaxed_file_ownership' => false,
|
||||
);
|
||||
$parsed_args = wp_parse_args( $args, $defaults );
|
||||
|
@ -78,21 +78,23 @@ class Core_Upgrader extends WP_Upgrader {
|
|||
$this->upgrade_strings();
|
||||
|
||||
// Is an update available?
|
||||
if ( !isset( $current->response ) || $current->response == 'latest' )
|
||||
return new WP_Error('up_to_date', $this->strings['up_to_date']);
|
||||
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 ) ) {
|
||||
return $res;
|
||||
}
|
||||
|
||||
$wp_dir = trailingslashit($wp_filesystem->abspath());
|
||||
$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 );
|
||||
|
@ -131,12 +134,12 @@ class Core_Upgrader extends WP_Upgrader {
|
|||
}
|
||||
|
||||
// Copy update-core.php from the new version into place.
|
||||
if ( !$wp_filesystem->copy($working_dir . '/wordpress/wp-admin/includes/update-core.php', $wp_dir . 'wp-admin/includes/update-core.php', true) ) {
|
||||
$wp_filesystem->delete($working_dir, true);
|
||||
if ( ! $wp_filesystem->copy( $working_dir . '/wordpress/wp-admin/includes/update-core.php', $wp_dir . 'wp-admin/includes/update-core.php', true ) ) {
|
||||
$wp_filesystem->delete( $working_dir, true );
|
||||
WP_Upgrader::release_lock( 'core_updater' );
|
||||
return new WP_Error( 'copy_failed_for_update_core_file', __( 'The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.' ), 'wp-admin/includes/update-core.php' );
|
||||
}
|
||||
$wp_filesystem->chmod($wp_dir . 'wp-admin/includes/update-core.php', FS_CHMOD_FILE);
|
||||
$wp_filesystem->chmod( $wp_dir . 'wp-admin/includes/update-core.php', FS_CHMOD_FILE );
|
||||
|
||||
require_once( ABSPATH . 'wp-admin/includes/update-core.php' );
|
||||
|
||||
|
@ -157,12 +160,13 @@ 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 ) {
|
||||
|
@ -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' );
|
||||
|
@ -191,7 +205,7 @@ class Core_Upgrader extends WP_Upgrader {
|
|||
'success' => true,
|
||||
'fs_method' => $wp_filesystem->method,
|
||||
'fs_method_forced' => defined( 'FS_METHOD' ) || has_filter( 'filesystem_method' ),
|
||||
'fs_method_direct' => !empty( $GLOBALS['_wp_filesystem_direct_method'] ) ? $GLOBALS['_wp_filesystem_direct_method'] : '',
|
||||
'fs_method_direct' => ! empty( $GLOBALS['_wp_filesystem_direct_method'] ) ? $GLOBALS['_wp_filesystem_direct_method'] : '',
|
||||
'time_taken' => time() - $start_time,
|
||||
'reported' => $wp_version,
|
||||
'attempted' => $current->version,
|
||||
|
@ -236,8 +250,8 @@ class Core_Upgrader extends WP_Upgrader {
|
|||
public static function should_update_to_version( $offered_ver ) {
|
||||
include( ABSPATH . WPINC . '/version.php' ); // $wp_version; // x.y.z
|
||||
|
||||
$current_branch = implode( '.', array_slice( preg_split( '/[.-]/', $wp_version ), 0, 2 ) ); // x.y
|
||||
$new_branch = implode( '.', array_slice( preg_split( '/[.-]/', $offered_ver ), 0, 2 ) ); // x.y
|
||||
$current_branch = implode( '.', array_slice( preg_split( '/[.-]/', $wp_version ), 0, 2 ) ); // x.y
|
||||
$new_branch = implode( '.', array_slice( preg_split( '/[.-]/', $offered_ver ), 0, 2 ) ); // x.y
|
||||
$current_is_development_version = (bool) strpos( $wp_version, '-' );
|
||||
|
||||
// Defaults:
|
||||
|
@ -255,34 +269,39 @@ class Core_Upgrader extends WP_Upgrader {
|
|||
$upgrade_dev = $upgrade_minor = $upgrade_major = true;
|
||||
} elseif ( 'minor' === WP_AUTO_UPDATE_CORE ) {
|
||||
// Only minor updates for core
|
||||
$upgrade_dev = $upgrade_major = false;
|
||||
$upgrade_dev = $upgrade_major = false;
|
||||
$upgrade_minor = true;
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
|
@ -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,15 +366,18 @@ 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;
|
||||
|
|
|
@ -52,28 +52,33 @@ class File_Upload_Upgrader {
|
|||
*/
|
||||
public function __construct( $form, $urlholder ) {
|
||||
|
||||
if ( empty($_FILES[$form]['name']) && empty($_GET[$urlholder]) )
|
||||
wp_die(__('Please select a file'));
|
||||
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 );
|
||||
$file = wp_handle_upload( $_FILES[$form], $overrides );
|
||||
if ( ! empty( $_FILES ) ) {
|
||||
$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'];
|
||||
$this->filename = $_FILES[ $form ]['name'];
|
||||
$this->package = $file['file'];
|
||||
|
||||
// Construct the object array
|
||||
$object = array(
|
||||
'post_title' => $this->filename,
|
||||
'post_content' => $file['url'],
|
||||
'post_title' => $this->filename,
|
||||
'post_content' => $file['url'],
|
||||
'post_mime_type' => $file['type'],
|
||||
'guid' => $file['url'],
|
||||
'context' => 'upgrader',
|
||||
'post_status' => 'private'
|
||||
'guid' => $file['url'],
|
||||
'context' => 'upgrader',
|
||||
'post_status' => 'private',
|
||||
);
|
||||
|
||||
// Save the data.
|
||||
|
@ -82,22 +87,24 @@ class File_Upload_Upgrader {
|
|||
// Schedule a cleanup for 2 hours from now in case of failed installation.
|
||||
wp_schedule_single_event( time() + 2 * HOUR_IN_SECONDS, 'upgrader_scheduled_cleanup', array( $this->id ) );
|
||||
|
||||
} elseif ( is_numeric( $_GET[$urlholder] ) ) {
|
||||
} elseif ( is_numeric( $_GET[ $urlholder ] ) ) {
|
||||
// Numeric Package = previously uploaded file, see above.
|
||||
$this->id = (int) $_GET[$urlholder];
|
||||
$this->id = (int) $_GET[ $urlholder ];
|
||||
$attachment = get_post( $this->id );
|
||||
if ( empty($attachment) )
|
||||
wp_die(__('Please select a file'));
|
||||
if ( empty( $attachment ) ) {
|
||||
wp_die( __( 'Please select a file' ) );
|
||||
}
|
||||
|
||||
$this->filename = $attachment->post_title;
|
||||
$this->package = get_attached_file( $attachment->ID );
|
||||
$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;
|
||||
$this->package = $uploads['basedir'] . '/' . $this->filename;
|
||||
|
||||
if ( 0 !== strpos( realpath( $this->package ), realpath( $uploads['basedir'] ) ) ) {
|
||||
wp_die( __( 'Please select a file' ) );
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -16,21 +16,25 @@
|
|||
* @see WP_Upgrader_Skin
|
||||
*/
|
||||
class Language_Pack_Upgrader_Skin extends WP_Upgrader_Skin {
|
||||
public $language_update = null;
|
||||
public $done_header = false;
|
||||
public $done_footer = false;
|
||||
public $language_update = null;
|
||||
public $done_header = false;
|
||||
public $done_footer = false;
|
||||
public $display_footer_actions = true;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $args
|
||||
*/
|
||||
public function __construct( $args = array() ) {
|
||||
$defaults = array( 'url' => '', 'nonce' => '', 'title' => __( 'Update Translations' ), 'skip_header_footer' => false );
|
||||
$args = wp_parse_args( $args, $defaults );
|
||||
$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;
|
||||
$this->done_footer = true;
|
||||
$this->done_header = true;
|
||||
$this->done_footer = true;
|
||||
$this->display_footer_actions = false;
|
||||
}
|
||||
parent::__construct( $args );
|
||||
|
@ -47,7 +51,6 @@ class Language_Pack_Upgrader_Skin extends WP_Upgrader_Skin {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string|WP_Error $error
|
||||
*/
|
||||
public function error( $error ) {
|
||||
|
@ -66,7 +69,7 @@ class Language_Pack_Upgrader_Skin extends WP_Upgrader_Skin {
|
|||
*/
|
||||
public function bulk_footer() {
|
||||
$this->decrement_update_count( 'translation' );
|
||||
$update_actions = array();
|
||||
$update_actions = array();
|
||||
$update_actions['updates_page'] = '<a href="' . self_admin_url( 'update-core.php' ) . '" target="_parent">' . __( 'Return to WordPress Updates page' ) . '</a>';
|
||||
|
||||
/**
|
||||
|
@ -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 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
'skip_header_footer' => true,
|
||||
) );
|
||||
$skin = new Language_Pack_Upgrader_Skin(
|
||||
array(
|
||||
'skip_header_footer' => true,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$lp_upgrader = new Language_Pack_Upgrader( $skin );
|
||||
|
@ -110,13 +112,13 @@ class Language_Pack_Upgrader extends WP_Upgrader {
|
|||
*/
|
||||
public function upgrade_strings() {
|
||||
$this->strings['starting_upgrade'] = __( 'Some of your translations need updating. Sit tight for a few more seconds while we update them as well.' );
|
||||
$this->strings['up_to_date'] = __( 'The translations are up to date.' );
|
||||
$this->strings['no_package'] = __( 'Update package not available.' );
|
||||
$this->strings['up_to_date'] = __( 'The translations are up to date.' );
|
||||
$this->strings['no_package'] = __( 'Update package not available.' );
|
||||
/* translators: %s: package URL */
|
||||
$this->strings['downloading_package'] = sprintf( __( 'Downloading translation from %s…' ), '<span class="code">%s</span>' );
|
||||
$this->strings['unpack_package'] = __( 'Unpacking the update…' );
|
||||
$this->strings['process_failed'] = __( 'Translation update failed.' );
|
||||
$this->strings['process_success'] = __( 'Translation updated successfully.' );
|
||||
$this->strings['unpack_package'] = __( 'Unpacking the update…' );
|
||||
$this->strings['process_failed'] = __( 'Translation update failed.' );
|
||||
$this->strings['process_success'] = __( 'Translation updated successfully.' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -163,7 +165,7 @@ class Language_Pack_Upgrader extends WP_Upgrader {
|
|||
public function bulk_upgrade( $language_updates = array(), $args = array() ) {
|
||||
global $wp_filesystem;
|
||||
|
||||
$defaults = array(
|
||||
$defaults = array(
|
||||
'clear_update_cache' => true,
|
||||
);
|
||||
$parsed_args = wp_parse_args( $args, $defaults );
|
||||
|
@ -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' );
|
||||
|
@ -205,7 +209,7 @@ class Language_Pack_Upgrader extends WP_Upgrader {
|
|||
|
||||
$results = array();
|
||||
|
||||
$this->update_count = count( $language_updates );
|
||||
$this->update_count = count( $language_updates );
|
||||
$this->update_current = 0;
|
||||
|
||||
/*
|
||||
|
@ -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,24 +230,25 @@ 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++;
|
||||
|
||||
$options = array(
|
||||
'package' => $language_update->package,
|
||||
'destination' => $destination,
|
||||
'clear_destination' => false,
|
||||
'package' => $language_update->package,
|
||||
'destination' => $destination,
|
||||
'clear_destination' => false,
|
||||
'abort_if_destination_exists' => false, // We expect the destination to exist.
|
||||
'clear_working' => true,
|
||||
'is_multi' => true,
|
||||
'hook_extra' => array(
|
||||
'clear_working' => true,
|
||||
'is_multi' => true,
|
||||
'hook_extra' => array(
|
||||
'language_update_type' => $language_update->type,
|
||||
'language_update' => $language_update,
|
||||
)
|
||||
'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(
|
||||
'action' => 'update',
|
||||
'type' => 'translation',
|
||||
'bulk' => true,
|
||||
'translations' => $language_updates_results
|
||||
) );
|
||||
do_action(
|
||||
'upgrader_process_complete', $this, array(
|
||||
'action' => 'update',
|
||||
'type' => 'translation',
|
||||
'bulk' => true,
|
||||
'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 '';
|
||||
|
|
|
@ -20,24 +20,30 @@ 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' => '' );
|
||||
$args = wp_parse_args($args, $defaults);
|
||||
public function __construct( $args = array() ) {
|
||||
$defaults = array(
|
||||
'type' => 'web',
|
||||
'url' => '',
|
||||
'plugin' => '',
|
||||
'nonce' => '',
|
||||
'title' => '',
|
||||
);
|
||||
$args = wp_parse_args( $args, $defaults );
|
||||
|
||||
$this->type = $args['type'];
|
||||
$this->api = isset($args['api']) ? $args['api'] : array();
|
||||
$this->api = isset( $args['api'] ) ? $args['api'] : array();
|
||||
|
||||
parent::__construct($args);
|
||||
parent::__construct( $args );
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
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 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -47,11 +53,11 @@ class Plugin_Installer_Skin extends WP_Upgrader_Skin {
|
|||
|
||||
$install_actions = array();
|
||||
|
||||
$from = isset($_GET['from']) ? wp_unslash( $_GET['from'] ) : 'plugins';
|
||||
$from = isset( $_GET['from'] ) ? wp_unslash( $_GET['from'] ) : 'plugins';
|
||||
|
||||
if ( 'import' == $from ) {
|
||||
$install_actions['activate_plugin'] = '<a class="button button-primary" href="' . wp_nonce_url( 'plugins.php?action=activate&from=import&plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ) . '" target="_parent">' . __( 'Activate Plugin & Run Importer' ) . '</a>';
|
||||
} else if ( 'press-this' == $from ) {
|
||||
} elseif ( 'press-this' == $from ) {
|
||||
$install_actions['activate_plugin'] = '<a class="button button-primary" href="' . wp_nonce_url( 'plugins.php?action=activate&from=press-this&plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ) . '" target="_parent">' . __( 'Activate Plugin & Return to Press This' ) . '</a>';
|
||||
} else {
|
||||
$install_actions['activate_plugin'] = '<a class="button button-primary" href="' . wp_nonce_url( 'plugins.php?action=activate&plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ) . '" target="_parent">' . __( 'Activate Plugin' ) . '</a>';
|
||||
|
@ -72,7 +78,7 @@ class Plugin_Installer_Skin extends WP_Upgrader_Skin {
|
|||
$install_actions['plugins_page'] = '<a href="' . self_admin_url( 'plugins.php' ) . '" target="_parent">' . __( 'Return to Plugins page' ) . '</a>';
|
||||
}
|
||||
|
||||
if ( ! $this->result || is_wp_error($this->result) ) {
|
||||
if ( ! $this->result || is_wp_error( $this->result ) ) {
|
||||
unset( $install_actions['activate_plugin'], $install_actions['network_activate'] );
|
||||
} elseif ( ! current_user_can( 'activate_plugin', $plugin_file ) ) {
|
||||
unset( $install_actions['activate_plugin'] );
|
||||
|
|
|
@ -16,43 +16,48 @@
|
|||
* @see WP_Upgrader_Skin
|
||||
*/
|
||||
class Plugin_Upgrader_Skin extends WP_Upgrader_Skin {
|
||||
public $plugin = '';
|
||||
public $plugin_active = false;
|
||||
public $plugin = '';
|
||||
public $plugin_active = false;
|
||||
public $plugin_network_active = false;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $args
|
||||
*/
|
||||
public function __construct( $args = array() ) {
|
||||
$defaults = array( 'url' => '', 'plugin' => '', 'nonce' => '', 'title' => __('Update Plugin') );
|
||||
$args = wp_parse_args($args, $defaults);
|
||||
$defaults = array(
|
||||
'url' => '',
|
||||
'plugin' => '',
|
||||
'nonce' => '',
|
||||
'title' => __( 'Update Plugin' ),
|
||||
);
|
||||
$args = wp_parse_args( $args, $defaults );
|
||||
|
||||
$this->plugin = $args['plugin'];
|
||||
|
||||
$this->plugin_active = is_plugin_active( $this->plugin );
|
||||
$this->plugin_active = is_plugin_active( $this->plugin );
|
||||
$this->plugin_network_active = is_plugin_active_for_network( $this->plugin );
|
||||
|
||||
parent::__construct($args);
|
||||
parent::__construct( $args );
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public function after() {
|
||||
$this->plugin = $this->upgrader->plugin_info();
|
||||
if ( !empty($this->plugin) && !is_wp_error($this->result) && $this->plugin_active ){
|
||||
if ( ! empty( $this->plugin ) && ! is_wp_error( $this->result ) && $this->plugin_active ) {
|
||||
// Currently used only when JS is off for a single plugin update?
|
||||
echo '<iframe title="' . esc_attr__( 'Update progress' ) . '" style="border:0;overflow:hidden" width="100%" height="170" src="' . wp_nonce_url( 'update.php?action=activate-plugin&networkwide=' . $this->plugin_network_active . '&plugin=' . urlencode( $this->plugin ), 'activate-plugin_' . $this->plugin ) . '"></iframe>';
|
||||
}
|
||||
|
||||
$this->decrement_update_count( 'plugin' );
|
||||
|
||||
$update_actions = array(
|
||||
'activate_plugin' => '<a href="' . wp_nonce_url( 'plugins.php?action=activate&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>'
|
||||
$update_actions = array(
|
||||
'activate_plugin' => '<a href="' . wp_nonce_url( 'plugins.php?action=activate&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>',
|
||||
);
|
||||
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) )
|
||||
$this->feedback(implode(' | ', (array)$update_actions));
|
||||
if ( ! empty( $update_actions ) ) {
|
||||
$this->feedback( implode( ' | ', (array) $update_actions ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,16 +44,16 @@ class Plugin_Upgrader extends WP_Upgrader {
|
|||
* @since 2.8.0
|
||||
*/
|
||||
public function upgrade_strings() {
|
||||
$this->strings['up_to_date'] = __('The plugin is at the latest version.');
|
||||
$this->strings['no_package'] = __('Update package not available.');
|
||||
$this->strings['up_to_date'] = __( 'The plugin is at the latest version.' );
|
||||
$this->strings['no_package'] = __( 'Update package not available.' );
|
||||
/* translators: %s: package URL */
|
||||
$this->strings['downloading_package'] = sprintf( __( 'Downloading update from %s…' ), '<span class="code">%s</span>' );
|
||||
$this->strings['unpack_package'] = __('Unpacking the update…');
|
||||
$this->strings['remove_old'] = __('Removing the old version of the plugin…');
|
||||
$this->strings['remove_old_failed'] = __('Could not remove the old plugin.');
|
||||
$this->strings['process_failed'] = __('Plugin update failed.');
|
||||
$this->strings['process_success'] = __('Plugin updated successfully.');
|
||||
$this->strings['process_bulk_success'] = __('Plugins updated successfully.');
|
||||
$this->strings['downloading_package'] = sprintf( __( 'Downloading update from %s…' ), '<span class="code">%s</span>' );
|
||||
$this->strings['unpack_package'] = __( 'Unpacking the update…' );
|
||||
$this->strings['remove_old'] = __( 'Removing the old version of the plugin…' );
|
||||
$this->strings['remove_old_failed'] = __( 'Could not remove the old plugin.' );
|
||||
$this->strings['process_failed'] = __( 'Plugin update failed.' );
|
||||
$this->strings['process_success'] = __( 'Plugin updated successfully.' );
|
||||
$this->strings['process_bulk_success'] = __( 'Plugins updated successfully.' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -62,14 +62,14 @@ class Plugin_Upgrader extends WP_Upgrader {
|
|||
* @since 2.8.0
|
||||
*/
|
||||
public function install_strings() {
|
||||
$this->strings['no_package'] = __('Installation package not available.');
|
||||
$this->strings['no_package'] = __( 'Installation package not available.' );
|
||||
/* translators: %s: package URL */
|
||||
$this->strings['downloading_package'] = sprintf( __( 'Downloading installation package from %s…' ), '<span class="code">%s</span>' );
|
||||
$this->strings['unpack_package'] = __('Unpacking the package…');
|
||||
$this->strings['installing_package'] = __('Installing the plugin…');
|
||||
$this->strings['no_files'] = __('The plugin contains no files.');
|
||||
$this->strings['process_failed'] = __('Plugin installation failed.');
|
||||
$this->strings['process_success'] = __('Plugin installed successfully.');
|
||||
$this->strings['unpack_package'] = __( 'Unpacking the package…' );
|
||||
$this->strings['installing_package'] = __( 'Installing the plugin…' );
|
||||
$this->strings['no_files'] = __( 'The plugin contains no files.' );
|
||||
$this->strings['process_failed'] = __( 'Plugin installation failed.' );
|
||||
$this->strings['process_success'] = __( 'Plugin installed successfully.' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -89,7 +89,7 @@ class Plugin_Upgrader extends WP_Upgrader {
|
|||
*/
|
||||
public function install( $package, $args = array() ) {
|
||||
|
||||
$defaults = array(
|
||||
$defaults = array(
|
||||
'clear_update_cache' => true,
|
||||
);
|
||||
$parsed_args = wp_parse_args( $args, $defaults );
|
||||
|
@ -97,28 +97,31 @@ class Plugin_Upgrader extends WP_Upgrader {
|
|||
$this->init();
|
||||
$this->install_strings();
|
||||
|
||||
add_filter('upgrader_source_selection', array($this, 'check_package') );
|
||||
add_filter( 'upgrader_source_selection', array( $this, 'check_package' ) );
|
||||
if ( $parsed_args['clear_update_cache'] ) {
|
||||
// Clear cache so wp_update_plugins() knows about the new plugin.
|
||||
add_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9, 0 );
|
||||
}
|
||||
|
||||
$this->run( array(
|
||||
'package' => $package,
|
||||
'destination' => WP_PLUGIN_DIR,
|
||||
'clear_destination' => false, // Do not overwrite files.
|
||||
'clear_working' => true,
|
||||
'hook_extra' => array(
|
||||
'type' => 'plugin',
|
||||
'action' => 'install',
|
||||
$this->run(
|
||||
array(
|
||||
'package' => $package,
|
||||
'destination' => WP_PLUGIN_DIR,
|
||||
'clear_destination' => false, // Do not overwrite files.
|
||||
'clear_working' => true,
|
||||
'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') );
|
||||
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'] );
|
||||
|
@ -143,7 +146,7 @@ class Plugin_Upgrader extends WP_Upgrader {
|
|||
*/
|
||||
public function upgrade( $plugin, $args = array() ) {
|
||||
|
||||
$defaults = array(
|
||||
$defaults = array(
|
||||
'clear_update_cache' => true,
|
||||
);
|
||||
$parsed_args = wp_parse_args( $args, $defaults );
|
||||
|
@ -152,10 +155,10 @@ class Plugin_Upgrader extends WP_Upgrader {
|
|||
$this->upgrade_strings();
|
||||
|
||||
$current = get_site_transient( 'update_plugins' );
|
||||
if ( !isset( $current->response[ $plugin ] ) ) {
|
||||
if ( ! isset( $current->response[ $plugin ] ) ) {
|
||||
$this->skin->before();
|
||||
$this->skin->set_result(false);
|
||||
$this->skin->error('up_to_date');
|
||||
$this->skin->set_result( false );
|
||||
$this->skin->error( 'up_to_date' );
|
||||
$this->skin->after();
|
||||
return false;
|
||||
}
|
||||
|
@ -163,33 +166,36 @@ class Plugin_Upgrader extends WP_Upgrader {
|
|||
// Get the URL to the zip file
|
||||
$r = $current->response[ $plugin ];
|
||||
|
||||
add_filter('upgrader_pre_install', array($this, 'deactivate_plugin_before_upgrade'), 10, 2);
|
||||
add_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'), 10, 4);
|
||||
add_filter( 'upgrader_pre_install', array( $this, 'deactivate_plugin_before_upgrade' ), 10, 2 );
|
||||
add_filter( 'upgrader_clear_destination', array( $this, 'delete_old_plugin' ), 10, 4 );
|
||||
//'source_selection' => array($this, 'source_selection'), //there's a trac ticket to move up the directory for zip's which are made a bit differently, useful for non-.org plugins.
|
||||
if ( $parsed_args['clear_update_cache'] ) {
|
||||
// Clear cache so wp_update_plugins() knows about the new plugin.
|
||||
add_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9, 0 );
|
||||
}
|
||||
|
||||
$this->run( array(
|
||||
'package' => $r->package,
|
||||
'destination' => WP_PLUGIN_DIR,
|
||||
'clear_destination' => true,
|
||||
'clear_working' => true,
|
||||
'hook_extra' => array(
|
||||
'plugin' => $plugin,
|
||||
'type' => 'plugin',
|
||||
'action' => 'update',
|
||||
),
|
||||
) );
|
||||
$this->run(
|
||||
array(
|
||||
'package' => $r->package,
|
||||
'destination' => WP_PLUGIN_DIR,
|
||||
'clear_destination' => true,
|
||||
'clear_working' => true,
|
||||
'hook_extra' => array(
|
||||
'plugin' => $plugin,
|
||||
'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'));
|
||||
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'] );
|
||||
|
@ -214,7 +220,7 @@ class Plugin_Upgrader extends WP_Upgrader {
|
|||
*/
|
||||
public function bulk_upgrade( $plugins, $args = array() ) {
|
||||
|
||||
$defaults = array(
|
||||
$defaults = array(
|
||||
'clear_update_cache' => true,
|
||||
);
|
||||
$parsed_args = wp_parse_args( $args, $defaults );
|
||||
|
@ -225,12 +231,12 @@ class Plugin_Upgrader extends WP_Upgrader {
|
|||
|
||||
$current = get_site_transient( 'update_plugins' );
|
||||
|
||||
add_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'), 10, 4);
|
||||
add_filter( 'upgrader_clear_destination', array( $this, 'delete_old_plugin' ), 10, 4 );
|
||||
|
||||
$this->skin->header();
|
||||
|
||||
// Connect to the Filesystem first.
|
||||
$res = $this->fs_connect( array(WP_CONTENT_DIR, WP_PLUGIN_DIR) );
|
||||
$res = $this->fs_connect( array( WP_CONTENT_DIR, WP_PLUGIN_DIR ) );
|
||||
if ( ! $res ) {
|
||||
$this->skin->footer();
|
||||
return false;
|
||||
|
@ -245,70 +251,77 @@ 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 )
|
||||
$maintenance = $maintenance || ( is_plugin_active( $plugin ) && isset( $current->response[ $plugin] ) );
|
||||
if ( $maintenance )
|
||||
$this->maintenance_mode(true);
|
||||
foreach ( $plugins as $plugin ) {
|
||||
$maintenance = $maintenance || ( is_plugin_active( $plugin ) && isset( $current->response[ $plugin ] ) );
|
||||
}
|
||||
if ( $maintenance ) {
|
||||
$this->maintenance_mode( true );
|
||||
}
|
||||
|
||||
$results = array();
|
||||
|
||||
$this->update_count = count($plugins);
|
||||
$this->update_count = count( $plugins );
|
||||
$this->update_current = 0;
|
||||
foreach ( $plugins as $plugin ) {
|
||||
$this->update_current++;
|
||||
$this->skin->plugin_info = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin, false, true);
|
||||
$this->skin->plugin_info = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin, false, true );
|
||||
|
||||
if ( !isset( $current->response[ $plugin ] ) ) {
|
||||
$this->skin->set_result('up_to_date');
|
||||
if ( ! isset( $current->response[ $plugin ] ) ) {
|
||||
$this->skin->set_result( 'up_to_date' );
|
||||
$this->skin->before();
|
||||
$this->skin->feedback('up_to_date');
|
||||
$this->skin->feedback( 'up_to_date' );
|
||||
$this->skin->after();
|
||||
$results[$plugin] = true;
|
||||
$results[ $plugin ] = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get the URL to the zip file.
|
||||
$r = $current->response[ $plugin ];
|
||||
|
||||
$this->skin->plugin_active = is_plugin_active($plugin);
|
||||
$this->skin->plugin_active = is_plugin_active( $plugin );
|
||||
|
||||
$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
|
||||
$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,
|
||||
),
|
||||
)
|
||||
) );
|
||||
);
|
||||
|
||||
$results[$plugin] = $this->result;
|
||||
$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);
|
||||
$this->maintenance_mode( false );
|
||||
|
||||
// Force refresh of plugin update information.
|
||||
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(
|
||||
'action' => 'update',
|
||||
'type' => 'plugin',
|
||||
'bulk' => true,
|
||||
'plugins' => $plugins,
|
||||
) );
|
||||
do_action(
|
||||
'upgrader_process_complete', $this, array(
|
||||
'action' => 'update',
|
||||
'type' => 'plugin',
|
||||
'bulk' => true,
|
||||
'plugins' => $plugins,
|
||||
)
|
||||
);
|
||||
|
||||
$this->skin->bulk_footer();
|
||||
|
||||
$this->skin->footer();
|
||||
|
||||
// Cleanup our hooks, in case something else does a upgrade on this connection.
|
||||
remove_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'));
|
||||
remove_filter( 'upgrader_clear_destination', array( $this, 'delete_old_plugin' ) );
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
@ -327,19 +340,21 @@ class Plugin_Upgrader extends WP_Upgrader {
|
|||
* @return string|WP_Error The source as passed, or a WP_Error object
|
||||
* if no plugins were found.
|
||||
*/
|
||||
public function check_package($source) {
|
||||
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.
|
||||
$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.
|
||||
return $source;
|
||||
}
|
||||
|
||||
// Check the folder contains at least 1 valid plugin.
|
||||
$plugins_found = false;
|
||||
$files = glob( $working_directory . '*.php' );
|
||||
$files = glob( $working_directory . '*.php' );
|
||||
if ( $files ) {
|
||||
foreach ( $files as $file ) {
|
||||
$info = get_plugin_data( $file, false, 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,16 +382,19 @@ 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) )
|
||||
$plugin = get_plugins( '/' . $this->result['destination_name'] ); //Ensure to pass with leading slash
|
||||
if ( empty( $plugin ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$pluginfiles = array_keys($plugin); //Assume the requested plugin is the first in the list
|
||||
$pluginfiles = array_keys( $plugin ); //Assume the requested plugin is the first in the list
|
||||
|
||||
return $this->result['destination_name'] . '/' . $pluginfiles[0];
|
||||
}
|
||||
|
@ -392,22 +411,25 @@ class Plugin_Upgrader extends WP_Upgrader {
|
|||
* @param array $plugin Plugin package arguments.
|
||||
* @return bool|WP_Error The passed in $return param or WP_Error.
|
||||
*/
|
||||
public function deactivate_plugin_before_upgrade($return, $plugin) {
|
||||
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) )
|
||||
return new WP_Error('bad_request', $this->strings['bad_request']);
|
||||
$plugin = isset( $plugin['plugin'] ) ? $plugin['plugin'] : '';
|
||||
if ( empty( $plugin ) ) {
|
||||
return new WP_Error( 'bad_request', $this->strings['bad_request'] );
|
||||
}
|
||||
|
||||
if ( is_plugin_active($plugin) ) {
|
||||
if ( is_plugin_active( $plugin ) ) {
|
||||
//Deactivate the plugin silently, Prevent deactivation hooks from running.
|
||||
deactivate_plugins($plugin, true);
|
||||
deactivate_plugins( $plugin, true );
|
||||
}
|
||||
|
||||
return $return;
|
||||
|
@ -422,37 +444,42 @@ class Plugin_Upgrader extends WP_Upgrader {
|
|||
* @since 2.8.0
|
||||
*
|
||||
* @global WP_Filesystem_Base $wp_filesystem Subclass
|
||||
*
|
||||
*
|
||||
* @param bool|WP_Error $removed
|
||||
* @param string $local_destination
|
||||
* @param string $remote_destination
|
||||
* @param array $plugin
|
||||
* @return WP_Error|bool
|
||||
*/
|
||||
public function delete_old_plugin($removed, $local_destination, $remote_destination, $plugin) {
|
||||
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) )
|
||||
return new WP_Error('bad_request', $this->strings['bad_request']);
|
||||
$plugin = isset( $plugin['plugin'] ) ? $plugin['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) );
|
||||
$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
|
||||
$deleted = $wp_filesystem->delete($this_plugin_dir, true);
|
||||
else
|
||||
$deleted = $wp_filesystem->delete($plugins_dir . $plugin);
|
||||
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 {
|
||||
$deleted = $wp_filesystem->delete( $plugins_dir . $plugin );
|
||||
}
|
||||
|
||||
if ( ! $deleted )
|
||||
return new WP_Error('remove_old_failed', $this->strings['remove_old_failed']);
|
||||
if ( ! $deleted ) {
|
||||
return new WP_Error( 'remove_old_failed', $this->strings['remove_old_failed'] );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -20,53 +20,63 @@ 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' => '' );
|
||||
$args = wp_parse_args($args, $defaults);
|
||||
public function __construct( $args = array() ) {
|
||||
$defaults = array(
|
||||
'type' => 'web',
|
||||
'url' => '',
|
||||
'theme' => '',
|
||||
'nonce' => '',
|
||||
'title' => '',
|
||||
);
|
||||
$args = wp_parse_args( $args, $defaults );
|
||||
|
||||
$this->type = $args['type'];
|
||||
$this->api = isset($args['api']) ? $args['api'] : array();
|
||||
$this->api = isset( $args['api'] ) ? $args['api'] : array();
|
||||
|
||||
parent::__construct($args);
|
||||
parent::__construct( $args );
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public function before() {
|
||||
if ( !empty($this->api) )
|
||||
$this->upgrader->strings['process_success'] = sprintf( $this->upgrader->strings['process_success_specific'], $this->api->name, $this->api->version);
|
||||
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');
|
||||
$name = $theme_info->display( 'Name' );
|
||||
$stylesheet = $this->upgrader->result['destination_name'];
|
||||
$template = $theme_info->get_template();
|
||||
|
||||
$activate_link = add_query_arg( array(
|
||||
'action' => 'activate',
|
||||
'template' => urlencode( $template ),
|
||||
'stylesheet' => urlencode( $stylesheet ),
|
||||
), admin_url('themes.php') );
|
||||
$activate_link = add_query_arg(
|
||||
array(
|
||||
'action' => 'activate',
|
||||
'template' => urlencode( $template ),
|
||||
'stylesheet' => urlencode( $stylesheet ),
|
||||
), admin_url( 'themes.php' )
|
||||
);
|
||||
$activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet );
|
||||
|
||||
$install_actions = array();
|
||||
|
||||
if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
|
||||
$customize_url = add_query_arg(
|
||||
$customize_url = add_query_arg(
|
||||
array(
|
||||
'theme' => urlencode( $stylesheet ),
|
||||
'theme' => urlencode( $stylesheet ),
|
||||
'return' => urlencode( admin_url( 'web' === $this->type ? 'theme-install.php' : 'themes.php' ) ),
|
||||
),
|
||||
admin_url( 'customize.php' )
|
||||
|
@ -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 “%s”' ), $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&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) )
|
||||
$this->feedback(implode(' | ', (array)$install_actions));
|
||||
if ( ! empty( $install_actions ) ) {
|
||||
$this->feedback( implode( ' | ', (array) $install_actions ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,16 +19,20 @@ 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') );
|
||||
$args = wp_parse_args($args, $defaults);
|
||||
public function __construct( $args = array() ) {
|
||||
$defaults = array(
|
||||
'url' => '',
|
||||
'theme' => '',
|
||||
'nonce' => '',
|
||||
'title' => __( 'Update Theme' ),
|
||||
);
|
||||
$args = wp_parse_args( $args, $defaults );
|
||||
|
||||
$this->theme = $args['theme'];
|
||||
|
||||
parent::__construct($args);
|
||||
parent::__construct( $args );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -38,27 +42,29 @@ class Theme_Upgrader_Skin extends WP_Upgrader_Skin {
|
|||
|
||||
$update_actions = array();
|
||||
if ( ! empty( $this->upgrader->result['destination_name'] ) && $theme_info = $this->upgrader->theme_info() ) {
|
||||
$name = $theme_info->display('Name');
|
||||
$name = $theme_info->display( 'Name' );
|
||||
$stylesheet = $this->upgrader->result['destination_name'];
|
||||
$template = $theme_info->get_template();
|
||||
|
||||
$activate_link = add_query_arg( array(
|
||||
'action' => 'activate',
|
||||
'template' => urlencode( $template ),
|
||||
'stylesheet' => urlencode( $stylesheet ),
|
||||
), admin_url('themes.php') );
|
||||
$activate_link = add_query_arg(
|
||||
array(
|
||||
'action' => 'activate',
|
||||
'template' => urlencode( $template ),
|
||||
'stylesheet' => urlencode( $stylesheet ),
|
||||
), admin_url( 'themes.php' )
|
||||
);
|
||||
$activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet );
|
||||
|
||||
$customize_url = add_query_arg(
|
||||
array(
|
||||
'theme' => urlencode( $stylesheet ),
|
||||
'theme' => urlencode( $stylesheet ),
|
||||
'return' => urlencode( admin_url( 'themes.php' ) ),
|
||||
),
|
||||
admin_url( 'customize.php' )
|
||||
);
|
||||
if ( get_stylesheet() == $stylesheet ) {
|
||||
if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
|
||||
$update_actions['preview'] = '<a href="' . esc_url( $customize_url ) . '" class="hide-if-no-customize load-customize"><span aria-hidden="true">' . __( 'Customize' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Customize “%s”' ), $name ) . '</span></a>';
|
||||
$update_actions['preview'] = '<a href="' . esc_url( $customize_url ) . '" class="hide-if-no-customize load-customize"><span aria-hidden="true">' . __( 'Customize' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Customize “%s”' ), $name ) . '</span></a>';
|
||||
}
|
||||
} elseif ( current_user_can( 'switch_themes' ) ) {
|
||||
if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
|
||||
|
@ -67,8 +73,9 @@ 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 “%s”' ), $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) )
|
||||
$this->feedback(implode(' | ', (array)$update_actions));
|
||||
if ( ! empty( $update_actions ) ) {
|
||||
$this->feedback( implode( ' | ', (array) $update_actions ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,15 +43,15 @@ class Theme_Upgrader extends WP_Upgrader {
|
|||
* @since 2.8.0
|
||||
*/
|
||||
public function upgrade_strings() {
|
||||
$this->strings['up_to_date'] = __('The theme is at the latest version.');
|
||||
$this->strings['no_package'] = __('Update package not available.');
|
||||
$this->strings['up_to_date'] = __( 'The theme is at the latest version.' );
|
||||
$this->strings['no_package'] = __( 'Update package not available.' );
|
||||
/* translators: %s: package URL */
|
||||
$this->strings['downloading_package'] = sprintf( __( 'Downloading update from %s…' ), '<span class="code">%s</span>' );
|
||||
$this->strings['unpack_package'] = __('Unpacking the update…');
|
||||
$this->strings['remove_old'] = __('Removing the old version of the theme…');
|
||||
$this->strings['remove_old_failed'] = __('Could not remove the old theme.');
|
||||
$this->strings['process_failed'] = __('Theme update failed.');
|
||||
$this->strings['process_success'] = __('Theme updated successfully.');
|
||||
$this->strings['unpack_package'] = __( 'Unpacking the update…' );
|
||||
$this->strings['remove_old'] = __( 'Removing the old version of the theme…' );
|
||||
$this->strings['remove_old_failed'] = __( 'Could not remove the old theme.' );
|
||||
$this->strings['process_failed'] = __( 'Theme update failed.' );
|
||||
$this->strings['process_success'] = __( 'Theme updated successfully.' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -60,23 +60,23 @@ class Theme_Upgrader extends WP_Upgrader {
|
|||
* @since 2.8.0
|
||||
*/
|
||||
public function install_strings() {
|
||||
$this->strings['no_package'] = __('Installation package not available.');
|
||||
$this->strings['no_package'] = __( 'Installation package not available.' );
|
||||
/* translators: %s: package URL */
|
||||
$this->strings['downloading_package'] = sprintf( __( 'Downloading installation package from %s…' ), '<span class="code">%s</span>' );
|
||||
$this->strings['unpack_package'] = __('Unpacking the package…');
|
||||
$this->strings['installing_package'] = __('Installing the theme…');
|
||||
$this->strings['no_files'] = __('The theme contains no files.');
|
||||
$this->strings['process_failed'] = __('Theme installation failed.');
|
||||
$this->strings['process_success'] = __('Theme installed successfully.');
|
||||
$this->strings['unpack_package'] = __( 'Unpacking the package…' );
|
||||
$this->strings['installing_package'] = __( 'Installing the theme…' );
|
||||
$this->strings['no_files'] = __( 'The theme contains no files.' );
|
||||
$this->strings['process_failed'] = __( 'Theme installation failed.' );
|
||||
$this->strings['process_success'] = __( 'Theme installed successfully.' );
|
||||
/* translators: 1: theme name, 2: version */
|
||||
$this->strings['process_success_specific'] = __('Successfully installed the theme <strong>%1$s %2$s</strong>.');
|
||||
$this->strings['parent_theme_search'] = __('This theme requires a parent theme. Checking if it is installed…');
|
||||
$this->strings['process_success_specific'] = __( 'Successfully installed the theme <strong>%1$s %2$s</strong>.' );
|
||||
$this->strings['parent_theme_search'] = __( 'This theme requires a parent theme. Checking if it is installed…' );
|
||||
/* translators: 1: theme name, 2: version */
|
||||
$this->strings['parent_theme_prepare_install'] = __('Preparing to install <strong>%1$s %2$s</strong>…');
|
||||
$this->strings['parent_theme_prepare_install'] = __( 'Preparing to install <strong>%1$s %2$s</strong>…' );
|
||||
/* translators: 1: theme name, 2: version */
|
||||
$this->strings['parent_theme_currently_installed'] = __('The parent theme, <strong>%1$s %2$s</strong>, is currently installed.');
|
||||
$this->strings['parent_theme_currently_installed'] = __( 'The parent theme, <strong>%1$s %2$s</strong>, is currently installed.' );
|
||||
/* translators: 1: theme name, 2: version */
|
||||
$this->strings['parent_theme_install_success'] = __('Successfully installed the parent theme, <strong>%1$s %2$s</strong>.');
|
||||
$this->strings['parent_theme_install_success'] = __( 'Successfully installed the parent theme, <strong>%1$s %2$s</strong>.' );
|
||||
/* translators: %s: theme name */
|
||||
$this->strings['parent_theme_not_found'] = sprintf( __( '<strong>The parent theme could not be found.</strong> You will need to install the parent theme, %s, before you can use this child theme.' ), '<strong>%s</strong>' );
|
||||
}
|
||||
|
@ -97,56 +97,68 @@ 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' );
|
||||
|
||||
if ( ! $theme_info->parent()->errors() ) {
|
||||
$this->skin->feedback( 'parent_theme_currently_installed', $theme_info->parent()->display('Name'), $theme_info->parent()->display('Version') );
|
||||
$this->skin->feedback( 'parent_theme_currently_installed', $theme_info->parent()->display( 'Name' ), $theme_info->parent()->display( 'Version' ) );
|
||||
// We already have the theme, fall through.
|
||||
return $install_result;
|
||||
}
|
||||
|
||||
// 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') );
|
||||
if ( ! $api || is_wp_error( $api ) ) {
|
||||
$this->skin->feedback( 'parent_theme_not_found', $theme_info->get( 'Template' ) );
|
||||
// Don't show activate or preview actions after installation
|
||||
add_filter('install_theme_complete_actions', array($this, 'hide_activate_preview_actions') );
|
||||
add_filter( 'install_theme_complete_actions', array( $this, 'hide_activate_preview_actions' ) );
|
||||
return $install_result;
|
||||
}
|
||||
|
||||
// Backup required data we're going to override:
|
||||
$child_api = $this->skin->api;
|
||||
$child_api = $this->skin->api;
|
||||
$child_success_message = $this->strings['process_success'];
|
||||
|
||||
// Override them
|
||||
$this->skin->api = $api;
|
||||
$this->skin->api = $api;
|
||||
$this->strings['process_success_specific'] = $this->strings['parent_theme_install_success'];//, $api->name, $api->version);
|
||||
|
||||
$this->skin->feedback('parent_theme_prepare_install', $api->name, $api->version);
|
||||
$this->skin->feedback( 'parent_theme_prepare_install', $api->name, $api->version );
|
||||
|
||||
add_filter('install_theme_complete_actions', '__return_false', 999); // Don't show any actions after installing the theme.
|
||||
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(
|
||||
'package' => $api->download_link,
|
||||
'destination' => get_theme_root(),
|
||||
'clear_destination' => false, //Do not overwrite files.
|
||||
'clear_working' => true
|
||||
) );
|
||||
$parent_result = $this->run(
|
||||
array(
|
||||
'package' => $api->download_link,
|
||||
'destination' => get_theme_root(),
|
||||
'clear_destination' => false, //Do not overwrite files.
|
||||
'clear_working' => true,
|
||||
)
|
||||
);
|
||||
|
||||
if ( is_wp_error($parent_result) )
|
||||
add_filter('install_theme_complete_actions', array($this, 'hide_activate_preview_actions') );
|
||||
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);
|
||||
remove_filter( 'install_theme_complete_actions', '__return_false', 999 );
|
||||
|
||||
// Reset child's result and data
|
||||
$this->result = $child_result;
|
||||
$this->skin->api = $child_api;
|
||||
$this->result = $child_result;
|
||||
$this->skin->api = $child_api;
|
||||
$this->strings['process_success'] = $child_success_message;
|
||||
|
||||
return $install_result;
|
||||
|
@ -165,7 +177,7 @@ class Theme_Upgrader extends WP_Upgrader {
|
|||
* @return array
|
||||
*/
|
||||
public function hide_activate_preview_actions( $actions ) {
|
||||
unset($actions['activate'], $actions['preview']);
|
||||
unset( $actions['activate'], $actions['preview'] );
|
||||
return $actions;
|
||||
}
|
||||
|
||||
|
@ -187,7 +199,7 @@ class Theme_Upgrader extends WP_Upgrader {
|
|||
*/
|
||||
public function install( $package, $args = array() ) {
|
||||
|
||||
$defaults = array(
|
||||
$defaults = array(
|
||||
'clear_update_cache' => true,
|
||||
);
|
||||
$parsed_args = wp_parse_args( $args, $defaults );
|
||||
|
@ -195,30 +207,33 @@ class Theme_Upgrader extends WP_Upgrader {
|
|||
$this->init();
|
||||
$this->install_strings();
|
||||
|
||||
add_filter('upgrader_source_selection', array($this, 'check_package') );
|
||||
add_filter('upgrader_post_install', array($this, 'check_parent_theme_filter'), 10, 3);
|
||||
add_filter( 'upgrader_source_selection', array( $this, 'check_package' ) );
|
||||
add_filter( 'upgrader_post_install', array( $this, 'check_parent_theme_filter' ), 10, 3 );
|
||||
if ( $parsed_args['clear_update_cache'] ) {
|
||||
// Clear cache so wp_update_themes() knows about the new theme.
|
||||
add_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9, 0 );
|
||||
}
|
||||
|
||||
$this->run( array(
|
||||
'package' => $package,
|
||||
'destination' => get_theme_root(),
|
||||
'clear_destination' => false, //Do not overwrite files.
|
||||
'clear_working' => true,
|
||||
'hook_extra' => array(
|
||||
'type' => 'theme',
|
||||
'action' => 'install',
|
||||
),
|
||||
) );
|
||||
$this->run(
|
||||
array(
|
||||
'package' => $package,
|
||||
'destination' => get_theme_root(),
|
||||
'clear_destination' => false, //Do not overwrite files.
|
||||
'clear_working' => true,
|
||||
'hook_extra' => array(
|
||||
'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'));
|
||||
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'] );
|
||||
|
@ -243,7 +258,7 @@ class Theme_Upgrader extends WP_Upgrader {
|
|||
*/
|
||||
public function upgrade( $theme, $args = array() ) {
|
||||
|
||||
$defaults = array(
|
||||
$defaults = array(
|
||||
'clear_update_cache' => true,
|
||||
);
|
||||
$parsed_args = wp_parse_args( $args, $defaults );
|
||||
|
@ -253,9 +268,9 @@ class Theme_Upgrader extends WP_Upgrader {
|
|||
|
||||
// Is an update available?
|
||||
$current = get_site_transient( 'update_themes' );
|
||||
if ( !isset( $current->response[ $theme ] ) ) {
|
||||
if ( ! isset( $current->response[ $theme ] ) ) {
|
||||
$this->skin->before();
|
||||
$this->skin->set_result(false);
|
||||
$this->skin->set_result( false );
|
||||
$this->skin->error( 'up_to_date' );
|
||||
$this->skin->after();
|
||||
return false;
|
||||
|
@ -263,33 +278,36 @@ class Theme_Upgrader extends WP_Upgrader {
|
|||
|
||||
$r = $current->response[ $theme ];
|
||||
|
||||
add_filter('upgrader_pre_install', array($this, 'current_before'), 10, 2);
|
||||
add_filter('upgrader_post_install', array($this, 'current_after'), 10, 2);
|
||||
add_filter('upgrader_clear_destination', array($this, 'delete_old_theme'), 10, 4);
|
||||
add_filter( 'upgrader_pre_install', array( $this, 'current_before' ), 10, 2 );
|
||||
add_filter( 'upgrader_post_install', array( $this, 'current_after' ), 10, 2 );
|
||||
add_filter( 'upgrader_clear_destination', array( $this, 'delete_old_theme' ), 10, 4 );
|
||||
if ( $parsed_args['clear_update_cache'] ) {
|
||||
// Clear cache so wp_update_themes() knows about the new theme.
|
||||
add_action( 'upgrader_process_complete', 'wp_clean_themes_cache', 9, 0 );
|
||||
}
|
||||
|
||||
$this->run( array(
|
||||
'package' => $r['package'],
|
||||
'destination' => get_theme_root( $theme ),
|
||||
'clear_destination' => true,
|
||||
'clear_working' => true,
|
||||
'hook_extra' => array(
|
||||
'theme' => $theme,
|
||||
'type' => 'theme',
|
||||
'action' => 'update',
|
||||
),
|
||||
) );
|
||||
$this->run(
|
||||
array(
|
||||
'package' => $r['package'],
|
||||
'destination' => get_theme_root( $theme ),
|
||||
'clear_destination' => true,
|
||||
'clear_working' => true,
|
||||
'hook_extra' => array(
|
||||
'theme' => $theme,
|
||||
'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'));
|
||||
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'] );
|
||||
|
||||
|
@ -313,7 +331,7 @@ class Theme_Upgrader extends WP_Upgrader {
|
|||
*/
|
||||
public function bulk_upgrade( $themes, $args = array() ) {
|
||||
|
||||
$defaults = array(
|
||||
$defaults = array(
|
||||
'clear_update_cache' => true,
|
||||
);
|
||||
$parsed_args = wp_parse_args( $args, $defaults );
|
||||
|
@ -324,14 +342,14 @@ class Theme_Upgrader extends WP_Upgrader {
|
|||
|
||||
$current = get_site_transient( 'update_themes' );
|
||||
|
||||
add_filter('upgrader_pre_install', array($this, 'current_before'), 10, 2);
|
||||
add_filter('upgrader_post_install', array($this, 'current_after'), 10, 2);
|
||||
add_filter('upgrader_clear_destination', array($this, 'delete_old_theme'), 10, 4);
|
||||
add_filter( 'upgrader_pre_install', array( $this, 'current_before' ), 10, 2 );
|
||||
add_filter( 'upgrader_post_install', array( $this, 'current_after' ), 10, 2 );
|
||||
add_filter( 'upgrader_clear_destination', array( $this, 'delete_old_theme' ), 10, 4 );
|
||||
|
||||
$this->skin->header();
|
||||
|
||||
// Connect to the Filesystem first.
|
||||
$res = $this->fs_connect( array(WP_CONTENT_DIR) );
|
||||
$res = $this->fs_connect( array( WP_CONTENT_DIR ) );
|
||||
if ( ! $res ) {
|
||||
$this->skin->footer();
|
||||
return false;
|
||||
|
@ -344,71 +362,78 @@ 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 )
|
||||
$this->maintenance_mode(true);
|
||||
}
|
||||
if ( $maintenance ) {
|
||||
$this->maintenance_mode( true );
|
||||
}
|
||||
|
||||
$results = array();
|
||||
|
||||
$this->update_count = count($themes);
|
||||
$this->update_count = count( $themes );
|
||||
$this->update_current = 0;
|
||||
foreach ( $themes as $theme ) {
|
||||
$this->update_current++;
|
||||
|
||||
$this->skin->theme_info = $this->theme_info($theme);
|
||||
$this->skin->theme_info = $this->theme_info( $theme );
|
||||
|
||||
if ( !isset( $current->response[ $theme ] ) ) {
|
||||
$this->skin->set_result(true);
|
||||
if ( ! isset( $current->response[ $theme ] ) ) {
|
||||
$this->skin->set_result( true );
|
||||
$this->skin->before();
|
||||
$this->skin->feedback( 'up_to_date' );
|
||||
$this->skin->after();
|
||||
$results[$theme] = true;
|
||||
$results[ $theme ] = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get the URL to the zip file
|
||||
$r = $current->response[ $theme ];
|
||||
|
||||
$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
|
||||
),
|
||||
) );
|
||||
$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,
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
$results[$theme] = $this->result;
|
||||
$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);
|
||||
$this->maintenance_mode( false );
|
||||
|
||||
// Refresh the Theme Update information
|
||||
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(
|
||||
'action' => 'update',
|
||||
'type' => 'theme',
|
||||
'bulk' => true,
|
||||
'themes' => $themes,
|
||||
) );
|
||||
do_action(
|
||||
'upgrader_process_complete', $this, array(
|
||||
'action' => 'update',
|
||||
'type' => 'theme',
|
||||
'bulk' => true,
|
||||
'themes' => $themes,
|
||||
)
|
||||
);
|
||||
|
||||
$this->skin->bulk_footer();
|
||||
|
||||
$this->skin->footer();
|
||||
|
||||
// Cleanup our hooks, in case something else does a upgrade on this connection.
|
||||
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'));
|
||||
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' ) );
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
@ -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.
|
||||
$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.
|
||||
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’t contain a valid theme header.' ),
|
||||
sprintf(
|
||||
__( 'The %s stylesheet doesn’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>'
|
||||
)
|
||||
);
|
||||
|
@ -484,17 +522,20 @@ class Theme_Upgrader extends WP_Upgrader {
|
|||
* @param array $theme
|
||||
* @return bool|WP_Error
|
||||
*/
|
||||
public function current_before($return, $theme) {
|
||||
if ( is_wp_error($return) )
|
||||
public function current_before( $return, $theme ) {
|
||||
if ( is_wp_error( $return ) ) {
|
||||
return $return;
|
||||
}
|
||||
|
||||
$theme = isset($theme['theme']) ? $theme['theme'] : '';
|
||||
$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 )
|
||||
$this->maintenance_mode(true);
|
||||
if ( ! $this->bulk ) {
|
||||
$this->maintenance_mode( true );
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
@ -511,14 +552,16 @@ class Theme_Upgrader extends WP_Upgrader {
|
|||
* @param array $theme
|
||||
* @return bool|WP_Error
|
||||
*/
|
||||
public function current_after($return, $theme) {
|
||||
if ( is_wp_error($return) )
|
||||
public function current_after( $return, $theme ) {
|
||||
if ( is_wp_error( $return ) ) {
|
||||
return $return;
|
||||
}
|
||||
|
||||
$theme = isset($theme['theme']) ? $theme['theme'] : '';
|
||||
$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 )
|
||||
$this->maintenance_mode(false);
|
||||
if ( ! $this->bulk ) {
|
||||
$this->maintenance_mode( false );
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
@ -552,17 +596,20 @@ 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'];
|
||||
$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;
|
||||
|
@ -579,13 +626,14 @@ class Theme_Upgrader extends WP_Upgrader {
|
|||
* @return WP_Theme|false The theme's info object, or false `$theme` is not supplied
|
||||
* and the last result isn't set.
|
||||
*/
|
||||
public function theme_info($theme = null) {
|
||||
public function theme_info( $theme = null ) {
|
||||
|
||||
if ( empty($theme) ) {
|
||||
if ( !empty($this->result['destination_name']) )
|
||||
if ( empty( $theme ) ) {
|
||||
if ( ! empty( $this->result['destination_name'] ) ) {
|
||||
$theme = $this->result['destination_name'];
|
||||
else
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return wp_get_theme( $theme );
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
@ -32,7 +35,7 @@ class Walker_Category_Checklist extends Walker {
|
|||
* @param array $args An array of arguments. @see wp_terms_checklist()
|
||||
*/
|
||||
public function start_lvl( &$output, $depth = 0, $args = array() ) {
|
||||
$indent = str_repeat("\t", $depth);
|
||||
$indent = str_repeat( "\t", $depth );
|
||||
$output .= "$indent<ul class='children'>\n";
|
||||
}
|
||||
|
||||
|
@ -48,7 +51,7 @@ class Walker_Category_Checklist extends Walker {
|
|||
* @param array $args An array of arguments. @see wp_terms_checklist()
|
||||
*/
|
||||
public function end_lvl( &$output, $depth = 0, $args = array() ) {
|
||||
$indent = str_repeat("\t", $depth);
|
||||
$indent = str_repeat( "\t", $depth );
|
||||
$output .= "$indent</ul>\n";
|
||||
}
|
||||
|
||||
|
@ -79,13 +82,13 @@ class Walker_Category_Checklist extends Walker {
|
|||
}
|
||||
|
||||
$args['popular_cats'] = empty( $args['popular_cats'] ) ? array() : $args['popular_cats'];
|
||||
$class = in_array( $category->term_id, $args['popular_cats'] ) ? ' class="popular-category"' : '';
|
||||
$class = in_array( $category->term_id, $args['popular_cats'] ) ? ' class="popular-category"' : '';
|
||||
|
||||
$args['selected_cats'] = empty( $args['selected_cats'] ) ? array() : $args['selected_cats'];
|
||||
|
||||
if ( ! empty( $args['list_only'] ) ) {
|
||||
$aria_checked = 'false';
|
||||
$inner_class = 'category';
|
||||
$inner_class = 'category';
|
||||
|
||||
if ( in_array( $category->term_id, $args['selected_cats'] ) ) {
|
||||
$inner_class .= ' selected';
|
||||
|
@ -100,7 +103,7 @@ class Walker_Category_Checklist extends Walker {
|
|||
} else {
|
||||
/** This filter is documented in wp-includes/category-template.php */
|
||||
$output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>" .
|
||||
'<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="'.$name.'[]" id="in-'.$taxonomy.'-' . $category->term_id . '"' .
|
||||
'<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="' . $name . '[]" id="in-' . $taxonomy . '-' . $category->term_id . '"' .
|
||||
checked( in_array( $category->term_id, $args['selected_cats'] ), true, false ) .
|
||||
disabled( empty( $args['disabled'] ), false, false ) . ' /> ' .
|
||||
esc_html( apply_filters( 'the_category', $category->name, '', '' ) ) . '</label>';
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
*/
|
||||
class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu {
|
||||
/**
|
||||
*
|
||||
* @param array $fields
|
||||
*/
|
||||
public function __construct( $fields = false ) {
|
||||
|
@ -36,7 +35,7 @@ class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu {
|
|||
* @param array $args Not used.
|
||||
*/
|
||||
public function start_lvl( &$output, $depth = 0, $args = array() ) {
|
||||
$indent = str_repeat( "\t", $depth );
|
||||
$indent = str_repeat( "\t", $depth );
|
||||
$output .= "\n$indent<ul class='children'>\n";
|
||||
}
|
||||
|
||||
|
@ -52,7 +51,7 @@ class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu {
|
|||
* @param array $args Not used.
|
||||
*/
|
||||
public function end_lvl( &$output, $depth = 0, $args = array() ) {
|
||||
$indent = str_repeat( "\t", $depth );
|
||||
$indent = str_repeat( "\t", $depth );
|
||||
$output .= "\n$indent</ul>";
|
||||
}
|
||||
|
||||
|
@ -74,9 +73,9 @@ class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu {
|
|||
public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
|
||||
global $_nav_menu_placeholder;
|
||||
|
||||
$_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1;
|
||||
$possible_object_id = isset( $item->post_type ) && 'nav_menu_item' == $item->post_type ? $item->object_id : $_nav_menu_placeholder;
|
||||
$possible_db_id = ( ! empty( $item->ID ) ) && ( 0 < $possible_object_id ) ? (int) $item->ID : 0;
|
||||
$_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval( $_nav_menu_placeholder ) - 1 : -1;
|
||||
$possible_object_id = isset( $item->post_type ) && 'nav_menu_item' == $item->post_type ? $item->object_id : $_nav_menu_placeholder;
|
||||
$possible_db_id = ( ! empty( $item->ID ) ) && ( 0 < $possible_object_id ) ? (int) $item->ID : 0;
|
||||
|
||||
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
|
||||
|
||||
|
@ -84,34 +83,36 @@ 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 ) .'" /> ';
|
||||
$output .= '" name="menu-item[' . $possible_object_id . '][menu-item-object-id]" value="' . esc_attr( $item->object_id ) . '" /> ';
|
||||
|
||||
if ( ! empty( $item->label ) ) {
|
||||
$title = $item->label;
|
||||
} 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>';
|
||||
$output .= '</label>';
|
||||
|
||||
// Menu item hidden fields
|
||||
$output .= '<input type="hidden" class="menu-item-db-id" name="menu-item[' . $possible_object_id . '][menu-item-db-id]" value="' . $possible_db_id . '" />';
|
||||
$output .= '<input type="hidden" class="menu-item-object" name="menu-item[' . $possible_object_id . '][menu-item-object]" value="'. esc_attr( $item->object ) .'" />';
|
||||
$output .= '<input type="hidden" class="menu-item-parent-id" name="menu-item[' . $possible_object_id . '][menu-item-parent-id]" value="'. esc_attr( $item->menu_item_parent ) .'" />';
|
||||
$output .= '<input type="hidden" class="menu-item-type" name="menu-item[' . $possible_object_id . '][menu-item-type]" value="'. esc_attr( $item->type ) .'" />';
|
||||
$output .= '<input type="hidden" class="menu-item-title" name="menu-item[' . $possible_object_id . '][menu-item-title]" value="'. esc_attr( $item->title ) .'" />';
|
||||
$output .= '<input type="hidden" class="menu-item-url" name="menu-item[' . $possible_object_id . '][menu-item-url]" value="'. esc_attr( $item->url ) .'" />';
|
||||
$output .= '<input type="hidden" class="menu-item-target" name="menu-item[' . $possible_object_id . '][menu-item-target]" value="'. esc_attr( $item->target ) .'" />';
|
||||
$output .= '<input type="hidden" class="menu-item-attr_title" name="menu-item[' . $possible_object_id . '][menu-item-attr_title]" value="'. esc_attr( $item->attr_title ) .'" />';
|
||||
$output .= '<input type="hidden" class="menu-item-classes" name="menu-item[' . $possible_object_id . '][menu-item-classes]" value="'. esc_attr( implode( ' ', $item->classes ) ) .'" />';
|
||||
$output .= '<input type="hidden" class="menu-item-xfn" name="menu-item[' . $possible_object_id . '][menu-item-xfn]" value="'. esc_attr( $item->xfn ) .'" />';
|
||||
$output .= '<input type="hidden" class="menu-item-object" name="menu-item[' . $possible_object_id . '][menu-item-object]" value="' . esc_attr( $item->object ) . '" />';
|
||||
$output .= '<input type="hidden" class="menu-item-parent-id" name="menu-item[' . $possible_object_id . '][menu-item-parent-id]" value="' . esc_attr( $item->menu_item_parent ) . '" />';
|
||||
$output .= '<input type="hidden" class="menu-item-type" name="menu-item[' . $possible_object_id . '][menu-item-type]" value="' . esc_attr( $item->type ) . '" />';
|
||||
$output .= '<input type="hidden" class="menu-item-title" name="menu-item[' . $possible_object_id . '][menu-item-title]" value="' . esc_attr( $item->title ) . '" />';
|
||||
$output .= '<input type="hidden" class="menu-item-url" name="menu-item[' . $possible_object_id . '][menu-item-url]" value="' . esc_attr( $item->url ) . '" />';
|
||||
$output .= '<input type="hidden" class="menu-item-target" name="menu-item[' . $possible_object_id . '][menu-item-target]" value="' . esc_attr( $item->target ) . '" />';
|
||||
$output .= '<input type="hidden" class="menu-item-attr_title" name="menu-item[' . $possible_object_id . '][menu-item-attr_title]" value="' . esc_attr( $item->attr_title ) . '" />';
|
||||
$output .= '<input type="hidden" class="menu-item-classes" name="menu-item[' . $possible_object_id . '][menu-item-classes]" value="' . esc_attr( implode( ' ', $item->classes ) ) . '" />';
|
||||
$output .= '<input type="hidden" class="menu-item-xfn" name="menu-item[' . $possible_object_id . '][menu-item-xfn]" value="' . esc_attr( $item->xfn ) . '" />';
|
||||
}
|
||||
|
||||
} // Walker_Nav_Menu_Checklist
|
||||
|
|
|
@ -60,7 +60,7 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
|
|||
$_wp_nav_menu_max_depth = $depth > $_wp_nav_menu_max_depth ? $depth : $_wp_nav_menu_max_depth;
|
||||
|
||||
ob_start();
|
||||
$item_id = esc_attr( $item->ID );
|
||||
$item_id = esc_attr( $item->ID );
|
||||
$removed_args = array(
|
||||
'action',
|
||||
'customlink-tab',
|
||||
|
@ -73,11 +73,12 @@ 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 );
|
||||
$original_title = get_the_title( $original_object->ID );
|
||||
} elseif ( 'post_type_archive' == $item->type ) {
|
||||
$original_object = get_post_type_object( $item->object );
|
||||
if ( $original_object ) {
|
||||
|
@ -88,7 +89,7 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
|
|||
$classes = array(
|
||||
'menu-item menu-item-depth-' . $depth,
|
||||
'menu-item-' . esc_attr( $item->object ),
|
||||
'menu-item-edit-' . ( ( isset( $_GET['edit-menu-item'] ) && $item_id == $_GET['edit-menu-item'] ) ? 'active' : 'inactive'),
|
||||
'menu-item-edit-' . ( ( isset( $_GET['edit-menu-item'] ) && $item_id == $_GET['edit-menu-item'] ) ? 'active' : 'inactive' ),
|
||||
);
|
||||
|
||||
$title = $item->title;
|
||||
|
@ -100,52 +101,59 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
|
|||
} elseif ( isset( $item->post_status ) && 'draft' == $item->post_status ) {
|
||||
$classes[] = 'pending';
|
||||
/* translators: %s: title of menu item in draft status */
|
||||
$title = sprintf( __('%s (Pending)'), $item->title );
|
||||
$title = sprintf( __( '%s (Pending)' ), $item->title );
|
||||
}
|
||||
|
||||
$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 ); ?>">
|
||||
<li id="menu-item-<?php echo $item_id; ?>" class="<?php echo implode( ' ', $classes ); ?>">
|
||||
<div class="menu-item-bar">
|
||||
<div class="menu-item-handle">
|
||||
<span class="item-title"><span class="menu-item-title"><?php echo esc_html( $title ); ?></span> <span class="is-submenu" <?php echo $submenu_text; ?>><?php _e( 'sub item' ); ?></span></span>
|
||||
<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(
|
||||
'action' => 'move-up-menu-item',
|
||||
'action' => 'move-up-menu-item',
|
||||
'menu-item' => $item_id,
|
||||
),
|
||||
remove_query_arg($removed_args, admin_url( 'nav-menus.php' ) )
|
||||
remove_query_arg( $removed_args, admin_url( 'nav-menus.php' ) )
|
||||
),
|
||||
'move-menu_item'
|
||||
);
|
||||
?>" class="item-move-up" aria-label="<?php esc_attr_e( 'Move up' ) ?>">↑</a>
|
||||
?>
|
||||
" class="item-move-up" aria-label="<?php esc_attr_e( 'Move up' ); ?>">↑</a>
|
||||
|
|
||||
<a href="<?php
|
||||
<a href="
|
||||
<?php
|
||||
echo wp_nonce_url(
|
||||
add_query_arg(
|
||||
array(
|
||||
'action' => 'move-down-menu-item',
|
||||
'action' => 'move-down-menu-item',
|
||||
'menu-item' => $item_id,
|
||||
),
|
||||
remove_query_arg($removed_args, admin_url( 'nav-menus.php' ) )
|
||||
remove_query_arg( $removed_args, admin_url( 'nav-menus.php' ) )
|
||||
),
|
||||
'move-menu_item'
|
||||
);
|
||||
?>" class="item-move-down" aria-label="<?php esc_attr_e( 'Move down' ) ?>">↓</a>
|
||||
?>
|
||||
" class="item-move-down" aria-label="<?php esc_attr_e( 'Move down' ); ?>">↓</a>
|
||||
</span>
|
||||
<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>
|
||||
<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>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -180,7 +188,7 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
|
|||
<p class="field-css-classes description description-thin">
|
||||
<label for="edit-menu-item-classes-<?php echo $item_id; ?>">
|
||||
<?php _e( 'CSS Classes (optional)' ); ?><br />
|
||||
<input type="text" id="edit-menu-item-classes-<?php echo $item_id; ?>" class="widefat code edit-menu-item-classes" name="menu-item-classes[<?php echo $item_id; ?>]" value="<?php echo esc_attr( implode(' ', $item->classes ) ); ?>" />
|
||||
<input type="text" id="edit-menu-item-classes-<?php echo $item_id; ?>" class="widefat code edit-menu-item-classes" name="menu-item-classes[<?php echo $item_id; ?>]" value="<?php echo esc_attr( implode( ' ', $item->classes ) ); ?>" />
|
||||
</label>
|
||||
</p>
|
||||
<p class="field-xfn description description-thin">
|
||||
|
@ -193,7 +201,7 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
|
|||
<label for="edit-menu-item-description-<?php echo $item_id; ?>">
|
||||
<?php _e( 'Description' ); ?><br />
|
||||
<textarea id="edit-menu-item-description-<?php echo $item_id; ?>" class="widefat edit-menu-item-description" rows="3" cols="20" name="menu-item-description[<?php echo $item_id; ?>]"><?php echo esc_html( $item->description ); // textarea_escaped ?></textarea>
|
||||
<span class="description"><?php _e('The description will be displayed in the menu if the current theme supports it.'); ?></span>
|
||||
<span class="description"><?php _e( 'The description will be displayed in the menu if the current theme supports it.' ); ?></span>
|
||||
</label>
|
||||
</p>
|
||||
|
||||
|
@ -209,21 +217,34 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
|
|||
<div class="menu-item-actions description-wide submitbox">
|
||||
<?php if ( 'custom' != $item->type && $original_title !== false ) : ?>
|
||||
<p class="link-to-original">
|
||||
<?php printf( __('Original: %s'), '<a href="' . esc_attr( $item->url ) . '">' . esc_html( $original_title ) . '</a>' ); ?>
|
||||
<?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
|
||||
echo wp_nonce_url(
|
||||
<a class="item-delete submitdelete deletion" id="delete-<?php echo $item_id; ?>" href="
|
||||
<?php
|
||||
echo wp_nonce_url(
|
||||
add_query_arg(
|
||||
array(
|
||||
'action' => 'delete-menu-item',
|
||||
'menu-item' => $item_id,
|
||||
),
|
||||
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(
|
||||
'action' => 'delete-menu-item',
|
||||
'menu-item' => $item_id,
|
||||
),
|
||||
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>
|
||||
'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; ?>" />
|
||||
|
|
|
@ -95,7 +95,7 @@ class WP_Ajax_Upgrader_Skin extends Automatic_Upgrader_Skin {
|
|||
|
||||
// Count existing errors to generate an unique error code.
|
||||
$errors_count = count( $this->errors->get_error_codes() );
|
||||
$this->errors->add( 'unknown_upgrade_error_' . $errors_count + 1 , $string );
|
||||
$this->errors->add( 'unknown_upgrade_error_' . $errors_count + 1, $string );
|
||||
} elseif ( is_wp_error( $errors ) ) {
|
||||
foreach ( $errors->get_error_codes() as $error_code ) {
|
||||
$this->errors->add( $error_code, $errors->get_error_message( $error_code ), $errors->get_error_data( $error_code ) );
|
||||
|
|
|
@ -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,10 +73,11 @@ 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' );
|
||||
$vcs_dirs = array( '.svn', '.git', '.hg', '.bzr' );
|
||||
$check_dirs = array();
|
||||
|
||||
foreach ( $context_dirs as $context_dir ) {
|
||||
|
@ -83,10 +86,11 @@ 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.
|
||||
// Continue one level at a time.
|
||||
} while ( $context_dir = dirname( $context_dir ) );
|
||||
}
|
||||
|
||||
|
@ -95,8 +99,9 @@ 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,13 +194,15 @@ 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.
|
||||
|
@ -298,19 +312,19 @@ class WP_Automatic_Updater {
|
|||
break;
|
||||
case 'theme':
|
||||
$upgrader_item = $item->theme;
|
||||
$theme = wp_get_theme( $upgrader_item );
|
||||
$item_name = $theme->Get( 'Name' );
|
||||
$theme = wp_get_theme( $upgrader_item );
|
||||
$item_name = $theme->Get( 'Name' );
|
||||
$skin->feedback( __( 'Updating theme: %s' ), $item_name );
|
||||
break;
|
||||
case 'plugin':
|
||||
$upgrader_item = $item->plugin;
|
||||
$plugin_data = get_plugin_data( $context . '/' . $upgrader_item );
|
||||
$item_name = $plugin_data['Name'];
|
||||
$plugin_data = get_plugin_data( $context . '/' . $upgrader_item );
|
||||
$item_name = $plugin_data['Name'];
|
||||
$skin->feedback( __( 'Updating plugin: %s' ), $item_name );
|
||||
break;
|
||||
case 'translation':
|
||||
$language_item_name = $upgrader->get_name_for_update( $item );
|
||||
$item_name = sprintf( __( 'Translations for %s' ), $language_item_name );
|
||||
$item_name = sprintf( __( 'Translations for %s' ), $language_item_name );
|
||||
$skin->feedback( sprintf( __( 'Updating translations for %1$s (%2$s)…' ), $language_item_name, $item->language ) );
|
||||
break;
|
||||
}
|
||||
|
@ -321,15 +335,17 @@ class WP_Automatic_Updater {
|
|||
}
|
||||
|
||||
// Boom, This sites about to get a whole new splash of paint!
|
||||
$upgrade_result = $upgrader->upgrade( $upgrader_item, array(
|
||||
'clear_update_cache' => false,
|
||||
// Always use partial builds if possible for core updates.
|
||||
'pre_check_md5' => false,
|
||||
// Only available for core updates.
|
||||
'attempt_rollback' => true,
|
||||
// Allow relaxed file ownership in some scenarios
|
||||
'allow_relaxed_file_ownership' => $allow_relaxed_file_ownership,
|
||||
) );
|
||||
$upgrade_result = $upgrader->upgrade(
|
||||
$upgrader_item, array(
|
||||
'clear_update_cache' => false,
|
||||
// Always use partial builds if possible for core updates.
|
||||
'pre_check_md5' => false,
|
||||
// Only available for core updates.
|
||||
'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 );
|
||||
|
@ -384,7 +403,7 @@ class WP_Automatic_Updater {
|
|||
// Next, Plugins
|
||||
wp_update_plugins(); // Check for Plugin updates
|
||||
$plugin_updates = get_site_transient( 'update_plugins' );
|
||||
if ( $plugin_updates && !empty( $plugin_updates->response ) ) {
|
||||
if ( $plugin_updates && ! empty( $plugin_updates->response ) ) {
|
||||
foreach ( $plugin_updates->response as $plugin ) {
|
||||
$this->update( 'plugin', $plugin );
|
||||
}
|
||||
|
@ -395,7 +414,7 @@ class WP_Automatic_Updater {
|
|||
// Next, those themes we all love
|
||||
wp_update_themes(); // Check for Theme updates
|
||||
$theme_updates = get_site_transient( 'update_themes' );
|
||||
if ( $theme_updates && !empty( $theme_updates->response ) ) {
|
||||
if ( $theme_updates && ! empty( $theme_updates->response ) ) {
|
||||
foreach ( $theme_updates->response as $theme ) {
|
||||
$this->update( 'theme', (object) $theme );
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -503,7 +525,7 @@ class WP_Automatic_Updater {
|
|||
$critical = true;
|
||||
} elseif ( $error_code === 'rollback_was_required' && is_wp_error( $result->get_error_data()->rollback ) ) {
|
||||
// A rollback is only critical if it failed too.
|
||||
$critical = true;
|
||||
$critical = true;
|
||||
$rollback_result = $result->get_error_data()->rollback;
|
||||
} elseif ( false !== strpos( $error_code, 'do_rollback' ) ) {
|
||||
$critical = true;
|
||||
|
@ -538,29 +560,33 @@ class WP_Automatic_Updater {
|
|||
* In fact, let's schedule a special update for an hour from now. (It's possible
|
||||
* the issue could actually be on WordPress.org's side.) If that one fails, then email.
|
||||
*/
|
||||
$send = true;
|
||||
$transient_failures = array( 'incompatible_archive', 'download_failed', 'insane_distro', 'locked' );
|
||||
if ( in_array( $error_code, $transient_failures ) && ! get_site_option( 'auto_core_update_failed' ) ) {
|
||||
wp_schedule_single_event( time() + HOUR_IN_SECONDS, 'wp_maybe_auto_update' );
|
||||
$send = false;
|
||||
}
|
||||
|
||||
$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 )
|
||||
$send = true;
|
||||
$transient_failures = array( 'incompatible_archive', 'download_failed', 'insane_distro', 'locked' );
|
||||
if ( in_array( $error_code, $transient_failures ) && ! get_site_option( 'auto_core_update_failed' ) ) {
|
||||
wp_schedule_single_event( time() + HOUR_IN_SECONDS, 'wp_maybe_auto_update' );
|
||||
$send = false;
|
||||
}
|
||||
|
||||
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 ),
|
||||
) );
|
||||
$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 ) {
|
||||
$send = false;
|
||||
}
|
||||
|
||||
if ( $send )
|
||||
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 ) {
|
||||
$this->send_email( 'fail', $core_update, $result );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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(
|
||||
'type' => $type,
|
||||
'email' => get_site_option( 'admin_email' ),
|
||||
'version' => $core_update->current,
|
||||
'timestamp' => time(),
|
||||
) );
|
||||
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,27 +626,28 @@ 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.
|
||||
case 'success': // We updated.
|
||||
/* translators: 1: Site name, 2: WordPress version number. */
|
||||
$subject = __( '[%1$s] Your site has updated to WordPress %2$s' );
|
||||
break;
|
||||
|
||||
case 'fail' : // We tried to update but couldn't.
|
||||
case 'manual' : // We can't update (and made no attempt).
|
||||
case 'fail': // We tried to update but couldn't.
|
||||
case 'manual': // We can't update (and made no attempt).
|
||||
/* translators: 1: Site name, 2: WordPress version number. */
|
||||
$subject = __( '[%1$s] WordPress %2$s is available. Please update!' );
|
||||
break;
|
||||
|
||||
case 'critical' : // We tried to update, started to copy files, then things went wrong.
|
||||
case 'critical': // We tried to update, started to copy files, then things went wrong.
|
||||
/* translators: 1: Site name. */
|
||||
$subject = __( '[%1$s] URGENT: Your site may be down due to a failed update' );
|
||||
break;
|
||||
|
||||
default :
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -628,16 +658,17 @@ class WP_Automatic_Updater {
|
|||
$body = '';
|
||||
|
||||
switch ( $type ) {
|
||||
case 'success' :
|
||||
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 .= "\n" . admin_url( 'about.php' );
|
||||
$body .= sprintf( __( 'For more on version %s, see the About WordPress screen:' ), $about_version );
|
||||
$body .= "\n" . admin_url( 'about.php' );
|
||||
|
||||
if ( $newer_version_available ) {
|
||||
$body .= "\n\n" . sprintf( __( 'WordPress %s is also now available.' ), $next_user_core_update->current ) . ' ';
|
||||
|
@ -647,26 +678,28 @@ class WP_Automatic_Updater {
|
|||
|
||||
break;
|
||||
|
||||
case 'fail' :
|
||||
case 'manual' :
|
||||
case 'fail':
|
||||
case 'manual':
|
||||
$body .= sprintf( __( 'Please update your site at %1$s to WordPress %2$s.' ), home_url(), $next_user_core_update->current );
|
||||
|
||||
$body .= "\n\n";
|
||||
|
||||
// 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 )
|
||||
case 'critical':
|
||||
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,28 +743,33 @@ 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";
|
||||
}
|
||||
|
||||
$to = get_site_option( 'admin_email' );
|
||||
$to = get_site_option( 'admin_email' );
|
||||
$headers = '';
|
||||
|
||||
$email = compact( 'to', 'subject', 'body', 'headers' );
|
||||
|
@ -767,10 +805,11 @@ 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();
|
||||
$body = array();
|
||||
$failures = 0;
|
||||
|
||||
$body[] = sprintf( __( 'WordPress site: %s' ), network_home_url( '/' ) );
|
||||
|
@ -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,8 +865,9 @@ class WP_Automatic_Updater {
|
|||
|
||||
$site_title = wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES );
|
||||
if ( $failures ) {
|
||||
$body[] = trim( __(
|
||||
"BETA TESTING?
|
||||
$body[] = trim(
|
||||
__(
|
||||
"BETA TESTING?
|
||||
=============
|
||||
|
||||
This debugging email is sent when you are using a development version of WordPress.
|
||||
|
@ -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( __(
|
||||
'UPDATE LOG
|
||||
==========' ) );
|
||||
$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( '…', '...', $message ) );
|
||||
foreach ( $update->messages as $message ) {
|
||||
$body[] = ' ' . html_entity_decode( str_replace( '…', '...', $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,8 +923,9 @@ 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' => '',
|
||||
);
|
||||
|
||||
/**
|
||||
|
|
|
@ -45,17 +45,19 @@ class WP_Comments_List_Table extends WP_List_Table {
|
|||
add_filter( 'comment_author', array( $this, 'floated_admin_avatar' ), 10, 2 );
|
||||
}
|
||||
|
||||
parent::__construct( array(
|
||||
'plural' => 'comments',
|
||||
'singular' => 'comment',
|
||||
'ajax' => true,
|
||||
'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
|
||||
) );
|
||||
parent::__construct(
|
||||
array(
|
||||
'plural' => 'comments',
|
||||
'singular' => 'comment',
|
||||
'ajax' => true,
|
||||
'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function floated_admin_avatar( $name, $comment_ID ) {
|
||||
$comment = get_comment( $comment_ID );
|
||||
$avatar = get_avatar( $comment, 32, 'mystery' );
|
||||
$avatar = get_avatar( $comment, 32, 'mystery' );
|
||||
return "$avatar $name";
|
||||
}
|
||||
|
||||
|
@ -63,11 +65,10 @@ class WP_Comments_List_Table extends WP_List_Table {
|
|||
* @return bool
|
||||
*/
|
||||
public function ajax_user_can() {
|
||||
return current_user_can('edit_posts');
|
||||
return current_user_can( 'edit_posts' );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @global int $post_id
|
||||
* @global string $comment_status
|
||||
* @global string $search
|
||||
|
@ -77,10 +78,11 @@ 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'] : '';
|
||||
$comment_type = ! empty( $_REQUEST['comment_type'] ) ? $_REQUEST['comment_type'] : '';
|
||||
|
||||
$search = ( isset( $_REQUEST['s'] ) ) ? $_REQUEST['s'] : '';
|
||||
|
||||
|
@ -89,7 +91,7 @@ class WP_Comments_List_Table extends WP_List_Table {
|
|||
$user_id = ( isset( $_REQUEST['user_id'] ) ) ? $_REQUEST['user_id'] : '';
|
||||
|
||||
$orderby = ( isset( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : '';
|
||||
$order = ( isset( $_REQUEST['order'] ) ) ? $_REQUEST['order'] : '';
|
||||
$order = ( isset( $_REQUEST['order'] ) ) ? $_REQUEST['order'] : '';
|
||||
|
||||
$comments_per_page = $this->get_per_page( $comment_status );
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -116,20 +117,20 @@ class WP_Comments_List_Table extends WP_List_Table {
|
|||
|
||||
$status_map = array(
|
||||
'moderated' => 'hold',
|
||||
'approved' => 'approve',
|
||||
'all' => '',
|
||||
'approved' => 'approve',
|
||||
'all' => '',
|
||||
);
|
||||
|
||||
$args = array(
|
||||
'status' => isset( $status_map[$comment_status] ) ? $status_map[$comment_status] : $comment_status,
|
||||
'search' => $search,
|
||||
'user_id' => $user_id,
|
||||
'offset' => $start,
|
||||
'number' => $number,
|
||||
'post_id' => $post_id,
|
||||
'type' => $comment_type,
|
||||
'orderby' => $orderby,
|
||||
'order' => $order,
|
||||
'status' => isset( $status_map[ $comment_status ] ) ? $status_map[ $comment_status ] : $comment_status,
|
||||
'search' => $search,
|
||||
'user_id' => $user_id,
|
||||
'offset' => $start,
|
||||
'number' => $number,
|
||||
'post_id' => $post_id,
|
||||
'type' => $comment_type,
|
||||
'orderby' => $orderby,
|
||||
'order' => $order,
|
||||
'post_type' => $post_type,
|
||||
);
|
||||
|
||||
|
@ -137,7 +138,7 @@ class WP_Comments_List_Table extends WP_List_Table {
|
|||
if ( is_array( $_comments ) ) {
|
||||
update_comment_cache( $_comments );
|
||||
|
||||
$this->items = array_slice( $_comments, 0, $comments_per_page );
|
||||
$this->items = array_slice( $_comments, 0, $comments_per_page );
|
||||
$this->extra_items = array_slice( $_comments, $comments_per_page );
|
||||
|
||||
$_comment_post_ids = array_unique( wp_list_pluck( $_comments, 'comment_post_ID' ) );
|
||||
|
@ -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(
|
||||
'count' => true,
|
||||
'offset' => 0,
|
||||
'number' => 0
|
||||
) ) );
|
||||
$total_comments = get_comments(
|
||||
array_merge(
|
||||
$args, array(
|
||||
'count' => true,
|
||||
'offset' => 0,
|
||||
'number' => 0,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$this->set_pagination_args( array(
|
||||
'total_items' => $total_comments,
|
||||
'per_page' => $comments_per_page,
|
||||
) );
|
||||
$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
|
||||
|
@ -203,7 +207,7 @@ class WP_Comments_List_Table extends WP_List_Table {
|
|||
|
||||
$stati = array(
|
||||
/* translators: %s: all comments count */
|
||||
'all' => _nx_noop(
|
||||
'all' => _nx_noop(
|
||||
'All <span class="count">(%s)</span>',
|
||||
'All <span class="count">(%s)</span>',
|
||||
'comments'
|
||||
|
@ -217,33 +221,35 @@ class WP_Comments_List_Table extends WP_List_Table {
|
|||
),
|
||||
|
||||
/* translators: %s: approved comments count */
|
||||
'approved' => _nx_noop(
|
||||
'approved' => _nx_noop(
|
||||
'Approved <span class="count">(%s)</span>',
|
||||
'Approved <span class="count">(%s)</span>',
|
||||
'comments'
|
||||
),
|
||||
|
||||
/* translators: %s: spam comments count */
|
||||
'spam' => _nx_noop(
|
||||
'spam' => _nx_noop(
|
||||
'Spam <span class="count">(%s)</span>',
|
||||
'Spam <span class="count">(%s)</span>',
|
||||
'comments'
|
||||
),
|
||||
|
||||
/* translators: %s: trashed comments count */
|
||||
'trash' => _nx_noop(
|
||||
'trash' => _nx_noop(
|
||||
'Trash <span class="count">(%s)</span>',
|
||||
'Trash <span class="count">(%s)</span>',
|
||||
'comments'
|
||||
)
|
||||
),
|
||||
);
|
||||
|
||||
if ( !EMPTY_TRASH_DAYS )
|
||||
unset($stati['trash']);
|
||||
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
|
||||
*
|
||||
|
@ -330,43 +341,46 @@ class WP_Comments_List_Table extends WP_List_Table {
|
|||
?>
|
||||
<div class="alignleft actions">
|
||||
<?php
|
||||
if ( 'top' === $which ) {
|
||||
if ( 'top' === $which ) {
|
||||
?>
|
||||
<label class="screen-reader-text" for="filter-by-comment-type"><?php _e( 'Filter by comment type' ); ?></label>
|
||||
<select id="filter-by-comment-type" name="comment_type">
|
||||
<option value=""><?php _e( 'All comment types' ); ?></option>
|
||||
<label class="screen-reader-text" for="filter-by-comment-type"><?php _e( 'Filter by comment type' ); ?></label>
|
||||
<select id="filter-by-comment-type" name="comment_type">
|
||||
<option value=""><?php _e( 'All comment types' ); ?></option>
|
||||
<?php
|
||||
/**
|
||||
* Filters the comment types dropdown menu.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param array $comment_types An array of comment types. Accepts 'Comments', 'Pings'.
|
||||
*/
|
||||
$comment_types = apply_filters( 'admin_comment_types_dropdown', array(
|
||||
'comment' => __( 'Comments' ),
|
||||
'pings' => __( 'Pings' ),
|
||||
) );
|
||||
/**
|
||||
* Filters the comment types dropdown menu.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @param array $comment_types An array of comment types. Accepts 'Comments', 'Pings'.
|
||||
*/
|
||||
$comment_types = apply_filters(
|
||||
'admin_comment_types_dropdown', array(
|
||||
'comment' => __( 'Comments' ),
|
||||
'pings' => __( 'Pings' ),
|
||||
)
|
||||
);
|
||||
|
||||
foreach ( $comment_types as $type => $label )
|
||||
echo "\t" . '<option value="' . esc_attr( $type ) . '"' . selected( $comment_type, $type, false ) . ">$label</option>\n";
|
||||
?>
|
||||
</select>
|
||||
foreach ( $comment_types as $type => $label ) {
|
||||
echo "\t" . '<option value="' . esc_attr( $type ) . '"' . selected( $comment_type, $type, false ) . ">$label</option>\n";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<?php
|
||||
/**
|
||||
* Fires just before the Filter submit button for comment types.
|
||||
*
|
||||
* @since 3.5.0
|
||||
*/
|
||||
do_action( 'restrict_manage_comments' );
|
||||
submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
|
||||
}
|
||||
/**
|
||||
* Fires just before the Filter submit button for comment types.
|
||||
*
|
||||
* @since 3.5.0
|
||||
*/
|
||||
do_action( 'restrict_manage_comments' );
|
||||
submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
|
||||
}
|
||||
|
||||
if ( ( 'spam' === $comment_status || 'trash' === $comment_status ) && current_user_can( 'moderate_comments' ) && $has_items ) {
|
||||
wp_nonce_field( 'bulk-destroy', '_destroy_nonce' );
|
||||
$title = ( 'spam' === $comment_status ) ? esc_attr__( 'Empty Spam' ) : esc_attr__( 'Empty Trash' );
|
||||
submit_button( $title, 'apply', 'delete_all', false );
|
||||
}
|
||||
if ( ( 'spam' === $comment_status || 'trash' === $comment_status ) && current_user_can( 'moderate_comments' ) && $has_items ) {
|
||||
wp_nonce_field( 'bulk-destroy', '_destroy_nonce' );
|
||||
$title = ( 'spam' === $comment_status ) ? esc_attr__( 'Empty Spam' ) : esc_attr__( 'Empty Trash' );
|
||||
submit_button( $title, 'apply', 'delete_all', false );
|
||||
}
|
||||
/**
|
||||
* Fires after the Filter submit button for comment types.
|
||||
*
|
||||
|
@ -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,10 +413,11 @@ 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['author'] = __( 'Author' );
|
||||
$columns['comment'] = _x( 'Comment', 'column name' );
|
||||
|
||||
if ( ! $post_id ) {
|
||||
|
@ -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' );
|
||||
|
||||
|
@ -507,54 +521,58 @@ class WP_Comments_List_Table extends WP_List_Table {
|
|||
unset( $GLOBALS['post'], $GLOBALS['comment'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate and display row actions links.
|
||||
*
|
||||
* @since 4.3.0
|
||||
*
|
||||
* @global string $comment_status Status for the current listed comments.
|
||||
*
|
||||
* @param WP_Comment $comment The comment object.
|
||||
* @param string $column_name Current column name.
|
||||
* @param string $primary Primary column name.
|
||||
* @return string|void Comment row actions output.
|
||||
*/
|
||||
protected function handle_row_actions( $comment, $column_name, $primary ) {
|
||||
global $comment_status;
|
||||
/**
|
||||
* Generate and display row actions links.
|
||||
*
|
||||
* @since 4.3.0
|
||||
*
|
||||
* @global string $comment_status Status for the current listed comments.
|
||||
*
|
||||
* @param WP_Comment $comment The comment object.
|
||||
* @param string $column_name Current column name.
|
||||
* @param string $primary Primary column name.
|
||||
* @return string|void Comment row actions output.
|
||||
*/
|
||||
protected function handle_row_actions( $comment, $column_name, $primary ) {
|
||||
global $comment_status;
|
||||
|
||||
if ( $primary !== $column_name ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ( ! $this->user_can ) {
|
||||
return;
|
||||
if ( ! $this->user_can ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$the_comment_status = wp_get_comment_status( $comment );
|
||||
|
||||
$out = '';
|
||||
|
||||
$del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) );
|
||||
$del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) );
|
||||
$approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) );
|
||||
|
||||
$url = "comment.php?c=$comment->comment_ID";
|
||||
|
||||
$approve_url = esc_url( $url . "&action=approvecomment&$approve_nonce" );
|
||||
$approve_url = esc_url( $url . "&action=approvecomment&$approve_nonce" );
|
||||
$unapprove_url = esc_url( $url . "&action=unapprovecomment&$approve_nonce" );
|
||||
$spam_url = esc_url( $url . "&action=spamcomment&$del_nonce" );
|
||||
$unspam_url = esc_url( $url . "&action=unspamcomment&$del_nonce" );
|
||||
$trash_url = esc_url( $url . "&action=trashcomment&$del_nonce" );
|
||||
$untrash_url = esc_url( $url . "&action=untrashcomment&$del_nonce" );
|
||||
$delete_url = esc_url( $url . "&action=deletecomment&$del_nonce" );
|
||||
$spam_url = esc_url( $url . "&action=spamcomment&$del_nonce" );
|
||||
$unspam_url = esc_url( $url . "&action=unspamcomment&$del_nonce" );
|
||||
$trash_url = esc_url( $url . "&action=trashcomment&$del_nonce" );
|
||||
$untrash_url = esc_url( $url . "&action=untrashcomment&$del_nonce" );
|
||||
$delete_url = esc_url( $url . "&action=deletecomment&$del_nonce" );
|
||||
|
||||
// Preorder it: Approve | Reply | Quick Edit | Edit | Spam | Trash.
|
||||
$actions = array(
|
||||
'approve' => '', 'unapprove' => '',
|
||||
'reply' => '',
|
||||
'approve' => '',
|
||||
'unapprove' => '',
|
||||
'reply' => '',
|
||||
'quickedit' => '',
|
||||
'edit' => '',
|
||||
'spam' => '', 'unspam' => '',
|
||||
'trash' => '', 'untrash' => '', 'delete' => ''
|
||||
'edit' => '',
|
||||
'spam' => '',
|
||||
'unspam' => '',
|
||||
'trash' => '',
|
||||
'untrash' => '',
|
||||
'delete' => '',
|
||||
);
|
||||
|
||||
// Not looking at all comments.
|
||||
|
@ -565,7 +583,7 @@ class WP_Comments_List_Table extends WP_List_Table {
|
|||
$actions['approve'] = "<a href='$approve_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=approved' class='vim-a vim-destructive' aria-label='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
|
||||
}
|
||||
} else {
|
||||
$actions['approve'] = "<a href='$approve_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved' class='vim-a' aria-label='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
|
||||
$actions['approve'] = "<a href='$approve_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved' class='vim-a' aria-label='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
|
||||
$actions['unapprove'] = "<a href='$unapprove_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved' class='vim-u' aria-label='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
|
||||
}
|
||||
|
||||
|
@ -579,14 +597,14 @@ class WP_Comments_List_Table extends WP_List_Table {
|
|||
$actions['untrash'] = "<a href='$untrash_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID:66cc66:untrash=1' class='vim-z vim-destructive' aria-label='" . esc_attr__( 'Restore this comment from the Trash' ) . "'>" . __( 'Restore' ) . '</a>';
|
||||
}
|
||||
|
||||
if ( 'spam' === $the_comment_status || 'trash' === $the_comment_status || !EMPTY_TRASH_DAYS ) {
|
||||
if ( 'spam' === $the_comment_status || 'trash' === $the_comment_status || ! EMPTY_TRASH_DAYS ) {
|
||||
$actions['delete'] = "<a href='$delete_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::delete=1' class='delete vim-d vim-destructive' aria-label='" . esc_attr__( 'Delete this comment permanently' ) . "'>" . __( 'Delete Permanently' ) . '</a>';
|
||||
} else {
|
||||
$actions['trash'] = "<a href='$trash_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive' aria-label='" . esc_attr__( 'Move this comment to the Trash' ) . "'>" . _x( 'Trash', 'verb' ) . '</a>';
|
||||
}
|
||||
|
||||
if ( 'spam' !== $the_comment_status && 'trash' !== $the_comment_status ) {
|
||||
$actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' aria-label='" . esc_attr__( 'Edit this comment' ) . "'>". __( 'Edit' ) . '</a>';
|
||||
$actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' aria-label='" . esc_attr__( 'Edit this comment' ) . "'>" . __( 'Edit' ) . '</a>';
|
||||
|
||||
$format = '<a data-comment-id="%d" data-post-id="%d" data-action="%s" class="%s" aria-label="%s" href="#">%s</a>';
|
||||
|
||||
|
@ -598,20 +616,21 @@ class WP_Comments_List_Table extends WP_List_Table {
|
|||
/** This filter is documented in wp-admin/includes/dashboard.php */
|
||||
$actions = apply_filters( 'comment_row_actions', array_filter( $actions ), $comment );
|
||||
|
||||
$i = 0;
|
||||
$i = 0;
|
||||
$out .= '<div class="row-actions">';
|
||||
foreach ( $actions as $action => $link ) {
|
||||
++$i;
|
||||
( ( ( '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
|
||||
|
@ -647,7 +666,7 @@ class WP_Comments_List_Table extends WP_List_Table {
|
|||
$parent = get_comment( $comment->comment_parent );
|
||||
if ( $parent ) {
|
||||
$parent_link = esc_url( get_comment_link( $parent ) );
|
||||
$name = get_comment_author( $parent );
|
||||
$name = get_comment_author( $parent );
|
||||
printf(
|
||||
/* translators: %s: comment link */
|
||||
__( 'In reply to %s.' ),
|
||||
|
@ -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, '…' );
|
||||
}
|
||||
|
||||
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,19 +743,19 @@ 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 )
|
||||
);
|
||||
|
||||
echo '<div class="submitted-on">';
|
||||
if ( 'approved' === wp_get_comment_status( $comment ) && ! empty ( $comment->comment_post_ID ) ) {
|
||||
if ( 'approved' === wp_get_comment_status( $comment ) && ! empty( $comment->comment_post_ID ) ) {
|
||||
printf(
|
||||
'<a href="%s">%s</a>',
|
||||
esc_url( get_comment_link( $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 ) {
|
||||
|
@ -750,15 +777,15 @@ class WP_Comments_List_Table extends WP_List_Table {
|
|||
return;
|
||||
}
|
||||
|
||||
if ( isset( $this->pending_count[$post->ID] ) ) {
|
||||
$pending_comments = $this->pending_count[$post->ID];
|
||||
if ( isset( $this->pending_count[ $post->ID ] ) ) {
|
||||
$pending_comments = $this->pending_count[ $post->ID ];
|
||||
} else {
|
||||
$_pending_count_temp = get_pending_comments_num( array( $post->ID ) );
|
||||
$pending_comments = $this->pending_count[$post->ID] = $_pending_count_temp[$post->ID];
|
||||
$pending_comments = $this->pending_count[ $post->ID ] = $_pending_count_temp[ $post->ID ];
|
||||
}
|
||||
|
||||
if ( current_user_can( 'edit_post', $post->ID ) ) {
|
||||
$post_link = "<a href='" . get_edit_post_link( $post->ID ) . "' class='comments-edit-item-link'>";
|
||||
$post_link = "<a href='" . get_edit_post_link( $post->ID ) . "' class='comments-edit-item-link'>";
|
||||
$post_link .= esc_html( get_the_title( $post->ID ) ) . '</a>';
|
||||
} else {
|
||||
$post_link = esc_html( get_the_title( $post->ID ) );
|
||||
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -95,8 +95,8 @@ class WP_Community_Events {
|
|||
// include an unmodified $wp_version
|
||||
include( ABSPATH . WPINC . '/version.php' );
|
||||
|
||||
$api_url = 'http://api.wordpress.org/events/1.0/';
|
||||
$request_args = $this->get_request_args( $location_search, $timezone );
|
||||
$api_url = 'http://api.wordpress.org/events/1.0/';
|
||||
$request_args = $this->get_request_args( $location_search, $timezone );
|
||||
$request_args['user-agent'] = 'WordPress/' . $wp_version . '; ' . home_url( '/' );
|
||||
|
||||
if ( wp_http_supports( array( 'ssl' ) ) ) {
|
||||
|
@ -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,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -339,7 +339,7 @@ class WP_Community_Events {
|
|||
|
||||
if ( isset( $location['ip'] ) ) {
|
||||
$key = 'community-events-' . md5( $location['ip'] );
|
||||
} else if ( isset( $location['latitude'], $location['longitude'] ) ) {
|
||||
} elseif ( isset( $location['latitude'], $location['longitude'] ) ) {
|
||||
$key = 'community-events-' . md5( $location['latitude'] . $location['longitude'] );
|
||||
}
|
||||
|
||||
|
@ -463,11 +463,13 @@ class WP_Community_Events {
|
|||
return;
|
||||
}
|
||||
|
||||
error_log( sprintf(
|
||||
'%s: %s. Details: %s',
|
||||
__METHOD__,
|
||||
trim( $message, '.' ),
|
||||
wp_json_encode( $details )
|
||||
) );
|
||||
error_log(
|
||||
sprintf(
|
||||
'%s: %s. Details: %s',
|
||||
__METHOD__,
|
||||
trim( $message, '.' ),
|
||||
wp_json_encode( $details )
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,10 +53,11 @@ class WP_Filesystem_Base {
|
|||
* @return string The location of the remote path.
|
||||
*/
|
||||
public function abspath() {
|
||||
$folder = $this->find_folder(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;
|
||||
}
|
||||
|
||||
|
@ -68,7 +69,7 @@ class WP_Filesystem_Base {
|
|||
* @return string The location of the remote path.
|
||||
*/
|
||||
public function wp_content_dir() {
|
||||
return $this->find_folder(WP_CONTENT_DIR);
|
||||
return $this->find_folder( WP_CONTENT_DIR );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -79,7 +80,7 @@ class WP_Filesystem_Base {
|
|||
* @return string The location of the remote path.
|
||||
*/
|
||||
public function wp_plugins_dir() {
|
||||
return $this->find_folder(WP_PLUGIN_DIR);
|
||||
return $this->find_folder( WP_PLUGIN_DIR );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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 );
|
||||
}
|
||||
|
@ -108,7 +110,7 @@ class WP_Filesystem_Base {
|
|||
* @return string The location of the remote path.
|
||||
*/
|
||||
public function wp_lang_dir() {
|
||||
return $this->find_folder(WP_LANG_DIR);
|
||||
return $this->find_folder( WP_LANG_DIR );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -128,7 +130,7 @@ class WP_Filesystem_Base {
|
|||
* @return string The location of the remote path.
|
||||
*/
|
||||
public function find_base_dir( $base = '.', $echo = false ) {
|
||||
_deprecated_function(__FUNCTION__, '2.7.0', 'WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir()' );
|
||||
_deprecated_function( __FUNCTION__, '2.7.0', 'WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir()' );
|
||||
$this->verbose = $echo;
|
||||
return $this->abspath();
|
||||
}
|
||||
|
@ -149,7 +151,7 @@ class WP_Filesystem_Base {
|
|||
* @return string The location of the remote path.
|
||||
*/
|
||||
public function get_base_dir( $base = '.', $echo = false ) {
|
||||
_deprecated_function(__FUNCTION__, '2.7.0', 'WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir()' );
|
||||
_deprecated_function( __FUNCTION__, '2.7.0', 'WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir()' );
|
||||
$this->verbose = $echo;
|
||||
return $this->abspath();
|
||||
}
|
||||
|
@ -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 ) {
|
||||
if ( stripos( $this->method, 'ftp' ) !== false ) {
|
||||
$constant_overrides = array(
|
||||
'FTP_BASE' => ABSPATH,
|
||||
'FTP_BASE' => ABSPATH,
|
||||
'FTP_CONTENT_DIR' => WP_CONTENT_DIR,
|
||||
'FTP_PLUGIN_DIR' => WP_PLUGIN_DIR,
|
||||
'FTP_LANG_DIR' => WP_LANG_DIR
|
||||
'FTP_PLUGIN_DIR' => WP_PLUGIN_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 );
|
||||
|
@ -200,23 +206,25 @@ class WP_Filesystem_Base {
|
|||
}
|
||||
}
|
||||
} elseif ( 'direct' == $this->method ) {
|
||||
$folder = str_replace('\\', '/', $folder); // Windows path sanitisation
|
||||
return trailingslashit($folder);
|
||||
$folder = str_replace( '\\', '/', $folder ); // Windows path sanitisation
|
||||
return trailingslashit( $folder );
|
||||
}
|
||||
|
||||
$folder = preg_replace('|^([a-z]{1}):|i', '', $folder); // Strip out windows drive letter if it's there.
|
||||
$folder = str_replace('\\', '/', $folder); // Windows path sanitisation
|
||||
$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);
|
||||
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,26 +241,28 @@ 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 )
|
||||
$base = trailingslashit($this->cwd());
|
||||
if ( empty( $base ) || '.' == $base ) {
|
||||
$base = trailingslashit( $this->cwd() );
|
||||
}
|
||||
|
||||
$folder = untrailingslashit($folder);
|
||||
$folder = untrailingslashit( $folder );
|
||||
|
||||
if ( $this->verbose ) {
|
||||
/* translators: 1: folder to locate, 2: folder to start searching from */
|
||||
printf( "\n" . __( 'Looking for %1$s in %2$s' ) . "<br/>\n", $folder, $base );
|
||||
}
|
||||
|
||||
$folder_parts = explode('/', $folder);
|
||||
$folder_parts = explode( '/', $folder );
|
||||
$folder_part_keys = array_keys( $folder_parts );
|
||||
$last_index = array_pop( $folder_part_keys );
|
||||
$last_path = $folder_parts[ $last_index ];
|
||||
$last_index = array_pop( $folder_part_keys );
|
||||
$last_path = $folder_parts[ $last_index ];
|
||||
|
||||
$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
|
||||
|
@ -261,10 +271,10 @@ class WP_Filesystem_Base {
|
|||
* folder level, and see if that matches, and so on. If it reaches the end, and still
|
||||
* cant find it, it'll return false for the entire function.
|
||||
*/
|
||||
if ( isset($files[ $key ]) ){
|
||||
if ( isset( $files[ $key ] ) ) {
|
||||
|
||||
// Let's try that folder:
|
||||
$newdir = trailingslashit(path_join($base, $key));
|
||||
$newdir = trailingslashit( path_join( $base, $key ) );
|
||||
if ( $this->verbose ) {
|
||||
/* translators: %s: directory name */
|
||||
printf( "\n" . __( 'Changing to %s' ) . "<br/>\n", $newdir );
|
||||
|
@ -272,25 +282,27 @@ 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.
|
||||
if (isset( $files[ $last_path ] ) ) {
|
||||
if ( isset( $files[ $last_path ] ) ) {
|
||||
if ( $this->verbose ) {
|
||||
/* translators: %s: directory name */
|
||||
printf( "\n" . __( 'Found %s' ) . "<br/>\n", $base . $last_path );
|
||||
printf( "\n" . __( 'Found %s' ) . "<br/>\n", $base . $last_path );
|
||||
}
|
||||
return trailingslashit($base . $last_path);
|
||||
return trailingslashit( $base . $last_path );
|
||||
}
|
||||
|
||||
// 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/....
|
||||
|
@ -310,45 +322,46 @@ class WP_Filesystem_Base {
|
|||
* @param string $file String filename.
|
||||
* @return string The *nix-style representation of permissions.
|
||||
*/
|
||||
public function gethchmod( $file ){
|
||||
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' : '-');
|
||||
$info .= (($perms & 0x0080) ? 'w' : '-');
|
||||
$info .= (($perms & 0x0040) ?
|
||||
(($perms & 0x0800) ? 's' : 'x' ) :
|
||||
(($perms & 0x0800) ? 'S' : '-'));
|
||||
$info .= ( ( $perms & 0x0100 ) ? 'r' : '-' );
|
||||
$info .= ( ( $perms & 0x0080 ) ? 'w' : '-' );
|
||||
$info .= ( ( $perms & 0x0040 ) ?
|
||||
( ( $perms & 0x0800 ) ? 's' : 'x' ) :
|
||||
( ( $perms & 0x0800 ) ? 'S' : '-' ) );
|
||||
|
||||
// Group
|
||||
$info .= (($perms & 0x0020) ? 'r' : '-');
|
||||
$info .= (($perms & 0x0010) ? 'w' : '-');
|
||||
$info .= (($perms & 0x0008) ?
|
||||
(($perms & 0x0400) ? 's' : 'x' ) :
|
||||
(($perms & 0x0400) ? 'S' : '-'));
|
||||
$info .= ( ( $perms & 0x0020 ) ? 'r' : '-' );
|
||||
$info .= ( ( $perms & 0x0010 ) ? 'w' : '-' );
|
||||
$info .= ( ( $perms & 0x0008 ) ?
|
||||
( ( $perms & 0x0400 ) ? 's' : 'x' ) :
|
||||
( ( $perms & 0x0400 ) ? 'S' : '-' ) );
|
||||
|
||||
// World
|
||||
$info .= (($perms & 0x0004) ? 'r' : '-');
|
||||
$info .= (($perms & 0x0002) ? 'w' : '-');
|
||||
$info .= (($perms & 0x0001) ?
|
||||
(($perms & 0x0200) ? 't' : 'x' ) :
|
||||
(($perms & 0x0200) ? 'T' : '-'));
|
||||
$info .= ( ( $perms & 0x0004 ) ? 'r' : '-' );
|
||||
$info .= ( ( $perms & 0x0002 ) ? 'w' : '-' );
|
||||
$info .= ( ( $perms & 0x0001 ) ?
|
||||
( ( $perms & 0x0200 ) ? 't' : 'x' ) :
|
||||
( ( $perms & 0x0200 ) ? 'T' : '-' ) );
|
||||
return $info;
|
||||
}
|
||||
|
||||
|
@ -368,7 +381,7 @@ class WP_Filesystem_Base {
|
|||
*
|
||||
* Converts '-rw-r--r--' to 0644
|
||||
* From "info at rvgate dot nl"'s comment on the PHP documentation for chmod()
|
||||
*
|
||||
*
|
||||
* @link https://secure.php.net/manual/en/function.chmod.php#49614
|
||||
*
|
||||
* @since 2.5.0
|
||||
|
@ -378,20 +391,25 @@ class WP_Filesystem_Base {
|
|||
*/
|
||||
public function getnumchmodfromh( $mode ) {
|
||||
$realmode = '';
|
||||
$legal = array('', 'w', 'r', 'x', '-');
|
||||
$attarray = preg_split('//', $mode);
|
||||
$legal = array( '', 'w', 'r', 'x', '-' );
|
||||
$attarray = preg_split( '//', $mode );
|
||||
|
||||
for ( $i = 0, $c = count( $attarray ); $i < $c; $i++ ) {
|
||||
if ($key = array_search($attarray[$i], $legal)) {
|
||||
$realmode .= $legal[$key];
|
||||
if ( $key = array_search( $attarray[ $i ], $legal ) ) {
|
||||
$realmode .= $legal[ $key ];
|
||||
}
|
||||
}
|
||||
|
||||
$mode = str_pad($realmode, 10, '-', STR_PAD_LEFT);
|
||||
$trans = array('-'=>'0', 'r'=>'4', 'w'=>'2', 'x'=>'1');
|
||||
$mode = strtr($mode,$trans);
|
||||
$mode = str_pad( $realmode, 10, '-', STR_PAD_LEFT );
|
||||
$trans = array(
|
||||
'-' => '0',
|
||||
'r' => '4',
|
||||
'w' => '2',
|
||||
'x' => '1',
|
||||
);
|
||||
$mode = strtr( $mode, $trans );
|
||||
|
||||
$newmode = $mode[0];
|
||||
$newmode = $mode[0];
|
||||
$newmode .= $mode[1] + $mode[2] + $mode[3];
|
||||
$newmode .= $mode[4] + $mode[5] + $mode[6];
|
||||
$newmode .= $mode[7] + $mode[8] + $mode[9];
|
||||
|
@ -539,7 +557,7 @@ class WP_Filesystem_Base {
|
|||
*
|
||||
* @since 2.5.0
|
||||
* @abstract
|
||||
*
|
||||
*
|
||||
* @param string $file Path to the file.
|
||||
* @return string|bool Username of the user or false on error.
|
||||
*/
|
||||
|
|
|
@ -18,10 +18,9 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
|||
/**
|
||||
* constructor
|
||||
*
|
||||
*
|
||||
* @param mixed $arg ignored argument
|
||||
*/
|
||||
public function __construct($arg) {
|
||||
public function __construct( $arg ) {
|
||||
$this->method = 'direct';
|
||||
$this->errors = new WP_Error();
|
||||
}
|
||||
|
@ -29,29 +28,26 @@ 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.
|
||||
*/
|
||||
public function get_contents($file) {
|
||||
return @file_get_contents($file);
|
||||
public function get_contents( $file ) {
|
||||
return @file_get_contents( $file );
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public function get_contents_array($file) {
|
||||
return @file($file);
|
||||
public function get_contents_array( $file ) {
|
||||
return @file( $file );
|
||||
}
|
||||
|
||||
/**
|
||||
* 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,35 +91,37 @@ 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.
|
||||
*/
|
||||
public function chdir($dir) {
|
||||
return @chdir($dir);
|
||||
public function chdir( $dir ) {
|
||||
return @chdir( $dir );
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) )
|
||||
public function chgrp( $file, $group, $recursive = false ) {
|
||||
if ( ! $this->exists( $file ) ) {
|
||||
return false;
|
||||
if ( ! $recursive )
|
||||
return @chgrp($file, $group);
|
||||
if ( ! $this->is_dir($file) )
|
||||
return @chgrp($file, $group);
|
||||
}
|
||||
if ( ! $recursive ) {
|
||||
return @chgrp( $file, $group );
|
||||
}
|
||||
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)
|
||||
$this->chgrp($file . $filename, $group, $recursive);
|
||||
$file = trailingslashit( $file );
|
||||
$filelist = $this->dirlist( $file );
|
||||
foreach ( $filelist as $filename ) {
|
||||
$this->chgrp( $file . $filename, $group, $recursive );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -130,30 +129,32 @@ 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.
|
||||
* @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 chmod($file, $mode = false, $recursive = false) {
|
||||
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) )
|
||||
return @chmod($file, $mode);
|
||||
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)
|
||||
$this->chmod($file . $filename, $mode, $recursive);
|
||||
$file = trailingslashit( $file );
|
||||
$filelist = $this->dirlist( $file );
|
||||
foreach ( (array) $filelist as $filename => $filemeta ) {
|
||||
$this->chmod( $file . $filename, $mode, $recursive );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -161,24 +162,26 @@ 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.
|
||||
* Default false.
|
||||
* @return bool Returns true on success or false on failure.
|
||||
*/
|
||||
public function chown($file, $owner, $recursive = false) {
|
||||
if ( ! $this->exists($file) )
|
||||
public function chown( $file, $owner, $recursive = false ) {
|
||||
if ( ! $this->exists( $file ) ) {
|
||||
return false;
|
||||
if ( ! $recursive )
|
||||
return @chown($file, $owner);
|
||||
if ( ! $this->is_dir($file) )
|
||||
return @chown($file, $owner);
|
||||
}
|
||||
if ( ! $recursive ) {
|
||||
return @chown( $file, $owner );
|
||||
}
|
||||
if ( ! $this->is_dir( $file ) ) {
|
||||
return @chown( $file, $owner );
|
||||
}
|
||||
// Is a directory, and we want recursive
|
||||
$filelist = $this->dirlist($file);
|
||||
foreach ($filelist as $filename) {
|
||||
$this->chown($file . '/' . $filename, $owner, $recursive);
|
||||
$filelist = $this->dirlist( $file );
|
||||
foreach ( $filelist as $filename ) {
|
||||
$this->chown( $file . '/' . $filename, $owner, $recursive );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -186,17 +189,18 @@ 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 )
|
||||
public function owner( $file ) {
|
||||
$owneruid = @fileowner( $file );
|
||||
if ( ! $owneruid ) {
|
||||
return false;
|
||||
if ( ! function_exists('posix_getpwuid') )
|
||||
}
|
||||
if ( ! function_exists( 'posix_getpwuid' ) ) {
|
||||
return $owneruid;
|
||||
$ownerarray = posix_getpwuid($owneruid);
|
||||
}
|
||||
$ownerarray = posix_getpwuid( $owneruid );
|
||||
return $ownerarray['name'];
|
||||
}
|
||||
|
||||
|
@ -205,64 +209,66 @@ 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).
|
||||
*/
|
||||
public function getchmod($file) {
|
||||
public function getchmod( $file ) {
|
||||
return substr( decoct( @fileperms( $file ) ), -3 );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @return string|false
|
||||
*/
|
||||
public function group($file) {
|
||||
$gid = @filegroup($file);
|
||||
if ( ! $gid )
|
||||
public function group( $file ) {
|
||||
$gid = @filegroup( $file );
|
||||
if ( ! $gid ) {
|
||||
return false;
|
||||
if ( ! function_exists('posix_getgrgid') )
|
||||
}
|
||||
if ( ! function_exists( 'posix_getgrgid' ) ) {
|
||||
return $gid;
|
||||
$grouparray = posix_getgrgid($gid);
|
||||
}
|
||||
$grouparray = posix_getgrgid( $gid );
|
||||
return $grouparray['name'];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $source
|
||||
* @param string $destination
|
||||
* @param bool $overwrite
|
||||
* @param int $mode
|
||||
* @return bool
|
||||
*/
|
||||
public function copy($source, $destination, $overwrite = false, $mode = false) {
|
||||
if ( ! $overwrite && $this->exists($destination) )
|
||||
public function copy( $source, $destination, $overwrite = false, $mode = false ) {
|
||||
if ( ! $overwrite && $this->exists( $destination ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$rtval = copy($source, $destination);
|
||||
if ( $mode )
|
||||
$this->chmod($destination, $mode);
|
||||
$rtval = copy( $source, $destination );
|
||||
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) )
|
||||
public function move( $source, $destination, $overwrite = false ) {
|
||||
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);
|
||||
if ( $this->copy( $source, $destination, $overwrite ) && $this->exists( $destination ) ) {
|
||||
$this->delete( $source );
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
@ -270,220 +276,225 @@ 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.
|
||||
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.
|
||||
return false;
|
||||
}
|
||||
$file = str_replace( '\\', '/', $file ); // for win32, occasional problems deleting files otherwise
|
||||
|
||||
if ( 'f' == $type || $this->is_file($file) )
|
||||
return @unlink($file);
|
||||
if ( ! $recursive && $this->is_dir($file) )
|
||||
return @rmdir($file);
|
||||
if ( 'f' == $type || $this->is_file( $file ) ) {
|
||||
return @unlink( $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);
|
||||
$filelist = $this->dirlist($file, true);
|
||||
$file = trailingslashit( $file );
|
||||
$filelist = $this->dirlist( $file, true );
|
||||
|
||||
$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
|
||||
*/
|
||||
public function exists($file) {
|
||||
return @file_exists($file);
|
||||
public function exists( $file ) {
|
||||
return @file_exists( $file );
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @return bool
|
||||
*/
|
||||
public function is_file($file) {
|
||||
return @is_file($file);
|
||||
public function is_file( $file ) {
|
||||
return @is_file( $file );
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param string $path
|
||||
* @return bool
|
||||
*/
|
||||
public function is_dir($path) {
|
||||
return @is_dir($path);
|
||||
public function is_dir( $path ) {
|
||||
return @is_dir( $path );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @return bool
|
||||
*/
|
||||
public function is_readable($file) {
|
||||
return @is_readable($file);
|
||||
public function is_readable( $file ) {
|
||||
return @is_readable( $file );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @return bool
|
||||
*/
|
||||
public function is_writable($file) {
|
||||
return @is_writable($file);
|
||||
public function is_writable( $file ) {
|
||||
return @is_writable( $file );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @return int
|
||||
*/
|
||||
public function atime($file) {
|
||||
return @fileatime($file);
|
||||
public function atime( $file ) {
|
||||
return @fileatime( $file );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @return int
|
||||
*/
|
||||
public function mtime($file) {
|
||||
return @filemtime($file);
|
||||
public function mtime( $file ) {
|
||||
return @filemtime( $file );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @return int
|
||||
*/
|
||||
public function size($file) {
|
||||
return @filesize($file);
|
||||
public function size( $file ) {
|
||||
return @filesize( $file );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @param int $time
|
||||
* @param int $atime
|
||||
* @return bool
|
||||
*/
|
||||
public function touch($file, $time = 0, $atime = 0) {
|
||||
if ($time == 0)
|
||||
public function touch( $file, $time = 0, $atime = 0 ) {
|
||||
if ( $time == 0 ) {
|
||||
$time = time();
|
||||
if ($atime == 0)
|
||||
}
|
||||
if ( $atime == 0 ) {
|
||||
$atime = time();
|
||||
return @touch($file, $time, $atime);
|
||||
}
|
||||
return @touch( $file, $time, $atime );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $path
|
||||
* @param mixed $chmod
|
||||
* @param mixed $chown
|
||||
* @param mixed $chgrp
|
||||
* @return bool
|
||||
*/
|
||||
public function mkdir($path, $chmod = false, $chown = false, $chgrp = false) {
|
||||
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) )
|
||||
$path = untrailingslashit( $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 )
|
||||
$this->chown($path, $chown);
|
||||
if ( $chgrp )
|
||||
$this->chgrp($path, $chgrp);
|
||||
}
|
||||
$this->chmod( $path, $chmod );
|
||||
if ( $chown ) {
|
||||
$this->chown( $path, $chown );
|
||||
}
|
||||
if ( $chgrp ) {
|
||||
$this->chgrp( $path, $chgrp );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $path
|
||||
* @param bool $recursive
|
||||
* @return bool
|
||||
*/
|
||||
public function rmdir($path, $recursive = false) {
|
||||
return $this->delete($path, $recursive);
|
||||
public function rmdir( $path, $recursive = false ) {
|
||||
return $this->delete( $path, $recursive );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $path
|
||||
* @param bool $include_hidden
|
||||
* @param bool $recursive
|
||||
* @return bool|array
|
||||
*/
|
||||
public function dirlist($path, $include_hidden = true, $recursive = false) {
|
||||
if ( $this->is_file($path) ) {
|
||||
$limit_file = basename($path);
|
||||
$path = dirname($path);
|
||||
public function dirlist( $path, $include_hidden = true, $recursive = false ) {
|
||||
if ( $this->is_file( $path ) ) {
|
||||
$limit_file = basename( $path );
|
||||
$path = dirname( $path );
|
||||
} else {
|
||||
$limit_file = false;
|
||||
}
|
||||
|
||||
if ( ! $this->is_dir($path) )
|
||||
if ( ! $this->is_dir( $path ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$dir = @dir($path);
|
||||
if ( ! $dir )
|
||||
$dir = @dir( $path );
|
||||
if ( ! $dir ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$ret = array();
|
||||
|
||||
while (false !== ($entry = $dir->read()) ) {
|
||||
$struc = array();
|
||||
while ( false !== ( $entry = $dir->read() ) ) {
|
||||
$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']);
|
||||
$struc['number'] = false;
|
||||
$struc['owner'] = $this->owner($path.'/'.$entry);
|
||||
$struc['group'] = $this->group($path.'/'.$entry);
|
||||
$struc['size'] = $this->size($path.'/'.$entry);
|
||||
$struc['lastmodunix']= $this->mtime($path.'/'.$entry);
|
||||
$struc['lastmod'] = date('M j',$struc['lastmodunix']);
|
||||
$struc['time'] = date('h:i:s',$struc['lastmodunix']);
|
||||
$struc['type'] = $this->is_dir($path.'/'.$entry) ? 'd' : 'f';
|
||||
$struc['perms'] = $this->gethchmod( $path . '/' . $entry );
|
||||
$struc['permsn'] = $this->getnumchmodfromh( $struc['perms'] );
|
||||
$struc['number'] = false;
|
||||
$struc['owner'] = $this->owner( $path . '/' . $entry );
|
||||
$struc['group'] = $this->group( $path . '/' . $entry );
|
||||
$struc['size'] = $this->size( $path . '/' . $entry );
|
||||
$struc['lastmodunix'] = $this->mtime( $path . '/' . $entry );
|
||||
$struc['lastmod'] = date( 'M j', $struc['lastmodunix'] );
|
||||
$struc['time'] = date( 'h:i:s', $struc['lastmodunix'] );
|
||||
$struc['type'] = $this->is_dir( $path . '/' . $entry ) ? 'd' : 'f';
|
||||
|
||||
if ( 'd' == $struc['type'] ) {
|
||||
if ( $recursive )
|
||||
$struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive);
|
||||
else
|
||||
if ( $recursive ) {
|
||||
$struc['files'] = $this->dirlist( $path . '/' . $struc['name'], $include_hidden, $recursive );
|
||||
} else {
|
||||
$struc['files'] = array();
|
||||
}
|
||||
}
|
||||
|
||||
$ret[ $struc['name'] ] = $struc;
|
||||
}
|
||||
$dir->close();
|
||||
unset($dir);
|
||||
unset( $dir );
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
|||
public $link;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $opt
|
||||
*/
|
||||
public function __construct( $opt = '' ) {
|
||||
|
@ -25,66 +24,76 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
|||
$this->errors = new WP_Error();
|
||||
|
||||
// Check if possible to use ftp functions.
|
||||
if ( ! extension_loaded('ftp') ) {
|
||||
$this->errors->add('no_ftp_ext', __('The ftp PHP extension is not available'));
|
||||
if ( ! extension_loaded( 'ftp' ) ) {
|
||||
$this->errors->add( 'no_ftp_ext', __( 'The ftp PHP extension is not available' ) );
|
||||
return;
|
||||
}
|
||||
|
||||
// This Class uses the timeout on a per-connection basis, Others use it on a per-action basis.
|
||||
|
||||
if ( ! defined('FS_TIMEOUT') )
|
||||
define('FS_TIMEOUT', 240);
|
||||
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']) )
|
||||
$this->errors->add('empty_hostname', __('FTP hostname is required'));
|
||||
else
|
||||
if ( empty( $opt['hostname'] ) ) {
|
||||
$this->errors->add( 'empty_hostname', __( 'FTP hostname is required' ) );
|
||||
} else {
|
||||
$this->options['hostname'] = $opt['hostname'];
|
||||
}
|
||||
|
||||
// Check if the options provided are OK.
|
||||
if ( empty($opt['username']) )
|
||||
$this->errors->add('empty_username', __('FTP username is required'));
|
||||
else
|
||||
if ( empty( $opt['username'] ) ) {
|
||||
$this->errors->add( 'empty_username', __( 'FTP username is required' ) );
|
||||
} else {
|
||||
$this->options['username'] = $opt['username'];
|
||||
}
|
||||
|
||||
if ( empty($opt['password']) )
|
||||
$this->errors->add('empty_password', __('FTP password is required'));
|
||||
else
|
||||
if ( empty( $opt['password'] ) ) {
|
||||
$this->errors->add( 'empty_password', __( 'FTP password is required' ) );
|
||||
} 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') )
|
||||
$this->link = @ftp_ssl_connect($this->options['hostname'], $this->options['port'], FS_CONNECT_TIMEOUT);
|
||||
else
|
||||
$this->link = @ftp_connect($this->options['hostname'], $this->options['port'], FS_CONNECT_TIMEOUT);
|
||||
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 {
|
||||
$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']
|
||||
)
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! @ftp_login( $this->link,$this->options['username'], $this->options['password'] ) ) {
|
||||
$this->errors->add( 'auth',
|
||||
if ( ! @ftp_login( $this->link, $this->options['username'], $this->options['password'] ) ) {
|
||||
$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 )
|
||||
@ftp_set_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;
|
||||
}
|
||||
|
@ -109,8 +119,8 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
|||
* or if the file couldn't be retrieved.
|
||||
*/
|
||||
public function get_contents( $file ) {
|
||||
$tempfile = wp_tempnam($file);
|
||||
$temp = fopen($tempfile, 'w+');
|
||||
$tempfile = wp_tempnam( $file );
|
||||
$temp = fopen( $tempfile, 'w+' );
|
||||
|
||||
if ( ! $temp ) {
|
||||
unlink( $tempfile );
|
||||
|
@ -126,33 +136,32 @@ 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) )
|
||||
$contents .= fread($temp, 8192);
|
||||
while ( ! feof( $temp ) ) {
|
||||
$contents .= fread( $temp, 8192 );
|
||||
}
|
||||
|
||||
fclose($temp);
|
||||
unlink($tempfile);
|
||||
fclose( $temp );
|
||||
unlink( $tempfile );
|
||||
return $contents;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @return array
|
||||
*/
|
||||
public function get_contents_array($file) {
|
||||
return explode("\n", $this->get_contents($file));
|
||||
public function get_contents_array( $file ) {
|
||||
return explode( "\n", $this->get_contents( $file ) );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @param string $contents
|
||||
* @param bool|int $mode
|
||||
* @return bool
|
||||
*/
|
||||
public function put_contents($file, $contents, $mode = false ) {
|
||||
$tempfile = wp_tempnam($file);
|
||||
$temp = fopen( $tempfile, 'wb+' );
|
||||
public function put_contents( $file, $contents, $mode = false ) {
|
||||
$tempfile = wp_tempnam( $file );
|
||||
$temp = fopen( $tempfile, 'wb+' );
|
||||
|
||||
if ( ! $temp ) {
|
||||
unlink( $tempfile );
|
||||
|
@ -161,7 +170,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
|||
|
||||
mbstring_binary_safe_encoding();
|
||||
|
||||
$data_length = strlen( $contents );
|
||||
$data_length = strlen( $contents );
|
||||
$bytes_written = fwrite( $temp, $contents );
|
||||
|
||||
reset_mbstring_encoding();
|
||||
|
@ -176,334 +185,331 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
|||
|
||||
$ret = @ftp_fput( $this->link, $file, $temp, FTP_BINARY );
|
||||
|
||||
fclose($temp);
|
||||
unlink($tempfile);
|
||||
fclose( $temp );
|
||||
unlink( $tempfile );
|
||||
|
||||
$this->chmod($file, $mode);
|
||||
$this->chmod( $file, $mode );
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function cwd() {
|
||||
$cwd = @ftp_pwd($this->link);
|
||||
if ( $cwd )
|
||||
$cwd = trailingslashit($cwd);
|
||||
$cwd = @ftp_pwd( $this->link );
|
||||
if ( $cwd ) {
|
||||
$cwd = trailingslashit( $cwd );
|
||||
}
|
||||
return $cwd;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $dir
|
||||
* @return bool
|
||||
*/
|
||||
public function chdir($dir) {
|
||||
return @ftp_chdir($this->link, $dir);
|
||||
public function chdir( $dir ) {
|
||||
return @ftp_chdir( $this->link, $dir );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @param int $mode
|
||||
* @param bool $recursive
|
||||
* @return bool
|
||||
*/
|
||||
public function chmod($file, $mode = false, $recursive = false) {
|
||||
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 )
|
||||
$this->chmod($file . '/' . $filename, $mode, $recursive);
|
||||
if ( $recursive && $this->is_dir( $file ) ) {
|
||||
$filelist = $this->dirlist( $file );
|
||||
foreach ( (array) $filelist as $filename => $filemeta ) {
|
||||
$this->chmod( $file . '/' . $filename, $mode, $recursive );
|
||||
}
|
||||
}
|
||||
|
||||
// chmod the file or directory
|
||||
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);
|
||||
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
|
||||
*/
|
||||
public function owner($file) {
|
||||
$dir = $this->dirlist($file);
|
||||
return $dir[$file]['owner'];
|
||||
public function owner( $file ) {
|
||||
$dir = $this->dirlist( $file );
|
||||
return $dir[ $file ]['owner'];
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @return string
|
||||
*/
|
||||
public function getchmod($file) {
|
||||
$dir = $this->dirlist($file);
|
||||
return $dir[$file]['permsn'];
|
||||
public function getchmod( $file ) {
|
||||
$dir = $this->dirlist( $file );
|
||||
return $dir[ $file ]['permsn'];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @return string
|
||||
*/
|
||||
public function group($file) {
|
||||
$dir = $this->dirlist($file);
|
||||
return $dir[$file]['group'];
|
||||
public function group( $file ) {
|
||||
$dir = $this->dirlist( $file );
|
||||
return $dir[ $file ]['group'];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $source
|
||||
* @param string $destination
|
||||
* @param bool $overwrite
|
||||
* @param string|bool $mode
|
||||
* @return bool
|
||||
*/
|
||||
public function copy($source, $destination, $overwrite = false, $mode = false) {
|
||||
if ( ! $overwrite && $this->exists($destination) )
|
||||
public function copy( $source, $destination, $overwrite = false, $mode = false ) {
|
||||
if ( ! $overwrite && $this->exists( $destination ) ) {
|
||||
return false;
|
||||
$content = $this->get_contents($source);
|
||||
if ( false === $content )
|
||||
}
|
||||
$content = $this->get_contents( $source );
|
||||
if ( false === $content ) {
|
||||
return false;
|
||||
return $this->put_contents($destination, $content, $mode);
|
||||
}
|
||||
return $this->put_contents( $destination, $content, $mode );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $source
|
||||
* @param string $destination
|
||||
* @param bool $overwrite
|
||||
* @return bool
|
||||
*/
|
||||
public function move($source, $destination, $overwrite = false) {
|
||||
return ftp_rename($this->link, $source, $destination);
|
||||
public function move( $source, $destination, $overwrite = false ) {
|
||||
return ftp_rename( $this->link, $source, $destination );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @param bool $recursive
|
||||
* @param string $type
|
||||
* @return bool
|
||||
*/
|
||||
public function delete($file, $recursive = false, $type = false) {
|
||||
if ( empty($file) )
|
||||
public function delete( $file, $recursive = false, $type = false ) {
|
||||
if ( empty( $file ) ) {
|
||||
return false;
|
||||
if ( 'f' == $type || $this->is_file($file) )
|
||||
return @ftp_delete($this->link, $file);
|
||||
if ( !$recursive )
|
||||
return @ftp_rmdir($this->link, $file);
|
||||
}
|
||||
if ( 'f' == $type || $this->is_file( $file ) ) {
|
||||
return @ftp_delete( $this->link, $file );
|
||||
}
|
||||
if ( ! $recursive ) {
|
||||
return @ftp_rmdir( $this->link, $file );
|
||||
}
|
||||
|
||||
$filelist = $this->dirlist( trailingslashit($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);
|
||||
$filelist = $this->dirlist( trailingslashit( $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
|
||||
*/
|
||||
public function exists($file) {
|
||||
$list = @ftp_nlist($this->link, $file);
|
||||
public function exists( $file ) {
|
||||
$list = @ftp_nlist( $this->link, $file );
|
||||
|
||||
if ( empty( $list ) && $this->is_dir( $file ) ) {
|
||||
return true; // File is an empty directory.
|
||||
}
|
||||
|
||||
return !empty($list); //empty list = no file, so invert.
|
||||
return ! empty( $list ); //empty list = no file, so invert.
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @return bool
|
||||
*/
|
||||
public function is_file($file) {
|
||||
return $this->exists($file) && !$this->is_dir($file);
|
||||
public function is_file( $file ) {
|
||||
return $this->exists( $file ) && ! $this->is_dir( $file );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $path
|
||||
* @return bool
|
||||
*/
|
||||
public function is_dir($path) {
|
||||
$cwd = $this->cwd();
|
||||
$result = @ftp_chdir($this->link, trailingslashit($path) );
|
||||
public function is_dir( $path ) {
|
||||
$cwd = $this->cwd();
|
||||
$result = @ftp_chdir( $this->link, trailingslashit( $path ) );
|
||||
if ( $result && $path == $this->cwd() || $this->cwd() != $cwd ) {
|
||||
@ftp_chdir($this->link, $cwd);
|
||||
@ftp_chdir( $this->link, $cwd );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @return bool
|
||||
*/
|
||||
public function is_readable($file) {
|
||||
public function is_readable( $file ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @return bool
|
||||
*/
|
||||
public function is_writable($file) {
|
||||
public function is_writable( $file ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @return bool
|
||||
*/
|
||||
public function atime($file) {
|
||||
public function atime( $file ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @return int
|
||||
*/
|
||||
public function mtime($file) {
|
||||
return ftp_mdtm($this->link, $file);
|
||||
public function mtime( $file ) {
|
||||
return ftp_mdtm( $this->link, $file );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @return int
|
||||
*/
|
||||
public function size($file) {
|
||||
return ftp_size($this->link, $file);
|
||||
public function size( $file ) {
|
||||
return ftp_size( $this->link, $file );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @return bool
|
||||
*/
|
||||
public function touch($file, $time = 0, $atime = 0) {
|
||||
public function touch( $file, $time = 0, $atime = 0 ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $path
|
||||
* @param mixed $chmod
|
||||
* @param mixed $chown
|
||||
* @param mixed $chgrp
|
||||
* @return bool
|
||||
*/
|
||||
public function mkdir($path, $chmod = false, $chown = false, $chgrp = false) {
|
||||
$path = untrailingslashit($path);
|
||||
if ( empty($path) )
|
||||
public function mkdir( $path, $chmod = false, $chown = false, $chgrp = false ) {
|
||||
$path = untrailingslashit( $path );
|
||||
if ( empty( $path ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( !@ftp_mkdir($this->link, $path) )
|
||||
if ( ! @ftp_mkdir( $this->link, $path ) ) {
|
||||
return false;
|
||||
$this->chmod($path, $chmod);
|
||||
}
|
||||
$this->chmod( $path, $chmod );
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $path
|
||||
* @param bool $recursive
|
||||
* @return bool
|
||||
*/
|
||||
public function rmdir($path, $recursive = false) {
|
||||
return $this->delete($path, $recursive);
|
||||
public function rmdir( $path, $recursive = false ) {
|
||||
return $this->delete( $path, $recursive );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @staticvar bool $is_windows
|
||||
* @param string $line
|
||||
* @return array
|
||||
*/
|
||||
public function parselisting($line) {
|
||||
public function parselisting( $line ) {
|
||||
static $is_windows = null;
|
||||
if ( is_null($is_windows) )
|
||||
$is_windows = stripos( ftp_systype($this->link), 'win') !== false;
|
||||
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) ) {
|
||||
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 )
|
||||
$lucifer[3] +=2000;
|
||||
else
|
||||
if ( $lucifer[3] < 70 ) {
|
||||
$lucifer[3] += 2000;
|
||||
} else {
|
||||
$lucifer[3] += 1900; // 4digit year fix
|
||||
$b['isdir'] = ( $lucifer[7] == '<DIR>');
|
||||
if ( $b['isdir'] )
|
||||
}
|
||||
$b['isdir'] = ( $lucifer[7] == '<DIR>' );
|
||||
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['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['am/pm'] = $lucifer[6];
|
||||
$b['name'] = $lucifer[8];
|
||||
} elseif ( !$is_windows && $lucifer = preg_split('/[ ]/', $line, 9, PREG_SPLIT_NO_EMPTY)) {
|
||||
$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 )
|
||||
$lcount = count( $lucifer );
|
||||
if ( $lcount < 8 ) {
|
||||
return '';
|
||||
$b = array();
|
||||
$b['isdir'] = $lucifer[0]{0} === 'd';
|
||||
}
|
||||
$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['perms'] = $lucifer[0];
|
||||
$b['permsn'] = $this->getnumchmodfromh( $b['perms'] );
|
||||
$b['number'] = $lucifer[1];
|
||||
$b['owner'] = $lucifer[2];
|
||||
$b['group'] = $lucifer[3];
|
||||
$b['size'] = $lucifer[4];
|
||||
$b['owner'] = $lucifer[2];
|
||||
$b['group'] = $lucifer[3];
|
||||
$b['size'] = $lucifer[4];
|
||||
if ( $lcount == 8 ) {
|
||||
sscanf($lucifer[5], '%d-%d-%d', $b['year'], $b['month'], $b['day']);
|
||||
sscanf($lucifer[6], '%d:%d', $b['hour'], $b['minute']);
|
||||
$b['time'] = @mktime($b['hour'], $b['minute'], 0, $b['month'], $b['day'], $b['year']);
|
||||
sscanf( $lucifer[5], '%d-%d-%d', $b['year'], $b['month'], $b['day'] );
|
||||
sscanf( $lucifer[6], '%d:%d', $b['hour'], $b['minute'] );
|
||||
$b['time'] = @mktime( $b['hour'], $b['minute'], 0, $b['month'], $b['day'], $b['year'] );
|
||||
$b['name'] = $lucifer[7];
|
||||
} else {
|
||||
$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['hour'] = $l2[1];
|
||||
$b['day'] = $lucifer[6];
|
||||
if ( preg_match( '/([0-9]{2}):([0-9]{2})/', $lucifer[7], $l2 ) ) {
|
||||
$b['year'] = date( 'Y' );
|
||||
$b['hour'] = $l2[1];
|
||||
$b['minute'] = $l2[2];
|
||||
} else {
|
||||
$b['year'] = $lucifer[7];
|
||||
$b['hour'] = 0;
|
||||
$b['year'] = $lucifer[7];
|
||||
$b['hour'] = 0;
|
||||
$b['minute'] = 0;
|
||||
}
|
||||
$b['time'] = strtotime( sprintf('%d %s %d %02d:%02d', $b['day'], $b['month'], $b['year'], $b['hour'], $b['minute']) );
|
||||
$b['time'] = strtotime( sprintf( '%d %s %d %02d:%02d', $b['day'], $b['month'], $b['year'], $b['hour'], $b['minute'] ) );
|
||||
$b['name'] = $lucifer[8];
|
||||
}
|
||||
}
|
||||
|
@ -517,54 +523,60 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $path
|
||||
* @param bool $include_hidden
|
||||
* @param bool $recursive
|
||||
* @return bool|array
|
||||
*/
|
||||
public function dirlist($path = '.', $include_hidden = true, $recursive = false) {
|
||||
if ( $this->is_file($path) ) {
|
||||
$limit_file = basename($path);
|
||||
$path = dirname($path) . '/';
|
||||
public function dirlist( $path = '.', $include_hidden = true, $recursive = false ) {
|
||||
if ( $this->is_file( $path ) ) {
|
||||
$limit_file = basename( $path );
|
||||
$path = dirname( $path ) . '/';
|
||||
} else {
|
||||
$limit_file = false;
|
||||
}
|
||||
|
||||
$pwd = @ftp_pwd($this->link);
|
||||
if ( ! @ftp_chdir($this->link, $path) ) // Cant change to folder = folder doesn't exist
|
||||
$pwd = @ftp_pwd( $this->link );
|
||||
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);
|
||||
}
|
||||
$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) )
|
||||
$entry = $this->parselisting( $v );
|
||||
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;
|
||||
}
|
||||
|
||||
$ret = array();
|
||||
foreach ( (array)$dirlist as $struc ) {
|
||||
foreach ( (array) $dirlist as $struc ) {
|
||||
if ( 'd' == $struc['type'] ) {
|
||||
if ( $recursive )
|
||||
$struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive);
|
||||
else
|
||||
if ( $recursive ) {
|
||||
$struc['files'] = $this->dirlist( $path . '/' . $struc['name'], $include_hidden, $recursive );
|
||||
} 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 )
|
||||
ftp_close($this->link);
|
||||
if ( $this->link ) {
|
||||
ftp_close( $this->link );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,10 +20,9 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
|||
public $ftp;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $opt
|
||||
*/
|
||||
public function __construct( $opt = '' ) {
|
||||
public function __construct( $opt = '' ) {
|
||||
$this->method = 'ftpsockets';
|
||||
$this->errors = new WP_Error();
|
||||
|
||||
|
@ -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']) )
|
||||
$this->errors->add('empty_hostname', __('FTP hostname is required'));
|
||||
else
|
||||
if ( empty( $opt['hostname'] ) ) {
|
||||
$this->errors->add( 'empty_hostname', __( 'FTP hostname is required' ) );
|
||||
} else {
|
||||
$this->options['hostname'] = $opt['hostname'];
|
||||
}
|
||||
|
||||
// Check if the options provided are OK.
|
||||
if ( empty ($opt['username']) )
|
||||
$this->errors->add('empty_username', __('FTP username is required'));
|
||||
else
|
||||
if ( empty( $opt['username'] ) ) {
|
||||
$this->errors->add( 'empty_username', __( 'FTP username is required' ) );
|
||||
} else {
|
||||
$this->options['username'] = $opt['username'];
|
||||
}
|
||||
|
||||
if ( empty ($opt['password']) )
|
||||
$this->errors->add('empty_password', __('FTP password is required'));
|
||||
else
|
||||
if ( empty( $opt['password'] ) ) {
|
||||
$this->errors->add( 'empty_password', __( 'FTP password is required' ) );
|
||||
} 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);
|
||||
$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 );
|
||||
|
||||
|
@ -123,9 +133,9 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
|||
|
||||
mbstring_binary_safe_encoding();
|
||||
|
||||
if ( ! $this->ftp->fget($temphandle, $file) ) {
|
||||
fclose($temphandle);
|
||||
unlink($temp);
|
||||
if ( ! $this->ftp->fget( $temphandle, $file ) ) {
|
||||
fclose( $temphandle );
|
||||
unlink( $temp );
|
||||
|
||||
reset_mbstring_encoding();
|
||||
|
||||
|
@ -137,34 +147,33 @@ 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) )
|
||||
$contents .= fread($temphandle, 8192);
|
||||
while ( ! feof( $temphandle ) ) {
|
||||
$contents .= fread( $temphandle, 8192 );
|
||||
}
|
||||
|
||||
fclose($temphandle);
|
||||
unlink($temp);
|
||||
fclose( $temphandle );
|
||||
unlink( $temp );
|
||||
return $contents;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @return array
|
||||
*/
|
||||
public function get_contents_array($file) {
|
||||
return explode("\n", $this->get_contents($file) );
|
||||
public function get_contents_array( $file ) {
|
||||
return explode( "\n", $this->get_contents( $file ) );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @param string $contents
|
||||
* @param int|bool $mode
|
||||
* @return bool
|
||||
*/
|
||||
public function put_contents($file, $contents, $mode = false ) {
|
||||
public function put_contents( $file, $contents, $mode = false ) {
|
||||
$temp = wp_tempnam( $file );
|
||||
if ( ! $temphandle = @fopen($temp, 'w+') ) {
|
||||
unlink($temp);
|
||||
if ( ! $temphandle = @fopen( $temp, 'w+' ) ) {
|
||||
unlink( $temp );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -183,146 +192,144 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
|||
|
||||
fseek( $temphandle, 0 ); // Skip back to the start of the file being written to
|
||||
|
||||
$ret = $this->ftp->fput($file, $temphandle);
|
||||
$ret = $this->ftp->fput( $file, $temphandle );
|
||||
|
||||
reset_mbstring_encoding();
|
||||
|
||||
fclose($temphandle);
|
||||
unlink($temp);
|
||||
fclose( $temphandle );
|
||||
unlink( $temp );
|
||||
|
||||
$this->chmod($file, $mode);
|
||||
$this->chmod( $file, $mode );
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function cwd() {
|
||||
$cwd = $this->ftp->pwd();
|
||||
if ( $cwd )
|
||||
$cwd = trailingslashit($cwd);
|
||||
if ( $cwd ) {
|
||||
$cwd = trailingslashit( $cwd );
|
||||
}
|
||||
return $cwd;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @return bool
|
||||
*/
|
||||
public function chdir($file) {
|
||||
return $this->ftp->chdir($file);
|
||||
public function chdir( $file ) {
|
||||
return $this->ftp->chdir( $file );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @param int|bool $mode
|
||||
* @param bool $recursive
|
||||
* @return bool
|
||||
*/
|
||||
public function chmod($file, $mode = false, $recursive = false ) {
|
||||
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 )
|
||||
$this->chmod($file . '/' . $filename, $mode, $recursive);
|
||||
if ( $recursive && $this->is_dir( $file ) ) {
|
||||
$filelist = $this->dirlist( $file );
|
||||
foreach ( (array) $filelist as $filename => $filemeta ) {
|
||||
$this->chmod( $file . '/' . $filename, $mode, $recursive );
|
||||
}
|
||||
}
|
||||
|
||||
// chmod the file or directory
|
||||
return $this->ftp->chmod($file, $mode);
|
||||
return $this->ftp->chmod( $file, $mode );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @return string
|
||||
*/
|
||||
public function owner($file) {
|
||||
$dir = $this->dirlist($file);
|
||||
return $dir[$file]['owner'];
|
||||
public function owner( $file ) {
|
||||
$dir = $this->dirlist( $file );
|
||||
return $dir[ $file ]['owner'];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @return string
|
||||
*/
|
||||
public function getchmod($file) {
|
||||
$dir = $this->dirlist($file);
|
||||
return $dir[$file]['permsn'];
|
||||
public function getchmod( $file ) {
|
||||
$dir = $this->dirlist( $file );
|
||||
return $dir[ $file ]['permsn'];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @return string
|
||||
*/
|
||||
public function group($file) {
|
||||
$dir = $this->dirlist($file);
|
||||
return $dir[$file]['group'];
|
||||
public function group( $file ) {
|
||||
$dir = $this->dirlist( $file );
|
||||
return $dir[ $file ]['group'];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $source
|
||||
* @param string $destination
|
||||
* @param bool $overwrite
|
||||
* @param int|bool $mode
|
||||
* @return bool
|
||||
*/
|
||||
public function copy($source, $destination, $overwrite = false, $mode = false) {
|
||||
if ( ! $overwrite && $this->exists($destination) )
|
||||
public function copy( $source, $destination, $overwrite = false, $mode = false ) {
|
||||
if ( ! $overwrite && $this->exists( $destination ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$content = $this->get_contents($source);
|
||||
if ( false === $content )
|
||||
$content = $this->get_contents( $source );
|
||||
if ( false === $content ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->put_contents($destination, $content, $mode);
|
||||
return $this->put_contents( $destination, $content, $mode );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $source
|
||||
* @param string $destination
|
||||
* @param bool $overwrite
|
||||
* @return bool
|
||||
*/
|
||||
public function move($source, $destination, $overwrite = false ) {
|
||||
return $this->ftp->rename($source, $destination);
|
||||
public function move( $source, $destination, $overwrite = false ) {
|
||||
return $this->ftp->rename( $source, $destination );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @param bool $recursive
|
||||
* @param string $type
|
||||
* @return bool
|
||||
*/
|
||||
public function delete($file, $recursive = false, $type = false) {
|
||||
if ( empty($file) )
|
||||
public function delete( $file, $recursive = false, $type = false ) {
|
||||
if ( empty( $file ) ) {
|
||||
return false;
|
||||
if ( 'f' == $type || $this->is_file($file) )
|
||||
return $this->ftp->delete($file);
|
||||
if ( !$recursive )
|
||||
return $this->ftp->rmdir($file);
|
||||
}
|
||||
if ( 'f' == $type || $this->is_file( $file ) ) {
|
||||
return $this->ftp->delete( $file );
|
||||
}
|
||||
if ( ! $recursive ) {
|
||||
return $this->ftp->rmdir( $file );
|
||||
}
|
||||
|
||||
return $this->ftp->mdel($file);
|
||||
return $this->ftp->mdel( $file );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @return bool
|
||||
*/
|
||||
|
@ -333,141 +340,136 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
|||
return true; // File is an empty directory.
|
||||
}
|
||||
|
||||
return !empty( $list ); //empty list = no file, so invert.
|
||||
return ! empty( $list ); //empty list = no file, so invert.
|
||||
// Return $this->ftp->is_exists($file); has issues with ABOR+426 responses on the ncFTPd server.
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @return bool
|
||||
*/
|
||||
public function is_file($file) {
|
||||
if ( $this->is_dir($file) )
|
||||
public function is_file( $file ) {
|
||||
if ( $this->is_dir( $file ) ) {
|
||||
return false;
|
||||
if ( $this->exists($file) )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $path
|
||||
* @return bool
|
||||
*/
|
||||
public function is_dir($path) {
|
||||
$cwd = $this->cwd();
|
||||
if ( $this->chdir($path) ) {
|
||||
$this->chdir($cwd);
|
||||
}
|
||||
if ( $this->exists( $file ) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @param string $path
|
||||
* @return bool
|
||||
*/
|
||||
public function is_readable($file) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @return bool
|
||||
*/
|
||||
public function is_writable($file) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @return bool
|
||||
*/
|
||||
public function atime($file) {
|
||||
public function is_dir( $path ) {
|
||||
$cwd = $this->cwd();
|
||||
if ( $this->chdir( $path ) ) {
|
||||
$this->chdir( $cwd );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @return int
|
||||
* @return bool
|
||||
*/
|
||||
public function mtime($file) {
|
||||
return $this->ftp->mdtm($file);
|
||||
public function is_readable( $file ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return bool
|
||||
*/
|
||||
public function is_writable( $file ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return bool
|
||||
*/
|
||||
public function atime( $file ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return int
|
||||
*/
|
||||
public function size($file) {
|
||||
return $this->ftp->filesize($file);
|
||||
public function mtime( $file ) {
|
||||
return $this->ftp->mdtm( $file );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return int
|
||||
*/
|
||||
public function size( $file ) {
|
||||
return $this->ftp->filesize( $file );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @param int $time
|
||||
* @param int $atime
|
||||
* @return bool
|
||||
*/
|
||||
public function touch($file, $time = 0, $atime = 0 ) {
|
||||
public function touch( $file, $time = 0, $atime = 0 ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $path
|
||||
* @param mixed $chmod
|
||||
* @param mixed $chown
|
||||
* @param mixed $chgrp
|
||||
* @return bool
|
||||
*/
|
||||
public function mkdir($path, $chmod = false, $chown = false, $chgrp = false ) {
|
||||
$path = untrailingslashit($path);
|
||||
if ( empty($path) )
|
||||
public function mkdir( $path, $chmod = false, $chown = false, $chgrp = false ) {
|
||||
$path = untrailingslashit( $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);
|
||||
}
|
||||
$this->chmod( $path, $chmod );
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $path
|
||||
* @param bool $recursive
|
||||
* @return bool
|
||||
*/
|
||||
public function rmdir($path, $recursive = false ) {
|
||||
return $this->delete($path, $recursive);
|
||||
public function rmdir( $path, $recursive = false ) {
|
||||
return $this->delete( $path, $recursive );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $path
|
||||
* @param bool $include_hidden
|
||||
* @param bool $recursive
|
||||
* @return bool|array
|
||||
*/
|
||||
public function dirlist($path = '.', $include_hidden = true, $recursive = false ) {
|
||||
if ( $this->is_file($path) ) {
|
||||
$limit_file = basename($path);
|
||||
$path = dirname($path) . '/';
|
||||
public function dirlist( $path = '.', $include_hidden = true, $recursive = false ) {
|
||||
if ( $this->is_file( $path ) ) {
|
||||
$limit_file = basename( $path );
|
||||
$path = dirname( $path ) . '/';
|
||||
} else {
|
||||
$limit_file = false;
|
||||
}
|
||||
|
||||
mbstring_binary_safe_encoding();
|
||||
|
||||
$list = $this->ftp->dirlist($path);
|
||||
$list = $this->ftp->dirlist( $path );
|
||||
if ( empty( $list ) && ! $this->exists( $path ) ) {
|
||||
|
||||
reset_mbstring_encoding();
|
||||
|
@ -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 )
|
||||
$struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive);
|
||||
else
|
||||
if ( $recursive ) {
|
||||
$struc['files'] = $this->dirlist( $path . '/' . $struc['name'], $include_hidden, $recursive );
|
||||
} 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'] );
|
||||
|
|
|
@ -46,7 +46,6 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
|||
public $keys = false;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $opt
|
||||
*/
|
||||
public function __construct( $opt = '' ) {
|
||||
|
@ -54,11 +53,11 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
|||
$this->errors = new WP_Error();
|
||||
|
||||
//Check if possible to use ssh2 functions.
|
||||
if ( ! extension_loaded('ssh2') ) {
|
||||
$this->errors->add('no_ssh2_ext', __('The ssh2 PHP extension is not available'));
|
||||
if ( ! extension_loaded( 'ssh2' ) ) {
|
||||
$this->errors->add( 'no_ssh2_ext', __( 'The ssh2 PHP extension is not available' ) );
|
||||
return;
|
||||
}
|
||||
if ( !function_exists('stream_get_contents') ) {
|
||||
if ( ! function_exists( 'stream_get_contents' ) ) {
|
||||
$this->errors->add(
|
||||
'ssh2_php_requirement',
|
||||
sprintf(
|
||||
|
@ -71,76 +70,85 @@ 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']) )
|
||||
$this->errors->add('empty_hostname', __('SSH2 hostname is required'));
|
||||
else
|
||||
$this->options['hostname'] = $opt['hostname'];
|
||||
|
||||
// Check if the options provided are OK.
|
||||
if ( !empty ($opt['public_key']) && !empty ($opt['private_key']) ) {
|
||||
$this->options['public_key'] = $opt['public_key'];
|
||||
$this->options['private_key'] = $opt['private_key'];
|
||||
|
||||
$this->options['hostkey'] = array('hostkey' => 'ssh-rsa');
|
||||
|
||||
$this->keys = true;
|
||||
} elseif ( empty ($opt['username']) ) {
|
||||
$this->errors->add('empty_username', __('SSH2 username is required'));
|
||||
}
|
||||
|
||||
if ( !empty($opt['username']) )
|
||||
$this->options['username'] = $opt['username'];
|
||||
if ( empty( $opt['hostname'] ) ) {
|
||||
$this->errors->add( 'empty_hostname', __( 'SSH2 hostname is required' ) );
|
||||
} else {
|
||||
$this->options['hostname'] = $opt['hostname'];
|
||||
}
|
||||
|
||||
if ( empty ($opt['password']) ) {
|
||||
// Check if the options provided are OK.
|
||||
if ( ! empty( $opt['public_key'] ) && ! empty( $opt['private_key'] ) ) {
|
||||
$this->options['public_key'] = $opt['public_key'];
|
||||
$this->options['private_key'] = $opt['private_key'];
|
||||
|
||||
$this->options['hostkey'] = array( 'hostkey' => 'ssh-rsa' );
|
||||
|
||||
$this->keys = true;
|
||||
} elseif ( empty( $opt['username'] ) ) {
|
||||
$this->errors->add( 'empty_username', __( 'SSH2 username is required' ) );
|
||||
}
|
||||
|
||||
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 )
|
||||
$this->errors->add('empty_password', __('SSH2 password is required'));
|
||||
if ( ! $this->keys ) {
|
||||
$this->errors->add( 'empty_password', __( 'SSH2 password is required' ) );
|
||||
}
|
||||
} else {
|
||||
$this->options['password'] = $opt['password'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function connect() {
|
||||
if ( ! $this->keys ) {
|
||||
$this->link = @ssh2_connect($this->options['hostname'], $this->options['port']);
|
||||
$this->link = @ssh2_connect( $this->options['hostname'], $this->options['port'] );
|
||||
} else {
|
||||
$this->link = @ssh2_connect($this->options['hostname'], $this->options['port'], $this->options['hostkey']);
|
||||
$this->link = @ssh2_connect( $this->options['hostname'], $this->options['port'], $this->options['hostkey'] );
|
||||
}
|
||||
|
||||
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']
|
||||
)
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( !$this->keys ) {
|
||||
if ( ! @ssh2_auth_password($this->link, $this->options['username'], $this->options['password']) ) {
|
||||
$this->errors->add( 'auth',
|
||||
if ( ! $this->keys ) {
|
||||
if ( ! @ssh2_auth_password( $this->link, $this->options['username'], $this->options['password'] ) ) {
|
||||
$this->errors->add(
|
||||
'auth',
|
||||
/* translators: %s: username */
|
||||
sprintf( __( 'Username/Password incorrect for %s' ),
|
||||
sprintf(
|
||||
__( 'Username/Password incorrect for %s' ),
|
||||
$this->options['username']
|
||||
)
|
||||
);
|
||||
return false;
|
||||
}
|
||||
} 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',
|
||||
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',
|
||||
/* 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',
|
||||
if ( ! ( $stream = ssh2_exec( $this->link, $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 )
|
||||
return ( $data === false ) ? false : '' != trim($data);
|
||||
else
|
||||
if ( $returnbool ) {
|
||||
return ( $data === false ) ? false : '' != trim( $data );
|
||||
} else {
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @return string|false
|
||||
*/
|
||||
|
@ -225,34 +236,32 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @return array
|
||||
*/
|
||||
public function get_contents_array($file) {
|
||||
public function get_contents_array( $file ) {
|
||||
return file( $this->sftp_path( $file ) );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @param string $contents
|
||||
* @param bool|int $mode
|
||||
* @return bool
|
||||
*/
|
||||
public function put_contents($file, $contents, $mode = false ) {
|
||||
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);
|
||||
$this->chmod( $file, $mode );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function cwd() {
|
||||
|
@ -264,336 +273,340 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $dir
|
||||
* @return bool|string
|
||||
*/
|
||||
public function chdir($dir) {
|
||||
return $this->run_command('cd ' . $dir, true);
|
||||
public function chdir( $dir ) {
|
||||
return $this->run_command( 'cd ' . $dir, true );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @param string $group
|
||||
* @param bool $recursive
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function chgrp($file, $group, $recursive = false ) {
|
||||
if ( ! $this->exists($file) )
|
||||
public function chgrp( $file, $group, $recursive = false ) {
|
||||
if ( ! $this->exists( $file ) ) {
|
||||
return false;
|
||||
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);
|
||||
}
|
||||
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) )
|
||||
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
|
||||
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);
|
||||
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) )
|
||||
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);
|
||||
}
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
$ownerarray = posix_getpwuid( $owneruid );
|
||||
return $ownerarray['name'];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @return string
|
||||
*/
|
||||
public function getchmod($file) {
|
||||
public function getchmod( $file ) {
|
||||
return substr( decoct( @fileperms( $this->sftp_path( $file ) ) ), -3 );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @return string|false
|
||||
*/
|
||||
public function group($file) {
|
||||
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);
|
||||
}
|
||||
$grouparray = posix_getgrgid( $gid );
|
||||
return $grouparray['name'];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $source
|
||||
* @param string $destination
|
||||
* @param bool $overwrite
|
||||
* @param int|bool $mode
|
||||
* @return bool
|
||||
*/
|
||||
public function copy($source, $destination, $overwrite = false, $mode = false) {
|
||||
if ( ! $overwrite && $this->exists($destination) )
|
||||
public function copy( $source, $destination, $overwrite = false, $mode = false ) {
|
||||
if ( ! $overwrite && $this->exists( $destination ) ) {
|
||||
return false;
|
||||
$content = $this->get_contents($source);
|
||||
if ( false === $content)
|
||||
}
|
||||
$content = $this->get_contents( $source );
|
||||
if ( false === $content ) {
|
||||
return false;
|
||||
return $this->put_contents($destination, $content, $mode);
|
||||
}
|
||||
return $this->put_contents( $destination, $content, $mode );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $source
|
||||
* @param string $destination
|
||||
* @param bool $overwrite
|
||||
* @return bool
|
||||
*/
|
||||
public function move($source, $destination, $overwrite = false) {
|
||||
public function move( $source, $destination, $overwrite = false ) {
|
||||
return @ssh2_sftp_rename( $this->sftp_link, $source, $destination );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @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) )
|
||||
return ssh2_sftp_unlink($this->sftp_link, $file);
|
||||
if ( ! $recursive )
|
||||
return ssh2_sftp_rmdir($this->sftp_link, $file);
|
||||
$filelist = $this->dirlist($file);
|
||||
if ( is_array($filelist) ) {
|
||||
foreach ( $filelist as $filename => $fileinfo) {
|
||||
$this->delete($file . '/' . $filename, $recursive, $fileinfo['type']);
|
||||
public function delete( $file, $recursive = false, $type = false ) {
|
||||
if ( 'f' == $type || $this->is_file( $file ) ) {
|
||||
return ssh2_sftp_unlink( $this->sftp_link, $file );
|
||||
}
|
||||
if ( ! $recursive ) {
|
||||
return ssh2_sftp_rmdir( $this->sftp_link, $file );
|
||||
}
|
||||
$filelist = $this->dirlist( $file );
|
||||
if ( is_array( $filelist ) ) {
|
||||
foreach ( $filelist as $filename => $fileinfo ) {
|
||||
$this->delete( $file . '/' . $filename, $recursive, $fileinfo['type'] );
|
||||
}
|
||||
}
|
||||
return ssh2_sftp_rmdir($this->sftp_link, $file);
|
||||
return ssh2_sftp_rmdir( $this->sftp_link, $file );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @return bool
|
||||
*/
|
||||
public function exists($file) {
|
||||
public function exists( $file ) {
|
||||
return file_exists( $this->sftp_path( $file ) );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @return bool
|
||||
*/
|
||||
public function is_file($file) {
|
||||
public function is_file( $file ) {
|
||||
return is_file( $this->sftp_path( $file ) );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $path
|
||||
* @return bool
|
||||
*/
|
||||
public function is_dir($path) {
|
||||
public function is_dir( $path ) {
|
||||
return is_dir( $this->sftp_path( $path ) );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @return bool
|
||||
*/
|
||||
public function is_readable($file) {
|
||||
public function is_readable( $file ) {
|
||||
return is_readable( $this->sftp_path( $file ) );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @return bool
|
||||
*/
|
||||
public function is_writable($file) {
|
||||
public function is_writable( $file ) {
|
||||
// PHP will base it's writable checks on system_user === file_owner, not ssh_user === file_owner
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @return int
|
||||
*/
|
||||
public function atime($file) {
|
||||
public function atime( $file ) {
|
||||
return fileatime( $this->sftp_path( $file ) );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @return int
|
||||
*/
|
||||
public function mtime($file) {
|
||||
public function mtime( $file ) {
|
||||
return filemtime( $this->sftp_path( $file ) );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @return int
|
||||
*/
|
||||
public function size($file) {
|
||||
public function size( $file ) {
|
||||
return filesize( $this->sftp_path( $file ) );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $file
|
||||
* @param int $time
|
||||
* @param int $atime
|
||||
*/
|
||||
public function touch($file, $time = 0, $atime = 0) {
|
||||
public function touch( $file, $time = 0, $atime = 0 ) {
|
||||
//Not implemented.
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $path
|
||||
* @param mixed $chmod
|
||||
* @param mixed $chown
|
||||
* @param mixed $chgrp
|
||||
* @return bool
|
||||
*/
|
||||
public function mkdir($path, $chmod = false, $chown = false, $chgrp = false) {
|
||||
$path = untrailingslashit($path);
|
||||
if ( empty($path) )
|
||||
public function mkdir( $path, $chmod = false, $chown = false, $chgrp = false ) {
|
||||
$path = untrailingslashit( $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 )
|
||||
$this->chown($path, $chown);
|
||||
if ( $chgrp )
|
||||
$this->chgrp($path, $chgrp);
|
||||
}
|
||||
if ( $chown ) {
|
||||
$this->chown( $path, $chown );
|
||||
}
|
||||
if ( $chgrp ) {
|
||||
$this->chgrp( $path, $chgrp );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $path
|
||||
* @param bool $recursive
|
||||
* @return bool
|
||||
*/
|
||||
public function rmdir($path, $recursive = false) {
|
||||
return $this->delete($path, $recursive);
|
||||
public function rmdir( $path, $recursive = false ) {
|
||||
return $this->delete( $path, $recursive );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $path
|
||||
* @param bool $include_hidden
|
||||
* @param bool $recursive
|
||||
* @return bool|array
|
||||
*/
|
||||
public function dirlist($path, $include_hidden = true, $recursive = false) {
|
||||
if ( $this->is_file($path) ) {
|
||||
$limit_file = basename($path);
|
||||
$path = dirname($path);
|
||||
public function dirlist( $path, $include_hidden = true, $recursive = false ) {
|
||||
if ( $this->is_file( $path ) ) {
|
||||
$limit_file = basename( $path );
|
||||
$path = dirname( $path );
|
||||
} else {
|
||||
$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();
|
||||
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']);
|
||||
$struc['number'] = false;
|
||||
$struc['owner'] = $this->owner($path.'/'.$entry);
|
||||
$struc['group'] = $this->group($path.'/'.$entry);
|
||||
$struc['size'] = $this->size($path.'/'.$entry);
|
||||
$struc['lastmodunix']= $this->mtime($path.'/'.$entry);
|
||||
$struc['lastmod'] = date('M j',$struc['lastmodunix']);
|
||||
$struc['time'] = date('h:i:s',$struc['lastmodunix']);
|
||||
$struc['type'] = $this->is_dir($path.'/'.$entry) ? 'd' : 'f';
|
||||
$struc['perms'] = $this->gethchmod( $path . '/' . $entry );
|
||||
$struc['permsn'] = $this->getnumchmodfromh( $struc['perms'] );
|
||||
$struc['number'] = false;
|
||||
$struc['owner'] = $this->owner( $path . '/' . $entry );
|
||||
$struc['group'] = $this->group( $path . '/' . $entry );
|
||||
$struc['size'] = $this->size( $path . '/' . $entry );
|
||||
$struc['lastmodunix'] = $this->mtime( $path . '/' . $entry );
|
||||
$struc['lastmod'] = date( 'M j', $struc['lastmodunix'] );
|
||||
$struc['time'] = date( 'h:i:s', $struc['lastmodunix'] );
|
||||
$struc['type'] = $this->is_dir( $path . '/' . $entry ) ? 'd' : 'f';
|
||||
|
||||
if ( 'd' == $struc['type'] ) {
|
||||
if ( $recursive )
|
||||
$struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive);
|
||||
else
|
||||
if ( $recursive ) {
|
||||
$struc['files'] = $this->dirlist( $path . '/' . $struc['name'], $include_hidden, $recursive );
|
||||
} else {
|
||||
$struc['files'] = array();
|
||||
}
|
||||
}
|
||||
|
||||
$ret[ $struc['name'] ] = $struc;
|
||||
}
|
||||
$dir->close();
|
||||
unset($dir);
|
||||
unset( $dir );
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
class WP_Importer {
|
||||
/**
|
||||
* Class Constructor
|
||||
*
|
||||
*/
|
||||
public function __construct() {}
|
||||
|
||||
|
@ -23,22 +22,22 @@ class WP_Importer {
|
|||
|
||||
$hashtable = array();
|
||||
|
||||
$limit = 100;
|
||||
$limit = 100;
|
||||
$offset = 0;
|
||||
|
||||
// Grab all posts in chunks
|
||||
do {
|
||||
$meta_key = $importer_name . '_' . $bid . '_permalink';
|
||||
$sql = $wpdb->prepare( "SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = %s LIMIT %d,%d", $meta_key, $offset, $limit );
|
||||
$results = $wpdb->get_results( $sql );
|
||||
$sql = $wpdb->prepare( "SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = %s LIMIT %d,%d", $meta_key, $offset, $limit );
|
||||
$results = $wpdb->get_results( $sql );
|
||||
|
||||
// Increment offset
|
||||
$offset = ( $limit + $offset );
|
||||
|
||||
if ( !empty( $results ) ) {
|
||||
if ( ! empty( $results ) ) {
|
||||
foreach ( $results as $r ) {
|
||||
// Set permalinks into array
|
||||
$hashtable[$r->meta_value] = intval( $r->post_id );
|
||||
$hashtable[ $r->meta_value ] = intval( $r->post_id );
|
||||
}
|
||||
}
|
||||
} while ( count( $results ) == $limit );
|
||||
|
@ -65,12 +64,13 @@ class WP_Importer {
|
|||
|
||||
// Get count of permalinks
|
||||
$meta_key = $importer_name . '_' . $bid . '_permalink';
|
||||
$sql = $wpdb->prepare( "SELECT COUNT( post_id ) AS cnt FROM $wpdb->postmeta WHERE meta_key = '%s'", $meta_key );
|
||||
$sql = $wpdb->prepare( "SELECT COUNT( post_id ) AS cnt FROM $wpdb->postmeta WHERE meta_key = '%s'", $meta_key );
|
||||
|
||||
$result = $wpdb->get_results( $sql );
|
||||
|
||||
if ( !empty( $result ) )
|
||||
if ( ! empty( $result ) ) {
|
||||
$count = intval( $result[0]->cnt );
|
||||
}
|
||||
|
||||
// Unset to save memory.
|
||||
unset( $results );
|
||||
|
@ -91,26 +91,26 @@ class WP_Importer {
|
|||
|
||||
$hashtable = array();
|
||||
|
||||
$limit = 100;
|
||||
$limit = 100;
|
||||
$offset = 0;
|
||||
|
||||
// Grab all comments in chunks
|
||||
do {
|
||||
$sql = $wpdb->prepare( "SELECT comment_ID, comment_agent FROM $wpdb->comments LIMIT %d,%d", $offset, $limit );
|
||||
$sql = $wpdb->prepare( "SELECT comment_ID, comment_agent FROM $wpdb->comments LIMIT %d,%d", $offset, $limit );
|
||||
$results = $wpdb->get_results( $sql );
|
||||
|
||||
// Increment offset
|
||||
$offset = ( $limit + $offset );
|
||||
|
||||
if ( !empty( $results ) ) {
|
||||
if ( ! empty( $results ) ) {
|
||||
foreach ( $results as $r ) {
|
||||
// Explode comment_agent key
|
||||
list ( $ca_bid, $source_comment_id ) = explode( '-', $r->comment_agent );
|
||||
$source_comment_id = intval( $source_comment_id );
|
||||
$source_comment_id = intval( $source_comment_id );
|
||||
|
||||
// Check if this comment came from this blog
|
||||
if ( $bid == $ca_bid ) {
|
||||
$hashtable[$source_comment_id] = intval( $r->comment_ID );
|
||||
$hashtable[ $source_comment_id ] = intval( $r->comment_ID );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -123,7 +123,6 @@ class WP_Importer {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param int $blog_id
|
||||
* @return int|void
|
||||
*/
|
||||
|
@ -132,32 +131,38 @@ class WP_Importer {
|
|||
$blog_id = (int) $blog_id;
|
||||
} else {
|
||||
$blog = 'http://' . preg_replace( '#^https?://#', '', $blog_id );
|
||||
if ( ( !$parsed = parse_url( $blog ) ) || empty( $parsed['host'] ) ) {
|
||||
if ( ( ! $parsed = parse_url( $blog ) ) || empty( $parsed['host'] ) ) {
|
||||
fwrite( STDERR, "Error: can not determine blog_id from $blog_id\n" );
|
||||
exit();
|
||||
}
|
||||
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();
|
||||
}
|
||||
$blog = array_shift( $blogs );
|
||||
$blog = array_shift( $blogs );
|
||||
$blog_id = (int) $blog->blog_id;
|
||||
}
|
||||
|
||||
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
|
||||
*/
|
||||
|
@ -168,7 +173,7 @@ class WP_Importer {
|
|||
$user_id = (int) username_exists( $user_id );
|
||||
}
|
||||
|
||||
if ( !$user_id || !wp_set_current_user( $user_id ) ) {
|
||||
if ( ! $user_id || ! wp_set_current_user( $user_id ) ) {
|
||||
fwrite( STDERR, "Error: can not find user\n" );
|
||||
exit();
|
||||
}
|
||||
|
@ -201,11 +206,13 @@ class WP_Importer {
|
|||
add_filter( 'http_request_timeout', array( $this, 'bump_request_timeout' ) );
|
||||
|
||||
$headers = array();
|
||||
$args = array();
|
||||
if ( true === $head )
|
||||
$args = array();
|
||||
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;
|
||||
|
||||
|
@ -278,42 +285,42 @@ function get_cli_args( $param, $required = false ) {
|
|||
$out = array();
|
||||
|
||||
$last_arg = null;
|
||||
$return = null;
|
||||
$return = null;
|
||||
|
||||
$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];
|
||||
$out[ $key ] = $parts[1];
|
||||
} else {
|
||||
$out[$key] = true;
|
||||
$out[ $key ] = true;
|
||||
}
|
||||
|
||||
$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;
|
||||
$key = $match[1]{$j};
|
||||
$out[ $key ] = true;
|
||||
}
|
||||
|
||||
$last_arg = $key;
|
||||
} elseif ( $last_arg !== null ) {
|
||||
$out[$last_arg] = $args[$i];
|
||||
$out[ $last_arg ] = $args[ $i ];
|
||||
}
|
||||
}
|
||||
|
||||
// Check array for specified param
|
||||
if ( isset( $out[$param] ) ) {
|
||||
if ( isset( $out[ $param ] ) ) {
|
||||
// Set return value
|
||||
$return = $out[$param];
|
||||
$return = $out[ $param ];
|
||||
}
|
||||
|
||||
// Check for missing required param
|
||||
if ( !isset( $out[$param] ) && $required ) {
|
||||
if ( ! isset( $out[ $param ] ) && $required ) {
|
||||
// Display message and exit
|
||||
echo "\"$param\" parameter is required but was not specified\n";
|
||||
exit();
|
||||
|
|
|
@ -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,8 +77,9 @@ 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,8 +88,9 @@ final class WP_Internal_Pointers {
|
|||
$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">
|
||||
|
|
|
@ -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(
|
||||
'plural' => 'bookmarks',
|
||||
'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
|
||||
) );
|
||||
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,38 +81,37 @@ class WP_Links_List_Table extends WP_List_Table {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_bulk_actions() {
|
||||
$actions = array();
|
||||
$actions = array();
|
||||
$actions['delete'] = __( 'Delete' );
|
||||
|
||||
return $actions;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @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
|
||||
$dropdown_options = array(
|
||||
'selected' => $cat_id,
|
||||
'name' => 'cat_id',
|
||||
'taxonomy' => 'link_category',
|
||||
'selected' => $cat_id,
|
||||
'name' => 'cat_id',
|
||||
'taxonomy' => 'link_category',
|
||||
'show_option_all' => get_taxonomy( 'link_category' )->labels->all_items,
|
||||
'hide_empty' => true,
|
||||
'hierarchical' => 1,
|
||||
'show_count' => 0,
|
||||
'orderby' => 'name',
|
||||
'hide_empty' => true,
|
||||
'hierarchical' => 1,
|
||||
'show_count' => 0,
|
||||
'orderby' => 'name',
|
||||
);
|
||||
|
||||
echo '<label class="screen-reader-text" for="cat_id">' . __( 'Filter by category' ) . '</label>';
|
||||
|
@ -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 “%s”' ), $link->link_name ) ),
|
||||
|
@ -285,12 +290,12 @@ class WP_Links_List_Table extends WP_List_Table {
|
|||
|
||||
public function display_rows() {
|
||||
foreach ( $this->items as $link ) {
|
||||
$link = sanitize_bookmark( $link );
|
||||
$link->link_name = esc_attr( $link->link_name );
|
||||
$link = sanitize_bookmark( $link );
|
||||
$link->link_name = esc_attr( $link->link_name );
|
||||
$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
|
||||
}
|
||||
|
@ -313,9 +318,9 @@ class WP_Links_List_Table extends WP_List_Table {
|
|||
|
||||
$edit_link = get_edit_bookmark_link( $link );
|
||||
|
||||
$actions = array();
|
||||
$actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
|
||||
$actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("link.php?action=delete&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 = array();
|
||||
$actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
|
||||
$actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url( "link.php?action=delete&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 );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,32 +17,31 @@ 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;
|
||||
|
||||
if ( !empty( $columns ) ) {
|
||||
if ( ! empty( $columns ) ) {
|
||||
$this->_columns = $columns;
|
||||
add_filter( 'manage_' . $screen->id . '_columns', array( $this, 'get_columns' ), 0 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_column_info() {
|
||||
$columns = get_column_headers( $this->_screen );
|
||||
$hidden = get_hidden_columns( $this->_screen );
|
||||
$columns = get_column_headers( $this->_screen );
|
||||
$hidden = get_hidden_columns( $this->_screen );
|
||||
$sortable = array();
|
||||
$primary = $this->get_default_primary_column_name();
|
||||
$primary = $this->get_default_primary_column_name();
|
||||
|
||||
return array( $columns, $hidden, $sortable, $primary );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_columns() {
|
||||
|
|
|
@ -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,21 +136,24 @@ class WP_List_Table {
|
|||
* }
|
||||
*/
|
||||
public function __construct( $args = array() ) {
|
||||
$args = wp_parse_args( $args, array(
|
||||
'plural' => '',
|
||||
'singular' => '',
|
||||
'ajax' => false,
|
||||
'screen' => null,
|
||||
) );
|
||||
$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['plural'] = sanitize_key( $args['plural'] );
|
||||
$args['singular'] = sanitize_key( $args['singular'] );
|
||||
|
||||
$this->_args = $args;
|
||||
|
@ -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(
|
||||
'total_items' => 0,
|
||||
'total_pages' => 0,
|
||||
'per_page' => 0,
|
||||
) );
|
||||
$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'] ) {
|
||||
|
@ -287,8 +308,8 @@ class WP_List_Table {
|
|||
return $this->get_pagenum();
|
||||
}
|
||||
|
||||
if ( isset( $this->_pagination_args[$key] ) ) {
|
||||
return $this->_pagination_args[$key];
|
||||
if ( isset( $this->_pagination_args[ $key ] ) ) {
|
||||
return $this->_pagination_args[ $key ];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -300,7 +321,7 @@ class WP_List_Table {
|
|||
* @return bool
|
||||
*/
|
||||
public function has_items() {
|
||||
return !empty( $this->items );
|
||||
return ! empty( $this->items );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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>';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -423,13 +450,14 @@ class WP_List_Table {
|
|||
* @param array $actions An array of the available bulk actions.
|
||||
*/
|
||||
$this->_actions = apply_filters( "bulk_actions-{$this->screen->id}", $this->_actions );
|
||||
$two = '';
|
||||
$two = '';
|
||||
} else {
|
||||
$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;
|
||||
}
|
||||
|
@ -478,16 +509,17 @@ class WP_List_Table {
|
|||
*/
|
||||
protected function row_actions( $actions, $always_visible = false ) {
|
||||
$action_count = count( $actions );
|
||||
$i = 0;
|
||||
$i = 0;
|
||||
|
||||
if ( !$action_count )
|
||||
if ( ! $action_count ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">';
|
||||
foreach ( $actions as $action => $link ) {
|
||||
++$i;
|
||||
( $i == $action_count ) ? $sep = '' : $sep = ' | ';
|
||||
$out .= "<span class='$action'>$link$sep</span>";
|
||||
$out .= "<span class='$action'>$link$sep</span>";
|
||||
}
|
||||
$out .= '</div>';
|
||||
|
||||
|
@ -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;
|
||||
?>
|
||||
|
@ -557,20 +594,22 @@ class WP_List_Table {
|
|||
<select name="m" id="filter-by-date">
|
||||
<option<?php selected( $m, 0 ); ?> value="0"><?php _e( 'All dates' ); ?></option>
|
||||
<?php
|
||||
foreach ( $months as $arc_row ) {
|
||||
if ( 0 == $arc_row->year )
|
||||
continue;
|
||||
foreach ( $months as $arc_row ) {
|
||||
if ( 0 == $arc_row->year ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$month = zeroise( $arc_row->month, 2 );
|
||||
$year = $arc_row->year;
|
||||
$month = zeroise( $arc_row->month, 2 );
|
||||
$year = $arc_row->year;
|
||||
|
||||
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 */
|
||||
sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $month ), $year )
|
||||
);
|
||||
}
|
||||
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 */
|
||||
sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $month ), $year )
|
||||
);
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<?php
|
||||
|
@ -588,17 +627,18 @@ class WP_List_Table {
|
|||
<input type="hidden" name="mode" value="<?php echo esc_attr( $current_mode ); ?>" />
|
||||
<div class="view-switch">
|
||||
<?php
|
||||
foreach ( $this->modes as $mode => $title ) {
|
||||
$classes = array( 'view-' . $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 ) ),
|
||||
implode( ' ', $classes ),
|
||||
$title
|
||||
);
|
||||
}
|
||||
foreach ( $this->modes as $mode => $title ) {
|
||||
$classes = array( 'view-' . $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 ) ),
|
||||
implode( ' ', $classes ),
|
||||
$title
|
||||
);
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
|
@ -616,39 +656,58 @@ class WP_List_Table {
|
|||
$approved_comments = get_comments_number();
|
||||
|
||||
$approved_comments_number = number_format_i18n( $approved_comments );
|
||||
$pending_comments_number = number_format_i18n( $pending_comments );
|
||||
$pending_comments_number = number_format_i18n( $pending_comments );
|
||||
|
||||
$approved_only_phrase = sprintf( _n( '%s comment', '%s comments', $approved_comments ), $approved_comments_number );
|
||||
$approved_phrase = sprintf( _n( '%s approved comment', '%s approved comments', $approved_comments ), $approved_comments_number );
|
||||
$pending_phrase = sprintf( _n( '%s pending comment', '%s pending comments', $pending_comments ), $pending_comments_number );
|
||||
$approved_phrase = sprintf( _n( '%s approved comment', '%s approved comments', $approved_comments ), $approved_comments_number );
|
||||
$pending_phrase = sprintf( _n( '%s pending comment', '%s pending comments', $pending_comments ), $pending_comments_number );
|
||||
|
||||
// No comments at all.
|
||||
if ( ! $approved_comments && ! $pending_comments ) {
|
||||
printf( '<span aria-hidden="true">—</span><span class="screen-reader-text">%s</span>',
|
||||
printf(
|
||||
'<span aria-hidden="true">—</span><span class="screen-reader-text">%s</span>',
|
||||
__( 'No comments' )
|
||||
);
|
||||
// Approved comments have different display depending on some conditions.
|
||||
// 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.
|
||||
|
@ -713,8 +774,8 @@ class WP_List_Table {
|
|||
return;
|
||||
}
|
||||
|
||||
$total_items = $this->_pagination_args['total_items'];
|
||||
$total_pages = $this->_pagination_args['total_pages'];
|
||||
$total_items = $this->_pagination_args['total_items'];
|
||||
$total_pages = $this->_pagination_args['total_pages'];
|
||||
$infinite_scroll = false;
|
||||
if ( isset( $this->_pagination_args['infinite_scroll'] ) ) {
|
||||
$infinite_scroll = $this->_pagination_args['infinite_scroll'];
|
||||
|
@ -726,7 +787,7 @@ class WP_List_Table {
|
|||
|
||||
$output = '<span class="displaying-num">' . sprintf( _n( '%s item', '%s items', $total_items ), number_format_i18n( $total_items ) ) . '</span>';
|
||||
|
||||
$current = $this->get_pagenum();
|
||||
$current = $this->get_pagenum();
|
||||
$removable_query_args = wp_removable_query_args();
|
||||
|
||||
$current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
|
||||
|
@ -740,17 +801,17 @@ class WP_List_Table {
|
|||
|
||||
$disable_first = $disable_last = $disable_prev = $disable_next = false;
|
||||
|
||||
if ( $current == 1 ) {
|
||||
if ( $current == 1 ) {
|
||||
$disable_first = true;
|
||||
$disable_prev = true;
|
||||
}
|
||||
$disable_prev = true;
|
||||
}
|
||||
if ( $current == 2 ) {
|
||||
$disable_first = true;
|
||||
}
|
||||
if ( $current == $total_pages ) {
|
||||
if ( $current == $total_pages ) {
|
||||
$disable_last = true;
|
||||
$disable_next = true;
|
||||
}
|
||||
}
|
||||
if ( $current == $total_pages - 1 ) {
|
||||
$disable_last = true;
|
||||
}
|
||||
|
@ -758,7 +819,8 @@ class WP_List_Table {
|
|||
if ( $disable_first ) {
|
||||
$page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">«</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' ),
|
||||
'«'
|
||||
|
@ -768,8 +830,9 @@ class WP_List_Table {
|
|||
if ( $disable_prev ) {
|
||||
$page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">‹</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>",
|
||||
esc_url( add_query_arg( 'paged', max( 1, $current-1 ), $current_url ) ),
|
||||
$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' ),
|
||||
'‹'
|
||||
);
|
||||
|
@ -779,20 +842,22 @@ 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 )
|
||||
);
|
||||
}
|
||||
$html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) );
|
||||
$page_links[] = $total_pages_before . sprintf( _x( '%1$s of %2$s', 'paging' ), $html_current_page, $html_total_pages ) . $total_pages_after;
|
||||
$page_links[] = $total_pages_before . sprintf( _x( '%1$s of %2$s', 'paging' ), $html_current_page, $html_total_pages ) . $total_pages_after;
|
||||
|
||||
if ( $disable_next ) {
|
||||
$page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">›</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>",
|
||||
esc_url( add_query_arg( 'paged', min( $total_pages, $current+1 ), $current_url ) ),
|
||||
$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' ),
|
||||
'›'
|
||||
);
|
||||
|
@ -801,7 +866,8 @@ class WP_List_Table {
|
|||
if ( $disable_last ) {
|
||||
$page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">»</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' ),
|
||||
'»'
|
||||
|
@ -862,7 +928,7 @@ class WP_List_Table {
|
|||
*/
|
||||
protected function get_default_primary_column_name() {
|
||||
$columns = $this->get_columns();
|
||||
$column = '';
|
||||
$column = '';
|
||||
|
||||
if ( empty( $columns ) ) {
|
||||
return $column;
|
||||
|
@ -918,7 +984,7 @@ class WP_List_Table {
|
|||
* @param string $default Column name default for the specific list table, e.g. 'name'.
|
||||
* @param string $context Screen ID for specific list table, e.g. 'plugins'.
|
||||
*/
|
||||
$column = apply_filters( 'list_table_primary_column', $default, $this->screen->id );
|
||||
$column = apply_filters( 'list_table_primary_column', $default, $this->screen->id );
|
||||
|
||||
if ( empty( $column ) || ! isset( $columns[ $column ] ) ) {
|
||||
$column = $default;
|
||||
|
@ -948,7 +1014,7 @@ class WP_List_Table {
|
|||
}
|
||||
|
||||
$columns = get_column_headers( $this->screen );
|
||||
$hidden = get_hidden_columns( $this->screen );
|
||||
$hidden = get_hidden_columns( $this->screen );
|
||||
|
||||
$sortable_columns = $this->get_sortable_columns();
|
||||
/**
|
||||
|
@ -965,17 +1031,19 @@ 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;
|
||||
$sortable[ $id ] = $data;
|
||||
}
|
||||
|
||||
$primary = $this->get_primary_column_name();
|
||||
$primary = $this->get_primary_column_name();
|
||||
$this->_column_headers = array( $columns, $hidden, $sortable, $primary );
|
||||
|
||||
return $this->_column_headers;
|
||||
|
@ -990,7 +1058,7 @@ class WP_List_Table {
|
|||
*/
|
||||
public function get_column_count() {
|
||||
list ( $columns, $hidden ) = $this->get_column_info();
|
||||
$hidden = array_intersect( array_keys( $columns ), array_filter( $hidden ) );
|
||||
$hidden = array_intersect( array_keys( $columns ), array_filter( $hidden ) );
|
||||
return count( $columns ) - count( $hidden );
|
||||
}
|
||||
|
||||
|
@ -1023,7 +1091,7 @@ class WP_List_Table {
|
|||
|
||||
if ( ! empty( $columns['cb'] ) ) {
|
||||
static $cb_counter = 1;
|
||||
$columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All' ) . '</label>'
|
||||
$columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All' ) . '</label>'
|
||||
. '<input id="cb-select-all-' . $cb_counter . '" type="checkbox" />';
|
||||
$cb_counter++;
|
||||
}
|
||||
|
@ -1035,24 +1103,25 @@ 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';
|
||||
}
|
||||
|
||||
if ( isset( $sortable[$column_key] ) ) {
|
||||
list( $orderby, $desc_first ) = $sortable[$column_key];
|
||||
if ( isset( $sortable[ $column_key ] ) ) {
|
||||
list( $orderby, $desc_first ) = $sortable[ $column_key ];
|
||||
|
||||
if ( $current_orderby === $orderby ) {
|
||||
$order = 'asc' === $current_order ? 'desc' : 'asc';
|
||||
$order = 'asc' === $current_order ? 'desc' : 'asc';
|
||||
$class[] = 'sorted';
|
||||
$class[] = $current_order;
|
||||
} else {
|
||||
$order = $desc_first ? 'desc' : 'asc';
|
||||
$order = $desc_first ? 'desc' : 'asc';
|
||||
$class[] = 'sortable';
|
||||
$class[] = $desc_first ? 'asc' : 'desc';
|
||||
}
|
||||
|
@ -1060,12 +1129,13 @@ class WP_List_Table {
|
|||
$column_display_name = '<a href="' . esc_url( add_query_arg( compact( 'orderby', 'order' ), $current_url ) ) . '"><span>' . $column_display_name . '</span><span class="sorting-indicator"></span></a>';
|
||||
}
|
||||
|
||||
$tag = ( 'cb' === $column_key ) ? 'td' : 'th';
|
||||
$tag = ( 'cb' === $column_key ) ? 'td' : 'th';
|
||||
$scope = ( 'th' === $tag ) ? 'scope="col"' : '';
|
||||
$id = $with_id ? "id='$column_key'" : '';
|
||||
$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
|
||||
if ( $singular ) {
|
||||
echo " data-wp-lists='list:$singular'";
|
||||
} ?>>
|
||||
<tbody id="the-list"
|
||||
<?php
|
||||
if ( $singular ) {
|
||||
echo " data-wp-lists='list:$singular'";
|
||||
}
|
||||
?>
|
||||
>
|
||||
<?php $this->display_rows_or_placeholder(); ?>
|
||||
</tbody>
|
||||
|
||||
|
@ -1132,11 +1205,12 @@ class WP_List_Table {
|
|||
?>
|
||||
<div class="tablenav <?php echo esc_attr( $which ); ?>">
|
||||
|
||||
<?php if ( $this->has_items() ): ?>
|
||||
<?php if ( $this->has_items() ) : ?>
|
||||
<div class="alignleft actions bulkactions">
|
||||
<?php $this->bulk_actions( $which ); ?>
|
||||
</div>
|
||||
<?php endif;
|
||||
<?php
|
||||
endif;
|
||||
$this->extra_tablenav( $which );
|
||||
$this->pagination( $which );
|
||||
?>
|
||||
|
@ -1176,8 +1250,9 @@ 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 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1270,7 +1343,7 @@ class WP_List_Table {
|
|||
*/
|
||||
protected function handle_row_actions( $item, $column_name, $primary ) {
|
||||
return $column_name === $primary ? '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __( 'Show more details' ) . '</span></button>' : '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming ajax request (called from admin-ajax.php)
|
||||
|
@ -1298,7 +1371,7 @@ class WP_List_Table {
|
|||
);
|
||||
}
|
||||
if ( isset( $this->_pagination_args['total_pages'] ) ) {
|
||||
$response['total_pages'] = $this->_pagination_args['total_pages'];
|
||||
$response['total_pages'] = $this->_pagination_args['total_pages'];
|
||||
$response['total_pages_i18n'] = number_format_i18n( $this->_pagination_args['total_pages'] );
|
||||
}
|
||||
|
||||
|
@ -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 ) );
|
||||
|
|
|
@ -42,25 +42,25 @@ class WP_Media_List_Table extends WP_List_Table {
|
|||
|
||||
$this->modes = array(
|
||||
'list' => __( 'List View' ),
|
||||
'grid' => __( 'Grid View' )
|
||||
'grid' => __( 'Grid View' ),
|
||||
);
|
||||
|
||||
parent::__construct( array(
|
||||
'plural' => 'media',
|
||||
'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
|
||||
) );
|
||||
parent::__construct(
|
||||
array(
|
||||
'plural' => 'media',
|
||||
'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function ajax_user_can() {
|
||||
return current_user_can('upload_files');
|
||||
return current_user_can( 'upload_files' );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @global WP_Query $wp_query
|
||||
* @global array $post_mime_types
|
||||
* @global array $avail_post_mime_types
|
||||
|
@ -71,15 +71,17 @@ class WP_Media_List_Table extends WP_List_Table {
|
|||
|
||||
list( $post_mime_types, $avail_post_mime_types ) = wp_edit_attachments_query( $_REQUEST );
|
||||
|
||||
$this->is_trash = isset( $_REQUEST['attachment-filter'] ) && 'trash' === $_REQUEST['attachment-filter'];
|
||||
$this->is_trash = isset( $_REQUEST['attachment-filter'] ) && 'trash' === $_REQUEST['attachment-filter'];
|
||||
|
||||
$mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode'];
|
||||
$mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode'];
|
||||
|
||||
$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'],
|
||||
) );
|
||||
$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'],
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -112,7 +114,7 @@ class WP_Media_List_Table extends WP_List_Table {
|
|||
false
|
||||
);
|
||||
|
||||
$type_links[$mime_type] = sprintf(
|
||||
$type_links[ $mime_type ] = sprintf(
|
||||
'<option value="post_mime_type:%s"%s>%s</option>',
|
||||
esc_attr( $mime_type ),
|
||||
$selected,
|
||||
|
@ -121,7 +123,7 @@ class WP_Media_List_Table extends WP_List_Table {
|
|||
}
|
||||
$type_links['detached'] = '<option value="detached"' . ( $this->detached ? ' selected="selected"' : '' ) . '>' . __( 'Unattached' ) . '</option>';
|
||||
|
||||
if ( $this->is_trash || ( defined( 'MEDIA_TRASH') && MEDIA_TRASH ) ) {
|
||||
if ( $this->is_trash || ( defined( 'MEDIA_TRASH' ) && MEDIA_TRASH ) ) {
|
||||
$type_links['trash'] = sprintf(
|
||||
'<option value="trash"%s>%s</option>',
|
||||
selected( 'trash' === $filter, true, false ),
|
||||
|
@ -132,7 +134,6 @@ class WP_Media_List_Table extends WP_List_Table {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_bulk_actions() {
|
||||
|
@ -140,7 +141,7 @@ class WP_Media_List_Table extends WP_List_Table {
|
|||
if ( MEDIA_TRASH ) {
|
||||
if ( $this->is_trash ) {
|
||||
$actions['untrash'] = __( 'Restore' );
|
||||
$actions['delete'] = __( 'Delete Permanently' );
|
||||
$actions['delete'] = __( 'Delete Permanently' );
|
||||
} else {
|
||||
$actions['trash'] = _x( 'Trash', 'verb' );
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -164,43 +166,45 @@ class WP_Media_List_Table extends WP_List_Table {
|
|||
?>
|
||||
<div class="actions">
|
||||
<?php
|
||||
if ( ! is_singular() ) {
|
||||
if ( ! $this->is_trash ) {
|
||||
$this->months_dropdown( 'attachment' );
|
||||
}
|
||||
if ( ! is_singular() ) {
|
||||
if ( ! $this->is_trash ) {
|
||||
$this->months_dropdown( 'attachment' );
|
||||
}
|
||||
|
||||
/** This action is documented in wp-admin/includes/class-wp-posts-list-table.php */
|
||||
do_action( 'restrict_manage_posts', $this->screen->post_type, $which );
|
||||
/** This action is documented in wp-admin/includes/class-wp-posts-list-table.php */
|
||||
do_action( 'restrict_manage_posts', $this->screen->post_type, $which );
|
||||
|
||||
submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
|
||||
}
|
||||
submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
|
||||
}
|
||||
|
||||
if ( $this->is_trash && current_user_can( 'edit_others_posts' ) && $this->has_items() ) {
|
||||
submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false );
|
||||
} ?>
|
||||
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() {
|
||||
|
@ -247,32 +251,31 @@ class WP_Media_List_Table extends WP_List_Table {
|
|||
$views = apply_filters( "views_{$this->screen->id}", array() );
|
||||
|
||||
// Back compat for pre-4.0 view links.
|
||||
if ( ! empty( $views ) ) {
|
||||
echo '<ul class="filter-links">';
|
||||
foreach ( $views as $class => $view ) {
|
||||
echo "<li class='$class'>$view</li>";
|
||||
}
|
||||
echo '</ul>';
|
||||
}
|
||||
if ( ! empty( $views ) ) {
|
||||
echo '<ul class="filter-links">';
|
||||
foreach ( $views as $class => $view ) {
|
||||
echo "<li class='$class'>$view</li>";
|
||||
}
|
||||
echo '</ul>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<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() {
|
||||
$posts_columns = array();
|
||||
$posts_columns = array();
|
||||
$posts_columns['cb'] = '<input type="checkbox" />';
|
||||
/* translators: column name */
|
||||
$posts_columns['title'] = _x( 'File', 'column name' );
|
||||
$posts_columns['title'] = _x( 'File', 'column name' );
|
||||
$posts_columns['author'] = __( 'Author' );
|
||||
|
||||
$taxonomies = get_taxonomies_for_attachments( 'objects' );
|
||||
|
@ -301,10 +304,11 @@ class WP_Media_List_Table extends WP_List_Table {
|
|||
}
|
||||
|
||||
/* translators: column name */
|
||||
if ( !$this->detached ) {
|
||||
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
|
||||
echo sprintf( __( 'Select %s' ), _draft_or_post_title() );
|
||||
?></label>
|
||||
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>
|
||||
<input type="checkbox" name="media[]" id="cb-select-<?php echo $post->ID; ?>" value="<?php echo $post->ID; ?>" />
|
||||
<?php }
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -360,8 +367,8 @@ class WP_Media_List_Table extends WP_List_Table {
|
|||
public function column_title( $post ) {
|
||||
list( $mime ) = explode( '/', $post->post_mime_type );
|
||||
|
||||
$title = _draft_or_post_title();
|
||||
$thumb = wp_get_attachment_image( $post->ID, array( 60, 60 ), true, array( 'alt' => '' ) );
|
||||
$title = _draft_or_post_title();
|
||||
$thumb = wp_get_attachment_image( $post->ID, array( 60, 60 ), true, array( 'alt' => '' ) );
|
||||
$link_start = $link_end = '';
|
||||
|
||||
if ( current_user_can( 'edit_post', $post->ID ) && ! $this->is_trash ) {
|
||||
|
@ -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,8 +413,9 @@ 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>',
|
||||
esc_url( add_query_arg( array( 'author' => get_the_author_meta('ID') ), 'upload.php' ) ),
|
||||
printf(
|
||||
'<a href="%s">%s</a>',
|
||||
esc_url( add_query_arg( array( 'author' => get_the_author_meta( 'ID' ) ), 'upload.php' ) ),
|
||||
get_the_author()
|
||||
);
|
||||
}
|
||||
|
@ -433,7 +443,7 @@ class WP_Media_List_Table extends WP_List_Table {
|
|||
$h_time = __( 'Unpublished' );
|
||||
} else {
|
||||
$m_time = $post->post_date;
|
||||
$time = get_post_time( 'G', true, $post, false );
|
||||
$time = get_post_time( 'G', true, $post, false );
|
||||
if ( ( abs( $t_diff = time() - $time ) ) < DAY_IN_SECONDS ) {
|
||||
if ( $t_diff < 0 ) {
|
||||
$h_time = sprintf( __( '%s from now' ), human_time_diff( $time ) );
|
||||
|
@ -465,26 +475,30 @@ class WP_Media_List_Table extends WP_List_Table {
|
|||
}
|
||||
|
||||
if ( $parent ) {
|
||||
$title = _draft_or_post_title( $post->post_parent );
|
||||
$title = _draft_or_post_title( $post->post_parent );
|
||||
$parent_type = get_post_type_object( $parent->post_type );
|
||||
|
||||
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(
|
||||
'parent_post_id' => $post->post_parent,
|
||||
'media[]' => $post->ID,
|
||||
'_wpnonce' => wp_create_nonce( 'bulk-' . $this->_args['plural'] )
|
||||
), 'upload.php' );
|
||||
if ( $user_can_edit ) :
|
||||
$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'
|
||||
);
|
||||
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>',
|
||||
|
@ -553,11 +569,12 @@ class WP_Media_List_Table extends WP_List_Table {
|
|||
if ( is_array( $terms ) ) {
|
||||
$out = array();
|
||||
foreach ( $terms as $t ) {
|
||||
$posts_in_term_qv = array();
|
||||
$posts_in_term_qv = array();
|
||||
$posts_in_term_qv['taxonomy'] = $taxonomy;
|
||||
$posts_in_term_qv['term'] = $t->slug;
|
||||
$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() {
|
||||
|
@ -596,9 +612,10 @@ class WP_Media_List_Table extends WP_List_Table {
|
|||
|
||||
$this->comment_pending_count = get_pending_comments_num( $post_ids );
|
||||
|
||||
add_filter( 'the_title','esc_html' );
|
||||
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' )
|
||||
|
@ -654,7 +671,7 @@ class WP_Media_List_Table extends WP_List_Table {
|
|||
_x( 'Trash', 'verb' )
|
||||
);
|
||||
} else {
|
||||
$delete_ays = ! MEDIA_TRASH ? " onclick='return showNotice.warn();'" : '';
|
||||
$delete_ays = ! MEDIA_TRASH ? " onclick='return showNotice.warn();'" : '';
|
||||
$actions['delete'] = sprintf(
|
||||
'<a href="%s" class="submitdelete aria-button-if-js"%s aria-label="%s">%s</a>',
|
||||
wp_nonce_url( "post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID ),
|
||||
|
@ -682,9 +699,8 @@ class WP_Media_List_Table extends WP_List_Table {
|
|||
__( 'Attach' )
|
||||
);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( current_user_can( 'edit_post', $post->ID ) && !$this->is_trash ) {
|
||||
} else {
|
||||
if ( current_user_can( 'edit_post', $post->ID ) && ! $this->is_trash ) {
|
||||
$actions['edit'] = sprintf(
|
||||
'<a href="%s" aria-label="%s">%s</a>',
|
||||
get_edit_post_link( $post->ID ),
|
||||
|
@ -712,7 +728,7 @@ class WP_Media_List_Table extends WP_List_Table {
|
|||
);
|
||||
}
|
||||
if ( $this->is_trash || ! EMPTY_TRASH_DAYS || ! MEDIA_TRASH ) {
|
||||
$delete_ays = ( !$this->is_trash && !MEDIA_TRASH ) ? " onclick='return showNotice.warn();'" : '';
|
||||
$delete_ays = ( ! $this->is_trash && ! MEDIA_TRASH ) ? " onclick='return showNotice.warn();'" : '';
|
||||
$actions['delete'] = sprintf(
|
||||
'<a href="%s" class="submitdelete aria-button-if-js"%s aria-label="%s">%s</a>',
|
||||
wp_nonce_url( "post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID ),
|
||||
|
|
|
@ -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(
|
||||
'plural' => 'sites',
|
||||
'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
|
||||
) );
|
||||
parent::__construct(
|
||||
array(
|
||||
'plural' => 'sites',
|
||||
'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function ajax_user_can() {
|
||||
|
@ -79,22 +80,24 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
|||
|
||||
$pagenum = $this->get_pagenum();
|
||||
|
||||
$s = isset( $_REQUEST['s'] ) ? wp_unslash( trim( $_REQUEST[ 's' ] ) ) : '';
|
||||
$s = isset( $_REQUEST['s'] ) ? wp_unslash( trim( $_REQUEST['s'] ) ) : '';
|
||||
$wild = '';
|
||||
if ( false !== strpos($s, '*') ) {
|
||||
if ( false !== strpos( $s, '*' ) ) {
|
||||
$wild = '*';
|
||||
$s = trim($s, '*');
|
||||
$s = trim( $s, '*' );
|
||||
}
|
||||
|
||||
/*
|
||||
* If the network is large and a search is not being performed, show only
|
||||
* the latest sites with no paging in order to avoid expensive count queries.
|
||||
*/
|
||||
if ( !$s && wp_is_large_network() ) {
|
||||
if ( !isset($_REQUEST['orderby']) )
|
||||
if ( ! $s && wp_is_large_network() ) {
|
||||
if ( ! isset( $_REQUEST['orderby'] ) ) {
|
||||
$_GET['orderby'] = $_REQUEST['orderby'] = '';
|
||||
if ( !isset($_REQUEST['order']) )
|
||||
}
|
||||
if ( ! isset( $_REQUEST['order'] ) ) {
|
||||
$_GET['order'] = $_REQUEST['order'] = 'DESC';
|
||||
}
|
||||
}
|
||||
|
||||
$args = array(
|
||||
|
@ -103,14 +106,14 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
|||
'network_id' => get_current_network_id(),
|
||||
);
|
||||
|
||||
if ( empty($s) ) {
|
||||
if ( empty( $s ) ) {
|
||||
// Nothing to do.
|
||||
} elseif ( preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $s ) ||
|
||||
preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s ) ||
|
||||
preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s ) ||
|
||||
preg_match( '/^[0-9]{1,3}\.$/', $s ) ) {
|
||||
// IPv4 address
|
||||
$sql = $wpdb->prepare( "SELECT blog_id FROM {$wpdb->registration_log} WHERE {$wpdb->registration_log}.IP LIKE %s", $wpdb->esc_like( $s ) . ( ! empty( $wild ) ? '%' : '' ) );
|
||||
$sql = $wpdb->prepare( "SELECT blog_id FROM {$wpdb->registration_log} WHERE {$wpdb->registration_log}.IP LIKE %s", $wpdb->esc_like( $s ) . ( ! empty( $wild ) ? '%' : '' ) );
|
||||
$reg_blog_ids = $wpdb->get_col( $sql );
|
||||
|
||||
if ( $reg_blog_ids ) {
|
||||
|
@ -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(
|
||||
'count' => true,
|
||||
'offset' => 0,
|
||||
'number' => 0,
|
||||
) ) );
|
||||
$total_sites = get_sites(
|
||||
array_merge(
|
||||
$args, array(
|
||||
'count' => true,
|
||||
'offset' => 0,
|
||||
'number' => 0,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$this->set_pagination_args( array(
|
||||
'total_items' => $total_sites,
|
||||
'per_page' => $per_page,
|
||||
) );
|
||||
$this->set_pagination_args(
|
||||
array(
|
||||
'total_items' => $total_sites,
|
||||
'per_page' => $per_page,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -190,14 +199,14 @@ 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['spam'] = _x( 'Mark as Spam', 'site' );
|
||||
$actions['notspam'] = _x( 'Not Spam', 'site' );
|
||||
|
||||
return $actions;
|
||||
|
@ -213,8 +222,9 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
|||
|
||||
parent::pagination( $which );
|
||||
|
||||
if ( 'top' === $which )
|
||||
if ( 'top' === $which ) {
|
||||
$this->view_switcher( $mode );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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
|
||||
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 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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -296,7 +309,7 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
|||
public function column_blogname( $blog ) {
|
||||
global $mode;
|
||||
|
||||
$blogname = untrailingslashit( $blog['domain'] . $blog['path'] );
|
||||
$blogname = untrailingslashit( $blog['domain'] . $blog['path'] );
|
||||
$blog_states = array();
|
||||
reset( $this->status_list );
|
||||
|
||||
|
@ -308,11 +321,11 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
|||
$blog_state = '';
|
||||
if ( ! empty( $blog_states ) ) {
|
||||
$state_count = count( $blog_states );
|
||||
$i = 0;
|
||||
$i = 0;
|
||||
$blog_state .= ' — ';
|
||||
foreach ( $blog_states as $state ) {
|
||||
++$i;
|
||||
$sep = ( $i == $state_count ) ? '' : ', ';
|
||||
$sep = ( $i == $state_count ) ? '' : ', ';
|
||||
$blog_state .= "<span class='post-state'>$state$sep</span>";
|
||||
}
|
||||
}
|
||||
|
@ -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,12 +467,11 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @global string $mode
|
||||
*/
|
||||
public function display_rows() {
|
||||
foreach ( $this->items as $blog ) {
|
||||
$blog = $blog->to_array();
|
||||
$blog = $blog->to_array();
|
||||
$class = '';
|
||||
reset( $this->status_list );
|
||||
|
||||
|
@ -502,19 +519,23 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
|||
|
||||
// Preordered.
|
||||
$actions = array(
|
||||
'edit' => '', 'backend' => '',
|
||||
'activate' => '', 'deactivate' => '',
|
||||
'archive' => '', 'unarchive' => '',
|
||||
'spam' => '', 'unspam' => '',
|
||||
'delete' => '',
|
||||
'visit' => '',
|
||||
'edit' => '',
|
||||
'backend' => '',
|
||||
'activate' => '',
|
||||
'deactivate' => '',
|
||||
'archive' => '',
|
||||
'unarchive' => '',
|
||||
'spam' => '',
|
||||
'unspam' => '',
|
||||
'delete' => '',
|
||||
'visit' => '',
|
||||
);
|
||||
|
||||
$actions['edit'] = '<a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ) . '">' . __( 'Edit' ) . '</a>';
|
||||
$actions['backend'] = "<a href='" . esc_url( get_admin_url( $blog['blog_id'] ) ) . "' class='edit'>" . __( 'Dashboard' ) . '</a>';
|
||||
$actions['edit'] = '<a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ) . '">' . __( 'Edit' ) . '</a>';
|
||||
$actions['backend'] = "<a href='" . esc_url( get_admin_url( $blog['blog_id'] ) ) . "' class='edit'>" . __( 'Dashboard' ) . '</a>';
|
||||
if ( get_network()->site_id != $blog['blog_id'] ) {
|
||||
if ( $blog['deleted'] == '1' ) {
|
||||
$actions['activate'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=activateblog&id=' . $blog['blog_id'] ), 'activateblog_' . $blog['blog_id'] ) ) . '">' . __( 'Activate' ) . '</a>';
|
||||
$actions['activate'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=activateblog&id=' . $blog['blog_id'] ), 'activateblog_' . $blog['blog_id'] ) ) . '">' . __( 'Activate' ) . '</a>';
|
||||
} else {
|
||||
$actions['deactivate'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=deactivateblog&id=' . $blog['blog_id'] ), 'deactivateblog_' . $blog['blog_id'] ) ) . '">' . __( 'Deactivate' ) . '</a>';
|
||||
}
|
||||
|
@ -522,13 +543,13 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
|||
if ( $blog['archived'] == '1' ) {
|
||||
$actions['unarchive'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=unarchiveblog&id=' . $blog['blog_id'] ), 'unarchiveblog_' . $blog['blog_id'] ) ) . '">' . __( 'Unarchive' ) . '</a>';
|
||||
} else {
|
||||
$actions['archive'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=archiveblog&id=' . $blog['blog_id'] ), 'archiveblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Archive', 'verb; site' ) . '</a>';
|
||||
$actions['archive'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=archiveblog&id=' . $blog['blog_id'] ), 'archiveblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Archive', 'verb; site' ) . '</a>';
|
||||
}
|
||||
|
||||
if ( $blog['spam'] == '1' ) {
|
||||
$actions['unspam'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=unspamblog&id=' . $blog['blog_id'] ), 'unspamblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Not Spam', 'site' ) . '</a>';
|
||||
} else {
|
||||
$actions['spam'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=spamblog&id=' . $blog['blog_id'] ), 'spamblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Spam', 'site' ) . '</a>';
|
||||
$actions['spam'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=spamblog&id=' . $blog['blog_id'] ), 'spamblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Spam', 'site' ) . '</a>';
|
||||
}
|
||||
|
||||
if ( current_user_can( 'delete_site', $blog['blog_id'] ) ) {
|
||||
|
@ -536,7 +557,7 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
|||
}
|
||||
}
|
||||
|
||||
$actions['visit'] = "<a href='" . esc_url( get_home_url( $blog['blog_id'], '/' ) ) . "' rel='bookmark'>" . __( 'Visit' ) . '</a>';
|
||||
$actions['visit'] = "<a href='" . esc_url( get_home_url( $blog['blog_id'], '/' ) ) . "' rel='bookmark'>" . __( 'Visit' ) . '</a>';
|
||||
|
||||
/**
|
||||
* Filters the action links displayed for each site in the Sites list table.
|
||||
|
|
|
@ -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(
|
||||
'plural' => 'themes',
|
||||
'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
|
||||
) );
|
||||
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
|
||||
|
@ -97,20 +99,20 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
|
|||
*
|
||||
* @param array $all An array of WP_Theme objects to display in the list table.
|
||||
*/
|
||||
'all' => apply_filters( 'all_themes', wp_get_themes() ),
|
||||
'search' => array(),
|
||||
'enabled' => array(),
|
||||
'all' => apply_filters( 'all_themes', wp_get_themes() ),
|
||||
'search' => array(),
|
||||
'enabled' => array(),
|
||||
'disabled' => array(),
|
||||
'upgrade' => array(),
|
||||
'broken' => $this->is_site_themes ? array() : wp_get_themes( array( 'errors' => true ) ),
|
||||
'upgrade' => array(),
|
||||
'broken' => $this->is_site_themes ? array() : wp_get_themes( array( 'errors' => true ) ),
|
||||
);
|
||||
|
||||
if ( $this->is_site_themes ) {
|
||||
$themes_per_page = $this->get_items_per_page( 'site_themes_network_per_page' );
|
||||
$allowed_where = 'site';
|
||||
$allowed_where = 'site';
|
||||
} else {
|
||||
$themes_per_page = $this->get_items_per_page( 'themes_network_per_page' );
|
||||
$allowed_where = 'network';
|
||||
$allowed_where = 'network';
|
||||
}
|
||||
|
||||
$maybe_update = current_user_can( 'update_themes' ) && ! $this->is_site_themes && $current = get_site_transient( 'update_themes' );
|
||||
|
@ -123,24 +125,26 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
|
|||
|
||||
if ( $maybe_update && isset( $current->response[ $key ] ) ) {
|
||||
$themes['all'][ $key ]->update = true;
|
||||
$themes['upgrade'][ $key ] = $themes['all'][ $key ];
|
||||
$themes['upgrade'][ $key ] = $themes['all'][ $key ];
|
||||
}
|
||||
|
||||
$filter = $theme->is_allowed( $allowed_where, $this->site_id ) ? 'enabled' : 'disabled';
|
||||
$filter = $theme->is_allowed( $allowed_where, $this->site_id ) ? 'enabled' : 'disabled';
|
||||
$themes[ $filter ][ $key ] = $themes['all'][ $key ];
|
||||
}
|
||||
|
||||
if ( $s ) {
|
||||
$status = 'search';
|
||||
$status = 'search';
|
||||
$themes['search'] = array_filter( array_merge( $themes['all'], $themes['broken'] ), array( $this, '_search_callback' ) );
|
||||
}
|
||||
|
||||
$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,14 +152,16 @@ 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(
|
||||
'themes' => $totals,
|
||||
'totals' => wp_get_update_data(),
|
||||
) );
|
||||
wp_localize_script(
|
||||
'updates', '_wpUpdatesItemCounts', array(
|
||||
'themes' => $totals,
|
||||
'totals' => wp_get_update_data(),
|
||||
)
|
||||
);
|
||||
|
||||
if ( $orderby ) {
|
||||
$orderby = ucfirst( $orderby );
|
||||
$order = strtoupper( $order );
|
||||
$order = strtoupper( $order );
|
||||
|
||||
if ( $orderby === 'Name' ) {
|
||||
if ( 'ASC' === $order ) {
|
||||
|
@ -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(
|
||||
'total_items' => $total_this_page,
|
||||
'per_page' => $themes_per_page,
|
||||
) );
|
||||
$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 ) )
|
||||
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,13 +229,15 @@ 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,12 +262,11 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_sortable_columns() {
|
||||
return array(
|
||||
'name' => 'name',
|
||||
'name' => 'name',
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -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':
|
||||
|
@ -295,19 +308,21 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
|
|||
case 'upgrade':
|
||||
$text = _n( 'Update Available <span class="count">(%s)</span>', 'Update Available <span class="count">(%s)</span>', $count );
|
||||
break;
|
||||
case 'broken' :
|
||||
case 'broken':
|
||||
$text = _n( 'Broken <span class="count">(%s)</span>', 'Broken <span class="count">(%s)</span>', $count );
|
||||
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>",
|
||||
esc_url( add_query_arg('theme_status', $type, $url) ),
|
||||
$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,15 +341,19 @@ 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;
|
||||
}
|
||||
|
@ -342,8 +361,9 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
|
|||
/**
|
||||
*/
|
||||
public function display_rows() {
|
||||
foreach ( $this->items as $theme )
|
||||
foreach ( $this->items as $theme ) {
|
||||
$this->single_row( $theme );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -354,10 +374,10 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
|
|||
* @param WP_Theme $theme The current WP_Theme object.
|
||||
*/
|
||||
public function column_cb( $theme ) {
|
||||
$checkbox_id = 'checkbox_' . md5( $theme->get('Name') );
|
||||
$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
|
||||
}
|
||||
|
||||
|
@ -378,31 +398,33 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
|
|||
$context = $status;
|
||||
|
||||
if ( $this->is_site_themes ) {
|
||||
$url = "site-themes.php?id={$this->site_id}&";
|
||||
$url = "site-themes.php?id={$this->site_id}&";
|
||||
$allowed = $theme->is_allowed( 'site', $this->site_id );
|
||||
} else {
|
||||
$url = 'themes.php?';
|
||||
$url = 'themes.php?';
|
||||
$allowed = $theme->is_allowed( 'network' );
|
||||
}
|
||||
|
||||
// Pre-order.
|
||||
$actions = array(
|
||||
'enable' => '',
|
||||
'enable' => '',
|
||||
'disable' => '',
|
||||
'delete' => ''
|
||||
'delete' => '',
|
||||
);
|
||||
|
||||
$stylesheet = $theme->get_stylesheet();
|
||||
$theme_key = urlencode( $stylesheet );
|
||||
$theme_key = urlencode( $stylesheet );
|
||||
|
||||
if ( ! $allowed ) {
|
||||
if ( ! $theme->errors() ) {
|
||||
$url = add_query_arg( array(
|
||||
'action' => 'enable',
|
||||
'theme' => $theme_key,
|
||||
'paged' => $page,
|
||||
's' => $s,
|
||||
), $url );
|
||||
$url = add_query_arg(
|
||||
array(
|
||||
'action' => 'enable',
|
||||
'theme' => $theme_key,
|
||||
'paged' => $page,
|
||||
's' => $s,
|
||||
), $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(
|
||||
'action' => 'disable',
|
||||
'theme' => $theme_key,
|
||||
'paged' => $page,
|
||||
's' => $s,
|
||||
), $url );
|
||||
$url = add_query_arg(
|
||||
array(
|
||||
'action' => 'disable',
|
||||
'theme' => $theme_key,
|
||||
'paged' => $page,
|
||||
's' => $s,
|
||||
), $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(
|
||||
'action' => 'delete-selected',
|
||||
'checked[]' => $theme_key,
|
||||
'theme_status' => $context,
|
||||
'paged' => $page,
|
||||
's' => $s,
|
||||
), 'themes.php' );
|
||||
$url = add_query_arg(
|
||||
array(
|
||||
'action' => 'delete-selected',
|
||||
'checked[]' => $theme_key,
|
||||
'theme_status' => $context,
|
||||
'paged' => $page,
|
||||
's' => $s,
|
||||
), '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'>";
|
||||
|
@ -535,16 +565,17 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
|
|||
$stylesheet = $theme->get_stylesheet();
|
||||
$theme_meta = array();
|
||||
|
||||
if ( $theme->get('Version') ) {
|
||||
$theme_meta[] = sprintf( __( 'Version %s' ), $theme->display('Version') );
|
||||
if ( $theme->get( 'Version' ) ) {
|
||||
$theme_meta[] = sprintf( __( 'Version %s' ), $theme->display( 'Version' ) );
|
||||
}
|
||||
$theme_meta[] = sprintf( __( 'By %s' ), $theme->display('Author') );
|
||||
$theme_meta[] = sprintf( __( 'By %s' ), $theme->display( 'Author' ) );
|
||||
|
||||
if ( $theme->get('ThemeURI') ) {
|
||||
if ( $theme->get( 'ThemeURI' ) ) {
|
||||
/* 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 */
|
||||
|
@ -632,7 +662,7 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
|
|||
}
|
||||
|
||||
/* In case this is a child theme, label it properly */
|
||||
if ( $stylesheet !== $template && $item->get_stylesheet() === $stylesheet) {
|
||||
if ( $stylesheet !== $template && $item->get_stylesheet() === $stylesheet ) {
|
||||
$active_theme_label = ' — ' . __( 'Active Child Theme' );
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
@ -43,22 +41,22 @@ class WP_MS_Users_List_Table extends WP_List_Table {
|
|||
$paged = $this->get_pagenum();
|
||||
|
||||
$args = array(
|
||||
'number' => $users_per_page,
|
||||
'offset' => ( $paged-1 ) * $users_per_page,
|
||||
'search' => $usersearch,
|
||||
'number' => $users_per_page,
|
||||
'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' ) ) {
|
||||
$args['search'] = ltrim( $args['search'], '*' );
|
||||
} else if ( '' !== $args['search'] ) {
|
||||
} elseif ( '' !== $args['search'] ) {
|
||||
$args['search'] = trim( $args['search'], '*' );
|
||||
$args['search'] = '*' . $args['search'] . '*';
|
||||
}
|
||||
|
||||
if ( $role === 'super' ) {
|
||||
$logins = implode( "', '", get_super_admins() );
|
||||
$logins = implode( "', '", get_super_admins() );
|
||||
$args['include'] = $wpdb->get_col( "SELECT ID FROM $wpdb->users WHERE user_login IN ('$logins')" );
|
||||
}
|
||||
|
||||
|
@ -67,19 +65,23 @@ class WP_MS_Users_List_Table extends WP_List_Table {
|
|||
* show only the latest users with no paging in order to avoid
|
||||
* expensive count queries.
|
||||
*/
|
||||
if ( !$usersearch && wp_is_large_network( 'users' ) ) {
|
||||
if ( !isset($_REQUEST['orderby']) )
|
||||
if ( ! $usersearch && wp_is_large_network( 'users' ) ) {
|
||||
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,21 +98,23 @@ class WP_MS_Users_List_Table extends WP_List_Table {
|
|||
|
||||
$this->items = $wp_user_search->get_results();
|
||||
|
||||
$this->set_pagination_args( array(
|
||||
'total_items' => $wp_user_search->get_total(),
|
||||
'per_page' => $users_per_page,
|
||||
) );
|
||||
$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['spam'] = _x( 'Mark as Spam', 'user' );
|
||||
$actions['notspam'] = _x( 'Not Spam', 'user' );
|
||||
|
||||
return $actions;
|
||||
|
@ -123,22 +127,21 @@ class WP_MS_Users_List_Table extends WP_List_Table {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @global string $role
|
||||
* @return array
|
||||
*/
|
||||
protected function get_views() {
|
||||
global $role;
|
||||
|
||||
$total_users = get_user_count();
|
||||
$total_users = get_user_count();
|
||||
$super_admins = get_super_admins();
|
||||
$total_admins = count( $super_admins );
|
||||
|
||||
$current_link_attributes = $role !== 'super' ? ' class="current" aria-current="page"' : '';
|
||||
$role_links = array();
|
||||
$role_links['all'] = "<a href='" . network_admin_url( 'users.php' ) . "'$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>';
|
||||
$role_links = array();
|
||||
$role_links['all'] = "<a href='" . network_admin_url( 'users.php' ) . "'$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>';
|
||||
$current_link_attributes = $role === 'super' ? ' class="current" aria-current="page"' : '';
|
||||
$role_links['super'] = "<a href='" . network_admin_url( 'users.php?role=super' ) . "'$current_link_attributes>" . sprintf( _n( 'Super Admin <span class="count">(%s)</span>', 'Super Admins <span class="count">(%s)</span>', $total_admins ), number_format_i18n( $total_admins ) ) . '</a>';
|
||||
$role_links['super'] = "<a href='" . network_admin_url( 'users.php?role=super' ) . "'$current_link_attributes>" . sprintf( _n( 'Super Admin <span class="count">(%s)</span>', 'Super Admins <span class="count">(%s)</span>', $total_admins ), number_format_i18n( $total_admins ) ) . '</a>';
|
||||
|
||||
return $role_links;
|
||||
}
|
||||
|
@ -151,7 +154,7 @@ class WP_MS_Users_List_Table extends WP_List_Table {
|
|||
protected function pagination( $which ) {
|
||||
global $mode;
|
||||
|
||||
parent::pagination ( $which );
|
||||
parent::pagination( $which );
|
||||
|
||||
if ( 'top' === $which ) {
|
||||
$this->view_switcher( $mode );
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -232,13 +233,13 @@ class WP_MS_Users_List_Table extends WP_List_Table {
|
|||
*/
|
||||
public function column_username( $user ) {
|
||||
$super_admins = get_super_admins();
|
||||
$avatar = get_avatar( $user->user_email, 32 );
|
||||
$avatar = get_avatar( $user->user_email, 32 );
|
||||
|
||||
echo $avatar;
|
||||
|
||||
if ( current_user_can( 'edit_user', $user->ID ) ) {
|
||||
$edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user->ID ) ) );
|
||||
$edit = "<a href=\"{$edit_link}\">{$user->user_login}</a>";
|
||||
$edit = "<a href=\"{$edit_link}\">{$user->user_login}</a>";
|
||||
} else {
|
||||
$edit = $user->user_login;
|
||||
}
|
||||
|
@ -338,12 +339,12 @@ class WP_MS_Users_List_Table extends WP_List_Table {
|
|||
continue;
|
||||
}
|
||||
|
||||
$path = ( $val->path === '/' ) ? '' : $val->path;
|
||||
$path = ( $val->path === '/' ) ? '' : $val->path;
|
||||
echo '<span class="site-' . $val->site_id . '" >';
|
||||
echo '<a href="'. esc_url( network_admin_url( 'site-info.php?id=' . $val->userblog_id ) ) .'">' . str_replace( '.' . get_network()->domain, '', $val->domain . $path ) . '</a>';
|
||||
echo '<a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $val->userblog_id ) ) . '">' . str_replace( '.' . get_network()->domain, '', $val->domain . $path ) . '</a>';
|
||||
echo ' <small class="row-actions">';
|
||||
$actions = array();
|
||||
$actions['edit'] = '<a href="'. esc_url( network_admin_url( 'site-info.php?id=' . $val->userblog_id ) ) .'">' . __( 'Edit' ) . '</a>';
|
||||
$actions = array();
|
||||
$actions['edit'] = '<a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $val->userblog_id ) ) . '">' . __( 'Edit' ) . '</a>';
|
||||
|
||||
$class = '';
|
||||
if ( $val->spam == 1 ) {
|
||||
|
@ -373,7 +374,7 @@ class WP_MS_Users_List_Table extends WP_List_Table {
|
|||
*/
|
||||
$actions = apply_filters( 'ms_user_list_site_actions', $actions, $val->userblog_id );
|
||||
|
||||
$i=0;
|
||||
$i = 0;
|
||||
$action_count = count( $actions );
|
||||
foreach ( $actions as $action => $link ) {
|
||||
++$i;
|
||||
|
@ -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 ) {
|
||||
|
@ -448,7 +452,7 @@ class WP_MS_Users_List_Table extends WP_List_Table {
|
|||
$actions = array();
|
||||
|
||||
if ( current_user_can( 'edit_user', $user->ID ) ) {
|
||||
$edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user->ID ) ) );
|
||||
$edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user->ID ) ) );
|
||||
$actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
|
||||
}
|
||||
|
||||
|
|
|
@ -17,18 +17,17 @@
|
|||
*/
|
||||
class WP_Plugin_Install_List_Table extends WP_List_Table {
|
||||
|
||||
public $order = 'ASC';
|
||||
public $order = 'ASC';
|
||||
public $orderby = null;
|
||||
public $groups = array();
|
||||
public $groups = array();
|
||||
|
||||
private $error;
|
||||
|
||||
/**
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function ajax_user_can() {
|
||||
return current_user_can('install_plugins');
|
||||
return current_user_can( 'install_plugins' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -79,7 +78,6 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @global array $tabs
|
||||
* @global string $tab
|
||||
* @global int $paged
|
||||
|
@ -138,21 +136,22 @@ 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();
|
||||
|
||||
$args = array(
|
||||
'page' => $paged,
|
||||
'per_page' => $per_page,
|
||||
'fields' => array(
|
||||
'last_updated' => true,
|
||||
'icons' => true,
|
||||
'active_installs' => true
|
||||
'page' => $paged,
|
||||
'per_page' => $per_page,
|
||||
'fields' => array(
|
||||
'last_updated' => true,
|
||||
'icons' => 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(),
|
||||
'locale' => get_user_locale(),
|
||||
'installed_plugins' => array_keys( $installed_plugins ),
|
||||
);
|
||||
|
||||
|
@ -177,7 +176,7 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
|
|||
|
||||
case 'featured':
|
||||
$args['fields']['group'] = true;
|
||||
$this->orderby = 'group';
|
||||
$this->orderby = 'group';
|
||||
// No break!
|
||||
case 'popular':
|
||||
case 'new':
|
||||
|
@ -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(
|
||||
'total_items' => $api->info['results'],
|
||||
'per_page' => $args['per_page'],
|
||||
) );
|
||||
$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(
|
||||
'plugins' => $js_plugins,
|
||||
'totals' => wp_get_update_data(),
|
||||
) );
|
||||
wp_localize_script(
|
||||
'updates', '_wpUpdatesItemCounts', array(
|
||||
'plugins' => $js_plugins,
|
||||
'totals' => wp_get_update_data(),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -274,11 +279,10 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
|
|||
<?php } else { ?>
|
||||
<div class="no-plugin-results"><?php _e( 'No plugins found. Try a different search.' ); ?></div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @global array $tabs
|
||||
* @global string $tab
|
||||
*
|
||||
|
@ -289,9 +293,9 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
|
|||
|
||||
$display_tabs = array();
|
||||
foreach ( (array) $tabs as $action => $text ) {
|
||||
$current_link_attributes = ( $action === $tab ) ? ' class="current" aria-current="page"' : '';
|
||||
$href = self_admin_url('plugin-install.php?tab=' . $action);
|
||||
$display_tabs['plugin-install-'.$action] = "<a href='$href'$current_link_attributes>$text</a>";
|
||||
$current_link_attributes = ( $action === $tab ) ? ' class="current" aria-current="page"' : '';
|
||||
$href = self_admin_url( 'plugin-install.php?tab=' . $action );
|
||||
$display_tabs[ 'plugin-install-' . $action ] = "<a href='$href'$current_link_attributes>$text</a>";
|
||||
}
|
||||
// No longer a real tab.
|
||||
unset( $display_tabs['plugin-install-upload'] );
|
||||
|
@ -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" />
|
||||
|
@ -386,7 +391,7 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
|
|||
<br class="clear" />
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -430,16 +435,28 @@ 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(
|
||||
'Performance' => _x( 'Performance', 'Plugin installer group title' ),
|
||||
'Social' => _x( 'Social', 'Plugin installer group title' ),
|
||||
'Tools' => _x( 'Tools', 'Plugin installer group title' ),
|
||||
'Social' => _x( 'Social', 'Plugin installer group title' ),
|
||||
'Tools' => _x( 'Tools', 'Plugin installer group title' ),
|
||||
);
|
||||
|
||||
$group = null;
|
||||
|
@ -475,7 +492,7 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
|
|||
|
||||
// Remove any HTML from the description.
|
||||
$description = strip_tags( $plugin['short_description'] );
|
||||
$version = wp_kses( $plugin['version'], $plugins_allowedtags );
|
||||
$version = wp_kses( $plugin['version'], $plugins_allowedtags );
|
||||
|
||||
$name = strip_tags( $title . ' ' . $version );
|
||||
|
||||
|
@ -509,17 +526,19 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
|
|||
if ( is_plugin_active( $status['file'] ) ) {
|
||||
$action_links[] = '<button type="button" class="button button-disabled" disabled="disabled">' . _x( 'Active', 'plugin' ) . '</button>';
|
||||
} elseif ( current_user_can( 'activate_plugin', $status['file'] ) ) {
|
||||
$button_text = __( 'Activate' );
|
||||
$button_text = __( 'Activate' );
|
||||
/* translators: %s: Plugin name */
|
||||
$button_label = _x( 'Activate %s', 'plugin' );
|
||||
$activate_url = add_query_arg( array(
|
||||
'_wpnonce' => wp_create_nonce( 'activate-plugin_' . $status['file'] ),
|
||||
'action' => 'activate',
|
||||
'plugin' => $status['file'],
|
||||
), network_admin_url( 'plugins.php' ) );
|
||||
$activate_url = add_query_arg(
|
||||
array(
|
||||
'_wpnonce' => wp_create_nonce( 'activate-plugin_' . $status['file'] ),
|
||||
'action' => 'activate',
|
||||
'plugin' => $status['file'],
|
||||
), network_admin_url( 'plugins.php' )
|
||||
);
|
||||
|
||||
if ( is_network_admin() ) {
|
||||
$button_text = __( 'Network Activate' );
|
||||
$button_text = __( 'Network Activate' );
|
||||
/* translators: %s: Plugin name */
|
||||
$button_label = _x( 'Network Activate %s', 'plugin' );
|
||||
$activate_url = add_query_arg( array( 'networkwide' => 1 ), $activate_url );
|
||||
|
@ -538,17 +557,19 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
|
|||
}
|
||||
}
|
||||
|
||||
$details_link = self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $plugin['slug'] .
|
||||
'&TB_iframe=true&width=600&height=550' );
|
||||
$details_link = self_admin_url(
|
||||
'plugin-install.php?tab=plugin-information&plugin=' . $plugin['slug'] .
|
||||
'&TB_iframe=true&width=600&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>';
|
||||
|
||||
if ( !empty( $plugin['icons']['svg'] ) ) {
|
||||
if ( ! empty( $plugin['icons']['svg'] ) ) {
|
||||
$plugin_icon_url = $plugin['icons']['svg'];
|
||||
} elseif ( !empty( $plugin['icons']['2x'] ) ) {
|
||||
} elseif ( ! empty( $plugin['icons']['2x'] ) ) {
|
||||
$plugin_icon_url = $plugin['icons']['2x'];
|
||||
} elseif ( !empty( $plugin['icons']['1x'] ) ) {
|
||||
} elseif ( ! empty( $plugin['icons']['1x'] ) ) {
|
||||
$plugin_icon_url = $plugin['icons']['1x'];
|
||||
} else {
|
||||
$plugin_icon_url = $plugin['icons']['default'];
|
||||
|
@ -572,15 +593,15 @@ 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>
|
||||
<div class="action-links">
|
||||
<?php
|
||||
if ( $action_links ) {
|
||||
echo '<ul class="plugin-action-buttons"><li>' . implode( '</li><li>', $action_links ) . '</li></ul>';
|
||||
}
|
||||
if ( $action_links ) {
|
||||
echo '<ul class="plugin-action-buttons"><li>' . implode( '</li><li>', $action_links ) . '</li></ul>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<div class="desc column-description">
|
||||
|
@ -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">
|
||||
|
|
|
@ -32,17 +32,21 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
|||
public function __construct( $args = array() ) {
|
||||
global $status, $page;
|
||||
|
||||
parent::__construct( array(
|
||||
'plural' => 'plugins',
|
||||
'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
|
||||
) );
|
||||
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']) )
|
||||
$_SERVER['REQUEST_URI'] = add_query_arg('s', wp_unslash($_REQUEST['s']) );
|
||||
if ( isset( $_REQUEST['s'] ) ) {
|
||||
$_SERVER['REQUEST_URI'] = add_query_arg( 's', wp_unslash( $_REQUEST['s'] ) );
|
||||
}
|
||||
|
||||
$page = $this->get_pagenum();
|
||||
}
|
||||
|
@ -58,11 +62,10 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
|||
* @return bool
|
||||
*/
|
||||
public function ajax_user_can() {
|
||||
return current_user_can('activate_plugins');
|
||||
return current_user_can( 'activate_plugins' );
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @global string $status
|
||||
* @global array $plugins
|
||||
* @global array $totals
|
||||
|
@ -122,15 +125,16 @@ 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' );
|
||||
foreach ( (array) $plugins['all'] as $plugin_file => $plugin_data ) {
|
||||
if ( isset( $current->response[ $plugin_file ] ) ) {
|
||||
$plugins['all'][ $plugin_file ]['update'] = true;
|
||||
$plugins['upgrade'][ $plugin_file ] = $plugins['all'][ $plugin_file ];
|
||||
$plugins['upgrade'][ $plugin_file ] = $plugins['all'][ $plugin_file ];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -164,7 +168,7 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
|||
|
||||
foreach ( $recently_activated as $key => $time ) {
|
||||
if ( $time + WEEK_IN_SECONDS < time() ) {
|
||||
unset( $recently_activated[$key] );
|
||||
unset( $recently_activated[ $key ] );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -226,21 +229,23 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
|||
}
|
||||
|
||||
if ( strlen( $s ) ) {
|
||||
$status = 'search';
|
||||
$status = 'search';
|
||||
$plugins['search'] = array_filter( $plugins['all'], array( $this, '_search_callback' ) );
|
||||
}
|
||||
|
||||
$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 ) {
|
||||
// Translate, Don't Apply Markup, Sanitize HTML
|
||||
$this->items[$plugin_file] = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, false, true );
|
||||
$this->items[ $plugin_file ] = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, false, true );
|
||||
}
|
||||
|
||||
$total_this_page = $totals[ $status ];
|
||||
|
@ -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(
|
||||
'plugins' => $js_plugins,
|
||||
'totals' => wp_get_update_data(),
|
||||
) );
|
||||
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(
|
||||
'total_items' => $total_this_page,
|
||||
'per_page' => $plugins_per_page,
|
||||
) );
|
||||
$this->set_pagination_args(
|
||||
array(
|
||||
'total_items' => $total_this_page,
|
||||
'per_page' => $plugins_per_page,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -306,11 +316,12 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
|||
public function _order_callback( $plugin_a, $plugin_b ) {
|
||||
global $orderby, $order;
|
||||
|
||||
$a = $plugin_a[$orderby];
|
||||
$b = $plugin_b[$orderby];
|
||||
$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,10 +345,11 @@ 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.' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -372,7 +383,6 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @global string $status
|
||||
* @return array
|
||||
*/
|
||||
|
@ -380,7 +390,7 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
|||
global $status;
|
||||
|
||||
return array(
|
||||
'cb' => !in_array( $status, array( 'mustuse', 'dropins' ) ) ? '<input type="checkbox" />' : '',
|
||||
'cb' => ! in_array( $status, array( 'mustuse', 'dropins' ) ) ? '<input type="checkbox" />' : '',
|
||||
'name' => __( 'Plugin' ),
|
||||
'description' => __( 'Description' ),
|
||||
);
|
||||
|
@ -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,11 +442,12 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
|||
}
|
||||
|
||||
if ( 'search' !== $type ) {
|
||||
$status_links[$type] = sprintf( "<a href='%s'%s>%s</a>",
|
||||
add_query_arg('plugin_status', $type, 'plugins.php'),
|
||||
$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,17 +463,21 @@ 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 ( ! is_multisite() || $this->screen->in_admin( 'network' ) ) {
|
||||
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,24 +532,26 @@ 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 ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -546,52 +566,55 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
|||
global $status, $page, $s, $totals;
|
||||
|
||||
list( $plugin_file, $plugin_data ) = $item;
|
||||
$context = $status;
|
||||
$screen = $this->screen;
|
||||
$context = $status;
|
||||
$screen = $this->screen;
|
||||
|
||||
// Pre-order.
|
||||
$actions = array(
|
||||
'deactivate' => '',
|
||||
'activate' => '',
|
||||
'details' => '',
|
||||
'delete' => '',
|
||||
'activate' => '',
|
||||
'details' => '',
|
||||
'delete' => '',
|
||||
);
|
||||
|
||||
// Do not restrict by default
|
||||
$restrict_network_active = false;
|
||||
$restrict_network_only = false;
|
||||
$restrict_network_only = false;
|
||||
|
||||
if ( 'mustuse' === $context ) {
|
||||
$is_active = true;
|
||||
} elseif ( 'dropins' === $context ) {
|
||||
$dropins = _get_dropins();
|
||||
$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;
|
||||
$is_active = true;
|
||||
$description = '<p><strong>' . $dropins[ $plugin_file ][0] . '</strong></p>';
|
||||
} elseif ( defined( $dropins[ $plugin_file ][1] ) && constant( $dropins[ $plugin_file ][1] ) ) { // Constant is true
|
||||
$is_active = true;
|
||||
$is_active = true;
|
||||
$description = '<p><strong>' . $dropins[ $plugin_file ][0] . '</strong></p>';
|
||||
} else {
|
||||
$is_active = false;
|
||||
$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 );
|
||||
} else {
|
||||
$is_active = is_plugin_active( $plugin_file );
|
||||
$is_active = is_plugin_active( $plugin_file );
|
||||
$restrict_network_active = ( is_multisite() && is_plugin_active_for_network( $plugin_file ) );
|
||||
$restrict_network_only = ( is_multisite() && is_network_only_plugin( $plugin_file ) && ! $is_active );
|
||||
$restrict_network_only = ( is_multisite() && is_network_only_plugin( $plugin_file ) && ! $is_active );
|
||||
}
|
||||
|
||||
if ( $screen->in_admin( 'network' ) ) {
|
||||
|
@ -599,7 +622,7 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
|||
if ( current_user_can( 'manage_network_plugins' ) ) {
|
||||
/* translators: %s: plugin name */
|
||||
$actions['deactivate'] = '<a href="' . wp_nonce_url( 'plugins.php?action=deactivate&plugin=' . urlencode( $plugin_file ) . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'deactivate-plugin_' . $plugin_file ) . '" aria-label="' . esc_attr( sprintf( _x( 'Network Deactivate %s', 'plugin' ), $plugin_data['Name'] ) ) . '">' . __( 'Network Deactivate' ) . '</a>';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ( current_user_can( 'manage_network_plugins' ) ) {
|
||||
/* translators: %s: plugin name */
|
||||
|
@ -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&checked[]=' . urlencode( $plugin_file ) . '&plugin_status=' . $context . '&paged=' . $page . '&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 );
|
||||
|
@ -715,12 +736,12 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
|||
|
||||
}
|
||||
|
||||
$class = $is_active ? 'active' : 'inactive';
|
||||
$checkbox_id = "checkbox_" . md5($plugin_data['Name']);
|
||||
$class = $is_active ? 'active' : 'inactive';
|
||||
$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'] ) ) {
|
||||
}
|
||||
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.
|
||||
|
|
|
@ -18,14 +18,13 @@
|
|||
class WP_Post_Comments_List_Table extends WP_Comments_List_Table {
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_column_info() {
|
||||
return array(
|
||||
array(
|
||||
'author' => __( 'Author' ),
|
||||
'comment' => _x( 'Comment', 'column name' ),
|
||||
'author' => __( 'Author' ),
|
||||
'comment' => _x( 'Comment', 'column name' ),
|
||||
),
|
||||
array(),
|
||||
array(),
|
||||
|
@ -34,40 +33,42 @@ class WP_Post_Comments_List_Table extends WP_Comments_List_Table {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_table_classes() {
|
||||
$classes = parent::get_table_classes();
|
||||
$classes = parent::get_table_classes();
|
||||
$classes[] = 'wp-list-table';
|
||||
$classes[] = 'comments-box';
|
||||
return $classes;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @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
|
||||
if ( $singular ) {
|
||||
echo " data-wp-lists='list:$singular'";
|
||||
} ?>>
|
||||
<?php if ( ! $output_empty ) {
|
||||
<tbody id="the-comment-list"
|
||||
<?php
|
||||
if ( $singular ) {
|
||||
echo " data-wp-lists='list:$singular'";
|
||||
}
|
||||
?>
|
||||
>
|
||||
<?php
|
||||
if ( ! $output_empty ) {
|
||||
$this->display_rows_or_placeholder();
|
||||
} ?>
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param bool $comment_status
|
||||
* @return int
|
||||
*/
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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
|
||||
*/
|
||||
|
@ -129,7 +130,7 @@ final class WP_Screen {
|
|||
*/
|
||||
private $_help_sidebar = '';
|
||||
|
||||
/**
|
||||
/**
|
||||
* The accessible hidden headings and text associated with the screen, if any.
|
||||
*
|
||||
* @since 4.4.0
|
||||
|
@ -191,7 +192,7 @@ final class WP_Screen {
|
|||
* @global string $hook_suffix
|
||||
*
|
||||
* @param string|WP_Screen $hook_name Optional. The hook name (also known as the hook suffix) used to determine the screen.
|
||||
* Defaults to the current $hook_suffix global.
|
||||
* Defaults to the current $hook_suffix global.
|
||||
* @return WP_Screen Screen object.
|
||||
*/
|
||||
public static function get( $hook_name = '' ) {
|
||||
|
@ -200,34 +201,36 @@ final class WP_Screen {
|
|||
}
|
||||
|
||||
$post_type = $taxonomy = null;
|
||||
$in_admin = false;
|
||||
$action = '';
|
||||
$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.
|
||||
$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 );
|
||||
$id = substr( $id, 0, -4 );
|
||||
$action = 'add';
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $post_type && $hook_name ) {
|
||||
if ( '-network' == substr( $id, -8 ) ) {
|
||||
$id = substr( $id, 0, -8 );
|
||||
$id = substr( $id, 0, -8 );
|
||||
$in_admin = 'network';
|
||||
} elseif ( '-user' == substr( $id, -5 ) ) {
|
||||
$id = substr( $id, 0, -5 );
|
||||
$id = substr( $id, 0, -5 );
|
||||
$in_admin = 'user';
|
||||
}
|
||||
|
||||
|
@ -235,58 +238,66 @@ final class WP_Screen {
|
|||
if ( 'edit-comments' != $id && 'edit-tags' != $id && 'edit-' == substr( $id, 0, 5 ) ) {
|
||||
$maybe = substr( $id, 5 );
|
||||
if ( taxonomy_exists( $maybe ) ) {
|
||||
$id = 'edit-tags';
|
||||
$id = 'edit-tags';
|
||||
$taxonomy = $maybe;
|
||||
} elseif ( post_type_exists( $maybe ) ) {
|
||||
$id = 'edit';
|
||||
$id = 'edit';
|
||||
$post_type = $maybe;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $in_admin )
|
||||
if ( ! $in_admin ) {
|
||||
$in_admin = 'site';
|
||||
}
|
||||
} else {
|
||||
if ( defined( 'WP_NETWORK_ADMIN' ) && WP_NETWORK_ADMIN )
|
||||
if ( defined( 'WP_NETWORK_ADMIN' ) && WP_NETWORK_ADMIN ) {
|
||||
$in_admin = 'network';
|
||||
elseif ( defined( 'WP_USER_ADMIN' ) && WP_USER_ADMIN )
|
||||
} elseif ( defined( 'WP_USER_ADMIN' ) && WP_USER_ADMIN ) {
|
||||
$in_admin = 'user';
|
||||
else
|
||||
} 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'] ) )
|
||||
case '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' ) )
|
||||
case 'edit-tags':
|
||||
case 'term':
|
||||
if ( null === $post_type && is_object_in_taxonomy( 'post', $taxonomy ? $taxonomy : 'post_tag' ) ) {
|
||||
$post_type = 'post';
|
||||
}
|
||||
break;
|
||||
case 'upload':
|
||||
$post_type = 'attachment';
|
||||
|
@ -295,25 +306,29 @@ final class WP_Screen {
|
|||
}
|
||||
|
||||
switch ( $base ) {
|
||||
case 'post' :
|
||||
if ( null === $post_type )
|
||||
case 'post':
|
||||
if ( null === $post_type ) {
|
||||
$post_type = 'post';
|
||||
}
|
||||
$id = $post_type;
|
||||
break;
|
||||
case 'edit' :
|
||||
if ( null === $post_type )
|
||||
case 'edit':
|
||||
if ( null === $post_type ) {
|
||||
$post_type = 'post';
|
||||
}
|
||||
$id .= '-' . $post_type;
|
||||
break;
|
||||
case 'edit-tags' :
|
||||
case 'term' :
|
||||
if ( null === $taxonomy )
|
||||
case 'edit-tags':
|
||||
case 'term':
|
||||
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;
|
||||
|
@ -330,11 +345,12 @@ 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;
|
||||
$screen = new WP_Screen();
|
||||
$screen->id = $id;
|
||||
}
|
||||
|
||||
$screen->base = $base;
|
||||
|
@ -363,8 +379,8 @@ final class WP_Screen {
|
|||
public function set_current_screen() {
|
||||
global $current_screen, $taxnow, $typenow;
|
||||
$current_screen = $this;
|
||||
$taxnow = $this->taxonomy;
|
||||
$typenow = $this->post_type;
|
||||
$taxnow = $this->taxonomy;
|
||||
$typenow = $this->post_type;
|
||||
|
||||
/**
|
||||
* Fires after the current screen has been set.
|
||||
|
@ -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 );
|
||||
}
|
||||
|
@ -422,9 +439,9 @@ final class WP_Screen {
|
|||
* @param string $parent_file The parent file of the screen. Typically the $parent_file global.
|
||||
*/
|
||||
public function set_parentage( $parent_file ) {
|
||||
$this->parent_file = $parent_file;
|
||||
$this->parent_file = $parent_file;
|
||||
list( $this->parent_base ) = explode( '?', $parent_file );
|
||||
$this->parent_base = str_replace( '.php', '', $this->parent_base );
|
||||
$this->parent_base = str_replace( '.php', '', $this->parent_base );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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 ];
|
||||
}
|
||||
|
||||
|
@ -563,13 +583,14 @@ final class WP_Screen {
|
|||
'callback' => false,
|
||||
'priority' => 10,
|
||||
);
|
||||
$args = wp_parse_args( $args, $defaults );
|
||||
$args = wp_parse_args( $args, $defaults );
|
||||
|
||||
$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;
|
||||
|
@ -635,7 +656,7 @@ final class WP_Screen {
|
|||
return $this->columns;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the accessible hidden headings and text used in the screen.
|
||||
*
|
||||
* @since 4.4.0
|
||||
|
@ -685,7 +706,7 @@ final class WP_Screen {
|
|||
'heading_pagination' => __( 'Items list navigation' ),
|
||||
'heading_list' => __( 'Items list' ),
|
||||
);
|
||||
$content = wp_parse_args( $content, $defaults );
|
||||
$content = wp_parse_args( $content, $defaults );
|
||||
|
||||
$this->_screen_reader_content = $content;
|
||||
}
|
||||
|
@ -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,29 +771,33 @@ 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(
|
||||
'id' => 'old-contextual-help',
|
||||
'title' => __('Overview'),
|
||||
'content' => $old_help,
|
||||
) );
|
||||
$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!
|
||||
?>
|
||||
<div id="screen-meta" class="metabox-prefs">
|
||||
|
||||
<div id="contextual-help-wrap" class="<?php echo esc_attr( $help_class ); ?>" tabindex="-1" aria-label="<?php esc_attr_e('Contextual Help Tab'); ?>">
|
||||
<div id="contextual-help-wrap" class="<?php echo esc_attr( $help_class ); ?>" tabindex="-1" aria-label="<?php esc_attr_e( 'Contextual Help Tab' ); ?>">
|
||||
<div id="contextual-help-back"></div>
|
||||
<div id="contextual-help-columns">
|
||||
<div class="contextual-help-tabs">
|
||||
|
@ -806,7 +830,7 @@ final class WP_Screen {
|
|||
<div class="contextual-help-tabs-wrap">
|
||||
<?php
|
||||
$classes = 'help-tab-content active';
|
||||
foreach ( $this->get_help_tabs() as $tab ):
|
||||
foreach ( $this->get_help_tabs() as $tab ) :
|
||||
$panel_id = "tab-panel-{$tab['id']}";
|
||||
?>
|
||||
|
||||
|
@ -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 ] ) )
|
||||
$this->add_option( 'layout_columns', array('max' => $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");
|
||||
$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.
|
||||
$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 );
|
||||
|
||||
|
@ -897,13 +928,13 @@ final class WP_Screen {
|
|||
|
||||
switch ( $this->base ) {
|
||||
case 'widgets':
|
||||
$nonce = wp_create_nonce( 'widgets-access' );
|
||||
$this->_screen_settings = '<p><a id="access-on" href="widgets.php?widgets-access=on&_wpnonce=' . urlencode( $nonce ) . '">' . __('Enable accessibility mode') . '</a><a id="access-off" href="widgets.php?widgets-access=off&_wpnonce=' . urlencode( $nonce ) . '">' . __('Disable accessibility mode') . "</a></p>\n";
|
||||
$nonce = wp_create_nonce( 'widgets-access' );
|
||||
$this->_screen_settings = '<p><a id="access-on" href="widgets.php?widgets-access=on&_wpnonce=' . urlencode( $nonce ) . '">' . __( 'Enable accessibility mode' ) . '</a><a id="access-off" href="widgets.php?widgets-access=off&_wpnonce=' . urlencode( $nonce ) . '">' . __( 'Disable accessibility mode' ) . "</a></p>\n";
|
||||
break;
|
||||
case 'post' :
|
||||
$expand = '<fieldset class="editor-expand hidden"><legend>' . __( 'Additional settings' ) . '</legend><label for="editor-expand-toggle">';
|
||||
$expand .= '<input type="checkbox" id="editor-expand-toggle"' . checked( get_user_setting( 'editor_expand', 'on' ), 'on', false ) . ' />';
|
||||
$expand .= __( 'Enable full-height editor and distraction-free functionality.' ) . '</label></fieldset>';
|
||||
case 'post':
|
||||
$expand = '<fieldset class="editor-expand hidden"><legend>' . __( 'Additional settings' ) . '</legend><label for="editor-expand-toggle">';
|
||||
$expand .= '<input type="checkbox" id="editor-expand-toggle"' . checked( get_user_setting( 'editor_expand', 'on' ), 'on', false ) . ' />';
|
||||
$expand .= __( 'Enable full-height editor and distraction-free functionality.' ) . '</label></fieldset>';
|
||||
$this->_screen_settings = $expand;
|
||||
break;
|
||||
default:
|
||||
|
@ -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,22 +982,24 @@ final class WP_Screen {
|
|||
* }
|
||||
*/
|
||||
public function render_screen_options( $options = array() ) {
|
||||
$options = wp_parse_args( $options, array(
|
||||
'wrap' => true,
|
||||
) );
|
||||
$options = wp_parse_args(
|
||||
$options, array(
|
||||
'wrap' => true,
|
||||
)
|
||||
);
|
||||
|
||||
$wrapper_start = $wrapper_end = $form_start = $form_end = '';
|
||||
|
||||
// Output optional wrapper.
|
||||
if ( $options['wrap'] ) {
|
||||
$wrapper_start = '<div id="screen-options-wrap" class="hidden" tabindex="-1" aria-label="' . esc_attr__( 'Screen Options Tab' ) . '">';
|
||||
$wrapper_end = '</div>';
|
||||
$wrapper_end = '</div>';
|
||||
}
|
||||
|
||||
// Don't output the form and nonce for the widgets accessibility mode links.
|
||||
if ( 'widgets' !== $this->base ) {
|
||||
$form_start = "\n<form id='adv-settings' method='post'>\n";
|
||||
$form_end = "\n" . wp_nonce_field( 'screen-options-nonce', 'screenoptionnonce', false, false ) . "\n</form>\n";
|
||||
$form_end = "\n" . wp_nonce_field( 'screen-options-nonce', 'screenoptionnonce', false, false ) . "\n</form>\n";
|
||||
}
|
||||
|
||||
echo $wrapper_start . $form_start;
|
||||
|
@ -1014,20 +1048,20 @@ final class WP_Screen {
|
|||
<?php
|
||||
meta_box_prefs( $this );
|
||||
|
||||
if ( 'dashboard' === $this->id && has_action( 'welcome_panel' ) && current_user_can( 'edit_theme_options' ) ) {
|
||||
if ( isset( $_GET['welcome'] ) ) {
|
||||
$welcome_checked = empty( $_GET['welcome'] ) ? 0 : 1;
|
||||
update_user_meta( get_current_user_id(), 'show_welcome_panel', $welcome_checked );
|
||||
} else {
|
||||
$welcome_checked = get_user_meta( get_current_user_id(), 'show_welcome_panel', true );
|
||||
if ( 2 == $welcome_checked && wp_get_current_user()->user_email != get_option( 'admin_email' ) ) {
|
||||
$welcome_checked = false;
|
||||
}
|
||||
if ( 'dashboard' === $this->id && has_action( 'welcome_panel' ) && current_user_can( 'edit_theme_options' ) ) {
|
||||
if ( isset( $_GET['welcome'] ) ) {
|
||||
$welcome_checked = empty( $_GET['welcome'] ) ? 0 : 1;
|
||||
update_user_meta( get_current_user_id(), 'show_welcome_panel', $welcome_checked );
|
||||
} else {
|
||||
$welcome_checked = get_user_meta( get_current_user_id(), 'show_welcome_panel', true );
|
||||
if ( 2 == $welcome_checked && wp_get_current_user()->user_email != get_option( 'admin_email' ) ) {
|
||||
$welcome_checked = false;
|
||||
}
|
||||
echo '<label for="wp_welcome_panel-hide">';
|
||||
echo '<input type="checkbox" id="wp_welcome_panel-hide"' . checked( (bool) $welcome_checked, true, false ) . ' />';
|
||||
echo _x( 'Welcome', 'Welcome panel' ) . "</label>\n";
|
||||
}
|
||||
echo '<label for="wp_welcome_panel-hide">';
|
||||
echo '<input type="checkbox" id="wp_welcome_panel-hide"' . checked( (bool) $welcome_checked, true, false ) . ' />';
|
||||
echo _x( 'Welcome', 'Welcome panel' ) . "</label>\n";
|
||||
}
|
||||
?>
|
||||
</fieldset>
|
||||
<?php
|
||||
|
@ -1092,20 +1126,22 @@ final class WP_Screen {
|
|||
}
|
||||
|
||||
$screen_layout_columns = $this->get_columns();
|
||||
$num = $this->get_option( 'layout_columns', 'max' );
|
||||
$num = $this->get_option( 'layout_columns', 'max' );
|
||||
|
||||
?>
|
||||
<fieldset class='columns-prefs'>
|
||||
<legend class="screen-layout"><?php _e( 'Layout' ); ?></legend><?php
|
||||
for ( $i = 1; $i <= $num; ++$i ):
|
||||
?>
|
||||
<label class="columns-prefs-<?php echo $i; ?>">
|
||||
<input type='radio' name='screen_columns' value='<?php echo esc_attr( $i ); ?>'
|
||||
<?php checked( $screen_layout_columns, $i ); ?> />
|
||||
<?php printf( _n( '%s column', '%s columns', $i ), number_format_i18n( $i ) ); ?>
|
||||
<legend class="screen-layout"><?php _e( 'Layout' ); ?></legend>
|
||||
<?php
|
||||
for ( $i = 1; $i <= $num; ++$i ) :
|
||||
?>
|
||||
<label class="columns-prefs-<?php echo $i; ?>">
|
||||
<input type='radio' name='screen_columns' value='<?php echo esc_attr( $i ); ?>'
|
||||
<?php checked( $screen_layout_columns, $i ); ?> />
|
||||
<?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.
|
||||
|
|
|
@ -20,7 +20,7 @@ class WP_Site_Icon {
|
|||
* @since 4.3.0
|
||||
* @var int
|
||||
*/
|
||||
public $min_size = 512;
|
||||
public $min_size = 512;
|
||||
|
||||
/**
|
||||
* The size to which to crop the image so that we can display it in the UI nicely.
|
||||
|
@ -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;
|
||||
|
|
|
@ -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(
|
||||
'plural' => 'tags',
|
||||
'singular' => 'tag',
|
||||
'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
|
||||
) );
|
||||
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() {
|
||||
|
@ -105,30 +109,33 @@ class WP_Terms_List_Table extends WP_List_Table {
|
|||
$tags_per_page = apply_filters( 'edit_categories_per_page', $tags_per_page );
|
||||
}
|
||||
|
||||
$search = !empty( $_REQUEST['s'] ) ? trim( wp_unslash( $_REQUEST['s'] ) ) : '';
|
||||
$search = ! empty( $_REQUEST['s'] ) ? trim( wp_unslash( $_REQUEST['s'] ) ) : '';
|
||||
|
||||
$args = array(
|
||||
'search' => $search,
|
||||
'page' => $this->get_pagenum(),
|
||||
'page' => $this->get_pagenum(),
|
||||
'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(
|
||||
'total_items' => wp_count_terms( $this->screen->taxonomy, compact( 'search' ) ),
|
||||
'per_page' => $tags_per_page,
|
||||
) );
|
||||
$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(
|
||||
'page' => 1,
|
||||
'number' => 20,
|
||||
'search' => '',
|
||||
'hide_empty' => 0
|
||||
) );
|
||||
$args = wp_parse_args(
|
||||
$this->callback_args, array(
|
||||
'page' => 1,
|
||||
'number' => 20,
|
||||
'search' => '',
|
||||
'hide_empty' => 0,
|
||||
)
|
||||
);
|
||||
|
||||
$page = $args['page'];
|
||||
|
||||
|
@ -268,22 +274,25 @@ 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'] ) ) {
|
||||
$my_parents = $parent_ids = array();
|
||||
$p = $term->parent;
|
||||
$p = $term->parent;
|
||||
while ( $p ) {
|
||||
$my_parent = get_term( $p, $taxonomy );
|
||||
$my_parent = get_term( $p, $taxonomy );
|
||||
$my_parents[] = $my_parent;
|
||||
$p = $my_parent->parent;
|
||||
if ( in_array( $p, $parent_ids ) ) // Prevent parent loops.
|
||||
$p = $my_parent->parent;
|
||||
if ( in_array( $p, $parent_ids ) ) { // Prevent parent loops.
|
||||
break;
|
||||
}
|
||||
$parent_ids[] = $p;
|
||||
}
|
||||
unset( $parent_ids );
|
||||
|
@ -303,10 +312,11 @@ class WP_Terms_List_Table extends WP_List_Table {
|
|||
|
||||
++$count;
|
||||
|
||||
unset( $terms[$key] );
|
||||
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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -317,7 +327,7 @@ class WP_Terms_List_Table extends WP_List_Table {
|
|||
*/
|
||||
public function single_row( $tag, $level = 0 ) {
|
||||
global $taxonomy;
|
||||
$tag = sanitize_term( $tag, $taxonomy );
|
||||
$tag = sanitize_term( $tag, $taxonomy );
|
||||
|
||||
$this->level = $level;
|
||||
|
||||
|
@ -418,8 +428,8 @@ class WP_Terms_List_Table extends WP_List_Table {
|
|||
}
|
||||
|
||||
$taxonomy = $this->screen->taxonomy;
|
||||
$tax = get_taxonomy( $taxonomy );
|
||||
$uri = wp_doing_ajax() ? wp_get_referer() : $_SERVER['REQUEST_URI'];
|
||||
$tax = get_taxonomy( $taxonomy );
|
||||
$uri = wp_doing_ajax() ? wp_get_referer() : $_SERVER['REQUEST_URI'];
|
||||
|
||||
$edit_link = add_query_arg(
|
||||
'wp_http_referer',
|
||||
|
@ -521,22 +531,28 @@ 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 )
|
||||
return "<a href='" . esc_url ( add_query_arg( $args, 'upload.php' ) ) . "'>$count</a>";
|
||||
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>";
|
||||
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">
|
||||
|
@ -593,7 +611,7 @@ class WP_Terms_List_Table extends WP_List_Table {
|
|||
<span class="title"><?php _ex( 'Name', 'term name' ); ?></span>
|
||||
<span class="input-text-wrap"><input type="text" name="name" class="ptitle" value="" /></span>
|
||||
</label>
|
||||
<?php if ( !global_terms_enabled() ) { ?>
|
||||
<?php if ( ! global_terms_enabled() ) { ?>
|
||||
<label>
|
||||
<span class="title"><?php _e( 'Slug' ); ?></span>
|
||||
<span class="input-text-wrap"><input type="text" name="slug" class="ptitle" value="" /></span>
|
||||
|
@ -602,18 +620,25 @@ 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] ) )
|
||||
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 );
|
||||
foreach ( $columns as $column_name => $column_display_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 );
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<div class="inline-edit-save submit">
|
||||
|
|
|
@ -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
|
||||
|
@ -41,30 +39,32 @@ class WP_Theme_Install_List_Table extends WP_Themes_List_Table {
|
|||
global $tabs, $tab, $paged, $type, $theme_field_defaults;
|
||||
wp_reset_vars( array( 'tab' ) );
|
||||
|
||||
$search_terms = array();
|
||||
$search_terms = array();
|
||||
$search_string = '';
|
||||
if ( ! empty( $_REQUEST['s'] ) ){
|
||||
if ( ! empty( $_REQUEST['s'] ) ) {
|
||||
$search_string = strtolower( wp_unslash( $_REQUEST['s'] ) );
|
||||
$search_terms = array_unique( array_filter( array_map( 'trim', explode( ',', $search_string ) ) ) );
|
||||
$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();
|
||||
|
||||
$per_page = 36;
|
||||
|
||||
// These are the tabs which are shown on the page,
|
||||
$tabs = array();
|
||||
$tabs = array();
|
||||
$tabs['dashboard'] = __( 'Search' );
|
||||
if ( 'search' === $tab )
|
||||
$tabs['search'] = __( 'Search Results' );
|
||||
$tabs['upload'] = __( 'Upload' );
|
||||
if ( 'search' === $tab ) {
|
||||
$tabs['search'] = __( 'Search Results' );
|
||||
}
|
||||
$tabs['upload'] = __( 'Upload' );
|
||||
$tabs['featured'] = _x( 'Featured', 'themes' );
|
||||
//$tabs['popular'] = _x( 'Popular', 'themes' );
|
||||
$tabs['new'] = _x( 'Latest', 'themes' );
|
||||
$tabs['updated'] = _x( 'Recently Updated', 'themes' );
|
||||
$tabs['new'] = _x( 'Latest', 'themes' );
|
||||
$tabs['updated'] = _x( 'Recently Updated', 'themes' );
|
||||
|
||||
$nonmenu_tabs = array( 'theme-information' ); // Valid actions to perform which do not have a Menu item.
|
||||
|
||||
|
@ -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':
|
||||
|
@ -103,8 +108,8 @@ class WP_Theme_Install_List_Table extends WP_Themes_List_Table {
|
|||
}
|
||||
|
||||
if ( ! empty( $this->features ) ) {
|
||||
$args['tag'] = $this->features;
|
||||
$_REQUEST['s'] = implode( ',', $this->features );
|
||||
$args['tag'] = $this->features;
|
||||
$_REQUEST['s'] = implode( ',', $this->features );
|
||||
$_REQUEST['type'] = 'tag';
|
||||
}
|
||||
|
||||
|
@ -112,7 +117,7 @@ class WP_Theme_Install_List_Table extends WP_Themes_List_Table {
|
|||
break;
|
||||
|
||||
case 'featured':
|
||||
// case 'popular':
|
||||
// case 'popular':
|
||||
case 'new':
|
||||
case 'updated':
|
||||
$args['browse'] = $tab;
|
||||
|
@ -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(
|
||||
'total_items' => $api->info['results'],
|
||||
'per_page' => $args['per_page'],
|
||||
'infinite_scroll' => true,
|
||||
) );
|
||||
$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
|
||||
|
@ -170,9 +178,9 @@ class WP_Theme_Install_List_Table extends WP_Themes_List_Table {
|
|||
|
||||
$display_tabs = array();
|
||||
foreach ( (array) $tabs as $action => $text ) {
|
||||
$current_link_attributes = ( $action === $tab ) ? ' class="current" aria-current="page"' : '';
|
||||
$href = self_admin_url('theme-install.php?tab=' . $action);
|
||||
$display_tabs['theme-install-'.$action] = "<a href='$href'$current_link_attributes>$text</a>";
|
||||
$current_link_attributes = ( $action === $tab ) ? ' class="current" aria-current="page"' : '';
|
||||
$href = self_admin_url( 'theme-install.php?tab=' . $action );
|
||||
$display_tabs[ 'theme-install-' . $action ] = "<a href='$href'$current_link_attributes>$text</a>";
|
||||
}
|
||||
|
||||
return $display_tabs;
|
||||
|
@ -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 );
|
||||
$name = wp_kses( $theme->name, $themes_allowedtags );
|
||||
$author = wp_kses( $theme->author, $themes_allowedtags );
|
||||
|
||||
$preview_title = sprintf( __('Preview “%s”'), $name );
|
||||
$preview_url = add_query_arg( array(
|
||||
'tab' => 'theme-information',
|
||||
'theme' => $theme->slug,
|
||||
), self_admin_url( 'theme-install.php' ) );
|
||||
$preview_title = sprintf( __( 'Preview “%s”' ), $name );
|
||||
$preview_url = add_query_arg(
|
||||
array(
|
||||
'tab' => 'theme-information',
|
||||
'theme' => $theme->slug,
|
||||
), self_admin_url( 'theme-install.php' )
|
||||
);
|
||||
|
||||
$actions = array();
|
||||
|
||||
$install_url = add_query_arg( array(
|
||||
'action' => 'install-theme',
|
||||
'theme' => $theme->slug,
|
||||
), self_admin_url( 'update.php' ) );
|
||||
$install_url = add_query_arg(
|
||||
array(
|
||||
'action' => 'install-theme',
|
||||
'theme' => $theme->slug,
|
||||
), self_admin_url( 'update.php' )
|
||||
);
|
||||
|
||||
$update_url = add_query_arg( array(
|
||||
'action' => 'upgrade-theme',
|
||||
'theme' => $theme->slug,
|
||||
), self_admin_url( 'update.php' ) );
|
||||
$update_url = add_query_arg(
|
||||
array(
|
||||
'action' => 'upgrade-theme',
|
||||
'theme' => $theme->slug,
|
||||
), self_admin_url( 'update.php' )
|
||||
);
|
||||
|
||||
$status = $this->_get_theme_status( $theme );
|
||||
|
||||
|
@ -309,10 +327,10 @@ class WP_Theme_Install_List_Table extends WP_Themes_List_Table {
|
|||
|
||||
<div class="action-links">
|
||||
<ul>
|
||||
<?php foreach ( $actions as $action ): ?>
|
||||
<?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,48 +393,63 @@ 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 );
|
||||
$name = wp_kses( $theme->name, $themes_allowedtags );
|
||||
$author = wp_kses( $theme->author, $themes_allowedtags );
|
||||
|
||||
$install_url = add_query_arg( array(
|
||||
'action' => 'install-theme',
|
||||
'theme' => $theme->slug,
|
||||
), self_admin_url( 'update.php' ) );
|
||||
$install_url = add_query_arg(
|
||||
array(
|
||||
'action' => 'install-theme',
|
||||
'theme' => $theme->slug,
|
||||
), self_admin_url( 'update.php' )
|
||||
);
|
||||
|
||||
$update_url = add_query_arg( array(
|
||||
'action' => 'upgrade-theme',
|
||||
'theme' => $theme->slug,
|
||||
), self_admin_url( 'update.php' ) );
|
||||
$update_url = add_query_arg(
|
||||
array(
|
||||
'action' => 'upgrade-theme',
|
||||
'theme' => $theme->slug,
|
||||
), self_admin_url( 'update.php' )
|
||||
);
|
||||
|
||||
$status = $this->_get_theme_status( $theme );
|
||||
|
||||
?>
|
||||
<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>';
|
||||
break;
|
||||
case 'newer_installed':
|
||||
case 'latest_installed':
|
||||
echo '<span class="theme-install" title="' . esc_attr__( 'This theme is already installed and is up to date' ) . '">' . _x( 'Installed', 'theme' ) . '</span>';
|
||||
break;
|
||||
case 'install':
|
||||
default:
|
||||
echo '<a class="theme-install button button-primary" href="' . esc_url( wp_nonce_url( $install_url, 'install-theme_' . $theme->slug ) ) . '">' . __( 'Install' ) . '</a>';
|
||||
break;
|
||||
} ?>
|
||||
<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>';
|
||||
break;
|
||||
case 'newer_installed':
|
||||
case 'latest_installed':
|
||||
echo '<span class="theme-install" title="' . esc_attr__( 'This theme is already installed and is up to date' ) . '">' . _x( 'Installed', 'theme' ) . '</span>';
|
||||
break;
|
||||
case 'install':
|
||||
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 ) ): ?>
|
||||
<?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,12 +489,13 @@ 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;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
class WP_Themes_List_Table extends WP_List_Table {
|
||||
|
||||
protected $search_terms = array();
|
||||
public $features = array();
|
||||
public $features = array();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
@ -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(
|
||||
'ajax' => true,
|
||||
'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
|
||||
) );
|
||||
parent::__construct(
|
||||
array(
|
||||
'ajax' => true,
|
||||
'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function ajax_user_can() {
|
||||
|
@ -50,16 +51,19 @@ 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 ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,17 +71,19 @@ class WP_Themes_List_Table extends WP_List_Table {
|
|||
WP_Theme::sort_by_name( $themes );
|
||||
|
||||
$per_page = 36;
|
||||
$page = $this->get_pagenum();
|
||||
$page = $this->get_pagenum();
|
||||
|
||||
$start = ( $page - 1 ) * $per_page;
|
||||
|
||||
$this->items = array_slice( $themes, $start, $per_page, true );
|
||||
|
||||
$this->set_pagination_args( array(
|
||||
'total_items' => count( $themes ),
|
||||
'per_page' => $per_page,
|
||||
'infinite_scroll' => true,
|
||||
) );
|
||||
$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() {
|
||||
|
@ -166,18 +172,20 @@ class WP_Themes_List_Table extends WP_List_Table {
|
|||
public function display_rows() {
|
||||
$themes = $this->items;
|
||||
|
||||
foreach ( $themes as $theme ):
|
||||
?><div class="available-theme"><?php
|
||||
foreach ( $themes as $theme ) :
|
||||
?>
|
||||
<div class="available-theme">
|
||||
<?php
|
||||
|
||||
$template = $theme->get_template();
|
||||
$stylesheet = $theme->get_stylesheet();
|
||||
$title = $theme->display('Name');
|
||||
$version = $theme->display('Version');
|
||||
$author = $theme->display('Author');
|
||||
$title = $theme->display( 'Name' );
|
||||
$version = $theme->display( 'Version' );
|
||||
$author = $theme->display( 'Author' );
|
||||
|
||||
$activate_link = wp_nonce_url( "themes.php?action=activate&template=" . urlencode( $template ) . "&stylesheet=" . urlencode( $stylesheet ), 'switch-theme_' . $stylesheet );
|
||||
$activate_link = wp_nonce_url( 'themes.php?action=activate&template=' . urlencode( $template ) . '&stylesheet=' . urlencode( $stylesheet ), 'switch-theme_' . $stylesheet );
|
||||
|
||||
$actions = array();
|
||||
$actions = array();
|
||||
$actions['activate'] = '<a href="' . $activate_link . '" class="activatelink" title="'
|
||||
. esc_attr( sprintf( __( 'Activate “%s”' ), $title ) ) . '">' . __( 'Activate' ) . '</a>';
|
||||
|
||||
|
@ -186,13 +194,14 @@ 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&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' );
|
||||
$actions = apply_filters( 'theme_action_links', $actions, $theme, 'all' );
|
||||
|
||||
/** This filter is documented in wp-admin/includes/class-wp-ms-themes-list-table.php */
|
||||
$actions = apply_filters( "theme_action_links_$stylesheet", $actions, $theme, 'all' );
|
||||
|
@ -216,10 +225,10 @@ class WP_Themes_List_Table extends WP_List_Table {
|
|||
<div class="theme-author"><?php printf( __( 'By %s' ), $author ); ?></div>
|
||||
<div class="action-links">
|
||||
<ul>
|
||||
<?php foreach ( $actions as $action ): ?>
|
||||
<?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; ?>
|
||||
|
||||
|
@ -227,13 +236,17 @@ class WP_Themes_List_Table extends WP_List_Table {
|
|||
</div>
|
||||
|
||||
<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>',
|
||||
<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>',
|
||||
__( '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;
|
||||
}
|
||||
|
@ -287,14 +304,15 @@ class WP_Themes_List_Table extends WP_List_Table {
|
|||
$search_string = isset( $_REQUEST['s'] ) ? esc_attr( wp_unslash( $_REQUEST['s'] ) ) : '';
|
||||
|
||||
$args = array(
|
||||
'search' => $search_string,
|
||||
'features' => $this->features,
|
||||
'paged' => $this->get_pagenum(),
|
||||
'search' => $search_string,
|
||||
'features' => $this->features,
|
||||
'paged' => $this->get_pagenum(),
|
||||
'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();
|
||||
|
|
|
@ -25,25 +25,29 @@ class WP_Upgrader_Skin {
|
|||
* @since 2.8.0
|
||||
* @var string|bool|WP_Error
|
||||
*/
|
||||
public $result = false;
|
||||
public $result = false;
|
||||
public $options = array();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $args
|
||||
*/
|
||||
public function __construct($args = array()) {
|
||||
$defaults = array( 'url' => '', 'nonce' => '', 'title' => '', 'context' => false );
|
||||
$this->options = wp_parse_args($args, $defaults);
|
||||
public function __construct( $args = array() ) {
|
||||
$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) )
|
||||
public function set_upgrader( &$upgrader ) {
|
||||
if ( is_object( $upgrader ) ) {
|
||||
$this->upgrader =& $upgrader;
|
||||
}
|
||||
$this->add_strings();
|
||||
}
|
||||
|
||||
|
@ -84,8 +88,8 @@ class WP_Upgrader_Skin {
|
|||
if ( ! $context ) {
|
||||
$context = $this->options['context'];
|
||||
}
|
||||
if ( !empty($this->options['nonce']) ) {
|
||||
$url = wp_nonce_url($url, $this->options['nonce']);
|
||||
if ( ! empty( $this->options['nonce'] ) ) {
|
||||
$url = wp_nonce_url( $url, $this->options['nonce'] );
|
||||
}
|
||||
|
||||
$extra_fields = array();
|
||||
|
@ -115,44 +119,46 @@ class WP_Upgrader_Skin {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string|WP_Error $errors
|
||||
*/
|
||||
public function error($errors) {
|
||||
if ( ! $this->done_header )
|
||||
public function error( $errors ) {
|
||||
if ( ! $this->done_header ) {
|
||||
$this->header();
|
||||
if ( is_string($errors) ) {
|
||||
$this->feedback($errors);
|
||||
} elseif ( is_wp_error($errors) && $errors->get_error_code() ) {
|
||||
}
|
||||
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() ) )
|
||||
$this->feedback($message . ' ' . esc_html( strip_tags( $errors->get_error_data() ) ) );
|
||||
else
|
||||
$this->feedback($message);
|
||||
if ( $errors->get_error_data() && is_string( $errors->get_error_data() ) ) {
|
||||
$this->feedback( $message . ' ' . esc_html( strip_tags( $errors->get_error_data() ) ) );
|
||||
} else {
|
||||
$this->feedback( $message );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $string
|
||||
*/
|
||||
public function feedback($string) {
|
||||
if ( isset( $this->upgrader->strings[$string] ) )
|
||||
$string = $this->upgrader->strings[$string];
|
||||
public function feedback( $string ) {
|
||||
if ( isset( $this->upgrader->strings[ $string ] ) ) {
|
||||
$string = $this->upgrader->strings[ $string ];
|
||||
}
|
||||
|
||||
if ( strpos($string, '%') !== false ) {
|
||||
if ( strpos( $string, '%' ) !== false ) {
|
||||
$args = func_get_args();
|
||||
$args = array_splice($args, 1);
|
||||
$args = array_splice( $args, 1 );
|
||||
if ( $args ) {
|
||||
$args = array_map( 'strip_tags', $args );
|
||||
$args = array_map( 'esc_html', $args );
|
||||
$string = vsprintf($string, $args);
|
||||
$args = array_map( 'strip_tags', $args );
|
||||
$args = array_map( 'esc_html', $args );
|
||||
$string = vsprintf( $string, $args );
|
||||
}
|
||||
}
|
||||
if ( empty($string) )
|
||||
if ( empty( $string ) ) {
|
||||
return;
|
||||
show_message($string);
|
||||
}
|
||||
show_message( $string );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -120,10 +120,11 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -135,7 +136,7 @@ class WP_Upgrader {
|
|||
* @since 2.8.0
|
||||
*/
|
||||
public function init() {
|
||||
$this->skin->set_upgrader($this);
|
||||
$this->skin->set_upgrader( $this );
|
||||
$this->generic_strings();
|
||||
}
|
||||
|
||||
|
@ -145,26 +146,26 @@ class WP_Upgrader {
|
|||
* @since 2.8.0
|
||||
*/
|
||||
public function generic_strings() {
|
||||
$this->strings['bad_request'] = __('Invalid data provided.');
|
||||
$this->strings['fs_unavailable'] = __('Could not access filesystem.');
|
||||
$this->strings['fs_error'] = __('Filesystem error.');
|
||||
$this->strings['fs_no_root_dir'] = __('Unable to locate WordPress root directory.');
|
||||
$this->strings['fs_no_content_dir'] = __('Unable to locate WordPress content directory (wp-content).');
|
||||
$this->strings['fs_no_plugins_dir'] = __('Unable to locate WordPress plugin directory.');
|
||||
$this->strings['fs_no_themes_dir'] = __('Unable to locate WordPress theme directory.');
|
||||
$this->strings['bad_request'] = __( 'Invalid data provided.' );
|
||||
$this->strings['fs_unavailable'] = __( 'Could not access filesystem.' );
|
||||
$this->strings['fs_error'] = __( 'Filesystem error.' );
|
||||
$this->strings['fs_no_root_dir'] = __( 'Unable to locate WordPress root directory.' );
|
||||
$this->strings['fs_no_content_dir'] = __( 'Unable to locate WordPress content directory (wp-content).' );
|
||||
$this->strings['fs_no_plugins_dir'] = __( 'Unable to locate WordPress plugin directory.' );
|
||||
$this->strings['fs_no_themes_dir'] = __( 'Unable to locate WordPress theme directory.' );
|
||||
/* translators: %s: directory name */
|
||||
$this->strings['fs_no_folder'] = __('Unable to locate needed folder (%s).');
|
||||
$this->strings['fs_no_folder'] = __( 'Unable to locate needed folder (%s).' );
|
||||
|
||||
$this->strings['download_failed'] = __('Download failed.');
|
||||
$this->strings['installing_package'] = __('Installing the latest version…');
|
||||
$this->strings['no_files'] = __('The package contains no files.');
|
||||
$this->strings['folder_exists'] = __('Destination folder already exists.');
|
||||
$this->strings['mkdir_failed'] = __('Could not create directory.');
|
||||
$this->strings['incompatible_archive'] = __('The package could not be installed.');
|
||||
$this->strings['files_not_writable'] = __( 'The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.' );
|
||||
$this->strings['download_failed'] = __( 'Download failed.' );
|
||||
$this->strings['installing_package'] = __( 'Installing the latest version…' );
|
||||
$this->strings['no_files'] = __( 'The package contains no files.' );
|
||||
$this->strings['folder_exists'] = __( 'Destination folder already exists.' );
|
||||
$this->strings['mkdir_failed'] = __( 'Could not create directory.' );
|
||||
$this->strings['incompatible_archive'] = __( 'The package could not be installed.' );
|
||||
$this->strings['files_not_writable'] = __( 'The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.' );
|
||||
|
||||
$this->strings['maintenance_start'] = __('Enabling Maintenance mode…');
|
||||
$this->strings['maintenance_end'] = __('Disabling Maintenance mode…');
|
||||
$this->strings['maintenance_start'] = __( 'Enabling Maintenance mode…' );
|
||||
$this->strings['maintenance_end'] = __( 'Disabling Maintenance mode…' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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) )
|
||||
return new WP_Error('fs_unavailable', $this->strings['fs_unavailable'] );
|
||||
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() )
|
||||
return new WP_Error('fs_error', $this->strings['fs_error'], $wp_filesystem->errors);
|
||||
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 ) {
|
||||
foreach ( (array) $directories as $dir ) {
|
||||
switch ( $dir ) {
|
||||
case ABSPATH:
|
||||
if ( ! $wp_filesystem->abspath() )
|
||||
return new WP_Error('fs_no_root_dir', $this->strings['fs_no_root_dir']);
|
||||
if ( ! $wp_filesystem->abspath() ) {
|
||||
return new WP_Error( 'fs_no_root_dir', $this->strings['fs_no_root_dir'] );
|
||||
}
|
||||
break;
|
||||
case WP_CONTENT_DIR:
|
||||
if ( ! $wp_filesystem->wp_content_dir() )
|
||||
return new WP_Error('fs_no_content_dir', $this->strings['fs_no_content_dir']);
|
||||
if ( ! $wp_filesystem->wp_content_dir() ) {
|
||||
return new WP_Error( 'fs_no_content_dir', $this->strings['fs_no_content_dir'] );
|
||||
}
|
||||
break;
|
||||
case WP_PLUGIN_DIR:
|
||||
if ( ! $wp_filesystem->wp_plugins_dir() )
|
||||
return new WP_Error('fs_no_plugins_dir', $this->strings['fs_no_plugins_dir']);
|
||||
if ( ! $wp_filesystem->wp_plugins_dir() ) {
|
||||
return new WP_Error( 'fs_no_plugins_dir', $this->strings['fs_no_plugins_dir'] );
|
||||
}
|
||||
break;
|
||||
case get_theme_root():
|
||||
if ( ! $wp_filesystem->wp_themes_dir() )
|
||||
return new WP_Error('fs_no_themes_dir', $this->strings['fs_no_themes_dir']);
|
||||
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) )
|
||||
return new WP_Error('no_package', $this->strings['no_package']);
|
||||
if ( empty( $package ) ) {
|
||||
return new WP_Error( 'no_package', $this->strings['no_package'] );
|
||||
}
|
||||
|
||||
$this->skin->feedback('downloading_package', $package);
|
||||
$this->skin->feedback( 'downloading_package', $package );
|
||||
|
||||
$download_file = download_url($package);
|
||||
$download_file = download_url( $package );
|
||||
|
||||
if ( is_wp_error($download_file) )
|
||||
return new WP_Error('download_failed', $this->strings['download_failed'], $download_file->get_error_message());
|
||||
if ( is_wp_error( $download_file ) ) {
|
||||
return new WP_Error( 'download_failed', $this->strings['download_failed'], $download_file->get_error_message() );
|
||||
}
|
||||
|
||||
return $download_file;
|
||||
}
|
||||
|
@ -286,33 +299,36 @@ class WP_Upgrader {
|
|||
public function unpack_package( $package, $delete_package = true ) {
|
||||
global $wp_filesystem;
|
||||
|
||||
$this->skin->feedback('unpack_package');
|
||||
$this->skin->feedback( 'unpack_package' );
|
||||
|
||||
$upgrade_folder = $wp_filesystem->wp_content_dir() . 'upgrade/';
|
||||
|
||||
//Clean up contents of upgrade directory beforehand.
|
||||
$upgrade_files = $wp_filesystem->dirlist($upgrade_folder);
|
||||
if ( !empty($upgrade_files) ) {
|
||||
foreach ( $upgrade_files as $file )
|
||||
$wp_filesystem->delete($upgrade_folder . $file['name'], true);
|
||||
$upgrade_files = $wp_filesystem->dirlist( $upgrade_folder );
|
||||
if ( ! empty( $upgrade_files ) ) {
|
||||
foreach ( $upgrade_files as $file ) {
|
||||
$wp_filesystem->delete( $upgrade_folder . $file['name'], true );
|
||||
}
|
||||
}
|
||||
|
||||
// We need a working directory - Strip off any .tmp or .zip suffixes
|
||||
$working_dir = $upgrade_folder . basename( basename( $package, '.tmp' ), '.zip' );
|
||||
|
||||
// Clean up working directory
|
||||
if ( $wp_filesystem->is_dir($working_dir) )
|
||||
$wp_filesystem->delete($working_dir, true);
|
||||
if ( $wp_filesystem->is_dir( $working_dir ) ) {
|
||||
$wp_filesystem->delete( $working_dir, true );
|
||||
}
|
||||
|
||||
// Unzip package to working directory
|
||||
$result = unzip_file( $package, $working_dir );
|
||||
|
||||
// Once extracted, delete the package if required.
|
||||
if ( $delete_package )
|
||||
unlink($package);
|
||||
if ( $delete_package ) {
|
||||
unlink( $package );
|
||||
}
|
||||
|
||||
if ( is_wp_error($result) ) {
|
||||
$wp_filesystem->delete($working_dir, true);
|
||||
if ( is_wp_error( $result ) ) {
|
||||
$wp_filesystem->delete( $working_dir, true );
|
||||
if ( 'incompatible_archive' == $result->get_error_code() ) {
|
||||
return new WP_Error( 'incompatible_archive', $this->strings['incompatible_archive'], $result->get_error_data() );
|
||||
}
|
||||
|
@ -432,19 +448,19 @@ class WP_Upgrader {
|
|||
global $wp_filesystem, $wp_theme_directories;
|
||||
|
||||
$defaults = array(
|
||||
'source' => '', // Please always pass this
|
||||
'destination' => '', // and this
|
||||
'clear_destination' => false,
|
||||
'clear_working' => false,
|
||||
'source' => '', // Please always pass this
|
||||
'destination' => '', // and this
|
||||
'clear_destination' => false,
|
||||
'clear_working' => false,
|
||||
'abort_if_destination_exists' => true,
|
||||
'hook_extra' => array()
|
||||
'hook_extra' => array(),
|
||||
);
|
||||
|
||||
$args = wp_parse_args($args, $defaults);
|
||||
$args = wp_parse_args( $args, $defaults );
|
||||
|
||||
// These were previously extract()'d.
|
||||
$source = $args['source'];
|
||||
$destination = $args['destination'];
|
||||
$source = $args['source'];
|
||||
$destination = $args['destination'];
|
||||
$clear_destination = $args['clear_destination'];
|
||||
|
||||
@set_time_limit( 300 );
|
||||
|
@ -473,10 +489,10 @@ class WP_Upgrader {
|
|||
}
|
||||
|
||||
//Retain the Original source and destinations
|
||||
$remote_source = $args['source'];
|
||||
$remote_source = $args['source'];
|
||||
$local_destination = $destination;
|
||||
|
||||
$source_files = array_keys( $wp_filesystem->dirlist( $remote_source ) );
|
||||
$source_files = array_keys( $wp_filesystem->dirlist( $remote_source ) );
|
||||
$remote_destination = $wp_filesystem->find_folder( $local_destination );
|
||||
|
||||
//Locate which directory to copy to the new folder, This is based on the actual folder holding the files.
|
||||
|
@ -525,12 +541,12 @@ class WP_Upgrader {
|
|||
|
||||
if ( in_array( $destination, $protected_directories ) ) {
|
||||
$remote_destination = trailingslashit( $remote_destination ) . trailingslashit( basename( $source ) );
|
||||
$destination = trailingslashit( $destination ) . trailingslashit( basename( $source ) );
|
||||
$destination = trailingslashit( $destination ) . trailingslashit( basename( $source ) );
|
||||
}
|
||||
|
||||
if ( $clear_destination ) {
|
||||
// We're going to clear the destination if there's something there.
|
||||
$this->skin->feedback('remove_old');
|
||||
$this->skin->feedback( 'remove_old' );
|
||||
|
||||
$removed = $this->clear_destination( $remote_destination );
|
||||
|
||||
|
@ -549,13 +565,13 @@ class WP_Upgrader {
|
|||
if ( is_wp_error( $removed ) ) {
|
||||
return $removed;
|
||||
}
|
||||
} elseif ( $args['abort_if_destination_exists'] && $wp_filesystem->exists($remote_destination) ) {
|
||||
} elseif ( $args['abort_if_destination_exists'] && $wp_filesystem->exists( $remote_destination ) ) {
|
||||
//If we're not clearing the destination folder and something exists there already, Bail.
|
||||
//But first check to see if there are actually any files in the folder.
|
||||
$_files = $wp_filesystem->dirlist($remote_destination);
|
||||
if ( ! empty($_files) ) {
|
||||
$wp_filesystem->delete($remote_source, true); //Clear out the source files.
|
||||
return new WP_Error('folder_exists', $this->strings['folder_exists'], $remote_destination );
|
||||
$_files = $wp_filesystem->dirlist( $remote_destination );
|
||||
if ( ! empty( $_files ) ) {
|
||||
$wp_filesystem->delete( $remote_source, true ); //Clear out the source files.
|
||||
return new WP_Error( 'folder_exists', $this->strings['folder_exists'], $remote_destination );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -566,8 +582,8 @@ class WP_Upgrader {
|
|||
}
|
||||
}
|
||||
// Copy new version of item into place.
|
||||
$result = copy_dir($source, $remote_destination);
|
||||
if ( is_wp_error($result) ) {
|
||||
$result = copy_dir( $source, $remote_destination );
|
||||
if ( is_wp_error( $result ) ) {
|
||||
if ( $args['clear_working'] ) {
|
||||
$wp_filesystem->delete( $remote_source, true );
|
||||
}
|
||||
|
@ -579,7 +595,7 @@ class WP_Upgrader {
|
|||
$wp_filesystem->delete( $remote_source, true );
|
||||
}
|
||||
|
||||
$destination_name = basename( str_replace($local_destination, '', $destination) );
|
||||
$destination_name = basename( str_replace( $local_destination, '', $destination ) );
|
||||
if ( '.' == $destination_name ) {
|
||||
$destination_name = '';
|
||||
}
|
||||
|
@ -597,7 +613,7 @@ class WP_Upgrader {
|
|||
*/
|
||||
$res = apply_filters( 'upgrader_post_install', true, $args['hook_extra'], $this->result );
|
||||
|
||||
if ( is_wp_error($res) ) {
|
||||
if ( is_wp_error( $res ) ) {
|
||||
$this->result = $res;
|
||||
return $res;
|
||||
}
|
||||
|
@ -642,13 +658,13 @@ class WP_Upgrader {
|
|||
public function run( $options ) {
|
||||
|
||||
$defaults = array(
|
||||
'package' => '', // Please always pass this.
|
||||
'destination' => '', // And this
|
||||
'clear_destination' => false,
|
||||
'package' => '', // Please always pass this.
|
||||
'destination' => '', // And this
|
||||
'clear_destination' => false,
|
||||
'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.
|
||||
'clear_working' => true,
|
||||
'is_multi' => false,
|
||||
'hook_extra' => array(), // Pass any extra $hook_extra args here, this will be passed to any hooked filters.
|
||||
);
|
||||
|
||||
$options = wp_parse_args( $options, $defaults );
|
||||
|
@ -701,8 +717,8 @@ class WP_Upgrader {
|
|||
|
||||
$this->skin->before();
|
||||
|
||||
if ( is_wp_error($res) ) {
|
||||
$this->skin->error($res);
|
||||
if ( is_wp_error( $res ) ) {
|
||||
$this->skin->error( $res );
|
||||
$this->skin->after();
|
||||
if ( ! $options['is_multi'] ) {
|
||||
$this->skin->footer();
|
||||
|
@ -715,8 +731,8 @@ class WP_Upgrader {
|
|||
* of the file if the package is a local file)
|
||||
*/
|
||||
$download = $this->download_package( $options['package'] );
|
||||
if ( is_wp_error($download) ) {
|
||||
$this->skin->error($download);
|
||||
if ( is_wp_error( $download ) ) {
|
||||
$this->skin->error( $download );
|
||||
$this->skin->after();
|
||||
if ( ! $options['is_multi'] ) {
|
||||
$this->skin->footer();
|
||||
|
@ -728,8 +744,8 @@ class WP_Upgrader {
|
|||
|
||||
// Unzips the file into a temporary directory.
|
||||
$working_dir = $this->unpack_package( $download, $delete_package );
|
||||
if ( is_wp_error($working_dir) ) {
|
||||
$this->skin->error($working_dir);
|
||||
if ( is_wp_error( $working_dir ) ) {
|
||||
$this->skin->error( $working_dir );
|
||||
$this->skin->after();
|
||||
if ( ! $options['is_multi'] ) {
|
||||
$this->skin->footer();
|
||||
|
@ -738,22 +754,24 @@ class WP_Upgrader {
|
|||
}
|
||||
|
||||
// With the given options, this installs it to the destination directory.
|
||||
$result = $this->install_package( array(
|
||||
'source' => $working_dir,
|
||||
'destination' => $options['destination'],
|
||||
'clear_destination' => $options['clear_destination'],
|
||||
'abort_if_destination_exists' => $options['abort_if_destination_exists'],
|
||||
'clear_working' => $options['clear_working'],
|
||||
'hook_extra' => $options['hook_extra']
|
||||
) );
|
||||
$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'],
|
||||
)
|
||||
);
|
||||
|
||||
$this->skin->set_result($result);
|
||||
if ( is_wp_error($result) ) {
|
||||
$this->skin->error($result);
|
||||
$this->skin->feedback('process_failed');
|
||||
$this->skin->set_result( $result );
|
||||
if ( is_wp_error( $result ) ) {
|
||||
$this->skin->error( $result );
|
||||
$this->skin->feedback( 'process_failed' );
|
||||
} else {
|
||||
// Installation succeeded.
|
||||
$this->skin->feedback('process_success');
|
||||
$this->skin->feedback( 'process_success' );
|
||||
}
|
||||
|
||||
$this->skin->after();
|
||||
|
@ -813,28 +831,28 @@ class WP_Upgrader {
|
|||
global $wp_filesystem;
|
||||
$file = $wp_filesystem->abspath() . '.maintenance';
|
||||
if ( $enable ) {
|
||||
$this->skin->feedback('maintenance_start');
|
||||
$this->skin->feedback( 'maintenance_start' );
|
||||
// Create maintenance file to signal that we are upgrading
|
||||
$maintenance_string = '<?php $upgrading = ' . time() . '; ?>';
|
||||
$wp_filesystem->delete($file);
|
||||
$wp_filesystem->put_contents($file, $maintenance_string, FS_CHMOD_FILE);
|
||||
$wp_filesystem->delete( $file );
|
||||
$wp_filesystem->put_contents( $file, $maintenance_string, FS_CHMOD_FILE );
|
||||
} elseif ( ! $enable && $wp_filesystem->exists( $file ) ) {
|
||||
$this->skin->feedback('maintenance_end');
|
||||
$wp_filesystem->delete($file);
|
||||
$this->skin->feedback( 'maintenance_end' );
|
||||
$wp_filesystem->delete( $file );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a lock using WordPress options.
|
||||
*
|
||||
* @since 4.5.0
|
||||
* @static
|
||||
*
|
||||
* @param string $lock_name The name of this unique lock.
|
||||
* @param int $release_timeout Optional. The duration in seconds to respect an existing lock.
|
||||
* Creates a lock using WordPress options.
|
||||
*
|
||||
* @since 4.5.0
|
||||
* @static
|
||||
*
|
||||
* @param string $lock_name The name of this unique lock.
|
||||
* @param int $release_timeout Optional. The duration in seconds to respect an existing lock.
|
||||
* Default: 1 hour.
|
||||
* @return bool False if a lock couldn't be created or if the lock is still valid. True otherwise.
|
||||
*/
|
||||
* @return bool False if a lock couldn't be created or if the lock is still valid. True otherwise.
|
||||
*/
|
||||
public static function create_lock( $lock_name, $release_timeout = null ) {
|
||||
global $wpdb;
|
||||
if ( ! $release_timeout ) {
|
||||
|
@ -871,16 +889,16 @@ class WP_Upgrader {
|
|||
}
|
||||
|
||||
/**
|
||||
* Releases an upgrader lock.
|
||||
*
|
||||
* @since 4.5.0
|
||||
* @static
|
||||
* Releases an upgrader lock.
|
||||
*
|
||||
* @since 4.5.0
|
||||
* @static
|
||||
*
|
||||
* @see WP_Upgrader::create_lock()
|
||||
*
|
||||
* @param string $lock_name The name of this unique lock.
|
||||
*
|
||||
* @param string $lock_name The name of this unique lock.
|
||||
* @return bool True if the lock was successfully released. False on failure.
|
||||
*/
|
||||
*/
|
||||
public static function release_lock( $lock_name ) {
|
||||
return delete_option( $lock_name . '.lock' );
|
||||
}
|
||||
|
|
|
@ -43,30 +43,34 @@ 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(
|
||||
'singular' => 'user',
|
||||
'plural' => 'users',
|
||||
'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
|
||||
) );
|
||||
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.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @since 3.1.0
|
||||
*
|
||||
* @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' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -84,40 +88,44 @@ class WP_Users_List_Table extends WP_List_Table {
|
|||
|
||||
$role = isset( $_REQUEST['role'] ) ? $_REQUEST['role'] : '';
|
||||
|
||||
$per_page = ( $this->is_site_users ) ? 'site_users_network_per_page' : 'users_per_page';
|
||||
$per_page = ( $this->is_site_users ) ? 'site_users_network_per_page' : 'users_per_page';
|
||||
$users_per_page = $this->get_items_per_page( $per_page );
|
||||
|
||||
$paged = $this->get_pagenum();
|
||||
|
||||
if ( 'none' === $role ) {
|
||||
$args = array(
|
||||
'number' => $users_per_page,
|
||||
'offset' => ( $paged-1 ) * $users_per_page,
|
||||
'number' => $users_per_page,
|
||||
'offset' => ( $paged - 1 ) * $users_per_page,
|
||||
'include' => wp_get_users_with_no_role( $this->site_id ),
|
||||
'search' => $usersearch,
|
||||
'fields' => 'all_with_meta'
|
||||
'search' => $usersearch,
|
||||
'fields' => 'all_with_meta',
|
||||
);
|
||||
} else {
|
||||
$args = array(
|
||||
'number' => $users_per_page,
|
||||
'offset' => ( $paged-1 ) * $users_per_page,
|
||||
'role' => $role,
|
||||
'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(
|
||||
'total_items' => $wp_user_search->get_total(),
|
||||
'per_page' => $users_per_page,
|
||||
) );
|
||||
$this->set_pagination_args(
|
||||
array(
|
||||
'total_items' => $wp_user_search->get_total(),
|
||||
'per_page' => $users_per_page,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -173,21 +183,22 @@ class WP_Users_List_Table extends WP_List_Table {
|
|||
$users_of_blog = count_users( 'time', $this->site_id );
|
||||
restore_current_blog();
|
||||
} else {
|
||||
$url = 'users.php';
|
||||
$url = 'users.php';
|
||||
$users_of_blog = count_users();
|
||||
}
|
||||
|
||||
$total_users = $users_of_blog['total_users'];
|
||||
$avail_roles =& $users_of_blog['avail_roles'];
|
||||
unset($users_of_blog);
|
||||
unset( $users_of_blog );
|
||||
|
||||
$current_link_attributes = empty( $role ) ? ' class="current" aria-current="page"' : '';
|
||||
|
||||
$role_links = array();
|
||||
$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 = '';
|
||||
|
||||
|
@ -197,11 +208,11 @@ class WP_Users_List_Table extends WP_List_Table {
|
|||
|
||||
$name = translate_user_role( $name );
|
||||
/* translators: User role name with count */
|
||||
$name = sprintf( __('%1$s <span class="count">(%2$s)</span>'), $name, number_format_i18n( $avail_roles[$this_role] ) );
|
||||
$role_links[$this_role] = "<a href='" . esc_url( add_query_arg( 'role', $this_role, $url ) ) . "'$current_link_attributes>$name</a>";
|
||||
$name = sprintf( __( '%1$s <span class="count">(%2$s)</span>' ), $name, number_format_i18n( $avail_roles[ $this_role ] ) );
|
||||
$role_links[ $this_role ] = "<a href='" . esc_url( add_query_arg( 'role', $this_role, $url ) ) . "'$current_link_attributes>$name</a>";
|
||||
}
|
||||
|
||||
if ( ! empty( $avail_roles['none' ] ) ) {
|
||||
if ( ! empty( $avail_roles['none'] ) ) {
|
||||
|
||||
$current_link_attributes = '';
|
||||
|
||||
|
@ -211,7 +222,7 @@ class WP_Users_List_Table extends WP_List_Table {
|
|||
|
||||
$name = __( 'No role' );
|
||||
/* translators: User role name with count */
|
||||
$name = sprintf( __('%1$s <span class="count">(%2$s)</span>'), $name, number_format_i18n( $avail_roles['none' ] ) );
|
||||
$name = sprintf( __( '%1$s <span class="count">(%2$s)</span>' ), $name, number_format_i18n( $avail_roles['none'] ) );
|
||||
$role_links['none'] = "<a href='" . esc_url( add_query_arg( 'role', 'none', $url ) ) . "'$current_link_attributes>$name</a>";
|
||||
|
||||
}
|
||||
|
@ -230,11 +241,13 @@ 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;
|
||||
|
@ -249,14 +262,14 @@ class WP_Users_List_Table extends WP_List_Table {
|
|||
* or below the table ("bottom").
|
||||
*/
|
||||
protected function extra_tablenav( $which ) {
|
||||
$id = 'bottom' === $which ? 'new_role2' : 'new_role';
|
||||
$id = 'bottom' === $which ? 'new_role2' : 'new_role';
|
||||
$button_id = 'bottom' === $which ? 'changeit2' : 'changeit';
|
||||
?>
|
||||
<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…' ) ?></label>
|
||||
<select name="<?php echo $id ?>" id="<?php echo $id ?>">
|
||||
<option value=""><?php _e( 'Change role to…' ) ?></option>
|
||||
<label class="screen-reader-text" for="<?php echo $id; ?>"><?php _e( 'Change role to…' ); ?></label>
|
||||
<select name="<?php echo $id; ?>" id="<?php echo $id; ?>">
|
||||
<option value=""><?php _e( 'Change role to…' ); ?></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 );
|
||||
|
@ -380,18 +395,19 @@ class WP_Users_List_Table extends WP_List_Table {
|
|||
$user_object = get_userdata( (int) $user_object );
|
||||
}
|
||||
$user_object->filter = 'display';
|
||||
$email = $user_object->user_email;
|
||||
$email = $user_object->user_email;
|
||||
|
||||
if ( $this->is_site_users )
|
||||
if ( $this->is_site_users ) {
|
||||
$url = "site-users.php?id={$this->site_id}&";
|
||||
else
|
||||
} else {
|
||||
$url = 'users.php?';
|
||||
}
|
||||
|
||||
$user_roles = $this->get_role_list( $user_object );
|
||||
|
||||
// Set up the hover actions for this user
|
||||
$actions = array();
|
||||
$checkbox = '';
|
||||
$actions = array();
|
||||
$checkbox = '';
|
||||
$super_admin = '';
|
||||
|
||||
if ( is_multisite() && current_user_can( 'manage_network_users' ) ) {
|
||||
|
@ -405,17 +421,19 @@ class WP_Users_List_Table extends WP_List_Table {
|
|||
// Set up the user editing link
|
||||
$edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user_object->ID ) ) );
|
||||
|
||||
if ( current_user_can( 'edit_user', $user_object->ID ) ) {
|
||||
$edit = "<strong><a href=\"{$edit_link}\">{$user_object->user_login}</a>{$super_admin}</strong><br />";
|
||||
if ( current_user_can( 'edit_user', $user_object->ID ) ) {
|
||||
$edit = "<strong><a href=\"{$edit_link}\">{$user_object->user_login}</a>{$super_admin}</strong><br />";
|
||||
$actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
|
||||
} else {
|
||||
$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&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&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&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&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>';
|
||||
|
|
|
@ -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,40 +48,47 @@ 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'] ) )
|
||||
wp_die ( __( 'Sorry, you are not allowed to edit comments on this post.' ) );
|
||||
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] ) {
|
||||
foreach ( array( 'aa', 'mm', 'jj', 'hh', 'mn' ) as $timeunit ) {
|
||||
if ( ! empty( $_POST[ 'hidden_' . $timeunit ] ) && $_POST[ 'hidden_' . $timeunit ] != $_POST[ $timeunit ] ) {
|
||||
$_POST['edit_date'] = '1';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !empty ( $_POST['edit_date'] ) ) {
|
||||
$aa = $_POST['aa'];
|
||||
$mm = $_POST['mm'];
|
||||
$jj = $_POST['jj'];
|
||||
$hh = $_POST['hh'];
|
||||
$mn = $_POST['mn'];
|
||||
$ss = $_POST['ss'];
|
||||
$jj = ($jj > 31 ) ? 31 : $jj;
|
||||
$hh = ($hh > 23 ) ? $hh -24 : $hh;
|
||||
$mn = ($mn > 59 ) ? $mn -60 : $mn;
|
||||
$ss = ($ss > 59 ) ? $ss -60 : $ss;
|
||||
if ( ! empty( $_POST['edit_date'] ) ) {
|
||||
$aa = $_POST['aa'];
|
||||
$mm = $_POST['mm'];
|
||||
$jj = $_POST['jj'];
|
||||
$hh = $_POST['hh'];
|
||||
$mn = $_POST['mn'];
|
||||
$ss = $_POST['ss'];
|
||||
$jj = ( $jj > 31 ) ? 31 : $jj;
|
||||
$hh = ( $hh > 23 ) ? $hh - 24 : $hh;
|
||||
$mn = ( $mn > 59 ) ? $mn - 60 : $mn;
|
||||
$ss = ( $ss > 59 ) ? $ss - 60 : $ss;
|
||||
$_POST['comment_date'] = "$aa-$mm-$jj $hh:$mn:$ss";
|
||||
}
|
||||
|
||||
|
@ -94,10 +104,11 @@ 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_ID = (int) $comment->comment_ID;
|
||||
$comment->comment_post_ID = (int) $comment->comment_post_ID;
|
||||
|
||||
$comment->comment_content = format_to_edit( $comment->comment_content );
|
||||
|
@ -110,10 +121,10 @@ function get_comment_to_edit( $id ) {
|
|||
*/
|
||||
$comment->comment_content = apply_filters( 'comment_edit_pre', $comment->comment_content );
|
||||
|
||||
$comment->comment_author = format_to_edit( $comment->comment_author );
|
||||
$comment->comment_author = format_to_edit( $comment->comment_author );
|
||||
$comment->comment_author_email = format_to_edit( $comment->comment_author_email );
|
||||
$comment->comment_author_url = format_to_edit( $comment->comment_author_url );
|
||||
$comment->comment_author_url = esc_url($comment->comment_author_url);
|
||||
$comment->comment_author_url = format_to_edit( $comment->comment_author_url );
|
||||
$comment->comment_author_url = esc_url( $comment->comment_author_url );
|
||||
|
||||
return $comment;
|
||||
}
|
||||
|
@ -132,33 +143,37 @@ function get_pending_comments_num( $post_id ) {
|
|||
global $wpdb;
|
||||
|
||||
$single = false;
|
||||
if ( !is_array($post_id) ) {
|
||||
if ( ! is_array( $post_id ) ) {
|
||||
$post_id_array = (array) $post_id;
|
||||
$single = true;
|
||||
$single = true;
|
||||
} else {
|
||||
$post_id_array = $post_id;
|
||||
}
|
||||
$post_id_array = array_map('intval', $post_id_array);
|
||||
$post_id_in = "'" . implode("', '", $post_id_array) . "'";
|
||||
$post_id_array = array_map( 'intval', $post_id_array );
|
||||
$post_id_in = "'" . implode( "', '", $post_id_array ) . "'";
|
||||
|
||||
$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
|
||||
return absint($pending[0]['num_comments']);
|
||||
} 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 )
|
||||
$pending_keyed[$id] = 0;
|
||||
foreach ( $post_id_array as $id ) {
|
||||
$pending_keyed[ $id ] = 0;
|
||||
}
|
||||
|
||||
if ( !empty($pending) )
|
||||
foreach ( $pending as $pend )
|
||||
$pending_keyed[$pend['comment_post_ID']] = absint($pend['num_comments']);
|
||||
if ( ! empty( $pending ) ) {
|
||||
foreach ( $pending as $pend ) {
|
||||
$pending_keyed[ $pend['comment_post_ID'] ] = absint( $pend['num_comments'] );
|
||||
}
|
||||
}
|
||||
|
||||
return $pending_keyed;
|
||||
}
|
||||
|
@ -180,8 +195,9 @@ 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' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -193,4 +209,4 @@ function comment_footer_die( $msg ) {
|
|||
echo "<div class='wrap'><p>$msg</p></div>";
|
||||
include( ABSPATH . 'wp-admin/admin-footer.php' );
|
||||
die;
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -26,7 +26,7 @@ function wp_credits() {
|
|||
|| false !== strpos( $wp_version, '-' )
|
||||
|| ( isset( $results['data']['version'] ) && strpos( $wp_version, $results['data']['version'] ) !== 0 )
|
||||
) {
|
||||
$url = "http://api.wordpress.org/core/credits/1.1/?version={$wp_version}&locale={$locale}";
|
||||
$url = "http://api.wordpress.org/core/credits/1.1/?version={$wp_version}&locale={$locale}";
|
||||
$options = array( 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ) );
|
||||
|
||||
if ( wp_http_supports( array( 'ssl' ) ) ) {
|
||||
|
@ -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 );
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
function wp_dashboard_setup() {
|
||||
global $wp_registered_widgets, $wp_registered_widget_controls, $wp_dashboard_control_callbacks;
|
||||
$wp_dashboard_control_callbacks = array();
|
||||
$screen = get_current_screen();
|
||||
$screen = get_current_screen();
|
||||
|
||||
/* Register Widgets and Controls */
|
||||
|
||||
|
@ -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() ) {
|
||||
|
@ -109,11 +112,11 @@ function wp_dashboard_setup() {
|
|||
}
|
||||
|
||||
foreach ( $dashboard_widgets as $widget_id ) {
|
||||
$name = empty( $wp_registered_widgets[$widget_id]['all_link'] ) ? $wp_registered_widgets[$widget_id]['name'] : $wp_registered_widgets[$widget_id]['name'] . " <a href='{$wp_registered_widgets[$widget_id]['all_link']}' class='edit-box open-box'>" . __('View all') . '</a>';
|
||||
wp_add_dashboard_widget( $widget_id, $name, $wp_registered_widgets[$widget_id]['callback'], $wp_registered_widget_controls[$widget_id]['callback'] );
|
||||
$name = empty( $wp_registered_widgets[ $widget_id ]['all_link'] ) ? $wp_registered_widgets[ $widget_id ]['name'] : $wp_registered_widgets[ $widget_id ]['name'] . " <a href='{$wp_registered_widgets[$widget_id]['all_link']}' class='edit-box open-box'>" . __( 'View all' ) . '</a>';
|
||||
wp_add_dashboard_widget( $widget_id, $name, $wp_registered_widgets[ $widget_id ]['callback'], $wp_registered_widget_controls[ $widget_id ]['callback'] );
|
||||
}
|
||||
|
||||
if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget_id']) ) {
|
||||
if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset( $_POST['widget_id'] ) ) {
|
||||
check_admin_referer( 'edit-dashboard-widget_' . $_POST['widget_id'], 'dashboard-widget-nonce' );
|
||||
ob_start(); // hack - but the same hack wp-admin/widgets.php uses
|
||||
wp_dashboard_trigger_widget_control( $_POST['widget_id'] );
|
||||
|
@ -152,18 +155,18 @@ function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_
|
|||
|
||||
if ( is_null( $callback_args ) ) {
|
||||
$callback_args = $private_callback_args;
|
||||
} else if ( is_array( $callback_args ) ) {
|
||||
} elseif ( is_array( $callback_args ) ) {
|
||||
$callback_args = array_merge( $callback_args, $private_callback_args );
|
||||
}
|
||||
|
||||
if ( $control_callback && current_user_can( 'edit_dashboard' ) && is_callable( $control_callback ) ) {
|
||||
$wp_dashboard_control_callbacks[$widget_id] = $control_callback;
|
||||
$wp_dashboard_control_callbacks[ $widget_id ] = $control_callback;
|
||||
if ( isset( $_GET['edit'] ) && $widget_id == $_GET['edit'] ) {
|
||||
list($url) = explode( '#', add_query_arg( 'edit', false ), 2 );
|
||||
list($url) = explode( '#', add_query_arg( 'edit', false ), 2 );
|
||||
$widget_name .= ' <span class="postbox-title-action"><a href="' . esc_url( $url ) . '">' . __( 'Cancel' ) . '</a></span>';
|
||||
$callback = '_wp_dashboard_control_callback';
|
||||
$callback = '_wp_dashboard_control_callback';
|
||||
} else {
|
||||
list($url) = explode( '#', add_query_arg( 'edit', $widget_id ), 2 );
|
||||
list($url) = explode( '#', add_query_arg( 'edit', $widget_id ), 2 );
|
||||
$widget_name .= ' <span class="postbox-title-action"><a href="' . esc_url( "$url#$widget_id" ) . '" class="edit-box open-box">' . __( 'Configure' ) . '</a></span>';
|
||||
}
|
||||
}
|
||||
|
@ -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 );
|
||||
}
|
||||
|
@ -194,8 +199,8 @@ function _wp_dashboard_control_callback( $dashboard, $meta_box ) {
|
|||
echo '<form method="post" class="dashboard-widget-control-form wp-clearfix">';
|
||||
wp_dashboard_trigger_widget_control( $meta_box['id'] );
|
||||
wp_nonce_field( 'edit-dashboard-widget_' . $meta_box['id'], 'dashboard-widget-nonce' );
|
||||
echo '<input type="hidden" name="widget_id" value="' . esc_attr($meta_box['id']) . '" />';
|
||||
submit_button( __('Submit') );
|
||||
echo '<input type="hidden" name="widget_id" value="' . esc_attr( $meta_box['id'] ) . '" />';
|
||||
submit_button( __( 'Submit' ) );
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
|
@ -205,8 +210,8 @@ function _wp_dashboard_control_callback( $dashboard, $meta_box ) {
|
|||
* @since 2.5.0
|
||||
*/
|
||||
function wp_dashboard() {
|
||||
$screen = get_current_screen();
|
||||
$columns = absint( $screen->get_columns() );
|
||||
$screen = get_current_screen();
|
||||
$columns = absint( $screen->get_columns() );
|
||||
$columns_css = '';
|
||||
if ( $columns ) {
|
||||
$columns_css = " columns-$columns";
|
||||
|
@ -259,14 +264,13 @@ function wp_dashboard_right_now() {
|
|||
} else {
|
||||
$text = _n( '%s Page', '%s Pages', $num_posts->publish );
|
||||
}
|
||||
$text = sprintf( $text, number_format_i18n( $num_posts->publish ) );
|
||||
$text = sprintf( $text, number_format_i18n( $num_posts->publish ) );
|
||||
$post_type_object = get_post_type_object( $post_type );
|
||||
if ( $post_type_object && current_user_can( $post_type_object->cap->edit_posts ) ) {
|
||||
printf( '<li class="%1$s-count"><a href="edit.php?post_type=%1$s">%2$s</a></li>', $post_type, $text );
|
||||
} 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
|
||||
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>
|
||||
<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>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
@ -338,7 +344,7 @@ function wp_dashboard_right_now() {
|
|||
*
|
||||
* @param string $content Default text.
|
||||
*/
|
||||
$content = apply_filters( 'privacy_on_link_text' , __( 'Search Engines Discouraged' ) );
|
||||
$content = apply_filters( 'privacy_on_link_text', __( 'Search Engines Discouraged' ) );
|
||||
$title_attr = '' === $title ? '' : " title='$title'";
|
||||
|
||||
echo "<p><a href='options-reading.php'$title_attr>$content</a></p>";
|
||||
|
@ -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') )
|
||||
$actions['create-site'] = '<a href="' . network_admin_url('site-new.php') . '">' . __( 'Create a New Site' ) . '</a>';
|
||||
if ( current_user_can('create_users') )
|
||||
$actions['create-user'] = '<a href="' . network_admin_url('user-new.php') . '">' . __( 'Create a New User' ) . '</a>';
|
||||
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' ) ) {
|
||||
$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();
|
||||
|
@ -426,7 +436,7 @@ function wp_network_dashboard_right_now() {
|
|||
do_action( 'wpmuadminresult', '' );
|
||||
?>
|
||||
|
||||
<form action="<?php echo network_admin_url('users.php'); ?>" method="get">
|
||||
<form action="<?php echo network_admin_url( 'users.php' ); ?>" method="get">
|
||||
<p>
|
||||
<label class="screen-reader-text" for="search-users"><?php _e( 'Search Users' ); ?></label>
|
||||
<input type="search" name="s" value="" size="30" autocomplete="off" id="search-users"/>
|
||||
|
@ -434,7 +444,7 @@ function wp_network_dashboard_right_now() {
|
|||
</p>
|
||||
</form>
|
||||
|
||||
<form action="<?php echo network_admin_url('sites.php'); ?>" method="get">
|
||||
<form action="<?php echo network_admin_url( 'sites.php' ); ?>" method="get">
|
||||
<p>
|
||||
<label class="screen-reader-text" for="search-sites"><?php _e( 'Search Sites' ); ?></label>
|
||||
<input type="search" name="s" value="" size="30" autocomplete="off" id="search-sites"/>
|
||||
|
@ -484,11 +494,12 @@ function wp_dashboard_quick_press( $error_msg = false ) {
|
|||
$post->post_title = ''; // Remove the auto draft title
|
||||
}
|
||||
} else {
|
||||
$post = get_default_post_to_edit( 'post' , true);
|
||||
$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',
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -560,18 +571,18 @@ function wp_dashboard_recent_drafts( $drafts = false ) {
|
|||
$drafts = get_posts( $query_args );
|
||||
if ( ! $drafts ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo '<div class="drafts">';
|
||||
if ( count( $drafts ) > 3 ) {
|
||||
echo '<p class="view-all"><a href="' . esc_url( admin_url( 'edit.php?post_status=draft' ) ) . '">' . __( 'View all drafts' ) . "</a></p>\n";
|
||||
}
|
||||
}
|
||||
echo '<h2 class="hide-if-no-js">' . __( 'Your Recent Drafts' ) . "</h2>\n<ul>";
|
||||
|
||||
$drafts = array_slice( $drafts, 0, 3 );
|
||||
foreach ( $drafts as $draft ) {
|
||||
$url = get_edit_post_link( $draft->ID );
|
||||
$url = get_edit_post_link( $draft->ID );
|
||||
$title = _draft_or_post_title( $draft->ID );
|
||||
echo "<li>\n";
|
||||
/* translators: %s: post title */
|
||||
|
@ -579,9 +590,9 @@ function wp_dashboard_recent_drafts( $drafts = false ) {
|
|||
echo '<time datetime="' . get_the_time( 'c', $draft ) . '">' . get_the_time( __( 'F j, Y' ), $draft ) . '</time></div>';
|
||||
if ( $the_content = wp_trim_words( $draft->post_content, 10 ) ) {
|
||||
echo '<p>' . $the_content . '</p>';
|
||||
}
|
||||
}
|
||||
echo "</li>\n";
|
||||
}
|
||||
}
|
||||
echo "</ul>\n</div>";
|
||||
}
|
||||
|
||||
|
@ -602,8 +613,8 @@ function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
|
|||
if ( $comment->comment_post_ID > 0 ) {
|
||||
|
||||
$comment_post_title = _draft_or_post_title( $comment->comment_post_ID );
|
||||
$comment_post_url = get_the_permalink( $comment->comment_post_ID );
|
||||
$comment_post_link = "<a href='$comment_post_url'>$comment_post_title</a>";
|
||||
$comment_post_url = get_the_permalink( $comment->comment_post_ID );
|
||||
$comment_post_link = "<a href='$comment_post_url'>$comment_post_title</a>";
|
||||
} else {
|
||||
$comment_post_link = '';
|
||||
}
|
||||
|
@ -612,28 +623,30 @@ 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' => '',
|
||||
'reply' => '',
|
||||
'edit' => '',
|
||||
'spam' => '',
|
||||
'trash' => '', 'delete' => '',
|
||||
'view' => '',
|
||||
'approve' => '',
|
||||
'unapprove' => '',
|
||||
'reply' => '',
|
||||
'edit' => '',
|
||||
'spam' => '',
|
||||
'trash' => '',
|
||||
'delete' => '',
|
||||
'view' => '',
|
||||
);
|
||||
|
||||
$del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) );
|
||||
$del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) );
|
||||
$approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) );
|
||||
|
||||
$approve_url = esc_url( "comment.php?action=approvecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" );
|
||||
$approve_url = esc_url( "comment.php?action=approvecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" );
|
||||
$unapprove_url = esc_url( "comment.php?action=unapprovecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" );
|
||||
$spam_url = esc_url( "comment.php?action=spamcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
|
||||
$trash_url = esc_url( "comment.php?action=trashcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
|
||||
$delete_url = esc_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
|
||||
$spam_url = esc_url( "comment.php?action=spamcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
|
||||
$trash_url = esc_url( "comment.php?action=trashcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
|
||||
$delete_url = esc_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" );
|
||||
|
||||
$actions['approve'] = "<a href='$approve_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved' class='vim-a' aria-label='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
|
||||
$actions['approve'] = "<a href='$approve_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved' class='vim-a' aria-label='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
|
||||
$actions['unapprove'] = "<a href='$unapprove_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved' class='vim-u' aria-label='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
|
||||
$actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' aria-label='" . esc_attr__( 'Edit this comment' ) . "'>". __( 'Edit' ) . '</a>';
|
||||
$actions['reply'] = '<a onclick="window.commentReply && commentReply.open(\'' . $comment->comment_ID . '\',\''.$comment->comment_post_ID.'\');return false;" class="vim-r hide-if-no-js" aria-label="' . esc_attr__( 'Reply to this comment' ) . '" href="#">' . __( 'Reply' ) . '</a>';
|
||||
$actions['spam'] = "<a href='$spam_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::spam=1' class='vim-s vim-destructive' aria-label='" . esc_attr__( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>';
|
||||
$actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' aria-label='" . esc_attr__( 'Edit this comment' ) . "'>" . __( 'Edit' ) . '</a>';
|
||||
$actions['reply'] = '<a onclick="window.commentReply && commentReply.open(\'' . $comment->comment_ID . '\',\'' . $comment->comment_post_ID . '\');return false;" class="vim-r hide-if-no-js" aria-label="' . esc_attr__( 'Reply to this comment' ) . '" href="#">' . __( 'Reply' ) . '</a>';
|
||||
$actions['spam'] = "<a href='$spam_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::spam=1' class='vim-s vim-destructive' aria-label='" . esc_attr__( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>';
|
||||
|
||||
if ( ! EMPTY_TRASH_DAYS ) {
|
||||
$actions['delete'] = "<a href='$delete_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive' aria-label='" . esc_attr__( 'Delete this comment permanently' ) . "'>" . __( 'Delete Permanently' ) . '</a>';
|
||||
|
@ -654,12 +667,12 @@ function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
|
|||
* 'Delete', and 'Trash'.
|
||||
* @param WP_Comment $comment The comment object.
|
||||
*/
|
||||
$actions = apply_filters( 'comment_row_actions', array_filter($actions), $comment );
|
||||
$actions = apply_filters( 'comment_row_actions', array_filter( $actions ), $comment );
|
||||
|
||||
$i = 0;
|
||||
foreach ( $actions as $action => $link ) {
|
||||
++$i;
|
||||
( ( ('approve' == $action || 'unapprove' == $action) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
|
||||
( ( ( 'approve' == $action || 'unapprove' == $action ) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
|
||||
|
||||
// Reply and quickedit need a hide-if-no-js span
|
||||
if ( 'reply' == $action || 'quickedit' == $action ) {
|
||||
|
@ -678,41 +691,41 @@ function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
|
|||
|
||||
<?php echo get_avatar( $comment, 50, 'mystery' ); ?>
|
||||
|
||||
<?php if ( !$comment->comment_type || 'comment' == $comment->comment_type ) : ?>
|
||||
<?php if ( ! $comment->comment_type || 'comment' == $comment->comment_type ) : ?>
|
||||
|
||||
<div class="dashboard-comment-wrap has-row-actions">
|
||||
<p class="comment-meta">
|
||||
<?php
|
||||
// Comments might not have a post they relate to, e.g. programmatically created ones.
|
||||
if ( $comment_post_link ) {
|
||||
printf(
|
||||
/* translators: 1: comment author, 2: post link, 3: notification if the comment is pending */
|
||||
__( 'From %1$s on %2$s %3$s' ),
|
||||
'<cite class="comment-author">' . get_comment_author_link( $comment ) . '</cite>',
|
||||
$comment_post_link,
|
||||
'<span class="approve">' . __( '[Pending]' ) . '</span>'
|
||||
);
|
||||
} else {
|
||||
printf(
|
||||
/* translators: 1: comment author, 2: notification if the comment is pending */
|
||||
__( 'From %1$s %2$s' ),
|
||||
'<cite class="comment-author">' . get_comment_author_link( $comment ) . '</cite>',
|
||||
'<span class="approve">' . __( '[Pending]' ) . '</span>'
|
||||
);
|
||||
}
|
||||
if ( $comment_post_link ) {
|
||||
printf(
|
||||
/* translators: 1: comment author, 2: post link, 3: notification if the comment is pending */
|
||||
__( 'From %1$s on %2$s %3$s' ),
|
||||
'<cite class="comment-author">' . get_comment_author_link( $comment ) . '</cite>',
|
||||
$comment_post_link,
|
||||
'<span class="approve">' . __( '[Pending]' ) . '</span>'
|
||||
);
|
||||
} else {
|
||||
printf(
|
||||
/* translators: 1: comment author, 2: notification if the comment is pending */
|
||||
__( 'From %1$s %2$s' ),
|
||||
'<cite class="comment-author">' . get_comment_author_link( $comment ) . '</cite>',
|
||||
'<span class="approve">' . __( '[Pending]' ) . '</span>'
|
||||
);
|
||||
}
|
||||
?>
|
||||
</p>
|
||||
|
||||
<?php
|
||||
else :
|
||||
switch ( $comment->comment_type ) {
|
||||
case 'pingback' :
|
||||
case 'pingback':
|
||||
$type = __( 'Pingback' );
|
||||
break;
|
||||
case 'trackback' :
|
||||
case 'trackback':
|
||||
$type = __( 'Trackback' );
|
||||
break;
|
||||
default :
|
||||
default:
|
||||
$type = ucwords( $comment->comment_type );
|
||||
}
|
||||
$type = esc_html( $type );
|
||||
|
@ -721,22 +734,22 @@ function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
|
|||
<p class="comment-meta">
|
||||
<?php
|
||||
// Pingbacks, Trackbacks or custom comment types might not have a post they relate to, e.g. programmatically created ones.
|
||||
if ( $comment_post_link ) {
|
||||
printf(
|
||||
/* translators: 1: type of comment, 2: post link, 3: notification if the comment is pending */
|
||||
_x( '%1$s on %2$s %3$s', 'dashboard' ),
|
||||
"<strong>$type</strong>",
|
||||
$comment_post_link,
|
||||
'<span class="approve">' . __( '[Pending]' ) . '</span>'
|
||||
);
|
||||
} else {
|
||||
printf(
|
||||
/* translators: 1: type of comment, 2: notification if the comment is pending */
|
||||
_x( '%1$s %2$s', 'dashboard' ),
|
||||
"<strong>$type</strong>",
|
||||
'<span class="approve">' . __( '[Pending]' ) . '</span>'
|
||||
);
|
||||
}
|
||||
if ( $comment_post_link ) {
|
||||
printf(
|
||||
/* translators: 1: type of comment, 2: post link, 3: notification if the comment is pending */
|
||||
_x( '%1$s on %2$s %3$s', 'dashboard' ),
|
||||
"<strong>$type</strong>",
|
||||
$comment_post_link,
|
||||
'<span class="approve">' . __( '[Pending]' ) . '</span>'
|
||||
);
|
||||
} else {
|
||||
printf(
|
||||
/* translators: 1: type of comment, 2: notification if the comment is pending */
|
||||
_x( '%1$s %2$s', 'dashboard' ),
|
||||
"<strong>$type</strong>",
|
||||
'<span class="approve">' . __( '[Pending]' ) . '</span>'
|
||||
);
|
||||
}
|
||||
?>
|
||||
</p>
|
||||
<p class="comment-author"><?php comment_author_link( $comment ); ?></p>
|
||||
|
@ -761,24 +774,28 @@ function wp_dashboard_site_activity() {
|
|||
|
||||
echo '<div id="activity-widget">';
|
||||
|
||||
$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(
|
||||
'max' => 5,
|
||||
'status' => 'publish',
|
||||
'order' => 'DESC',
|
||||
'title' => __( 'Recently Published' ),
|
||||
'id' => 'published-posts',
|
||||
) );
|
||||
$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(
|
||||
'max' => 5,
|
||||
'status' => 'publish',
|
||||
'order' => 'DESC',
|
||||
'title' => __( 'Recently Published' ),
|
||||
'id' => 'published-posts',
|
||||
)
|
||||
);
|
||||
|
||||
$recent_comments = wp_dashboard_recent_comments();
|
||||
|
||||
if ( !$future_posts && !$recent_posts && !$recent_comments ) {
|
||||
if ( ! $future_posts && ! $recent_posts && ! $recent_comments ) {
|
||||
echo '<div class="no-activity">';
|
||||
echo '<p class="smiley" aria-hidden="true"></p>';
|
||||
echo '<p>' . __( 'No activity yet!' ) . '</p>';
|
||||
|
@ -824,7 +841,7 @@ function wp_dashboard_recent_posts( $args ) {
|
|||
* @param array $query_args The arguments passed to WP_Query to produce the list of posts.
|
||||
*/
|
||||
$query_args = apply_filters( 'dashboard_recent_posts_query_args', $query_args );
|
||||
$posts = new WP_Query( $query_args );
|
||||
$posts = new WP_Query( $query_args );
|
||||
|
||||
if ( $posts->have_posts() ) {
|
||||
|
||||
|
@ -894,24 +911,27 @@ 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;
|
||||
$comments_query['number'] = $total_items * 10;
|
||||
}
|
||||
|
||||
if ( $comments ) {
|
||||
|
@ -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>';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -968,19 +989,19 @@ function wp_dashboard_rss_output( $widget_id ) {
|
|||
* @return bool False on failure. True on success.
|
||||
*/
|
||||
function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = array() ) {
|
||||
$loading = '<p class="widget-loading hide-if-no-js">' . __( 'Loading…' ) . '</p><div class="hide-if-js notice notice-error inline"><p>' . __( 'This widget requires JavaScript.' ) . '</p></div>';
|
||||
$loading = '<p class="widget-loading hide-if-no-js">' . __( 'Loading…' ) . '</p><div class="hide-if-js notice notice-error inline"><p>' . __( 'This widget requires JavaScript.' ) . '</p></div>';
|
||||
$doing_ajax = wp_doing_ajax();
|
||||
|
||||
if ( empty($check_urls) ) {
|
||||
if ( empty( $check_urls ) ) {
|
||||
$widgets = get_option( 'dashboard_widget_options' );
|
||||
if ( empty($widgets[$widget_id]['url']) && ! $doing_ajax ) {
|
||||
if ( empty( $widgets[ $widget_id ]['url'] ) && ! $doing_ajax ) {
|
||||
echo $loading;
|
||||
return false;
|
||||
}
|
||||
$check_urls = array( $widgets[$widget_id]['url'] );
|
||||
$check_urls = array( $widgets[ $widget_id ]['url'] );
|
||||
}
|
||||
|
||||
$locale = get_user_locale();
|
||||
$locale = get_user_locale();
|
||||
$cache_key = 'dash_v2_' . md5( $widget_id . '_' . $locale );
|
||||
if ( false !== ( $output = get_transient( $cache_key ) ) ) {
|
||||
echo $output;
|
||||
|
@ -1019,8 +1040,13 @@ function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = ar
|
|||
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] ) );
|
||||
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 ],
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1036,38 +1062,40 @@ 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]) )
|
||||
$widget_options[$widget_id] = array();
|
||||
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;
|
||||
$number = 1; // Hack to use wp_widget_rss_form()
|
||||
$widget_options[ $widget_id ]['number'] = $number;
|
||||
|
||||
if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget-rss'][$number]) ) {
|
||||
$_POST['widget-rss'][$number] = wp_unslash( $_POST['widget-rss'][$number] );
|
||||
$widget_options[$widget_id] = wp_widget_rss_process( $_POST['widget-rss'][$number] );
|
||||
$widget_options[$widget_id]['number'] = $number;
|
||||
if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset( $_POST['widget-rss'][ $number ] ) ) {
|
||||
$_POST['widget-rss'][ $number ] = wp_unslash( $_POST['widget-rss'][ $number ] );
|
||||
$widget_options[ $widget_id ] = wp_widget_rss_process( $_POST['widget-rss'][ $number ] );
|
||||
$widget_options[ $widget_id ]['number'] = $number;
|
||||
|
||||
// Title is optional. If black, fill it if possible.
|
||||
if ( !$widget_options[$widget_id]['title'] && isset($_POST['widget-rss'][$number]['title']) ) {
|
||||
$rss = fetch_feed($widget_options[$widget_id]['url']);
|
||||
if ( is_wp_error($rss) ) {
|
||||
$widget_options[$widget_id]['title'] = htmlentities(__('Unknown Feed'));
|
||||
if ( ! $widget_options[ $widget_id ]['title'] && isset( $_POST['widget-rss'][ $number ]['title'] ) ) {
|
||||
$rss = fetch_feed( $widget_options[ $widget_id ]['url'] );
|
||||
if ( is_wp_error( $rss ) ) {
|
||||
$widget_options[ $widget_id ]['title'] = htmlentities( __( 'Unknown Feed' ) );
|
||||
} else {
|
||||
$widget_options[$widget_id]['title'] = htmlentities(strip_tags($rss->get_title()));
|
||||
$widget_options[ $widget_id ]['title'] = htmlentities( strip_tags( $rss->get_title() ) );
|
||||
$rss->__destruct();
|
||||
unset($rss);
|
||||
unset( $rss );
|
||||
}
|
||||
}
|
||||
update_option( 'dashboard_widget_options', $widget_options );
|
||||
$locale = get_user_locale();
|
||||
$locale = get_user_locale();
|
||||
$cache_key = 'dash_v2_' . md5( $widget_id . '_' . $locale );
|
||||
delete_transient( $cache_key );
|
||||
}
|
||||
|
||||
wp_widget_rss_form( $widget_options[$widget_id], $form_inputs );
|
||||
wp_widget_rss_form( $widget_options[ $widget_id ], $form_inputs );
|
||||
}
|
||||
|
||||
|
||||
|
@ -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’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’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’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>
|
||||
|
@ -1276,7 +1312,7 @@ function wp_print_community_events_templates() {
|
|||
*/
|
||||
function wp_dashboard_primary() {
|
||||
$feeds = array(
|
||||
'news' => array(
|
||||
'news' => array(
|
||||
|
||||
/**
|
||||
* Filters the primary link URL for the 'WordPress News' dashboard widget.
|
||||
|
@ -1285,7 +1321,7 @@ function wp_dashboard_primary() {
|
|||
*
|
||||
* @param string $link The widget's primary link URL.
|
||||
*/
|
||||
'link' => apply_filters( 'dashboard_primary_link', __( 'https://wordpress.org/news/' ) ),
|
||||
'link' => apply_filters( 'dashboard_primary_link', __( 'https://wordpress.org/news/' ) ),
|
||||
|
||||
/**
|
||||
* Filters the primary feed URL for the 'WordPress News' dashboard widget.
|
||||
|
@ -1294,7 +1330,7 @@ function wp_dashboard_primary() {
|
|||
*
|
||||
* @param string $url The widget's primary feed URL.
|
||||
*/
|
||||
'url' => apply_filters( 'dashboard_primary_feed', __( 'http://wordpress.org/news/feed/' ) ),
|
||||
'url' => apply_filters( 'dashboard_primary_feed', __( 'http://wordpress.org/news/feed/' ) ),
|
||||
|
||||
/**
|
||||
* Filters the primary link title for the 'WordPress News' dashboard widget.
|
||||
|
@ -1318,7 +1354,7 @@ function wp_dashboard_primary() {
|
|||
*
|
||||
* @param string $link The widget's secondary link URL.
|
||||
*/
|
||||
'link' => apply_filters( 'dashboard_secondary_link', __( 'https://planet.wordpress.org/' ) ),
|
||||
'link' => apply_filters( 'dashboard_secondary_link', __( 'https://planet.wordpress.org/' ) ),
|
||||
|
||||
/**
|
||||
* Filters the secondary feed URL for the 'WordPress News' dashboard widget.
|
||||
|
@ -1327,7 +1363,7 @@ function wp_dashboard_primary() {
|
|||
*
|
||||
* @param string $url The widget's secondary feed URL.
|
||||
*/
|
||||
'url' => apply_filters( 'dashboard_secondary_feed', __( 'https://planet.wordpress.org/feed/' ) ),
|
||||
'url' => apply_filters( 'dashboard_secondary_feed', __( 'https://planet.wordpress.org/feed/' ) ),
|
||||
|
||||
/**
|
||||
* Filters the secondary link title for the 'WordPress News' dashboard widget.
|
||||
|
@ -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,18 +1419,20 @@ 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();
|
||||
$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 );
|
||||
}
|
||||
$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>
|
||||
|
@ -1434,35 +1476,38 @@ function wp_dashboard_quota() {
|
|||
|
||||
// Display Browser Nag Meta Box
|
||||
function wp_dashboard_browser_nag() {
|
||||
$notice = '';
|
||||
$notice = '';
|
||||
$response = wp_check_browser_version();
|
||||
|
||||
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'] ) )
|
||||
);
|
||||
}
|
||||
|
||||
$browser_nag_class = '';
|
||||
if ( !empty( $response['img_src'] ) ) {
|
||||
$img_src = ( is_ssl() && ! empty( $response['img_src_ssl'] ) )? $response['img_src_ssl'] : $response['img_src'];
|
||||
if ( ! empty( $response['img_src'] ) ) {
|
||||
$img_src = ( is_ssl() && ! empty( $response['img_src_ssl'] ) ) ? $response['img_src_ssl'] : $response['img_src'];
|
||||
|
||||
$notice .= '<div class="alignright browser-icon"><a href="' . esc_attr($response['update_url']) . '"><img src="' . esc_attr( $img_src ) . '" alt="" /></a></div>';
|
||||
$notice .= '<div class="alignright browser-icon"><a href="' . esc_attr( $response['update_url'] ) . '"><img src="' . esc_attr( $img_src ) . '" alt="" /></a></div>';
|
||||
$browser_nag_class = ' has-browser-icon';
|
||||
}
|
||||
$notice .= "<p class='browser-update-nag{$browser_nag_class}'>{$msg}</p>";
|
||||
|
||||
$browsehappy = 'https://browsehappy.com/';
|
||||
$locale = get_user_locale();
|
||||
if ( 'en_US' !== $locale )
|
||||
$locale = get_user_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>';
|
||||
|
@ -1470,13 +1515,13 @@ function wp_dashboard_browser_nag() {
|
|||
}
|
||||
|
||||
/**
|
||||
* Filters the notice output for the 'Browse Happy' nag meta box.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @param string $notice The notice content.
|
||||
* @param array $response An array containing web browser information.
|
||||
*/
|
||||
* Filters the notice output for the 'Browse Happy' nag meta box.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @param string $notice The notice content.
|
||||
* @param array $response An array containing web browser information.
|
||||
*/
|
||||
echo apply_filters( 'browse-happy-notice', $notice, $response );
|
||||
}
|
||||
|
||||
|
@ -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,19 +1549,20 @@ 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'] );
|
||||
|
||||
if ( false === ($response = get_site_transient('browser_' . $key) ) ) {
|
||||
if ( false === ( $response = get_site_transient( 'browser_' . $key ) ) ) {
|
||||
// include an unmodified $wp_version
|
||||
include( ABSPATH . WPINC . '/version.php' );
|
||||
|
||||
$url = 'http://api.wordpress.org/core/browse-happy/1.1/';
|
||||
$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
|
||||
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' ) );
|
||||
} 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>
|
||||
<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' )
|
||||
);
|
||||
} 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>
|
||||
<?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>
|
||||
|
|
|
@ -55,4 +55,4 @@ if ( isset( $_REQUEST['message'] ) && ( $msg = (int) $_REQUEST['message'] ) ) {
|
|||
} elseif ( ! isset( $messages[ $taxonomy ] ) && isset( $messages['_item'][ $msg ] ) ) {
|
||||
$message = $messages['_item'][ $msg ];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,10 +56,15 @@ 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 );
|
||||
$args = wp_parse_args( $args, $defaults );
|
||||
|
||||
/**
|
||||
* Fires at the beginning of an export, before any headers are sent.
|
||||
|
@ -74,8 +79,8 @@ function export_wp( $args = array() ) {
|
|||
if ( ! empty( $sitename ) ) {
|
||||
$sitename .= '.';
|
||||
}
|
||||
$date = date( 'Y-m-d' );
|
||||
$wp_filename = $sitename . 'wordpress.' . $date . '.xml';
|
||||
$date = date( 'Y-m-d' );
|
||||
$wp_filename = $sitename . 'WordPress.' . $date . '.xml';
|
||||
/**
|
||||
* Filters the export filename.
|
||||
*
|
||||
|
@ -93,38 +98,43 @@ 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 {
|
||||
$post_types = get_post_types( array( 'can_export' => true ) );
|
||||
$esses = array_fill( 0, count($post_types), '%s' );
|
||||
$where = $wpdb->prepare( "{$wpdb->posts}.post_type IN (" . implode( ',', $esses ) . ')', $post_types );
|
||||
$esses = array_fill( 0, count( $post_types ), '%s' );
|
||||
$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'] ) {
|
||||
if ( $term = term_exists( $args['category'], 'category' ) ) {
|
||||
$join = "INNER JOIN {$wpdb->term_relationships} ON ({$wpdb->posts}.ID = {$wpdb->term_relationships}.object_id)";
|
||||
$join = "INNER JOIN {$wpdb->term_relationships} ON ({$wpdb->posts}.ID = {$wpdb->term_relationships}.object_id)";
|
||||
$where .= $wpdb->prepare( " AND {$wpdb->term_relationships}.term_taxonomy_id = %d", $term['term_taxonomy_id'] );
|
||||
}
|
||||
}
|
||||
|
||||
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'] )
|
||||
$where .= $wpdb->prepare( " AND {$wpdb->posts}.post_date >= %s", date( 'Y-m-d', strtotime($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'] )
|
||||
$where .= $wpdb->prepare( " AND {$wpdb->posts}.post_date < %s", date( 'Y-m-d', strtotime('+1 month', strtotime($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.
|
||||
|
@ -136,30 +146,32 @@ function export_wp( $args = array() ) {
|
|||
*/
|
||||
$cats = $tags = $terms = array();
|
||||
if ( isset( $term ) && $term ) {
|
||||
$cat = get_term( $term['term_id'], 'category' );
|
||||
$cat = get_term( $term['term_id'], 'category' );
|
||||
$cats = array( $cat->term_id => $cat );
|
||||
unset( $term, $cat );
|
||||
} elseif ( 'all' == $args['content'] ) {
|
||||
$categories = (array) get_categories( array( 'get' => 'all' ) );
|
||||
$tags = (array) get_tags( array( 'get' => 'all' ) );
|
||||
$tags = (array) get_tags( array( 'get' => 'all' ) );
|
||||
|
||||
$custom_taxonomies = get_taxonomies( array( '_builtin' => false ) );
|
||||
$custom_terms = (array) get_terms( $custom_taxonomies, array( 'get' => 'all' ) );
|
||||
$custom_terms = (array) get_terms( $custom_taxonomies, array( 'get' => 'all' ) );
|
||||
|
||||
// Put categories in order with no child going before its parent.
|
||||
while ( $cat = array_shift( $categories ) ) {
|
||||
if ( $cat->parent == 0 || isset( $cats[$cat->parent] ) )
|
||||
$cats[$cat->term_id] = $cat;
|
||||
else
|
||||
if ( $cat->parent == 0 || isset( $cats[ $cat->parent ] ) ) {
|
||||
$cats[ $cat->term_id ] = $cat;
|
||||
} 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] ) )
|
||||
$terms[$t->term_id] = $t;
|
||||
else
|
||||
if ( $t->parent == 0 || isset( $terms[ $t->parent ] ) ) {
|
||||
$terms[ $t->term_id ] = $t;
|
||||
} else {
|
||||
$custom_terms[] = $t;
|
||||
}
|
||||
}
|
||||
|
||||
unset( $categories, $custom_taxonomies, $custom_terms );
|
||||
|
@ -192,11 +204,12 @@ 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' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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";
|
||||
}
|
||||
|
@ -326,17 +345,18 @@ function export_wp( $args = array() ) {
|
|||
function wxr_authors_list( array $post_ids = null ) {
|
||||
global $wpdb;
|
||||
|
||||
if ( !empty( $post_ids ) ) {
|
||||
if ( ! empty( $post_ids ) ) {
|
||||
$post_ids = array_map( 'absint', $post_ids );
|
||||
$and = 'AND ID IN ( ' . implode( ', ', $post_ids ) . ')';
|
||||
$and = 'AND ID IN ( ' . implode( ', ', $post_ids ) . ')';
|
||||
} else {
|
||||
$and = '';
|
||||
}
|
||||
|
||||
$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,19 +413,19 @@ 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 );
|
||||
|
||||
echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . "\" ?>\n";
|
||||
echo '<?xml version="1.0" encoding="' . get_bloginfo( 'charset' ) . "\" ?>\n";
|
||||
|
||||
?>
|
||||
<!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your site. -->
|
||||
|
@ -448,19 +470,23 @@ function export_wp( $args = array() ) {
|
|||
<wp:category>
|
||||
<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 );
|
||||
<wp:category_parent><?php echo wxr_cdata( $c->parent ? $cats[ $c->parent ]->slug : '' ); ?></wp:category_parent>
|
||||
<?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 ) : ?>
|
||||
|
@ -468,20 +494,26 @@ function export_wp( $args = array() ) {
|
|||
<wp:term_id><?php echo wxr_cdata( $t->term_id ); ?></wp:term_id>
|
||||
<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 );
|
||||
<wp:term_parent><?php echo wxr_cdata( $t->parent ? $terms[ $t->parent ]->slug : '' ); ?></wp:term_parent>
|
||||
<?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
|
||||
*/
|
||||
|
@ -492,25 +524,28 @@ function export_wp( $args = array() ) {
|
|||
|
||||
// Fetch 20 posts at a time rather than loading the entire table into memory.
|
||||
while ( $next_posts = array_splice( $post_ids, 0, 20 ) ) {
|
||||
$where = 'WHERE ID IN (' . join( ',', $next_posts ) . ')';
|
||||
$posts = $wpdb->get_results( "SELECT * FROM {$wpdb->posts} $where" );
|
||||
$where = 'WHERE ID IN (' . join( ',', $next_posts ) . ')';
|
||||
$posts = $wpdb->get_results( "SELECT * FROM {$wpdb->posts} $where" );
|
||||
|
||||
// Begin Loop.
|
||||
foreach ( $posts as $post ) {
|
||||
setup_postdata( $post );
|
||||
$is_sticky = is_sticky( $post->ID ) ? 1 : 0;
|
||||
?>
|
||||
// Begin Loop.
|
||||
foreach ( $posts as $post ) {
|
||||
setup_postdata( $post );
|
||||
$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>
|
||||
|
@ -542,36 +580,40 @@ function export_wp( $args = array() ) {
|
|||
<wp:post_type><?php echo wxr_cdata( $post->post_type ); ?></wp:post_type>
|
||||
<wp:post_password><?php echo wxr_cdata( $post->post_password ); ?></wp:post_password>
|
||||
<wp:is_sticky><?php echo intval( $is_sticky ); ?></wp:is_sticky>
|
||||
<?php if ( $post->post_type == 'attachment' ) : ?>
|
||||
<?php if ( $post->post_type == 'attachment' ) : ?>
|
||||
<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 ) );
|
||||
foreach ( $postmeta as $meta ) :
|
||||
/**
|
||||
* Filters whether to selectively skip post meta used for WXR exports.
|
||||
*
|
||||
* Returning a truthy value to the filter will skip the current meta
|
||||
* object from being exported.
|
||||
*
|
||||
* @since 3.3.0
|
||||
*
|
||||
* @param bool $skip Whether to skip the current post meta. Default false.
|
||||
* @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 ) )
|
||||
continue;
|
||||
<?php endif; ?>
|
||||
<?php wxr_post_taxonomy(); ?>
|
||||
<?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.
|
||||
*
|
||||
* Returning a truthy value to the filter will skip the current meta
|
||||
* object from being exported.
|
||||
*
|
||||
* @since 3.3.0
|
||||
*
|
||||
* @param bool $skip Whether to skip the current post meta. Default false.
|
||||
* @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 ) ) {
|
||||
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: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 ) : ?>
|
||||
$comments = array_map( 'get_comment', $_comments );
|
||||
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,41 +622,43 @@ 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 ) );
|
||||
foreach ( $c_meta as $meta ) :
|
||||
/**
|
||||
* Filters whether to selectively skip comment meta used for WXR exports.
|
||||
*
|
||||
* Returning a truthy value to the filter will skip the current meta
|
||||
* object from being exported.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*
|
||||
* @param bool $skip Whether to skip the current comment meta. Default false.
|
||||
* @param string $meta_key Current meta key.
|
||||
* @param object $meta Current meta object.
|
||||
*/
|
||||
if ( apply_filters( 'wxr_export_skip_commentmeta', false, $meta->meta_key, $meta ) ) {
|
||||
continue;
|
||||
}
|
||||
?>
|
||||
<wp:commentmeta>
|
||||
<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>
|
||||
<?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.
|
||||
*
|
||||
* Returning a truthy value to the filter will skip the current meta
|
||||
* object from being exported.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*
|
||||
* @param bool $skip Whether to skip the current comment meta. Default false.
|
||||
* @param string $meta_key Current meta key.
|
||||
* @param object $meta Current meta object.
|
||||
*/
|
||||
if ( apply_filters( 'wxr_export_skip_commentmeta', false, $meta->meta_key, $meta ) ) {
|
||||
continue;
|
||||
}
|
||||
?>
|
||||
<wp:commentmeta>
|
||||
<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:commentmeta>
|
||||
<?php endforeach; ?>
|
||||
<?php endforeach; ?>
|
||||
</wp:comment>
|
||||
<?php endforeach; ?>
|
||||
</item>
|
||||
<?php
|
||||
</item>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
} ?>
|
||||
}
|
||||
?>
|
||||
</channel>
|
||||
</rss>
|
||||
<?php
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -13,30 +13,33 @@
|
|||
* @param bool|object $msg Optional. Message to display for image editor updates or errors.
|
||||
* Default false.
|
||||
*/
|
||||
function wp_image_editor($post_id, $msg = false) {
|
||||
$nonce = wp_create_nonce("image_editor-$post_id");
|
||||
$meta = wp_get_attachment_metadata($post_id);
|
||||
$thumb = image_get_intermediate_size($post_id, 'thumbnail');
|
||||
$sub_sizes = isset($meta['sizes']) && is_array($meta['sizes']);
|
||||
$note = '';
|
||||
function wp_image_editor( $post_id, $msg = false ) {
|
||||
$nonce = wp_create_nonce( "image_editor-$post_id" );
|
||||
$meta = wp_get_attachment_metadata( $post_id );
|
||||
$thumb = image_get_intermediate_size( $post_id, 'thumbnail' );
|
||||
$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
|
||||
die( __('Image data does not exist. Please re-upload the image.') );
|
||||
} 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'] ) )
|
||||
$can_restore = false;
|
||||
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>";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -49,10 +52,10 @@ function wp_image_editor($post_id, $msg = false) {
|
|||
<h2><?php _e( 'Scale Image' ); ?></h2>
|
||||
<button type="button" class="dashicons dashicons-editor-help imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);return false;" aria-expanded="false"><span class="screen-reader-text"><?php esc_html_e( 'Scale Image Help' ); ?></span></button>
|
||||
<div class="imgedit-help">
|
||||
<p><?php _e('You can proportionally scale the original image. For best results, scaling should be done before you crop, flip, or rotate. Images can only be scaled down, not up.'); ?></p>
|
||||
<p><?php _e( 'You can proportionally scale the original image. For best results, scaling should be done before you crop, flip, or rotate. Images can only be scaled down, not up.' ); ?></p>
|
||||
</div>
|
||||
<?php if ( isset( $meta['width'], $meta['height'] ) ): ?>
|
||||
<p><?php printf( __('Original dimensions %s'), $meta['width'] . ' × ' . $meta['height'] ); ?></p>
|
||||
<?php if ( isset( $meta['width'], $meta['height'] ) ) : ?>
|
||||
<p><?php printf( __( 'Original dimensions %s' ), $meta['width'] . ' × ' . $meta['height'] ); ?></p>
|
||||
<?php endif ?>
|
||||
<div class="imgedit-submit">
|
||||
|
||||
|
@ -68,7 +71,7 @@ function wp_image_editor($post_id, $msg = false) {
|
|||
</label>
|
||||
<span class="imgedit-scale-warn" id="imgedit-scale-warn-<?php echo $post_id; ?>">!</span>
|
||||
<input id="imgedit-scale-button" type="button" onclick="imageEdit.action(<?php echo "$post_id, '$nonce'"; ?>, 'scale')" class="button button-primary" value="<?php esc_attr_e( 'Scale' ); ?>" />
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
</div>
|
||||
|
@ -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 )
|
||||
echo ' '.__('Previously edited copies of the image will not be deleted.');
|
||||
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>
|
||||
|
@ -102,13 +109,13 @@ function wp_image_editor($post_id, $msg = false) {
|
|||
<button type="button" class="dashicons dashicons-editor-help imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);return false;" aria-expanded="false"><span class="screen-reader-text"><?php esc_html_e( 'Image Crop Help' ); ?></span></button>
|
||||
|
||||
<div class="imgedit-help">
|
||||
<p><?php _e('To crop the image, click on it and drag to make your selection.'); ?></p>
|
||||
<p><?php _e( 'To crop the image, click on it and drag to make your selection.' ); ?></p>
|
||||
|
||||
<p><strong><?php _e('Crop Aspect Ratio'); ?></strong><br />
|
||||
<?php _e('The aspect ratio is the relationship between the width and height. You can preserve the aspect ratio by holding down the shift key while resizing your selection. Use the input box to specify the aspect ratio, e.g. 1:1 (square), 4:3, 16:9, etc.'); ?></p>
|
||||
<p><strong><?php _e( 'Crop Aspect Ratio' ); ?></strong><br />
|
||||
<?php _e( 'The aspect ratio is the relationship between the width and height. You can preserve the aspect ratio by holding down the shift key while resizing your selection. Use the input box to specify the aspect ratio, e.g. 1:1 (square), 4:3, 16:9, etc.' ); ?></p>
|
||||
|
||||
<p><strong><?php _e('Crop Selection'); ?></strong><br />
|
||||
<?php _e('Once you have made your selection, you can adjust it by entering the size in pixels. The minimum selection size is the thumbnail size as set in the Media settings.'); ?></p>
|
||||
<p><strong><?php _e( 'Crop Selection' ); ?></strong><br />
|
||||
<?php _e( 'Once you have made your selection, you can adjust it by entering the size in pixels. The minimum selection size is the thumbnail size as set in the Media settings.' ); ?></p>
|
||||
</div>
|
||||
</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 );
|
||||
?>
|
||||
|
||||
|
@ -148,7 +156,7 @@ function wp_image_editor($post_id, $msg = false) {
|
|||
<div class="imgedit-group-top">
|
||||
<h2><?php _e( 'Thumbnail Settings' ); ?></h2>
|
||||
<button type="button" class="dashicons dashicons-editor-help imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);return false;" aria-expanded="false"><span class="screen-reader-text"><?php esc_html_e( 'Thumbnail Settings Help' ); ?></span></button>
|
||||
<p class="imgedit-help"><?php _e('You can edit the image while preserving the thumbnail. For example, you may wish to have a square thumbnail that displays just a section of the image.'); ?></p>
|
||||
<p class="imgedit-help"><?php _e( 'You can edit the image while preserving the thumbnail. For example, you may wish to have a square thumbnail that displays just a section of the image.' ); ?></p>
|
||||
</div>
|
||||
|
||||
<figure class="imgedit-thumbnail-preview">
|
||||
|
@ -162,15 +170,15 @@ function wp_image_editor($post_id, $msg = false) {
|
|||
|
||||
<label class="imgedit-label">
|
||||
<input type="radio" name="imgedit-target-<?php echo $post_id; ?>" value="all" checked="checked" />
|
||||
<?php _e('All image sizes'); ?></label>
|
||||
<?php _e( 'All image sizes' ); ?></label>
|
||||
|
||||
<label class="imgedit-label">
|
||||
<input type="radio" name="imgedit-target-<?php echo $post_id; ?>" value="thumbnail" />
|
||||
<?php _e('Thumbnail'); ?></label>
|
||||
<?php _e( 'Thumbnail' ); ?></label>
|
||||
|
||||
<label class="imgedit-label">
|
||||
<input type="radio" name="imgedit-target-<?php echo $post_id; ?>" value="nothumb" />
|
||||
<?php _e('All sizes except thumbnail'); ?></label>
|
||||
<?php _e( 'All sizes except thumbnail' ); ?></label>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -182,20 +190,27 @@ 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' ) ) ) ) {
|
||||
$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>
|
||||
// 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' ),
|
||||
)
|
||||
) ) {
|
||||
$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 {
|
||||
$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>
|
||||
<button type="button" class="imgedit-rright button disabled" disabled></button>
|
||||
<?php } ?>
|
||||
<?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>
|
||||
<button type="button" class="imgedit-rright button disabled" disabled></button>
|
||||
<?php } ?>
|
||||
|
||||
<button type="button" onclick="imageEdit.flip(1, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-flipv button"><span class="screen-reader-text"><?php esc_html_e( 'Flip vertically' ); ?></span></button>
|
||||
<button type="button" onclick="imageEdit.flip(2, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-fliph button"><span class="screen-reader-text"><?php esc_html_e( 'Flip horizontally' ); ?></span></button>
|
||||
|
@ -213,7 +228,7 @@ function wp_image_editor($post_id, $msg = false) {
|
|||
<input type="hidden" id="imgedit-y-<?php echo $post_id; ?>" value="<?php echo isset( $meta['height'] ) ? $meta['height'] : 0; ?>" />
|
||||
|
||||
<div id="imgedit-crop-<?php echo $post_id; ?>" class="imgedit-crop-wrap">
|
||||
<img id="image-preview-<?php echo $post_id; ?>" onload="imageEdit.imgLoaded('<?php echo $post_id; ?>')" src="<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>?action=imgedit-preview&_ajax_nonce=<?php echo $nonce; ?>&postid=<?php echo $post_id; ?>&rand=<?php echo rand(1, 99999); ?>" alt="" />
|
||||
<img id="image-preview-<?php echo $post_id; ?>" onload="imageEdit.imgLoaded('<?php echo $post_id; ?>')" src="<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>?action=imgedit-preview&_ajax_nonce=<?php echo $nonce; ?>&postid=<?php echo $post_id; ?>&rand=<?php echo rand( 1, 99999 ); ?>" alt="" />
|
||||
</div>
|
||||
|
||||
<div class="imgedit-submit">
|
||||
|
@ -224,7 +239,7 @@ function wp_image_editor($post_id, $msg = false) {
|
|||
|
||||
</div>
|
||||
<div class="imgedit-wait" id="imgedit-wait-<?php echo $post_id; ?>"></div>
|
||||
<div class="hidden" id="imgedit-leaving-<?php echo $post_id; ?>"><?php _e("There are unsaved changes that will be lost. 'OK' to continue, 'Cancel' to return to the Image Editor."); ?></div>
|
||||
<div class="hidden" id="imgedit-leaving-<?php echo $post_id; ?>"><?php _e( "There are unsaved changes that will be lost. 'OK' to continue, 'Cancel' to return to the Image Editor." ); ?></div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
@ -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':
|
||||
|
@ -370,9 +387,9 @@ function wp_save_image_file( $filename, $image, $mime_type, $post_id ) {
|
|||
* @param int $h Image height in pixels.
|
||||
* @return float|int Image preview ratio.
|
||||
*/
|
||||
function _image_get_preview_ratio($w, $h) {
|
||||
$max = max($w, $h);
|
||||
return $max > 400 ? (400 / $max) : 1;
|
||||
function _image_get_preview_ratio( $w, $h ) {
|
||||
$max = max( $w, $h );
|
||||
return $max > 400 ? ( 400 / $max ) : 1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -387,12 +404,12 @@ function _image_get_preview_ratio($w, $h) {
|
|||
* @param float|int $angle Image rotation angle, in degrees.
|
||||
* @return resource|false GD image resource, false otherwise.
|
||||
*/
|
||||
function _rotate_image_resource($img, $angle) {
|
||||
function _rotate_image_resource( $img, $angle ) {
|
||||
_deprecated_function( __FUNCTION__, '3.5.0', 'WP_Image_Editor::rotate()' );
|
||||
if ( function_exists('imagerotate') ) {
|
||||
$rotated = imagerotate($img, $angle, 0);
|
||||
if ( is_resource($rotated) ) {
|
||||
imagedestroy($img);
|
||||
if ( function_exists( 'imagerotate' ) ) {
|
||||
$rotated = imagerotate( $img, $angle, 0 );
|
||||
if ( is_resource( $rotated ) ) {
|
||||
imagedestroy( $img );
|
||||
$img = $rotated;
|
||||
}
|
||||
}
|
||||
|
@ -412,19 +429,19 @@ function _rotate_image_resource($img, $angle) {
|
|||
* @param bool $vert Whether to flip vertically.
|
||||
* @return resource (maybe) flipped image resource.
|
||||
*/
|
||||
function _flip_image_resource($img, $horz, $vert) {
|
||||
function _flip_image_resource( $img, $horz, $vert ) {
|
||||
_deprecated_function( __FUNCTION__, '3.5.0', 'WP_Image_Editor::flip()' );
|
||||
$w = imagesx($img);
|
||||
$h = imagesy($img);
|
||||
$dst = wp_imagecreatetruecolor($w, $h);
|
||||
if ( is_resource($dst) ) {
|
||||
$sx = $vert ? ($w - 1) : 0;
|
||||
$sy = $horz ? ($h - 1) : 0;
|
||||
$w = imagesx( $img );
|
||||
$h = imagesy( $img );
|
||||
$dst = wp_imagecreatetruecolor( $w, $h );
|
||||
if ( is_resource( $dst ) ) {
|
||||
$sx = $vert ? ( $w - 1 ) : 0;
|
||||
$sy = $horz ? ( $h - 1 ) : 0;
|
||||
$sw = $vert ? -$w : $w;
|
||||
$sh = $horz ? -$h : $h;
|
||||
|
||||
if ( imagecopyresampled($dst, $img, 0, 0, $sx, $sy, $w, $h, $sw, $sh) ) {
|
||||
imagedestroy($img);
|
||||
if ( imagecopyresampled( $dst, $img, 0, 0, $sx, $sy, $w, $h, $sw, $sh ) ) {
|
||||
imagedestroy( $img );
|
||||
$img = $dst;
|
||||
}
|
||||
}
|
||||
|
@ -444,11 +461,11 @@ function _flip_image_resource($img, $horz, $vert) {
|
|||
* @param float $h Source height.
|
||||
* @return resource (maybe) cropped image resource.
|
||||
*/
|
||||
function _crop_image_resource($img, $x, $y, $w, $h) {
|
||||
$dst = wp_imagecreatetruecolor($w, $h);
|
||||
if ( is_resource($dst) ) {
|
||||
if ( imagecopy($dst, $img, 0, 0, $x, $y, $w, $h) ) {
|
||||
imagedestroy($img);
|
||||
function _crop_image_resource( $img, $x, $y, $w, $h ) {
|
||||
$dst = wp_imagecreatetruecolor( $w, $h );
|
||||
if ( is_resource( $dst ) ) {
|
||||
if ( imagecopy( $dst, $img, 0, 0, $x, $y, $w, $h ) ) {
|
||||
imagedestroy( $img );
|
||||
$img = $dst;
|
||||
}
|
||||
}
|
||||
|
@ -465,52 +482,55 @@ 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 ) {
|
||||
if ( isset($obj->r) ) {
|
||||
$obj->type = 'rotate';
|
||||
if ( isset( $obj->r ) ) {
|
||||
$obj->type = 'rotate';
|
||||
$obj->angle = $obj->r;
|
||||
unset($obj->r);
|
||||
} elseif ( isset($obj->f) ) {
|
||||
unset( $obj->r );
|
||||
} elseif ( isset( $obj->f ) ) {
|
||||
$obj->type = 'flip';
|
||||
$obj->axis = $obj->f;
|
||||
unset($obj->f);
|
||||
} elseif ( isset($obj->c) ) {
|
||||
unset( $obj->f );
|
||||
} elseif ( isset( $obj->c ) ) {
|
||||
$obj->type = 'crop';
|
||||
$obj->sel = $obj->c;
|
||||
unset($obj->c);
|
||||
$obj->sel = $obj->c;
|
||||
unset( $obj->c );
|
||||
}
|
||||
$changes[$key] = $obj;
|
||||
$changes[ $key ] = $obj;
|
||||
}
|
||||
|
||||
// Combine operations.
|
||||
if ( count($changes) > 1 ) {
|
||||
$filtered = array($changes[0]);
|
||||
if ( count( $changes ) > 1 ) {
|
||||
$filtered = array( $changes[0] );
|
||||
for ( $i = 0, $j = 1, $c = count( $changes ); $j < $c; $j++ ) {
|
||||
$combined = false;
|
||||
if ( $filtered[$i]->type == $changes[$j]->type ) {
|
||||
switch ( $filtered[$i]->type ) {
|
||||
if ( $filtered[ $i ]->type == $changes[ $j ]->type ) {
|
||||
switch ( $filtered[ $i ]->type ) {
|
||||
case 'rotate':
|
||||
$filtered[$i]->angle += $changes[$j]->angle;
|
||||
$combined = true;
|
||||
$filtered[ $i ]->angle += $changes[ $j ]->angle;
|
||||
$combined = true;
|
||||
break;
|
||||
case 'flip':
|
||||
$filtered[$i]->axis ^= $changes[$j]->axis;
|
||||
$combined = true;
|
||||
$filtered[ $i ]->axis ^= $changes[ $j ]->axis;
|
||||
$combined = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( !$combined )
|
||||
$filtered[++$i] = $changes[$j];
|
||||
if ( ! $combined ) {
|
||||
$filtered[ ++$i ] = $changes[ $j ];
|
||||
}
|
||||
}
|
||||
$changes = $filtered;
|
||||
unset($filtered);
|
||||
unset( $filtered );
|
||||
}
|
||||
|
||||
// Image resource before applying the changes.
|
||||
|
@ -522,7 +542,7 @@ function image_edit_apply_changes( $image, $changes ) {
|
|||
* @since 3.5.0
|
||||
*
|
||||
* @param WP_Image_Editor $image WP_Image_Editor instance.
|
||||
* @param array $changes Array of change operations.
|
||||
* @param array $changes Array of change operations.
|
||||
*/
|
||||
$image = apply_filters( 'wp_image_editor_before_change', $image, $changes );
|
||||
} elseif ( is_resource( $image ) ) {
|
||||
|
@ -534,7 +554,7 @@ function image_edit_apply_changes( $image, $changes ) {
|
|||
* @deprecated 3.5.0 Use wp_image_editor_before_change instead.
|
||||
*
|
||||
* @param resource $image GD image resource.
|
||||
* @param array $changes Array of change operations.
|
||||
* @param array $changes Array of change operations.
|
||||
*/
|
||||
$image = apply_filters( 'image_edit_before_change', $image, $changes );
|
||||
}
|
||||
|
@ -543,26 +563,29 @@ 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 )
|
||||
$image->flip( ($operation->axis & 1) != 0, ($operation->axis & 2) != 0 );
|
||||
else
|
||||
if ( $operation->axis != 0 ) {
|
||||
if ( $image instanceof WP_Image_Editor ) {
|
||||
$image->flip( ( $operation->axis & 1 ) != 0, ( $operation->axis & 2 ) != 0 );
|
||||
} else {
|
||||
$image = _flip_image_resource( $image, ( $operation->axis & 1 ) != 0, ( $operation->axis & 2 ) != 0 );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'crop':
|
||||
$sel = $operation->sel;
|
||||
|
||||
if ( $image instanceof WP_Image_Editor ) {
|
||||
$size = $image->get_size();
|
||||
$w = $size['width'];
|
||||
$h = $size['height'];
|
||||
$w = $size['width'];
|
||||
$h = $size['height'];
|
||||
|
||||
$scale = 1 / _image_get_preview_ratio( $w, $h ); // discard preview scaling
|
||||
$image->crop( $sel->x * $scale, $sel->y * $scale, $sel->w * $scale, $sel->h * $scale );
|
||||
|
@ -596,21 +619,23 @@ function stream_preview_image( $post_id ) {
|
|||
return false;
|
||||
}
|
||||
|
||||
$changes = !empty($_REQUEST['history']) ? json_decode( wp_unslash($_REQUEST['history']) ) : null;
|
||||
if ( $changes )
|
||||
$changes = ! empty( $_REQUEST['history'] ) ? json_decode( wp_unslash( $_REQUEST['history'] ) ) : null;
|
||||
if ( $changes ) {
|
||||
$img = image_edit_apply_changes( $img, $changes );
|
||||
}
|
||||
|
||||
// Scale the image.
|
||||
$size = $img->get_size();
|
||||
$w = $size['width'];
|
||||
$h = $size['height'];
|
||||
$w = $size['width'];
|
||||
$h = $size['height'];
|
||||
|
||||
$ratio = _image_get_preview_ratio( $w, $h );
|
||||
$w2 = max ( 1, $w * $ratio );
|
||||
$h2 = max ( 1, $h * $ratio );
|
||||
$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 );
|
||||
}
|
||||
|
@ -623,78 +648,83 @@ function stream_preview_image( $post_id ) {
|
|||
* @param int $post_id Attachment post ID.
|
||||
* @return stdClass Image restoration message object.
|
||||
*/
|
||||
function wp_restore_image($post_id) {
|
||||
$meta = wp_get_attachment_metadata($post_id);
|
||||
$file = get_attached_file($post_id);
|
||||
function wp_restore_image( $post_id ) {
|
||||
$meta = wp_get_attachment_metadata( $post_id );
|
||||
$file = get_attached_file( $post_id );
|
||||
$backup_sizes = $old_backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true );
|
||||
$restored = false;
|
||||
$msg = new stdClass;
|
||||
$restored = false;
|
||||
$msg = new stdClass;
|
||||
|
||||
if ( !is_array($backup_sizes) ) {
|
||||
$msg->error = __('Cannot load image metadata.');
|
||||
if ( ! is_array( $backup_sizes ) ) {
|
||||
$msg->error = __( 'Cannot load image metadata.' );
|
||||
return $msg;
|
||||
}
|
||||
|
||||
$parts = pathinfo($file);
|
||||
$suffix = time() . rand(100, 999);
|
||||
$parts = pathinfo( $file );
|
||||
$suffix = time() . rand( 100, 999 );
|
||||
$default_sizes = get_intermediate_image_sizes();
|
||||
|
||||
if ( isset($backup_sizes['full-orig']) && is_array($backup_sizes['full-orig']) ) {
|
||||
if ( isset( $backup_sizes['full-orig'] ) && is_array( $backup_sizes['full-orig'] ) ) {
|
||||
$data = $backup_sizes['full-orig'];
|
||||
|
||||
if ( $parts['basename'] != $data['file'] ) {
|
||||
if ( defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE ) {
|
||||
if ( defined( 'IMAGE_EDIT_OVERWRITE' ) && IMAGE_EDIT_OVERWRITE ) {
|
||||
|
||||
// Delete only if it's an edited image.
|
||||
if ( preg_match('/-e[0-9]{13}\./', $parts['basename']) ) {
|
||||
if ( preg_match( '/-e[0-9]{13}\./', $parts['basename'] ) ) {
|
||||
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'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$restored_file = path_join($parts['dirname'], $data['file']);
|
||||
$restored = update_attached_file($post_id, $restored_file);
|
||||
$restored_file = path_join( $parts['dirname'], $data['file'] );
|
||||
$restored = update_attached_file( $post_id, $restored_file );
|
||||
|
||||
$meta['file'] = _wp_relative_upload_path( $restored_file );
|
||||
$meta['width'] = $data['width'];
|
||||
$meta['file'] = _wp_relative_upload_path( $restored_file );
|
||||
$meta['width'] = $data['width'];
|
||||
$meta['height'] = $data['height'];
|
||||
}
|
||||
|
||||
foreach ( $default_sizes as $default_size ) {
|
||||
if ( isset($backup_sizes["$default_size-orig"]) ) {
|
||||
$data = $backup_sizes["$default_size-orig"];
|
||||
if ( isset($meta['sizes'][$default_size]) && $meta['sizes'][$default_size]['file'] != $data['file'] ) {
|
||||
if ( defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE ) {
|
||||
if ( isset( $backup_sizes[ "$default_size-orig" ] ) ) {
|
||||
$data = $backup_sizes[ "$default_size-orig" ];
|
||||
if ( isset( $meta['sizes'][ $default_size ] ) && $meta['sizes'][ $default_size ]['file'] != $data['file'] ) {
|
||||
if ( defined( 'IMAGE_EDIT_OVERWRITE' ) && IMAGE_EDIT_OVERWRITE ) {
|
||||
|
||||
// Delete only if it's an edited image.
|
||||
if ( preg_match('/-e[0-9]{13}-/', $meta['sizes'][$default_size]['file']) ) {
|
||||
$delete_file = path_join( $parts['dirname'], $meta['sizes'][$default_size]['file'] );
|
||||
if ( preg_match( '/-e[0-9]{13}-/', $meta['sizes'][ $default_size ]['file'] ) ) {
|
||||
$delete_file = path_join( $parts['dirname'], $meta['sizes'][ $default_size ]['file'] );
|
||||
wp_delete_file( $delete_file );
|
||||
}
|
||||
} else {
|
||||
$backup_sizes["$default_size-{$suffix}"] = $meta['sizes'][$default_size];
|
||||
$backup_sizes[ "$default_size-{$suffix}" ] = $meta['sizes'][ $default_size ];
|
||||
}
|
||||
}
|
||||
|
||||
$meta['sizes'][$default_size] = $data;
|
||||
$meta['sizes'][ $default_size ] = $data;
|
||||
} else {
|
||||
unset($meta['sizes'][$default_size]);
|
||||
unset( $meta['sizes'][ $default_size ] );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! wp_update_attachment_metadata( $post_id, $meta ) ||
|
||||
( $old_backup_sizes !== $backup_sizes && ! update_post_meta( $post_id, '_wp_attachment_backup_sizes', $backup_sizes ) ) ) {
|
||||
|
||||
$msg->error = __('Cannot save image metadata.');
|
||||
$msg->error = __( 'Cannot save image metadata.' );
|
||||
return $msg;
|
||||
}
|
||||
|
||||
if ( !$restored )
|
||||
$msg->error = __('Image metadata is inconsistent.');
|
||||
else
|
||||
$msg->msg = __('Image restored successfully.');
|
||||
if ( ! $restored ) {
|
||||
$msg->error = __( 'Image metadata is inconsistent.' );
|
||||
} else {
|
||||
$msg->msg = __( 'Image restored successfully.' );
|
||||
}
|
||||
|
||||
return $msg;
|
||||
}
|
||||
|
@ -709,69 +739,72 @@ function wp_restore_image($post_id) {
|
|||
function wp_save_image( $post_id ) {
|
||||
$_wp_additional_image_sizes = wp_get_additional_image_sizes();
|
||||
|
||||
$return = new stdClass;
|
||||
$return = new stdClass;
|
||||
$success = $delete = $scaled = $nocrop = false;
|
||||
$post = get_post( $post_id );
|
||||
$post = get_post( $post_id );
|
||||
|
||||
$img = wp_get_image_editor( _load_image_to_edit_path( $post_id, 'full' ) );
|
||||
if ( is_wp_error( $img ) ) {
|
||||
$return->error = esc_js( __('Unable to create new image.') );
|
||||
$return->error = esc_js( __( 'Unable to create new image.' ) );
|
||||
return $return;
|
||||
}
|
||||
|
||||
$fwidth = !empty($_REQUEST['fwidth']) ? intval($_REQUEST['fwidth']) : 0;
|
||||
$fheight = !empty($_REQUEST['fheight']) ? intval($_REQUEST['fheight']) : 0;
|
||||
$target = !empty($_REQUEST['target']) ? preg_replace('/[^a-z0-9_-]+/i', '', $_REQUEST['target']) : '';
|
||||
$scale = !empty($_REQUEST['do']) && 'scale' == $_REQUEST['do'];
|
||||
$fwidth = ! empty( $_REQUEST['fwidth'] ) ? intval( $_REQUEST['fwidth'] ) : 0;
|
||||
$fheight = ! empty( $_REQUEST['fheight'] ) ? intval( $_REQUEST['fheight'] ) : 0;
|
||||
$target = ! empty( $_REQUEST['target'] ) ? preg_replace( '/[^a-z0-9_-]+/i', '', $_REQUEST['target'] ) : '';
|
||||
$scale = ! empty( $_REQUEST['do'] ) && 'scale' == $_REQUEST['do'];
|
||||
|
||||
if ( $scale && $fwidth > 0 && $fheight > 0 ) {
|
||||
$size = $img->get_size();
|
||||
$sX = $size['width'];
|
||||
$sY = $size['height'];
|
||||
$sX = $size['width'];
|
||||
$sY = $size['height'];
|
||||
|
||||
// Check if it has roughly the same w / h ratio.
|
||||
$diff = round($sX / $sY, 2) - round($fwidth / $fheight, 2);
|
||||
$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.') );
|
||||
if ( ! $scaled ) {
|
||||
$return->error = esc_js( __( 'Error while saving the scaled image. Please reload the page and try again.' ) );
|
||||
return $return;
|
||||
}
|
||||
} elseif ( !empty($_REQUEST['history']) ) {
|
||||
$changes = json_decode( wp_unslash($_REQUEST['history']) );
|
||||
if ( $changes )
|
||||
$img = image_edit_apply_changes($img, $changes);
|
||||
} elseif ( ! empty( $_REQUEST['history'] ) ) {
|
||||
$changes = json_decode( wp_unslash( $_REQUEST['history'] ) );
|
||||
if ( $changes ) {
|
||||
$img = image_edit_apply_changes( $img, $changes );
|
||||
}
|
||||
} else {
|
||||
$return->error = esc_js( __('Nothing to save, the image has not changed.') );
|
||||
$return->error = esc_js( __( 'Nothing to save, the image has not changed.' ) );
|
||||
return $return;
|
||||
}
|
||||
|
||||
$meta = wp_get_attachment_metadata($post_id);
|
||||
$meta = wp_get_attachment_metadata( $post_id );
|
||||
$backup_sizes = get_post_meta( $post->ID, '_wp_attachment_backup_sizes', true );
|
||||
|
||||
if ( !is_array($meta) ) {
|
||||
$return->error = esc_js( __('Image data does not exist. Please re-upload the image.') );
|
||||
if ( ! is_array( $meta ) ) {
|
||||
$return->error = esc_js( __( 'Image data does not exist. Please re-upload the image.' ) );
|
||||
return $return;
|
||||
}
|
||||
|
||||
if ( !is_array($backup_sizes) )
|
||||
if ( ! is_array( $backup_sizes ) ) {
|
||||
$backup_sizes = array();
|
||||
}
|
||||
|
||||
// Generate new filename.
|
||||
$path = get_attached_file( $post_id );
|
||||
|
||||
$basename = pathinfo( $path, PATHINFO_BASENAME );
|
||||
$dirname = pathinfo( $path, PATHINFO_DIRNAME );
|
||||
$ext = pathinfo( $path, PATHINFO_EXTENSION );
|
||||
$dirname = pathinfo( $path, PATHINFO_DIRNAME );
|
||||
$ext = pathinfo( $path, PATHINFO_EXTENSION );
|
||||
$filename = pathinfo( $path, PATHINFO_FILENAME );
|
||||
$suffix = time() . rand(100, 999);
|
||||
$suffix = time() . rand( 100, 999 );
|
||||
|
||||
if ( defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE &&
|
||||
isset($backup_sizes['full-orig']) && $backup_sizes['full-orig']['file'] != $basename ) {
|
||||
if ( defined( 'IMAGE_EDIT_OVERWRITE' ) && IMAGE_EDIT_OVERWRITE &&
|
||||
isset( $backup_sizes['full-orig'] ) && $backup_sizes['full-orig']['file'] != $basename ) {
|
||||
|
||||
if ( 'thumbnail' == $target ) {
|
||||
$new_path = "{$dirname}/{$filename}-temp.{$ext}";
|
||||
|
@ -780,11 +813,11 @@ function wp_save_image( $post_id ) {
|
|||
}
|
||||
} else {
|
||||
while ( true ) {
|
||||
$filename = preg_replace( '/-e([0-9]+)$/', '', $filename );
|
||||
$filename .= "-e{$suffix}";
|
||||
$filename = preg_replace( '/-e([0-9]+)$/', '', $filename );
|
||||
$filename .= "-e{$suffix}";
|
||||
$new_filename = "{$filename}.{$ext}";
|
||||
$new_path = "{$dirname}/$new_filename";
|
||||
if ( file_exists($new_path) ) {
|
||||
$new_path = "{$dirname}/$new_filename";
|
||||
if ( file_exists( $new_path ) ) {
|
||||
$suffix++;
|
||||
} else {
|
||||
break;
|
||||
|
@ -793,8 +826,8 @@ function wp_save_image( $post_id ) {
|
|||
}
|
||||
|
||||
// Save the full-size file, also needed to create sub-sizes.
|
||||
if ( !wp_save_image_file($new_path, $img, $post->post_mime_type, $post_id) ) {
|
||||
$return->error = esc_js( __('Unable to save the image.') );
|
||||
if ( ! wp_save_image_file( $new_path, $img, $post->post_mime_type, $post_id ) ) {
|
||||
$return->error = esc_js( __( 'Unable to save the image.' ) );
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
@ -809,26 +842,31 @@ 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 );
|
||||
|
||||
$meta['file'] = _wp_relative_upload_path( $new_path );
|
||||
|
||||
$size = $img->get_size();
|
||||
$meta['width'] = $size['width'];
|
||||
$size = $img->get_size();
|
||||
$meta['width'] = $size['width'];
|
||||
$meta['height'] = $size['height'];
|
||||
|
||||
if ( $success && ('nothumb' == $target || 'all' == $target) ) {
|
||||
if ( $success && ( 'nothumb' == $target || 'all' == $target ) ) {
|
||||
$sizes = get_intermediate_image_sizes();
|
||||
if ( 'nothumb' == $target )
|
||||
$sizes = array_diff( $sizes, array('thumbnail') );
|
||||
if ( 'nothumb' == $target ) {
|
||||
$sizes = array_diff( $sizes, array( 'thumbnail' ) );
|
||||
}
|
||||
}
|
||||
|
||||
$return->fw = $meta['width'];
|
||||
$return->fh = $meta['height'];
|
||||
} elseif ( 'thumbnail' == $target ) {
|
||||
$sizes = array( 'thumbnail' );
|
||||
$sizes = array( 'thumbnail' );
|
||||
$success = $delete = $nocrop = true;
|
||||
}
|
||||
|
||||
|
@ -852,16 +890,18 @@ function wp_save_image( $post_id ) {
|
|||
|
||||
foreach ( $sizes as $size ) {
|
||||
$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 ( 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'] ) {
|
||||
$tag = "$size-$suffix";
|
||||
}
|
||||
} else {
|
||||
$tag = "$size-orig";
|
||||
}
|
||||
|
||||
if ( $tag )
|
||||
$backup_sizes[$tag] = $meta['sizes'][$size];
|
||||
if ( $tag ) {
|
||||
$backup_sizes[ $tag ] = $meta['sizes'][ $size ];
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $_wp_additional_image_sizes[ $size ] ) ) {
|
||||
|
@ -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 ) );
|
||||
|
@ -884,17 +928,17 @@ function wp_save_image( $post_id ) {
|
|||
|
||||
if ( $success ) {
|
||||
wp_update_attachment_metadata( $post_id, $meta );
|
||||
update_post_meta( $post_id, '_wp_attachment_backup_sizes', $backup_sizes);
|
||||
update_post_meta( $post_id, '_wp_attachment_backup_sizes', $backup_sizes );
|
||||
|
||||
if ( $target == 'thumbnail' || $target == 'all' || $target == 'full' ) {
|
||||
// Check if it's an image edit from attachment edit screen
|
||||
if ( ! empty( $_REQUEST['context'] ) && 'edit-attachment' == $_REQUEST['context'] ) {
|
||||
$thumb_url = wp_get_attachment_image_src( $post_id, array( 900, 600 ), true );
|
||||
$thumb_url = wp_get_attachment_image_src( $post_id, array( 900, 600 ), true );
|
||||
$return->thumbnail = $thumb_url[0];
|
||||
} else {
|
||||
$file_url = wp_get_attachment_url($post_id);
|
||||
$file_url = wp_get_attachment_url( $post_id );
|
||||
if ( ! empty( $meta['sizes']['thumbnail'] ) && $thumb = $meta['sizes']['thumbnail'] ) {
|
||||
$return->thumbnail = path_join( dirname($file_url), $thumb['file'] );
|
||||
$return->thumbnail = path_join( dirname( $file_url ), $thumb['file'] );
|
||||
} else {
|
||||
$return->thumbnail = "$file_url?w=128&h=128";
|
||||
}
|
||||
|
@ -908,6 +952,6 @@ function wp_save_image( $post_id ) {
|
|||
wp_delete_file( $new_path );
|
||||
}
|
||||
|
||||
$return->msg = esc_js( __('Image saved') );
|
||||
$return->msg = esc_js( __( 'Image saved' ) );
|
||||
return $return;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
@ -74,46 +78,50 @@ function wp_crop_image( $src, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $s
|
|||
function wp_generate_attachment_metadata( $attachment_id, $file ) {
|
||||
$attachment = get_post( $attachment_id );
|
||||
|
||||
$metadata = array();
|
||||
$support = false;
|
||||
$metadata = array();
|
||||
$support = false;
|
||||
$mime_type = get_post_mime_type( $attachment );
|
||||
|
||||
if ( preg_match( '!^image/!', $mime_type ) && file_is_displayable_image( $file ) ) {
|
||||
$imagesize = getimagesize( $file );
|
||||
$metadata['width'] = $imagesize[0];
|
||||
$imagesize = getimagesize( $file );
|
||||
$metadata['width'] = $imagesize[0];
|
||||
$metadata['height'] = $imagesize[1];
|
||||
|
||||
// Make the file path relative to the upload dir.
|
||||
$metadata['file'] = _wp_relative_upload_path($file);
|
||||
$metadata['file'] = _wp_relative_upload_path( $file );
|
||||
|
||||
// Make thumbnails and other intermediate sizes.
|
||||
$_wp_additional_image_sizes = wp_get_additional_image_sizes();
|
||||
|
||||
$sizes = array();
|
||||
foreach ( get_intermediate_image_sizes() as $s ) {
|
||||
$sizes[$s] = array( 'width' => '', 'height' => '', 'crop' => false );
|
||||
if ( isset( $_wp_additional_image_sizes[$s]['width'] ) ) {
|
||||
$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'] );
|
||||
$sizes[ $s ]['width'] = intval( $_wp_additional_image_sizes[ $s ]['width'] );
|
||||
} else {
|
||||
// For default sizes set in options
|
||||
$sizes[$s]['width'] = get_option( "{$s}_size_w" );
|
||||
$sizes[ $s ]['width'] = get_option( "{$s}_size_w" );
|
||||
}
|
||||
|
||||
if ( isset( $_wp_additional_image_sizes[$s]['height'] ) ) {
|
||||
if ( isset( $_wp_additional_image_sizes[ $s ]['height'] ) ) {
|
||||
// For theme-added sizes
|
||||
$sizes[$s]['height'] = intval( $_wp_additional_image_sizes[$s]['height'] );
|
||||
$sizes[ $s ]['height'] = intval( $_wp_additional_image_sizes[ $s ]['height'] );
|
||||
} else {
|
||||
// For default sizes set in options
|
||||
$sizes[$s]['height'] = get_option( "{$s}_size_h" );
|
||||
$sizes[ $s ]['height'] = get_option( "{$s}_size_h" );
|
||||
}
|
||||
|
||||
if ( isset( $_wp_additional_image_sizes[$s]['crop'] ) ) {
|
||||
if ( isset( $_wp_additional_image_sizes[ $s ]['crop'] ) ) {
|
||||
// For theme-added sizes
|
||||
$sizes[$s]['crop'] = $_wp_additional_image_sizes[$s]['crop'];
|
||||
$sizes[ $s ]['crop'] = $_wp_additional_image_sizes[ $s ]['crop'];
|
||||
} else {
|
||||
// For default sizes set in options
|
||||
$sizes[$s]['crop'] = get_option( "{$s}_crop" );
|
||||
$sizes[ $s ]['crop'] = get_option( "{$s}_crop" );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -131,37 +139,40 @@ 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' );
|
||||
$support = current_theme_supports( 'post-thumbnails', 'attachment:video' ) || post_type_supports( 'attachment:video', 'thumbnail' );
|
||||
} elseif ( wp_attachment_is( 'audio', $attachment ) ) {
|
||||
$metadata = wp_read_audio_metadata( $file );
|
||||
$support = current_theme_supports( 'post-thumbnails', 'attachment:audio' ) || post_type_supports( 'attachment:audio', 'thumbnail' );
|
||||
$support = current_theme_supports( 'post-thumbnails', 'attachment:audio' ) || post_type_supports( 'attachment:audio', 'thumbnail' );
|
||||
}
|
||||
|
||||
if ( $support && ! empty( $metadata['image']['data'] ) ) {
|
||||
// Check for existing cover.
|
||||
$hash = md5( $metadata['image']['data'] );
|
||||
$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
|
||||
) );
|
||||
$hash = md5( $metadata['image']['data'] );
|
||||
$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,
|
||||
)
|
||||
);
|
||||
$exists = reset( $posts );
|
||||
|
||||
if ( ! empty( $exists ) ) {
|
||||
|
@ -169,20 +180,20 @@ function wp_generate_attachment_metadata( $attachment_id, $file ) {
|
|||
} else {
|
||||
$ext = '.jpg';
|
||||
switch ( $metadata['image']['mime'] ) {
|
||||
case 'image/gif':
|
||||
$ext = '.gif';
|
||||
break;
|
||||
case 'image/png':
|
||||
$ext = '.png';
|
||||
break;
|
||||
case 'image/gif':
|
||||
$ext = '.gif';
|
||||
break;
|
||||
case 'image/png':
|
||||
$ext = '.png';
|
||||
break;
|
||||
}
|
||||
$basename = str_replace( '.', '-', basename( $file ) ) . '-image' . $ext;
|
||||
$uploaded = wp_upload_bits( $basename, '', $metadata['image']['data'] );
|
||||
if ( false === $uploaded['error'] ) {
|
||||
$image_attachment = array(
|
||||
'post_mime_type' => $metadata['image']['mime'],
|
||||
'post_type' => 'attachment',
|
||||
'post_content' => '',
|
||||
'post_type' => 'attachment',
|
||||
'post_content' => '',
|
||||
);
|
||||
/**
|
||||
* Filters the parameters for the attachment thumbnail creation.
|
||||
|
@ -202,9 +213,8 @@ 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
|
||||
else if ( 'application/pdf' === $mime_type ) {
|
||||
} // Try to create image thumbnails for PDFs
|
||||
elseif ( 'application/pdf' === $mime_type ) {
|
||||
$fallback_sizes = array(
|
||||
'thumbnail',
|
||||
'medium',
|
||||
|
@ -221,7 +231,7 @@ function wp_generate_attachment_metadata( $attachment_id, $file ) {
|
|||
*/
|
||||
$fallback_sizes = apply_filters( 'fallback_intermediate_image_sizes', $fallback_sizes, $metadata );
|
||||
|
||||
$sizes = array();
|
||||
$sizes = array();
|
||||
$_wp_additional_image_sizes = wp_get_additional_image_sizes();
|
||||
|
||||
foreach ( $fallback_sizes as $s ) {
|
||||
|
@ -256,8 +266,8 @@ function wp_generate_attachment_metadata( $attachment_id, $file ) {
|
|||
* PDFs may have the same file filename as JPEGs.
|
||||
* Ensure the PDF preview image does not overwrite any JPEG images that already exist.
|
||||
*/
|
||||
$dirname = dirname( $file ) . '/';
|
||||
$ext = '.' . pathinfo( $file, PATHINFO_EXTENSION );
|
||||
$dirname = dirname( $file ) . '/';
|
||||
$ext = '.' . pathinfo( $file, PATHINFO_EXTENSION );
|
||||
$preview_file = $dirname . wp_unique_filename( $dirname, wp_basename( $file, $ext ) . '-pdf.jpg' );
|
||||
|
||||
$uploaded = $editor->save( $preview_file, 'image/jpeg' );
|
||||
|
@ -269,7 +279,7 @@ function wp_generate_attachment_metadata( $attachment_id, $file ) {
|
|||
unset( $uploaded['path'] );
|
||||
|
||||
if ( ! is_wp_error( $editor ) ) {
|
||||
$metadata['sizes'] = $editor->multi_resize( $sizes );
|
||||
$metadata['sizes'] = $editor->multi_resize( $sizes );
|
||||
$metadata['sizes']['full'] = $uploaded;
|
||||
}
|
||||
}
|
||||
|
@ -301,10 +311,11 @@ function wp_generate_attachment_metadata( $attachment_id, $file ) {
|
|||
* @param string $str
|
||||
* @return int|float
|
||||
*/
|
||||
function wp_exif_frac2dec($str) {
|
||||
function wp_exif_frac2dec( $str ) {
|
||||
@list( $n, $d ) = explode( '/', $str );
|
||||
if ( !empty($d) )
|
||||
if ( ! empty( $d ) ) {
|
||||
return $n / $d;
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
|
@ -316,9 +327,9 @@ function wp_exif_frac2dec($str) {
|
|||
* @param string $str
|
||||
* @return int
|
||||
*/
|
||||
function wp_exif_date2ts($str) {
|
||||
@list( $date, $time ) = explode( ' ', trim($str) );
|
||||
@list( $y, $m, $d ) = explode( ':', $date );
|
||||
function wp_exif_date2ts( $str ) {
|
||||
@list( $date, $time ) = explode( ' ', trim( $str ) );
|
||||
@list( $y, $m, $d ) = explode( ':', $date );
|
||||
|
||||
return strtotime( "{$y}-{$m}-{$d} {$time}" );
|
||||
}
|
||||
|
@ -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 );
|
||||
|
||||
|
@ -352,18 +364,18 @@ function wp_read_image_metadata( $file ) {
|
|||
* floats, dates to unix timestamps, and everything else to strings.
|
||||
*/
|
||||
$meta = array(
|
||||
'aperture' => 0,
|
||||
'credit' => '',
|
||||
'camera' => '',
|
||||
'caption' => '',
|
||||
'aperture' => 0,
|
||||
'credit' => '',
|
||||
'camera' => '',
|
||||
'caption' => '',
|
||||
'created_timestamp' => 0,
|
||||
'copyright' => '',
|
||||
'focal_length' => 0,
|
||||
'iso' => 0,
|
||||
'shutter_speed' => 0,
|
||||
'title' => '',
|
||||
'orientation' => 0,
|
||||
'keywords' => array(),
|
||||
'copyright' => '',
|
||||
'focal_length' => 0,
|
||||
'iso' => 0,
|
||||
'shutter_speed' => 0,
|
||||
'title' => '',
|
||||
'orientation' => 0,
|
||||
'keywords' => array(),
|
||||
);
|
||||
|
||||
$iptc = array();
|
||||
|
@ -380,10 +392,10 @@ function wp_read_image_metadata( $file ) {
|
|||
// Headline, "A brief synopsis of the caption."
|
||||
if ( ! empty( $iptc['2#105'][0] ) ) {
|
||||
$meta['title'] = trim( $iptc['2#105'][0] );
|
||||
/*
|
||||
* Title, "Many use the Title field to store the filename of the image,
|
||||
* though the field may be used in many ways."
|
||||
*/
|
||||
/*
|
||||
* Title, "Many use the Title field to store the filename of the image,
|
||||
* though the field may be used in many ways."
|
||||
*/
|
||||
} elseif ( ! empty( $iptc['2#005'][0] ) ) {
|
||||
$meta['title'] = trim( $iptc['2#005'][0] );
|
||||
}
|
||||
|
@ -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'] );
|
||||
|
@ -454,7 +469,7 @@ function wp_read_image_metadata( $file ) {
|
|||
if ( empty( $meta['credit'] ) ) {
|
||||
if ( ! empty( $exif['Artist'] ) ) {
|
||||
$meta['credit'] = trim( $exif['Artist'] );
|
||||
} elseif ( ! empty($exif['Author'] ) ) {
|
||||
} elseif ( ! empty( $exif['Author'] ) ) {
|
||||
$meta['credit'] = trim( $exif['Author'] );
|
||||
}
|
||||
}
|
||||
|
@ -523,9 +538,9 @@ function wp_read_image_metadata( $file ) {
|
|||
* @param string $path File path to test if valid image.
|
||||
* @return bool True if valid image, false if not valid image.
|
||||
*/
|
||||
function file_is_valid_image($path) {
|
||||
$size = @getimagesize($path);
|
||||
return !empty($size);
|
||||
function file_is_valid_image( $path ) {
|
||||
$size = @getimagesize( $path );
|
||||
return ! empty( $size );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -536,7 +551,7 @@ function file_is_valid_image($path) {
|
|||
* @param string $path File path to test.
|
||||
* @return bool True if suitable, false if not suitable.
|
||||
*/
|
||||
function file_is_displayable_image($path) {
|
||||
function file_is_displayable_image( $path ) {
|
||||
$displayable_image_types = array( IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_BMP );
|
||||
|
||||
$info = @getimagesize( $path );
|
||||
|
@ -571,24 +586,25 @@ 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':
|
||||
$image = imagecreatefromjpeg($filepath);
|
||||
$image = imagecreatefromjpeg( $filepath );
|
||||
break;
|
||||
case 'image/png':
|
||||
$image = imagecreatefrompng($filepath);
|
||||
$image = imagecreatefrompng( $filepath );
|
||||
break;
|
||||
case 'image/gif':
|
||||
$image = imagecreatefromgif($filepath);
|
||||
$image = imagecreatefromgif( $filepath );
|
||||
break;
|
||||
default:
|
||||
$image = false;
|
||||
break;
|
||||
}
|
||||
if ( is_resource($image) ) {
|
||||
if ( is_resource( $image ) ) {
|
||||
/**
|
||||
* Filters the current image being loaded for editing.
|
||||
*
|
||||
|
@ -599,9 +615,9 @@ function load_image_to_edit( $attachment_id, $mime_type, $size = 'full' ) {
|
|||
* @param string $size Image size.
|
||||
*/
|
||||
$image = apply_filters( 'load_image_to_edit', $image, $attachment_id, $size );
|
||||
if ( function_exists('imagealphablending') && function_exists('imagesavealpha') ) {
|
||||
imagealphablending($image, false);
|
||||
imagesavealpha($image, true);
|
||||
if ( function_exists( 'imagealphablending' ) && function_exists( 'imagesavealpha' ) ) {
|
||||
imagealphablending( $image, false );
|
||||
imagesavealpha( $image, true );
|
||||
}
|
||||
}
|
||||
return $image;
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -53,9 +53,10 @@ 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 );
|
||||
}
|
||||
$wp_importers[ $id ] = array( $name, $description, $callback );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -81,13 +82,16 @@ 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 );
|
||||
$upload = wp_handle_upload( $_FILES['import'], $overrides );
|
||||
|
||||
if ( isset( $upload['error'] ) ) {
|
||||
return $upload;
|
||||
|
@ -95,12 +99,12 @@ function wp_import_handle_upload() {
|
|||
|
||||
// Construct the object array
|
||||
$object = array(
|
||||
'post_title' => basename( $upload['file'] ),
|
||||
'post_content' => $upload['url'],
|
||||
'post_title' => basename( $upload['file'] ),
|
||||
'post_content' => $upload['url'],
|
||||
'post_mime_type' => $upload['type'],
|
||||
'guid' => $upload['url'],
|
||||
'context' => 'import',
|
||||
'post_status' => 'private'
|
||||
'guid' => $upload['url'],
|
||||
'context' => 'import',
|
||||
'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,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -125,22 +132,24 @@ function wp_import_handle_upload() {
|
|||
function wp_get_popular_importers() {
|
||||
include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version
|
||||
|
||||
$locale = get_user_locale();
|
||||
$cache_key = 'popular_importers_' . md5( $locale . $wp_version );
|
||||
$locale = get_user_locale();
|
||||
$cache_key = 'popular_importers_' . md5( $locale . $wp_version );
|
||||
$popular_importers = get_site_transient( $cache_key );
|
||||
|
||||
if ( ! $popular_importers ) {
|
||||
$url = add_query_arg( array(
|
||||
'locale' => $locale,
|
||||
'version' => $wp_version,
|
||||
), 'http://api.wordpress.org/core/importers/1.1/' );
|
||||
$url = add_query_arg(
|
||||
array(
|
||||
'locale' => $locale,
|
||||
'version' => $wp_version,
|
||||
), 'http://api.wordpress.org/core/importers/1.1/'
|
||||
);
|
||||
$options = array( 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ) );
|
||||
|
||||
if ( wp_http_supports( array( 'ssl' ) ) ) {
|
||||
$url = set_url_scheme( $url, 'https' );
|
||||
}
|
||||
|
||||
$response = wp_remote_get( $url, $options );
|
||||
$response = wp_remote_get( $url, $options );
|
||||
$popular_importers = json_decode( wp_remote_retrieve_body( $response ), true );
|
||||
|
||||
if ( is_array( $popular_importers ) ) {
|
||||
|
@ -152,63 +161,65 @@ 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'];
|
||||
}
|
||||
|
||||
return array(
|
||||
// slug => name, description, plugin slug, and register_importer() slug
|
||||
'blogger' => array(
|
||||
'name' => __( 'Blogger' ),
|
||||
'blogger' => array(
|
||||
'name' => __( 'Blogger' ),
|
||||
'description' => __( 'Import posts, comments, and users from a Blogger blog.' ),
|
||||
'plugin-slug' => 'blogger-importer',
|
||||
'importer-id' => 'blogger',
|
||||
),
|
||||
'wpcat2tag' => array(
|
||||
'name' => __( 'Categories and Tags Converter' ),
|
||||
'wpcat2tag' => array(
|
||||
'name' => __( 'Categories and Tags Converter' ),
|
||||
'description' => __( 'Convert existing categories to tags or tags to categories, selectively.' ),
|
||||
'plugin-slug' => 'wpcat2tag-importer',
|
||||
'importer-id' => 'wp-cat2tag',
|
||||
),
|
||||
'livejournal' => array(
|
||||
'name' => __( 'LiveJournal' ),
|
||||
'name' => __( 'LiveJournal' ),
|
||||
'description' => __( 'Import posts from LiveJournal using their API.' ),
|
||||
'plugin-slug' => 'livejournal-importer',
|
||||
'importer-id' => 'livejournal',
|
||||
),
|
||||
'movabletype' => array(
|
||||
'name' => __( 'Movable Type and TypePad' ),
|
||||
'name' => __( 'Movable Type and TypePad' ),
|
||||
'description' => __( 'Import posts and comments from a Movable Type or TypePad blog.' ),
|
||||
'plugin-slug' => 'movabletype-importer',
|
||||
'importer-id' => 'mt',
|
||||
),
|
||||
'opml' => array(
|
||||
'name' => __( 'Blogroll' ),
|
||||
'opml' => array(
|
||||
'name' => __( 'Blogroll' ),
|
||||
'description' => __( 'Import links in OPML format.' ),
|
||||
'plugin-slug' => 'opml-importer',
|
||||
'importer-id' => 'opml',
|
||||
),
|
||||
'rss' => array(
|
||||
'name' => __( 'RSS' ),
|
||||
'rss' => array(
|
||||
'name' => __( 'RSS' ),
|
||||
'description' => __( 'Import posts from an RSS feed.' ),
|
||||
'plugin-slug' => 'rss-importer',
|
||||
'importer-id' => 'rss',
|
||||
),
|
||||
'tumblr' => array(
|
||||
'name' => __( 'Tumblr' ),
|
||||
'tumblr' => array(
|
||||
'name' => __( 'Tumblr' ),
|
||||
'description' => __( 'Import posts & media from Tumblr using their API.' ),
|
||||
'plugin-slug' => 'tumblr-importer',
|
||||
'importer-id' => 'tumblr',
|
||||
),
|
||||
'wordpress' => array(
|
||||
'name' => 'WordPress',
|
||||
'wordpress' => array(
|
||||
'name' => 'WordPress',
|
||||
'description' => __( 'Import posts, pages, comments, custom fields, categories, and tags from a WordPress export file.' ),
|
||||
'plugin-slug' => 'wordpress-importer',
|
||||
'importer-id' => 'wordpress',
|
||||
|
|
|
@ -22,33 +22,35 @@
|
|||
function _get_list_table( $class, $args = array() ) {
|
||||
$core_classes = array(
|
||||
//Site Admin
|
||||
'WP_Posts_List_Table' => 'posts',
|
||||
'WP_Media_List_Table' => 'media',
|
||||
'WP_Terms_List_Table' => 'terms',
|
||||
'WP_Users_List_Table' => 'users',
|
||||
'WP_Comments_List_Table' => 'comments',
|
||||
'WP_Post_Comments_List_Table' => array( 'comments', 'post-comments' ),
|
||||
'WP_Links_List_Table' => 'links',
|
||||
'WP_Posts_List_Table' => 'posts',
|
||||
'WP_Media_List_Table' => 'media',
|
||||
'WP_Terms_List_Table' => 'terms',
|
||||
'WP_Users_List_Table' => 'users',
|
||||
'WP_Comments_List_Table' => 'comments',
|
||||
'WP_Post_Comments_List_Table' => array( 'comments', 'post-comments' ),
|
||||
'WP_Links_List_Table' => 'links',
|
||||
'WP_Plugin_Install_List_Table' => 'plugin-install',
|
||||
'WP_Themes_List_Table' => 'themes',
|
||||
'WP_Theme_Install_List_Table' => array( 'themes', 'theme-install' ),
|
||||
'WP_Plugins_List_Table' => 'plugins',
|
||||
'WP_Themes_List_Table' => 'themes',
|
||||
'WP_Theme_Install_List_Table' => array( 'themes', 'theme-install' ),
|
||||
'WP_Plugins_List_Table' => 'plugins',
|
||||
// Network Admin
|
||||
'WP_MS_Sites_List_Table' => 'ms-sites',
|
||||
'WP_MS_Users_List_Table' => 'ms-users',
|
||||
'WP_MS_Themes_List_Table' => 'ms-themes',
|
||||
'WP_MS_Sites_List_Table' => 'ms-sites',
|
||||
'WP_MS_Users_List_Table' => 'ms-users',
|
||||
'WP_MS_Themes_List_Table' => 'ms-themes',
|
||||
);
|
||||
|
||||
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 );
|
||||
}
|
||||
|
@ -65,7 +67,7 @@ function _get_list_table( $class, $args = array() ) {
|
|||
* @param array $columns An array of columns with column IDs as the keys and translated column names as the values
|
||||
* @see get_column_headers(), print_column_headers(), get_hidden_columns()
|
||||
*/
|
||||
function register_column_headers($screen, $columns) {
|
||||
function register_column_headers( $screen, $columns ) {
|
||||
new _WP_List_Table_Compat( $screen, $columns );
|
||||
}
|
||||
|
||||
|
@ -78,7 +80,7 @@ function register_column_headers($screen, $columns) {
|
|||
* @param bool $with_id Whether to set the id attribute or not.
|
||||
*/
|
||||
function print_column_headers( $screen, $with_id = true ) {
|
||||
$wp_list_table = new _WP_List_Table_Compat($screen);
|
||||
$wp_list_table = new _WP_List_Table_Compat( $screen );
|
||||
|
||||
$wp_list_table->print_column_headers( $with_id );
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -42,48 +42,51 @@ if ( is_network_admin() ) {
|
|||
}
|
||||
|
||||
// Create list of page plugin hook names.
|
||||
foreach ($menu as $menu_page) {
|
||||
if ( false !== $pos = strpos($menu_page[2], '?') ) {
|
||||
foreach ( $menu as $menu_page ) {
|
||||
if ( false !== $pos = strpos( $menu_page[2], '?' ) ) {
|
||||
// Handle post_type=post|page|foo pages.
|
||||
$hook_name = substr($menu_page[2], 0, $pos);
|
||||
$hook_args = substr($menu_page[2], $pos + 1);
|
||||
wp_parse_str($hook_args, $hook_args);
|
||||
$hook_name = substr( $menu_page[2], 0, $pos );
|
||||
$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
|
||||
$hook_name = basename($hook_name, '.php');
|
||||
unset($hook_args);
|
||||
} else {
|
||||
$hook_name = basename( $hook_name, '.php' );
|
||||
}
|
||||
unset( $hook_args );
|
||||
} else {
|
||||
$hook_name = basename($menu_page[2], '.php');
|
||||
$hook_name = basename( $menu_page[2], '.php' );
|
||||
}
|
||||
$hook_name = sanitize_title($hook_name);
|
||||
$hook_name = sanitize_title( $hook_name );
|
||||
|
||||
if ( isset($compat[$hook_name]) )
|
||||
$hook_name = $compat[$hook_name];
|
||||
elseif ( !$hook_name )
|
||||
if ( isset( $compat[ $hook_name ] ) ) {
|
||||
$hook_name = $compat[ $hook_name ];
|
||||
} elseif ( ! $hook_name ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$admin_page_hooks[$menu_page[2]] = $hook_name;
|
||||
$admin_page_hooks[ $menu_page[2] ] = $hook_name;
|
||||
}
|
||||
unset($menu_page, $compat);
|
||||
unset( $menu_page, $compat );
|
||||
|
||||
$_wp_submenu_nopriv = array();
|
||||
$_wp_menu_nopriv = array();
|
||||
$_wp_menu_nopriv = array();
|
||||
// Loop over submenus and remove pages for which the user does not have privs.
|
||||
foreach ($submenu as $parent => $sub) {
|
||||
foreach ($sub as $index => $data) {
|
||||
if ( ! current_user_can($data[1]) ) {
|
||||
unset($submenu[$parent][$index]);
|
||||
$_wp_submenu_nopriv[$parent][$data[2]] = true;
|
||||
foreach ( $submenu as $parent => $sub ) {
|
||||
foreach ( $sub as $index => $data ) {
|
||||
if ( ! current_user_can( $data[1] ) ) {
|
||||
unset( $submenu[ $parent ][ $index ] );
|
||||
$_wp_submenu_nopriv[ $parent ][ $data[2] ] = true;
|
||||
}
|
||||
}
|
||||
unset($index, $data);
|
||||
unset( $index, $data );
|
||||
|
||||
if ( empty($submenu[$parent]) )
|
||||
unset($submenu[$parent]);
|
||||
if ( empty( $submenu[ $parent ] ) ) {
|
||||
unset( $submenu[ $parent ] );
|
||||
}
|
||||
}
|
||||
unset($sub, $parent);
|
||||
unset( $sub, $parent );
|
||||
|
||||
/*
|
||||
* Loop over the top-level menu.
|
||||
|
@ -91,10 +94,11 @@ 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 );
|
||||
}
|
||||
$subs = $submenu[ $data[2] ];
|
||||
$first_sub = reset( $subs );
|
||||
$old_parent = $data[2];
|
||||
$new_parent = $first_sub[2];
|
||||
/*
|
||||
|
@ -102,20 +106,21 @@ foreach ( $menu as $id => $data ) {
|
|||
* make the first submenu the new parent.
|
||||
*/
|
||||
if ( $new_parent != $old_parent ) {
|
||||
$_wp_real_parent_file[$old_parent] = $new_parent;
|
||||
$menu[$id][2] = $new_parent;
|
||||
$_wp_real_parent_file[ $old_parent ] = $new_parent;
|
||||
$menu[ $id ][2] = $new_parent;
|
||||
|
||||
foreach ($submenu[$old_parent] as $index => $data) {
|
||||
$submenu[$new_parent][$index] = $submenu[$old_parent][$index];
|
||||
unset($submenu[$old_parent][$index]);
|
||||
foreach ( $submenu[ $old_parent ] as $index => $data ) {
|
||||
$submenu[ $new_parent ][ $index ] = $submenu[ $old_parent ][ $index ];
|
||||
unset( $submenu[ $old_parent ][ $index ] );
|
||||
}
|
||||
unset($submenu[$old_parent], $index);
|
||||
unset( $submenu[ $old_parent ], $index );
|
||||
|
||||
if ( isset($_wp_submenu_nopriv[$old_parent]) )
|
||||
$_wp_submenu_nopriv[$new_parent] = $_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);
|
||||
unset( $id, $data, $subs, $first_sub, $old_parent, $new_parent );
|
||||
|
||||
if ( is_network_admin() ) {
|
||||
|
||||
|
@ -154,75 +159,75 @@ 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]) )
|
||||
$_wp_menu_nopriv[$data[2]] = true;
|
||||
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,
|
||||
* remove the submenu.
|
||||
*/
|
||||
if ( ! empty( $submenu[$data[2]] ) && 1 == count ( $submenu[$data[2]] ) ) {
|
||||
$subs = $submenu[$data[2]];
|
||||
if ( ! empty( $submenu[ $data[2] ] ) && 1 == count( $submenu[ $data[2] ] ) ) {
|
||||
$subs = $submenu[ $data[2] ];
|
||||
$first_sub = reset( $subs );
|
||||
if ( $data[2] == $first_sub[2] )
|
||||
unset( $submenu[$data[2]] );
|
||||
if ( $data[2] == $first_sub[2] ) {
|
||||
unset( $submenu[ $data[2] ] );
|
||||
}
|
||||
}
|
||||
|
||||
// If submenu is empty...
|
||||
if ( empty($submenu[$data[2]]) ) {
|
||||
if ( empty( $submenu[ $data[2] ] ) ) {
|
||||
// And user doesn't have privs, remove menu.
|
||||
if ( isset( $_wp_menu_nopriv[$data[2]] ) ) {
|
||||
unset($menu[$id]);
|
||||
if ( isset( $_wp_menu_nopriv[ $data[2] ] ) ) {
|
||||
unset( $menu[ $id ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($id, $data, $subs, $first_sub);
|
||||
unset( $id, $data, $subs, $first_sub );
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $add
|
||||
* @param string $class
|
||||
* @return string
|
||||
*/
|
||||
function add_cssclass($add, $class) {
|
||||
$class = empty($class) ? $add : $class .= ' ' . $add;
|
||||
function add_cssclass( $add, $class ) {
|
||||
$class = empty( $class ) ? $add : $class .= ' ' . $add;
|
||||
return $class;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $menu
|
||||
* @return array
|
||||
*/
|
||||
function add_menu_classes($menu) {
|
||||
function add_menu_classes( $menu ) {
|
||||
$first = $lastorder = false;
|
||||
$i = 0;
|
||||
$mc = count($menu);
|
||||
$i = 0;
|
||||
$mc = count( $menu );
|
||||
foreach ( $menu as $order => $top ) {
|
||||
$i++;
|
||||
|
||||
if ( 0 == $order ) { // dashboard is always shown/single
|
||||
$menu[0][4] = add_cssclass('menu-top-first', $top[4]);
|
||||
$lastorder = 0;
|
||||
$menu[0][4] = add_cssclass( 'menu-top-first', $top[4] );
|
||||
$lastorder = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( 0 === strpos($top[2], 'separator') && false !== $lastorder ) { // if separator
|
||||
$first = true;
|
||||
$c = $menu[$lastorder][4];
|
||||
$menu[$lastorder][4] = add_cssclass('menu-top-last', $c);
|
||||
if ( 0 === strpos( $top[2], 'separator' ) && false !== $lastorder ) { // if separator
|
||||
$first = true;
|
||||
$c = $menu[ $lastorder ][4];
|
||||
$menu[ $lastorder ][4] = add_cssclass( 'menu-top-last', $c );
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( $first ) {
|
||||
$c = $menu[$order][4];
|
||||
$menu[$order][4] = add_cssclass('menu-top-first', $c);
|
||||
$first = false;
|
||||
$c = $menu[ $order ][4];
|
||||
$menu[ $order ][4] = add_cssclass( 'menu-top-first', $c );
|
||||
$first = false;
|
||||
}
|
||||
|
||||
if ( $mc == $i ) { // last item
|
||||
$c = $menu[$order][4];
|
||||
$menu[$order][4] = add_cssclass('menu-top-last', $c);
|
||||
$c = $menu[ $order ][4];
|
||||
$menu[ $order ][4] = add_cssclass( 'menu-top-last', $c );
|
||||
}
|
||||
|
||||
$lastorder = $order;
|
||||
|
@ -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.
|
||||
|
@ -254,7 +259,7 @@ if ( apply_filters( 'custom_menu_order', false ) ) {
|
|||
foreach ( $menu as $menu_item ) {
|
||||
$menu_order[] = $menu_item[2];
|
||||
}
|
||||
unset($menu_item);
|
||||
unset( $menu_item );
|
||||
$default_menu_order = $menu_order;
|
||||
|
||||
/**
|
||||
|
@ -269,12 +274,11 @@ if ( apply_filters( 'custom_menu_order', false ) ) {
|
|||
*
|
||||
* @param array $menu_order An ordered array of menu items.
|
||||
*/
|
||||
$menu_order = apply_filters( 'menu_order', $menu_order );
|
||||
$menu_order = array_flip($menu_order);
|
||||
$default_menu_order = array_flip($default_menu_order);
|
||||
$menu_order = apply_filters( 'menu_order', $menu_order );
|
||||
$menu_order = array_flip( $menu_order );
|
||||
$default_menu_order = array_flip( $default_menu_order );
|
||||
|
||||
/**
|
||||
*
|
||||
* @global array $menu_order
|
||||
* @global array $default_menu_order
|
||||
*
|
||||
|
@ -282,25 +286,26 @@ if ( apply_filters( 'custom_menu_order', false ) ) {
|
|||
* @param array $b
|
||||
* @return int
|
||||
*/
|
||||
function sort_menu($a, $b) {
|
||||
function sort_menu( $a, $b ) {
|
||||
global $menu_order, $default_menu_order;
|
||||
$a = $a[2];
|
||||
$b = $b[2];
|
||||
if ( isset($menu_order[$a]) && !isset($menu_order[$b]) ) {
|
||||
if ( isset( $menu_order[ $a ] ) && ! isset( $menu_order[ $b ] ) ) {
|
||||
return -1;
|
||||
} elseif ( !isset($menu_order[$a]) && isset($menu_order[$b]) ) {
|
||||
} 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] )
|
||||
} elseif ( isset( $menu_order[ $a ] ) && isset( $menu_order[ $b ] ) ) {
|
||||
if ( $menu_order[ $a ] == $menu_order[ $b ] ) {
|
||||
return 0;
|
||||
return ($menu_order[$a] < $menu_order[$b]) ? -1 : 1;
|
||||
}
|
||||
return ( $menu_order[ $a ] < $menu_order[ $b ] ) ? -1 : 1;
|
||||
} else {
|
||||
return ($default_menu_order[$a] <= $default_menu_order[$b]) ? -1 : 1;
|
||||
return ( $default_menu_order[ $a ] <= $default_menu_order[ $b ] ) ? -1 : 1;
|
||||
}
|
||||
}
|
||||
|
||||
usort($menu, 'sort_menu');
|
||||
unset($menu_order, $default_menu_order);
|
||||
usort( $menu, 'sort_menu' );
|
||||
unset( $menu_order, $default_menu_order );
|
||||
}
|
||||
|
||||
// Prevent adjacent separators
|
||||
|
@ -326,11 +331,12 @@ 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() ) {
|
||||
if ( ! user_can_access_admin_page() ) {
|
||||
|
||||
/**
|
||||
* Fires when access to an admin page is denied.
|
||||
|
@ -342,4 +348,4 @@ if ( !user_can_access_admin_page() ) {
|
|||
wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
|
||||
}
|
||||
|
||||
$menu = add_menu_classes($menu);
|
||||
$menu = add_menu_classes( $menu );
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -14,7 +14,7 @@
|
|||
* @return bool
|
||||
*/
|
||||
function got_mod_rewrite() {
|
||||
$got_rewrite = apache_mod_loaded('mod_rewrite', true);
|
||||
$got_rewrite = apache_mod_loaded( 'mod_rewrite', true );
|
||||
|
||||
/**
|
||||
* Filters whether Apache and mod_rewrite are present.
|
||||
|
@ -65,7 +65,7 @@ function got_url_rewrite() {
|
|||
* @return array An array of strings from a file (.htaccess ) from between BEGIN and END markers.
|
||||
*/
|
||||
function extract_from_markers( $filename, $marker ) {
|
||||
$result = array ();
|
||||
$result = array();
|
||||
|
||||
if ( ! file_exists( $filename ) ) {
|
||||
return $result;
|
||||
|
@ -136,7 +136,7 @@ function insert_with_markers( $filename, $marker, $insertion ) {
|
|||
}
|
||||
|
||||
// Split out the existing file into the preceding lines, and those that appear after the marker
|
||||
$pre_lines = $post_lines = $existing_lines = array();
|
||||
$pre_lines = $post_lines = $existing_lines = array();
|
||||
$found_marker = $found_end_marker = false;
|
||||
foreach ( $lines as $line ) {
|
||||
if ( ! $found_marker && false !== strpos( $line, $start_marker ) ) {
|
||||
|
@ -164,13 +164,15 @@ function insert_with_markers( $filename, $marker, $insertion ) {
|
|||
}
|
||||
|
||||
// Generate the new file data
|
||||
$new_file_data = implode( "\n", array_merge(
|
||||
$pre_lines,
|
||||
array( $start_marker ),
|
||||
$insertion,
|
||||
array( $end_marker ),
|
||||
$post_lines
|
||||
) );
|
||||
$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,19 +198,20 @@ 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;
|
||||
|
||||
$home_path = get_home_path();
|
||||
$htaccess_file = $home_path.'.htaccess';
|
||||
$home_path = get_home_path();
|
||||
$htaccess_file = $home_path . '.htaccess';
|
||||
|
||||
/*
|
||||
* If the file doesn't already exist check for write access to the directory
|
||||
* and whether we have some rules. Else check for write access to the file.
|
||||
*/
|
||||
if ((!file_exists($htaccess_file) && is_writable($home_path) && $wp_rewrite->using_mod_rewrite_permalinks()) || is_writable($htaccess_file)) {
|
||||
if ( ( ! file_exists( $htaccess_file ) && is_writable( $home_path ) && $wp_rewrite->using_mod_rewrite_permalinks() ) || is_writable( $htaccess_file ) ) {
|
||||
if ( got_mod_rewrite() ) {
|
||||
$rules = explode( "\n", $wp_rewrite->mod_rewrite_rules() );
|
||||
return insert_with_markers( $htaccess_file, 'WordPress', $rules );
|
||||
|
@ -228,22 +231,23 @@ function save_mod_rewrite_rules() {
|
|||
*
|
||||
* @return bool True if web.config was updated successfully
|
||||
*/
|
||||
function iis7_save_url_rewrite_rules(){
|
||||
if ( is_multisite() )
|
||||
function iis7_save_url_rewrite_rules() {
|
||||
if ( is_multisite() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
global $wp_rewrite;
|
||||
|
||||
$home_path = get_home_path();
|
||||
$home_path = get_home_path();
|
||||
$web_config_file = $home_path . 'web.config';
|
||||
|
||||
// Using win_is_writable() instead of is_writable() because of a bug in Windows PHP
|
||||
if ( iis7_supports_permalinks() && ( ( ! file_exists($web_config_file) && win_is_writable($home_path) && $wp_rewrite->using_mod_rewrite_permalinks() ) || win_is_writable($web_config_file) ) ) {
|
||||
$rule = $wp_rewrite->iis7_url_rewrite_rules(false, '', '');
|
||||
if ( ! empty($rule) ) {
|
||||
return iis7_add_rewrite_rule($web_config_file, $rule);
|
||||
if ( iis7_supports_permalinks() && ( ( ! file_exists( $web_config_file ) && win_is_writable( $home_path ) && $wp_rewrite->using_mod_rewrite_permalinks() ) || win_is_writable( $web_config_file ) ) ) {
|
||||
$rule = $wp_rewrite->iis7_url_rewrite_rules( false, '', '' );
|
||||
if ( ! empty( $rule ) ) {
|
||||
return iis7_add_rewrite_rule( $web_config_file, $rule );
|
||||
} else {
|
||||
return iis7_delete_rewrite_rule($web_config_file);
|
||||
return iis7_delete_rewrite_rule( $web_config_file );
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -257,14 +261,15 @@ function iis7_save_url_rewrite_rules(){
|
|||
* @param string $file
|
||||
*/
|
||||
function update_recently_edited( $file ) {
|
||||
$oldfiles = (array ) get_option( 'recently_edited' );
|
||||
$oldfiles = (array) get_option( 'recently_edited' );
|
||||
if ( $oldfiles ) {
|
||||
$oldfiles = array_reverse( $oldfiles );
|
||||
$oldfiles = array_reverse( $oldfiles );
|
||||
$oldfiles[] = $file;
|
||||
$oldfiles = array_reverse( $oldfiles );
|
||||
$oldfiles = array_unique( $oldfiles );
|
||||
if ( 5 < count( $oldfiles ))
|
||||
$oldfiles = array_reverse( $oldfiles );
|
||||
$oldfiles = array_unique( $oldfiles );
|
||||
if ( 5 < count( $oldfiles ) ) {
|
||||
array_pop( $oldfiles );
|
||||
}
|
||||
} else {
|
||||
$oldfiles[] = $file;
|
||||
}
|
||||
|
@ -283,7 +288,7 @@ function update_recently_edited( $file ) {
|
|||
function wp_make_theme_file_tree( $allowed_files ) {
|
||||
$tree_list = array();
|
||||
foreach ( $allowed_files as $file_name => $absolute_filename ) {
|
||||
$list = explode( '/', $file_name );
|
||||
$list = explode( '/', $file_name );
|
||||
$last_dir = &$tree_list;
|
||||
foreach ( $list as $dir ) {
|
||||
$last_dir =& $last_dir[ $dir ];
|
||||
|
@ -309,7 +314,7 @@ function wp_print_theme_file_tree( $tree, $level = 2, $size = 1, $index = 1 ) {
|
|||
|
||||
if ( is_array( $tree ) ) {
|
||||
$index = 0;
|
||||
$size = count( $tree );
|
||||
$size = count( $tree );
|
||||
foreach ( $tree as $label => $theme_file ) :
|
||||
$index++;
|
||||
if ( ! is_array( $theme_file ) ) {
|
||||
|
@ -328,9 +333,9 @@ function wp_print_theme_file_tree( $tree, $level = 2, $size = 1, $index = 1 ) {
|
|||
endforeach;
|
||||
} else {
|
||||
$filename = $tree;
|
||||
$url = add_query_arg(
|
||||
$url = add_query_arg(
|
||||
array(
|
||||
'file' => rawurlencode( $tree ),
|
||||
'file' => rawurlencode( $tree ),
|
||||
'theme' => rawurlencode( $stylesheet ),
|
||||
),
|
||||
self_admin_url( 'theme-editor.php' )
|
||||
|
@ -372,7 +377,7 @@ function wp_print_theme_file_tree( $tree, $level = 2, $size = 1, $index = 1 ) {
|
|||
function wp_make_plugin_file_tree( $plugin_editable_files ) {
|
||||
$tree_list = array();
|
||||
foreach ( $plugin_editable_files as $plugin_file ) {
|
||||
$list = explode( '/', preg_replace( '#^.+?/#', '', $plugin_file ) );
|
||||
$list = explode( '/', preg_replace( '#^.+?/#', '', $plugin_file ) );
|
||||
$last_dir = &$tree_list;
|
||||
foreach ( $list as $dir ) {
|
||||
$last_dir =& $last_dir[ $dir ];
|
||||
|
@ -398,7 +403,7 @@ function wp_print_plugin_file_tree( $tree, $label = '', $level = 2, $size = 1, $
|
|||
global $file, $plugin;
|
||||
if ( is_array( $tree ) ) {
|
||||
$index = 0;
|
||||
$size = count( $tree );
|
||||
$size = count( $tree );
|
||||
foreach ( $tree as $label => $plugin_file ) :
|
||||
$index++;
|
||||
if ( ! is_array( $plugin_file ) ) {
|
||||
|
@ -418,7 +423,7 @@ function wp_print_plugin_file_tree( $tree, $label = '', $level = 2, $size = 1, $
|
|||
} else {
|
||||
$url = add_query_arg(
|
||||
array(
|
||||
'file' => rawurlencode( $tree ),
|
||||
'file' => rawurlencode( $tree ),
|
||||
'plugin' => rawurlencode( $plugin ),
|
||||
),
|
||||
self_admin_url( 'plugin-editor.php' )
|
||||
|
@ -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' );
|
||||
|
@ -495,12 +501,13 @@ function wp_reset_vars( $vars ) {
|
|||
*
|
||||
* @param string|WP_Error $message
|
||||
*/
|
||||
function show_message($message) {
|
||||
if ( is_wp_error($message) ){
|
||||
if ( $message->get_error_data() && is_string( $message->get_error_data() ) )
|
||||
function show_message( $message ) {
|
||||
if ( is_wp_error( $message ) ) {
|
||||
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();
|
||||
|
@ -514,15 +521,17 @@ 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 );
|
||||
$functions = array();
|
||||
$tokens = token_get_all( $content );
|
||||
$count = count( $tokens );
|
||||
$functions = array();
|
||||
$ignore_functions = array();
|
||||
for ( $t = 0; $t < $count - 2; $t++ ) {
|
||||
if ( ! is_array( $tokens[ $t ] ) ) {
|
||||
|
@ -532,10 +541,10 @@ function wp_doc_link_parse( $content ) {
|
|||
if ( T_STRING == $tokens[ $t ][0] && ( '(' == $tokens[ $t + 1 ] || '(' == $tokens[ $t + 2 ] ) ) {
|
||||
// If it's a function or class defined locally, there's not going to be any docs available
|
||||
if ( ( isset( $tokens[ $t - 2 ][1] ) && in_array( $tokens[ $t - 2 ][1], array( 'function', 'class' ) ) ) || ( isset( $tokens[ $t - 2 ][0] ) && T_OBJECT_OPERATOR == $tokens[ $t - 1 ][0] ) ) {
|
||||
$ignore_functions[] = $tokens[$t][1];
|
||||
$ignore_functions[] = $tokens[ $t ][1];
|
||||
}
|
||||
// Add this to our stack of unique references
|
||||
$functions[] = $tokens[$t][1];
|
||||
$functions[] = $tokens[ $t ][1];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -570,26 +580,29 @@ function wp_doc_link_parse( $content ) {
|
|||
*/
|
||||
function set_screen_options() {
|
||||
|
||||
if ( isset($_POST['wp_screen_options']) && is_array($_POST['wp_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'];
|
||||
$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() ) )
|
||||
$type = str_replace( 'edit_', '', $map_option );
|
||||
$type = str_replace( '_per_page', '', $type );
|
||||
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
|
||||
$option = str_replace('-', '_', $option);
|
||||
} else {
|
||||
$option = str_replace( '-', '_', $option );
|
||||
}
|
||||
|
||||
switch ( $map_option ) {
|
||||
case 'edit_per_page':
|
||||
|
@ -598,7 +611,7 @@ function set_screen_options() {
|
|||
case 'upload_per_page':
|
||||
case 'edit_tags_per_page':
|
||||
case 'plugins_per_page':
|
||||
// Network admin
|
||||
// Network admin
|
||||
case 'sites_network_per_page':
|
||||
case 'users_network_per_page':
|
||||
case 'site_users_network_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,12 +642,13 @@ function set_screen_options() {
|
|||
*/
|
||||
$value = apply_filters( 'set-screen-option', false, $option, $value );
|
||||
|
||||
if ( false === $value )
|
||||
if ( false === $value ) {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
update_user_meta($user->ID, $option, $value);
|
||||
update_user_meta( $user->ID, $option, $value );
|
||||
|
||||
$url = remove_query_arg( array( 'pagenum', 'apage', 'paged' ), wp_get_referer() );
|
||||
if ( isset( $_POST['mode'] ) ) {
|
||||
|
@ -654,22 +668,25 @@ function set_screen_options() {
|
|||
* @return bool
|
||||
* @param string $filename The file path to the configuration file
|
||||
*/
|
||||
function iis7_rewrite_rule_exists($filename) {
|
||||
if ( ! file_exists($filename) )
|
||||
function iis7_rewrite_rule_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 )
|
||||
}
|
||||
$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 ) {
|
||||
return false;
|
||||
else
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -680,28 +697,30 @@ function iis7_rewrite_rule_exists($filename) {
|
|||
* @param string $filename Name of the configuration file
|
||||
* @return bool
|
||||
*/
|
||||
function iis7_delete_rewrite_rule($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;
|
||||
}
|
||||
|
||||
$doc = new DOMDocument();
|
||||
$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\')]');
|
||||
}
|
||||
$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 ) {
|
||||
$child = $rules->item(0);
|
||||
$child = $rules->item( 0 );
|
||||
$parent = $child->parentNode;
|
||||
$parent->removeChild($child);
|
||||
$parent->removeChild( $child );
|
||||
$doc->formatOutput = true;
|
||||
saveDomDocument($doc, $filename);
|
||||
saveDomDocument( $doc, $filename );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -715,74 +734,76 @@ function iis7_delete_rewrite_rule($filename) {
|
|||
* @param string $rewrite_rule The XML fragment with URL Rewrite rule
|
||||
* @return bool
|
||||
*/
|
||||
function iis7_add_rewrite_rule($filename, $rewrite_rule) {
|
||||
function iis7_add_rewrite_rule( $filename, $rewrite_rule ) {
|
||||
if ( ! class_exists( 'DOMDocument', false ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If configuration file does not exist then we create one.
|
||||
if ( ! file_exists($filename) ) {
|
||||
$fp = fopen( $filename, 'w');
|
||||
fwrite($fp, '<configuration/>');
|
||||
fclose($fp);
|
||||
if ( ! file_exists( $filename ) ) {
|
||||
$fp = fopen( $filename, 'w' );
|
||||
fwrite( $fp, '<configuration/>' );
|
||||
fclose( $fp );
|
||||
}
|
||||
|
||||
$doc = new DOMDocument();
|
||||
$doc = new DOMDocument();
|
||||
$doc->preserveWhiteSpace = false;
|
||||
|
||||
if ( $doc->load($filename) === false )
|
||||
if ( $doc->load( $filename ) === false ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$xpath = new DOMXPath($doc);
|
||||
$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 )
|
||||
$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 ) {
|
||||
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');
|
||||
$xmlnodes = $xpath->query( '/configuration/system.webServer/rewrite/rules' );
|
||||
if ( $xmlnodes->length > 0 ) {
|
||||
$rules_node = $xmlnodes->item(0);
|
||||
$rules_node = $xmlnodes->item( 0 );
|
||||
} else {
|
||||
$rules_node = $doc->createElement('rules');
|
||||
$rules_node = $doc->createElement( 'rules' );
|
||||
|
||||
$xmlnodes = $xpath->query('/configuration/system.webServer/rewrite');
|
||||
$xmlnodes = $xpath->query( '/configuration/system.webServer/rewrite' );
|
||||
if ( $xmlnodes->length > 0 ) {
|
||||
$rewrite_node = $xmlnodes->item(0);
|
||||
$rewrite_node->appendChild($rules_node);
|
||||
$rewrite_node = $xmlnodes->item( 0 );
|
||||
$rewrite_node->appendChild( $rules_node );
|
||||
} else {
|
||||
$rewrite_node = $doc->createElement('rewrite');
|
||||
$rewrite_node->appendChild($rules_node);
|
||||
$rewrite_node = $doc->createElement( 'rewrite' );
|
||||
$rewrite_node->appendChild( $rules_node );
|
||||
|
||||
$xmlnodes = $xpath->query('/configuration/system.webServer');
|
||||
$xmlnodes = $xpath->query( '/configuration/system.webServer' );
|
||||
if ( $xmlnodes->length > 0 ) {
|
||||
$system_webServer_node = $xmlnodes->item(0);
|
||||
$system_webServer_node->appendChild($rewrite_node);
|
||||
$system_webServer_node = $xmlnodes->item( 0 );
|
||||
$system_webServer_node->appendChild( $rewrite_node );
|
||||
} else {
|
||||
$system_webServer_node = $doc->createElement('system.webServer');
|
||||
$system_webServer_node->appendChild($rewrite_node);
|
||||
$system_webServer_node = $doc->createElement( 'system.webServer' );
|
||||
$system_webServer_node->appendChild( $rewrite_node );
|
||||
|
||||
$xmlnodes = $xpath->query('/configuration');
|
||||
$xmlnodes = $xpath->query( '/configuration' );
|
||||
if ( $xmlnodes->length > 0 ) {
|
||||
$config_node = $xmlnodes->item(0);
|
||||
$config_node->appendChild($system_webServer_node);
|
||||
$config_node = $xmlnodes->item( 0 );
|
||||
$config_node->appendChild( $system_webServer_node );
|
||||
} else {
|
||||
$config_node = $doc->createElement('configuration');
|
||||
$doc->appendChild($config_node);
|
||||
$config_node->appendChild($system_webServer_node);
|
||||
$config_node = $doc->createElement( 'configuration' );
|
||||
$doc->appendChild( $config_node );
|
||||
$config_node->appendChild( $system_webServer_node );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$rule_fragment = $doc->createDocumentFragment();
|
||||
$rule_fragment->appendXML($rewrite_rule);
|
||||
$rules_node->appendChild($rule_fragment);
|
||||
$rule_fragment->appendXML( $rewrite_rule );
|
||||
$rules_node->appendChild( $rule_fragment );
|
||||
|
||||
$doc->encoding = "UTF-8";
|
||||
$doc->encoding = 'UTF-8';
|
||||
$doc->formatOutput = true;
|
||||
saveDomDocument($doc, $filename);
|
||||
saveDomDocument( $doc, $filename );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -795,12 +816,12 @@ function iis7_add_rewrite_rule($filename, $rewrite_rule) {
|
|||
* @param DOMDocument $doc
|
||||
* @param string $filename
|
||||
*/
|
||||
function saveDomDocument($doc, $filename) {
|
||||
function saveDomDocument( $doc, $filename ) {
|
||||
$config = $doc->saveXML();
|
||||
$config = preg_replace("/([^\r])\n/", "$1\r\n", $config);
|
||||
$fp = fopen($filename, 'w');
|
||||
fwrite($fp, $config);
|
||||
fclose($fp);
|
||||
$config = preg_replace( "/([^\r])\n/", "$1\r\n", $config );
|
||||
$fp = fopen( $filename, 'w' );
|
||||
fwrite( $fp, $config );
|
||||
fclose( $fp );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
$checked[ $key ] = $send;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty( $checked ) )
|
||||
if ( ! empty( $checked ) ) {
|
||||
$response['wp-check-locked-posts'] = $checked;
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
@ -949,28 +983,32 @@ function wp_check_locked_posts( $response, $data, $screen_id ) {
|
|||
function wp_refresh_post_lock( $response, $data, $screen_id ) {
|
||||
if ( array_key_exists( 'wp-refresh-post-lock', $data ) ) {
|
||||
$received = $data['wp-refresh-post-lock'];
|
||||
$send = array();
|
||||
$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;
|
||||
|
@ -991,7 +1029,7 @@ function wp_refresh_post_lock( $response, $data, $screen_id ) {
|
|||
*/
|
||||
function wp_refresh_post_nonces( $response, $data, $screen_id ) {
|
||||
if ( array_key_exists( 'wp-refresh-post-nonces', $data ) ) {
|
||||
$received = $data['wp-refresh-post-nonces'];
|
||||
$received = $data['wp-refresh-post-nonces'];
|
||||
$response['wp-refresh-post-nonces'] = array( 'check' => 1 );
|
||||
|
||||
if ( ! $post_id = absint( $received['post_id'] ) ) {
|
||||
|
@ -1003,12 +1041,12 @@ function wp_refresh_post_nonces( $response, $data, $screen_id ) {
|
|||
}
|
||||
|
||||
$response['wp-refresh-post-nonces'] = array(
|
||||
'replace' => array(
|
||||
'getpermalinknonce' => wp_create_nonce('getpermalink'),
|
||||
'samplepermalinknonce' => wp_create_nonce('samplepermalink'),
|
||||
'closedpostboxesnonce' => wp_create_nonce('closedpostboxes'),
|
||||
'_ajax_linking_nonce' => wp_create_nonce( 'internal-linking' ),
|
||||
'_wpnonce' => wp_create_nonce( 'update-post_' . $post_id ),
|
||||
'replace' => array(
|
||||
'getpermalinknonce' => wp_create_nonce( 'getpermalink' ),
|
||||
'samplepermalinknonce' => wp_create_nonce( 'samplepermalink' ),
|
||||
'closedpostboxesnonce' => wp_create_nonce( 'closedpostboxes' ),
|
||||
'_ajax_linking_nonce' => wp_create_nonce( 'internal-linking' ),
|
||||
'_wpnonce' => wp_create_nonce( 'update-post_' . $post_id ),
|
||||
),
|
||||
'heartbeatNonce' => wp_create_nonce( 'heartbeat-nonce' ),
|
||||
);
|
||||
|
@ -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 ) ),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1148,7 +1195,7 @@ function update_option_new_admin_email( $old_value, $value ) {
|
|||
return;
|
||||
}
|
||||
|
||||
$hash = md5( $value . time() . mt_rand() );
|
||||
$hash = md5( $value . time() . mt_rand() );
|
||||
$new_admin_email = array(
|
||||
'hash' => $hash,
|
||||
'newemail' => $value,
|
||||
|
@ -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.
|
||||
|
@ -1199,11 +1248,11 @@ All at ###SITENAME###
|
|||
$content = apply_filters( 'new_admin_email_content', $email_text, $new_admin_email );
|
||||
|
||||
$current_user = wp_get_current_user();
|
||||
$content = str_replace( '###USERNAME###', $current_user->user_login, $content );
|
||||
$content = str_replace( '###ADMIN_URL###', esc_url( self_admin_url( 'options.php?adminhash=' . $hash ) ), $content );
|
||||
$content = str_replace( '###EMAIL###', $value, $content );
|
||||
$content = str_replace( '###SITENAME###', wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ), $content );
|
||||
$content = str_replace( '###SITEURL###', home_url(), $content );
|
||||
$content = str_replace( '###USERNAME###', $current_user->user_login, $content );
|
||||
$content = str_replace( '###ADMIN_URL###', esc_url( self_admin_url( 'options.php?adminhash=' . $hash ) ), $content );
|
||||
$content = str_replace( '###EMAIL###', $value, $content );
|
||||
$content = str_replace( '###SITENAME###', wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ), $content );
|
||||
$content = str_replace( '###SITEURL###', home_url(), $content );
|
||||
|
||||
wp_mail( $value, sprintf( __( '[%s] New Admin Email Address' ), wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ) ), $content );
|
||||
|
||||
|
|
|
@ -32,13 +32,13 @@ add_filter( 'wp_insert_post_data', 'avoid_blog_page_permalink_collision', 10, 2
|
|||
add_filter( 'import_allow_create_users', 'check_import_new_users' );
|
||||
|
||||
// Notices Hooks
|
||||
add_action( 'admin_notices', 'site_admin_notice' );
|
||||
add_action( 'admin_notices', 'site_admin_notice' );
|
||||
add_action( 'network_admin_notices', 'site_admin_notice' );
|
||||
|
||||
// Update Hooks
|
||||
add_action( 'network_admin_notices', 'update_nag', 3 );
|
||||
add_action( 'network_admin_notices', 'update_nag', 3 );
|
||||
add_action( 'network_admin_notices', 'maintenance_nag', 10 );
|
||||
|
||||
// Network Admin Hooks
|
||||
add_action( 'add_site_option_new_admin_email', 'update_network_option_new_admin_email', 10, 2 );
|
||||
add_action( 'add_site_option_new_admin_email', 'update_network_option_new_admin_email', 10, 2 );
|
||||
add_action( 'update_site_option_new_admin_email', 'update_network_option_new_admin_email', 10, 2 );
|
||||
|
|
|
@ -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 ) ) {
|
||||
|
@ -137,21 +145,22 @@ function wpmu_delete_blog( $blog_id, $drop = false ) {
|
|||
* @param string $uploads['basedir'] Uploads path without subdirectory. @see wp_upload_dir()
|
||||
* @param int $blog_id The site ID.
|
||||
*/
|
||||
$dir = apply_filters( 'wpmu_delete_blog_upload_dir', $uploads['basedir'], $blog_id );
|
||||
$dir = rtrim( $dir, DIRECTORY_SEPARATOR );
|
||||
$dir = apply_filters( 'wpmu_delete_blog_upload_dir', $uploads['basedir'], $blog_id );
|
||||
$dir = rtrim( $dir, DIRECTORY_SEPARATOR );
|
||||
$top_dir = $dir;
|
||||
$stack = array($dir);
|
||||
$index = 0;
|
||||
$stack = array( $dir );
|
||||
$index = 0;
|
||||
|
||||
while ( $index < count( $stack ) ) {
|
||||
// Get indexed directory from stack
|
||||
$dir = $stack[$index];
|
||||
$dir = $stack[ $index ];
|
||||
|
||||
$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,8 +175,9 @@ 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)
|
||||
@rmdir( $dir );
|
||||
if ( $dir != $top_dir ) {
|
||||
@rmdir( $dir );
|
||||
}
|
||||
}
|
||||
|
||||
clean_blog_cache( $blog );
|
||||
|
@ -183,8 +193,9 @@ function wpmu_delete_blog( $blog_id, $drop = false ) {
|
|||
*/
|
||||
do_action( 'deleted_blog', $blog_id, $drop );
|
||||
|
||||
if ( $switch )
|
||||
if ( $switch ) {
|
||||
restore_current_blog();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -206,11 +217,12 @@ function wpmu_delete_user( $id ) {
|
|||
return false;
|
||||
}
|
||||
|
||||
$id = (int) $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,8 +255,9 @@ 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();
|
||||
|
@ -252,8 +265,9 @@ function wpmu_delete_user( $id ) {
|
|||
}
|
||||
|
||||
$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;
|
||||
|
@ -299,7 +315,7 @@ function upload_is_user_over_quota( $echo = true ) {
|
|||
*/
|
||||
function display_space_usage() {
|
||||
$space_allowed = get_space_allowed();
|
||||
$space_used = get_space_used();
|
||||
$space_used = get_space_used();
|
||||
|
||||
$percent_used = ( $space_used / $space_allowed ) * 100;
|
||||
|
||||
|
@ -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 );
|
||||
|
||||
|
@ -443,19 +464,194 @@ function refresh_user_details( $id ) {
|
|||
* then the first two letters of $code is returned.
|
||||
*/
|
||||
function format_code_lang( $code = '' ) {
|
||||
$code = strtolower( substr( $code, 0, 2 ) );
|
||||
$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,30 +696,33 @@ 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>' . 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>';
|
||||
|
||||
$output .= '<h3>' . __('Your Sites') . '</h3>';
|
||||
$output .= '<h3>' . __( 'Your Sites' ) . '</h3>';
|
||||
$output .= '<table>';
|
||||
|
||||
foreach ( $blogs as $blog ) {
|
||||
$output .= '<tr>';
|
||||
$output .= "<td>{$blog->blogname}</td>";
|
||||
$output .= '<td><a href="' . esc_url( get_admin_url( $blog->userblog_id ) ) . '">' . __( 'Visit Dashboard' ) . '</a> | ' .
|
||||
'<a href="' . esc_url( get_home_url( $blog->userblog_id ) ). '">' . __( 'View Site' ) . '</a></td>';
|
||||
'<a href="' . esc_url( get_home_url( $blog->userblog_id ) ) . '">' . __( 'View Site' ) . '</a></td>';
|
||||
$output .= '</tr>';
|
||||
}
|
||||
|
||||
|
@ -558,29 +757,29 @@ function check_import_new_users( $permission ) {
|
|||
* @param string $current Optional. The current language code. Default empty.
|
||||
*/
|
||||
function mu_dropdown_languages( $lang_files = array(), $current = '' ) {
|
||||
$flag = false;
|
||||
$flag = false;
|
||||
$output = array();
|
||||
|
||||
foreach ( (array) $lang_files as $val ) {
|
||||
$code_lang = basename( $val, '.mo' );
|
||||
|
||||
if ( $code_lang == 'en_US' ) { // American English
|
||||
$flag = true;
|
||||
$ae = __( 'American English' );
|
||||
$output[$ae] = '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang, false ) . '> ' . $ae . '</option>';
|
||||
$flag = true;
|
||||
$ae = __( 'American English' );
|
||||
$output[ $ae ] = '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang, false ) . '> ' . $ae . '</option>';
|
||||
} elseif ( $code_lang == 'en_GB' ) { // British English
|
||||
$flag = true;
|
||||
$be = __( 'British English' );
|
||||
$output[$be] = '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang, false ) . '> ' . $be . '</option>';
|
||||
$flag = true;
|
||||
$be = __( 'British English' );
|
||||
$output[ $be ] = '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang, false ) . '> ' . $be . '</option>';
|
||||
} else {
|
||||
$translated = format_code_lang( $code_lang );
|
||||
$output[$translated] = '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang, false ) . '> ' . esc_html ( $translated ) . '</option>';
|
||||
$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,18 +837,22 @@ 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;
|
||||
while( $c < 10 && get_id_from_blogname( $post_name ) ) {
|
||||
$c = 0;
|
||||
while ( $c < 10 && get_id_from_blogname( $post_name ) ) {
|
||||
$post_name .= mt_rand( 1, 10 );
|
||||
$c ++;
|
||||
}
|
||||
|
@ -675,30 +878,36 @@ function choose_primary_blog() {
|
|||
<th scope="row"><label for="primary_blog"><?php _e( 'Primary Site' ); ?></label></th>
|
||||
<td>
|
||||
<?php
|
||||
$all_blogs = get_blogs_of_user( get_current_user_id() );
|
||||
$all_blogs = get_blogs_of_user( get_current_user_id() );
|
||||
$primary_blog = get_user_meta( get_current_user_id(), 'primary_blog', true );
|
||||
if ( count( $all_blogs ) > 1 ) {
|
||||
$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 ) {
|
||||
if ( ! $found ) {
|
||||
$blog = reset( $all_blogs );
|
||||
update_user_meta( get_current_user_id(), 'primary_blog', $blog->userblog_id );
|
||||
}
|
||||
} 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,23 +1002,33 @@ 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' ) ) );
|
||||
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>';
|
||||
$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>';
|
||||
$user_dropdown .= "<select name='blog[$user_id][$key]' id='reassign_user'>";
|
||||
$user_list = '';
|
||||
$user_list = '';
|
||||
foreach ( $blog_users as $user ) {
|
||||
if ( ! in_array( $user->ID, $allusers ) ) {
|
||||
$user_list .= "<option value='{$user->ID}'>{$user->user_login}</option>";
|
||||
|
@ -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,13 +1067,15 @@ 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 “Confirm Deletion”, the user will be permanently removed.' ); ?></p>
|
||||
<?php else : ?>
|
||||
<p><?php _e( 'Once you hit “Confirm Deletion”, these users will be permanently removed.' ); ?></p>
|
||||
<?php endif;
|
||||
<?php
|
||||
endif;
|
||||
|
||||
submit_button( __('Confirm Deletion'), 'primary' );
|
||||
submit_button( __( 'Confirm Deletion' ), 'primary' );
|
||||
?>
|
||||
</form>
|
||||
<?php
|
||||
|
@ -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(
|
||||
'blog_id' => isset( $_GET['blog_id'] ) ? (int) $_GET['blog_id'] : 0,
|
||||
'links' => $links,
|
||||
'selected' => 'site-info',
|
||||
) );
|
||||
$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();
|
||||
|
@ -974,13 +1217,13 @@ function network_edit_site_nav( $args = array() ) {
|
|||
function get_site_screen_help_tab_args() {
|
||||
return array(
|
||||
'id' => 'overview',
|
||||
'title' => __('Overview'),
|
||||
'title' => __( 'Overview' ),
|
||||
'content' =>
|
||||
'<p>' . __('The menu is for editing information specific to individual sites, particularly if the admin area of a site is unavailable.') . '</p>' .
|
||||
'<p>' . __('<strong>Info</strong> — 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> — 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> — 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’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> — 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>' . __( 'The menu is for editing information specific to individual sites, particularly if the admin area of a site is unavailable.' ) . '</p>' .
|
||||
'<p>' . __( '<strong>Info</strong> — 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> — 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> — 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’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> — 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>',
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -992,7 +1235,7 @@ function get_site_screen_help_tab_args() {
|
|||
* @return string Help sidebar content.
|
||||
*/
|
||||
function get_site_screen_help_sidebar_content() {
|
||||
return '<p><strong>' . __('For more information:') . '</strong></p>' .
|
||||
'<p>' . __('<a href="https://codex.wordpress.org/Network_Admin_Sites_Screen">Documentation on Site Management</a>') . '</p>' .
|
||||
'<p>' . __('<a href="https://wordpress.org/support/forum/multisite/">Support Forums</a>') . '</p>';
|
||||
return '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
|
||||
'<p>' . __( '<a href="https://codex.wordpress.org/Network_Admin_Sites_Screen">Documentation on Site Management</a>' ) . '</p>' .
|
||||
'<p>' . __( '<a href="https://wordpress.org/support/forum/multisite/">Support Forums</a>' ) . '</p>';
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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;
|
||||
}
|
||||
|
@ -51,22 +52,25 @@ function allow_subdomain_install() {
|
|||
*/
|
||||
function allow_subdirectory_install() {
|
||||
global $wpdb;
|
||||
/**
|
||||
* Filters whether to enable the subdirectory installation feature in Multisite.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param bool $allow Whether to enable the subdirectory installation feature in Multisite. Default is false.
|
||||
*/
|
||||
if ( apply_filters( 'allow_subdirectory_install', false ) )
|
||||
/**
|
||||
* Filters whether to enable the subdirectory installation feature in Multisite.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param bool $allow Whether to enable the subdirectory installation feature in Multisite. Default is 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;
|
||||
}
|
||||
|
||||
|
@ -90,7 +96,7 @@ function get_clean_basedomain() {
|
|||
* Prints step 1 for Network installation process.
|
||||
*
|
||||
* @todo Realistically, step 1 should be a welcome screen explaining what a Network is and such. Navigating to Tools > Network
|
||||
* should not be a sudden "Welcome to a new install process! Fill this out and click here." See also contextual help todo.
|
||||
* should not be a sudden "Welcome to a new install process! Fill this out and click here." See also contextual help todo.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
|
@ -101,7 +107,7 @@ function get_clean_basedomain() {
|
|||
function network_step1( $errors = false ) {
|
||||
global $is_apache;
|
||||
|
||||
if ( defined('DO_NOT_UPGRADE_GLOBAL_TABLES') ) {
|
||||
if ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) {
|
||||
echo '<div class="error"><p><strong>' . __( 'ERROR:' ) . '</strong> ' . sprintf(
|
||||
/* translators: %s: DO_NOT_UPGRADE_GLOBAL_TABLES */
|
||||
__( 'The constant %s cannot be defined when creating a network.' ),
|
||||
|
@ -125,7 +131,7 @@ function network_step1( $errors = false ) {
|
|||
die();
|
||||
}
|
||||
|
||||
$hostname = get_clean_basedomain();
|
||||
$hostname = get_clean_basedomain();
|
||||
$has_ports = strstr( $hostname, ':' );
|
||||
if ( ( false !== $has_ports && ! in_array( $has_ports, array( ':80', ':443' ) ) ) ) {
|
||||
echo '<div class="error"><p><strong>' . __( 'ERROR:' ) . '</strong> ' . __( 'You cannot install a network of sites with your server address.' ) . '</p></div>';
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -172,23 +179,25 @@ function network_step1( $errors = false ) {
|
|||
|
||||
if ( isset( $_POST['subdomain_install'] ) ) {
|
||||
$subdomain_install = (bool) $_POST['subdomain_install'];
|
||||
} elseif ( apache_mod_loaded('mod_rewrite') ) { // assume nothing
|
||||
} elseif ( apache_mod_loaded( 'mod_rewrite' ) ) { // assume nothing
|
||||
$subdomain_install = true;
|
||||
} elseif ( !allow_subdirectory_install() ) {
|
||||
} elseif ( ! allow_subdirectory_install() ) {
|
||||
$subdomain_install = true;
|
||||
} else {
|
||||
$subdomain_install = 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() ) )
|
||||
echo '<div class="error inline"><p><strong>' . __( 'Warning:' ) . '</strong> ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</p></div>';
|
||||
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 ) :
|
||||
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(
|
||||
<th scope='row'><?php esc_html_e( 'Server Address' ); ?></th>
|
||||
<td>
|
||||
<?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() )
|
||||
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>
|
||||
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>
|
||||
</tr>
|
||||
<?php elseif ( !allow_subdomain_install() ) : ?>
|
||||
<?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() )
|
||||
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>
|
||||
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>
|
||||
</tr>
|
||||
<?php elseif ( !allow_subdirectory_install() ) : ?>
|
||||
<?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,37 +431,41 @@ 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
|
||||
if ( file_exists( $home_path . '.htaccess' ) ) {
|
||||
echo '<strong>' . __( 'Caution:' ) . '</strong> ';
|
||||
printf(
|
||||
/* translators: 1: wp-config.php 2: .htaccess */
|
||||
__( 'We recommend you back up your existing %1$s and %2$s files.' ),
|
||||
'<code>wp-config.php</code>',
|
||||
'<code>.htaccess</code>'
|
||||
);
|
||||
} elseif ( file_exists( $home_path . 'web.config' ) ) {
|
||||
echo '<strong>' . __( 'Caution:' ) . '</strong> ';
|
||||
printf(
|
||||
/* translators: 1: wp-config.php 2: web.config */
|
||||
__( 'We recommend you back up your existing %1$s and %2$s files.' ),
|
||||
'<code>wp-config.php</code>',
|
||||
'<code>web.config</code>'
|
||||
);
|
||||
} else {
|
||||
echo '<strong>' . __( 'Caution:' ) . '</strong> ';
|
||||
printf(
|
||||
/* translators: 1: wp-config.php */
|
||||
__( 'We recommend you back up your existing %s file.' ),
|
||||
'<code>wp-config.php</code>'
|
||||
);
|
||||
}
|
||||
?></p></div>
|
||||
<div class="updated inline"><p>
|
||||
<?php
|
||||
if ( file_exists( $home_path . '.htaccess' ) ) {
|
||||
echo '<strong>' . __( 'Caution:' ) . '</strong> ';
|
||||
printf(
|
||||
/* translators: 1: wp-config.php 2: .htaccess */
|
||||
__( 'We recommend you back up your existing %1$s and %2$s files.' ),
|
||||
'<code>wp-config.php</code>',
|
||||
'<code>.htaccess</code>'
|
||||
);
|
||||
} elseif ( file_exists( $home_path . 'web.config' ) ) {
|
||||
echo '<strong>' . __( 'Caution:' ) . '</strong> ';
|
||||
printf(
|
||||
/* translators: 1: wp-config.php 2: web.config */
|
||||
__( 'We recommend you back up your existing %1$s and %2$s files.' ),
|
||||
'<code>wp-config.php</code>',
|
||||
'<code>web.config</code>'
|
||||
);
|
||||
} else {
|
||||
echo '<strong>' . __( 'Caution:' ) . '</strong> ';
|
||||
printf(
|
||||
/* translators: 1: wp-config.php */
|
||||
__( 'We recommend you back up your existing %s file.' ),
|
||||
'<code>wp-config.php</code>'
|
||||
);
|
||||
}
|
||||
?>
|
||||
</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’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,58 +488,68 @@ 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' => '' );
|
||||
foreach ( $keys_salts as $c => $v ) {
|
||||
if ( defined( $c ) )
|
||||
unset( $keys_salts[ $c ] );
|
||||
$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 ) ) {
|
||||
unset( $keys_salts[ $c ] );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty( $keys_salts ) ) {
|
||||
$keys_salts_str = '';
|
||||
$from_api = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' );
|
||||
if ( is_wp_error( $from_api ) ) {
|
||||
foreach ( $keys_salts as $c => $v ) {
|
||||
$keys_salts_str .= "\ndefine( '$c', '" . wp_generate_password( 64, true, true ) . "' );";
|
||||
}
|
||||
} else {
|
||||
$from_api = explode( "\n", wp_remote_retrieve_body( $from_api ) );
|
||||
foreach ( $keys_salts as $c => $v ) {
|
||||
$keys_salts_str .= "\ndefine( '$c', '" . substr( array_shift( $from_api ), 28, 64 ) . "' );";
|
||||
}
|
||||
if ( ! empty( $keys_salts ) ) {
|
||||
$keys_salts_str = '';
|
||||
$from_api = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' );
|
||||
if ( is_wp_error( $from_api ) ) {
|
||||
foreach ( $keys_salts as $c => $v ) {
|
||||
$keys_salts_str .= "\ndefine( '$c', '" . wp_generate_password( 64, true, true ) . "' );";
|
||||
}
|
||||
$num_keys_salts = count( $keys_salts );
|
||||
} else {
|
||||
$from_api = explode( "\n", wp_remote_retrieve_body( $from_api ) );
|
||||
foreach ( $keys_salts as $c => $v ) {
|
||||
$keys_salts_str .= "\ndefine( '$c', '" . substr( array_shift( $from_api ), 28, 64 ) . "' );";
|
||||
}
|
||||
}
|
||||
$num_keys_salts = count( $keys_salts );
|
||||
?>
|
||||
<p>
|
||||
<?php
|
||||
if ( 1 == $num_keys_salts ) {
|
||||
printf(
|
||||
/* translators: 1: wp-config.php */
|
||||
__( 'This unique authentication key is also missing from your %s file.' ),
|
||||
'<code>wp-config.php</code>'
|
||||
);
|
||||
} else {
|
||||
printf(
|
||||
/* translators: 1: wp-config.php */
|
||||
__( 'These unique authentication keys are also missing from your %s file.' ),
|
||||
'<code>wp-config.php</code>'
|
||||
);
|
||||
}
|
||||
<p>
|
||||
<?php
|
||||
if ( 1 == $num_keys_salts ) {
|
||||
printf(
|
||||
/* translators: 1: wp-config.php */
|
||||
__( 'This unique authentication key is also missing from your %s file.' ),
|
||||
'<code>wp-config.php</code>'
|
||||
);
|
||||
} else {
|
||||
printf(
|
||||
/* translators: 1: wp-config.php */
|
||||
__( 'These unique authentication keys are also missing from your %s file.' ),
|
||||
'<code>wp-config.php</code>'
|
||||
);
|
||||
}
|
||||
?>
|
||||
<?php _e( 'To make your installation more secure, you should also add:' ); ?>
|
||||
</p>
|
||||
<textarea class="code" readonly="readonly" cols="100" rows="<?php echo $num_keys_salts; ?>"><?php echo esc_textarea( $keys_salts_str ); ?></textarea>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
</li>
|
||||
<?php
|
||||
if ( iis7_supports_permalinks() ) :
|
||||
// IIS doesn't support RewriteBase, all your RewriteBase are belong to us
|
||||
$iis_subdir_match = ltrim( $base, '/' ) . $subdir_match;
|
||||
$iis_rewrite_base = ltrim( $base, '/' ) . $rewrite_base;
|
||||
$iis_subdir_replacement = $subdomain_install ? '' : '{R:1}';
|
||||
if ( iis7_supports_permalinks() ) :
|
||||
// IIS doesn't support RewriteBase, all your RewriteBase are belong to us
|
||||
$iis_subdir_match = ltrim( $base, '/' ) . $subdir_match;
|
||||
$iis_rewrite_base = ltrim( $base, '/' ) . $rewrite_base;
|
||||
$iis_subdir_replacement = $subdomain_install ? '' : '{R:1}';
|
||||
|
||||
$web_config_file = '<?xml version="1.0" encoding="UTF-8"?>
|
||||
$web_config_file = '<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<system.webServer>
|
||||
<rewrite>
|
||||
|
@ -504,14 +558,14 @@ define('BLOG_ID_CURRENT_SITE', 1);
|
|||
<match url="^index\.php$" ignoreCase="false" />
|
||||
<action type="None" />
|
||||
</rule>';
|
||||
if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) {
|
||||
$web_config_file .= '
|
||||
if ( is_multisite() && get_site_option( 'ms_files_rewriting' ) ) {
|
||||
$web_config_file .= '
|
||||
<rule name="WordPress Rule for Files" stopProcessing="true">
|
||||
<match url="^' . $iis_subdir_match . 'files/(.+)" ignoreCase="false" />
|
||||
<action type="Rewrite" url="' . $iis_rewrite_base . WPINC . '/ms-files.php?file={R:1}" appendQueryString="false" />
|
||||
</rule>';
|
||||
}
|
||||
$web_config_file .= '
|
||||
}
|
||||
$web_config_file .= '
|
||||
<rule name="WordPress Rule 2" stopProcessing="true">
|
||||
<match url="^' . $iis_subdir_match . 'wp-admin$" ignoreCase="false" />
|
||||
<action type="Redirect" url="' . $iis_subdir_replacement . 'wp-admin/" redirectType="Permanent" />
|
||||
|
@ -542,26 +596,28 @@ define('BLOG_ID_CURRENT_SITE', 1);
|
|||
</configuration>
|
||||
';
|
||||
|
||||
echo '<li><p>';
|
||||
printf(
|
||||
/* translators: 1: a filename like .htaccess. 2: a file path. */
|
||||
__( 'Add the following to your %1$s file in %2$s, <strong>replacing</strong> other WordPress rules:' ),
|
||||
'<code>web.config</code>',
|
||||
'<code>' . $home_path . '</code>'
|
||||
);
|
||||
echo '</p>';
|
||||
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 ); ?>
|
||||
echo '<li><p>';
|
||||
printf(
|
||||
/* translators: 1: a filename like .htaccess. 2: a file path. */
|
||||
__( 'Add the following to your %1$s file in %2$s, <strong>replacing</strong> other WordPress rules:' ),
|
||||
'<code>web.config</code>',
|
||||
'<code>' . $home_path . '</code>'
|
||||
);
|
||||
echo '</p>';
|
||||
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' ) ) {
|
||||
$ms_files_rewriting = "\n# uploaded files\nRewriteRule ^";
|
||||
$ms_files_rewriting = "\n# uploaded files\nRewriteRule ^";
|
||||
$ms_files_rewriting .= $subdir_match . "files/(.+) {$rewrite_base}" . WPINC . "/ms-files.php?file={$subdir_replacement_12} [L]" . "\n";
|
||||
}
|
||||
|
||||
|
@ -590,17 +646,20 @@ 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
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,7 +65,8 @@ function get_bloginfo() {}
|
|||
/**
|
||||
* @ignore
|
||||
*/
|
||||
function is_admin() {return true;}
|
||||
function is_admin() {
|
||||
return true;}
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
|
@ -93,15 +94,15 @@ function includes_url() {}
|
|||
function wp_guess_url() {}
|
||||
|
||||
if ( ! function_exists( 'json_encode' ) ) :
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
function json_encode() {}
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
function json_encode() {}
|
||||
endif;
|
||||
|
||||
function get_file( $path ) {
|
||||
|
||||
if ( function_exists('realpath') ) {
|
||||
if ( function_exists( 'realpath' ) ) {
|
||||
$path = realpath( $path );
|
||||
}
|
||||
|
||||
|
@ -110,4 +111,4 @@ function get_file( $path ) {
|
|||
}
|
||||
|
||||
return @file_get_contents( $path );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ function options_reading_add_js() {
|
|||
selects.prop( 'disabled', ! staticPage.prop('checked') );
|
||||
};
|
||||
check_disabled();
|
||||
section.find('input:radio').change(check_disabled);
|
||||
section.find('input:radio').change(check_disabled);
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
|
|
|
@ -145,18 +145,19 @@ 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,
|
||||
'timeout' => 15,
|
||||
'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ),
|
||||
'body' => array(
|
||||
'action' => $action,
|
||||
'request' => serialize( $args )
|
||||
)
|
||||
'body' => array(
|
||||
'action' => $action,
|
||||
'request' => serialize( $args ),
|
||||
),
|
||||
);
|
||||
$request = wp_remote_post( $url, $http_args );
|
||||
$request = wp_remote_post( $url, $http_args );
|
||||
|
||||
if ( $ssl && is_wp_error( $request ) ) {
|
||||
trigger_error(
|
||||
|
@ -170,8 +171,9 @@ function plugins_api( $action, $args = array() ) {
|
|||
$request = wp_remote_post( $http_url, $http_args );
|
||||
}
|
||||
|
||||
if ( is_wp_error($request) ) {
|
||||
$res = new WP_Error( 'plugins_api_failed',
|
||||
if ( is_wp_error( $request ) ) {
|
||||
$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’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’s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
|
||||
|
@ -192,7 +195,7 @@ function plugins_api( $action, $args = array() ) {
|
|||
);
|
||||
}
|
||||
}
|
||||
} elseif ( !is_wp_error($res) ) {
|
||||
} elseif ( ! is_wp_error( $res ) ) {
|
||||
$res->external = true;
|
||||
}
|
||||
|
||||
|
@ -217,14 +220,16 @@ function plugins_api( $action, $args = array() ) {
|
|||
* @return array
|
||||
*/
|
||||
function install_popular_tags( $args = array() ) {
|
||||
$key = md5(serialize($args));
|
||||
if ( false !== ($tags = get_site_transient('poptags_' . $key) ) )
|
||||
$key = md5( serialize( $args ) );
|
||||
if ( false !== ( $tags = get_site_transient( 'poptags_' . $key ) ) ) {
|
||||
return $tags;
|
||||
}
|
||||
|
||||
$tags = plugins_api('hot_tags', $args);
|
||||
$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,30 +246,35 @@ 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();
|
||||
|
||||
echo '<p class="popular-tags">';
|
||||
if ( is_wp_error($api_tags) ) {
|
||||
if ( is_wp_error( $api_tags ) ) {
|
||||
echo $api_tags->get_error_message();
|
||||
} else {
|
||||
//Set up the tags in a way which can be interpreted by wp_generate_tag_cloud()
|
||||
$tags = array();
|
||||
foreach ( (array) $api_tags as $tag ) {
|
||||
$url = self_admin_url( 'plugin-install.php?tab=search&type=tag&s=' . urlencode( $tag['name'] ) );
|
||||
$data = array(
|
||||
'link' => esc_url( $url ),
|
||||
'name' => $tag['name'],
|
||||
'slug' => $tag['slug'],
|
||||
'id' => sanitize_title_with_dashes( $tag['name'] ),
|
||||
'count' => $tag['count']
|
||||
$url = self_admin_url( 'plugin-install.php?tab=search&type=tag&s=' . urlencode( $tag['name'] ) );
|
||||
$data = array(
|
||||
'link' => esc_url( $url ),
|
||||
'name' => $tag['name'],
|
||||
'slug' => $tag['slug'],
|
||||
'id' => sanitize_title_with_dashes( $tag['name'] ),
|
||||
'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,21 +300,23 @@ 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() {
|
||||
?>
|
||||
<div class="upload-plugin">
|
||||
<p class="install-help"><?php _e('If you have a plugin in a .zip format, you may install it by uploading it here.'); ?></p>
|
||||
<form method="post" enctype="multipart/form-data" class="wp-upload-form" action="<?php echo self_admin_url('update.php?action=upload-plugin'); ?>">
|
||||
<p class="install-help"><?php _e( 'If you have a plugin in a .zip format, you may install it by uploading it here.' ); ?></p>
|
||||
<form method="post" enctype="multipart/form-data" class="wp-upload-form" action="<?php echo self_admin_url( 'update.php?action=upload-plugin' ); ?>">
|
||||
<?php wp_nonce_field( 'plugin-upload' ); ?>
|
||||
<label class="screen-reader-text" for="pluginzip"><?php _e( 'Plugin zip file' ); ?></label>
|
||||
<input type="file" id="pluginzip" name="pluginzip" />
|
||||
|
@ -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' );
|
||||
|
@ -346,15 +359,15 @@ function display_plugins_table() {
|
|||
global $wp_list_table;
|
||||
|
||||
switch ( current_filter() ) {
|
||||
case 'install_plugins_favorites' :
|
||||
case 'install_plugins_favorites':
|
||||
if ( empty( $_GET['user'] ) && ! get_user_option( 'wporg_favorites' ) ) {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case 'install_plugins_recommended' :
|
||||
case 'install_plugins_recommended':
|
||||
echo '<p>' . __( 'These suggestions are based on the plugins you and other users have installed.' ) . '</p>';
|
||||
break;
|
||||
case 'install_plugins_beta' :
|
||||
case 'install_plugins_beta':
|
||||
printf(
|
||||
'<p>' . __( 'You are using a development version of WordPress. These feature plugins are also under development. <a href="%s">Learn more</a>.' ) . '</p>',
|
||||
'https://make.wordpress.org/core/handbook/about/release-cycle/features-as-plugins/'
|
||||
|
@ -385,29 +398,31 @@ function display_plugins_table() {
|
|||
* @type string $file Plugin filename relative to the plugins directory.
|
||||
* }
|
||||
*/
|
||||
function install_plugin_install_status($api, $loop = false) {
|
||||
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';
|
||||
$url = false;
|
||||
$status = 'install';
|
||||
$url = false;
|
||||
$update_file = false;
|
||||
|
||||
/*
|
||||
* Check to see if this plugin is known to be installed,
|
||||
* and has an update awaiting it.
|
||||
*/
|
||||
$update_plugins = get_site_transient('update_plugins');
|
||||
$update_plugins = get_site_transient( 'update_plugins' );
|
||||
if ( isset( $update_plugins->response ) ) {
|
||||
foreach ( (array)$update_plugins->response as $file => $plugin ) {
|
||||
foreach ( (array) $update_plugins->response as $file => $plugin ) {
|
||||
if ( $plugin->slug === $api->slug ) {
|
||||
$status = 'update_available';
|
||||
$status = 'update_available';
|
||||
$update_file = $file;
|
||||
$version = $plugin->new_version;
|
||||
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);
|
||||
$version = $plugin->new_version;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -415,36 +430,39 @@ function install_plugin_install_status($api, $loop = false) {
|
|||
|
||||
if ( 'install' == $status ) {
|
||||
if ( is_dir( WP_PLUGIN_DIR . '/' . $api->slug ) ) {
|
||||
$installed_plugin = get_plugins('/' . $api->slug);
|
||||
if ( empty($installed_plugin) ) {
|
||||
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);
|
||||
$installed_plugin = get_plugins( '/' . $api->slug );
|
||||
if ( empty( $installed_plugin ) ) {
|
||||
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
|
||||
$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
|
||||
$update_file = $api->slug . '/' . $key;
|
||||
if ( version_compare($api->version, $installed_plugin[ $key ]['Version'], '=') ){
|
||||
if ( version_compare( $api->version, $installed_plugin[ $key ]['Version'], '=' ) ) {
|
||||
$status = 'latest_installed';
|
||||
} elseif ( version_compare($api->version, $installed_plugin[ $key ]['Version'], '<') ) {
|
||||
$status = 'newer_installed';
|
||||
} elseif ( version_compare( $api->version, $installed_plugin[ $key ]['Version'], '<' ) ) {
|
||||
$status = 'newer_installed';
|
||||
$version = $installed_plugin[ $key ]['Version'];
|
||||
} else {
|
||||
//If the above update check failed, Then that probably means that the update checker has out-of-date information, force a refresh
|
||||
if ( ! $loop ) {
|
||||
delete_site_transient('update_plugins');
|
||||
delete_site_transient( 'update_plugins' );
|
||||
wp_update_plugins();
|
||||
return install_plugin_install_status($api, true);
|
||||
return install_plugin_install_status( $api, true );
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// "install" & no directory with that slug
|
||||
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 ( 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 .= '&from=' . urlencode( wp_unslash( $_GET['from'] ) );
|
||||
}
|
||||
|
||||
$file = $update_file;
|
||||
return compact( 'status', 'url', 'version', 'file' );
|
||||
|
@ -464,45 +482,69 @@ function install_plugin_information() {
|
|||
return;
|
||||
}
|
||||
|
||||
$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
|
||||
$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,
|
||||
),
|
||||
)
|
||||
) );
|
||||
);
|
||||
|
||||
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 ),
|
||||
);
|
||||
|
||||
$plugins_section_titles = array(
|
||||
'description' => _x( 'Description', 'Plugin installer section title' ),
|
||||
'description' => _x( 'Description', 'Plugin installer section title' ),
|
||||
'installation' => _x( 'Installation', 'Plugin installer section title' ),
|
||||
'faq' => _x( 'FAQ', 'Plugin installer section title' ),
|
||||
'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' )
|
||||
'faq' => _x( 'FAQ', 'Plugin installer section title' ),
|
||||
'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' ),
|
||||
);
|
||||
|
||||
// Sanitize HTML
|
||||
foreach ( (array) $api->sections as $section_name => $content ) {
|
||||
$api->sections[$section_name] = wp_kses( $content, $plugins_allowedtags );
|
||||
$api->sections[ $section_name ] = wp_kses( $content, $plugins_allowedtags );
|
||||
}
|
||||
|
||||
foreach ( array( 'version', 'author', 'requires', 'tested', 'homepage', 'downloaded', 'slug' ) as $key ) {
|
||||
|
@ -516,7 +558,7 @@ function install_plugin_information() {
|
|||
$section = isset( $_REQUEST['section'] ) ? wp_unslash( $_REQUEST['section'] ) : 'description'; // Default to the Description tab, Do not translate, API returns English.
|
||||
if ( empty( $section ) || ! isset( $api->sections[ $section ] ) ) {
|
||||
$section_titles = array_keys( (array) $api->sections );
|
||||
$section = reset( $section_titles );
|
||||
$section = reset( $section_titles );
|
||||
}
|
||||
|
||||
iframe_header( __( 'Plugin Installation' ) );
|
||||
|
@ -525,8 +567,8 @@ function install_plugin_information() {
|
|||
|
||||
if ( ! empty( $api->banners ) && ( ! empty( $api->banners['low'] ) || ! empty( $api->banners['high'] ) ) ) {
|
||||
$_with_banner = 'with-banner';
|
||||
$low = empty( $api->banners['low'] ) ? $api->banners['high'] : $api->banners['low'];
|
||||
$high = empty( $api->banners['high'] ) ? $api->banners['low'] : $api->banners['high'];
|
||||
$low = empty( $api->banners['low'] ) ? $api->banners['high'] : $api->banners['low'];
|
||||
$high = empty( $api->banners['high'] ) ? $api->banners['low'] : $api->banners['high'];
|
||||
?>
|
||||
<style type="text/css">
|
||||
#plugin-information-title.with-banner {
|
||||
|
@ -556,9 +598,14 @@ function install_plugin_information() {
|
|||
$title = ucwords( str_replace( '_', ' ', $section_name ) );
|
||||
}
|
||||
|
||||
$class = ( $section_name === $section ) ? ' class="current"' : '';
|
||||
$href = add_query_arg( array('tab' => $tab, 'section' => $section_name) );
|
||||
$href = esc_url( $href );
|
||||
$class = ( $section_name === $section ) ? ' class="current"' : '';
|
||||
$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,15 +638,17 @@ 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
|
||||
if ( $api->active_installs >= 1000000 ) {
|
||||
_ex( '1+ Million', 'Active plugin installations' );
|
||||
} elseif ( 0 == $api->active_installs ) {
|
||||
_ex( 'Less Than 10', 'Active plugin installations' );
|
||||
} else {
|
||||
echo number_format_i18n( $api->active_installs ) . '+';
|
||||
}
|
||||
?></li>
|
||||
<li><strong><?php _e( 'Active Installations:' ); ?></strong>
|
||||
<?php
|
||||
if ( $api->active_installs >= 1000000 ) {
|
||||
_ex( '1+ Million', 'Active plugin installations' );
|
||||
} elseif ( 0 == $api->active_installs ) {
|
||||
_ex( 'Less Than 10', 'Active plugin installations' );
|
||||
} else {
|
||||
echo number_format_i18n( $api->active_installs ) . '+';
|
||||
}
|
||||
?>
|
||||
</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 »' ); ?></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 ),
|
||||
$key,
|
||||
number_format_i18n( $ratecount )
|
||||
) );
|
||||
$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">
|
||||
|
@ -639,8 +701,9 @@ function install_plugin_information() {
|
|||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
if ( ! empty( $api->contributors ) ) { ?>
|
||||
}
|
||||
if ( ! empty( $api->contributors ) ) {
|
||||
?>
|
||||
<h3><?php _e( 'Contributors' ); ?></h3>
|
||||
<ul class="contributors">
|
||||
<?php
|
||||
|
@ -701,12 +764,12 @@ function install_plugin_information() {
|
|||
break;
|
||||
case 'update_available':
|
||||
if ( $status['url'] ) {
|
||||
echo '<a data-slug="' . esc_attr( $api->slug ) . '" data-plugin="' . esc_attr( $status['file'] ) . '" id="plugin_update_from_iframe" class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __( 'Install Update Now' ) .'</a>';
|
||||
echo '<a data-slug="' . esc_attr( $api->slug ) . '" data-plugin="' . esc_attr( $status['file'] ) . '" id="plugin_update_from_iframe" class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __( 'Install Update Now' ) . '</a>';
|
||||
}
|
||||
break;
|
||||
case 'newer_installed':
|
||||
/* translators: %s: Plugin version */
|
||||
echo '<a class="button button-primary right disabled">' . sprintf( __( 'Newer Version (%s) Installed'), $status['version'] ) . '</a>';
|
||||
echo '<a class="button button-primary right disabled">' . sprintf( __( 'Newer Version (%s) Installed' ), $status['version'] ) . '</a>';
|
||||
break;
|
||||
case 'latest_installed':
|
||||
echo '<a class="button button-primary right disabled">' . __( 'Latest Version Installed' ) . '</a>';
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue