code stringlengths 1 2.01M | repo_name stringlengths 3 62 | path stringlengths 1 267 | language stringclasses 231
values | license stringclasses 13
values | size int64 1 2.01M |
|---|---|---|---|---|---|
<?php
/**
* Deprecated admin functions from past WordPress versions. You shouldn't use these
* functions and look for the alternatives instead. The functions will be removed
* in a later version.
*
* @package WordPress
* @subpackage Deprecated
*/
/*
* Deprecated functions come here to die.
*/
/**
* @since 2.1
* @deprecated 2.1
* @deprecated Use wp_editor().
* @see wp_editor()
*/
function tinymce_include() {
_deprecated_function( __FUNCTION__, '2.1', 'wp_editor()' );
wp_tiny_mce();
}
/**
* Unused Admin function.
*
* @since 2.0
* @deprecated 2.5
*
*/
function documentation_link() {
_deprecated_function( __FUNCTION__, '2.5' );
return;
}
/**
* Calculates the new dimensions for a downsampled image.
*
* @since 2.0.0
* @deprecated 3.0.0
* @deprecated Use wp_constrain_dimensions()
*
* @param int $width Current width of the image
* @param int $height Current height of the image
* @param int $wmax Maximum wanted width
* @param int $hmax Maximum wanted height
* @return mixed Array(height,width) of shrunk dimensions.
*/
function wp_shrink_dimensions( $width, $height, $wmax = 128, $hmax = 96 ) {
_deprecated_function( __FUNCTION__, '3.0', 'wp_constrain_dimensions()' );
return wp_constrain_dimensions( $width, $height, $wmax, $hmax );
}
/**
* {@internal Missing Short Description}}
*
* @since 0.71
* @deprecated 2.6.0
* @deprecated Use wp_category_checklist()
* @see wp_category_checklist()
*
* @param unknown_type $default
* @param unknown_type $parent
* @param unknown_type $popular_ids
*/
function dropdown_categories( $default = 0, $parent = 0, $popular_ids = array() ) {
_deprecated_function( __FUNCTION__, '2.6', 'wp_category_checklist()' );
global $post_ID;
wp_category_checklist( $post_ID );
}
/**
* {@internal Missing Short Description}}
*
* @since 2.1.0
* @deprecated 2.6.0
* @deprecated Use wp_link_category_checklist()
* @see wp_link_category_checklist()
*
* @param unknown_type $default
*/
function dropdown_link_categories( $default = 0 ) {
_deprecated_function( __FUNCTION__, '2.6', 'wp_link_category_checklist()' );
global $link_id;
wp_link_category_checklist( $link_id );
}
/**
* {@internal Missing Short Description}}
*
* @since 1.2.0
* @deprecated 3.0.0
* @deprecated Use wp_dropdown_categories()
* @see wp_dropdown_categories()
*
* @param unknown_type $currentcat
* @param unknown_type $currentparent
* @param unknown_type $parent
* @param unknown_type $level
* @param unknown_type $categories
* @return unknown
*/
function wp_dropdown_cats( $currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0 ) {
_deprecated_function( __FUNCTION__, '3.0', 'wp_dropdown_categories()' );
if (!$categories )
$categories = get_categories( array('hide_empty' => 0) );
if ( $categories ) {
foreach ( $categories as $category ) {
if ( $currentcat != $category->term_id && $parent == $category->parent) {
$pad = str_repeat( '– ', $level );
$category->name = esc_html( $category->name );
echo "\n\t<option value='$category->term_id'";
if ( $currentparent == $category->term_id )
echo " selected='selected'";
echo ">$pad$category->name</option>";
wp_dropdown_cats( $currentcat, $currentparent, $category->term_id, $level +1, $categories );
}
}
} else {
return false;
}
}
/**
* Register a setting and its sanitization callback
*
* @since 2.7.0
* @deprecated 3.0.0
* @deprecated Use register_setting()
* @see register_setting()
*
* @param string $option_group A settings group name. Should correspond to a whitelisted option key name.
* Default whitelisted option key names include "general," "discussion," and "reading," among others.
* @param string $option_name The name of an option to sanitize and save.
* @param unknown_type $sanitize_callback A callback function that sanitizes the option's value.
* @return unknown
*/
function add_option_update_handler( $option_group, $option_name, $sanitize_callback = '' ) {
_deprecated_function( __FUNCTION__, '3.0', 'register_setting()' );
return register_setting( $option_group, $option_name, $sanitize_callback );
}
/**
* Unregister a setting
*
* @since 2.7.0
* @deprecated 3.0.0
* @deprecated Use unregister_setting()
* @see unregister_setting()
*
* @param unknown_type $option_group
* @param unknown_type $option_name
* @param unknown_type $sanitize_callback
* @return unknown
*/
function remove_option_update_handler( $option_group, $option_name, $sanitize_callback = '' ) {
_deprecated_function( __FUNCTION__, '3.0', 'unregister_setting()' );
return unregister_setting( $option_group, $option_name, $sanitize_callback );
}
/**
* Determines the language to use for CodePress syntax highlighting.
*
* @since 2.8.0
* @deprecated 3.0.0
*
* @param string $filename
**/
function codepress_get_lang( $filename ) {
_deprecated_function( __FUNCTION__, '3.0' );
return;
}
/**
* Adds Javascript required to make CodePress work on the theme/plugin editors.
*
* @since 2.8.0
* @deprecated 3.0.0
**/
function codepress_footer_js() {
_deprecated_function( __FUNCTION__, '3.0' );
return;
}
/**
* Determine whether to use CodePress.
*
* @since 2.8
* @deprecated 3.0.0
**/
function use_codepress() {
_deprecated_function( __FUNCTION__, '3.0' );
return;
}
/**
* @deprecated 3.1.0
*
* @return array List of user IDs.
*/
function get_author_user_ids() {
_deprecated_function( __FUNCTION__, '3.1', 'get_users()' );
global $wpdb;
if ( !is_multisite() )
$level_key = $wpdb->get_blog_prefix() . 'user_level';
else
$level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value != '0'", $level_key) );
}
/**
* @deprecated 3.1.0
*
* @param int $user_id User ID.
* @return array|bool List of editable authors. False if no editable users.
*/
function get_editable_authors( $user_id ) {
_deprecated_function( __FUNCTION__, '3.1', 'get_users()' );
global $wpdb;
$editable = get_editable_user_ids( $user_id );
if ( !$editable ) {
return false;
} else {
$editable = join(',', $editable);
$authors = $wpdb->get_results( "SELECT * FROM $wpdb->users WHERE ID IN ($editable) ORDER BY display_name" );
}
return apply_filters('get_editable_authors', $authors);
}
/**
* @deprecated 3.1.0
*
* @param int $user_id User ID.
* @param bool $exclude_zeros Optional, default is true. Whether to exclude zeros.
* @return unknown
*/
function get_editable_user_ids( $user_id, $exclude_zeros = true, $post_type = 'post' ) {
_deprecated_function( __FUNCTION__, '3.1', 'get_users()' );
global $wpdb;
$user = new WP_User( $user_id );
$post_type_obj = get_post_type_object($post_type);
if ( ! $user->has_cap($post_type_obj->cap->edit_others_posts) ) {
if ( $user->has_cap($post_type_obj->cap->edit_posts) || ! $exclude_zeros )
return array($user->ID);
else
return array();
}
if ( !is_multisite() )
$level_key = $wpdb->get_blog_prefix() . 'user_level';
else
$level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
$query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s", $level_key);
if ( $exclude_zeros )
$query .= " AND meta_value != '0'";
return $wpdb->get_col( $query );
}
/**
* @deprecated 3.1.0
*/
function get_nonauthor_user_ids() {
_deprecated_function( __FUNCTION__, '3.1', 'get_users()' );
global $wpdb;
if ( !is_multisite() )
$level_key = $wpdb->get_blog_prefix() . 'user_level';
else
$level_key = $wpdb->get_blog_prefix() . 'capabilities'; // wpmu site admins don't have user_levels
return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value = '0'", $level_key) );
}
if ( !class_exists('WP_User_Search') ) :
/**
* WordPress User Search class.
*
* @since 2.1.0
* @deprecated 3.1.0
*/
class WP_User_Search {
/**
* {@internal Missing Description}}
*
* @since 2.1.0
* @access private
* @var unknown_type
*/
var $results;
/**
* {@internal Missing Description}}
*
* @since 2.1.0
* @access private
* @var unknown_type
*/
var $search_term;
/**
* Page number.
*
* @since 2.1.0
* @access private
* @var int
*/
var $page;
/**
* Role name that users have.
*
* @since 2.5.0
* @access private
* @var string
*/
var $role;
/**
* Raw page number.
*
* @since 2.1.0
* @access private
* @var int|bool
*/
var $raw_page;
/**
* Amount of users to display per page.
*
* @since 2.1.0
* @access public
* @var int
*/
var $users_per_page = 50;
/**
* {@internal Missing Description}}
*
* @since 2.1.0
* @access private
* @var unknown_type
*/
var $first_user;
/**
* {@internal Missing Description}}
*
* @since 2.1.0
* @access private
* @var int
*/
var $last_user;
/**
* {@internal Missing Description}}
*
* @since 2.1.0
* @access private
* @var string
*/
var $query_limit;
/**
* {@internal Missing Description}}
*
* @since 3.0.0
* @access private
* @var string
*/
var $query_orderby;
/**
* {@internal Missing Description}}
*
* @since 3.0.0
* @access private
* @var string
*/
var $query_from;
/**
* {@internal Missing Description}}
*
* @since 3.0.0
* @access private
* @var string
*/
var $query_where;
/**
* {@internal Missing Description}}
*
* @since 2.1.0
* @access private
* @var int
*/
var $total_users_for_query = 0;
/**
* {@internal Missing Description}}
*
* @since 2.1.0
* @access private
* @var bool
*/
var $too_many_total_users = false;
/**
* {@internal Missing Description}}
*
* @since 2.1.0
* @access private
* @var unknown_type
*/
var $search_errors;
/**
* {@internal Missing Description}}
*
* @since 2.7.0
* @access private
* @var unknown_type
*/
var $paging_text;
/**
* PHP4 Constructor - Sets up the object properties.
*
* @since 2.1.0
*
* @param string $search_term Search terms string.
* @param int $page Optional. Page ID.
* @param string $role Role name.
* @return WP_User_Search
*/
function WP_User_Search ($search_term = '', $page = '', $role = '') {
_deprecated_function( __FUNCTION__, '3.1', 'WP_User_Query' );
$this->search_term = stripslashes( $search_term );
$this->raw_page = ( '' == $page ) ? false : (int) $page;
$this->page = (int) ( '' == $page ) ? 1 : $page;
$this->role = $role;
$this->prepare_query();
$this->query();
$this->prepare_vars_for_template_usage();
$this->do_paging();
}
/**
* {@internal Missing Short Description}}
*
* {@internal Missing Long Description}}
*
* @since 2.1.0
* @access public
*/
function prepare_query() {
global $wpdb;
$this->first_user = ($this->page - 1) * $this->users_per_page;
$this->query_limit = $wpdb->prepare(" LIMIT %d, %d", $this->first_user, $this->users_per_page);
$this->query_orderby = ' ORDER BY user_login';
$search_sql = '';
if ( $this->search_term ) {
$searches = array();
$search_sql = 'AND (';
foreach ( array('user_login', 'user_nicename', 'user_email', 'user_url', 'display_name') as $col )
$searches[] = $wpdb->prepare( $col . ' LIKE %s', '%' . like_escape($this->search_term) . '%' );
$search_sql .= implode(' OR ', $searches);
$search_sql .= ')';
}
$this->query_from = " FROM $wpdb->users";
$this->query_where = " WHERE 1=1 $search_sql";
if ( $this->role ) {
$this->query_from .= " INNER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id";
$this->query_where .= $wpdb->prepare(" AND $wpdb->usermeta.meta_key = '{$wpdb->prefix}capabilities' AND $wpdb->usermeta.meta_value LIKE %s", '%' . $this->role . '%');
} elseif ( is_multisite() ) {
$level_key = $wpdb->prefix . 'capabilities'; // wpmu site admins don't have user_levels
$this->query_from .= ", $wpdb->usermeta";
$this->query_where .= " AND $wpdb->users.ID = $wpdb->usermeta.user_id AND meta_key = '{$level_key}'";
}
do_action_ref_array( 'pre_user_search', array( &$this ) );
}
/**
* {@internal Missing Short Description}}
*
* {@internal Missing Long Description}}
*
* @since 2.1.0
* @access public
*/
function query() {
global $wpdb;
$this->results = $wpdb->get_col("SELECT DISTINCT($wpdb->users.ID)" . $this->query_from . $this->query_where . $this->query_orderby . $this->query_limit);
if ( $this->results )
$this->total_users_for_query = $wpdb->get_var("SELECT COUNT(DISTINCT($wpdb->users.ID))" . $this->query_from . $this->query_where); // no limit
else
$this->search_errors = new WP_Error('no_matching_users_found', __('No matching users were found!'));
}
/**
* {@internal Missing Short Description}}
*
* {@internal Missing Long Description}}
*
* @since 2.1.0
* @access public
*/
function prepare_vars_for_template_usage() {
$this->search_term = stripslashes($this->search_term); // done with DB, from now on we want slashes gone
}
/**
* {@internal Missing Short Description}}
*
* {@internal Missing Long Description}}
*
* @since 2.1.0
* @access public
*/
function do_paging() {
if ( $this->total_users_for_query > $this->users_per_page ) { // have to page the results
$args = array();
if( ! empty($this->search_term) )
$args['usersearch'] = urlencode($this->search_term);
if( ! empty($this->role) )
$args['role'] = urlencode($this->role);
$this->paging_text = paginate_links( array(
'total' => ceil($this->total_users_for_query / $this->users_per_page),
'current' => $this->page,
'base' => 'users.php?%_%',
'format' => 'userspage=%#%',
'add_args' => $args
) );
if ( $this->paging_text ) {
$this->paging_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s',
number_format_i18n( ( $this->page - 1 ) * $this->users_per_page + 1 ),
number_format_i18n( min( $this->page * $this->users_per_page, $this->total_users_for_query ) ),
number_format_i18n( $this->total_users_for_query ),
$this->paging_text
);
}
}
}
/**
* {@internal Missing Short Description}}
*
* {@internal Missing Long Description}}
*
* @since 2.1.0
* @access public
*
* @return unknown
*/
function get_results() {
return (array) $this->results;
}
/**
* Displaying paging text.
*
* @see do_paging() Builds paging text.
*
* @since 2.1.0
* @access public
*/
function page_links() {
echo $this->paging_text;
}
/**
* Whether paging is enabled.
*
* @see do_paging() Builds paging text.
*
* @since 2.1.0
* @access public
*
* @return bool
*/
function results_are_paged() {
if ( $this->paging_text )
return true;
return false;
}
/**
* Whether there are search terms.
*
* @since 2.1.0
* @access public
*
* @return bool
*/
function is_search() {
if ( $this->search_term )
return true;
return false;
}
}
endif;
/**
* Retrieve editable posts from other users.
*
* @deprecated 3.1.0
*
* @param int $user_id User ID to not retrieve posts from.
* @param string $type Optional, defaults to 'any'. Post type to retrieve, can be 'draft' or 'pending'.
* @return array List of posts from others.
*/
function get_others_unpublished_posts($user_id, $type='any') {
_deprecated_function( __FUNCTION__, '3.1' );
global $wpdb;
$editable = get_editable_user_ids( $user_id );
if ( in_array($type, array('draft', 'pending')) )
$type_sql = " post_status = '$type' ";
else
$type_sql = " ( post_status = 'draft' OR post_status = 'pending' ) ";
$dir = ( 'pending' == $type ) ? 'ASC' : 'DESC';
if ( !$editable ) {
$other_unpubs = '';
} else {
$editable = join(',', $editable);
$other_unpubs = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_title, post_author FROM $wpdb->posts WHERE post_type = 'post' AND $type_sql AND post_author IN ($editable) AND post_author != %d ORDER BY post_modified $dir", $user_id) );
}
return apply_filters('get_others_drafts', $other_unpubs);
}
/**
* Retrieve drafts from other users.
*
* @deprecated 3.1.0
*
* @param int $user_id User ID.
* @return array List of drafts from other users.
*/
function get_others_drafts($user_id) {
_deprecated_function( __FUNCTION__, '3.1' );
return get_others_unpublished_posts($user_id, 'draft');
}
/**
* Retrieve pending review posts from other users.
*
* @deprecated 3.1.0
*
* @param int $user_id User ID.
* @return array List of posts with pending review post type from other users.
*/
function get_others_pending($user_id) {
_deprecated_function( __FUNCTION__, '3.1' );
return get_others_unpublished_posts($user_id, 'pending');
}
/**
* Output the QuickPress dashboard widget.
*
* @since 3.0.0
* @deprecated 3.2.0
* @deprecated Use wp_dashboard_quick_press()
* @see wp_dashboard_quick_press()
*/
function wp_dashboard_quick_press_output() {
_deprecated_function( __FUNCTION__, '3.2', 'wp_dashboard_quick_press()' );
wp_dashboard_quick_press();
}
/**
* @since 2.7.0
* @deprecated 3.3
* @deprecated Use wp_editor()
* @see wp_editor()
*/
function wp_tiny_mce( $teeny = false, $settings = false ) {
_deprecated_function( __FUNCTION__, '3.3', 'wp_editor()' );
static $num = 1;
if ( ! class_exists('_WP_Editors' ) )
require_once( ABSPATH . WPINC . '/class-wp-editor.php' );
$editor_id = 'content' . $num++;
$set = array(
'teeny' => $teeny,
'tinymce' => $settings ? $settings : true,
'quicktags' => false
);
$set = _WP_Editors::parse_settings($editor_id, $set);
_WP_Editors::editor_settings($editor_id, $set);
}
/**
* @deprecated 3.3.0
* @deprecated Use wp_editor()
* @see wp_editor()
*/
function wp_preload_dialogs() {
_deprecated_function( __FUNCTION__, '3.3', 'wp_editor()' );
}
/**
* @deprecated 3.3.0
* @deprecated Use wp_editor()
* @see wp_editor()
*/
function wp_print_editor_js() {
_deprecated_function( __FUNCTION__, '3.3', 'wp_editor()' );
}
/**
* @deprecated 3.3.0
* @deprecated Use wp_editor()
* @see wp_editor()
*/
function wp_quicktags() {
_deprecated_function( __FUNCTION__, '3.3', 'wp_editor()' );
}
/**
* Returns the screen layout options.
*
* @since 2.8.0
* @deprecated 3.3.0
* @deprecated Use $current_screen->render_screen_layout()
* @see WP_Screen::render_screen_layout()
*/
function screen_layout( $screen ) {
_deprecated_function( __FUNCTION__, '3.3', '$current_screen->render_screen_layout()' );
$current_screen = get_current_screen();
if ( ! $current_screen )
return '';
ob_start();
$current_screen->render_screen_layout();
return ob_get_clean();
}
/**
* Returns the screen's per-page options.
*
* @since 2.8.0
* @deprecated 3.3.0
* @deprecated Use $current_screen->render_per_page_options()
* @see WP_Screen::render_per_page_options()
*/
function screen_options( $screen ) {
_deprecated_function( __FUNCTION__, '3.3', '$current_screen->render_per_page_options()' );
$current_screen = get_current_screen();
if ( ! $current_screen )
return '';
ob_start();
$current_screen->render_per_page_options();
return ob_get_clean();
}
/**
* Renders the screen's help.
*
* @since 2.7.0
* @deprecated 3.3.0
* @deprecated Use $current_screen->render_screen_meta()
* @see WP_Screen::render_screen_meta()
*/
function screen_meta( $screen ) {
$current_screen = get_current_screen();
$current_screen->render_screen_meta();
}
/**
* Favorite actions were deprecated in version 3.2. Use the admin bar instead.
*
* @since 2.7.0
* @deprecated 3.2.0
*/
function favorite_actions() {
_deprecated_function( __FUNCTION__, '3.2', 'WP_Admin_Bar' );
}
function media_upload_image() {
__deprecated_function( __FUNCTION__, '3.3', 'wp_media_upload_handler()' );
return wp_media_upload_handler();
}
function media_upload_audio() {
__deprecated_function( __FUNCTION__, '3.3', 'wp_media_upload_handler()' );
return wp_media_upload_handler();
}
function media_upload_video() {
__deprecated_function( __FUNCTION__, '3.3', 'wp_media_upload_handler()' );
return wp_media_upload_handler();
}
function media_upload_file() {
__deprecated_function( __FUNCTION__, '3.3', 'wp_media_upload_handler()' );
return wp_media_upload_handler();
}
function type_url_form_image() {
__deprecated_function( __FUNCTION__, '3.3', "wp_media_insert_url_form('image')" );
return wp_media_insert_url_form( 'image' );
}
function type_url_form_audio() {
__deprecated_function( __FUNCTION__, '3.3', "wp_media_insert_url_form('audio')" );
return wp_media_insert_url_form( 'audio' );
}
function type_url_form_video() {
__deprecated_function( __FUNCTION__, '3.3', "wp_media_insert_url_form('video')" );
return wp_media_insert_url_form( 'video' );
}
function type_url_form_file() {
__deprecated_function( __FUNCTION__, '3.3', "wp_media_insert_url_form('file')" );
return wp_media_insert_url_form( 'file' );
}
/**
* Add contextual help text for a page.
*
* Creates an 'Overview' help tab.
*
* @since 2.7.0
* @deprecated 3.3.0
* @deprecated Use get_current_screen()->add_help_tab()
* @see WP_Screen
*
* @param string $screen The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions.
* @param string $help The content of an 'Overview' help tab.
*/
function add_contextual_help( $screen, $help ) {
_deprecated_function( __FUNCTION__, '3.3', 'get_current_screen()->add_help_tab()' );
if ( is_string( $screen ) )
$screen = convert_to_screen( $screen );
WP_Screen::add_old_compat_help( $screen, $help );
}
/**
* Get the allowed themes for the current blog.
*
* @since 3.0.0
* @deprecated 3.4.0
* @deprecated Use wp_get_themes()
* @see wp_get_themes()
*
* @return array $themes Array of allowed themes.
*/
function get_allowed_themes() {
_deprecated_function( __FUNCTION__, '3.4', "wp_get_themes( array( 'allowed' => true ) )" );
$themes = wp_get_themes( array( 'allowed' => true ) );
$wp_themes = array();
foreach ( $themes as $theme ) {
$wp_themes[ $theme->get('Name') ] = $theme;
}
return $wp_themes;
}
/**
* {@internal Missing Short Description}}
*
* @since 1.5.0
*
* @return unknown
*/
function get_broken_themes() {
_deprecated_function( __FUNCTION__, '3.4', "wp_get_themes( array( 'errors' => true )" );
$themes = wp_get_themes( array( 'errors' => true ) );
$broken = array();
foreach ( $themes as $theme ) {
$name = $theme->get('Name');
$broken[ $name ] = array(
'Name' => $name,
'Title' => $name,
'Description' => $theme->errors()->get_error_message(),
);
}
return $broken;
}
/**
* {@internal Missing Short Description}}
*
* @since 2.0.0
*
* @return unknown
*/
function current_theme_info() {
_deprecated_function( __FUNCTION__, '3.4', 'wp_get_theme()' );
return wp_get_theme();
} | 01happy-blog | trunk/myblog/wp-admin/includes/deprecated.php | PHP | oos | 22,849 |
<?php
/**
* WordPress Taxonomy Administration API.
*
* @package WordPress
* @subpackage Administration
*/
//
// Category
//
/**
* {@internal Missing Short Description}}
*
* @since 2.0.0
*
* @param unknown_type $cat_name
* @return unknown
*/
function category_exists($cat_name, $parent = 0) {
$id = term_exists($cat_name, 'category', $parent);
if ( is_array($id) )
$id = $id['term_id'];
return $id;
}
/**
* {@internal Missing Short Description}}
*
* @since 2.0.0
*
* @param unknown_type $id
* @return unknown
*/
function get_category_to_edit( $id ) {
$category = get_category( $id, OBJECT, 'edit' );
return $category;
}
/**
* {@internal Missing Short Description}}
*
* @since 2.0.0
*
* @param unknown_type $cat_name
* @param unknown_type $parent
* @return unknown
*/
function wp_create_category( $cat_name, $parent = 0 ) {
if ( $id = category_exists($cat_name, $parent) )
return $id;
return wp_insert_category( array('cat_name' => $cat_name, 'category_parent' => $parent) );
}
/**
* {@internal Missing Short Description}}
*
* @since 2.0.0
*
* @param unknown_type $categories
* @param unknown_type $post_id
* @return unknown
*/
function wp_create_categories($categories, $post_id = '') {
$cat_ids = array ();
foreach ($categories as $category) {
if ($id = category_exists($category))
$cat_ids[] = $id;
else
if ($id = wp_create_category($category))
$cat_ids[] = $id;
}
if ( $post_id )
wp_set_post_categories($post_id, $cat_ids);
return $cat_ids;
}
/**
* Updates an existing Category or creates a new Category.
*
* @since 2.0.0
*
* @param mixed $catarr See defaults below. Set 'cat_ID' to a non-zero value to update an existing category. The 'taxonomy' key was added in 3.0.0.
* @param bool $wp_error Optional, since 2.5.0. Set this to true if the caller handles WP_Error return values.
* @return int|object The ID number of the new or updated Category on success. Zero or a WP_Error on failure, depending on param $wp_error.
*/
function wp_insert_category($catarr, $wp_error = false) {
$cat_defaults = array('cat_ID' => 0, 'taxonomy' => 'category', 'cat_name' => '', 'category_description' => '', 'category_nicename' => '', 'category_parent' => '');
$catarr = wp_parse_args($catarr, $cat_defaults);
extract($catarr, EXTR_SKIP);
if ( trim( $cat_name ) == '' ) {
if ( ! $wp_error )
return 0;
else
return new WP_Error( 'cat_name', __('You did not enter a category name.') );
}
$cat_ID = (int) $cat_ID;
// Are we updating or creating?
if ( !empty ($cat_ID) )
$update = true;
else
$update = false;
$name = $cat_name;
$description = $category_description;
$slug = $category_nicename;
$parent = $category_parent;
$parent = (int) $parent;
if ( $parent < 0 )
$parent = 0;
if ( empty( $parent ) || ! term_exists( $parent, $taxonomy ) || ( $cat_ID && term_is_ancestor_of( $cat_ID, $parent, $taxonomy ) ) )
$parent = 0;
$args = compact('name', 'slug', 'parent', 'description');
if ( $update )
$cat_ID = wp_update_term($cat_ID, $taxonomy, $args);
else
$cat_ID = wp_insert_term($cat_name, $taxonomy, $args);
if ( is_wp_error($cat_ID) ) {
if ( $wp_error )
return $cat_ID;
else
return 0;
}
return $cat_ID['term_id'];
}
/**
* Aliases wp_insert_category() with minimal args.
*
* If you want to update only some fields of an existing category, call this
* function with only the new values set inside $catarr.
*
* @since 2.0.0
*
* @param array $catarr The 'cat_ID' value is required. All other keys are optional.
* @return int|bool The ID number of the new or updated Category on success. Zero or FALSE on failure.
*/
function wp_update_category($catarr) {
$cat_ID = (int) $catarr['cat_ID'];
if ( isset($catarr['category_parent']) && ($cat_ID == $catarr['category_parent']) )
return false;
// First, get all of the original fields
$category = get_category($cat_ID, ARRAY_A);
// Escape data pulled from DB.
$category = add_magic_quotes($category);
// Merge old and new fields with new fields overwriting old ones.
$catarr = array_merge($category, $catarr);
return wp_insert_category($catarr);
}
//
// Tags
//
/**
* {@internal Missing Short Description}}
*
* @since 2.3.0
*
* @param unknown_type $tag_name
* @return unknown
*/
function tag_exists($tag_name) {
return term_exists($tag_name, 'post_tag');
}
/**
* {@internal Missing Short Description}}
*
* @since 2.3.0
*
* @param unknown_type $tag_name
* @return unknown
*/
function wp_create_tag($tag_name) {
return wp_create_term( $tag_name, 'post_tag');
}
/**
* {@internal Missing Short Description}}
*
* @since 2.3.0
*
* @param unknown_type $post_id
* @return unknown
*/
function get_tags_to_edit( $post_id, $taxonomy = 'post_tag' ) {
return get_terms_to_edit( $post_id, $taxonomy);
}
/**
* {@internal Missing Short Description}}
*
* @since 2.8.0
*
* @param unknown_type $post_id
* @return unknown
*/
function get_terms_to_edit( $post_id, $taxonomy = 'post_tag' ) {
$post_id = (int) $post_id;
if ( !$post_id )
return false;
$tags = wp_get_post_terms($post_id, $taxonomy, array());
if ( !$tags )
return false;
if ( is_wp_error($tags) )
return $tags;
foreach ( $tags as $tag )
$tag_names[] = $tag->name;
$tags_to_edit = join( ',', $tag_names );
$tags_to_edit = esc_attr( $tags_to_edit );
$tags_to_edit = apply_filters( 'terms_to_edit', $tags_to_edit, $taxonomy );
return $tags_to_edit;
}
/**
* {@internal Missing Short Description}}
*
* @since 2.8.0
*
* @param unknown_type $tag_name
* @return unknown
*/
function wp_create_term($tag_name, $taxonomy = 'post_tag') {
if ( $id = term_exists($tag_name, $taxonomy) )
return $id;
return wp_insert_term($tag_name, $taxonomy);
}
| 01happy-blog | trunk/myblog/wp-admin/includes/taxonomy.php | PHP | oos | 5,745 |
<?php
/**
* WordPress Plugin Install Administration API
*
* @package WordPress
* @subpackage Administration
*/
/**
* Retrieve plugin installer pages from WordPress Plugins API.
*
* It is possible for a plugin to override the Plugin API result with three
* filters. Assume this is for plugins, which can extend on the Plugin Info to
* offer more choices. This is very powerful and must be used with care, when
* overriding the filters.
*
* The first filter, 'plugins_api_args', is for the args and gives the action as
* the second parameter. The hook for 'plugins_api_args' must ensure that an
* object is returned.
*
* The second filter, 'plugins_api', is the result that would be returned.
*
* @since 2.7.0
*
* @param string $action
* @param array|object $args Optional. Arguments to serialize for the Plugin Info API.
* @return object plugins_api response object on success, WP_Error on failure.
*/
function plugins_api($action, $args = null) {
if ( is_array($args) )
$args = (object)$args;
if ( !isset($args->per_page) )
$args->per_page = 24;
// Allows a plugin to override the WordPress.org API entirely.
// Use the filter 'plugins_api_result' to merely add results.
// Please ensure that a object is returned from the following filters.
$args = apply_filters('plugins_api_args', $args, $action);
$res = apply_filters('plugins_api', false, $action, $args);
if ( false === $res ) {
$request = wp_remote_post('http://api.wordpress.org/plugins/info/1.0/', array( 'timeout' => 15, 'body' => array('action' => $action, 'request' => serialize($args))) );
if ( is_wp_error($request) ) {
$res = new WP_Error('plugins_api_failed', __( '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="http://wordpress.org/support/">support forums</a>.' ), $request->get_error_message() );
} else {
$res = maybe_unserialize( wp_remote_retrieve_body( $request ) );
if ( ! is_object( $res ) && ! is_array( $res ) )
$res = new WP_Error('plugins_api_failed', __( '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="http://wordpress.org/support/">support forums</a>.' ), wp_remote_retrieve_body( $request ) );
}
} elseif ( !is_wp_error($res) ) {
$res->external = true;
}
return apply_filters('plugins_api_result', $res, $action, $args);
}
/**
* Retrieve popular WordPress plugin tags.
*
* @since 2.7.0
*
* @param array $args
* @return array
*/
function install_popular_tags( $args = array() ) {
$key = md5(serialize($args));
if ( false !== ($tags = get_site_transient('poptags_' . $key) ) )
return $tags;
$tags = plugins_api('hot_tags', $args);
if ( is_wp_error($tags) )
return $tags;
set_site_transient('poptags_' . $key, $tags, 10800); // 3 * 60 * 60 = 10800
return $tags;
}
function install_dashboard() {
?>
<p><?php printf( __( 'Plugins extend and expand the functionality of WordPress. You may automatically install plugins from the <a href="http://wordpress.org/extend/plugins/">WordPress Plugin Directory</a> or upload a plugin in .zip format via <a href="%s">this page</a>.' ), self_admin_url( 'plugin-install.php?tab=upload' ) ); ?></p>
<h4><?php _e('Search') ?></h4>
<?php install_search_form( false ); ?>
<h4><?php _e('Popular tags') ?></h4>
<p class="install-help"><?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) ) {
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 )
$tags[ $tag['name'] ] = (object) array(
'link' => esc_url( self_admin_url('plugin-install.php?tab=search&type=tag&s=' . urlencode($tag['name'])) ),
'name' => $tag['name'],
'id' => sanitize_title_with_dashes($tag['name']),
'count' => $tag['count'] );
echo wp_generate_tag_cloud($tags, array( 'single_text' => __('%s plugin'), 'multiple_text' => __('%s plugins') ) );
}
echo '</p><br class="clear" />';
}
add_action('install_plugins_dashboard', 'install_dashboard');
/**
* Display search form for searching plugins.
*
* @since 2.7.0
*/
function install_search_form( $type_selector = true ) {
$type = isset($_REQUEST['type']) ? stripslashes( $_REQUEST['type'] ) : 'term';
$term = isset($_REQUEST['s']) ? stripslashes( $_REQUEST['s'] ) : '';
?><form id="search-plugins" method="get" action="">
<input type="hidden" name="tab" value="search" />
<?php if ( $type_selector ) : ?>
<select name="type" id="typeselector">
<option value="term"<?php selected('term', $type) ?>><?php _e('Keyword'); ?></option>
<option value="author"<?php selected('author', $type) ?>><?php _e('Author'); ?></option>
<option value="tag"<?php selected('tag', $type) ?>><?php _ex('Tag', 'Plugin Installer'); ?></option>
</select>
<?php endif; ?>
<input type="search" name="s" value="<?php echo esc_attr($term) ?>" />
<label class="screen-reader-text" for="plugin-search-input"><?php _e('Search Plugins'); ?></label>
<?php submit_button( __( 'Search Plugins' ), 'button', 'plugin-search-input', false ); ?>
</form><?php
}
/**
* Upload from zip
* @since 2.8.0
*
* @param string $page
*/
function install_plugins_upload( $page = 1 ) {
?>
<h4><?php _e('Install a plugin in .zip format') ?></h4>
<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" 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" />
<input type="submit" class="button" value="<?php esc_attr_e('Install Now') ?>" />
</form>
<?php
}
add_action('install_plugins_upload', 'install_plugins_upload', 10, 1);
/**
* Display plugin content based on plugin list.
*
* @since 2.7.0
*/
function display_plugins_table() {
global $wp_list_table;
$wp_list_table->display();
}
add_action('install_plugins_search', 'display_plugins_table');
add_action('install_plugins_featured', 'display_plugins_table');
add_action('install_plugins_popular', 'display_plugins_table');
add_action('install_plugins_new', 'display_plugins_table');
/**
* Determine the status we can perform on a plugin.
*
* @since 3.0.0
*/
function install_plugin_install_status($api, $loop = false) {
// this function is called recursively, $loop prevents further loops.
if ( is_array($api) )
$api = (object) $api;
//Default to a "new" plugin
$status = 'install';
$url = 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');
if ( isset( $update_plugins->response ) ) {
foreach ( (array)$update_plugins->response as $file => $plugin ) {
if ( $plugin->slug === $api->slug ) {
$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);
break;
}
}
}
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);
} else {
$key = array_shift( $key = array_keys($installed_plugin) ); //Use the first plugin regardless of the name, Could have issues for multiple-plugins in one directory if they share different version numbers
if ( version_compare($api->version, $installed_plugin[ $key ]['Version'], '=') ){
$status = 'latest_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');
wp_update_plugins();
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 ( isset($_GET['from']) )
$url .= '&from=' . urlencode(stripslashes($_GET['from']));
return compact('status', 'url', 'version');
}
/**
* Display plugin information in dialog box form.
*
* @since 2.7.0
*/
function install_plugin_information() {
global $tab;
$api = plugins_api('plugin_information', array('slug' => stripslashes( $_REQUEST['plugin'] ) ));
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(), 'p' => array(), 'ul' => array(), 'ol' => array(), 'li' => array(),
'h1' => array(), 'h2' => array(), 'h3' => array(), 'h4' => array(), 'h5' => array(), 'h6' => array(),
'img' => array( 'src' => array(), 'class' => array(), 'alt' => array() )
);
$plugins_section_titles = array(
'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'),
'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);
foreach ( array( 'version', 'author', 'requires', 'tested', 'homepage', 'downloaded', 'slug' ) as $key ) {
if ( isset( $api->$key ) )
$api->$key = wp_kses( $api->$key, $plugins_allowedtags );
}
$section = isset($_REQUEST['section']) ? stripslashes( $_REQUEST['section'] ) : 'description'; //Default to the Description tab, Do not translate, API returns English.
if ( empty($section) || ! isset($api->sections[ $section ]) )
$section = array_shift( $section_titles = array_keys((array)$api->sections) );
iframe_header( __('Plugin Install') );
echo "<div id='$tab-header'>\n";
echo "<ul id='sidemenu'>\n";
foreach ( (array)$api->sections as $section_name => $content ) {
if ( isset( $plugins_section_titles[ $section_name ] ) )
$title = $plugins_section_titles[ $section_name ];
else
$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);
$san_section = esc_attr( $section_name );
echo "\t<li><a name='$san_section' href='$href' $class>$title</a></li>\n";
}
echo "</ul>\n";
echo "</div>\n";
?>
<div class="alignright fyi">
<?php if ( ! empty($api->download_link) && ( current_user_can('install_plugins') || current_user_can('update_plugins') ) ) : ?>
<p class="action-button">
<?php
$status = install_plugin_install_status($api);
switch ( $status['status'] ) {
case 'install':
if ( $status['url'] )
echo '<a href="' . $status['url'] . '" target="_parent">' . __('Install Now') . '</a>';
break;
case 'update_available':
if ( $status['url'] )
echo '<a href="' . $status['url'] . '" target="_parent">' . __('Install Update Now') .'</a>';
break;
case 'newer_installed':
echo '<a>' . sprintf(__('Newer Version (%s) Installed'), $status['version']) . '</a>';
break;
case 'latest_installed':
echo '<a>' . __('Latest Version Installed') . '</a>';
break;
}
?>
</p>
<?php endif; ?>
<h2 class="mainheader"><?php /* translators: For Your Information */ _e('FYI') ?></h2>
<ul>
<?php if ( ! empty($api->version) ) : ?>
<li><strong><?php _e('Version:') ?></strong> <?php echo $api->version ?></li>
<?php endif; if ( ! empty($api->author) ) : ?>
<li><strong><?php _e('Author:') ?></strong> <?php echo links_add_target($api->author, '_blank') ?></li>
<?php endif; if ( ! empty($api->last_updated) ) : ?>
<li><strong><?php _e('Last Updated:') ?></strong> <span title="<?php echo $api->last_updated ?>"><?php
printf( __('%s ago'), human_time_diff(strtotime($api->last_updated)) ) ?></span></li>
<?php endif; if ( ! empty($api->requires) ) : ?>
<li><strong><?php _e('Requires WordPress Version:') ?></strong> <?php printf(__('%s or higher'), $api->requires) ?></li>
<?php endif; if ( ! empty($api->tested) ) : ?>
<li><strong><?php _e('Compatible up to:') ?></strong> <?php echo $api->tested ?></li>
<?php endif; if ( ! empty($api->downloaded) ) : ?>
<li><strong><?php _e('Downloaded:') ?></strong> <?php printf(_n('%s time', '%s times', $api->downloaded), number_format_i18n($api->downloaded)) ?></li>
<?php endif; if ( ! empty($api->slug) && empty($api->external) ) : ?>
<li><a target="_blank" href="http://wordpress.org/extend/plugins/<?php echo $api->slug ?>/"><?php _e('WordPress.org Plugin Page »') ?></a></li>
<?php endif; if ( ! empty($api->homepage) ) : ?>
<li><a target="_blank" href="<?php echo $api->homepage ?>"><?php _e('Plugin Homepage »') ?></a></li>
<?php endif; ?>
</ul>
<?php if ( ! empty($api->rating) ) : ?>
<h2><?php _e('Average Rating') ?></h2>
<div class="star-holder" title="<?php printf(_n('(based on %s rating)', '(based on %s ratings)', $api->num_ratings), number_format_i18n($api->num_ratings)); ?>">
<div class="star star-rating" style="width: <?php echo esc_attr( str_replace( ',', '.', $api->rating ) ); ?>px"></div>
</div>
<small><?php printf(_n('(based on %s rating)', '(based on %s ratings)', $api->num_ratings), number_format_i18n($api->num_ratings)); ?></small>
<?php endif; ?>
</div>
<div id="section-holder" class="wrap">
<?php
if ( !empty($api->tested) && version_compare( substr($GLOBALS['wp_version'], 0, strlen($api->tested)), $api->tested, '>') )
echo '<div class="updated"><p>' . __('<strong>Warning:</strong> This plugin has <strong>not been tested</strong> with your current version of WordPress.') . '</p></div>';
else if ( !empty($api->requires) && version_compare( substr($GLOBALS['wp_version'], 0, strlen($api->requires)), $api->requires, '<') )
echo '<div class="updated"><p>' . __('<strong>Warning:</strong> This plugin has <strong>not been marked as compatible</strong> with your version of WordPress.') . '</p></div>';
foreach ( (array)$api->sections as $section_name => $content ) {
if ( isset( $plugins_section_titles[ $section_name ] ) )
$title = $plugins_section_titles[ $section_name ];
else
$title = ucwords( str_replace( '_', ' ', $section_name ) );
$content = links_add_base_url($content, 'http://wordpress.org/extend/plugins/' . $api->slug . '/');
$content = links_add_target($content, '_blank');
$san_section = esc_attr( $section_name );
$display = ( $section_name == $section ) ? 'block' : 'none';
echo "\t<div id='section-{$san_section}' class='section' style='display: {$display};'>\n";
echo "\t\t<h2 class='long-header'>$title</h2>";
echo $content;
echo "\t</div>\n";
}
echo "</div>\n";
iframe_footer();
exit;
}
add_action('install_plugins_pre_plugin-information', 'install_plugin_information');
| 01happy-blog | trunk/myblog/wp-admin/includes/plugin-install.php | PHP | oos | 16,270 |
<?php
/**
* WordPress Widgets Administration API
*
* @package WordPress
* @subpackage Administration
*/
/**
* Display list of the available widgets.
*
* @since 2.5.0
*/
function wp_list_widgets() {
global $wp_registered_widgets, $sidebars_widgets, $wp_registered_widget_controls;
$sort = $wp_registered_widgets;
usort( $sort, '_sort_name_callback' );
$done = array();
foreach ( $sort as $widget ) {
if ( in_array( $widget['callback'], $done, true ) ) // We already showed this multi-widget
continue;
$sidebar = is_active_widget( $widget['callback'], $widget['id'], false, false );
$done[] = $widget['callback'];
if ( ! isset( $widget['params'][0] ) )
$widget['params'][0] = array();
$args = array( 'widget_id' => $widget['id'], 'widget_name' => $widget['name'], '_display' => 'template' );
if ( isset($wp_registered_widget_controls[$widget['id']]['id_base']) && isset($widget['params'][0]['number']) ) {
$id_base = $wp_registered_widget_controls[$widget['id']]['id_base'];
$args['_temp_id'] = "$id_base-__i__";
$args['_multi_num'] = next_widget_id_number($id_base);
$args['_add'] = 'multi';
} else {
$args['_add'] = 'single';
if ( $sidebar )
$args['_hide'] = '1';
}
$args = wp_list_widget_controls_dynamic_sidebar( array( 0 => $args, 1 => $widget['params'][0] ) );
call_user_func_array( 'wp_widget_control', $args );
}
}
/**
* Callback to sort array by a 'name' key.
*
* @since 3.1.0
* @access private
*/
function _sort_name_callback( $a, $b ) {
return strnatcasecmp( $a['name'], $b['name'] );
}
/**
* Show the widgets and their settings for a sidebar.
* Used in the the admin widget config screen.
*
* @since 2.5.0
*
* @param string $sidebar id slug of the sidebar
*/
function wp_list_widget_controls( $sidebar ) {
add_filter( 'dynamic_sidebar_params', 'wp_list_widget_controls_dynamic_sidebar' );
echo "<div id='$sidebar' class='widgets-sortables'>\n";
$description = wp_sidebar_description( $sidebar );
if ( !empty( $description ) ) {
echo "<div class='sidebar-description'>\n";
echo "\t<p class='description'>$description</p>";
echo "</div>\n";
}
dynamic_sidebar( $sidebar );
echo "</div>\n";
}
/**
* {@internal Missing Short Description}}
*
* @since 2.5.0
*
* @param array $params
* @return array
*/
function wp_list_widget_controls_dynamic_sidebar( $params ) {
global $wp_registered_widgets;
static $i = 0;
$i++;
$widget_id = $params[0]['widget_id'];
$id = isset($params[0]['_temp_id']) ? $params[0]['_temp_id'] : $widget_id;
$hidden = isset($params[0]['_hide']) ? ' style="display:none;"' : '';
$params[0]['before_widget'] = "<div id='widget-{$i}_{$id}' class='widget'$hidden>";
$params[0]['after_widget'] = "</div>";
$params[0]['before_title'] = "%BEG_OF_TITLE%"; // deprecated
$params[0]['after_title'] = "%END_OF_TITLE%"; // deprecated
if ( is_callable( $wp_registered_widgets[$widget_id]['callback'] ) ) {
$wp_registered_widgets[$widget_id]['_callback'] = $wp_registered_widgets[$widget_id]['callback'];
$wp_registered_widgets[$widget_id]['callback'] = 'wp_widget_control';
}
return $params;
}
function next_widget_id_number($id_base) {
global $wp_registered_widgets;
$number = 1;
foreach ( $wp_registered_widgets as $widget_id => $widget ) {
if ( preg_match( '/' . $id_base . '-([0-9]+)$/', $widget_id, $matches ) )
$number = max($number, $matches[1]);
}
$number++;
return $number;
}
/**
* Meta widget used to display the control form for a widget.
*
* Called from dynamic_sidebar().
*
* @since 2.5.0
*
* @param array $sidebar_args
* @return array
*/
function wp_widget_control( $sidebar_args ) {
global $wp_registered_widgets, $wp_registered_widget_controls, $sidebars_widgets;
$widget_id = $sidebar_args['widget_id'];
$sidebar_id = isset($sidebar_args['id']) ? $sidebar_args['id'] : false;
$key = $sidebar_id ? array_search( $widget_id, $sidebars_widgets[$sidebar_id] ) : '-1'; // position of widget in sidebar
$control = isset($wp_registered_widget_controls[$widget_id]) ? $wp_registered_widget_controls[$widget_id] : array();
$widget = $wp_registered_widgets[$widget_id];
$id_format = $widget['id'];
$widget_number = isset($control['params'][0]['number']) ? $control['params'][0]['number'] : '';
$id_base = isset($control['id_base']) ? $control['id_base'] : $widget_id;
$multi_number = isset($sidebar_args['_multi_num']) ? $sidebar_args['_multi_num'] : '';
$add_new = isset($sidebar_args['_add']) ? $sidebar_args['_add'] : '';
$query_arg = array( 'editwidget' => $widget['id'] );
if ( $add_new ) {
$query_arg['addnew'] = 1;
if ( $multi_number ) {
$query_arg['num'] = $multi_number;
$query_arg['base'] = $id_base;
}
} else {
$query_arg['sidebar'] = $sidebar_id;
$query_arg['key'] = $key;
}
// We aren't showing a widget control, we're outputting a template for a multi-widget control
if ( isset($sidebar_args['_display']) && 'template' == $sidebar_args['_display'] && $widget_number ) {
// number == -1 implies a template where id numbers are replaced by a generic '__i__'
$control['params'][0]['number'] = -1;
// with id_base widget id's are constructed like {$id_base}-{$id_number}
if ( isset($control['id_base']) )
$id_format = $control['id_base'] . '-__i__';
}
$wp_registered_widgets[$widget_id]['callback'] = $wp_registered_widgets[$widget_id]['_callback'];
unset($wp_registered_widgets[$widget_id]['_callback']);
$widget_title = esc_html( strip_tags( $sidebar_args['widget_name'] ) );
$has_form = 'noform';
echo $sidebar_args['before_widget']; ?>
<div class="widget-top">
<div class="widget-title-action">
<a class="widget-action hide-if-no-js" href="#available-widgets"></a>
<a class="widget-control-edit hide-if-js" href="<?php echo esc_url( add_query_arg( $query_arg ) ); ?>"><span class="edit"><?php _e('Edit'); ?></span><span class="add"><?php _e('Add'); ?></span></a>
</div>
<div class="widget-title"><h4><?php echo $widget_title ?><span class="in-widget-title"></span></h4></div>
</div>
<div class="widget-inside">
<form action="" method="post">
<div class="widget-content">
<?php
if ( isset($control['callback']) )
$has_form = call_user_func_array( $control['callback'], $control['params'] );
else
echo "\t\t<p>" . __('There are no options for this widget.') . "</p>\n"; ?>
</div>
<input type="hidden" name="widget-id" class="widget-id" value="<?php echo esc_attr($id_format); ?>" />
<input type="hidden" name="id_base" class="id_base" value="<?php echo esc_attr($id_base); ?>" />
<input type="hidden" name="widget-width" class="widget-width" value="<?php if (isset( $control['width'] )) echo esc_attr($control['width']); ?>" />
<input type="hidden" name="widget-height" class="widget-height" value="<?php if (isset( $control['height'] )) echo esc_attr($control['height']); ?>" />
<input type="hidden" name="widget_number" class="widget_number" value="<?php echo esc_attr($widget_number); ?>" />
<input type="hidden" name="multi_number" class="multi_number" value="<?php echo esc_attr($multi_number); ?>" />
<input type="hidden" name="add_new" class="add_new" value="<?php echo esc_attr($add_new); ?>" />
<div class="widget-control-actions">
<div class="alignleft">
<a class="widget-control-remove" href="#remove"><?php _e('Delete'); ?></a> |
<a class="widget-control-close" href="#close"><?php _e('Close'); ?></a>
</div>
<div class="alignright<?php if ( 'noform' === $has_form ) echo ' widget-control-noform'; ?>">
<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-feedback" title="" alt="" />
<?php submit_button( __( 'Save' ), 'button-primary widget-control-save', 'savewidget', false, array( 'id' => 'widget-' . esc_attr( $id_format ) . '-savewidget' ) ); ?>
</div>
<br class="clear" />
</div>
</form>
</div>
<div class="widget-description">
<?php echo ( $widget_description = wp_widget_description($widget_id) ) ? "$widget_description\n" : "$widget_title\n"; ?>
</div>
<?php
echo $sidebar_args['after_widget'];
return $sidebar_args;
}
| 01happy-blog | trunk/myblog/wp-admin/includes/widgets.php | PHP | oos | 8,074 |
<?php
/**
* WordPress Comment Administration API.
*
* @package WordPress
* @subpackage Administration
*/
/**
* {@internal Missing Short Description}}
*
* @since 2.0.0
* @uses $wpdb
*
* @param string $comment_author Author of the comment
* @param string $comment_date Date of the comment
* @return mixed Comment ID on success.
*/
function comment_exists($comment_author, $comment_date) {
global $wpdb;
$comment_author = stripslashes($comment_author);
$comment_date = stripslashes($comment_date);
return $wpdb->get_var( $wpdb->prepare("SELECT comment_post_ID FROM $wpdb->comments
WHERE comment_author = %s AND comment_date = %s", $comment_author, $comment_date) );
}
/**
* Update a comment with values provided in $_POST.
*
* @since 2.0.0
*/
function edit_comment() {
if ( ! current_user_can( 'edit_comment', (int) $_POST['comment_ID'] ) )
wp_die ( __( 'You are not allowed to edit comments on this post.' ) );
$_POST['comment_author'] = $_POST['newcomment_author'];
$_POST['comment_author_email'] = $_POST['newcomment_author_email'];
$_POST['comment_author_url'] = $_POST['newcomment_author_url'];
$_POST['comment_approved'] = $_POST['comment_status'];
$_POST['comment_content'] = $_POST['content'];
$_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] ) {
$_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;
$_POST['comment_date'] = "$aa-$mm-$jj $hh:$mn:$ss";
}
wp_update_comment( $_POST );
}
/**
* {@internal Missing Short Description}}
*
* @since 2.0.0
*
* @param int $id ID of comment to retrieve
* @return bool|object Comment if found. False on failure.
*/
function get_comment_to_edit( $id ) {
if ( !$comment = get_comment($id) )
return false;
$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 );
$comment->comment_content = apply_filters( 'comment_edit_pre', $comment->comment_content);
$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);
return $comment;
}
/**
* Get the number of pending comments on a post or posts
*
* @since 2.3.0
* @uses $wpdb
*
* @param int|array $post_id Either a single Post ID or an array of Post IDs
* @return int|array Either a single Posts pending comments as an int or an array of ints keyed on the Post IDs
*/
function get_pending_comments_num( $post_id ) {
global $wpdb;
$single = false;
if ( !is_array($post_id) ) {
$post_id_array = (array) $post_id;
$single = true;
} else {
$post_id_array = $post_id;
}
$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) )
return 0;
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;
if ( !empty($pending) )
foreach ( $pending as $pend )
$pending_keyed[$pend['comment_post_ID']] = absint($pend['num_comments']);
return $pending_keyed;
}
/**
* Add avatars to relevant places in admin, or try to.
*
* @since 2.5.0
* @uses $comment
*
* @param string $name User name.
* @return string Avatar with Admin name.
*/
function floated_admin_avatar( $name ) {
global $comment;
$avatar = get_avatar( $comment, 32 );
return "$avatar $name";
}
function enqueue_comment_hotkeys_js() {
if ( 'true' == get_user_option( 'comment_shortcuts' ) )
wp_enqueue_script( 'jquery-table-hotkeys' );
}
| 01happy-blog | trunk/myblog/wp-admin/includes/comment.php | PHP | oos | 4,500 |
<?php
/**
* WordPress Image Editor
*
* @package WordPress
* @subpackage Administration
*/
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 ( is_array($meta) && isset($meta['width']) )
$big = max( $meta['width'], $meta['height'] );
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 = !empty($backup_sizes) && isset($backup_sizes['full-orig'])
&& $backup_sizes['full-orig']['file'] != basename($meta['file']);
if ( $msg ) {
if ( isset($msg->error) )
$note = "<div class='error'><p>$msg->error</p></div>";
elseif ( isset($msg->msg) )
$note = "<div class='updated'><p>$msg->msg</p></div>";
}
?>
<div class="imgedit-wrap">
<?php echo $note; ?>
<table id="imgedit-panel-<?php echo $post_id; ?>"><tbody>
<tr><td>
<div class="imgedit-menu">
<div onclick="imageEdit.crop(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-crop disabled" title="<?php esc_attr_e( 'Crop' ); ?>"></div><?php
// On some setups GD library does not provide imagerotate() - Ticket #11536
if ( function_exists('imagerotate') ) { ?>
<div class="imgedit-rleft" onclick="imageEdit.rotate( 90, <?php echo "$post_id, '$nonce'"; ?>, this)" title="<?php esc_attr_e( 'Rotate counter-clockwise' ); ?>"></div>
<div class="imgedit-rright" onclick="imageEdit.rotate(-90, <?php echo "$post_id, '$nonce'"; ?>, this)" title="<?php esc_attr_e( 'Rotate clockwise' ); ?>"></div>
<?php } else {
$note_gdlib = esc_attr__('Image rotation is not supported by your web host (function imagerotate() is missing)');
?>
<div class="imgedit-rleft disabled" title="<?php echo $note_gdlib; ?>"></div>
<div class="imgedit-rright disabled" title="<?php echo $note_gdlib; ?>"></div>
<?php } ?>
<div onclick="imageEdit.flip(1, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-flipv" title="<?php esc_attr_e( 'Flip vertically' ); ?>"></div>
<div onclick="imageEdit.flip(2, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-fliph" title="<?php esc_attr_e( 'Flip horizontally' ); ?>"></div>
<div id="image-undo-<?php echo $post_id; ?>" onclick="imageEdit.undo(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-undo disabled" title="<?php esc_attr_e( 'Undo' ); ?>"></div>
<div id="image-redo-<?php echo $post_id; ?>" onclick="imageEdit.redo(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-redo disabled" title="<?php esc_attr_e( 'Redo' ); ?>"></div>
<br class="clear" />
</div>
<input type="hidden" id="imgedit-sizer-<?php echo $post_id; ?>" value="<?php echo $sizer; ?>" />
<input type="hidden" id="imgedit-minthumb-<?php echo $post_id; ?>" value="<?php echo ( get_option('thumbnail_size_w') . ':' . get_option('thumbnail_size_h') ); ?>" />
<input type="hidden" id="imgedit-history-<?php echo $post_id; ?>" value="" />
<input type="hidden" id="imgedit-undone-<?php echo $post_id; ?>" value="0" />
<input type="hidden" id="imgedit-selection-<?php echo $post_id; ?>" value="" />
<input type="hidden" id="imgedit-x-<?php echo $post_id; ?>" value="<?php echo $meta['width']; ?>" />
<input type="hidden" id="imgedit-y-<?php echo $post_id; ?>" value="<?php echo $meta['height']; ?>" />
<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); ?>" />
</div>
<div class="imgedit-submit">
<input type="button" onclick="imageEdit.close(<?php echo $post_id; ?>, 1)" class="button" value="<?php esc_attr_e( 'Cancel' ); ?>" />
<input type="button" onclick="imageEdit.save(<?php echo "$post_id, '$nonce'"; ?>)" disabled="disabled" class="button-primary imgedit-submit-btn" value="<?php esc_attr_e( 'Save' ); ?>" />
</div>
</td>
<td class="imgedit-settings">
<div class="imgedit-group">
<div class="imgedit-group-top">
<a class="imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);return false;" href="#"><strong><?php _e('Scale Image'); ?></strong></a>
<div class="imgedit-help">
<p><?php _e('You can proportionally scale the original image. For best results the scaling should be done before performing any other operations on it like crop, rotate, etc. Note that if you make the image larger it may become fuzzy.'); ?></p>
<p><?php printf( __('Original dimensions %s'), $meta['width'] . '×' . $meta['height'] ); ?></p>
<div class="imgedit-submit">
<span class="nowrap"><input type="text" id="imgedit-scale-width-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1)" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1)" style="width:4em;" value="<?php echo $meta['width']; ?>" />×<input type="text" id="imgedit-scale-height-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0)" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0)" style="width:4em;" value="<?php echo $meta['height']; ?>" />
<span class="imgedit-scale-warn" id="imgedit-scale-warn-<?php echo $post_id; ?>">!</span></span>
<input type="button" onclick="imageEdit.action(<?php echo "$post_id, '$nonce'"; ?>, 'scale')" class="button-primary" value="<?php esc_attr_e( 'Scale' ); ?>" />
</div>
</div>
</div>
<?php if ( $can_restore ) { ?>
<div class="imgedit-group-top">
<a class="imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);return false;" href="#"><strong><?php _e('Restore Original Image'); ?></strong></a>
<div class="imgedit-help">
<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.');
?></p>
<div class="imgedit-submit">
<input type="button" onclick="imageEdit.action(<?php echo "$post_id, '$nonce'"; ?>, 'restore')" class="button-primary" value="<?php esc_attr_e( 'Restore image' ); ?>" <?php echo $can_restore; ?> />
</div>
</div>
</div>
<?php } ?>
</div>
<div class="imgedit-group">
<div class="imgedit-group-top">
<strong><?php _e('Image Crop'); ?></strong>
<a class="imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);return false;" href="#"><?php _e('(help)'); ?></a>
<div class="imgedit-help">
<p><?php _e('The image can be cropped by clicking on it and dragging to select the desired part. While dragging the dimensions of the selection are displayed below.'); ?></p>
<strong><?php _e('Keyboard Shortcuts'); ?></strong>
<ul>
<li><?php _e('Arrow: move by 10px'); ?></li>
<li><?php _e('Shift + arrow: move by 1px'); ?></li>
<li><?php _e('Ctrl + arrow: resize by 10px'); ?></li>
<li><?php _e('Ctrl + Shift + arrow: resize by 1px'); ?></li>
<li><?php _e('Shift + drag: lock aspect ratio'); ?></li>
</ul>
<p><strong><?php _e('Crop Aspect Ratio'); ?></strong><br />
<?php _e('You can specify the crop selection aspect ratio then hold down the Shift key while dragging to lock it. The values can be 1:1 (square), 4:3, 16:9, etc. If there is a selection, specifying aspect ratio will set it immediately.'); ?></p>
<p><strong><?php _e('Crop Selection'); ?></strong><br />
<?php _e('Once started, the selection can be adjusted by entering new values (in pixels). Note that these values are scaled to approximately match the original image dimensions. The minimum selection size equals the thumbnail size as set in the Media settings.'); ?></p>
</div>
</div>
<p>
<?php _e('Aspect ratio:'); ?>
<span class="nowrap">
<input type="text" id="imgedit-crop-width-<?php echo $post_id; ?>" onkeyup="imageEdit.setRatioSelection(<?php echo $post_id; ?>, 0, this)" style="width:3em;" />
:
<input type="text" id="imgedit-crop-height-<?php echo $post_id; ?>" onkeyup="imageEdit.setRatioSelection(<?php echo $post_id; ?>, 1, this)" style="width:3em;" />
</span>
</p>
<p id="imgedit-crop-sel-<?php echo $post_id; ?>">
<?php _e('Selection:'); ?>
<span class="nowrap">
<input type="text" id="imgedit-sel-width-<?php echo $post_id; ?>" onkeyup="imageEdit.setNumSelection(<?php echo $post_id; ?>)" style="width:4em;" />
:
<input type="text" id="imgedit-sel-height-<?php echo $post_id; ?>" onkeyup="imageEdit.setNumSelection(<?php echo $post_id; ?>)" style="width:4em;" />
</span>
</p>
</div>
<?php if ( $thumb && $sub_sizes ) {
$thumb_img = wp_constrain_dimensions( $thumb['width'], $thumb['height'], 160, 120 );
?>
<div class="imgedit-group imgedit-applyto">
<div class="imgedit-group-top">
<strong><?php _e('Thumbnail Settings'); ?></strong>
<a class="imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);return false;" href="#"><?php _e('(help)'); ?></a>
<p class="imgedit-help"><?php _e('The thumbnail image can be cropped differently. For example it can be square or contain only a portion of the original image to showcase it better. Here you can select whether to apply changes to all image sizes or make the thumbnail different.'); ?></p>
</div>
<p>
<img src="<?php echo $thumb['url']; ?>" width="<?php echo $thumb_img[0]; ?>" height="<?php echo $thumb_img[1]; ?>" class="imgedit-size-preview" alt="" /><br /><?php _e('Current thumbnail'); ?>
</p>
<p id="imgedit-save-target-<?php echo $post_id; ?>">
<strong><?php _e('Apply changes to:'); ?></strong><br />
<label class="imgedit-label">
<input type="radio" name="imgedit-target-<?php echo $post_id; ?>" value="all" checked="checked" />
<?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>
<label class="imgedit-label">
<input type="radio" name="imgedit-target-<?php echo $post_id; ?>" value="nothumb" />
<?php _e('All sizes except thumbnail'); ?></label>
</p>
</div>
<?php } ?>
</td></tr>
</tbody></table>
<div class="imgedit-wait" id="imgedit-wait-<?php echo $post_id; ?>"></div>
<script type="text/javascript">imageEdit.init(<?php echo $post_id; ?>);</script>
<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
}
function wp_stream_image($image, $mime_type, $post_id) {
$image = apply_filters('image_save_pre', $image, $post_id);
switch ( $mime_type ) {
case 'image/jpeg':
header('Content-Type: image/jpeg');
return imagejpeg($image, null, 90);
case 'image/png':
header('Content-Type: image/png');
return imagepng($image);
case 'image/gif':
header('Content-Type: image/gif');
return imagegif($image);
default:
return false;
}
}
function wp_save_image_file($filename, $image, $mime_type, $post_id) {
$image = apply_filters('image_save_pre', $image, $post_id);
$saved = apply_filters('wp_save_image_file', null, $filename, $image, $mime_type, $post_id);
if ( null !== $saved )
return $saved;
switch ( $mime_type ) {
case 'image/jpeg':
return imagejpeg( $image, $filename, apply_filters( 'jpeg_quality', 90, 'edit_image' ) );
case 'image/png':
return imagepng($image, $filename);
case 'image/gif':
return imagegif($image, $filename);
default:
return false;
}
}
function _image_get_preview_ratio($w, $h) {
$max = max($w, $h);
return $max > 400 ? (400 / $max) : 1;
}
function _rotate_image_resource($img, $angle) {
if ( function_exists('imagerotate') ) {
$rotated = imagerotate($img, $angle, 0);
if ( is_resource($rotated) ) {
imagedestroy($img);
$img = $rotated;
}
}
return $img;
}
function _flip_image_resource($img, $horz, $vert) {
$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);
$img = $dst;
}
}
return $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;
}
}
return $img;
}
function image_edit_apply_changes($img, $changes) {
if ( !is_array($changes) )
return $img;
// expand change operations
foreach ( $changes as $key => $obj ) {
if ( isset($obj->r) ) {
$obj->type = 'rotate';
$obj->angle = $obj->r;
unset($obj->r);
} elseif ( isset($obj->f) ) {
$obj->type = 'flip';
$obj->axis = $obj->f;
unset($obj->f);
} elseif ( isset($obj->c) ) {
$obj->type = 'crop';
$obj->sel = $obj->c;
unset($obj->c);
}
$changes[$key] = $obj;
}
// combine operations
if ( count($changes) > 1 ) {
$filtered = array($changes[0]);
for ( $i = 0, $j = 1; $j < count($changes); $j++ ) {
$combined = false;
if ( $filtered[$i]->type == $changes[$j]->type ) {
switch ( $filtered[$i]->type ) {
case 'rotate':
$filtered[$i]->angle += $changes[$j]->angle;
$combined = true;
break;
case 'flip':
$filtered[$i]->axis ^= $changes[$j]->axis;
$combined = true;
break;
}
}
if ( !$combined )
$filtered[++$i] = $changes[$j];
}
$changes = $filtered;
unset($filtered);
}
// image resource before applying the changes
$img = apply_filters('image_edit_before_change', $img, $changes);
foreach ( $changes as $operation ) {
switch ( $operation->type ) {
case 'rotate':
if ( $operation->angle != 0 )
$img = _rotate_image_resource($img, $operation->angle);
break;
case 'flip':
if ( $operation->axis != 0 )
$img = _flip_image_resource($img, ($operation->axis & 1) != 0, ($operation->axis & 2) != 0);
break;
case 'crop':
$sel = $operation->sel;
$scale = 1 / _image_get_preview_ratio( imagesx($img), imagesy($img) ); // discard preview scaling
$img = _crop_image_resource($img, $sel->x * $scale, $sel->y * $scale, $sel->w * $scale, $sel->h * $scale);
break;
}
}
return $img;
}
function stream_preview_image($post_id) {
$post = get_post($post_id);
@ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', WP_MAX_MEMORY_LIMIT ) );
$img = load_image_to_edit( $post_id, $post->post_mime_type, array(400, 400) );
if ( !is_resource($img) )
return false;
$changes = !empty($_REQUEST['history']) ? json_decode( stripslashes($_REQUEST['history']) ) : null;
if ( $changes )
$img = image_edit_apply_changes($img, $changes);
// scale the image
$w = imagesx($img);
$h = imagesy($img);
$ratio = _image_get_preview_ratio($w, $h);
$w2 = $w * $ratio;
$h2 = $h * $ratio;
$preview = wp_imagecreatetruecolor($w2, $h2);
imagecopyresampled( $preview, $img, 0, 0, 0, 0, $w2, $h2, $w, $h );
wp_stream_image($preview, $post->post_mime_type, $post_id);
imagedestroy($preview);
imagedestroy($img);
return true;
}
function wp_restore_image($post_id) {
$meta = wp_get_attachment_metadata($post_id);
$file = get_attached_file($post_id);
$backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true );
$restored = false;
$msg = new stdClass;
if ( !is_array($backup_sizes) ) {
$msg->error = __('Cannot load image metadata.');
return $msg;
}
$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']) ) {
$data = $backup_sizes['full-orig'];
if ( $parts['basename'] != $data['file'] ) {
if ( defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE ) {
// delete only if it's edited image
if ( preg_match('/-e[0-9]{13}\./', $parts['basename']) ) {
$delpath = apply_filters('wp_delete_file', $file);
@unlink($delpath);
}
} else {
$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);
$meta['file'] = _wp_relative_upload_path( $restored_file );
$meta['width'] = $data['width'];
$meta['height'] = $data['height'];
list ( $uwidth, $uheight ) = wp_constrain_dimensions($meta['width'], $meta['height'], 128, 96);
$meta['hwstring_small'] = "height='$uheight' width='$uwidth'";
}
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 ) {
// delete only if it's edited image
if ( preg_match('/-e[0-9]{13}-/', $meta['sizes'][$default_size]['file']) ) {
$delpath = apply_filters( 'wp_delete_file', path_join($parts['dirname'], $meta['sizes'][$default_size]['file']) );
@unlink($delpath);
}
} else {
$backup_sizes["$default_size-{$suffix}"] = $meta['sizes'][$default_size];
}
}
$meta['sizes'][$default_size] = $data;
} else {
unset($meta['sizes'][$default_size]);
}
}
if ( !wp_update_attachment_metadata($post_id, $meta) || !update_post_meta( $post_id, '_wp_attachment_backup_sizes', $backup_sizes) ) {
$msg->error = __('Cannot save image metadata.');
return $msg;
}
if ( !$restored )
$msg->error = __('Image metadata is inconsistent.');
else
$msg->msg = __('Image restored successfully.');
return $msg;
}
function wp_save_image($post_id) {
$return = new stdClass;
$success = $delete = $scaled = $nocrop = false;
$post = get_post($post_id);
@ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', WP_MAX_MEMORY_LIMIT ) );
$img = load_image_to_edit($post_id, $post->post_mime_type);
if ( !is_resource($img) ) {
$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'];
if ( $scale && $fwidth > 0 && $fheight > 0 ) {
$sX = imagesx($img);
$sY = imagesy($img);
// check if it has roughly the same w / h ratio
$diff = round($sX / $sY, 2) - round($fwidth / $fheight, 2);
if ( -0.1 < $diff && $diff < 0.1 ) {
// scale the full size image
$dst = wp_imagecreatetruecolor($fwidth, $fheight);
if ( imagecopyresampled( $dst, $img, 0, 0, 0, 0, $fwidth, $fheight, $sX, $sY ) ) {
imagedestroy($img);
$img = $dst;
$scaled = true;
}
}
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( stripslashes($_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 $return;
}
$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.') );
return $return;
}
if ( !is_array($backup_sizes) )
$backup_sizes = array();
// generate new filename
$path = get_attached_file($post_id);
$path_parts = pathinfo( $path );
$filename = $path_parts['filename'];
$suffix = time() . rand(100, 999);
if ( defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE &&
isset($backup_sizes['full-orig']) && $backup_sizes['full-orig']['file'] != $path_parts['basename'] ) {
if ( 'thumbnail' == $target )
$new_path = "{$path_parts['dirname']}/{$filename}-temp.{$path_parts['extension']}";
else
$new_path = $path;
} else {
while( true ) {
$filename = preg_replace( '/-e([0-9]+)$/', '', $filename );
$filename .= "-e{$suffix}";
$new_filename = "{$filename}.{$path_parts['extension']}";
$new_path = "{$path_parts['dirname']}/$new_filename";
if ( file_exists($new_path) )
$suffix++;
else
break;
}
}
// 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.') );
return $return;
}
if ( 'nothumb' == $target || 'all' == $target || 'full' == $target || $scaled ) {
$tag = false;
if ( isset($backup_sizes['full-orig']) ) {
if ( ( !defined('IMAGE_EDIT_OVERWRITE') || !IMAGE_EDIT_OVERWRITE ) && $backup_sizes['full-orig']['file'] != $path_parts['basename'] )
$tag = "full-$suffix";
} else {
$tag = 'full-orig';
}
if ( $tag )
$backup_sizes[$tag] = array('width' => $meta['width'], 'height' => $meta['height'], 'file' => $path_parts['basename']);
$success = update_attached_file($post_id, $new_path);
$meta['file'] = _wp_relative_upload_path($new_path);
$meta['width'] = imagesx($img);
$meta['height'] = imagesy($img);
list ( $uwidth, $uheight ) = wp_constrain_dimensions($meta['width'], $meta['height'], 128, 96);
$meta['hwstring_small'] = "height='$uheight' width='$uwidth'";
if ( $success && ('nothumb' == $target || 'all' == $target) ) {
$sizes = get_intermediate_image_sizes();
if ( 'nothumb' == $target )
$sizes = array_diff( $sizes, array('thumbnail') );
}
$return->fw = $meta['width'];
$return->fh = $meta['height'];
} elseif ( 'thumbnail' == $target ) {
$sizes = array( 'thumbnail' );
$success = $delete = $nocrop = true;
}
if ( isset($sizes) ) {
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'] )
$tag = "$size-$suffix";
} else {
$tag = "$size-orig";
}
if ( $tag )
$backup_sizes[$tag] = $meta['sizes'][$size];
}
$crop = $nocrop ? false : get_option("{$size}_crop");
$resized = image_make_intermediate_size($new_path, get_option("{$size}_size_w"), get_option("{$size}_size_h"), $crop );
if ( $resized )
$meta['sizes'][$size] = $resized;
else
unset($meta['sizes'][$size]);
}
}
if ( $success ) {
wp_update_attachment_metadata($post_id, $meta);
update_post_meta( $post_id, '_wp_attachment_backup_sizes', $backup_sizes);
if ( $target == 'thumbnail' || $target == 'all' || $target == 'full' ) {
$file_url = wp_get_attachment_url($post_id);
if ( $thumb = $meta['sizes']['thumbnail'] )
$return->thumbnail = path_join( dirname($file_url), $thumb['file'] );
else
$return->thumbnail = "$file_url?w=128&h=128";
}
} else {
$delete = true;
}
if ( $delete ) {
$delpath = apply_filters('wp_delete_file', $new_path);
@unlink($delpath);
}
imagedestroy($img);
$return->msg = esc_js( __('Image saved') );
return $return;
}
| 01happy-blog | trunk/myblog/wp-admin/includes/image-edit.php | PHP | oos | 23,710 |
<?php
/**
* WordPress Direct Filesystem.
*
* @package WordPress
* @subpackage Filesystem
*/
/**
* WordPress Filesystem Class for direct PHP file and folder manipulation.
*
* @since 2.5
* @package WordPress
* @subpackage Filesystem
* @uses WP_Filesystem_Base Extends class
*/
class WP_Filesystem_Direct extends WP_Filesystem_Base {
var $errors = null;
/**
* constructor
*
* @param mixed $arg ignored argument
*/
function __construct($arg) {
$this->method = 'direct';
$this->errors = new WP_Error();
}
/**
* connect filesystem.
*
* @return bool Returns true on success or false on failure (always true for WP_Filesystem_Direct).
*/
function connect() {
return true;
}
/**
* 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.
*/
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.
*/
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.
* @return bool False upon failure.
*/
function put_contents($file, $contents, $mode = false ) {
if ( ! ($fp = @fopen($file, 'w')) )
return false;
@fwrite($fp, $contents);
@fclose($fp);
$this->chmod($file, $mode);
return true;
}
/**
* Gets the current working directory
*
* @return string|bool the current working directory on success, or false on failure.
*/
function cwd() {
return @getcwd();
}
/**
* Change directory
*
* @param string $dir The new current directory.
* @return bool Returns true on success or false on failure.
*/
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. Defaults to False.
* @return bool Returns true on success or false on failure.
*/
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);
//Is a directory, and we want recursive
$file = trailingslashit($file);
$filelist = $this->dirlist($file);
foreach ($filelist as $filename)
$this->chgrp($file . $filename, $group, $recursive);
return true;
}
/**
* 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.
* @param bool $recursive (optional) If set True changes file group recursively. Defaults to False.
* @return bool Returns true on success or false on failure.
*/
function chmod($file, $mode = false, $recursive = 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 @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);
return true;
}
/**
* 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. Defaults to False.
* @return bool Returns true on success or false on failure.
*/
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);
//Is a directory, and we want recursive
$filelist = $this->dirlist($file);
foreach ($filelist as $filename) {
$this->chown($file . '/' . $filename, $owner, $recursive);
}
return true;
}
/**
* Gets file owner
*
* @param string $file Path to the file.
* @return string Username of the user.
*/
function owner($file) {
$owneruid = @fileowner($file);
if ( ! $owneruid )
return false;
if ( ! function_exists('posix_getpwuid') )
return $owneruid;
$ownerarray = posix_getpwuid($owneruid);
return $ownerarray['name'];
}
/**
* Gets file permissions
*
* FIXME does not handle errors in fileperms()
*
* @param string $file Path to the file.
* @return string Mode of the file (last 4 digits).
*/
function getchmod($file) {
return substr(decoct(@fileperms($file)),3);
}
function group($file) {
$gid = @filegroup($file);
if ( ! $gid )
return false;
if ( ! function_exists('posix_getgrgid') )
return $gid;
$grouparray = posix_getgrgid($gid);
return $grouparray['name'];
}
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);
return $rtval;
}
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) )
return true;
if ( $this->copy($source, $destination, $overwrite) && $this->exists($destination) ) {
$this->delete($source);
return true;
} else {
return false;
}
}
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);
//At this point its a folder, and we're in recursive mode
$file = trailingslashit($file);
$filelist = $this->dirlist($file, true);
$retval = true;
if ( is_array($filelist) ) //false if no files, So check first.
foreach ($filelist as $filename => $fileinfo)
if ( ! $this->delete($file . $filename, $recursive, $fileinfo['type']) )
$retval = false;
if ( file_exists($file) && ! @rmdir($file) )
$retval = false;
return $retval;
}
function exists($file) {
return @file_exists($file);
}
function is_file($file) {
return @is_file($file);
}
function is_dir($path) {
return @is_dir($path);
}
function is_readable($file) {
return @is_readable($file);
}
function is_writable($file) {
return @is_writable($file);
}
function atime($file) {
return @fileatime($file);
}
function mtime($file) {
return @filemtime($file);
}
function size($file) {
return @filesize($file);
}
function touch($file, $time = 0, $atime = 0) {
if ($time == 0)
$time = time();
if ($atime == 0)
$atime = time();
return @touch($file, $time, $atime);
}
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) )
return false;
if ( ! $chmod )
$chmod = FS_CHMOD_DIR;
if ( ! @mkdir($path) )
return false;
$this->chmod($path, $chmod);
if ( $chown )
$this->chown($path, $chown);
if ( $chgrp )
$this->chgrp($path, $chgrp);
return true;
}
function rmdir($path, $recursive = false) {
return $this->delete($path, $recursive);
}
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) )
return false;
$dir = @dir($path);
if ( ! $dir )
return false;
$ret = array();
while (false !== ($entry = $dir->read()) ) {
$struc = array();
$struc['name'] = $entry;
if ( '.' == $struc['name'] || '..' == $struc['name'] )
continue;
if ( ! $include_hidden && '.' == $struc['name'][0] )
continue;
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';
if ( 'd' == $struc['type'] ) {
if ( $recursive )
$struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive);
else
$struc['files'] = array();
}
$ret[ $struc['name'] ] = $struc;
}
$dir->close();
unset($dir);
return $ret;
}
}
| 01happy-blog | trunk/myblog/wp-admin/includes/class-wp-filesystem-direct.php | PHP | oos | 9,558 |
<?php
/**
* WordPress SSH2 Filesystem.
*
* @package WordPress
* @subpackage Filesystem
*/
/**
* WordPress Filesystem Class for implementing SSH2.
*
* To use this class you must follow these steps for PHP 5.2.6+
*
* @contrib http://kevin.vanzonneveld.net/techblog/article/make_ssh_connections_with_php/ - Installation Notes
*
* Complie libssh2 (Note: Only 0.14 is officaly working with PHP 5.2.6+ right now, But many users have found the latest versions work)
*
* cd /usr/src
* wget http://surfnet.dl.sourceforge.net/sourceforge/libssh2/libssh2-0.14.tar.gz
* tar -zxvf libssh2-0.14.tar.gz
* cd libssh2-0.14/
* ./configure
* make all install
*
* Note: Do not leave the directory yet!
*
* Enter: pecl install -f ssh2
*
* Copy the ssh.so file it creates to your PHP Module Directory.
* Open up your PHP.INI file and look for where extensions are placed.
* Add in your PHP.ini file: extension=ssh2.so
*
* Restart Apache!
* Check phpinfo() streams to confirm that: ssh2.shell, ssh2.exec, ssh2.tunnel, ssh2.scp, ssh2.sftp exist.
*
* Note: as of WordPress 2.8, This utilises the PHP5+ function 'stream_get_contents'
*
* @since 2.7
* @package WordPress
* @subpackage Filesystem
* @uses WP_Filesystem_Base Extends class
*/
class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
var $link = false;
var $sftp_link = false;
var $keys = false;
var $errors = array();
var $options = array();
function __construct($opt='') {
$this->method = 'ssh2';
$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'));
return false;
}
if ( !function_exists('stream_get_contents') ) {
$this->errors->add('ssh2_php_requirement', __('The ssh2 PHP extension is available, however, we require the PHP5 function <code>stream_get_contents()</code>'));
return false;
}
// Set defaults:
if ( empty($opt['port']) )
$this->options['port'] = 22;
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'];
if ( ! empty($opt['base']) )
$this->wp_base = $opt['base'];
// 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']) ) {
if ( !$this->keys ) //password can be blank if we are using keys
$this->errors->add('empty_password', __('SSH2 password is required'));
} else {
$this->options['password'] = $opt['password'];
}
}
function connect() {
if ( ! $this->keys ) {
$this->link = @ssh2_connect($this->options['hostname'], $this->options['port']);
} else {
$this->link = @ssh2_connect($this->options['hostname'], $this->options['port'], $this->options['hostkey']);
}
if ( ! $this->link ) {
$this->errors->add('connect', sprintf(__('Failed to connect to SSH2 Server %1$s:%2$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', 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', sprintf(__('Public and Private keys incorrect for %s'), $this->options['username']));
return false;
}
}
$this->sftp_link = ssh2_sftp($this->link);
return true;
}
function run_command( $command, $returnbool = false) {
if ( ! $this->link )
return false;
if ( ! ($stream = ssh2_exec($this->link, $command)) ) {
$this->errors->add('command', sprintf(__('Unable to perform command: %s'), $command));
} else {
stream_set_blocking( $stream, true );
stream_set_timeout( $stream, FS_TIMEOUT );
$data = stream_get_contents( $stream );
fclose( $stream );
if ( $returnbool )
return ( $data === false ) ? false : '' != trim($data);
else
return $data;
}
return false;
}
function get_contents($file, $type = '', $resumepos = 0 ) {
$file = ltrim($file, '/');
return file_get_contents('ssh2.sftp://' . $this->sftp_link . '/' . $file);
}
function get_contents_array($file) {
$file = ltrim($file, '/');
return file('ssh2.sftp://' . $this->sftp_link . '/' . $file);
}
function put_contents($file, $contents, $mode = false ) {
$file = ltrim($file, '/');
$ret = file_put_contents('ssh2.sftp://' . $this->sftp_link . '/' . $file, $contents);
$this->chmod($file, $mode);
return false !== $ret;
}
function cwd() {
$cwd = $this->run_command('pwd');
if ( $cwd )
$cwd = trailingslashit($cwd);
return $cwd;
}
function chdir($dir) {
return $this->run_command('cd ' . $dir, true);
}
function chgrp($file, $group, $recursive = false ) {
if ( ! $this->exists($file) )
return false;
if ( ! $recursive || ! $this->is_dir($file) )
return $this->run_command(sprintf('chgrp %o %s', $mode, escapeshellarg($file)), true);
return $this->run_command(sprintf('chgrp -R %o %s', $mode, escapeshellarg($file)), true);
}
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);
}
function chown($file, $owner, $recursive = false ) {
if ( ! $this->exists($file) )
return false;
if ( ! $recursive || ! $this->is_dir($file) )
return $this->run_command(sprintf('chown %o %s', $mode, escapeshellarg($file)), true);
return $this->run_command(sprintf('chown -R %o %s', $mode, escapeshellarg($file)), true);
}
function owner($file) {
$owneruid = @fileowner('ssh2.sftp://' . $this->sftp_link . '/' . ltrim($file, '/'));
if ( ! $owneruid )
return false;
if ( ! function_exists('posix_getpwuid') )
return $owneruid;
$ownerarray = posix_getpwuid($owneruid);
return $ownerarray['name'];
}
function getchmod($file) {
return substr(decoct(@fileperms( 'ssh2.sftp://' . $this->sftp_link . '/' . ltrim($file, '/') )),3);
}
function group($file) {
$gid = @filegroup('ssh2.sftp://' . $this->sftp_link . '/' . ltrim($file, '/'));
if ( ! $gid )
return false;
if ( ! function_exists('posix_getgrgid') )
return $gid;
$grouparray = posix_getgrgid($gid);
return $grouparray['name'];
}
function copy($source, $destination, $overwrite = false, $mode = false) {
if ( ! $overwrite && $this->exists($destination) )
return false;
$content = $this->get_contents($source);
if ( false === $content)
return false;
return $this->put_contents($destination, $content, $mode);
}
function move($source, $destination, $overwrite = false) {
return @ssh2_sftp_rename($this->link, $source, $destination);
}
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);
}
function exists($file) {
$file = ltrim($file, '/');
return file_exists('ssh2.sftp://' . $this->sftp_link . '/' . $file);
}
function is_file($file) {
$file = ltrim($file, '/');
return is_file('ssh2.sftp://' . $this->sftp_link . '/' . $file);
}
function is_dir($path) {
$path = ltrim($path, '/');
return is_dir('ssh2.sftp://' . $this->sftp_link . '/' . $path);
}
function is_readable($file) {
$file = ltrim($file, '/');
return is_readable('ssh2.sftp://' . $this->sftp_link . '/' . $file);
}
function is_writable($file) {
$file = ltrim($file, '/');
return is_writable('ssh2.sftp://' . $this->sftp_link . '/' . $file);
}
function atime($file) {
$file = ltrim($file, '/');
return fileatime('ssh2.sftp://' . $this->sftp_link . '/' . $file);
}
function mtime($file) {
$file = ltrim($file, '/');
return filemtime('ssh2.sftp://' . $this->sftp_link . '/' . $file);
}
function size($file) {
$file = ltrim($file, '/');
return filesize('ssh2.sftp://' . $this->sftp_link . '/' . $file);
}
function touch($file, $time = 0, $atime = 0) {
//Not implemented.
}
function mkdir($path, $chmod = false, $chown = false, $chgrp = false) {
$path = untrailingslashit($path);
if ( empty($path) )
return false;
if ( ! $chmod )
$chmod = FS_CHMOD_DIR;
if ( ! ssh2_sftp_mkdir($this->sftp_link, $path, $chmod, true) )
return false;
if ( $chown )
$this->chown($path, $chown);
if ( $chgrp )
$this->chgrp($path, $chgrp);
return true;
}
function rmdir($path, $recursive = false) {
return $this->delete($path, $recursive);
}
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) )
return false;
$ret = array();
$dir = @dir('ssh2.sftp://' . $this->sftp_link .'/' . ltrim($path, '/') );
if ( ! $dir )
return false;
while (false !== ($entry = $dir->read()) ) {
$struc = array();
$struc['name'] = $entry;
if ( '.' == $struc['name'] || '..' == $struc['name'] )
continue; //Do not care about these folders.
if ( ! $include_hidden && '.' == $struc['name'][0] )
continue;
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';
if ( 'd' == $struc['type'] ) {
if ( $recursive )
$struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive);
else
$struc['files'] = array();
}
$ret[ $struc['name'] ] = $struc;
}
$dir->close();
unset($dir);
return $ret;
}
}
| 01happy-blog | trunk/myblog/wp-admin/includes/class-wp-filesystem-ssh2.php | PHP | oos | 11,437 |
<?php
/**
* WP_Importer base class
*/
class WP_Importer {
/**
* Class Constructor
*
* @return void
*/
function __construct() {}
/**
* Returns array with imported permalinks from WordPress database
*
* @param string $bid
* @return array
*/
function get_imported_posts( $importer_name, $bid ) {
global $wpdb;
$hashtable = array();
$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 );
// Increment offset
$offset = ( $limit + $offset );
if ( !empty( $results ) ) {
foreach ( $results as $r ) {
// Set permalinks into array
$hashtable[$r->meta_value] = intval( $r->post_id );
}
}
} while ( count( $results ) == $limit );
// unset to save memory
unset( $results, $r );
return $hashtable;
}
/**
* Return count of imported permalinks from WordPress database
*
* @param string $bid
* @return int
*/
function count_imported_posts( $importer_name, $bid ) {
global $wpdb;
$count = 0;
// 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 );
$result = $wpdb->get_results( $sql );
if ( !empty( $result ) )
$count = intval( $result[0]->cnt );
// unset to save memory
unset( $results );
return $count;
}
/**
* Set array with imported comments from WordPress database
*
* @param string $bid
* @return array
*/
function get_imported_comments( $bid ) {
global $wpdb;
$hashtable = array();
$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 );
$results = $wpdb->get_results( $sql );
// Increment offset
$offset = ( $limit + $offset );
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 );
// Check if this comment came from this blog
if ( $bid == $ca_bid ) {
$hashtable[$source_comment_id] = intval( $r->comment_ID );
}
}
}
} while ( count( $results ) == $limit );
// unset to save memory
unset( $results, $r );
return $hashtable;
}
function set_blog( $blog_id ) {
if ( is_numeric( $blog_id ) ) {
$blog_id = (int) $blog_id;
} else {
$blog = 'http://' . preg_replace( '#^https?://#', '', $blog_id );
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'] = '/';
$blog = get_blog_details( array( 'domain' => $parsed['host'], 'path' => $parsed['path'] ) );
if ( !$blog ) {
fwrite( STDERR, "Error: Could not find blog\n" );
exit();
}
$blog_id = (int) $blog->blog_id;
// Restore global $current_blog
global $current_blog;
$current_blog = $blog;
}
if ( function_exists( 'is_multisite' ) ) {
if ( is_multisite() )
switch_to_blog( $blog_id );
}
return $blog_id;
}
function set_user( $user_id ) {
if ( is_numeric( $user_id ) ) {
$user_id = (int) $user_id;
} else {
$user_id = (int) username_exists( $user_id );
}
if ( !$user_id || !wp_set_current_user( $user_id ) ) {
fwrite( STDERR, "Error: can not find user\n" );
exit();
}
return $user_id;
}
/**
* Sort by strlen, longest string first
*
* @param string $a
* @param string $b
* @return int
*/
function cmpr_strlen( $a, $b ) {
return strlen( $b ) - strlen( $a );
}
/**
* GET URL
*
* @param string $url
* @param string $username
* @param string $password
* @param bool $head
* @return array
*/
function get_page( $url, $username = '', $password = '', $head = false ) {
// Increase the timeout
add_filter( 'http_request_timeout', array( &$this, 'bump_request_timeout' ) );
$headers = array();
$args = array();
if ( true === $head )
$args['method'] = 'HEAD';
if ( !empty( $username ) && !empty( $password ) )
$headers['Authorization'] = 'Basic ' . base64_encode( "$username:$password" );
$args['headers'] = $headers;
return wp_remote_request( $url, $args );
}
/**
* Bump up the request timeout for http requests
*
* @param int $val
* @return int
*/
function bump_request_timeout( $val ) {
return 60;
}
/**
* Check if user has exceeded disk quota
*
* @return bool
*/
function is_user_over_quota() {
global $current_blog;
if ( function_exists( 'upload_is_user_over_quota' ) ) {
if ( upload_is_user_over_quota( 1 ) ) {
echo "Sorry, you have used your upload quota.\n";
return true;
}
}
return false;
}
/**
* Replace newlines, tabs, and multiple spaces with a single space
*
* @param string $string
* @return string
*/
function min_whitespace( $string ) {
return preg_replace( '|[\r\n\t ]+|', ' ', $string );
}
/**
* Reset global variables that grow out of control during imports
*
* @return void
*/
function stop_the_insanity() {
global $wpdb, $wp_actions;
// Or define( 'WP_IMPORTING', true );
$wpdb->queries = array();
// Reset $wp_actions to keep it from growing out of control
$wp_actions = array();
}
}
/**
* Returns value of command line params.
* Exits when a required param is not set.
*
* @param string $param
* @param bool $required
* @return mixed
*/
function get_cli_args( $param, $required = false ) {
$args = $_SERVER['argv'];
$out = array();
$last_arg = 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 ( isset( $parts[1] ) ) {
$out[$key] = $parts[1];
} else {
$out[$key] = true;
}
$last_arg = $key;
} else if ( (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;
}
$last_arg = $key;
} else if ( $last_arg !== null ) {
$out[$last_arg] = $args[$i];
}
}
// Check array for specified param
if ( isset( $out[$param] ) ) {
// Set return value
$return = $out[$param];
}
// Check for missing required param
if ( !isset( $out[$param] ) && $required ) {
// Display message and exit
echo "\"$param\" parameter is required but was not specified\n";
exit();
}
return $return;
}
| 01happy-blog | trunk/myblog/wp-admin/includes/class-wp-importer.php | PHP | oos | 6,897 |
<?php
/**
* Posts List Table class.
*
* @package WordPress
* @subpackage List_Table
* @since 3.1.0
* @access private
*/
class WP_Posts_List_Table extends WP_List_Table {
/**
* Whether the items should be displayed hierarchically or linearly
*
* @since 3.1.0
* @var bool
* @access protected
*/
var $hierarchical_display;
/**
* Holds the number of pending comments for each post
*
* @since 3.1.0
* @var int
* @access protected
*/
var $comment_pending_count;
/**
* Holds the number of posts for this user
*
* @since 3.1.0
* @var int
* @access private
*/
var $user_posts_count;
/**
* Holds the number of posts which are sticky.
*
* @since 3.1.0
* @var int
* @access private
*/
var $sticky_posts_count = 0;
function __construct() {
global $post_type_object, $wpdb;
$post_type = get_current_screen()->post_type;
$post_type_object = get_post_type_object( $post_type );
if ( !current_user_can( $post_type_object->cap->edit_others_posts ) ) {
$this->user_posts_count = $wpdb->get_var( $wpdb->prepare( "
SELECT COUNT( 1 ) FROM $wpdb->posts
WHERE post_type = %s AND post_status NOT IN ( 'trash', 'auto-draft' )
AND post_author = %d
", $post_type, get_current_user_id() ) );
if ( $this->user_posts_count && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['all_posts'] ) && empty( $_REQUEST['author'] ) && empty( $_REQUEST['show_sticky'] ) )
$_GET['author'] = get_current_user_id();
}
if ( 'post' == $post_type && $sticky_posts = get_option( 'sticky_posts' ) ) {
$sticky_posts = implode( ', ', array_map( 'absint', (array) $sticky_posts ) );
$this->sticky_posts_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( 1 ) FROM $wpdb->posts WHERE post_type = %s AND post_status != 'trash' AND ID IN ($sticky_posts)", $post_type ) );
}
parent::__construct( array(
'plural' => 'posts',
) );
}
function ajax_user_can() {
global $post_type_object;
return current_user_can( $post_type_object->cap->edit_posts );
}
function prepare_items() {
global $post_type_object, $avail_post_stati, $wp_query, $per_page, $mode;
$avail_post_stati = wp_edit_posts_query();
$this->hierarchical_display = ( $post_type_object->hierarchical && 'menu_order title' == $wp_query->query['orderby'] );
$total_items = $this->hierarchical_display ? $wp_query->post_count : $wp_query->found_posts;
$post_type = $post_type_object->name;
$per_page = $this->get_items_per_page( 'edit_' . $post_type . '_per_page' );
$per_page = apply_filters( 'edit_posts_per_page', $per_page, $post_type );
if ( $this->hierarchical_display )
$total_pages = ceil( $total_items / $per_page );
else
$total_pages = $wp_query->max_num_pages;
$mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode'];
$this->is_trash = isset( $_REQUEST['post_status'] ) && $_REQUEST['post_status'] == 'trash';
$this->set_pagination_args( array(
'total_items' => $total_items,
'total_pages' => $total_pages,
'per_page' => $per_page
) );
}
function has_items() {
return have_posts();
}
function no_items() {
global $post_type_object;
if ( isset( $_REQUEST['post_status'] ) && 'trash' == $_REQUEST['post_status'] )
echo $post_type_object->labels->not_found_in_trash;
else
echo $post_type_object->labels->not_found;
}
function get_views() {
global $post_type_object, $locked_post_status, $avail_post_stati;
$post_type = $post_type_object->name;
if ( !empty($locked_post_status) )
return array();
$status_links = array();
$num_posts = wp_count_posts( $post_type, 'readable' );
$class = '';
$allposts = '';
$current_user_id = get_current_user_id();
if ( $this->user_posts_count ) {
if ( isset( $_GET['author'] ) && ( $_GET['author'] == $current_user_id ) )
$class = ' class="current"';
$status_links['mine'] = "<a href='edit.php?post_type=$post_type&author=$current_user_id'$class>" . sprintf( _nx( 'Mine <span class="count">(%s)</span>', 'Mine <span class="count">(%s)</span>', $this->user_posts_count, 'posts' ), number_format_i18n( $this->user_posts_count ) ) . '</a>';
$allposts = '&all_posts=1';
}
$total_posts = array_sum( (array) $num_posts );
// Subtract post types that are not included in the admin all list.
foreach ( get_post_stati( array('show_in_admin_all_list' => false) ) as $state )
$total_posts -= $num_posts->$state;
$class = empty( $class ) && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['show_sticky'] ) ? ' class="current"' : '';
$status_links['all'] = "<a href='edit.php?post_type=$post_type{$allposts}'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_posts, 'posts' ), number_format_i18n( $total_posts ) ) . '</a>';
foreach ( get_post_stati(array('show_in_admin_status_list' => true), 'objects') as $status ) {
$class = '';
$status_name = $status->name;
if ( !in_array( $status_name, $avail_post_stati ) )
continue;
if ( empty( $num_posts->$status_name ) )
continue;
if ( isset($_REQUEST['post_status']) && $status_name == $_REQUEST['post_status'] )
$class = ' class="current"';
$status_links[$status_name] = "<a href='edit.php?post_status=$status_name&post_type=$post_type'$class>" . sprintf( translate_nooped_plural( $status->label_count, $num_posts->$status_name ), number_format_i18n( $num_posts->$status_name ) ) . '</a>';
}
if ( ! empty( $this->sticky_posts_count ) ) {
$class = ! empty( $_REQUEST['show_sticky'] ) ? ' class="current"' : '';
$sticky_link = array( 'sticky' => "<a href='edit.php?post_type=$post_type&show_sticky=1'$class>" . sprintf( _nx( 'Sticky <span class="count">(%s)</span>', 'Sticky <span class="count">(%s)</span>', $this->sticky_posts_count, 'posts' ), number_format_i18n( $this->sticky_posts_count ) ) . '</a>' );
// Sticky comes after Publish, or if not listed, after All.
$split = 1 + array_search( ( isset( $status_links['publish'] ) ? 'publish' : 'all' ), array_keys( $status_links ) );
$status_links = array_merge( array_slice( $status_links, 0, $split ), $sticky_link, array_slice( $status_links, $split ) );
}
return $status_links;
}
function get_bulk_actions() {
$actions = array();
if ( $this->is_trash )
$actions['untrash'] = __( 'Restore' );
else
$actions['edit'] = __( 'Edit' );
if ( $this->is_trash || !EMPTY_TRASH_DAYS )
$actions['delete'] = __( 'Delete Permanently' );
else
$actions['trash'] = __( 'Move to Trash' );
return $actions;
}
function extra_tablenav( $which ) {
global $post_type_object, $cat;
?>
<div class="alignleft actions">
<?php
if ( 'top' == $which && !is_singular() ) {
$this->months_dropdown( $post_type_object->name );
if ( is_object_in_taxonomy( $post_type_object->name, 'category' ) ) {
$dropdown_options = array(
'show_option_all' => __( 'View all categories' ),
'hide_empty' => 0,
'hierarchical' => 1,
'show_count' => 0,
'orderby' => 'name',
'selected' => $cat
);
wp_dropdown_categories( $dropdown_options );
}
do_action( 'restrict_manage_posts' );
submit_button( __( 'Filter' ), 'secondary', false, false, array( 'id' => 'post-query-submit' ) );
}
if ( $this->is_trash && current_user_can( $post_type_object->cap->edit_others_posts ) ) {
submit_button( __( 'Empty Trash' ), 'button-secondary apply', 'delete_all', false );
}
?>
</div>
<?php
}
function current_action() {
if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) )
return 'delete_all';
return parent::current_action();
}
function pagination( $which ) {
global $post_type_object, $mode;
parent::pagination( $which );
if ( 'top' == $which && !$post_type_object->hierarchical )
$this->view_switcher( $mode );
}
function get_table_classes() {
global $post_type_object;
return array( 'widefat', 'fixed', $post_type_object->hierarchical ? 'pages' : 'posts' );
}
function get_columns() {
$screen = get_current_screen();
if ( empty( $screen ) )
$post_type = 'post';
else
$post_type = $screen->post_type;
$posts_columns = array();
$posts_columns['cb'] = '<input type="checkbox" />';
/* translators: manage posts column name */
$posts_columns['title'] = _x( 'Title', 'column name' );
if ( post_type_supports( $post_type, 'author' ) )
$posts_columns['author'] = __( 'Author' );
if ( empty( $post_type ) || is_object_in_taxonomy( $post_type, 'category' ) )
$posts_columns['categories'] = __( 'Categories' );
if ( empty( $post_type ) || is_object_in_taxonomy( $post_type, 'post_tag' ) )
$posts_columns['tags'] = __( 'Tags' );
$post_status = !empty( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all';
if ( post_type_supports( $post_type, 'comments' ) && !in_array( $post_status, array( 'pending', 'draft', 'future' ) ) )
$posts_columns['comments'] = '<span class="vers"><img alt="' . esc_attr__( 'Comments' ) . '" src="' . esc_url( admin_url( 'images/comment-grey-bubble.png' ) ) . '" /></span>';
$posts_columns['date'] = __( 'Date' );
if ( 'page' == $post_type )
$posts_columns = apply_filters( 'manage_pages_columns', $posts_columns );
else
$posts_columns = apply_filters( 'manage_posts_columns', $posts_columns, $post_type );
$posts_columns = apply_filters( "manage_{$post_type}_posts_columns", $posts_columns );
return $posts_columns;
}
function get_sortable_columns() {
return array(
'title' => 'title',
'author' => 'author',
'parent' => 'parent',
'comments' => 'comment_count',
'date' => array( 'date', true )
);
}
function display_rows( $posts = array() ) {
global $wp_query, $post_type_object, $per_page;
if ( empty( $posts ) )
$posts = $wp_query->posts;
add_filter( 'the_title', 'esc_html' );
if ( $this->hierarchical_display ) {
$this->_display_rows_hierarchical( $posts, $this->get_pagenum(), $per_page );
} else {
$this->_display_rows( $posts );
}
}
function _display_rows( $posts ) {
global $post, $mode;
// Create array of post IDs.
$post_ids = array();
foreach ( $posts as $a_post )
$post_ids[] = $a_post->ID;
$this->comment_pending_count = get_pending_comments_num( $post_ids );
foreach ( $posts as $post )
$this->single_row( $post );
}
function _display_rows_hierarchical( $pages, $pagenum = 1, $per_page = 20 ) {
global $wpdb;
$level = 0;
if ( ! $pages ) {
$pages = get_pages( array( 'sort_column' => 'menu_order' ) );
if ( ! $pages )
return false;
}
/*
* arrange pages into two parts: top level pages and children_pages
* children_pages is two dimensional array, eg.
* children_pages[10][] contains all sub-pages whose parent is 10.
* It only takes O( N ) to arrange this and it takes O( 1 ) for subsequent lookup operations
* If searching, ignore hierarchy and treat everything as top level
*/
if ( empty( $_REQUEST['s'] ) ) {
$top_level_pages = array();
$children_pages = array();
foreach ( $pages as $page ) {
// catch and repair bad pages
if ( $page->post_parent == $page->ID ) {
$page->post_parent = 0;
$wpdb->update( $wpdb->posts, array( 'post_parent' => 0 ), array( 'ID' => $page->ID ) );
clean_post_cache( $page );
}
if ( 0 == $page->post_parent )
$top_level_pages[] = $page;
else
$children_pages[ $page->post_parent ][] = $page;
}
$pages = &$top_level_pages;
}
$count = 0;
$start = ( $pagenum - 1 ) * $per_page;
$end = $start + $per_page;
foreach ( $pages as $page ) {
if ( $count >= $end )
break;
if ( $count >= $start )
echo "\t" . $this->single_row( $page, $level );
$count++;
if ( isset( $children_pages ) )
$this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page );
}
// if it is the last pagenum and there are orphaned pages, display them with paging as well
if ( isset( $children_pages ) && $count < $end ){
foreach ( $children_pages as $orphans ){
foreach ( $orphans as $op ) {
if ( $count >= $end )
break;
if ( $count >= $start )
echo "\t" . $this->single_row( $op, 0 );
$count++;
}
}
}
}
/**
* Given a top level page ID, display the nested hierarchy of sub-pages
* together with paging support
*
* @since 3.1.0 (Standalone function exists since 2.6.0)
*
* @param unknown_type $children_pages
* @param unknown_type $count
* @param unknown_type $parent
* @param unknown_type $level
* @param unknown_type $pagenum
* @param unknown_type $per_page
*/
function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page ) {
if ( ! isset( $children_pages[$parent] ) )
return;
$start = ( $pagenum - 1 ) * $per_page;
$end = $start + $per_page;
foreach ( $children_pages[$parent] as $page ) {
if ( $count >= $end )
break;
// If the page starts in a subtree, print the parents.
if ( $count == $start && $page->post_parent > 0 ) {
$my_parents = array();
$my_parent = $page->post_parent;
while ( $my_parent ) {
$my_parent = get_post( $my_parent );
$my_parents[] = $my_parent;
if ( !$my_parent->post_parent )
break;
$my_parent = $my_parent->post_parent;
}
$num_parents = count( $my_parents );
while ( $my_parent = array_pop( $my_parents ) ) {
echo "\t" . $this->single_row( $my_parent, $level - $num_parents );
$num_parents--;
}
}
if ( $count >= $start )
echo "\t" . $this->single_row( $page, $level );
$count++;
$this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page );
}
unset( $children_pages[$parent] ); //required in order to keep track of orphans
}
function single_row( $a_post, $level = 0 ) {
global $post, $mode;
static $alternate;
$global_post = $post;
$post = $a_post;
setup_postdata( $post );
$edit_link = get_edit_post_link( $post->ID );
$title = _draft_or_post_title();
$post_type_object = get_post_type_object( $post->post_type );
$can_edit_post = current_user_can( $post_type_object->cap->edit_post, $post->ID );
$alternate = 'alternate' == $alternate ? '' : 'alternate';
$classes = $alternate . ' iedit author-' . ( get_current_user_id() == $post->post_author ? 'self' : 'other' );
?>
<tr id="post-<?php echo $post->ID; ?>" class="<?php echo implode( ' ', get_post_class( $classes, $post->ID ) ); ?>" valign="top">
<?php
list( $columns, $hidden ) = $this->get_column_info();
foreach ( $columns as $column_name => $column_display_name ) {
$class = "class=\"$column_name column-$column_name\"";
$style = '';
if ( in_array( $column_name, $hidden ) )
$style = ' style="display:none;"';
$attributes = "$class$style";
switch ( $column_name ) {
case 'cb':
?>
<th scope="row" class="check-column"><?php if ( $can_edit_post ) { ?><input type="checkbox" name="post[]" value="<?php the_ID(); ?>" /><?php } ?></th>
<?php
break;
case 'title':
if ( $this->hierarchical_display ) {
$attributes = 'class="post-title page-title column-title"' . $style;
if ( 0 == $level && (int) $post->post_parent > 0 ) {
//sent level 0 by accident, by default, or because we don't know the actual level
$find_main_page = (int) $post->post_parent;
while ( $find_main_page > 0 ) {
$parent = get_page( $find_main_page );
if ( is_null( $parent ) )
break;
$level++;
$find_main_page = (int) $parent->post_parent;
if ( !isset( $parent_name ) )
$parent_name = apply_filters( 'the_title', $parent->post_title, $parent->ID );
}
}
$pad = str_repeat( '— ', $level );
?>
<td <?php echo $attributes ?>><strong><?php if ( $can_edit_post && $post->post_status != 'trash' ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr( sprintf( __( 'Edit “%s”' ), $title ) ); ?>"><?php echo $pad; echo $title ?></a><?php } else { echo $pad; echo $title; }; _post_states( $post ); echo isset( $parent_name ) ? ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html( $parent_name ) : ''; ?></strong>
<?php
}
else {
$attributes = 'class="post-title page-title column-title"' . $style;
?>
<td <?php echo $attributes ?>><strong><?php if ( $can_edit_post && $post->post_status != 'trash' ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr( sprintf( __( 'Edit “%s”' ), $title ) ); ?>"><?php echo $title ?></a><?php } else { echo $title; }; _post_states( $post ); ?></strong>
<?php
if ( 'excerpt' == $mode && current_user_can( 'read_post', $post->ID ) )
the_excerpt();
}
$actions = array();
if ( $can_edit_post && 'trash' != $post->post_status ) {
$actions['edit'] = '<a href="' . get_edit_post_link( $post->ID, true ) . '" title="' . esc_attr( __( 'Edit this item' ) ) . '">' . __( 'Edit' ) . '</a>';
$actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr( __( 'Edit this item inline' ) ) . '">' . __( 'Quick Edit' ) . '</a>';
}
if ( current_user_can( $post_type_object->cap->delete_post, $post->ID ) ) {
if ( 'trash' == $post->post_status )
$actions['untrash'] = "<a title='" . esc_attr( __( 'Restore this item from the Trash' ) ) . "' href='" . wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&action=untrash', $post->ID ) ), 'untrash-' . $post->post_type . '_' . $post->ID ) . "'>" . __( 'Restore' ) . "</a>";
elseif ( EMPTY_TRASH_DAYS )
$actions['trash'] = "<a class='submitdelete' title='" . esc_attr( __( 'Move this item to the Trash' ) ) . "' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Trash' ) . "</a>";
if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS )
$actions['delete'] = "<a class='submitdelete' title='" . esc_attr( __( 'Delete this item permanently' ) ) . "' href='" . get_delete_post_link( $post->ID, '', true ) . "'>" . __( 'Delete Permanently' ) . "</a>";
}
if ( $post_type_object->public ) {
if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ) ) ) {
if ( $can_edit_post )
$actions['view'] = '<a href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) ) . '" title="' . esc_attr( sprintf( __( 'Preview “%s”' ), $title ) ) . '" rel="permalink">' . __( 'Preview' ) . '</a>';
} elseif ( 'trash' != $post->post_status ) {
$actions['view'] = '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( sprintf( __( 'View “%s”' ), $title ) ) . '" rel="permalink">' . __( 'View' ) . '</a>';
}
}
$actions = apply_filters( is_post_type_hierarchical( $post->post_type ) ? 'page_row_actions' : 'post_row_actions', $actions, $post );
echo $this->row_actions( $actions );
get_inline_data( $post );
echo '</td>';
break;
case 'date':
if ( '0000-00-00 00:00:00' == $post->post_date && 'date' == $column_name ) {
$t_time = $h_time = __( 'Unpublished' );
$time_diff = 0;
} else {
$t_time = get_the_time( __( 'Y/m/d g:i:s A' ) );
$m_time = $post->post_date;
$time = get_post_time( 'G', true, $post );
$time_diff = time() - $time;
if ( $time_diff > 0 && $time_diff < 24*60*60 )
$h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) );
else
$h_time = mysql2date( __( 'Y/m/d' ), $m_time );
}
echo '<td ' . $attributes . '>';
if ( 'excerpt' == $mode )
echo apply_filters( 'post_date_column_time', $t_time, $post, $column_name, $mode );
else
echo '<abbr title="' . $t_time . '">' . apply_filters( 'post_date_column_time', $h_time, $post, $column_name, $mode ) . '</abbr>';
echo '<br />';
if ( 'publish' == $post->post_status ) {
_e( 'Published' );
} elseif ( 'future' == $post->post_status ) {
if ( $time_diff > 0 )
echo '<strong class="attention">' . __( 'Missed schedule' ) . '</strong>';
else
_e( 'Scheduled' );
} else {
_e( 'Last Modified' );
}
echo '</td>';
break;
case 'categories':
?>
<td <?php echo $attributes ?>><?php
$categories = get_the_category();
if ( !empty( $categories ) ) {
$out = array();
foreach ( $categories as $c ) {
$out[] = sprintf( '<a href="%s">%s</a>',
esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'category_name' => $c->slug ), 'edit.php' ) ),
esc_html( sanitize_term_field( 'name', $c->name, $c->term_id, 'category', 'display' ) )
);
}
/* translators: used between list items, there is a space after the comma */
echo join( __( ', ' ), $out );
} else {
_e( 'Uncategorized' );
}
?></td>
<?php
break;
case 'tags':
?>
<td <?php echo $attributes ?>><?php
$tags = get_the_tags( $post->ID );
if ( !empty( $tags ) ) {
$out = array();
foreach ( $tags as $c ) {
$out[] = sprintf( '<a href="%s">%s</a>',
esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'tag' => $c->slug ), 'edit.php' ) ),
esc_html( sanitize_term_field( 'name', $c->name, $c->term_id, 'tag', 'display' ) )
);
}
/* translators: used between list items, there is a space after the comma */
echo join( __( ', ' ), $out );
} else {
_e( 'No Tags' );
}
?></td>
<?php
break;
case 'comments':
?>
<td <?php echo $attributes ?>><div class="post-com-count-wrapper">
<?php
$pending_comments = isset( $this->comment_pending_count[$post->ID] ) ? $this->comment_pending_count[$post->ID] : 0;
$this->comments_bubble( $post->ID, $pending_comments );
?>
</div></td>
<?php
break;
case 'author':
?>
<td <?php echo $attributes ?>><?php
printf( '<a href="%s">%s</a>',
esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'author' => get_the_author_meta( 'ID' ) ), 'edit.php' )),
get_the_author()
);
?></td>
<?php
break;
default:
?>
<td <?php echo $attributes ?>><?php
if ( is_post_type_hierarchical( $post->post_type ) )
do_action( 'manage_pages_custom_column', $column_name, $post->ID );
else
do_action( 'manage_posts_custom_column', $column_name, $post->ID );
do_action( "manage_{$post->post_type}_posts_custom_column", $column_name, $post->ID );
?></td>
<?php
break;
}
}
?>
</tr>
<?php
$post = $global_post;
}
/**
* Outputs the hidden row displayed when inline editing
*
* @since 3.1.0
*/
function inline_edit() {
global $mode;
$screen = get_current_screen();
$post = get_default_post_to_edit( $screen->post_type );
$post_type_object = get_post_type_object( $screen->post_type );
$taxonomy_names = get_object_taxonomies( $screen->post_type );
$hierarchical_taxonomies = array();
$flat_taxonomies = array();
foreach ( $taxonomy_names as $taxonomy_name ) {
$taxonomy = get_taxonomy( $taxonomy_name );
if ( !$taxonomy->show_ui )
continue;
if ( $taxonomy->hierarchical )
$hierarchical_taxonomies[] = $taxonomy;
else
$flat_taxonomies[] = $taxonomy;
}
$m = ( isset( $mode ) && 'excerpt' == $mode ) ? 'excerpt' : 'list';
$can_publish = current_user_can( $post_type_object->cap->publish_posts );
$core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true );
?>
<form method="get" action=""><table style="display: none"><tbody id="inlineedit">
<?php
$hclass = count( $hierarchical_taxonomies ) ? 'post' : 'page';
$bulk = 0;
while ( $bulk < 2 ) { ?>
<tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$hclass inline-edit-$screen->post_type ";
echo $bulk ? "bulk-edit-row bulk-edit-row-$hclass bulk-edit-$screen->post_type" : "quick-edit-row quick-edit-row-$hclass inline-edit-$screen->post_type";
?>" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange">
<fieldset class="inline-edit-col-left"><div class="inline-edit-col">
<h4><?php echo $bulk ? __( 'Bulk Edit' ) : __( 'Quick Edit' ); ?></h4>
<?php
if ( post_type_supports( $screen->post_type, 'title' ) ) :
if ( $bulk ) : ?>
<div id="bulk-title-div">
<div id="bulk-titles"></div>
</div>
<?php else : // $bulk ?>
<label>
<span class="title"><?php _e( 'Title' ); ?></span>
<span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span>
</label>
<label>
<span class="title"><?php _e( 'Slug' ); ?></span>
<span class="input-text-wrap"><input type="text" name="post_name" value="" /></span>
</label>
<?php endif; // $bulk
endif; // post_type_supports title ?>
<?php if ( !$bulk ) : ?>
<label><span class="title"><?php _e( 'Date' ); ?></span></label>
<div class="inline-edit-date">
<?php touch_time( 1, 1, 4, 1 ); ?>
</div>
<br class="clear" />
<?php endif; // $bulk
if ( post_type_supports( $screen->post_type, 'author' ) ) :
$authors_dropdown = '';
if ( is_super_admin() || current_user_can( $post_type_object->cap->edit_others_posts ) ) :
$users_opt = array(
'hide_if_only_one_author' => false,
'who' => 'authors',
'name' => 'post_author',
'class'=> 'authors',
'multi' => 1,
'echo' => 0
);
if ( $bulk )
$users_opt['show_option_none'] = __( '— No Change —' );
if ( $authors = wp_dropdown_users( $users_opt ) ) :
$authors_dropdown = '<label class="inline-edit-author">';
$authors_dropdown .= '<span class="title">' . __( 'Author' ) . '</span>';
$authors_dropdown .= $authors;
$authors_dropdown .= '</label>';
endif;
endif; // authors
?>
<?php if ( !$bulk ) echo $authors_dropdown;
endif; // post_type_supports author
if ( !$bulk ) :
?>
<div class="inline-edit-group">
<label class="alignleft">
<span class="title"><?php _e( 'Password' ); ?></span>
<span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span>
</label>
<em style="margin:5px 10px 0 0" class="alignleft">
<?php
/* translators: Between password field and private checkbox on post quick edit interface */
echo __( '–OR–' );
?>
</em>
<label class="alignleft inline-edit-private">
<input type="checkbox" name="keep_private" value="private" />
<span class="checkbox-title"><?php echo __( 'Private' ); ?></span>
</label>
</div>
<?php endif; ?>
</div></fieldset>
<?php if ( count( $hierarchical_taxonomies ) && !$bulk ) : ?>
<fieldset class="inline-edit-col-center inline-edit-categories"><div class="inline-edit-col">
<?php foreach ( $hierarchical_taxonomies as $taxonomy ) : ?>
<span class="title inline-edit-categories-label"><?php echo esc_html( $taxonomy->labels->name ) ?>
<span class="catshow"><?php _e( '[more]' ); ?></span>
<span class="cathide" style="display:none;"><?php _e( '[less]' ); ?></span>
</span>
<input type="hidden" name="<?php echo ( $taxonomy->name == 'category' ) ? 'post_category[]' : 'tax_input[' . esc_attr( $taxonomy->name ) . '][]'; ?>" value="0" />
<ul class="cat-checklist <?php echo esc_attr( $taxonomy->name )?>-checklist">
<?php wp_terms_checklist( null, array( 'taxonomy' => $taxonomy->name ) ) ?>
</ul>
<?php endforeach; //$hierarchical_taxonomies as $taxonomy ?>
</div></fieldset>
<?php endif; // count( $hierarchical_taxonomies ) && !$bulk ?>
<fieldset class="inline-edit-col-right"><div class="inline-edit-col">
<?php
if ( post_type_supports( $screen->post_type, 'author' ) && $bulk )
echo $authors_dropdown;
if ( post_type_supports( $screen->post_type, 'page-attributes' ) ) :
if ( $post_type_object->hierarchical ) :
?>
<label>
<span class="title"><?php _e( 'Parent' ); ?></span>
<?php
$dropdown_args = array(
'post_type' => $post_type_object->name,
'selected' => $post->post_parent,
'name' => 'post_parent',
'show_option_none' => __( 'Main Page (no parent)' ),
'option_none_value' => 0,
'sort_column' => 'menu_order, post_title',
);
if ( $bulk )
$dropdown_args['show_option_no_change'] = __( '— No Change —' );
$dropdown_args = apply_filters( 'quick_edit_dropdown_pages_args', $dropdown_args );
wp_dropdown_pages( $dropdown_args );
?>
</label>
<?php
endif; // hierarchical
if ( !$bulk ) : ?>
<label>
<span class="title"><?php _e( 'Order' ); ?></span>
<span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order ?>" /></span>
</label>
<?php endif; // !$bulk
if ( 'page' == $screen->post_type ) :
?>
<label>
<span class="title"><?php _e( 'Template' ); ?></span>
<select name="page_template">
<?php if ( $bulk ) : ?>
<option value="-1"><?php _e( '— No Change —' ); ?></option>
<?php endif; // $bulk ?>
<option value="default"><?php _e( 'Default Template' ); ?></option>
<?php page_template_dropdown() ?>
</select>
</label>
<?php
endif; // page post_type
endif; // page-attributes
?>
<?php if ( count( $flat_taxonomies ) && !$bulk ) : ?>
<?php foreach ( $flat_taxonomies as $taxonomy ) : ?>
<?php if ( current_user_can( $taxonomy->cap->assign_terms ) ) : ?>
<label class="inline-edit-tags">
<span class="title"><?php echo esc_html( $taxonomy->labels->name ) ?></span>
<textarea cols="22" rows="1" name="tax_input[<?php echo esc_attr( $taxonomy->name )?>]" class="tax_input_<?php echo esc_attr( $taxonomy->name )?>"></textarea>
</label>
<?php endif; ?>
<?php endforeach; //$flat_taxonomies as $taxonomy ?>
<?php endif; // count( $flat_taxonomies ) && !$bulk ?>
<?php if ( post_type_supports( $screen->post_type, 'comments' ) || post_type_supports( $screen->post_type, 'trackbacks' ) ) :
if ( $bulk ) : ?>
<div class="inline-edit-group">
<?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?>
<label class="alignleft">
<span class="title"><?php _e( 'Comments' ); ?></span>
<select name="comment_status">
<option value=""><?php _e( '— No Change —' ); ?></option>
<option value="open"><?php _e( 'Allow' ); ?></option>
<option value="closed"><?php _e( 'Do not allow' ); ?></option>
</select>
</label>
<?php endif; if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?>
<label class="alignright">
<span class="title"><?php _e( 'Pings' ); ?></span>
<select name="ping_status">
<option value=""><?php _e( '— No Change —' ); ?></option>
<option value="open"><?php _e( 'Allow' ); ?></option>
<option value="closed"><?php _e( 'Do not allow' ); ?></option>
</select>
</label>
<?php endif; ?>
</div>
<?php else : // $bulk ?>
<div class="inline-edit-group">
<?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?>
<label class="alignleft">
<input type="checkbox" name="comment_status" value="open" />
<span class="checkbox-title"><?php _e( 'Allow Comments' ); ?></span>
</label>
<?php endif; if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?>
<label class="alignleft">
<input type="checkbox" name="ping_status" value="open" />
<span class="checkbox-title"><?php _e( 'Allow Pings' ); ?></span>
</label>
<?php endif; ?>
</div>
<?php endif; // $bulk
endif; // post_type_supports comments or pings ?>
<div class="inline-edit-group">
<label class="inline-edit-status alignleft">
<span class="title"><?php _e( 'Status' ); ?></span>
<select name="_status">
<?php if ( $bulk ) : ?>
<option value="-1"><?php _e( '— No Change —' ); ?></option>
<?php endif; // $bulk ?>
<?php if ( $can_publish ) : // Contributors only get "Unpublished" and "Pending Review" ?>
<option value="publish"><?php _e( 'Published' ); ?></option>
<option value="future"><?php _e( 'Scheduled' ); ?></option>
<?php if ( $bulk ) : ?>
<option value="private"><?php _e( 'Private' ) ?></option>
<?php endif; // $bulk ?>
<?php endif; ?>
<option value="pending"><?php _e( 'Pending Review' ); ?></option>
<option value="draft"><?php _e( 'Draft' ); ?></option>
</select>
</label>
<?php if ( 'post' == $screen->post_type && $can_publish && current_user_can( $post_type_object->cap->edit_others_posts ) ) : ?>
<?php if ( $bulk ) : ?>
<label class="alignright">
<span class="title"><?php _e( 'Sticky' ); ?></span>
<select name="sticky">
<option value="-1"><?php _e( '— No Change —' ); ?></option>
<option value="sticky"><?php _e( 'Sticky' ); ?></option>
<option value="unsticky"><?php _e( 'Not Sticky' ); ?></option>
</select>
</label>
<?php else : // $bulk ?>
<label class="alignleft">
<input type="checkbox" name="sticky" value="sticky" />
<span class="checkbox-title"><?php _e( 'Make this post sticky' ); ?></span>
</label>
<?php endif; // $bulk ?>
<?php endif; // 'post' && $can_publish && current_user_can( 'edit_others_cap' ) ?>
</div>
<?php if ( post_type_supports( $screen->post_type, 'post-formats' ) && current_theme_supports( 'post-formats' ) ) :
$post_formats = get_theme_support( 'post-formats' );
if ( isset( $post_formats[0] ) && is_array( $post_formats[0] ) ) :
$all_post_formats = get_post_format_strings();
unset( $all_post_formats['standard'] ); ?>
<div class="inline-edit-group">
<label class="alignleft" for="post_format">
<span class="title"><?php _ex( 'Format', 'post format' ); ?></span>
<select name="post_format">
<?php if ( $bulk ) : ?>
<option value="-1"><?php _e( '— No Change —' ); ?></option>
<?php endif; ?>
<option value="0"><?php _ex( 'Standard', 'Post format' ); ?></option>
<?php foreach ( $all_post_formats as $slug => $format ) :
$unsupported = ! in_array( $slug, $post_formats[0] );
if ( $bulk && $unsupported )
continue;
?>
<option value="<?php echo esc_attr( $slug ); ?>"<?php if ( $unsupported ) echo ' class="unsupported"'; ?>><?php echo esc_html( $format ); ?></option>
<?php endforeach; ?>
</select></label>
</div>
<?php endif; ?>
<?php endif; // post-formats ?>
</div></fieldset>
<?php
list( $columns ) = $this->get_column_info();
foreach ( $columns as $column_name => $column_display_name ) {
if ( isset( $core_columns[$column_name] ) )
continue;
do_action( $bulk ? 'bulk_edit_custom_box' : 'quick_edit_custom_box', $column_name, $screen->post_type );
}
?>
<p class="submit inline-edit-save">
<a accesskey="c" href="#inline-edit" title="<?php esc_attr_e( 'Cancel' ); ?>" class="button-secondary cancel alignleft"><?php _e( 'Cancel' ); ?></a>
<?php if ( ! $bulk ) {
wp_nonce_field( 'inlineeditnonce', '_inline_edit', false );
$update_text = __( 'Update' );
?>
<a accesskey="s" href="#inline-edit" title="<?php esc_attr_e( 'Update' ); ?>" class="button-primary save alignright"><?php echo esc_attr( $update_text ); ?></a>
<img class="waiting" style="display:none;" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
<?php } else {
submit_button( __( 'Update' ), 'button-primary alignright', 'bulk_edit', false, array( 'accesskey' => 's' ) );
} ?>
<input type="hidden" name="post_view" value="<?php echo esc_attr( $m ); ?>" />
<input type="hidden" name="screen" value="<?php echo esc_attr( $screen->id ); ?>" />
<span class="error" style="display:none"></span>
<br class="clear" />
</p>
</td></tr>
<?php
$bulk++;
}
?>
</tbody></table></form>
<?php
}
}
| 01happy-blog | trunk/myblog/wp-admin/includes/class-wp-posts-list-table.php | PHP | oos | 36,078 |
<?php
/**
* WordPress Administration Update API
*
* @package WordPress
* @subpackage Administration
*/
// The admin side of our 1.1 update system
/**
* Selects the first update version from the update_core option
*
* @return object the response from the API
*/
function get_preferred_from_update_core() {
$updates = get_core_updates();
if ( !is_array( $updates ) )
return false;
if ( empty( $updates ) )
return (object)array('response' => 'latest');
return $updates[0];
}
/**
* Get available core updates
*
* @param array $options Set $options['dismissed'] to true to show dismissed upgrades too,
* set $options['available'] to false to skip not-dismissed updates.
* @return array Array of the update objects
*/
function get_core_updates( $options = array() ) {
$options = array_merge( array('available' => true, 'dismissed' => false ), $options );
$dismissed = get_site_option( 'dismissed_update_core' );
if ( !is_array( $dismissed ) ) $dismissed = array();
$from_api = get_site_transient( 'update_core' );
if ( empty($from_api) )
return false;
if ( !isset( $from_api->updates ) || !is_array( $from_api->updates ) ) return false;
$updates = $from_api->updates;
if ( !is_array( $updates ) ) return false;
$result = array();
foreach($updates as $update) {
if ( array_key_exists( $update->current.'|'.$update->locale, $dismissed ) ) {
if ( $options['dismissed'] ) {
$update->dismissed = true;
$result[]= $update;
}
} else {
if ( $options['available'] ) {
$update->dismissed = false;
$result[]= $update;
}
}
}
return $result;
}
function dismiss_core_update( $update ) {
$dismissed = get_site_option( 'dismissed_update_core' );
$dismissed[ $update->current.'|'.$update->locale ] = true;
return update_site_option( 'dismissed_update_core', $dismissed );
}
function undismiss_core_update( $version, $locale ) {
$dismissed = get_site_option( 'dismissed_update_core' );
$key = $version.'|'.$locale;
if ( !isset( $dismissed[$key] ) ) return false;
unset( $dismissed[$key] );
return update_site_option( 'dismissed_update_core', $dismissed );
}
function find_core_update( $version, $locale ) {
$from_api = get_site_transient( 'update_core' );
if ( !is_array( $from_api->updates ) ) return false;
$updates = $from_api->updates;
foreach($updates as $update) {
if ( $update->current == $version && $update->locale == $locale )
return $update;
}
return false;
}
function core_update_footer( $msg = '' ) {
if ( !current_user_can('update_core') )
return sprintf( __( 'Version %s' ), $GLOBALS['wp_version'] );
$cur = get_preferred_from_update_core();
if ( ! isset( $cur->current ) )
$cur->current = '';
if ( ! isset( $cur->url ) )
$cur->url = '';
if ( ! isset( $cur->response ) )
$cur->response = '';
switch ( $cur->response ) {
case 'development' :
return sprintf( __( 'You are using a development version (%1$s). Cool! Please <a href="%2$s">stay updated</a>.' ), $GLOBALS['wp_version'], network_admin_url( 'update-core.php' ) );
break;
case 'upgrade' :
return sprintf( '<strong>'.__( '<a href="%1$s">Get Version %2$s</a>' ).'</strong>', network_admin_url( 'update-core.php' ), $cur->current);
break;
case 'latest' :
default :
return sprintf( __( 'Version %s' ), $GLOBALS['wp_version'] );
break;
}
}
add_filter( 'update_footer', 'core_update_footer' );
function update_nag() {
if ( is_multisite() && !current_user_can('update_core') )
return false;
global $pagenow;
if ( 'update-core.php' == $pagenow )
return;
$cur = get_preferred_from_update_core();
if ( ! isset( $cur->response ) || $cur->response != 'upgrade' )
return false;
if ( current_user_can('update_core') ) {
$msg = sprintf( __('<a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> is available! <a href="%2$s">Please update now</a>.'), $cur->current, network_admin_url( 'update-core.php' ) );
} else {
$msg = sprintf( __('<a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> is available! Please notify the site administrator.'), $cur->current );
}
echo "<div class='update-nag'>$msg</div>";
}
add_action( 'admin_notices', 'update_nag', 3 );
// Called directly from dashboard
function update_right_now_message() {
$msg = sprintf( __('You are using <span class="b">WordPress %s</span>.'), $GLOBALS['wp_version'] );
if ( current_user_can('update_core') ) {
$cur = get_preferred_from_update_core();
if ( isset( $cur->response ) && $cur->response == 'upgrade' )
$msg .= " <a href='" . network_admin_url( 'update-core.php' ) . "' class='button'>" . sprintf( __('Update to %s'), $cur->current ? $cur->current : __( 'Latest' ) ) . '</a>';
}
echo "<span id='wp-version-message'>$msg</span>";
}
function get_plugin_updates() {
$all_plugins = get_plugins();
$upgrade_plugins = array();
$current = get_site_transient( 'update_plugins' );
foreach ( (array)$all_plugins as $plugin_file => $plugin_data) {
if ( isset( $current->response[ $plugin_file ] ) ) {
$upgrade_plugins[ $plugin_file ] = (object) $plugin_data;
$upgrade_plugins[ $plugin_file ]->update = $current->response[ $plugin_file ];
}
}
return $upgrade_plugins;
}
function wp_plugin_update_rows() {
if ( !current_user_can('update_plugins' ) )
return;
$plugins = get_site_transient( 'update_plugins' );
if ( isset($plugins->response) && is_array($plugins->response) ) {
$plugins = array_keys( $plugins->response );
foreach( $plugins as $plugin_file ) {
add_action( "after_plugin_row_$plugin_file", 'wp_plugin_update_row', 10, 2 );
}
}
}
add_action( 'admin_init', 'wp_plugin_update_rows' );
function wp_plugin_update_row( $file, $plugin_data ) {
$current = get_site_transient( 'update_plugins' );
if ( !isset( $current->response[ $file ] ) )
return false;
$r = $current->response[ $file ];
$plugins_allowedtags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array());
$plugin_name = wp_kses( $plugin_data['Name'], $plugins_allowedtags );
$details_url = self_admin_url('plugin-install.php?tab=plugin-information&plugin=' . $r->slug . '§ion=changelog&TB_iframe=true&width=600&height=800');
$wp_list_table = _get_list_table('WP_Plugins_List_Table');
if ( is_network_admin() || !is_multisite() ) {
echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">';
if ( ! current_user_can('update_plugins') )
printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a>.'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version );
else if ( empty($r->package) )
printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a>. <em>Automatic update is unavailable for this plugin.</em>'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version );
else
printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a> or <a href="%5$s">update now</a>.'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $r->new_version, wp_nonce_url( self_admin_url('update.php?action=upgrade-plugin&plugin=') . $file, 'upgrade-plugin_' . $file) );
do_action( "in_plugin_update_message-$file", $plugin_data, $r );
echo '</div></td></tr>';
}
}
function wp_update_plugin($plugin, $feedback = '') {
if ( !empty($feedback) )
add_filter('update_feedback', $feedback);
include ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
$upgrader = new Plugin_Upgrader();
return $upgrader->upgrade($plugin);
}
function get_theme_updates() {
$themes = wp_get_themes();
$current = get_site_transient('update_themes');
if ( ! isset( $current->response ) )
return array();
$update_themes = array();
foreach ( $current->response as $stylesheet => $data ) {
$update_themes[ $stylesheet ] = wp_get_theme( $stylesheet );
$update_themes[ $stylesheet ]->update = $data;
}
return $update_themes;
}
function wp_update_theme($theme, $feedback = '') {
if ( !empty($feedback) )
add_filter('update_feedback', $feedback);
include ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
$upgrader = new Theme_Upgrader();
return $upgrader->upgrade($theme);
}
function wp_theme_update_rows() {
if ( !current_user_can('update_themes' ) )
return;
$themes = get_site_transient( 'update_themes' );
if ( isset($themes->response) && is_array($themes->response) ) {
$themes = array_keys( $themes->response );
foreach( $themes as $theme ) {
add_action( "after_theme_row_$theme", 'wp_theme_update_row', 10, 2 );
}
}
}
add_action( 'admin_init', 'wp_theme_update_rows' );
function wp_theme_update_row( $theme_key, $theme ) {
$current = get_site_transient( 'update_themes' );
if ( !isset( $current->response[ $theme_key ] ) )
return false;
$r = $current->response[ $theme_key ];
$themes_allowedtags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array());
$theme_name = wp_kses( $theme['Name'], $themes_allowedtags );
$details_url = add_query_arg( array( 'TB_iframe' => 'true', 'width' => 1024, 'height' => 800 ), $current->response[ $theme_key ]['url'] );
$wp_list_table = _get_list_table('WP_MS_Themes_List_Table');
echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">';
if ( ! current_user_can('update_themes') )
printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a>.'), $theme['Name'], esc_url($details_url), esc_attr($theme['Name']), $r->new_version );
else if ( empty( $r['package'] ) )
printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a>. <em>Automatic update is unavailable for this theme.</em>'), $theme['Name'], esc_url($details_url), esc_attr($theme['Name']), $r['new_version'] );
else
printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a> or <a href="%5$s">update now</a>.'), $theme['Name'], esc_url($details_url), esc_attr($theme['Name']), $r['new_version'], wp_nonce_url( self_admin_url('update.php?action=upgrade-theme&theme=') . $theme_key, 'upgrade-theme_' . $theme_key) );
do_action( "in_theme_update_message-$theme_key", $theme, $r );
echo '</div></td></tr>';
}
function wp_update_core($current, $feedback = '') {
if ( !empty($feedback) )
add_filter('update_feedback', $feedback);
include ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
$upgrader = new Core_Upgrader();
return $upgrader->upgrade($current);
}
function maintenance_nag() {
global $upgrading;
if ( ! isset( $upgrading ) )
return false;
if ( current_user_can('update_core') )
$msg = sprintf( __('An automated WordPress update has failed to complete - <a href="%s">please attempt the update again now</a>.'), 'update-core.php' );
else
$msg = __('An automated WordPress update has failed to complete! Please notify the site administrator.');
echo "<div class='update-nag'>$msg</div>";
}
add_action( 'admin_notices', 'maintenance_nag' );
| 01happy-blog | trunk/myblog/wp-admin/includes/update.php | PHP | oos | 11,573 |
<?php
/**
* File contains all the administration image manipulation functions.
*
* @package WordPress
* @subpackage Administration
*/
/** The descriptions for theme files. */
$wp_file_descriptions = array(
'index.php' => __( 'Main Index Template' ),
'style.css' => __( 'Stylesheet' ),
'editor-style.css' => __( 'Visual Editor Stylesheet' ),
'editor-style-rtl.css' => __( 'Visual Editor RTL Stylesheet' ),
'rtl.css' => __( 'RTL Stylesheet' ),
'comments.php' => __( 'Comments' ),
'comments-popup.php' => __( 'Popup Comments' ),
'footer.php' => __( 'Footer' ),
'header.php' => __( 'Header' ),
'sidebar.php' => __( 'Sidebar' ),
'archive.php' => __( 'Archives' ),
'author.php' => __( 'Author Template' ),
'tag.php' => __( 'Tag Template' ),
'category.php' => __( 'Category Template' ),
'page.php' => __( 'Page Template' ),
'search.php' => __( 'Search Results' ),
'searchform.php' => __( 'Search Form' ),
'single.php' => __( 'Single Post' ),
'404.php' => __( '404 Template' ),
'link.php' => __( 'Links Template' ),
'functions.php' => __( 'Theme Functions' ),
'attachment.php' => __( 'Attachment Template' ),
'image.php' => __('Image Attachment Template'),
'video.php' => __('Video Attachment Template'),
'audio.php' => __('Audio Attachment Template'),
'application.php' => __('Application Attachment Template'),
'my-hacks.php' => __( 'my-hacks.php (legacy hacks support)' ),
'.htaccess' => __( '.htaccess (for rewrite rules )' ),
// Deprecated files
'wp-layout.css' => __( 'Stylesheet' ),
'wp-comments.php' => __( 'Comments Template' ),
'wp-comments-popup.php' => __( 'Popup Comments Template' ),
);
/**
* Get the description for standard WordPress theme files and other various standard
* WordPress files
*
* @since 1.5.0
*
* @uses _cleanup_header_comment
* @uses $wp_file_descriptions
* @param string $file Filesystem path or filename
* @return string Description of file from $wp_file_descriptions or basename of $file if description doesn't exist
*/
function get_file_description( $file ) {
global $wp_file_descriptions;
if ( isset( $wp_file_descriptions[basename( $file )] ) ) {
return $wp_file_descriptions[basename( $file )];
}
elseif ( file_exists( $file ) && is_file( $file ) ) {
$template_data = implode( '', file( $file ) );
if ( preg_match( '|Template Name:(.*)$|mi', $template_data, $name ))
return sprintf( __( '%s Page Template' ), _cleanup_header_comment($name[1]) );
}
return trim( basename( $file ) );
}
/**
* Get the absolute filesystem path to the root of the WordPress installation
*
* @since 1.5.0
*
* @uses get_option
* @return string Full filesystem path to the root of the WordPress installation
*/
function get_home_path() {
$home = get_option( 'home' );
$siteurl = get_option( 'siteurl' );
if ( $home != '' && $home != $siteurl ) {
$wp_path_rel_to_home = str_replace($home, '', $siteurl); /* $siteurl - $home */
$pos = strrpos($_SERVER["SCRIPT_FILENAME"], $wp_path_rel_to_home);
$home_path = substr($_SERVER["SCRIPT_FILENAME"], 0, $pos);
$home_path = trailingslashit( $home_path );
} else {
$home_path = ABSPATH;
}
return $home_path;
}
/**
* Get the real file system path to a file to edit within the admin
*
* If the $file is index.php or .htaccess this function will assume it is relative
* to the install root, otherwise it is assumed the file is relative to the wp-content
* directory
*
* @since 1.5.0
*
* @uses get_home_path
* @uses WP_CONTENT_DIR full filesystem path to the wp-content directory
* @param string $file filesystem path relative to the WordPress install directory or to the wp-content directory
* @return string full file system path to edit
*/
function get_real_file_to_edit( $file ) {
if ('index.php' == $file || '.htaccess' == $file ) {
$real_file = get_home_path() . $file;
} else {
$real_file = WP_CONTENT_DIR . $file;
}
return $real_file;
}
/**
* Returns a listing of all files in the specified folder and all subdirectories up to 100 levels deep.
* The depth of the recursiveness can be controlled by the $levels param.
*
* @since 2.6.0
*
* @param string $folder Full path to folder
* @param int $levels (optional) Levels of folders to follow, Default: 100 (PHP Loop limit).
* @return bool|array False on failure, Else array of files
*/
function list_files( $folder = '', $levels = 100 ) {
if ( empty($folder) )
return false;
if ( ! $levels )
return false;
$files = array();
if ( $dir = @opendir( $folder ) ) {
while (($file = readdir( $dir ) ) !== false ) {
if ( in_array($file, array('.', '..') ) )
continue;
if ( is_dir( $folder . '/' . $file ) ) {
$files2 = list_files( $folder . '/' . $file, $levels - 1);
if ( $files2 )
$files = array_merge($files, $files2 );
else
$files[] = $folder . '/' . $file . '/';
} else {
$files[] = $folder . '/' . $file;
}
}
}
@closedir( $dir );
return $files;
}
/**
* Returns a filename of a Temporary unique file.
* Please note that the calling function must unlink() this itself.
*
* The filename is based off the passed parameter or defaults to the current unix timestamp,
* while the directory can either be passed as well, or by leaving it blank, default to a writable temporary directory.
*
* @since 2.6.0
*
* @param string $filename (optional) Filename to base the Unique file off
* @param string $dir (optional) Directory to store the file in
* @return string a writable filename
*/
function wp_tempnam($filename = '', $dir = '') {
if ( empty($dir) )
$dir = get_temp_dir();
$filename = basename($filename);
if ( empty($filename) )
$filename = time();
$filename = preg_replace('|\..*$|', '.tmp', $filename);
$filename = $dir . wp_unique_filename($dir, $filename);
touch($filename);
return $filename;
}
/**
* Make sure that the file that was requested to edit, is allowed to be edited
*
* Function will die if if you are not allowed to edit the file
*
* @since 1.5.0
*
* @uses wp_die
* @uses validate_file
* @param string $file file the users is attempting to edit
* @param array $allowed_files Array of allowed files to edit, $file must match an entry exactly
* @return null
*/
function validate_file_to_edit( $file, $allowed_files = '' ) {
$code = validate_file( $file, $allowed_files );
if (!$code )
return $file;
switch ( $code ) {
case 1 :
wp_die( __('Sorry, can’t edit files with “..” in the name. If you are trying to edit a file in your WordPress home directory, you can just type the name of the file in.' ));
//case 2 :
// wp_die( __('Sorry, can’t call files with their real path.' ));
case 3 :
wp_die( __('Sorry, that file cannot be edited.' ));
}
}
/**
* Handle PHP uploads in WordPress, sanitizing file names, checking extensions for mime type,
* and moving the file to the appropriate directory within the uploads directory.
*
* @since 2.0
*
* @uses wp_handle_upload_error
* @uses apply_filters
* @uses is_multisite
* @uses wp_check_filetype_and_ext
* @uses current_user_can
* @uses wp_upload_dir
* @uses wp_unique_filename
* @uses delete_transient
* @param array $file Reference to a single element of $_FILES. Call the function once for each uploaded file.
* @param array $overrides Optional. An associative array of names=>values to override default variables with extract( $overrides, EXTR_OVERWRITE ).
* @return array On success, returns an associative array of file attributes. On failure, returns $overrides['upload_error_handler'](&$file, $message ) or array( 'error'=>$message ).
*/
function wp_handle_upload( &$file, $overrides = false, $time = null ) {
// The default error handler.
if ( ! function_exists( 'wp_handle_upload_error' ) ) {
function wp_handle_upload_error( &$file, $message ) {
return array( 'error'=>$message );
}
}
$file = apply_filters( 'wp_handle_upload_prefilter', $file );
// You may define your own function and pass the name in $overrides['upload_error_handler']
$upload_error_handler = 'wp_handle_upload_error';
// You may have had one or more 'wp_handle_upload_prefilter' functions error out the file. Handle that gracefully.
if ( isset( $file['error'] ) && !is_numeric( $file['error'] ) && $file['error'] )
return $upload_error_handler( $file, $file['error'] );
// You may define your own function and pass the name in $overrides['unique_filename_callback']
$unique_filename_callback = null;
// $_POST['action'] must be set and its value must equal $overrides['action'] or this:
$action = 'wp_handle_upload';
// Courtesy of php.net, the strings that describe the error indicated in $_FILES[{form field}]['error'].
$upload_error_strings = array( false,
__( "The uploaded file exceeds the upload_max_filesize directive in php.ini." ),
__( "The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form." ),
__( "The uploaded file was only partially uploaded." ),
__( "No file was uploaded." ),
'',
__( "Missing a temporary folder." ),
__( "Failed to write file to disk." ),
__( "File upload stopped by extension." ));
// All tests are on by default. Most can be turned off by $overrides[{test_name}] = false;
$test_form = true;
$test_size = true;
$test_upload = true;
// If you override this, you must provide $ext and $type!!!!
$test_type = true;
$mimes = false;
// Install user overrides. Did we mention that this voids your warranty?
if ( is_array( $overrides ) )
extract( $overrides, EXTR_OVERWRITE );
// A correct form post will pass this test.
if ( $test_form && (!isset( $_POST['action'] ) || ($_POST['action'] != $action ) ) )
return call_user_func($upload_error_handler, $file, __( 'Invalid form submission.' ));
// A successful upload will pass this test. It makes no sense to override this one.
if ( $file['error'] > 0 )
return call_user_func($upload_error_handler, $file, $upload_error_strings[$file['error']] );
// A non-empty file will pass this test.
if ( $test_size && !($file['size'] > 0 ) ) {
if ( is_multisite() )
$error_msg = __( 'File is empty. Please upload something more substantial.' );
else
$error_msg = __( '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.' );
return call_user_func($upload_error_handler, $file, $error_msg);
}
// A properly uploaded file will pass this test. There should be no reason to override this one.
if ( $test_upload && ! @ is_uploaded_file( $file['tmp_name'] ) )
return call_user_func($upload_error_handler, $file, __( 'Specified file failed upload test.' ));
// A correct MIME type will pass this test. Override $mimes or use the upload_mimes filter.
if ( $test_type ) {
$wp_filetype = wp_check_filetype_and_ext( $file['tmp_name'], $file['name'], $mimes );
extract( $wp_filetype );
// Check to see if wp_check_filetype_and_ext() determined the filename was incorrect
if ( $proper_filename )
$file['name'] = $proper_filename;
if ( ( !$type || !$ext ) && !current_user_can( 'unfiltered_upload' ) )
return call_user_func($upload_error_handler, $file, __( 'Sorry, this file type is not permitted for security reasons.' ));
if ( !$ext )
$ext = ltrim(strrchr($file['name'], '.'), '.');
if ( !$type )
$type = $file['type'];
} else {
$type = '';
}
// A writable uploads dir will pass this test. Again, there's no point overriding this one.
if ( ! ( ( $uploads = wp_upload_dir($time) ) && false === $uploads['error'] ) )
return call_user_func($upload_error_handler, $file, $uploads['error'] );
$filename = wp_unique_filename( $uploads['path'], $file['name'], $unique_filename_callback );
// Move the file to the uploads dir
$new_file = $uploads['path'] . "/$filename";
if ( false === @ move_uploaded_file( $file['tmp_name'], $new_file ) )
return $upload_error_handler( $file, sprintf( __('The uploaded file could not be moved to %s.' ), $uploads['path'] ) );
// Set correct file permissions
$stat = stat( dirname( $new_file ));
$perms = $stat['mode'] & 0000666;
@ chmod( $new_file, $perms );
// Compute the URL
$url = $uploads['url'] . "/$filename";
if ( is_multisite() )
delete_transient( 'dirsize_cache' );
return apply_filters( 'wp_handle_upload', array( 'file' => $new_file, 'url' => $url, 'type' => $type ), 'upload' );
}
/**
* Handle sideloads, which is the process of retrieving a media item from another server instead of
* a traditional media upload. This process involves sanitizing the filename, checking extensions
* for mime type, and moving the file to the appropriate directory within the uploads directory.
*
* @since 2.6.0
*
* @uses wp_handle_upload_error
* @uses apply_filters
* @uses wp_check_filetype_and_ext
* @uses current_user_can
* @uses wp_upload_dir
* @uses wp_unique_filename
* @param array $file an array similar to that of a PHP $_FILES POST array
* @param array $overrides Optional. An associative array of names=>values to override default variables with extract( $overrides, EXTR_OVERWRITE ).
* @return array On success, returns an associative array of file attributes. On failure, returns $overrides['upload_error_handler'](&$file, $message ) or array( 'error'=>$message ).
*/
function wp_handle_sideload( &$file, $overrides = false ) {
// The default error handler.
if (! function_exists( 'wp_handle_upload_error' ) ) {
function wp_handle_upload_error( &$file, $message ) {
return array( 'error'=>$message );
}
}
// You may define your own function and pass the name in $overrides['upload_error_handler']
$upload_error_handler = 'wp_handle_upload_error';
// You may define your own function and pass the name in $overrides['unique_filename_callback']
$unique_filename_callback = null;
// $_POST['action'] must be set and its value must equal $overrides['action'] or this:
$action = 'wp_handle_sideload';
// Courtesy of php.net, the strings that describe the error indicated in $_FILES[{form field}]['error'].
$upload_error_strings = array( false,
__( "The uploaded file exceeds the <code>upload_max_filesize</code> directive in <code>php.ini</code>." ),
__( "The uploaded file exceeds the <em>MAX_FILE_SIZE</em> directive that was specified in the HTML form." ),
__( "The uploaded file was only partially uploaded." ),
__( "No file was uploaded." ),
'',
__( "Missing a temporary folder." ),
__( "Failed to write file to disk." ),
__( "File upload stopped by extension." ));
// All tests are on by default. Most can be turned off by $overrides[{test_name}] = false;
$test_form = true;
$test_size = true;
// If you override this, you must provide $ext and $type!!!!
$test_type = true;
$mimes = false;
// Install user overrides. Did we mention that this voids your warranty?
if ( is_array( $overrides ) )
extract( $overrides, EXTR_OVERWRITE );
// A correct form post will pass this test.
if ( $test_form && (!isset( $_POST['action'] ) || ($_POST['action'] != $action ) ) )
return $upload_error_handler( $file, __( 'Invalid form submission.' ));
// A successful upload will pass this test. It makes no sense to override this one.
if ( ! empty( $file['error'] ) )
return $upload_error_handler( $file, $upload_error_strings[$file['error']] );
// A non-empty file will pass this test.
if ( $test_size && !(filesize($file['tmp_name']) > 0 ) )
return $upload_error_handler( $file, __( 'File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini.' ));
// A properly uploaded file will pass this test. There should be no reason to override this one.
if (! @ is_file( $file['tmp_name'] ) )
return $upload_error_handler( $file, __( 'Specified file does not exist.' ));
// A correct MIME type will pass this test. Override $mimes or use the upload_mimes filter.
if ( $test_type ) {
$wp_filetype = wp_check_filetype_and_ext( $file['tmp_name'], $file['name'], $mimes );
extract( $wp_filetype );
// Check to see if wp_check_filetype_and_ext() determined the filename was incorrect
if ( $proper_filename )
$file['name'] = $proper_filename;
if ( ( !$type || !$ext ) && !current_user_can( 'unfiltered_upload' ) )
return $upload_error_handler( $file, __( 'Sorry, this file type is not permitted for security reasons.' ));
if ( !$ext )
$ext = ltrim(strrchr($file['name'], '.'), '.');
if ( !$type )
$type = $file['type'];
}
// A writable uploads dir will pass this test. Again, there's no point overriding this one.
if ( ! ( ( $uploads = wp_upload_dir() ) && false === $uploads['error'] ) )
return $upload_error_handler( $file, $uploads['error'] );
$filename = wp_unique_filename( $uploads['path'], $file['name'], $unique_filename_callback );
// Strip the query strings.
$filename = str_replace('?','-', $filename);
$filename = str_replace('&','-', $filename);
// Move the file to the uploads dir
$new_file = $uploads['path'] . "/$filename";
if ( false === @ rename( $file['tmp_name'], $new_file ) ) {
return $upload_error_handler( $file, sprintf( __('The uploaded file could not be moved to %s.' ), $uploads['path'] ) );
}
// Set correct file permissions
$stat = stat( dirname( $new_file ));
$perms = $stat['mode'] & 0000666;
@ chmod( $new_file, $perms );
// Compute the URL
$url = $uploads['url'] . "/$filename";
$return = apply_filters( 'wp_handle_upload', array( 'file' => $new_file, 'url' => $url, 'type' => $type ), 'sideload' );
return $return;
}
/**
* Downloads a url to a local temporary file using the WordPress HTTP Class.
* Please note, That the calling function must unlink() the file.
*
* @since 2.5.0
*
* @param string $url the URL of the file to download
* @param int $timeout The timeout for the request to download the file default 300 seconds
* @return mixed WP_Error on failure, string Filename on success.
*/
function download_url( $url, $timeout = 300 ) {
//WARNING: The file is not automatically deleted, The script must unlink() the file.
if ( ! $url )
return new WP_Error('http_no_url', __('Invalid URL Provided.'));
$tmpfname = wp_tempnam($url);
if ( ! $tmpfname )
return new WP_Error('http_no_file', __('Could not create Temporary file.'));
$response = wp_remote_get( $url, array( 'timeout' => $timeout, 'stream' => true, 'filename' => $tmpfname ) );
if ( is_wp_error( $response ) ) {
unlink( $tmpfname );
return $response;
}
if ( 200 != wp_remote_retrieve_response_code( $response ) ){
unlink( $tmpfname );
return new WP_Error( 'http_404', trim( wp_remote_retrieve_response_message( $response ) ) );
}
return $tmpfname;
}
/**
* Unzips a specified ZIP file to a location on the Filesystem via the WordPress Filesystem Abstraction.
* Assumes that WP_Filesystem() has already been called and set up. Does not extract a root-level __MACOSX directory, if present.
*
* Attempts to increase the PHP Memory limit to 256M before uncompressing,
* However, The most memory required shouldn't be much larger than the Archive itself.
*
* @since 2.5.0
*
* @param string $file Full path and filename of zip archive
* @param string $to Full path on the filesystem to extract archive to
* @return mixed WP_Error on failure, True on success
*/
function unzip_file($file, $to) {
global $wp_filesystem;
if ( ! $wp_filesystem || !is_object($wp_filesystem) )
return new WP_Error('fs_unavailable', __('Could not access filesystem.'));
// Unzip can use a lot of memory, but not this much hopefully
@ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', WP_MAX_MEMORY_LIMIT ) );
$needed_dirs = array();
$to = trailingslashit($to);
// Determine any parent dir's needed (of the upgrade directory)
if ( ! $wp_filesystem->is_dir($to) ) { //Only do parents if no children exist
$path = preg_split('![/\\\]!', untrailingslashit($to));
for ( $i = count($path); $i >= 0; $i-- ) {
if ( empty($path[$i]) )
continue;
$dir = implode('/', array_slice($path, 0, $i+1) );
if ( preg_match('!^[a-z]:$!i', $dir) ) // Skip it if it looks like a Windows Drive letter.
continue;
if ( ! $wp_filesystem->is_dir($dir) )
$needed_dirs[] = $dir;
else
break; // A folder exists, therefor, we dont need the check the levels below this
}
}
if ( class_exists('ZipArchive') && apply_filters('unzip_file_use_ziparchive', true ) ) {
$result = _unzip_file_ziparchive($file, $to, $needed_dirs);
if ( true === $result ) {
return $result;
} elseif ( is_wp_error($result) ) {
if ( 'incompatible_archive' != $result->get_error_code() )
return $result;
}
}
// Fall through to PclZip if ZipArchive is not available, or encountered an error opening the file.
return _unzip_file_pclzip($file, $to, $needed_dirs);
}
/**
* This function should not be called directly, use unzip_file instead. Attempts to unzip an archive using the ZipArchive class.
* Assumes that WP_Filesystem() has already been called and set up.
*
* @since 3.0.0
* @see unzip_file
* @access private
*
* @param string $file Full path and filename of zip archive
* @param string $to Full path on the filesystem to extract archive to
* @param array $needed_dirs A partial list of required folders needed to be created.
* @return mixed WP_Error on failure, True on success
*/
function _unzip_file_ziparchive($file, $to, $needed_dirs = array() ) {
global $wp_filesystem;
$z = new ZipArchive();
// PHP4-compat - php4 classes can't contain constants
$zopen = $z->open($file, /* ZIPARCHIVE::CHECKCONS */ 4);
if ( true !== $zopen )
return new WP_Error('incompatible_archive', __('Incompatible Archive.'));
for ( $i = 0; $i < $z->numFiles; $i++ ) {
if ( ! $info = $z->statIndex($i) )
return new WP_Error('stat_failed', __('Could not retrieve file from archive.'));
if ( '__MACOSX/' === substr($info['name'], 0, 9) ) // Skip the OS X-created __MACOSX directory
continue;
if ( '/' == substr($info['name'], -1) ) // directory
$needed_dirs[] = $to . untrailingslashit($info['name']);
else
$needed_dirs[] = $to . untrailingslashit(dirname($info['name']));
}
$needed_dirs = array_unique($needed_dirs);
foreach ( $needed_dirs as $dir ) {
// Check the parent folders of the folders all exist within the creation array.
if ( untrailingslashit($to) == $dir ) // Skip over the working directory, We know this exists (or will exist)
continue;
if ( strpos($dir, $to) === false ) // If the directory is not within the working directory, Skip it
continue;
$parent_folder = dirname($dir);
while ( !empty($parent_folder) && untrailingslashit($to) != $parent_folder && !in_array($parent_folder, $needed_dirs) ) {
$needed_dirs[] = $parent_folder;
$parent_folder = dirname($parent_folder);
}
}
asort($needed_dirs);
// Create those directories if need be:
foreach ( $needed_dirs as $_dir ) {
if ( ! $wp_filesystem->mkdir($_dir, FS_CHMOD_DIR) && ! $wp_filesystem->is_dir($_dir) ) // Only check to see if the Dir exists upon creation failure. Less I/O this way.
return new WP_Error('mkdir_failed', __('Could not create directory.'), $_dir);
}
unset($needed_dirs);
for ( $i = 0; $i < $z->numFiles; $i++ ) {
if ( ! $info = $z->statIndex($i) )
return new WP_Error('stat_failed', __('Could not retrieve file from archive.'));
if ( '/' == substr($info['name'], -1) ) // directory
continue;
if ( '__MACOSX/' === substr($info['name'], 0, 9) ) // Don't extract the OS X-created __MACOSX directory files
continue;
$contents = $z->getFromIndex($i);
if ( false === $contents )
return new WP_Error('extract_failed', __('Could not extract file from archive.'), $info['name']);
if ( ! $wp_filesystem->put_contents( $to . $info['name'], $contents, FS_CHMOD_FILE) )
return new WP_Error('copy_failed', __('Could not copy file.'), $to . $info['name']);
}
$z->close();
return true;
}
/**
* This function should not be called directly, use unzip_file instead. Attempts to unzip an archive using the PclZip library.
* Assumes that WP_Filesystem() has already been called and set up.
*
* @since 3.0.0
* @see unzip_file
* @access private
*
* @param string $file Full path and filename of zip archive
* @param string $to Full path on the filesystem to extract archive to
* @param array $needed_dirs A partial list of required folders needed to be created.
* @return mixed WP_Error on failure, True on success
*/
function _unzip_file_pclzip($file, $to, $needed_dirs = array()) {
global $wp_filesystem;
// See #15789 - PclZip uses string functions on binary data, If it's overloaded with Multibyte safe functions the results are incorrect.
if ( ini_get('mbstring.func_overload') && function_exists('mb_internal_encoding') ) {
$previous_encoding = mb_internal_encoding();
mb_internal_encoding('ISO-8859-1');
}
require_once(ABSPATH . 'wp-admin/includes/class-pclzip.php');
$archive = new PclZip($file);
$archive_files = $archive->extract(PCLZIP_OPT_EXTRACT_AS_STRING);
if ( isset($previous_encoding) )
mb_internal_encoding($previous_encoding);
// Is the archive valid?
if ( !is_array($archive_files) )
return new WP_Error('incompatible_archive', __('Incompatible Archive.'), $archive->errorInfo(true));
if ( 0 == count($archive_files) )
return new WP_Error('empty_archive', __('Empty archive.'));
// Determine any children directories needed (From within the archive)
foreach ( $archive_files as $file ) {
if ( '__MACOSX/' === substr($file['filename'], 0, 9) ) // Skip the OS X-created __MACOSX directory
continue;
$needed_dirs[] = $to . untrailingslashit( $file['folder'] ? $file['filename'] : dirname($file['filename']) );
}
$needed_dirs = array_unique($needed_dirs);
foreach ( $needed_dirs as $dir ) {
// Check the parent folders of the folders all exist within the creation array.
if ( untrailingslashit($to) == $dir ) // Skip over the working directory, We know this exists (or will exist)
continue;
if ( strpos($dir, $to) === false ) // If the directory is not within the working directory, Skip it
continue;
$parent_folder = dirname($dir);
while ( !empty($parent_folder) && untrailingslashit($to) != $parent_folder && !in_array($parent_folder, $needed_dirs) ) {
$needed_dirs[] = $parent_folder;
$parent_folder = dirname($parent_folder);
}
}
asort($needed_dirs);
// Create those directories if need be:
foreach ( $needed_dirs as $_dir ) {
if ( ! $wp_filesystem->mkdir($_dir, FS_CHMOD_DIR) && ! $wp_filesystem->is_dir($_dir) ) // Only check to see if the dir exists upon creation failure. Less I/O this way.
return new WP_Error('mkdir_failed', __('Could not create directory.'), $_dir);
}
unset($needed_dirs);
// Extract the files from the zip
foreach ( $archive_files as $file ) {
if ( $file['folder'] )
continue;
if ( '__MACOSX/' === substr($file['filename'], 0, 9) ) // Don't extract the OS X-created __MACOSX directory files
continue;
if ( ! $wp_filesystem->put_contents( $to . $file['filename'], $file['content'], FS_CHMOD_FILE) )
return new WP_Error('copy_failed', __('Could not copy file.'), $to . $file['filename']);
}
return true;
}
/**
* Copies a directory from one location to another via the WordPress Filesystem Abstraction.
* Assumes that WP_Filesystem() has already been called and setup.
*
* @since 2.5.0
*
* @param string $from source directory
* @param string $to destination directory
* @param array $skip_list a list of files/folders to skip copying
* @return mixed WP_Error on failure, True on success.
*/
function copy_dir($from, $to, $skip_list = array() ) {
global $wp_filesystem;
$dirlist = $wp_filesystem->dirlist($from);
$from = trailingslashit($from);
$to = trailingslashit($to);
$skip_regex = '';
foreach ( (array)$skip_list as $key => $skip_file )
$skip_regex .= preg_quote($skip_file, '!') . '|';
if ( !empty($skip_regex) )
$skip_regex = '!(' . rtrim($skip_regex, '|') . ')$!i';
foreach ( (array) $dirlist as $filename => $fileinfo ) {
if ( !empty($skip_regex) )
if ( preg_match($skip_regex, $from . $filename) )
continue;
if ( 'f' == $fileinfo['type'] ) {
if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) ) {
// If copy failed, chmod file to 0644 and try again.
$wp_filesystem->chmod($to . $filename, 0644);
if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) )
return new WP_Error('copy_failed', __('Could not copy file.'), $to . $filename);
}
} elseif ( 'd' == $fileinfo['type'] ) {
if ( !$wp_filesystem->is_dir($to . $filename) ) {
if ( !$wp_filesystem->mkdir($to . $filename, FS_CHMOD_DIR) )
return new WP_Error('mkdir_failed', __('Could not create directory.'), $to . $filename);
}
$result = copy_dir($from . $filename, $to . $filename, $skip_list);
if ( is_wp_error($result) )
return $result;
}
}
return true;
}
/**
* Initialises and connects the WordPress Filesystem Abstraction classes.
* This function will include the chosen transport and attempt connecting.
*
* Plugins may add extra transports, And force WordPress to use them by returning the filename via the 'filesystem_method_file' filter.
*
* @since 2.5.0
*
* @param array $args (optional) Connection args, These are passed directly to the WP_Filesystem_*() classes.
* @param string $context (optional) Context for get_filesystem_method(), See function declaration for more information.
* @return boolean false on failure, true on success
*/
function WP_Filesystem( $args = false, $context = false ) {
global $wp_filesystem;
require_once(ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php');
$method = get_filesystem_method($args, $context);
if ( ! $method )
return false;
if ( ! class_exists("WP_Filesystem_$method") ) {
$abstraction_file = apply_filters('filesystem_method_file', ABSPATH . 'wp-admin/includes/class-wp-filesystem-' . $method . '.php', $method);
if ( ! file_exists($abstraction_file) )
return;
require_once($abstraction_file);
}
$method = "WP_Filesystem_$method";
$wp_filesystem = new $method($args);
//Define the timeouts for the connections. Only available after the construct is called to allow for per-transport overriding of the default.
if ( ! defined('FS_CONNECT_TIMEOUT') )
define('FS_CONNECT_TIMEOUT', 30);
if ( ! defined('FS_TIMEOUT') )
define('FS_TIMEOUT', 30);
if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() )
return false;
if ( !$wp_filesystem->connect() )
return false; //There was an error connecting to the server.
// Set the permission constants if not already set.
if ( ! defined('FS_CHMOD_DIR') )
define('FS_CHMOD_DIR', 0755 );
if ( ! defined('FS_CHMOD_FILE') )
define('FS_CHMOD_FILE', 0644 );
return true;
}
/**
* Determines which Filesystem Method to use.
* The priority of the Transports are: Direct, SSH2, FTP PHP Extension, FTP Sockets (Via Sockets class, or fsockopen())
*
* Note that the return value of this function can be overridden in 2 ways
* - By defining FS_METHOD in your <code>wp-config.php</code> file
* - By using the filesystem_method filter
* Valid values for these are: 'direct', 'ssh', 'ftpext' or 'ftpsockets'
* Plugins may also define a custom transport handler, See the WP_Filesystem function for more information.
*
* @since 2.5.0
*
* @param array $args Connection details.
* @param string $context Full path to the directory that is tested for being writable.
* @return string The transport to use, see description for valid return values.
*/
function get_filesystem_method($args = array(), $context = false) {
$method = defined('FS_METHOD') ? FS_METHOD : false; //Please ensure that this is either 'direct', 'ssh', 'ftpext' or 'ftpsockets'
if ( ! $method && function_exists('getmyuid') && function_exists('fileowner') ){
if ( !$context )
$context = WP_CONTENT_DIR;
$context = trailingslashit($context);
$temp_file_name = $context . 'temp-write-test-' . time();
$temp_handle = @fopen($temp_file_name, 'w');
if ( $temp_handle ) {
if ( getmyuid() == @fileowner($temp_file_name) )
$method = 'direct';
@fclose($temp_handle);
@unlink($temp_file_name);
}
}
if ( ! $method && isset($args['connection_type']) && 'ssh' == $args['connection_type'] && extension_loaded('ssh2') && function_exists('stream_get_contents') ) $method = 'ssh2';
if ( ! $method && extension_loaded('ftp') ) $method = 'ftpext';
if ( ! $method && ( extension_loaded('sockets') || function_exists('fsockopen') ) ) $method = 'ftpsockets'; //Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread
return apply_filters('filesystem_method', $method, $args);
}
/**
* Displays a form to the user to request for their FTP/SSH details in order to connect to the filesystem.
* All chosen/entered details are saved, Excluding the Password.
*
* Hostnames may be in the form of hostname:portnumber (eg: wordpress.org:2467) to specify an alternate FTP/SSH port.
*
* Plugins may override this form by returning true|false via the <code>request_filesystem_credentials</code> filter.
*
* @since 2.5.0
*
* @param string $form_post the URL to post the form to
* @param string $type the chosen Filesystem method in use
* @param boolean $error if the current request has failed to connect
* @param string $context The directory which is needed access to, The write-test will be performed on this directory by get_filesystem_method()
* @param string $extra_fields Extra POST fields which should be checked for to be included in the post.
* @return boolean False on failure. True on success.
*/
function request_filesystem_credentials($form_post, $type = '', $error = false, $context = false, $extra_fields = null) {
$req_cred = apply_filters( 'request_filesystem_credentials', '', $form_post, $type, $error, $context, $extra_fields );
if ( '' !== $req_cred )
return $req_cred;
if ( empty($type) )
$type = get_filesystem_method(array(), $context);
if ( 'direct' == $type )
return true;
if ( is_null( $extra_fields ) )
$extra_fields = array( 'version', 'locale' );
$credentials = get_option('ftp_credentials', array( 'hostname' => '', 'username' => ''));
// If defined, set it to that, Else, If POST'd, set it to that, If not, Set it to whatever it previously was(saved details in option)
$credentials['hostname'] = defined('FTP_HOST') ? FTP_HOST : (!empty($_POST['hostname']) ? stripslashes($_POST['hostname']) : $credentials['hostname']);
$credentials['username'] = defined('FTP_USER') ? FTP_USER : (!empty($_POST['username']) ? stripslashes($_POST['username']) : $credentials['username']);
$credentials['password'] = defined('FTP_PASS') ? FTP_PASS : (!empty($_POST['password']) ? stripslashes($_POST['password']) : '');
// Check to see if we are setting the public/private keys for ssh
$credentials['public_key'] = defined('FTP_PUBKEY') ? FTP_PUBKEY : (!empty($_POST['public_key']) ? stripslashes($_POST['public_key']) : '');
$credentials['private_key'] = defined('FTP_PRIKEY') ? FTP_PRIKEY : (!empty($_POST['private_key']) ? stripslashes($_POST['private_key']) : '');
//sanitize the hostname, Some people might pass in odd-data:
$credentials['hostname'] = preg_replace('|\w+://|', '', $credentials['hostname']); //Strip any schemes off
if ( strpos($credentials['hostname'], ':') ) {
list( $credentials['hostname'], $credentials['port'] ) = explode(':', $credentials['hostname'], 2);
if ( ! is_numeric($credentials['port']) )
unset($credentials['port']);
} else {
unset($credentials['port']);
}
if ( (defined('FTP_SSH') && FTP_SSH) || (defined('FS_METHOD') && 'ssh' == FS_METHOD) )
$credentials['connection_type'] = 'ssh';
else if ( (defined('FTP_SSL') && FTP_SSL) && 'ftpext' == $type ) //Only the FTP Extension understands SSL
$credentials['connection_type'] = 'ftps';
else if ( !empty($_POST['connection_type']) )
$credentials['connection_type'] = stripslashes($_POST['connection_type']);
else if ( !isset($credentials['connection_type']) ) //All else fails (And its not defaulted to something else saved), Default to FTP
$credentials['connection_type'] = 'ftp';
if ( ! $error &&
(
( !empty($credentials['password']) && !empty($credentials['username']) && !empty($credentials['hostname']) ) ||
( 'ssh' == $credentials['connection_type'] && !empty($credentials['public_key']) && !empty($credentials['private_key']) )
) ) {
$stored_credentials = $credentials;
if ( !empty($stored_credentials['port']) ) //save port as part of hostname to simplify above code.
$stored_credentials['hostname'] .= ':' . $stored_credentials['port'];
unset($stored_credentials['password'], $stored_credentials['port'], $stored_credentials['private_key'], $stored_credentials['public_key']);
update_option('ftp_credentials', $stored_credentials);
return $credentials;
}
$hostname = '';
$username = '';
$password = '';
$connection_type = '';
if ( !empty($credentials) )
extract($credentials, EXTR_OVERWRITE);
if ( $error ) {
$error_string = __('<strong>ERROR:</strong> There was an error connecting to the server, Please verify the settings are correct.');
if ( is_wp_error($error) )
$error_string = esc_html( $error->get_error_message() );
echo '<div id="message" class="error"><p>' . $error_string . '</p></div>';
}
$types = array();
if ( extension_loaded('ftp') || extension_loaded('sockets') || function_exists('fsockopen') )
$types[ 'ftp' ] = __('FTP');
if ( extension_loaded('ftp') ) //Only this supports FTPS
$types[ 'ftps' ] = __('FTPS (SSL)');
if ( extension_loaded('ssh2') && function_exists('stream_get_contents') )
$types[ 'ssh' ] = __('SSH2');
$types = apply_filters('fs_ftp_connection_types', $types, $credentials, $type, $error, $context);
?>
<script type="text/javascript">
<!--
jQuery(function($){
jQuery("#ssh").click(function () {
jQuery("#ssh_keys").show();
});
jQuery("#ftp, #ftps").click(function () {
jQuery("#ssh_keys").hide();
});
jQuery('form input[value=""]:first').focus();
});
-->
</script>
<form action="<?php echo $form_post ?>" method="post">
<div class="wrap">
<?php screen_icon(); ?>
<h2><?php _e('Connection Information') ?></h2>
<p><?php
$label_user = __('Username');
$label_pass = __('Password');
_e('To perform the requested action, WordPress needs to access your web server.');
echo ' ';
if ( ( isset( $types['ftp'] ) || isset( $types['ftps'] ) ) ) {
if ( isset( $types['ssh'] ) ) {
_e('Please enter your FTP or SSH credentials to proceed.');
$label_user = __('FTP/SSH Username');
$label_pass = __('FTP/SSH Password');
} else {
_e('Please enter your FTP credentials to proceed.');
$label_user = __('FTP Username');
$label_pass = __('FTP Password');
}
echo ' ';
}
_e('If you do not remember your credentials, you should contact your web host.');
?></p>
<table class="form-table">
<tr valign="top">
<th scope="row"><label for="hostname"><?php _e('Hostname') ?></label></th>
<td><input name="hostname" type="text" id="hostname" value="<?php echo esc_attr($hostname); if ( !empty($port) ) echo ":$port"; ?>"<?php disabled( defined('FTP_HOST') ); ?> size="40" /></td>
</tr>
<tr valign="top">
<th scope="row"><label for="username"><?php echo $label_user; ?></label></th>
<td><input name="username" type="text" id="username" value="<?php echo esc_attr($username) ?>"<?php disabled( defined('FTP_USER') ); ?> size="40" /></td>
</tr>
<tr valign="top">
<th scope="row"><label for="password"><?php echo $label_pass; ?></label></th>
<td><input name="password" type="password" id="password" value="<?php if ( defined('FTP_PASS') ) echo '*****'; ?>"<?php disabled( defined('FTP_PASS') ); ?> size="40" /></td>
</tr>
<?php if ( isset($types['ssh']) ) : ?>
<tr id="ssh_keys" valign="top" style="<?php if ( 'ssh' != $connection_type ) echo 'display:none' ?>">
<th scope="row"><?php _e('Authentication Keys') ?>
<div class="key-labels textright">
<label for="public_key"><?php _e('Public Key:') ?></label ><br />
<label for="private_key"><?php _e('Private Key:') ?></label>
</div></th>
<td><br /><input name="public_key" type="text" id="public_key" value="<?php echo esc_attr($public_key) ?>"<?php disabled( defined('FTP_PUBKEY') ); ?> size="40" /><br /><input name="private_key" type="text" id="private_key" value="<?php echo esc_attr($private_key) ?>"<?php disabled( defined('FTP_PRIKEY') ); ?> size="40" />
<div><?php _e('Enter the location on the server where the keys are located. If a passphrase is needed, enter that in the password field above.') ?></div></td>
</tr>
<?php endif; ?>
<tr valign="top">
<th scope="row"><?php _e('Connection Type') ?></th>
<td>
<fieldset><legend class="screen-reader-text"><span><?php _e('Connection Type') ?></span></legend>
<?php
$disabled = disabled( (defined('FTP_SSL') && FTP_SSL) || (defined('FTP_SSH') && FTP_SSH), true, false );
foreach ( $types as $name => $text ) : ?>
<label for="<?php echo esc_attr($name) ?>">
<input type="radio" name="connection_type" id="<?php echo esc_attr($name) ?>" value="<?php echo esc_attr($name) ?>"<?php checked($name, $connection_type); echo $disabled; ?> />
<?php echo $text ?>
</label>
<?php endforeach; ?>
</fieldset>
</td>
</tr>
</table>
<?php
foreach ( (array) $extra_fields as $field ) {
if ( isset( $_POST[ $field ] ) )
echo '<input type="hidden" name="' . esc_attr( $field ) . '" value="' . esc_attr( stripslashes( $_POST[ $field ] ) ) . '" />';
}
submit_button( __( 'Proceed' ), 'button', 'upgrade' );
?>
</div>
</form>
<?php
return false;
}
| 01happy-blog | trunk/myblog/wp-admin/includes/file.php | PHP | oos | 41,660 |
<?php
/**
* WordPress Theme Administration API
*
* @package WordPress
* @subpackage Administration
*/
/**
* Remove a theme
*
* @since 2.8.0
*
* @param string $stylesheet Stylesheet of the theme to delete
* @param string $redirect Redirect to page when complete.
* @return mixed
*/
function delete_theme($stylesheet, $redirect = '') {
global $wp_filesystem;
if ( empty($stylesheet) )
return false;
ob_start();
if ( empty( $redirect ) )
$redirect = wp_nonce_url('themes.php?action=delete&stylesheet=' . $stylesheet, 'delete-theme_' . $stylesheet);
if ( false === ($credentials = request_filesystem_credentials($redirect)) ) {
$data = ob_get_contents();
ob_end_clean();
if ( ! empty($data) ){
include_once( ABSPATH . 'wp-admin/admin-header.php');
echo $data;
include( ABSPATH . 'wp-admin/admin-footer.php');
exit;
}
return;
}
if ( ! WP_Filesystem($credentials) ) {
request_filesystem_credentials($url, '', true); // Failed to connect, Error and request again
$data = ob_get_contents();
ob_end_clean();
if ( ! empty($data) ) {
include_once( ABSPATH . 'wp-admin/admin-header.php');
echo $data;
include( ABSPATH . 'wp-admin/admin-footer.php');
exit;
}
return;
}
if ( ! is_object($wp_filesystem) )
return new WP_Error('fs_unavailable', __('Could not access filesystem.'));
if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() )
return new WP_Error('fs_error', __('Filesystem error.'), $wp_filesystem->errors);
//Get the base plugin folder
$themes_dir = $wp_filesystem->wp_themes_dir();
if ( empty($themes_dir) )
return new WP_Error('fs_no_themes_dir', __('Unable to locate WordPress theme directory.'));
$themes_dir = trailingslashit( $themes_dir );
$theme_dir = trailingslashit($themes_dir . $stylesheet);
$deleted = $wp_filesystem->delete($theme_dir, true);
if ( ! $deleted )
return new WP_Error('could_not_remove_theme', sprintf(__('Could not fully remove the theme %s.'), $stylesheet) );
// Force refresh of theme update information
delete_site_transient('update_themes');
return true;
}
/**
* Get the Page Templates available in this theme
*
* @since 1.5.0
*
* @return array Key is the template name, value is the filename of the template
*/
function get_page_templates() {
return array_flip( wp_get_theme()->get_page_templates() );
}
/**
* Tidies a filename for url display by the theme editor.
*
* @since 2.9.0
* @access private
*
* @param string $fullpath Full path to the theme file
* @param string $containingfolder Path of the theme parent folder
* @return string
*/
function _get_template_edit_filename($fullpath, $containingfolder) {
return str_replace(dirname(dirname( $containingfolder )) , '', $fullpath);
}
/**
* Check if there is an update for a theme available.
*
* Will display link, if there is an update available.
*
* @since 2.7.0
*
* @param object $theme Theme data object.
* @return bool False if no valid info was passed.
*/
function theme_update_available( $theme ) {
static $themes_update;
if ( !current_user_can('update_themes' ) )
return;
if ( !isset($themes_update) )
$themes_update = get_site_transient('update_themes');
if ( ! is_a( $theme, 'WP_Theme' ) )
return;
$stylesheet = $theme->get_stylesheet();
if ( isset($themes_update->response[ $stylesheet ]) ) {
$update = $themes_update->response[ $stylesheet ];
$theme_name = $theme->display('Name');
$details_url = add_query_arg(array('TB_iframe' => 'true', 'width' => 1024, 'height' => 800), $update['url']); //Theme browser inside WP? replace this, Also, theme preview JS will override this on the available list.
$update_url = wp_nonce_url('update.php?action=upgrade-theme&theme=' . urlencode($stylesheet), 'upgrade-theme_' . $stylesheet);
$update_onclick = 'onclick="if ( confirm(\'' . esc_js( __("Updating this theme will lose any customizations you have made. 'Cancel' to stop, 'OK' to update.") ) . '\') ) {return true;}return false;"';
if ( !is_multisite() ) {
if ( ! current_user_can('update_themes') )
printf( '<p><strong>' . __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%1$s">View version %3$s details</a>.') . '</strong></p>', $theme_name, $details_url, $update['new_version']);
else if ( empty($update['package']) )
printf( '<p><strong>' . __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%1$s">View version %3$s details</a>. <em>Automatic update is unavailable for this theme.</em>') . '</strong></p>', $theme_name, $details_url, $update['new_version']);
else
printf( '<p><strong>' . __('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%1$s">View version %3$s details</a> or <a href="%4$s" %5$s>update now</a>.') . '</strong></p>', $theme_name, $details_url, $update['new_version'], $update_url, $update_onclick );
}
}
}
/**
* Retrieve list of WordPress theme features (aka theme tags)
*
* @since 3.1.0
*
* @param bool $api Optional. Whether try to fetch tags from the WP.org API. Defaults to true.
* @return array Array of features keyed by category with translations keyed by slug.
*/
function get_theme_feature_list( $api = true ) {
// Hard-coded list is used if api not accessible.
$features = array(
__('Colors') => array(
'black' => __( 'Black' ),
'blue' => __( 'Blue' ),
'brown' => __( 'Brown' ),
'gray' => __( 'Gray' ),
'green' => __( 'Green' ),
'orange' => __( 'Orange' ),
'pink' => __( 'Pink' ),
'purple' => __( 'Purple' ),
'red' => __( 'Red' ),
'silver' => __( 'Silver' ),
'tan' => __( 'Tan' ),
'white' => __( 'White' ),
'yellow' => __( 'Yellow' ),
'dark' => __( 'Dark' ),
'light' => __( 'Light' ),
),
__('Columns') => array(
'one-column' => __( 'One Column' ),
'two-columns' => __( 'Two Columns' ),
'three-columns' => __( 'Three Columns' ),
'four-columns' => __( 'Four Columns' ),
'left-sidebar' => __( 'Left Sidebar' ),
'right-sidebar' => __( 'Right Sidebar' ),
),
__('Width') => array(
'fixed-width' => __( 'Fixed Width' ),
'flexible-width' => __( 'Flexible Width' ),
),
__( 'Features' ) => array(
'blavatar' => __( 'Blavatar' ),
'buddypress' => __( 'BuddyPress' ),
'custom-background' => __( 'Custom Background' ),
'custom-colors' => __( 'Custom Colors' ),
'custom-header' => __( 'Custom Header' ),
'custom-menu' => __( 'Custom Menu' ),
'editor-style' => __( 'Editor Style' ),
'featured-image-header' => __( 'Featured Image Header' ),
'featured-images' => __( 'Featured Images' ),
'front-page-post-form' => __( 'Front Page Posting' ),
'full-width-template' => __( 'Full Width Template' ),
'microformats' => __( 'Microformats' ),
'post-formats' => __( 'Post Formats' ),
'rtl-language-support' => __( 'RTL Language Support' ),
'sticky-post' => __( 'Sticky Post' ),
'theme-options' => __( 'Theme Options' ),
'threaded-comments' => __( 'Threaded Comments' ),
'translation-ready' => __( 'Translation Ready' ),
),
__( 'Subject' ) => array(
'holiday' => __( 'Holiday' ),
'photoblogging' => __( 'Photoblogging' ),
'seasonal' => __( 'Seasonal' ),
)
);
if ( ! $api || ! current_user_can( 'install_themes' ) )
return $features;
if ( !$feature_list = get_site_transient( 'wporg_theme_feature_list' ) )
set_site_transient( 'wporg_theme_feature_list', array( ), 10800);
if ( !$feature_list ) {
$feature_list = themes_api( 'feature_list', array( ) );
if ( is_wp_error( $feature_list ) )
return $features;
}
if ( !$feature_list )
return $features;
set_site_transient( 'wporg_theme_feature_list', $feature_list, 10800 );
$category_translations = array( 'Colors' => __('Colors'), 'Columns' => __('Columns'), 'Width' => __('Width'),
'Features' => __('Features'), 'Subject' => __('Subject') );
// Loop over the wporg canonical list and apply translations
$wporg_features = array();
foreach ( (array) $feature_list as $feature_category => $feature_items ) {
if ( isset($category_translations[$feature_category]) )
$feature_category = $category_translations[$feature_category];
$wporg_features[$feature_category] = array();
foreach ( $feature_items as $feature ) {
if ( isset($features[$feature_category][$feature]) )
$wporg_features[$feature_category][$feature] = $features[$feature_category][$feature];
else
$wporg_features[$feature_category][$feature] = $feature;
}
}
return $wporg_features;
}
/**
* Retrieve theme installer pages from WordPress Themes API.
*
* It is possible for a theme to override the Themes API result with three
* filters. Assume this is for themes, which can extend on the Theme Info to
* offer more choices. This is very powerful and must be used with care, when
* overridding the filters.
*
* The first filter, 'themes_api_args', is for the args and gives the action as
* the second parameter. The hook for 'themes_api_args' must ensure that an
* object is returned.
*
* The second filter, 'themes_api', is the result that would be returned.
*
* @since 2.8.0
*
* @param string $action
* @param array|object $args Optional. Arguments to serialize for the Theme Info API.
* @return mixed
*/
function themes_api($action, $args = null) {
if ( is_array($args) )
$args = (object)$args;
if ( !isset($args->per_page) )
$args->per_page = 24;
$args = apply_filters('themes_api_args', $args, $action); //NOTE: Ensure that an object is returned via this filter.
$res = apply_filters('themes_api', false, $action, $args); //NOTE: Allows a theme to completely override the builtin WordPress.org API.
if ( ! $res ) {
$request = wp_remote_post('http://api.wordpress.org/themes/info/1.0/', array( 'body' => array('action' => $action, 'request' => serialize($args))) );
if ( is_wp_error($request) ) {
$res = new WP_Error('themes_api_failed', __( '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="http://wordpress.org/support/">support forums</a>.' ), $request->get_error_message() );
} else {
$res = maybe_unserialize( wp_remote_retrieve_body( $request ) );
if ( ! is_object( $res ) && ! is_array( $res ) )
$res = new WP_Error('themes_api_failed', __( '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="http://wordpress.org/support/">support forums</a>.' ), wp_remote_retrieve_body( $request ) );
}
}
return apply_filters('themes_api_result', $res, $action, $args);
}
| 01happy-blog | trunk/myblog/wp-admin/includes/theme.php | PHP | oos | 10,912 |
<?php
/**
* Plugins List Table class.
*
* @package WordPress
* @subpackage List_Table
* @since 3.1.0
* @access private
*/
class WP_Plugins_List_Table extends WP_List_Table {
function __construct() {
global $status, $page;
$status = 'all';
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', stripslashes($_REQUEST['s']) );
$page = $this->get_pagenum();
parent::__construct( array(
'plural' => 'plugins',
) );
}
function get_table_classes() {
return array( 'widefat', $this->_args['plural'] );
}
function ajax_user_can() {
if ( is_multisite() ) {
$menu_perms = get_site_option( 'menu_items', array() );
if ( empty( $menu_perms['plugins'] ) && ! is_super_admin() )
return false;
}
return current_user_can('activate_plugins');
}
function prepare_items() {
global $status, $plugins, $totals, $page, $orderby, $order, $s;
wp_reset_vars( array( 'orderby', 'order', 's' ) );
$plugins = array(
'all' => apply_filters( 'all_plugins', get_plugins() ),
'search' => array(),
'active' => array(),
'inactive' => array(),
'recently_activated' => array(),
'upgrade' => array(),
'mustuse' => array(),
'dropins' => array()
);
$screen = get_current_screen();
if ( ! is_multisite() || ( $screen->is_network && current_user_can('manage_network_plugins') ) ) {
if ( apply_filters( 'show_advanced_plugins', true, 'mustuse' ) )
$plugins['mustuse'] = get_mu_plugins();
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 ];
}
}
}
}
set_transient( 'plugin_slugs', array_keys( $plugins['all'] ), 86400 );
if ( ! $screen->is_network ) {
$recently_activated = get_option( 'recently_activated', array() );
$one_week = 7*24*60*60;
foreach ( $recently_activated as $key => $time )
if ( $time + $one_week < time() )
unset( $recently_activated[$key] );
update_option( 'recently_activated', $recently_activated );
}
foreach ( (array) $plugins['all'] as $plugin_file => $plugin_data ) {
// Filter into individual sections
if ( ! $screen->is_network && is_plugin_active_for_network( $plugin_file ) ) {
unset( $plugins['all'][ $plugin_file ] );
} elseif ( ( ! $screen->is_network && is_plugin_active( $plugin_file ) )
|| ( $screen->is_network && is_plugin_active_for_network( $plugin_file ) ) ) {
$plugins['active'][ $plugin_file ] = $plugin_data;
} else {
if ( !$screen->is_network && isset( $recently_activated[ $plugin_file ] ) ) // Was the plugin recently activated?
$plugins['recently_activated'][ $plugin_file ] = $plugin_data;
$plugins['inactive'][ $plugin_file ] = $plugin_data;
}
}
if ( $s ) {
$status = 'search';
$plugins['search'] = array_filter( $plugins['all'], array( &$this, '_search_callback' ) );
}
$totals = array();
foreach ( $plugins as $type => $list )
$totals[ $type ] = count( $list );
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 );
}
$total_this_page = $totals[ $status ];
if ( $orderby ) {
$orderby = ucfirst( $orderby );
$order = strtoupper( $order );
uasort( $this->items, array( &$this, '_order_callback' ) );
}
$plugins_per_page = $this->get_items_per_page( str_replace( '-', '_', $screen->id . '_per_page' ), 999 );
$start = ( $page - 1 ) * $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,
) );
}
function _search_callback( $plugin ) {
static $term;
if ( is_null( $term ) )
$term = stripslashes( $_REQUEST['s'] );
foreach ( $plugin as $value )
if ( stripos( $value, $term ) !== false )
return true;
return false;
}
function _order_callback( $plugin_a, $plugin_b ) {
global $orderby, $order;
$a = $plugin_a[$orderby];
$b = $plugin_b[$orderby];
if ( $a == $b )
return 0;
if ( 'DESC' == $order )
return ( $a < $b ) ? 1 : -1;
else
return ( $a < $b ) ? -1 : 1;
}
function no_items() {
global $plugins;
if ( !empty( $plugins['all'] ) )
_e( 'No plugins found.' );
else
_e( 'You do not appear to have any plugins available at this time.' );
}
function get_columns() {
global $status;
return array(
'cb' => !in_array( $status, array( 'mustuse', 'dropins' ) ) ? '<input type="checkbox" />' : '',
'name' => __( 'Plugin' ),
'description' => __( 'Description' ),
);
}
function get_sortable_columns() {
return array();
}
function get_views() {
global $totals, $status;
$status_links = array();
foreach ( $totals as $type => $count ) {
if ( !$count )
continue;
switch ( $type ) {
case 'all':
$text = _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $count, 'plugins' );
break;
case 'active':
$text = _n( 'Active <span class="count">(%s)</span>', 'Active <span class="count">(%s)</span>', $count );
break;
case 'recently_activated':
$text = _n( 'Recently Active <span class="count">(%s)</span>', 'Recently Active <span class="count">(%s)</span>', $count );
break;
case 'inactive':
$text = _n( 'Inactive <span class="count">(%s)</span>', 'Inactive <span class="count">(%s)</span>', $count );
break;
case 'mustuse':
$text = _n( 'Must-Use <span class="count">(%s)</span>', 'Must-Use <span class="count">(%s)</span>', $count );
break;
case 'dropins':
$text = _n( 'Drop-ins <span class="count">(%s)</span>', 'Drop-ins <span class="count">(%s)</span>', $count );
break;
case 'upgrade':
$text = _n( 'Update Available <span class="count">(%s)</span>', 'Update Available <span class="count">(%s)</span>', $count );
break;
}
if ( 'search' != $type ) {
$status_links[$type] = sprintf( "<a href='%s' %s>%s</a>",
add_query_arg('plugin_status', $type, 'plugins.php'),
( $type == $status ) ? ' class="current"' : '',
sprintf( $text, number_format_i18n( $count ) )
);
}
}
return $status_links;
}
function get_bulk_actions() {
global $status;
$actions = array();
$screen = get_current_screen();
if ( 'active' != $status )
$actions['activate-selected'] = $screen->is_network ? __( 'Network Activate' ) : __( 'Activate' );
if ( 'inactive' != $status && 'recent' != $status )
$actions['deactivate-selected'] = $screen->is_network ? __( 'Network Deactivate' ) : __( 'Deactivate' );
if ( !is_multisite() || $screen->is_network ) {
if ( current_user_can( 'update_plugins' ) )
$actions['update-selected'] = __( 'Update' );
if ( current_user_can( 'delete_plugins' ) && ( 'active' != $status ) )
$actions['delete-selected'] = __( 'Delete' );
}
return $actions;
}
function bulk_actions( $which ) {
global $status;
if ( in_array( $status, array( 'mustuse', 'dropins' ) ) )
return;
parent::bulk_actions( $which );
}
function extra_tablenav( $which ) {
global $status;
if ( ! in_array($status, array('recently_activated', 'mustuse', 'dropins') ) )
return;
echo '<div class="alignleft actions">';
$screen = get_current_screen();
if ( ! $screen->is_network && 'recently_activated' == $status )
submit_button( __( 'Clear List' ), 'secondary', 'clear-recent-list', false );
elseif ( 'top' == $which && 'mustuse' == $status )
echo '<p>' . sprintf( __( 'Files in the <code>%s</code> directory are executed automatically.' ), str_replace( ABSPATH, '/', WPMU_PLUGIN_DIR ) ) . '</p>';
elseif ( 'top' == $which && 'dropins' == $status )
echo '<p>' . sprintf( __( 'Drop-ins are advanced plugins in the <code>%s</code> directory that replace WordPress functionality when present.' ), str_replace( ABSPATH, '', WP_CONTENT_DIR ) ) . '</p>';
echo '</div>';
}
function current_action() {
if ( isset($_POST['clear-recent-list']) )
return 'clear-recent-list';
return parent::current_action();
}
function display_rows() {
global $status;
$screen = get_current_screen();
if ( is_multisite() && !$screen->is_network && in_array( $status, array( 'mustuse', 'dropins' ) ) )
return;
foreach ( $this->items as $plugin_file => $plugin_data )
$this->single_row( $plugin_file, $plugin_data );
}
function single_row( $plugin_file, $plugin_data ) {
global $status, $page, $s, $totals;
$context = $status;
$screen = get_current_screen();
// preorder
$actions = array(
'deactivate' => '',
'activate' => '',
'edit' => '',
'delete' => '',
);
if ( 'mustuse' == $context ) {
$is_active = true;
} elseif ( 'dropins' == $context ) {
$dropins = _get_dropins();
$plugin_name = $plugin_file;
if ( $plugin_file != $plugin_data['Name'] )
$plugin_name .= '<br/>' . $plugin_data['Name'];
if ( true === ( $dropins[ $plugin_file ][1] ) ) { // Doesn't require a constant
$is_active = true;
$description = '<p><strong>' . $dropins[ $plugin_file ][0] . '</strong></p>';
} elseif ( constant( $dropins[ $plugin_file ][1] ) ) { // Constant is true
$is_active = true;
$description = '<p><strong>' . $dropins[ $plugin_file ][0] . '</strong></p>';
} else {
$is_active = false;
$description = '<p><strong>' . $dropins[ $plugin_file ][0] . ' <span class="attention">' . __('Inactive:') . '</span></strong> ' . sprintf( __( 'Requires <code>%s</code> in <code>wp-config.php</code>.' ), "define('" . $dropins[ $plugin_file ][1] . "', true);" ) . '</p>';
}
if ( $plugin_data['Description'] )
$description .= '<p>' . $plugin_data['Description'] . '</p>';
} else {
if ( $screen->is_network )
$is_active = is_plugin_active_for_network( $plugin_file );
else
$is_active = is_plugin_active( $plugin_file );
if ( $screen->is_network ) {
if ( $is_active ) {
if ( current_user_can( 'manage_network_plugins' ) )
$actions['deactivate'] = '<a href="' . wp_nonce_url('plugins.php?action=deactivate&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'deactivate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Deactivate this plugin') . '">' . __('Network Deactivate') . '</a>';
} else {
if ( current_user_can( 'manage_network_plugins' ) )
$actions['activate'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin for all sites in this network') . '" class="edit">' . __('Network Activate') . '</a>';
if ( current_user_can( 'delete_plugins' ) && ! is_plugin_active( $plugin_file ) )
$actions['delete'] = '<a href="' . wp_nonce_url('plugins.php?action=delete-selected&checked[]=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'bulk-plugins') . '" title="' . esc_attr__('Delete this plugin') . '" class="delete">' . __('Delete') . '</a>';
}
} else {
if ( $is_active ) {
$actions['deactivate'] = '<a href="' . wp_nonce_url('plugins.php?action=deactivate&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'deactivate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Deactivate this plugin') . '">' . __('Deactivate') . '</a>';
} else {
$actions['activate'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin') . '" class="edit">' . __('Activate') . '</a>';
if ( ! is_multisite() && current_user_can('delete_plugins') )
$actions['delete'] = '<a href="' . wp_nonce_url('plugins.php?action=delete-selected&checked[]=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'bulk-plugins') . '" title="' . esc_attr__('Delete this plugin') . '" class="delete">' . __('Delete') . '</a>';
} // end if $is_active
} // end if $screen->is_network
if ( ( ! is_multisite() || $screen->is_network ) && current_user_can('edit_plugins') && is_writable(WP_PLUGIN_DIR . '/' . $plugin_file) )
$actions['edit'] = '<a href="plugin-editor.php?file=' . $plugin_file . '" title="' . esc_attr__('Open this file in the Plugin Editor') . '" class="edit">' . __('Edit') . '</a>';
} // end if $context
$prefix = $screen->is_network ? 'network_admin_' : '';
$actions = apply_filters( $prefix . 'plugin_action_links', array_filter( $actions ), $plugin_file, $plugin_data, $context );
$actions = apply_filters( $prefix . "plugin_action_links_$plugin_file", $actions, $plugin_file, $plugin_data, $context );
$class = $is_active ? 'active' : 'inactive';
$checkbox_id = "checkbox_" . md5($plugin_data['Name']);
$checkbox = in_array( $status, array( 'mustuse', 'dropins' ) ) ? '' : "<input type='checkbox' name='checked[]' value='" . esc_attr( $plugin_file ) . "' id='" . $checkbox_id . "' /><label class='screen-reader-text' for='" . $checkbox_id . "' >" . __('Select') . " " . $plugin_data['Name'] . "</label>";
if ( 'dropins' != $context ) {
$description = '<p>' . ( $plugin_data['Description'] ? $plugin_data['Description'] : ' ' ) . '</p>';
$plugin_name = $plugin_data['Name'];
}
$id = sanitize_title( $plugin_name );
if ( ! empty( $totals['upgrade'] ) && ! empty( $plugin_data['update'] ) )
$class .= ' update';
echo "<tr id='$id' class='$class'>";
list( $columns, $hidden ) = $this->get_column_info();
foreach ( $columns as $column_name => $column_display_name ) {
$style = '';
if ( in_array( $column_name, $hidden ) )
$style = ' style="display:none;"';
switch ( $column_name ) {
case 'cb':
echo "<th scope='row' class='check-column'>$checkbox</th>";
break;
case 'name':
echo "<td class='plugin-title'$style><strong>$plugin_name</strong>";
echo $this->row_actions( $actions, true );
echo "</td>";
break;
case 'description':
echo "<td class='column-description desc'$style>
<div class='plugin-description'>$description</div>
<div class='$class second plugin-version-author-uri'>";
$plugin_meta = array();
if ( !empty( $plugin_data['Version'] ) )
$plugin_meta[] = sprintf( __( 'Version %s' ), $plugin_data['Version'] );
if ( !empty( $plugin_data['Author'] ) ) {
$author = $plugin_data['Author'];
if ( !empty( $plugin_data['AuthorURI'] ) )
$author = '<a href="' . $plugin_data['AuthorURI'] . '" title="' . esc_attr__( 'Visit author homepage' ) . '">' . $plugin_data['Author'] . '</a>';
$plugin_meta[] = sprintf( __( 'By %s' ), $author );
}
if ( ! empty( $plugin_data['PluginURI'] ) )
$plugin_meta[] = '<a href="' . $plugin_data['PluginURI'] . '" title="' . esc_attr__( 'Visit plugin site' ) . '">' . __( 'Visit plugin site' ) . '</a>';
$plugin_meta = apply_filters( 'plugin_row_meta', $plugin_meta, $plugin_file, $plugin_data, $status );
echo implode( ' | ', $plugin_meta );
echo "</div></td>";
break;
default:
echo "<td class='$column_name column-$column_name'$style>";
do_action( 'manage_plugins_custom_column', $column_name, $plugin_file, $plugin_data );
echo "</td>";
}
}
echo "</tr>";
do_action( 'after_plugin_row', $plugin_file, $plugin_data, $status );
do_action( "after_plugin_row_$plugin_file", $plugin_file, $plugin_data, $status );
}
}
| 01happy-blog | trunk/myblog/wp-admin/includes/class-wp-plugins-list-table.php | PHP | oos | 16,587 |
<?php
/**
* Build Administration Menu.
*
* @package WordPress
* @subpackage Administration
*/
if ( is_network_admin() )
do_action('_network_admin_menu');
elseif ( is_user_admin() )
do_action('_user_admin_menu');
else
do_action('_admin_menu');
// Create list of page plugin hook names.
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);
// Set the hook name to be the 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($menu_page[2], '.php');
}
$hook_name = sanitize_title($hook_name);
if ( isset($compat[$hook_name]) )
$hook_name = $compat[$hook_name];
elseif ( !$hook_name )
continue;
$admin_page_hooks[$menu_page[2]] = $hook_name;
}
unset($menu_page, $compat);
$_wp_submenu_nopriv = array();
$_wp_menu_nopriv = array();
// Loop over submenus and remove pages for which the user does not have privs.
foreach ( array( 'submenu' ) as $sub_loop ) {
foreach ($$sub_loop as $parent => $sub) {
foreach ($sub as $index => $data) {
if ( ! current_user_can($data[1]) ) {
unset(${$sub_loop}[$parent][$index]);
$_wp_submenu_nopriv[$parent][$data[2]] = true;
}
}
unset($index, $data);
if ( empty(${$sub_loop}[$parent]) )
unset(${$sub_loop}[$parent]);
}
unset($sub, $parent);
}
unset($sub_loop);
// Loop over the top-level menu.
// Menus for which the original parent is not accessible due to lack of privs will have the next
// submenu in line be assigned as the new menu parent.
foreach ( $menu as $id => $data ) {
if ( empty($submenu[$data[2]]) )
continue;
$subs = $submenu[$data[2]];
$first_sub = array_shift($subs);
$old_parent = $data[2];
$new_parent = $first_sub[2];
// If the first submenu is not the same as the assigned parent,
// 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;
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);
if ( isset($_wp_submenu_nopriv[$old_parent]) )
$_wp_submenu_nopriv[$new_parent] = $_wp_submenu_nopriv[$old_parent];
}
}
unset($id, $data, $subs, $first_sub, $old_parent, $new_parent);
if ( is_network_admin() )
do_action('network_admin_menu', '');
elseif ( is_user_admin() )
do_action('user_admin_menu', '');
else
do_action('admin_menu', '');
// Remove menus that have no accessible submenus and require privs 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 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]];
$first_sub = array_shift($subs);
if ( $data[2] == $first_sub[2] )
unset( $submenu[$data[2]] );
}
// If submenu is empty...
if ( empty($submenu[$data[2]]) ) {
// And user doesn't have privs, remove menu.
if ( isset( $_wp_menu_nopriv[$data[2]] ) ) {
unset($menu[$id]);
}
}
}
unset($id, $data, $subs, $first_sub);
// Remove any duplicated separators
$separator_found = false;
foreach ( $menu as $id => $data ) {
if ( 0 == strcmp('wp-menu-separator', $data[4] ) ) {
if (false == $separator_found) {
$separator_found = true;
} else {
unset($menu[$id]);
$separator_found = false;
}
} else {
$separator_found = false;
}
}
unset($id, $data);
function add_cssclass($add, $class) {
$class = empty($class) ? $add : $class .= ' ' . $add;
return $class;
}
function add_menu_classes($menu) {
$first = $lastorder = false;
$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;
continue;
}
if ( 0 === strpos($top[2], 'separator') ) { // 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;
}
if ( $mc == $i ) { // last item
$c = $menu[$order][4];
$menu[$order][4] = add_cssclass('menu-top-last', $c);
}
$lastorder = $order;
}
return apply_filters( 'add_menu_classes', $menu );
}
uksort($menu, "strnatcasecmp"); // make it all pretty
if ( apply_filters('custom_menu_order', false) ) {
$menu_order = array();
foreach ( $menu as $menu_item ) {
$menu_order[] = $menu_item[2];
}
unset($menu_item);
$default_menu_order = $menu_order;
$menu_order = apply_filters('menu_order', $menu_order);
$menu_order = array_flip($menu_order);
$default_menu_order = array_flip($default_menu_order);
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]) ) {
return -1;
} 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] )
return 0;
return ($menu_order[$a] < $menu_order[$b]) ? -1 : 1;
} else {
return ($default_menu_order[$a] <= $default_menu_order[$b]) ? -1 : 1;
}
}
usort($menu, 'sort_menu');
unset($menu_order, $default_menu_order);
}
// 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 ] )
unset( $menu[ $last_menu_key ] );
unset( $last_menu_key );
if ( !user_can_access_admin_page() ) {
do_action('admin_page_access_denied');
wp_die( __('You do not have sufficient permissions to access this page.') );
}
$menu = add_menu_classes($menu);
| 01happy-blog | trunk/myblog/wp-admin/includes/menu.php | PHP | oos | 6,307 |
<?php
/**
* WordPress Administration Importer API.
*
* @package WordPress
* @subpackage Administration
*/
/**
* Retrieve list of importers.
*
* @since 2.0.0
*
* @return array
*/
function get_importers() {
global $wp_importers;
if ( is_array($wp_importers) )
uasort($wp_importers, create_function('$a, $b', 'return strcmp($a[0], $b[0]);'));
return $wp_importers;
}
/**
* Register importer for WordPress.
*
* @since 2.0.0
*
* @param string $id Importer tag. Used to uniquely identify importer.
* @param string $name Importer name and title.
* @param string $description Importer description.
* @param callback $callback Callback to run.
* @return WP_Error Returns WP_Error when $callback is WP_Error.
*/
function register_importer( $id, $name, $description, $callback ) {
global $wp_importers;
if ( is_wp_error( $callback ) )
return $callback;
$wp_importers[$id] = array ( $name, $description, $callback );
}
/**
* Cleanup importer.
*
* Removes attachment based on ID.
*
* @since 2.0.0
*
* @param string $id Importer ID.
*/
function wp_import_cleanup( $id ) {
wp_delete_attachment( $id );
}
/**
* Handle importer uploading and add attachment.
*
* @since 2.0.0
*
* @return array Uploaded file's details on success, error message on failure
*/
function wp_import_handle_upload() {
if ( !isset($_FILES['import']) ) {
$file['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.' );
return $file;
}
$overrides = array( 'test_form' => false, 'test_type' => false );
$_FILES['import']['name'] .= '.txt';
$file = wp_handle_upload( $_FILES['import'], $overrides );
if ( isset( $file['error'] ) )
return $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_mime_type' => $type,
'guid' => $url,
'context' => 'import',
'post_status' => 'private'
);
// Save the data
$id = wp_insert_attachment( $object, $file );
// schedule a cleanup for one day from now in case of failed import or missing wp_import_cleanup() call
wp_schedule_single_event( time() + 86400, 'importer_scheduled_cleanup', array( $id ) );
return array( 'file' => $file, 'id' => $id );
}
| 01happy-blog | trunk/myblog/wp-admin/includes/import.php | PHP | oos | 2,460 |
<?php
/**
* Comments and Post Comments List Table classes.
*
* @package WordPress
* @subpackage List_Table
* @since 3.1.0
*/
/**
* Comments List Table class.
*
* @package WordPress
* @subpackage List_Table
* @since 3.1.0
* @access private
*/
class WP_Comments_List_Table extends WP_List_Table {
var $checkbox = true;
var $pending_count = array();
function __construct() {
global $post_id;
$post_id = isset( $_REQUEST['p'] ) ? absint( $_REQUEST['p'] ) : 0;
if ( get_option('show_avatars') )
add_filter( 'comment_author', 'floated_admin_avatar' );
parent::__construct( array(
'plural' => 'comments',
'singular' => 'comment',
'ajax' => true,
) );
}
function ajax_user_can() {
return current_user_can('edit_posts');
}
function prepare_items() {
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' ) ) )
$comment_status = 'all';
$comment_type = !empty( $_REQUEST['comment_type'] ) ? $_REQUEST['comment_type'] : '';
$search = ( isset( $_REQUEST['s'] ) ) ? $_REQUEST['s'] : '';
$user_id = ( isset( $_REQUEST['user_id'] ) ) ? $_REQUEST['user_id'] : '';
$orderby = ( isset( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : '';
$order = ( isset( $_REQUEST['order'] ) ) ? $_REQUEST['order'] : '';
$comments_per_page = $this->get_per_page( $comment_status );
$doing_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
if ( isset( $_REQUEST['number'] ) ) {
$number = (int) $_REQUEST['number'];
}
else {
$number = $comments_per_page + min( 8, $comments_per_page ); // Grab a few extra
}
$page = $this->get_pagenum();
if ( isset( $_REQUEST['start'] ) ) {
$start = $_REQUEST['start'];
} else {
$start = ( $page - 1 ) * $comments_per_page;
}
if ( $doing_ajax && isset( $_REQUEST['offset'] ) ) {
$start += $_REQUEST['offset'];
}
$status_map = array(
'moderated' => 'hold',
'approved' => 'approve'
);
$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,
);
$_comments = get_comments( $args );
update_comment_cache( $_comments );
$this->items = array_slice( $_comments, 0, $comments_per_page );
$this->extra_items = array_slice( $_comments, $comments_per_page );
$total_comments = get_comments( array_merge( $args, array('count' => true, 'offset' => 0, 'number' => 0) ) );
$_comment_post_ids = array();
foreach ( $_comments as $_c ) {
$_comment_post_ids[] = $_c->comment_post_ID;
}
$_comment_post_ids = array_unique( $_comment_post_ids );
$this->pending_count = get_pending_comments_num( $_comment_post_ids );
$this->set_pagination_args( array(
'total_items' => $total_comments,
'per_page' => $comments_per_page,
) );
}
function get_per_page( $comment_status = 'all' ) {
$comments_per_page = $this->get_items_per_page( 'edit_comments_per_page' );
$comments_per_page = apply_filters( 'comments_per_page', $comments_per_page, $comment_status );
return $comments_per_page;
}
function no_items() {
global $comment_status;
if ( 'moderated' == $comment_status )
_e( 'No comments awaiting moderation.' );
else
_e( 'No comments found.' );
}
function get_views() {
global $post_id, $comment_status, $comment_type;
$status_links = array();
$num_comments = ( $post_id ) ? wp_count_comments( $post_id ) : wp_count_comments();
//, number_format_i18n($num_comments->moderated) ), "<span class='comment-count'>" . number_format_i18n($num_comments->moderated) . "</span>"),
//, number_format_i18n($num_comments->spam) ), "<span class='spam-comment-count'>" . number_format_i18n($num_comments->spam) . "</span>")
$stati = array(
'all' => _nx_noop('All', 'All', 'comments'), // singular not used
'moderated' => _n_noop('Pending <span class="count">(<span class="pending-count">%s</span>)</span>', 'Pending <span class="count">(<span class="pending-count">%s</span>)</span>'),
'approved' => _n_noop('Approved', 'Approved'), // singular not used
'spam' => _n_noop('Spam <span class="count">(<span class="spam-count">%s</span>)</span>', 'Spam <span class="count">(<span class="spam-count">%s</span>)</span>'),
'trash' => _n_noop('Trash <span class="count">(<span class="trash-count">%s</span>)</span>', 'Trash <span class="count">(<span class="trash-count">%s</span>)</span>')
);
if ( !EMPTY_TRASH_DAYS )
unset($stati['trash']);
$link = 'edit-comments.php';
if ( !empty($comment_type) && 'all' != $comment_type )
$link = add_query_arg( 'comment_type', $comment_type, $link );
foreach ( $stati as $status => $label ) {
$class = ( $status == $comment_status ) ? ' class="current"' : '';
if ( !isset( $num_comments->$status ) )
$num_comments->$status = 10;
$link = add_query_arg( 'comment_status', $status, $link );
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'] ) )
$link = add_query_arg( 's', esc_attr( stripslashes( $_REQUEST['s'] ) ), $link );
*/
$status_links[$status] = "<a href='$link'$class>" . sprintf(
translate_nooped_plural( $label, $num_comments->$status ),
number_format_i18n( $num_comments->$status )
) . '</a>';
}
$status_links = apply_filters( 'comment_status_links', $status_links );
return $status_links;
}
function get_bulk_actions() {
global $comment_status;
$actions = array();
if ( in_array( $comment_status, array( 'all', 'approved' ) ) )
$actions['unapprove'] = __( 'Unapprove' );
if ( in_array( $comment_status, array( 'all', 'moderated' ) ) )
$actions['approve'] = __( 'Approve' );
if ( in_array( $comment_status, array( 'all', 'moderated', 'approved' ) ) )
$actions['spam'] = _x( 'Mark as Spam', 'comment' );
if ( 'trash' == $comment_status )
$actions['untrash'] = __( 'Restore' );
elseif ( 'spam' == $comment_status )
$actions['unspam'] = _x( 'Not Spam', 'comment' );
if ( in_array( $comment_status, array( 'trash', 'spam' ) ) || !EMPTY_TRASH_DAYS )
$actions['delete'] = __( 'Delete Permanently' );
else
$actions['trash'] = __( 'Move to Trash' );
return $actions;
}
function extra_tablenav( $which ) {
global $comment_status, $comment_type;
?>
<div class="alignleft actions">
<?php
if ( 'top' == $which ) {
?>
<select name="comment_type">
<option value=""><?php _e( 'Show all comment types' ); ?></option>
<?php
$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>
<?php
submit_button( __( 'Filter' ), 'secondary', false, false, array( 'id' => 'post-query-submit' ) );
}
if ( ( 'spam' == $comment_status || 'trash' == $comment_status ) && current_user_can( 'moderate_comments' ) ) {
wp_nonce_field( 'bulk-destroy', '_destroy_nonce' );
$title = ( 'spam' == $comment_status ) ? esc_attr__( 'Empty Spam' ) : esc_attr__( 'Empty Trash' );
submit_button( $title, 'button-secondary apply', 'delete_all', false );
}
do_action( 'manage_comments_nav', $comment_status );
echo '</div>';
}
function current_action() {
if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) )
return 'delete_all';
return parent::current_action();
}
function get_columns() {
global $post_id;
$columns = array();
if ( $this->checkbox )
$columns['cb'] = '<input type="checkbox" />';
$columns['author'] = __( 'Author' );
$columns['comment'] = _x( 'Comment', 'column name' );
if ( !$post_id )
$columns['response'] = _x( 'In Response To', 'column name' );
return $columns;
}
function get_sortable_columns() {
return array(
'author' => 'comment_author',
'response' => 'comment_post_ID'
);
}
function display() {
extract( $this->_args );
wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' );
$this->display_tablenav( 'top' );
?>
<table class="<?php echo implode( ' ', $this->get_table_classes() ); ?>" cellspacing="0">
<thead>
<tr>
<?php $this->print_column_headers(); ?>
</tr>
</thead>
<tfoot>
<tr>
<?php $this->print_column_headers( false ); ?>
</tr>
</tfoot>
<tbody id="the-comment-list" class="list:comment">
<?php $this->display_rows_or_placeholder(); ?>
</tbody>
<tbody id="the-extra-comment-list" class="list:comment" style="display: none;">
<?php $this->items = $this->extra_items; $this->display_rows(); ?>
</tbody>
</table>
<?php
$this->display_tablenav( 'bottom' );
}
function single_row( $a_comment ) {
global $post, $comment;
$comment = $a_comment;
$the_comment_class = join( ' ', get_comment_class( wp_get_comment_status( $comment->comment_ID ) ) );
$post = get_post( $comment->comment_post_ID );
$this->user_can = current_user_can( 'edit_comment', $comment->comment_ID );
echo "<tr id='comment-$comment->comment_ID' class='$the_comment_class'>";
echo $this->single_row_columns( $comment );
echo "</tr>\n";
}
function column_cb( $comment ) {
if ( $this->user_can )
echo "<input type='checkbox' name='delete_comments[]' value='$comment->comment_ID' />";
}
function column_comment( $comment ) {
global $post, $comment_status;
$user_can = $this->user_can;
$comment_url = esc_url( get_comment_link( $comment->comment_ID ) );
$the_comment_status = wp_get_comment_status( $comment->comment_ID );
$ptime = date( 'G', strtotime( $comment->comment_date ) );
if ( ( abs( time() - $ptime ) ) < 86400 )
$ptime = sprintf( __( '%s ago' ), human_time_diff( $ptime ) );
else
$ptime = mysql2date( __( 'Y/m/d \a\t g:i A' ), $comment->comment_date );
if ( $user_can ) {
$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" );
$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" );
}
echo '<div class="submitted-on">';
/* translators: 2: comment date, 3: comment time */
printf( __( 'Submitted on <a href="%1$s">%2$s at %3$s</a>' ), $comment_url,
/* translators: comment date format. See http://php.net/date */ get_comment_date( __( 'Y/m/d' ) ),
/* translators: comment time format. See http://php.net/date */ get_comment_date( get_option( 'time_format' ) ) );
if ( $comment->comment_parent ) {
$parent = get_comment( $comment->comment_parent );
$parent_link = esc_url( get_comment_link( $comment->comment_parent ) );
$name = get_comment_author( $parent->comment_ID );
printf( ' | '.__( 'In reply to <a href="%1$s">%2$s</a>.' ), $parent_link, $name );
}
echo '</div>';
comment_text();
if ( $user_can ) { ?>
<div id="inline-<?php echo $comment->comment_ID; ?>" class="hidden">
<textarea class="comment" rows="1" cols="1"><?php echo esc_textarea( apply_filters( 'comment_edit_pre', $comment->comment_content ) ); ?></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>
<div class="comment_status"><?php echo $comment->comment_approved; ?></div>
</div>
<?php
}
if ( $user_can ) {
// preorder it: Approve | Reply | Quick Edit | Edit | Spam | Trash
$actions = array(
'approve' => '', 'unapprove' => '',
'reply' => '',
'quickedit' => '',
'edit' => '',
'spam' => '', 'unspam' => '',
'trash' => '', 'untrash' => '', 'delete' => ''
);
if ( $comment_status && 'all' != $comment_status ) { // not looking at all comments
if ( 'approved' == $the_comment_status )
$actions['unapprove'] = "<a href='$unapprove_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=unapproved vim-u vim-destructive' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
else if ( 'unapproved' == $the_comment_status )
$actions['approve'] = "<a href='$approve_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=approved vim-a vim-destructive' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
} else {
$actions['approve'] = "<a href='$approve_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved vim-a' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
$actions['unapprove'] = "<a href='$unapprove_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved vim-u' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
}
if ( 'spam' != $the_comment_status && 'trash' != $the_comment_status ) {
$actions['spam'] = "<a href='$spam_url' class='delete:the-comment-list:comment-$comment->comment_ID::spam=1 vim-s vim-destructive' title='" . esc_attr__( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>';
} elseif ( 'spam' == $the_comment_status ) {
$actions['unspam'] = "<a href='$unspam_url' class='delete:the-comment-list:comment-$comment->comment_ID:66cc66:unspam=1 vim-z vim-destructive'>" . _x( 'Not Spam', 'comment' ) . '</a>';
} elseif ( 'trash' == $the_comment_status ) {
$actions['untrash'] = "<a href='$untrash_url' class='delete:the-comment-list:comment-$comment->comment_ID:66cc66:untrash=1 vim-z vim-destructive'>" . __( 'Restore' ) . '</a>';
}
if ( 'spam' == $the_comment_status || 'trash' == $the_comment_status || !EMPTY_TRASH_DAYS ) {
$actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID::delete=1 delete vim-d vim-destructive'>" . __( 'Delete Permanently' ) . '</a>';
} else {
$actions['trash'] = "<a href='$trash_url' class='delete:the-comment-list:comment-$comment->comment_ID::trash=1 delete vim-d vim-destructive' title='" . 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}' title='" . esc_attr__( 'Edit comment' ) . "'>". __( 'Edit' ) . '</a>';
$actions['quickedit'] = '<a onclick="commentReply.open( \''.$comment->comment_ID.'\',\''.$post->ID.'\',\'edit\' );return false;" class="vim-q" title="'.esc_attr__( 'Quick Edit' ).'" href="#">' . __( 'Quick Edit' ) . '</a>';
$actions['reply'] = '<a onclick="commentReply.open( \''.$comment->comment_ID.'\',\''.$post->ID.'\' );return false;" class="vim-r" title="'.esc_attr__( 'Reply to this comment' ).'" href="#">' . __( 'Reply' ) . '</a>';
}
$actions = apply_filters( 'comment_row_actions', array_filter( $actions ), $comment );
$i = 0;
echo '<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 ) && ! defined('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 ) )
$action .= ' approve';
else
$action .= ' unapprove';
}
echo "<span class='$action'>$sep$link</span>";
}
echo '</div>';
}
}
function column_author( $comment ) {
global $comment_status;
$author_url = get_comment_author_url();
if ( 'http://' == $author_url )
$author_url = '';
$author_url_display = preg_replace( '|http://(www\.)?|i', '', $author_url );
if ( strlen( $author_url_display ) > 50 )
$author_url_display = substr( $author_url_display, 0, 49 ) . '...';
echo "<strong>"; comment_author(); echo '</strong><br />';
if ( !empty( $author_url ) )
echo "<a title='$author_url' href='$author_url'>$author_url_display</a><br />";
if ( $this->user_can ) {
if ( !empty( $comment->comment_author_email ) ) {
comment_author_email_link();
echo '<br />';
}
echo '<a href="edit-comments.php?s=';
comment_author_IP();
echo '&mode=detail';
if ( 'spam' == $comment_status )
echo '&comment_status=spam';
echo '">';
comment_author_IP();
echo '</a>';
}
}
function column_date( $comment ) {
return get_comment_date( __( 'Y/m/d \a\t g:ia' ) );
}
function column_response( $comment ) {
global $post;
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];
}
if ( current_user_can( 'edit_post', $post->ID ) ) {
$post_link = "<a href='" . get_edit_post_link( $post->ID ) . "'>";
$post_link .= get_the_title( $post->ID ) . '</a>';
} else {
$post_link = get_the_title( $post->ID );
}
echo '<div class="response-links"><span class="post-com-count-wrapper">';
echo $post_link . '<br />';
$this->comments_bubble( $post->ID, $pending_comments );
echo '</span> ';
$post_type_object = get_post_type_object( $post->post_type );
echo "<a href='" . get_permalink( $post->ID ) . "'>" . $post_type_object->labels->view_item . '</a>';
echo '</div>';
if ( 'attachment' == $post->post_type && ( $thumb = wp_get_attachment_image( $post->ID, array( 80, 60 ), true ) ) )
echo $thumb;
}
function column_default( $comment, $column_name ) {
do_action( 'manage_comments_custom_column', $column_name, $comment->comment_ID );
}
}
/**
* Post Comments List Table class.
*
* @package WordPress
* @subpackage List_Table
* @since 3.1.0
* @access private
*
* @see WP_Comments_Table
*/
class WP_Post_Comments_List_Table extends WP_Comments_List_Table {
function get_column_info() {
$this->_column_headers = array(
array(
'author' => __( 'Author' ),
'comment' => _x( 'Comment', 'column name' ),
),
array(),
array(),
);
return $this->_column_headers;
}
function get_table_classes() {
$classes = parent::get_table_classes();
$classes[] = 'comments-box';
return $classes;
}
function display( $output_empty = false ) {
extract( $this->_args );
wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' );
?>
<table class="<?php echo implode( ' ', $this->get_table_classes() ); ?>" cellspacing="0" style="display:none;">
<tbody id="the-comment-list"<?php if ( $singular ) echo " class='list:$singular'"; ?>>
<?php if ( ! $output_empty ) $this->display_rows_or_placeholder(); ?>
</tbody>
</table>
<?php
}
function get_per_page( $comment_status = false ) {
return 10;
}
}
| 01happy-blog | trunk/myblog/wp-admin/includes/class-wp-comments-list-table.php | PHP | oos | 20,242 |
<?php
/**
* Create HTML list of nav menu input items.
*
* @package WordPress
* @since 3.0.0
* @uses Walker_Nav_Menu
*/
class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
/**
* @see Walker_Nav_Menu::start_lvl()
* @since 3.0.0
*
* @param string $output Passed by reference.
*/
function start_lvl(&$output) {}
/**
* @see Walker_Nav_Menu::end_lvl()
* @since 3.0.0
*
* @param string $output Passed by reference.
*/
function end_lvl(&$output) {
}
/**
* @see Walker::start_el()
* @since 3.0.0
*
* @param string $output Passed by reference. Used to append additional content.
* @param object $item Menu item data object.
* @param int $depth Depth of menu item. Used for padding.
* @param object $args
*/
function start_el(&$output, $item, $depth, $args) {
global $_wp_nav_menu_max_depth;
$_wp_nav_menu_max_depth = $depth > $_wp_nav_menu_max_depth ? $depth : $_wp_nav_menu_max_depth;
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
ob_start();
$item_id = esc_attr( $item->ID );
$removed_args = array(
'action',
'customlink-tab',
'edit-menu-item',
'menu-item',
'page-tab',
'_wpnonce',
);
$original_title = '';
if ( 'taxonomy' == $item->type ) {
$original_title = get_term_field( 'name', $item->object_id, $item->object, 'raw' );
if ( is_wp_error( $original_title ) )
$original_title = false;
} elseif ( 'post_type' == $item->type ) {
$original_object = get_post( $item->object_id );
$original_title = $original_object->post_title;
}
$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'),
);
$title = $item->title;
if ( ! empty( $item->_invalid ) ) {
$classes[] = 'menu-item-invalid';
/* translators: %s: title of menu item which is invalid */
$title = sprintf( __( '%s (Invalid)' ), $item->title );
} 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 = empty( $item->label ) ? $title : $item->label;
?>
<li id="menu-item-<?php echo $item_id; ?>" class="<?php echo implode(' ', $classes ); ?>">
<dl class="menu-item-bar">
<dt class="menu-item-handle">
<span class="item-title"><?php echo esc_html( $title ); ?></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
echo wp_nonce_url(
add_query_arg(
array(
'action' => 'move-up-menu-item',
'menu-item' => $item_id,
),
remove_query_arg($removed_args, admin_url( 'nav-menus.php' ) )
),
'move-menu_item'
);
?>" class="item-move-up"><abbr title="<?php esc_attr_e('Move up'); ?>">↑</abbr></a>
|
<a href="<?php
echo wp_nonce_url(
add_query_arg(
array(
'action' => 'move-down-menu-item',
'menu-item' => $item_id,
),
remove_query_arg($removed_args, admin_url( 'nav-menus.php' ) )
),
'move-menu_item'
);
?>" class="item-move-down"><abbr title="<?php esc_attr_e('Move down'); ?>">↓</abbr></a>
</span>
<a class="item-edit" id="edit-<?php echo $item_id; ?>" title="<?php esc_attr_e('Edit Menu Item'); ?>" 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 ) ) );
?>"><?php _e( 'Edit Menu Item' ); ?></a>
</span>
</dt>
</dl>
<div class="menu-item-settings" id="menu-item-settings-<?php echo $item_id; ?>">
<?php if( 'custom' == $item->type ) : ?>
<p class="field-url description description-wide">
<label for="edit-menu-item-url-<?php echo $item_id; ?>">
<?php _e( 'URL' ); ?><br />
<input type="text" id="edit-menu-item-url-<?php echo $item_id; ?>" class="widefat code edit-menu-item-url" name="menu-item-url[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->url ); ?>" />
</label>
</p>
<?php endif; ?>
<p class="description description-thin">
<label for="edit-menu-item-title-<?php echo $item_id; ?>">
<?php _e( 'Navigation Label' ); ?><br />
<input type="text" id="edit-menu-item-title-<?php echo $item_id; ?>" class="widefat edit-menu-item-title" name="menu-item-title[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->title ); ?>" />
</label>
</p>
<p class="description description-thin">
<label for="edit-menu-item-attr-title-<?php echo $item_id; ?>">
<?php _e( 'Title Attribute' ); ?><br />
<input type="text" id="edit-menu-item-attr-title-<?php echo $item_id; ?>" class="widefat edit-menu-item-attr-title" name="menu-item-attr-title[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->post_excerpt ); ?>" />
</label>
</p>
<p class="field-link-target description">
<label for="edit-menu-item-target-<?php echo $item_id; ?>">
<input type="checkbox" id="edit-menu-item-target-<?php echo $item_id; ?>" value="_blank" name="menu-item-target[<?php echo $item_id; ?>]"<?php checked( $item->target, '_blank' ); ?> />
<?php _e( 'Open link in a new window/tab' ); ?>
</label>
</p>
<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 ) ); ?>" />
</label>
</p>
<p class="field-xfn description description-thin">
<label for="edit-menu-item-xfn-<?php echo $item_id; ?>">
<?php _e( 'Link Relationship (XFN)' ); ?><br />
<input type="text" id="edit-menu-item-xfn-<?php echo $item_id; ?>" class="widefat code edit-menu-item-xfn" name="menu-item-xfn[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->xfn ); ?>" />
</label>
</p>
<p class="field-description description description-wide">
<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>
</label>
</p>
<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>' ); ?>
</p>
<?php endif; ?>
<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,
),
remove_query_arg($removed_args, admin_url( 'nav-menus.php' ) )
),
'delete-menu_item_' . $item_id
); ?>"><?php _e('Remove'); ?></a> <span class="meta-sep"> | </span> <a class="item-cancel submitcancel" id="cancel-<?php echo $item_id; ?>" href="<?php echo esc_url( add_query_arg( array('edit-menu-item' => $item_id, 'cancel' => time()), remove_query_arg( $removed_args, 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; ?>" />
<input class="menu-item-data-object-id" type="hidden" name="menu-item-object-id[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->object_id ); ?>" />
<input class="menu-item-data-object" type="hidden" name="menu-item-object[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->object ); ?>" />
<input class="menu-item-data-parent-id" type="hidden" name="menu-item-parent-id[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->menu_item_parent ); ?>" />
<input class="menu-item-data-position" type="hidden" name="menu-item-position[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->menu_order ); ?>" />
<input class="menu-item-data-type" type="hidden" name="menu-item-type[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->type ); ?>" />
</div><!-- .menu-item-settings-->
<ul class="menu-item-transport"></ul>
<?php
$output .= ob_get_clean();
}
}
/**
* Create HTML list of nav menu input items.
*
* @package WordPress
* @since 3.0.0
* @uses Walker_Nav_Menu
*/
class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu {
function __construct( $fields = false ) {
if ( $fields ) {
$this->db_fields = $fields;
}
}
function start_lvl( &$output, $depth ) {
$indent = str_repeat( "\t", $depth );
$output .= "\n$indent<ul class='children'>\n";
}
function end_lvl( &$output, $depth ) {
$indent = str_repeat( "\t", $depth );
$output .= "\n$indent</ul>";
}
/**
* @see Walker::start_el()
* @since 3.0.0
*
* @param string $output Passed by reference. Used to append additional content.
* @param object $item Menu item data object.
* @param int $depth Depth of menu item. Used for padding.
* @param object $args
*/
function start_el(&$output, $item, $depth, $args) {
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;
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
$output .= $indent . '<li>';
$output .= '<label class="menu-item-title">';
$output .= '<input type="checkbox" class="menu-item-checkbox';
if ( ! empty( $item->_add_to_top ) ) {
$output .= ' add-to-top';
}
$output .= '" name="menu-item[' . $possible_object_id . '][menu-item-object-id]" value="'. esc_attr( $item->object_id ) .'" /> ';
$output .= empty( $item->label ) ? esc_html( $item->title ) : esc_html( $item->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 ) .'" />';
}
}
/**
* Prints the appropriate response to a menu quick search.
*
* @since 3.0.0
*
* @param array $request The unsanitized request values.
*/
function _wp_ajax_menu_quick_search( $request = array() ) {
$args = array();
$type = isset( $request['type'] ) ? $request['type'] : '';
$object_type = isset( $request['object_type'] ) ? $request['object_type'] : '';
$query = isset( $request['q'] ) ? $request['q'] : '';
$response_format = isset( $request['response-format'] ) && in_array( $request['response-format'], array( 'json', 'markup' ) ) ? $request['response-format'] : 'json';
if ( 'markup' == $response_format ) {
$args['walker'] = new Walker_Nav_Menu_Checklist;
}
if ( 'get-post-item' == $type ) {
if ( post_type_exists( $object_type ) ) {
if ( isset( $request['ID'] ) ) {
$object_id = (int) $request['ID'];
if ( 'markup' == $response_format ) {
echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( get_post( $object_id ) ) ), 0, (object) $args );
} elseif ( 'json' == $response_format ) {
$post_obj = get_post( $object_id );
echo json_encode(
array(
'ID' => $object_id,
'post_title' => get_the_title( $object_id ),
'post_type' => get_post_type( $object_id ),
)
);
echo "\n";
}
}
} elseif ( taxonomy_exists( $object_type ) ) {
if ( isset( $request['ID'] ) ) {
$object_id = (int) $request['ID'];
if ( 'markup' == $response_format ) {
echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( get_term( $object_id, $object_type ) ) ), 0, (object) $args );
} elseif ( 'json' == $response_format ) {
$post_obj = get_term( $object_id, $object_type );
echo json_encode(
array(
'ID' => $object_id,
'post_title' => $post_obj->name,
'post_type' => $object_type,
)
);
echo "\n";
}
}
}
} elseif ( preg_match('/quick-search-(posttype|taxonomy)-([a-zA-Z_-]*\b)/', $type, $matches) ) {
if ( 'posttype' == $matches[1] && get_post_type_object( $matches[2] ) ) {
query_posts(array(
'posts_per_page' => 10,
'post_type' => $matches[2],
's' => $query,
));
if ( ! have_posts() )
return;
while ( have_posts() ) {
the_post();
if ( 'markup' == $response_format ) {
$var_by_ref = get_the_ID();
echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( get_post( $var_by_ref ) ) ), 0, (object) $args );
} elseif ( 'json' == $response_format ) {
echo json_encode(
array(
'ID' => get_the_ID(),
'post_title' => get_the_title(),
'post_type' => get_post_type(),
)
);
echo "\n";
}
}
} elseif ( 'taxonomy' == $matches[1] ) {
$terms = get_terms( $matches[2], array(
'name__like' => $query,
'number' => 10,
));
if ( empty( $terms ) || is_wp_error( $terms ) )
return;
foreach( (array) $terms as $term ) {
if ( 'markup' == $response_format ) {
echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( $term ) ), 0, (object) $args );
} elseif ( 'json' == $response_format ) {
echo json_encode(
array(
'ID' => $term->term_id,
'post_title' => $term->name,
'post_type' => $matches[2],
)
);
echo "\n";
}
}
}
}
}
/**
* Register nav menu metaboxes and advanced menu items
*
* @since 3.0.0
**/
function wp_nav_menu_setup() {
// Register meta boxes
if ( wp_get_nav_menus() )
add_meta_box( 'nav-menu-theme-locations', __( 'Theme Locations' ), 'wp_nav_menu_locations_meta_box' , 'nav-menus', 'side', 'default' );
add_meta_box( 'add-custom-links', __('Custom Links'), 'wp_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default' );
wp_nav_menu_post_type_meta_boxes();
wp_nav_menu_taxonomy_meta_boxes();
// Register advanced menu items (columns)
add_filter( 'manage_nav-menus_columns', 'wp_nav_menu_manage_columns');
// If first time editing, disable advanced items by default.
if( false === get_user_option( 'managenav-menuscolumnshidden' ) ) {
$user = wp_get_current_user();
update_user_option($user->ID, 'managenav-menuscolumnshidden',
array( 0 => 'link-target', 1 => 'css-classes', 2 => 'xfn', 3 => 'description', ),
true);
}
}
/**
* Limit the amount of meta boxes to just links, pages and cats for first time users.
*
* @since 3.0.0
**/
function wp_initial_nav_menu_meta_boxes() {
global $wp_meta_boxes;
if ( get_user_option( 'metaboxhidden_nav-menus' ) !== false || ! is_array($wp_meta_boxes) )
return;
$initial_meta_boxes = array( 'nav-menu-theme-locations', 'add-custom-links', 'add-page', 'add-category' );
$hidden_meta_boxes = array();
foreach ( array_keys($wp_meta_boxes['nav-menus']) as $context ) {
foreach ( array_keys($wp_meta_boxes['nav-menus'][$context]) as $priority ) {
foreach ( $wp_meta_boxes['nav-menus'][$context][$priority] as $box ) {
if ( in_array( $box['id'], $initial_meta_boxes ) ) {
unset( $box['id'] );
} else {
$hidden_meta_boxes[] = $box['id'];
}
}
}
}
$user = wp_get_current_user();
update_user_option( $user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true );
}
/**
* Creates metaboxes for any post type menu item.
*
* @since 3.0.0
*/
function wp_nav_menu_post_type_meta_boxes() {
$post_types = get_post_types( array( 'show_in_nav_menus' => true ), 'object' );
if ( ! $post_types )
return;
foreach ( $post_types as $post_type ) {
$post_type = apply_filters( 'nav_menu_meta_box_object', $post_type );
if ( $post_type ) {
$id = $post_type->name;
add_meta_box( "add-{$id}", $post_type->labels->name, 'wp_nav_menu_item_post_type_meta_box', 'nav-menus', 'side', 'default', $post_type );
}
}
}
/**
* Creates metaboxes for any taxonomy menu item.
*
* @since 3.0.0
*/
function wp_nav_menu_taxonomy_meta_boxes() {
$taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'object' );
if ( !$taxonomies )
return;
foreach ( $taxonomies as $tax ) {
$tax = apply_filters( 'nav_menu_meta_box_object', $tax );
if ( $tax ) {
$id = $tax->name;
add_meta_box( "add-{$id}", $tax->labels->name, 'wp_nav_menu_item_taxonomy_meta_box', 'nav-menus', 'side', 'default', $tax );
}
}
}
/**
* Displays a metabox for the nav menu theme locations.
*
* @since 3.0.0
*/
function wp_nav_menu_locations_meta_box() {
global $nav_menu_selected_id;
if ( ! current_theme_supports( 'menus' ) ) {
// We must only support widgets. Leave a message and bail.
echo '<p class="howto">' . __('The current theme does not natively support menus, but you can use the “Custom Menu” widget to add any menus you create here to the theme’s sidebar.') . '</p>';
return;
}
$locations = get_registered_nav_menus();
$menus = wp_get_nav_menus();
$menu_locations = get_nav_menu_locations();
$num_locations = count( array_keys($locations) );
echo '<p class="howto">' . sprintf( _n('Your theme supports %s menu. Select which menu you would like to use.', 'Your theme supports %s menus. Select which menu appears in each location.', $num_locations ), number_format_i18n($num_locations) ) . '</p>';
foreach ( $locations as $location => $description ) {
?>
<p>
<label class="howto" for="locations-<?php echo $location; ?>">
<span><?php echo $description; ?></span>
<select name="menu-locations[<?php echo $location; ?>]" id="locations-<?php echo $location; ?>">
<option value="0"></option>
<?php foreach ( $menus as $menu ) : ?>
<option<?php selected( isset( $menu_locations[ $location ] ) && $menu_locations[ $location ] == $menu->term_id ); ?>
value="<?php echo $menu->term_id; ?>"><?php
$truncated_name = wp_html_excerpt( $menu->name, 40 );
echo $truncated_name == $menu->name ? $menu->name : trim( $truncated_name ) . '…';
?></option>
<?php endforeach; ?>
</select>
</label>
</p>
<?php
}
?>
<p class="button-controls">
<img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
<?php submit_button( __( 'Save' ), 'primary', 'nav-menu-locations', false, disabled( $nav_menu_selected_id, 0, false ) ); ?>
</p>
<?php
}
/**
* Displays a metabox for the custom links menu item.
*
* @since 3.0.0
*/
function wp_nav_menu_item_link_meta_box() {
global $_nav_menu_placeholder, $nav_menu_selected_id;
$_nav_menu_placeholder = 0 > $_nav_menu_placeholder ? $_nav_menu_placeholder - 1 : -1;
$current_tab = 'create';
if ( isset( $_REQUEST['customlink-tab'] ) && in_array( $_REQUEST['customlink-tab'], array('create', 'all') ) ) {
$current_tab = $_REQUEST['customlink-tab'];
}
$removed_args = array(
'action',
'customlink-tab',
'edit-menu-item',
'menu-item',
'page-tab',
'_wpnonce',
);
?>
<div class="customlinkdiv" id="customlinkdiv">
<input type="hidden" value="custom" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-type]" />
<p id="menu-item-url-wrap">
<label class="howto" for="custom-menu-item-url">
<span><?php _e('URL'); ?></span>
<input id="custom-menu-item-url" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-url]" type="text" class="code menu-item-textbox" value="http://" />
</label>
</p>
<p id="menu-item-name-wrap">
<label class="howto" for="custom-menu-item-name">
<span><?php _e('Label'); ?></span>
<input id="custom-menu-item-name" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-title]" type="text" class="regular-text menu-item-textbox input-with-default-title" title="<?php esc_attr_e('Menu Item'); ?>" />
</label>
</p>
<p class="button-controls">
<span class="add-to-menu">
<img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
<input type="submit"<?php disabled( $nav_menu_selected_id, 0 ); ?> class="button-secondary submit-add-to-menu" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-custom-menu-item" id="submit-customlinkdiv" />
</span>
</p>
</div><!-- /.customlinkdiv -->
<?php
}
/**
* Displays a metabox for a post type menu item.
*
* @since 3.0.0
*
* @param string $object Not used.
* @param string $post_type The post type object.
*/
function wp_nav_menu_item_post_type_meta_box( $object, $post_type ) {
global $_nav_menu_placeholder, $nav_menu_selected_id;
$post_type_name = $post_type['args']->name;
// paginate browsing for large numbers of post objects
$per_page = 50;
$pagenum = isset( $_REQUEST[$post_type_name . '-tab'] ) && isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 1;
$offset = 0 < $pagenum ? $per_page * ( $pagenum - 1 ) : 0;
$args = array(
'offset' => $offset,
'order' => 'ASC',
'orderby' => 'title',
'posts_per_page' => $per_page,
'post_type' => $post_type_name,
'suppress_filters' => true,
'update_post_term_cache' => false,
'update_post_meta_cache' => false
);
if ( isset( $post_type['args']->_default_query ) )
$args = array_merge($args, (array) $post_type['args']->_default_query );
// @todo transient caching of these results with proper invalidation on updating of a post of this type
$get_posts = new WP_Query;
$posts = $get_posts->query( $args );
if ( ! $get_posts->post_count ) {
echo '<p>' . __( 'No items.' ) . '</p>';
return;
}
$post_type_object = get_post_type_object($post_type_name);
$num_pages = $get_posts->max_num_pages;
$page_links = paginate_links( array(
'base' => add_query_arg(
array(
$post_type_name . '-tab' => 'all',
'paged' => '%#%',
'item-type' => 'post_type',
'item-object' => $post_type_name,
)
),
'format' => '',
'prev_text' => __('«'),
'next_text' => __('»'),
'total' => $num_pages,
'current' => $pagenum
));
if ( !$posts )
$error = '<li id="error">'. $post_type['args']->labels->not_found .'</li>';
$db_fields = false;
if ( is_post_type_hierarchical( $post_type_name ) ) {
$db_fields = array( 'parent' => 'post_parent', 'id' => 'ID' );
}
$walker = new Walker_Nav_Menu_Checklist( $db_fields );
$current_tab = 'most-recent';
if ( isset( $_REQUEST[$post_type_name . '-tab'] ) && in_array( $_REQUEST[$post_type_name . '-tab'], array('all', 'search') ) ) {
$current_tab = $_REQUEST[$post_type_name . '-tab'];
}
if ( ! empty( $_REQUEST['quick-search-posttype-' . $post_type_name] ) ) {
$current_tab = 'search';
}
$removed_args = array(
'action',
'customlink-tab',
'edit-menu-item',
'menu-item',
'page-tab',
'_wpnonce',
);
?>
<div id="posttype-<?php echo $post_type_name; ?>" class="posttypediv">
<ul id="posttype-<?php echo $post_type_name; ?>-tabs" class="posttype-tabs add-menu-item-tabs">
<li <?php echo ( 'most-recent' == $current_tab ? ' class="tabs"' : '' ); ?>><a class="nav-tab-link" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($post_type_name . '-tab', 'most-recent', remove_query_arg($removed_args))); ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent"><?php _e('Most Recent'); ?></a></li>
<li <?php echo ( 'all' == $current_tab ? ' class="tabs"' : '' ); ?>><a class="nav-tab-link" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($post_type_name . '-tab', 'all', remove_query_arg($removed_args))); ?>#<?php echo $post_type_name; ?>-all"><?php _e('View All'); ?></a></li>
<li <?php echo ( 'search' == $current_tab ? ' class="tabs"' : '' ); ?>><a class="nav-tab-link" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($post_type_name . '-tab', 'search', remove_query_arg($removed_args))); ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-search"><?php _e('Search'); ?></a></li>
</ul>
<div id="tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent" class="tabs-panel <?php
echo ( 'most-recent' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
?>">
<ul id="<?php echo $post_type_name; ?>checklist-most-recent" class="categorychecklist form-no-clear">
<?php
$recent_args = array_merge( $args, array( 'orderby' => 'post_date', 'order' => 'DESC', 'posts_per_page' => 15 ) );
$most_recent = $get_posts->query( $recent_args );
$args['walker'] = $walker;
echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $most_recent), 0, (object) $args );
?>
</ul>
</div><!-- /.tabs-panel -->
<div class="tabs-panel <?php
echo ( 'search' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
?>" id="tabs-panel-posttype-<?php echo $post_type_name; ?>-search">
<?php
if ( isset( $_REQUEST['quick-search-posttype-' . $post_type_name] ) ) {
$searched = esc_attr( $_REQUEST['quick-search-posttype-' . $post_type_name] );
$search_results = get_posts( array( 's' => $searched, 'post_type' => $post_type_name, 'fields' => 'all', 'order' => 'DESC', ) );
} else {
$searched = '';
$search_results = array();
}
?>
<p class="quick-search-wrap">
<input type="search" class="quick-search input-with-default-title" title="<?php esc_attr_e('Search'); ?>" value="<?php echo $searched; ?>" name="quick-search-posttype-<?php echo $post_type_name; ?>" />
<img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
<?php submit_button( __( 'Search' ), 'quick-search-submit button-secondary hide-if-js', 'submit', false, array( 'id' => 'submit-quick-search-posttype-' . $post_type_name ) ); ?>
</p>
<ul id="<?php echo $post_type_name; ?>-search-checklist" class="list:<?php echo $post_type_name?> categorychecklist form-no-clear">
<?php if ( ! empty( $search_results ) && ! is_wp_error( $search_results ) ) : ?>
<?php
$args['walker'] = $walker;
echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $search_results), 0, (object) $args );
?>
<?php elseif ( is_wp_error( $search_results ) ) : ?>
<li><?php echo $search_results->get_error_message(); ?></li>
<?php elseif ( ! empty( $searched ) ) : ?>
<li><?php _e('No results found.'); ?></li>
<?php endif; ?>
</ul>
</div><!-- /.tabs-panel -->
<div id="<?php echo $post_type_name; ?>-all" class="tabs-panel tabs-panel-view-all <?php
echo ( 'all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
?>">
<?php if ( ! empty( $page_links ) ) : ?>
<div class="add-menu-item-pagelinks">
<?php echo $page_links; ?>
</div>
<?php endif; ?>
<ul id="<?php echo $post_type_name; ?>checklist" class="list:<?php echo $post_type_name?> categorychecklist form-no-clear">
<?php
$args['walker'] = $walker;
// if we're dealing with pages, let's put a checkbox for the front page at the top of the list
if ( 'page' == $post_type_name ) {
$front_page = 'page' == get_option('show_on_front') ? (int) get_option( 'page_on_front' ) : 0;
if ( ! empty( $front_page ) ) {
$front_page_obj = get_post( $front_page );
$front_page_obj->_add_to_top = true;
$front_page_obj->label = sprintf( _x('Home: %s', 'nav menu front page title'), $front_page_obj->post_title );
array_unshift( $posts, $front_page_obj );
} else {
$_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1;
array_unshift( $posts, (object) array(
'_add_to_top' => true,
'ID' => 0,
'object_id' => $_nav_menu_placeholder,
'post_content' => '',
'post_excerpt' => '',
'post_parent' => '',
'post_title' => _x('Home', 'nav menu home label'),
'post_type' => 'nav_menu_item',
'type' => 'custom',
'url' => home_url('/'),
) );
}
}
$posts = apply_filters( 'nav_menu_items_'.$post_type_name, $posts, $args, $post_type );
$checkbox_items = walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $posts), 0, (object) $args );
if ( 'all' == $current_tab && ! empty( $_REQUEST['selectall'] ) ) {
$checkbox_items = preg_replace('/(type=(.)checkbox(\2))/', '$1 checked=$2checked$2', $checkbox_items);
}
echo $checkbox_items;
?>
</ul>
<?php if ( ! empty( $page_links ) ) : ?>
<div class="add-menu-item-pagelinks">
<?php echo $page_links; ?>
</div>
<?php endif; ?>
</div><!-- /.tabs-panel -->
<p class="button-controls">
<span class="list-controls">
<a href="<?php
echo esc_url(add_query_arg(
array(
$post_type_name . '-tab' => 'all',
'selectall' => 1,
),
remove_query_arg($removed_args)
));
?>#posttype-<?php echo $post_type_name; ?>" class="select-all"><?php _e('Select All'); ?></a>
</span>
<span class="add-to-menu">
<img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
<input type="submit"<?php disabled( $nav_menu_selected_id, 0 ); ?> class="button-secondary submit-add-to-menu" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-post-type-menu-item" id="submit-posttype-<?php echo $post_type_name; ?>" />
</span>
</p>
</div><!-- /.posttypediv -->
<?php
}
/**
* Displays a metabox for a taxonomy menu item.
*
* @since 3.0.0
*
* @param string $object Not used.
* @param string $taxonomy The taxonomy object.
*/
function wp_nav_menu_item_taxonomy_meta_box( $object, $taxonomy ) {
global $nav_menu_selected_id;
$taxonomy_name = $taxonomy['args']->name;
// paginate browsing for large numbers of objects
$per_page = 50;
$pagenum = isset( $_REQUEST[$taxonomy_name . '-tab'] ) && isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 1;
$offset = 0 < $pagenum ? $per_page * ( $pagenum - 1 ) : 0;
$args = array(
'child_of' => 0,
'exclude' => '',
'hide_empty' => false,
'hierarchical' => 1,
'include' => '',
'number' => $per_page,
'offset' => $offset,
'order' => 'ASC',
'orderby' => 'name',
'pad_counts' => false,
);
$terms = get_terms( $taxonomy_name, $args );
if ( ! $terms || is_wp_error($terms) ) {
echo '<p>' . __( 'No items.' ) . '</p>';
return;
}
$num_pages = ceil( wp_count_terms( $taxonomy_name , array_merge( $args, array('number' => '', 'offset' => '') ) ) / $per_page );
$page_links = paginate_links( array(
'base' => add_query_arg(
array(
$taxonomy_name . '-tab' => 'all',
'paged' => '%#%',
'item-type' => 'taxonomy',
'item-object' => $taxonomy_name,
)
),
'format' => '',
'prev_text' => __('«'),
'next_text' => __('»'),
'total' => $num_pages,
'current' => $pagenum
));
$db_fields = false;
if ( is_taxonomy_hierarchical( $taxonomy_name ) ) {
$db_fields = array( 'parent' => 'parent', 'id' => 'term_id' );
}
$walker = new Walker_Nav_Menu_Checklist( $db_fields );
$current_tab = 'most-used';
if ( isset( $_REQUEST[$taxonomy_name . '-tab'] ) && in_array( $_REQUEST[$taxonomy_name . '-tab'], array('all', 'most-used', 'search') ) ) {
$current_tab = $_REQUEST[$taxonomy_name . '-tab'];
}
if ( ! empty( $_REQUEST['quick-search-taxonomy-' . $taxonomy_name] ) ) {
$current_tab = 'search';
}
$removed_args = array(
'action',
'customlink-tab',
'edit-menu-item',
'menu-item',
'page-tab',
'_wpnonce',
);
?>
<div id="taxonomy-<?php echo $taxonomy_name; ?>" class="taxonomydiv">
<ul id="taxonomy-<?php echo $taxonomy_name; ?>-tabs" class="taxonomy-tabs add-menu-item-tabs">
<li <?php echo ( 'most-used' == $current_tab ? ' class="tabs"' : '' ); ?>><a class="nav-tab-link" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($taxonomy_name . '-tab', 'most-used', remove_query_arg($removed_args))); ?>#tabs-panel-<?php echo $taxonomy_name; ?>-pop"><?php _e('Most Used'); ?></a></li>
<li <?php echo ( 'all' == $current_tab ? ' class="tabs"' : '' ); ?>><a class="nav-tab-link" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($taxonomy_name . '-tab', 'all', remove_query_arg($removed_args))); ?>#tabs-panel-<?php echo $taxonomy_name; ?>-all"><?php _e('View All'); ?></a></li>
<li <?php echo ( 'search' == $current_tab ? ' class="tabs"' : '' ); ?>><a class="nav-tab-link" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($taxonomy_name . '-tab', 'search', remove_query_arg($removed_args))); ?>#tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>"><?php _e('Search'); ?></a></li>
</ul>
<div id="tabs-panel-<?php echo $taxonomy_name; ?>-pop" class="tabs-panel <?php
echo ( 'most-used' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
?>">
<ul id="<?php echo $taxonomy_name; ?>checklist-pop" class="categorychecklist form-no-clear" >
<?php
$popular_terms = get_terms( $taxonomy_name, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) );
$args['walker'] = $walker;
echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $popular_terms), 0, (object) $args );
?>
</ul>
</div><!-- /.tabs-panel -->
<div id="tabs-panel-<?php echo $taxonomy_name; ?>-all" class="tabs-panel tabs-panel-view-all <?php
echo ( 'all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
?>">
<?php if ( ! empty( $page_links ) ) : ?>
<div class="add-menu-item-pagelinks">
<?php echo $page_links; ?>
</div>
<?php endif; ?>
<ul id="<?php echo $taxonomy_name; ?>checklist" class="list:<?php echo $taxonomy_name?> categorychecklist form-no-clear">
<?php
$args['walker'] = $walker;
echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $terms), 0, (object) $args );
?>
</ul>
<?php if ( ! empty( $page_links ) ) : ?>
<div class="add-menu-item-pagelinks">
<?php echo $page_links; ?>
</div>
<?php endif; ?>
</div><!-- /.tabs-panel -->
<div class="tabs-panel <?php
echo ( 'search' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
?>" id="tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>">
<?php
if ( isset( $_REQUEST['quick-search-taxonomy-' . $taxonomy_name] ) ) {
$searched = esc_attr( $_REQUEST['quick-search-taxonomy-' . $taxonomy_name] );
$search_results = get_terms( $taxonomy_name, array( 'name__like' => $searched, 'fields' => 'all', 'orderby' => 'count', 'order' => 'DESC', 'hierarchical' => false ) );
} else {
$searched = '';
$search_results = array();
}
?>
<p class="quick-search-wrap">
<input type="search" class="quick-search input-with-default-title" title="<?php esc_attr_e('Search'); ?>" value="<?php echo $searched; ?>" name="quick-search-taxonomy-<?php echo $taxonomy_name; ?>" />
<img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
<?php submit_button( __( 'Search' ), 'quick-search-submit button-secondary hide-if-js', 'submit', false, array( 'id' => 'submit-quick-search-taxonomy-' . $taxonomy_name ) ); ?>
</p>
<ul id="<?php echo $taxonomy_name; ?>-search-checklist" class="list:<?php echo $taxonomy_name?> categorychecklist form-no-clear">
<?php if ( ! empty( $search_results ) && ! is_wp_error( $search_results ) ) : ?>
<?php
$args['walker'] = $walker;
echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $search_results), 0, (object) $args );
?>
<?php elseif ( is_wp_error( $search_results ) ) : ?>
<li><?php echo $search_results->get_error_message(); ?></li>
<?php elseif ( ! empty( $searched ) ) : ?>
<li><?php _e('No results found.'); ?></li>
<?php endif; ?>
</ul>
</div><!-- /.tabs-panel -->
<p class="button-controls">
<span class="list-controls">
<a href="<?php
echo esc_url(add_query_arg(
array(
$taxonomy_name . '-tab' => 'all',
'selectall' => 1,
),
remove_query_arg($removed_args)
));
?>#taxonomy-<?php echo $taxonomy_name; ?>" class="select-all"><?php _e('Select All'); ?></a>
</span>
<span class="add-to-menu">
<img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
<input type="submit"<?php disabled( $nav_menu_selected_id, 0 ); ?> class="button-secondary submit-add-to-menu" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-taxonomy-menu-item" id="submit-taxonomy-<?php echo $taxonomy_name; ?>" />
</span>
</p>
</div><!-- /.taxonomydiv -->
<?php
}
/**
* Save posted nav menu item data.
*
* @since 3.0.0
*
* @param int $menu_id The menu ID for which to save this item. $menu_id of 0 makes a draft, orphaned menu item.
* @param array $menu_data The unsanitized posted menu item data.
* @return array The database IDs of the items saved
*/
function wp_save_nav_menu_items( $menu_id = 0, $menu_data = array() ) {
$menu_id = (int) $menu_id;
$items_saved = array();
if ( 0 == $menu_id || is_nav_menu( $menu_id ) ) {
// Loop through all the menu items' POST values
foreach( (array) $menu_data as $_possible_db_id => $_item_object_data ) {
if (
empty( $_item_object_data['menu-item-object-id'] ) && // checkbox is not checked
(
! isset( $_item_object_data['menu-item-type'] ) || // and item type either isn't set
in_array( $_item_object_data['menu-item-url'], array( 'http://', '' ) ) || // or URL is the default
! ( 'custom' == $_item_object_data['menu-item-type'] && ! isset( $_item_object_data['menu-item-db-id'] ) ) || // or it's not a custom menu item (but not the custom home page)
! empty( $_item_object_data['menu-item-db-id'] ) // or it *is* a custom menu item that already exists
)
) {
continue; // then this potential menu item is not getting added to this menu
}
// if this possible menu item doesn't actually have a menu database ID yet
if (
empty( $_item_object_data['menu-item-db-id'] ) ||
( 0 > $_possible_db_id ) ||
$_possible_db_id != $_item_object_data['menu-item-db-id']
) {
$_actual_db_id = 0;
} else {
$_actual_db_id = (int) $_item_object_data['menu-item-db-id'];
}
$args = array(
'menu-item-db-id' => ( isset( $_item_object_data['menu-item-db-id'] ) ? $_item_object_data['menu-item-db-id'] : '' ),
'menu-item-object-id' => ( isset( $_item_object_data['menu-item-object-id'] ) ? $_item_object_data['menu-item-object-id'] : '' ),
'menu-item-object' => ( isset( $_item_object_data['menu-item-object'] ) ? $_item_object_data['menu-item-object'] : '' ),
'menu-item-parent-id' => ( isset( $_item_object_data['menu-item-parent-id'] ) ? $_item_object_data['menu-item-parent-id'] : '' ),
'menu-item-position' => ( isset( $_item_object_data['menu-item-position'] ) ? $_item_object_data['menu-item-position'] : '' ),
'menu-item-type' => ( isset( $_item_object_data['menu-item-type'] ) ? $_item_object_data['menu-item-type'] : '' ),
'menu-item-title' => ( isset( $_item_object_data['menu-item-title'] ) ? $_item_object_data['menu-item-title'] : '' ),
'menu-item-url' => ( isset( $_item_object_data['menu-item-url'] ) ? $_item_object_data['menu-item-url'] : '' ),
'menu-item-description' => ( isset( $_item_object_data['menu-item-description'] ) ? $_item_object_data['menu-item-description'] : '' ),
'menu-item-attr-title' => ( isset( $_item_object_data['menu-item-attr-title'] ) ? $_item_object_data['menu-item-attr-title'] : '' ),
'menu-item-target' => ( isset( $_item_object_data['menu-item-target'] ) ? $_item_object_data['menu-item-target'] : '' ),
'menu-item-classes' => ( isset( $_item_object_data['menu-item-classes'] ) ? $_item_object_data['menu-item-classes'] : '' ),
'menu-item-xfn' => ( isset( $_item_object_data['menu-item-xfn'] ) ? $_item_object_data['menu-item-xfn'] : '' ),
);
$items_saved[] = wp_update_nav_menu_item( $menu_id, $_actual_db_id, $args );
}
}
return $items_saved;
}
/**
* Adds custom arguments to some of the meta box object types.
*
* @since 3.0.0
*
* @access private
*
* @param object $object The post type or taxonomy meta-object.
* @return object The post type of taxonomy object.
*/
function _wp_nav_menu_meta_box_object( $object = null ) {
if ( isset( $object->name ) ) {
if ( 'page' == $object->name ) {
$object->_default_query = array(
'orderby' => 'menu_order title',
'post_status' => 'publish',
);
// posts should show only published items
} elseif ( 'post' == $object->name ) {
$object->_default_query = array(
'post_status' => 'publish',
);
// cats should be in reverse chronological order
} elseif ( 'category' == $object->name ) {
$object->_default_query = array(
'orderby' => 'id',
'order' => 'DESC',
);
// custom post types should show only published items
} else {
$object->_default_query = array(
'post_status' => 'publish',
);
}
}
return $object;
}
/**
* Returns the menu formatted to edit.
*
* @since 3.0.0
*
* @param string $menu_id The ID of the menu to format.
* @return string|WP_Error $output The menu formatted to edit or error object on failure.
*/
function wp_get_nav_menu_to_edit( $menu_id = 0 ) {
$menu = wp_get_nav_menu_object( $menu_id );
// If the menu exists, get its items.
if ( is_nav_menu( $menu ) ) {
$menu_items = wp_get_nav_menu_items( $menu->term_id, array('post_status' => 'any') );
$result = '<div id="menu-instructions" class="post-body-plain';
$result .= ( ! empty($menu_items) ) ? ' menu-instructions-inactive">' : '">';
$result .= '<p>' . __('Select menu items (pages, categories, links) from the boxes at left to begin building your custom menu.') . '</p>';
$result .= '</div>';
if( empty($menu_items) )
return $result . ' <ul class="menu" id="menu-to-edit"> </ul>';
$walker_class_name = apply_filters( 'wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $menu_id );
if ( class_exists( $walker_class_name ) )
$walker = new $walker_class_name;
else
return new WP_Error( 'menu_walker_not_exist', sprintf( __('The Walker class named <strong>%s</strong> does not exist.'), $walker_class_name ) );
$some_pending_menu_items = $some_invalid_menu_items = false;
foreach( (array) $menu_items as $menu_item ) {
if ( isset( $menu_item->post_status ) && 'draft' == $menu_item->post_status )
$some_pending_menu_items = true;
if ( ! empty( $menu_item->_invalid ) )
$some_invalid_menu_items = true;
}
if ( $some_pending_menu_items )
$result .= '<div class="updated inline"><p>' . __('Click Save Menu to make pending menu items public.') . '</p></div>';
if ( $some_invalid_menu_items )
$result .= '<div class="error inline"><p>' . __('There are some invalid menu items. Please check or delete them.') . '</p></div>';
$result .= '<ul class="menu" id="menu-to-edit"> ';
$result .= walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $menu_items), 0, (object) array('walker' => $walker ) );
$result .= ' </ul> ';
return $result;
} elseif ( is_wp_error( $menu ) ) {
return $menu;
}
}
/**
* Returns the columns for the nav menus page.
*
* @since 3.0.0
*
* @return string|WP_Error $output The menu formatted to edit or error object on failure.
*/
function wp_nav_menu_manage_columns() {
return array(
'_title' => __('Show advanced menu properties'),
'cb' => '<input type="checkbox" />',
'link-target' => __('Link Target'),
'css-classes' => __('CSS Classes'),
'xfn' => __('Link Relationship (XFN)'),
'description' => __('Description'),
);
}
/**
* Deletes orphaned draft menu items
*
* @access private
* @since 3.0.0
*
*/
function _wp_delete_orphaned_draft_menu_items() {
global $wpdb;
$delete_timestamp = time() - (60*60*24*EMPTY_TRASH_DAYS);
// delete orphaned draft menu items
$menu_items_to_delete = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts AS p LEFT JOIN $wpdb->postmeta AS m ON p.ID = m.post_id WHERE post_type = 'nav_menu_item' AND post_status = 'draft' AND meta_key = '_menu_item_orphaned' AND meta_value < '%d'", $delete_timestamp ) );
foreach( (array) $menu_items_to_delete as $menu_item_id )
wp_delete_post( $menu_item_id, true );
}
add_action('admin_head-nav-menus.php', '_wp_delete_orphaned_draft_menu_items');
| 01happy-blog | trunk/myblog/wp-admin/includes/nav-menu.php | PHP | oos | 46,778 |
<?php
/**
* Multisite administration functions.
*
* @package WordPress
* @subpackage Multisite
* @since 3.0.0
*/
/**
* Determine if uploaded file exceeds space quota.
*
* @since 3.0.0
*
* @param array $file $_FILES array for a given file.
* @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' ) )
return $file;
if ( $file['error'] != '0' ) // there's already an error
return $file;
if ( defined( 'WP_IMPORTING' ) )
return $file;
$space_allowed = 1048576 * get_space_allowed();
$space_used = get_dirsize( BLOGUPLOADDIR );
$space_left = $space_allowed - $space_used;
$file_size = filesize( $file['tmp_name'] );
if ( $space_left < $file_size )
$file['error'] = sprintf( __( 'Not enough space to upload. %1$s KB needed.' ), number_format( ($file_size - $space_left) /1024 ) );
if ( $file_size > ( 1024 * get_site_option( 'fileupload_maxk', 1500 ) ) )
$file['error'] = sprintf(__('This file is too big. Files must be less than %1$s KB in size.'), get_site_option( 'fileupload_maxk', 1500 ) );
if ( upload_is_user_over_quota( false ) ) {
$file['error'] = __( 'You have used your space quota. Please delete files before uploading.' );
}
if ( $file['error'] != '0' && !isset($_POST['html-upload']) )
wp_die( $file['error'] . ' <a href="javascript:history.go(-1)">' . __( 'Back' ) . '</a>' );
return $file;
}
add_filter( 'wp_handle_upload_prefilter', 'check_upload_size' );
/**
* Delete a blog
*
* @since 3.0.0
*
* @param int $blog_id Blog ID
* @param bool $drop True if blog's table should be dropped. Default is false.
* @return void
*/
function wpmu_delete_blog( $blog_id, $drop = false ) {
global $wpdb, $current_site;
$switch = false;
if ( $blog_id != $wpdb->blogid ) {
$switch = true;
switch_to_blog( $blog_id );
$blog = get_blog_details( $blog_id );
} else {
$blog = $GLOBALS['current_blog'];
}
do_action( 'delete_blog', $blog_id, $drop );
$users = get_users( array( 'blog_id' => $blog_id, 'fields' => 'ids' ) );
// Remove users from this blog.
if ( ! empty( $users ) ) {
foreach ( $users as $user_id ) {
remove_user_from_blog( $user_id, $blog_id );
}
}
update_blog_status( $blog_id, 'deleted', 1 );
// Don't destroy the initial, main, or root blog.
if ( $drop && ( 1 == $blog_id || is_main_site( $blog_id ) || ( $blog->path == $current_site->path && $blog->domain == $current_site->domain ) ) )
$drop = false;
if ( $drop ) {
$drop_tables = apply_filters( 'wpmu_drop_tables', $wpdb->tables( 'blog' ) );
foreach ( (array) $drop_tables as $table ) {
$wpdb->query( "DROP TABLE IF EXISTS `$table`" );
}
$wpdb->delete( $wpdb->blogs, array( 'blog_id' => $blog_id ) );
$dir = apply_filters( 'wpmu_delete_blog_upload_dir', WP_CONTENT_DIR . "/blogs.dir/{$blog_id}/files/", $blog_id );
$dir = rtrim( $dir, DIRECTORY_SEPARATOR );
$top_dir = $dir;
$stack = array($dir);
$index = 0;
while ( $index < count( $stack ) ) {
# Get indexed directory from stack
$dir = $stack[$index];
$dh = @opendir( $dir );
if ( $dh ) {
while ( ( $file = @readdir( $dh ) ) !== false ) {
if ( $file == '.' || $file == '..' )
continue;
if ( @is_dir( $dir . DIRECTORY_SEPARATOR . $file ) )
$stack[] = $dir . DIRECTORY_SEPARATOR . $file;
else if ( @is_file( $dir . DIRECTORY_SEPARATOR . $file ) )
@unlink( $dir . DIRECTORY_SEPARATOR . $file );
}
}
$index++;
}
$stack = array_reverse( $stack ); // Last added dirs are deepest
foreach( (array) $stack as $dir ) {
if ( $dir != $top_dir)
@rmdir( $dir );
}
}
if ( $switch )
restore_current_blog();
}
// @todo Merge with wp_delete_user() ?
function wpmu_delete_user( $id ) {
global $wpdb;
$id = (int) $id;
$user = new WP_User( $id );
do_action( 'wpmu_delete_user', $id );
$blogs = get_blogs_of_user( $id );
if ( ! empty( $blogs ) ) {
foreach ( $blogs as $blog ) {
switch_to_blog( $blog->userblog_id );
remove_user_from_blog( $id, $blog->userblog_id );
$post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d", $id ) );
foreach ( (array) $post_ids as $post_id ) {
wp_delete_post( $post_id );
}
// Clean links
$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 )
wp_delete_link( $link_id );
}
restore_current_blog();
}
}
$meta = $wpdb->get_col( $wpdb->prepare( "SELECT umeta_id FROM $wpdb->usermeta WHERE user_id = %d", $id ) );
foreach ( $meta as $mid )
delete_metadata_by_mid( 'user', $mid );
$wpdb->delete( $wpdb->users, array( 'ID' => $id ) );
clean_user_cache( $user );
// allow for commit transaction
do_action( 'deleted_user', $id );
return true;
}
function update_option_new_admin_email( $old_value, $value ) {
$email = get_option( 'admin_email' );
if ( $value == get_option( 'admin_email' ) || !is_email( $value ) )
return;
$hash = md5( $value. time() .mt_rand() );
$new_admin_email = array(
'hash' => $hash,
'newemail' => $value
);
update_option( 'adminhash', $new_admin_email );
$content = apply_filters( 'new_admin_email_content', __( "Dear user,
You recently requested to have the administration email address on
your site changed.
If this is correct, please click on the following link to change it:
###ADMIN_URL###
You can safely ignore and delete this email if you do not want to
take this action.
This email has been sent to ###EMAIL###
Regards,
All at ###SITENAME###
###SITEURL### "), $new_admin_email );
$content = str_replace( '###ADMIN_URL###', esc_url( admin_url( 'options.php?adminhash='.$hash ) ), $content );
$content = str_replace( '###EMAIL###', $value, $content );
$content = str_replace( '###SITENAME###', get_site_option( 'site_name' ), $content );
$content = str_replace( '###SITEURL###', network_home_url(), $content );
wp_mail( $value, sprintf( __( '[%s] New Admin Email Address' ), get_option( 'blogname' ) ), $content );
}
add_action( 'update_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 );
function send_confirmation_on_profile_email() {
global $errors, $wpdb;
$current_user = wp_get_current_user();
if ( ! is_object($errors) )
$errors = new WP_Error();
if ( $current_user->ID != $_POST['user_id'] )
return false;
if ( $current_user->user_email != $_POST['email'] ) {
if ( !is_email( $_POST['email'] ) ) {
$errors->add( 'user_email', __( "<strong>ERROR</strong>: The e-mail address isn't correct." ), array( 'form-field' => 'email' ) );
return;
}
if ( $wpdb->get_var( $wpdb->prepare( "SELECT user_email FROM {$wpdb->users} WHERE user_email=%s", $_POST['email'] ) ) ) {
$errors->add( 'user_email', __( "<strong>ERROR</strong>: The e-mail address is already used." ), array( 'form-field' => 'email' ) );
delete_option( $current_user->ID . '_new_email' );
return;
}
$hash = md5( $_POST['email'] . time() . mt_rand() );
$new_user_email = array(
'hash' => $hash,
'newemail' => $_POST['email']
);
update_option( $current_user->ID . '_new_email', $new_user_email );
$content = apply_filters( 'new_user_email_content', __( "Dear user,
You recently requested to have the email address on your account changed.
If this is correct, please click on the following link to change it:
###ADMIN_URL###
You can safely ignore and delete this email if you do not want to
take this action.
This email has been sent to ###EMAIL###
Regards,
All at ###SITENAME###
###SITEURL###" ), $new_user_email );
$content = str_replace( '###ADMIN_URL###', esc_url( admin_url( 'profile.php?newuseremail='.$hash ) ), $content );
$content = str_replace( '###EMAIL###', $_POST['email'], $content);
$content = str_replace( '###SITENAME###', get_site_option( 'site_name' ), $content );
$content = str_replace( '###SITEURL###', network_home_url(), $content );
wp_mail( $_POST['email'], sprintf( __( '[%s] New Email Address' ), get_option( 'blogname' ) ), $content );
$_POST['email'] = $current_user->user_email;
}
}
add_action( 'personal_options_update', 'send_confirmation_on_profile_email' );
function new_user_email_admin_notice() {
if ( strpos( $_SERVER['PHP_SELF'], 'profile.php' ) && isset( $_GET['updated'] ) && $email = get_option( get_current_user_id() . '_new_email' ) )
echo "<div class='update-nag'>" . sprintf( __( "Your email address has not been updated yet. Please check your inbox at %s for a confirmation email." ), $email['newemail'] ) . "</div>";
}
add_action( 'admin_notices', 'new_user_email_admin_notice' );
/**
* Determines if there is any upload space left in the current blog's quota.
*
* @since 3.0.0
* @return bool True if space is available, false otherwise.
*/
function is_upload_space_available() {
if ( get_site_option( 'upload_space_check_disabled' ) )
return true;
if ( !( $space_allowed = get_upload_space_available() ) )
return false;
return true;
}
/**
* @since 3.0.0
*
* @return int of upload size limit in bytes
*/
function upload_size_limit_filter( $size ) {
$fileupload_maxk = 1024 * get_site_option( 'fileupload_maxk', 1500 );
if ( get_site_option( 'upload_space_check_disabled' ) )
return min( $size, $fileupload_maxk );
return min( $size, $fileupload_maxk, get_upload_space_available() );
}
/**
* Determines if there is any upload space left in the current blog's quota.
*
* @return int of upload space available in bytes
*/
function get_upload_space_available() {
$space_allowed = get_space_allowed() * 1024 * 1024;
if ( get_site_option( 'upload_space_check_disabled' ) )
return $space_allowed;
$dir_name = trailingslashit( BLOGUPLOADDIR );
if ( !( is_dir( $dir_name) && is_readable( $dir_name ) ) )
return $space_allowed;
$dir = dir( $dir_name );
$size = 0;
while ( $file = $dir->read() ) {
if ( $file != '.' && $file != '..' ) {
if ( is_dir( $dir_name . $file) ) {
$size += get_dirsize( $dir_name . $file );
} else {
$size += filesize( $dir_name . $file );
}
}
}
$dir->close();
if ( ( $space_allowed - $size ) <= 0 )
return 0;
return $space_allowed - $size;
}
/**
* Returns the upload quota for the current blog.
*
* @return int Quota
*/
function get_space_allowed() {
$space_allowed = get_option( 'blog_upload_space' );
if ( ! is_numeric( $space_allowed ) )
$space_allowed = get_site_option( 'blog_upload_space' );
if ( empty( $space_allowed ) || ! is_numeric( $space_allowed ) )
$space_allowed = 50;
return $space_allowed;
}
function display_space_usage() {
$space = get_space_allowed();
$used = get_dirsize( BLOGUPLOADDIR ) / 1024 / 1024;
$percentused = ( $used / $space ) * 100;
if ( $space > 1000 ) {
$space = number_format( $space / 1024 );
/* translators: Gigabytes */
$space .= __( 'GB' );
} else {
/* translators: Megabytes */
$space .= __( 'MB' );
}
?>
<strong><?php printf( __( 'Used: %1s%% of %2s' ), number_format( $percentused ), $space ); ?></strong>
<?php
}
// Edit blog upload space setting on Edit Blog page
function upload_space_setting( $id ) {
$quota = get_blog_option( $id, 'blog_upload_space' );
if ( !$quota )
$quota = '';
?>
<tr>
<th><?php _e( 'Site Upload Space Quota '); ?></th>
<td><input type="number" step="1" min="0" style="width: 100px" name="option[blog_upload_space]" value="<?php echo $quota; ?>" /> <?php _e( 'MB (Leave blank for network default)' ); ?></td>
</tr>
<?php
}
add_action( 'wpmueditblogaction', 'upload_space_setting' );
function update_user_status( $id, $pref, $value, $deprecated = null ) {
global $wpdb;
if ( null !== $deprecated )
_deprecated_argument( __FUNCTION__, '3.1' );
$wpdb->update( $wpdb->users, array( $pref => $value ), array( 'ID' => $id ) );
$user = new WP_User( $id );
clean_user_cache( $user );
if ( $pref == 'spam' ) {
if ( $value == 1 )
do_action( 'make_spam_user', $id );
else
do_action( 'make_ham_user', $id );
}
return $value;
}
function refresh_user_details( $id ) {
$id = (int) $id;
if ( !$user = get_userdata( $id ) )
return false;
clean_user_cache( $user );
return $id;
}
function format_code_lang( $code = '' ) {
$code = strtolower( substr( $code, 0, 2 ) );
$lang_codes = array(
'aa' => 'Afar', 'ab' => 'Abkhazian', 'af' => 'Afrikaans', 'ak' => 'Akan', 'sq' => 'Albanian', 'am' => 'Amharic', 'ar' => 'Arabic', 'an' => 'Aragonese', 'hy' => 'Armenian', 'as' => 'Assamese', 'av' => 'Avaric', 'ae' => 'Avestan', 'ay' => 'Aymara', 'az' => 'Azerbaijani', 'ba' => 'Bashkir', 'bm' => 'Bambara', 'eu' => 'Basque', 'be' => 'Belarusian', 'bn' => 'Bengali',
'bh' => 'Bihari', 'bi' => 'Bislama', 'bs' => 'Bosnian', 'br' => 'Breton', 'bg' => 'Bulgarian', 'my' => 'Burmese', 'ca' => 'Catalan; Valencian', 'ch' => 'Chamorro', 'ce' => 'Chechen', 'zh' => 'Chinese', 'cu' => 'Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian; Old Church Slavonic', 'cv' => 'Chuvash', 'kw' => 'Cornish', 'co' => 'Corsican', 'cr' => 'Cree',
'cs' => 'Czech', 'da' => 'Danish', 'dv' => 'Divehi; Dhivehi; Maldivian', 'nl' => 'Dutch; Flemish', 'dz' => 'Dzongkha', 'en' => 'English', 'eo' => 'Esperanto', 'et' => 'Estonian', 'ee' => 'Ewe', 'fo' => 'Faroese', 'fj' => 'Fijjian', 'fi' => 'Finnish', 'fr' => 'French', 'fy' => 'Western Frisian', 'ff' => 'Fulah', 'ka' => 'Georgian', 'de' => 'German', 'gd' => 'Gaelic; Scottish Gaelic',
'ga' => 'Irish', 'gl' => 'Galician', 'gv' => 'Manx', 'el' => 'Greek, Modern', 'gn' => 'Guarani', 'gu' => 'Gujarati', 'ht' => 'Haitian; Haitian Creole', 'ha' => 'Hausa', 'he' => 'Hebrew', 'hz' => 'Herero', 'hi' => 'Hindi', 'ho' => 'Hiri Motu', 'hu' => 'Hungarian', 'ig' => 'Igbo', 'is' => 'Icelandic', 'io' => 'Ido', 'ii' => 'Sichuan Yi', 'iu' => 'Inuktitut', 'ie' => 'Interlingue',
'ia' => 'Interlingua (International Auxiliary Language Association)', 'id' => 'Indonesian', 'ik' => 'Inupiaq', 'it' => 'Italian', 'jv' => 'Javanese', 'ja' => 'Japanese', 'kl' => 'Kalaallisut; Greenlandic', 'kn' => 'Kannada', 'ks' => 'Kashmiri', 'kr' => 'Kanuri', 'kk' => 'Kazakh', 'km' => 'Central Khmer', 'ki' => 'Kikuyu; Gikuyu', 'rw' => 'Kinyarwanda', 'ky' => 'Kirghiz; Kyrgyz',
'kv' => 'Komi', 'kg' => 'Kongo', 'ko' => 'Korean', 'kj' => 'Kuanyama; Kwanyama', 'ku' => 'Kurdish', 'lo' => 'Lao', 'la' => 'Latin', 'lv' => 'Latvian', 'li' => 'Limburgan; Limburger; Limburgish', 'ln' => 'Lingala', 'lt' => 'Lithuanian', 'lb' => 'Luxembourgish; Letzeburgesch', 'lu' => 'Luba-Katanga', 'lg' => 'Ganda', 'mk' => 'Macedonian', 'mh' => 'Marshallese', 'ml' => 'Malayalam',
'mi' => 'Maori', 'mr' => 'Marathi', 'ms' => 'Malay', 'mg' => 'Malagasy', 'mt' => 'Maltese', 'mo' => 'Moldavian', 'mn' => 'Mongolian', 'na' => 'Nauru', 'nv' => 'Navajo; Navaho', 'nr' => 'Ndebele, South; South Ndebele', 'nd' => 'Ndebele, North; North Ndebele', 'ng' => 'Ndonga', 'ne' => 'Nepali', 'nn' => 'Norwegian Nynorsk; Nynorsk, Norwegian', 'nb' => 'Bokmål, Norwegian, Norwegian Bokmål',
'no' => 'Norwegian', 'ny' => 'Chichewa; Chewa; Nyanja', 'oc' => 'Occitan, Provençal', 'oj' => 'Ojibwa', 'or' => 'Oriya', 'om' => 'Oromo', 'os' => 'Ossetian; Ossetic', 'pa' => 'Panjabi; Punjabi', 'fa' => 'Persian', 'pi' => 'Pali', 'pl' => 'Polish', 'pt' => 'Portuguese', 'ps' => 'Pushto', 'qu' => 'Quechua', 'rm' => 'Romansh', 'ro' => 'Romanian', 'rn' => 'Rundi', 'ru' => 'Russian',
'sg' => 'Sango', 'sa' => 'Sanskrit', 'sr' => 'Serbian', 'hr' => 'Croatian', 'si' => 'Sinhala; Sinhalese', 'sk' => 'Slovak', 'sl' => 'Slovenian', 'se' => 'Northern Sami', 'sm' => 'Samoan', 'sn' => 'Shona', 'sd' => 'Sindhi', 'so' => 'Somali', 'st' => 'Sotho, Southern', 'es' => 'Spanish; Castilian', 'sc' => 'Sardinian', 'ss' => 'Swati', 'su' => 'Sundanese', 'sw' => 'Swahili',
'sv' => 'Swedish', 'ty' => 'Tahitian', 'ta' => 'Tamil', 'tt' => 'Tatar', 'te' => 'Telugu', 'tg' => 'Tajik', 'tl' => 'Tagalog', 'th' => 'Thai', 'bo' => 'Tibetan', 'ti' => 'Tigrinya', 'to' => 'Tonga (Tonga Islands)', 'tn' => 'Tswana', 'ts' => 'Tsonga', 'tk' => 'Turkmen', 'tr' => 'Turkish', 'tw' => 'Twi', 'ug' => 'Uighur; Uyghur', 'uk' => 'Ukrainian', 'ur' => 'Urdu', 'uz' => 'Uzbek',
've' => 'Venda', 'vi' => 'Vietnamese', 'vo' => 'Volapük', 'cy' => 'Welsh','wa' => 'Walloon','wo' => 'Wolof', 'xh' => 'Xhosa', 'yi' => 'Yiddish', 'yo' => 'Yoruba', 'za' => 'Zhuang; Chuang', 'zu' => 'Zulu' );
$lang_codes = apply_filters( 'lang_codes', $lang_codes, $code );
return strtr( $code, $lang_codes );
}
function sync_category_tag_slugs( $term, $taxonomy ) {
if ( global_terms_enabled() && ( $taxonomy == 'category' || $taxonomy == 'post_tag' ) ) {
if ( is_object( $term ) ) {
$term->slug = sanitize_title( $term->name );
} else {
$term['slug'] = sanitize_title( $term['name'] );
}
}
return $term;
}
add_filter( 'get_term', 'sync_category_tag_slugs', 10, 2 );
function _access_denied_splash() {
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() ) ) )
return;
$blog_name = get_bloginfo( 'name' );
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 ) );
$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 .= '<table>';
foreach ( $blogs as $blog ) {
$output .= "<tr>";
$output .= "<td valign='top'>";
$output .= "{$blog->blogname}";
$output .= "</td>";
$output .= "<td valign='top'>";
$output .= "<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>" ;
$output .= "</td>";
$output .= "</tr>";
}
$output .= '</table>';
wp_die( $output );
}
add_action( 'admin_page_access_denied', '_access_denied_splash', 99 );
function check_import_new_users( $permission ) {
if ( !is_super_admin() )
return false;
return true;
}
add_filter( 'import_allow_create_users', 'check_import_new_users' );
// See "import_allow_fetch_attachments" and "import_attachment_size_limit" filters too.
function mu_dropdown_languages( $lang_files = array(), $current = '' ) {
$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>';
} 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>';
} else {
$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>";
// Order by name
uksort( $output, 'strnatcasecmp' );
$output = apply_filters( 'mu_dropdown_languages', $output, $lang_files, $current );
echo implode( "\n\t", $output );
}
/* Warn the admin if SECRET SALT information is missing from wp-config.php */
function secret_salt_warning() {
if ( !is_super_admin() )
return;
$secret_keys = array( 'AUTH_KEY', 'SECURE_AUTH_KEY', 'LOGGED_IN_KEY', 'NONCE_KEY', 'AUTH_SALT', 'SECURE_AUTH_SALT', 'LOGGED_IN_SALT', 'NONCE_SALT' );
$out = '';
foreach( $secret_keys as $key ) {
if ( ! defined( $key ) )
$out .= "define( '$key', '" . esc_html( wp_generate_password( 64, true, true ) ) . "' );<br />";
}
if ( $out != '' ) {
$msg = __( 'Warning! WordPress encrypts user cookies, but you must add the following lines to <strong>wp-config.php</strong> for it to be more secure.' );
$msg .= '<br/>' . __( "Before the line <code>/* That's all, stop editing! Happy blogging. */</code> please add this code:" );
$msg .= "<br/><br/><code>$out</code>";
echo "<div class='update-nag'>$msg</div>";
}
}
add_action( 'network_admin_notices', 'secret_salt_warning' );
function site_admin_notice() {
global $wp_db_version;
if ( !is_super_admin() )
return false;
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">Update Network</a> page to update all your sites.' ), esc_url( network_admin_url( 'upgrade.php' ) ) ) . "</div>";
}
add_action( 'admin_notices', 'site_admin_notice' );
add_action( 'network_admin_notices', 'site_admin_notice' );
function avoid_blog_page_permalink_collision( $data, $postarr ) {
if ( is_subdomain_install() )
return $data;
if ( $data['post_type'] != 'page' )
return $data;
if ( !isset( $data['post_name'] ) || $data['post_name'] == '' )
return $data;
if ( !is_main_site() )
return $data;
$post_name = $data['post_name'];
$c = 0;
while( $c < 10 && get_id_from_blogname( $post_name ) ) {
$post_name .= mt_rand( 1, 10 );
$c ++;
}
if ( $post_name != $data['post_name'] ) {
$data['post_name'] = $post_name;
}
return $data;
}
add_filter( 'wp_insert_post_data', 'avoid_blog_page_permalink_collision', 10, 2 );
function choose_primary_blog() {
?>
<table class="form-table">
<tr>
<?php /* translators: My sites label */ ?>
<th scope="row"><?php _e( 'Primary Site' ); ?></th>
<td>
<?php
$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">
<?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
} ?>
</select>
<?php
if ( !$found ) {
$blog = array_shift( $all_blogs );
update_user_meta( get_current_user_id(), 'primary_blog', $blog->userblog_id );
}
} elseif ( count( $all_blogs ) == 1 ) {
$blog = array_shift( $all_blogs );
echo $blog->domain;
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";
}
?>
</td>
</tr>
<?php if ( in_array( get_site_option( 'registration' ), array( 'all', 'blog' ) ) ) : ?>
<tr>
<th scope="row" colspan="2" class="th-full">
<a href="<?php echo apply_filters( 'wp_signup_location', network_home_url( 'wp-signup.php' ) ); ?>"><?php _e( 'Create a New Site' ); ?></a>
</th>
</tr>
<?php endif; ?>
</table>
<?php
}
function ms_deprecated_blogs_file() {
if ( ! is_super_admin() )
return;
if ( ! file_exists( WP_CONTENT_DIR . '/blogs.php' ) )
return;
echo '<div class="update-nag">' . sprintf( __( 'The <code>%1$s</code> file is deprecated. Please remove it and update your server rewrite rules to use <code>%2$s</code> instead.' ), 'wp-content/blogs.php', 'wp-includes/ms-files.php' ) . '</div>';
}
add_action( 'network_admin_notices', 'ms_deprecated_blogs_file' );
/**
* Grants super admin privileges.
*
* @since 3.0.0
* @param int $user_id
*/
function grant_super_admin( $user_id ) {
global $super_admins;
// If global super_admins override is defined, there is nothing to do here.
if ( isset($super_admins) )
return false;
do_action( 'grant_super_admin', $user_id );
// Directly fetch site_admins instead of using get_super_admins()
$super_admins = get_site_option( 'site_admins', array( 'admin' ) );
$user = new WP_User( $user_id );
if ( ! in_array( $user->user_login, $super_admins ) ) {
$super_admins[] = $user->user_login;
update_site_option( 'site_admins' , $super_admins );
do_action( 'granted_super_admin', $user_id );
return true;
}
return false;
}
/**
* Revokes super admin privileges.
*
* @since 3.0.0
* @param int $user_id
*/
function revoke_super_admin( $user_id ) {
global $super_admins;
// If global super_admins override is defined, there is nothing to do here.
if ( isset($super_admins) )
return false;
do_action( 'revoke_super_admin', $user_id );
// Directly fetch site_admins instead of using get_super_admins()
$super_admins = get_site_option( 'site_admins', array( 'admin' ) );
$user = new WP_User( $user_id );
if ( $user->user_email != get_site_option( 'admin_email' ) ) {
if ( false !== ( $key = array_search( $user->user_login, $super_admins ) ) ) {
unset( $super_admins[$key] );
update_site_option( 'site_admins', $super_admins );
do_action( 'revoked_super_admin', $user_id );
return true;
}
}
return false;
}
/**
* Whether or not we can edit this network from this page
*
* By default editing of network is restricted to the Network Admin for that site_id this allows for this to be overridden
*
* @since 3.1.0
* @param integer $site_id The network/site id to check.
*/
function can_edit_network( $site_id ) {
global $wpdb;
if ($site_id == $wpdb->siteid )
$result = true;
else
$result = false;
return apply_filters( 'can_edit_network', $result, $site_id );
}
/**
* Thickbox image paths for Network Admin.
*
* @since 3.1.0
* @access private
*/
function _thickbox_path_admin_subfolder() {
?>
<script type="text/javascript">
//<![CDATA[
var tb_pathToImage = "../../wp-includes/js/thickbox/loadingAnimation.gif";
var tb_closeImage = "../../wp-includes/js/thickbox/tb-close.png";
//]]>
</script>
<?php
}
/**
* Whether or not we have a large network.
*
* The default criteria for a large network is either more than 10,000 users or more than 10,000 sites.
* Plugins can alter this criteria using the 'wp_is_large_network' filter.
*
* @since 3.3.0
* @param string $using 'sites or 'users'. Default is 'sites'.
* @return bool True if the network meets the criteria for large. False otherwise.
*/
function wp_is_large_network( $using = 'sites' ) {
if ( 'users' == $using ) {
$count = get_user_count();
return apply_filters( 'wp_is_large_network', $count > 10000, 'users', $count );
}
$count = get_blog_count();
return apply_filters( 'wp_is_large_network', $count > 10000, 'sites', $count );
}
| 01happy-blog | trunk/myblog/wp-admin/includes/ms.php | PHP | oos | 27,256 |
<?php
// -- Post related Meta Boxes
/**
* Display post submit form fields.
*
* @since 2.7.0
*
* @param object $post
*/
function post_submit_meta_box($post) {
global $action;
$post_type = $post->post_type;
$post_type_object = get_post_type_object($post_type);
$can_publish = current_user_can($post_type_object->cap->publish_posts);
?>
<div class="submitbox" id="submitpost">
<div id="minor-publishing">
<?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key ?>
<div style="display:none;">
<?php submit_button( __( 'Save' ), 'button', 'save' ); ?>
</div>
<div id="minor-publishing-actions">
<div id="save-action">
<?php if ( 'publish' != $post->post_status && 'future' != $post->post_status && 'pending' != $post->post_status ) { ?>
<input <?php if ( 'private' == $post->post_status ) { ?>style="display:none"<?php } ?> type="submit" name="save" id="save-post" value="<?php esc_attr_e('Save Draft'); ?>" tabindex="4" class="button button-highlighted" />
<?php } elseif ( 'pending' == $post->post_status && $can_publish ) { ?>
<input type="submit" name="save" id="save-post" value="<?php esc_attr_e('Save as Pending'); ?>" tabindex="4" class="button button-highlighted" />
<?php } ?>
<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-loading" id="draft-ajax-loading" alt="" />
</div>
<?php if ( $post_type_object->public ) : ?>
<div id="preview-action">
<?php
if ( 'publish' == $post->post_status ) {
$preview_link = esc_url( get_permalink( $post->ID ) );
$preview_button = __( 'Preview Changes' );
} else {
$preview_link = get_permalink( $post->ID );
if ( is_ssl() )
$preview_link = str_replace( 'http://', 'https://', $preview_link );
$preview_link = esc_url( apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ) ) );
$preview_button = __( 'Preview' );
}
?>
<a class="preview button" href="<?php echo $preview_link; ?>" target="wp-preview" id="post-preview" tabindex="4"><?php echo $preview_button; ?></a>
<input type="hidden" name="wp-preview" id="wp-preview" value="" />
</div>
<?php endif; // public post type ?>
<div class="clear"></div>
</div><?php // /minor-publishing-actions ?>
<div id="misc-publishing-actions">
<div class="misc-pub-section"><label for="post_status"><?php _e('Status:') ?></label>
<span id="post-status-display">
<?php
switch ( $post->post_status ) {
case 'private':
_e('Privately Published');
break;
case 'publish':
_e('Published');
break;
case 'future':
_e('Scheduled');
break;
case 'pending':
_e('Pending Review');
break;
case 'draft':
case 'auto-draft':
_e('Draft');
break;
}
?>
</span>
<?php if ( 'publish' == $post->post_status || 'private' == $post->post_status || $can_publish ) { ?>
<a href="#post_status" <?php if ( 'private' == $post->post_status ) { ?>style="display:none;" <?php } ?>class="edit-post-status hide-if-no-js" tabindex='4'><?php _e('Edit') ?></a>
<div id="post-status-select" class="hide-if-js">
<input type="hidden" name="hidden_post_status" id="hidden_post_status" value="<?php echo esc_attr( ('auto-draft' == $post->post_status ) ? 'draft' : $post->post_status); ?>" />
<select name='post_status' id='post_status' tabindex='4'>
<?php if ( 'publish' == $post->post_status ) : ?>
<option<?php selected( $post->post_status, 'publish' ); ?> value='publish'><?php _e('Published') ?></option>
<?php elseif ( 'private' == $post->post_status ) : ?>
<option<?php selected( $post->post_status, 'private' ); ?> value='publish'><?php _e('Privately Published') ?></option>
<?php elseif ( 'future' == $post->post_status ) : ?>
<option<?php selected( $post->post_status, 'future' ); ?> value='future'><?php _e('Scheduled') ?></option>
<?php endif; ?>
<option<?php selected( $post->post_status, 'pending' ); ?> value='pending'><?php _e('Pending Review') ?></option>
<?php if ( 'auto-draft' == $post->post_status ) : ?>
<option<?php selected( $post->post_status, 'auto-draft' ); ?> value='draft'><?php _e('Draft') ?></option>
<?php else : ?>
<option<?php selected( $post->post_status, 'draft' ); ?> value='draft'><?php _e('Draft') ?></option>
<?php endif; ?>
</select>
<a href="#post_status" class="save-post-status hide-if-no-js button"><?php _e('OK'); ?></a>
<a href="#post_status" class="cancel-post-status hide-if-no-js"><?php _e('Cancel'); ?></a>
</div>
<?php } ?>
</div><?php // /misc-pub-section ?>
<div class="misc-pub-section" id="visibility">
<?php _e('Visibility:'); ?> <span id="post-visibility-display"><?php
if ( 'private' == $post->post_status ) {
$post->post_password = '';
$visibility = 'private';
$visibility_trans = __('Private');
} elseif ( !empty( $post->post_password ) ) {
$visibility = 'password';
$visibility_trans = __('Password protected');
} elseif ( $post_type == 'post' && is_sticky( $post->ID ) ) {
$visibility = 'public';
$visibility_trans = __('Public, Sticky');
} else {
$visibility = 'public';
$visibility_trans = __('Public');
}
echo esc_html( $visibility_trans ); ?></span>
<?php if ( $can_publish ) { ?>
<a href="#visibility" class="edit-visibility hide-if-no-js"><?php _e('Edit'); ?></a>
<div id="post-visibility-select" class="hide-if-js">
<input type="hidden" name="hidden_post_password" id="hidden-post-password" value="<?php echo esc_attr($post->post_password); ?>" />
<?php if ($post_type == 'post'): ?>
<input type="checkbox" style="display:none" name="hidden_post_sticky" id="hidden-post-sticky" value="sticky" <?php checked(is_sticky($post->ID)); ?> />
<?php endif; ?>
<input type="hidden" name="hidden_post_visibility" id="hidden-post-visibility" value="<?php echo esc_attr( $visibility ); ?>" />
<input type="radio" name="visibility" id="visibility-radio-public" value="public" <?php checked( $visibility, 'public' ); ?> /> <label for="visibility-radio-public" class="selectit"><?php _e('Public'); ?></label><br />
<?php if ( $post_type == 'post' && current_user_can( 'edit_others_posts' ) ) : ?>
<span id="sticky-span"><input id="sticky" name="sticky" type="checkbox" value="sticky" <?php checked( is_sticky( $post->ID ) ); ?> tabindex="4" /> <label for="sticky" class="selectit"><?php _e( 'Stick this post to the front page' ); ?></label><br /></span>
<?php endif; ?>
<input type="radio" name="visibility" id="visibility-radio-password" value="password" <?php checked( $visibility, 'password' ); ?> /> <label for="visibility-radio-password" class="selectit"><?php _e('Password protected'); ?></label><br />
<span id="password-span"><label for="post_password"><?php _e('Password:'); ?></label> <input type="text" name="post_password" id="post_password" value="<?php echo esc_attr($post->post_password); ?>" /><br /></span>
<input type="radio" name="visibility" id="visibility-radio-private" value="private" <?php checked( $visibility, 'private' ); ?> /> <label for="visibility-radio-private" class="selectit"><?php _e('Private'); ?></label><br />
<p>
<a href="#visibility" class="save-post-visibility hide-if-no-js button"><?php _e('OK'); ?></a>
<a href="#visibility" class="cancel-post-visibility hide-if-no-js"><?php _e('Cancel'); ?></a>
</p>
</div>
<?php } ?>
</div><?php // /misc-pub-section ?>
<?php
// translators: Publish box date format, see http://php.net/date
$datef = __( 'M j, Y @ G:i' );
if ( 0 != $post->ID ) {
if ( 'future' == $post->post_status ) { // scheduled for publishing at a future date
$stamp = __('Scheduled for: <b>%1$s</b>');
} else if ( 'publish' == $post->post_status || 'private' == $post->post_status ) { // already published
$stamp = __('Published on: <b>%1$s</b>');
} else if ( '0000-00-00 00:00:00' == $post->post_date_gmt ) { // draft, 1 or more saves, no date specified
$stamp = __('Publish <b>immediately</b>');
} else if ( time() < strtotime( $post->post_date_gmt . ' +0000' ) ) { // draft, 1 or more saves, future date specified
$stamp = __('Schedule for: <b>%1$s</b>');
} else { // draft, 1 or more saves, date specified
$stamp = __('Publish on: <b>%1$s</b>');
}
$date = date_i18n( $datef, strtotime( $post->post_date ) );
} else { // draft (no saves, and thus no date specified)
$stamp = __('Publish <b>immediately</b>');
$date = date_i18n( $datef, strtotime( current_time('mysql') ) );
}
if ( $can_publish ) : // Contributors don't get to choose the date of publish ?>
<div class="misc-pub-section curtime">
<span id="timestamp">
<?php printf($stamp, $date); ?></span>
<a href="#edit_timestamp" class="edit-timestamp hide-if-no-js" tabindex='4'><?php _e('Edit') ?></a>
<div id="timestampdiv" class="hide-if-js"><?php touch_time(($action == 'edit'),1,4); ?></div>
</div><?php // /misc-pub-section ?>
<?php endif; ?>
<?php do_action('post_submitbox_misc_actions'); ?>
</div>
<div class="clear"></div>
</div>
<div id="major-publishing-actions">
<?php do_action('post_submitbox_start'); ?>
<div id="delete-action">
<?php
if ( current_user_can( "delete_post", $post->ID ) ) {
if ( !EMPTY_TRASH_DAYS )
$delete_text = __('Delete Permanently');
else
$delete_text = __('Move to Trash');
?>
<a class="submitdelete deletion" href="<?php echo get_delete_post_link($post->ID); ?>"><?php echo $delete_text; ?></a><?php
} ?>
</div>
<div id="publishing-action">
<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-loading" id="ajax-loading" alt="" />
<?php
if ( !in_array( $post->post_status, array('publish', 'future', 'private') ) || 0 == $post->ID ) {
if ( $can_publish ) :
if ( !empty($post->post_date_gmt) && time() < strtotime( $post->post_date_gmt . ' +0000' ) ) : ?>
<input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Schedule') ?>" />
<?php submit_button( __( 'Schedule' ), 'primary', 'publish', false, array( 'tabindex' => '5', 'accesskey' => 'p' ) ); ?>
<?php else : ?>
<input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Publish') ?>" />
<?php submit_button( __( 'Publish' ), 'primary', 'publish', false, array( 'tabindex' => '5', 'accesskey' => 'p' ) ); ?>
<?php endif;
else : ?>
<input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Submit for Review') ?>" />
<?php submit_button( __( 'Submit for Review' ), 'primary', 'publish', false, array( 'tabindex' => '5', 'accesskey' => 'p' ) ); ?>
<?php
endif;
} else { ?>
<input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Update') ?>" />
<input name="save" type="submit" class="button-primary" id="publish" tabindex="5" accesskey="p" value="<?php esc_attr_e('Update') ?>" />
<?php
} ?>
</div>
<div class="clear"></div>
</div>
</div>
<?php
}
/**
* Display post format form elements.
*
* @since 3.1.0
*
* @param object $post
*/
function post_format_meta_box( $post, $box ) {
if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) ) :
$post_formats = get_theme_support( 'post-formats' );
if ( is_array( $post_formats[0] ) ) :
$post_format = get_post_format( $post->ID );
if ( !$post_format )
$post_format = '0';
// Add in the current one if it isn't there yet, in case the current theme doesn't support it
if ( $post_format && !in_array( $post_format, $post_formats[0] ) )
$post_formats[0][] = $post_format;
?>
<div id="post-formats-select">
<input type="radio" name="post_format" class="post-format" id="post-format-0" value="0" <?php checked( $post_format, '0' ); ?> /> <label for="post-format-0"><?php _e('Standard'); ?></label>
<?php foreach ( $post_formats[0] as $format ) : ?>
<br /><input type="radio" name="post_format" class="post-format" id="post-format-<?php echo esc_attr( $format ); ?>" value="<?php echo esc_attr( $format ); ?>" <?php checked( $post_format, $format ); ?> /> <label for="post-format-<?php echo esc_attr( $format ); ?>"><?php echo esc_html( get_post_format_string( $format ) ); ?></label>
<?php endforeach; ?><br />
</div>
<?php endif; endif;
}
/**
* Display post tags form fields.
*
* @since 2.6.0
*
* @param object $post
*/
function post_tags_meta_box($post, $box) {
$defaults = array('taxonomy' => 'post_tag');
if ( !isset($box['args']) || !is_array($box['args']) )
$args = array();
else
$args = $box['args'];
extract( wp_parse_args($args, $defaults), EXTR_SKIP );
$tax_name = esc_attr($taxonomy);
$taxonomy = get_taxonomy($taxonomy);
$disabled = !current_user_can($taxonomy->cap->assign_terms) ? 'disabled="disabled"' : '';
$comma = _x( ',', 'tag delimiter' );
?>
<div class="tagsdiv" id="<?php echo $tax_name; ?>">
<div class="jaxtag">
<div class="nojs-tags hide-if-js">
<p><?php echo $taxonomy->labels->add_or_remove_items; ?></p>
<textarea name="<?php echo "tax_input[$tax_name]"; ?>" rows="3" cols="20" class="the-tags" id="tax-input-<?php echo $tax_name; ?>" <?php echo $disabled; ?>><?php echo str_replace( ',', $comma . ' ', get_terms_to_edit( $post->ID, $tax_name ) ); // textarea_escaped by esc_attr() ?></textarea></div>
<?php if ( current_user_can($taxonomy->cap->assign_terms) ) : ?>
<div class="ajaxtag hide-if-no-js">
<label class="screen-reader-text" for="new-tag-<?php echo $tax_name; ?>"><?php echo $box['title']; ?></label>
<div class="taghint"><?php echo $taxonomy->labels->add_new_item; ?></div>
<p><input type="text" id="new-tag-<?php echo $tax_name; ?>" name="newtag[<?php echo $tax_name; ?>]" class="newtag form-input-tip" size="16" autocomplete="off" value="" />
<input type="button" class="button tagadd" value="<?php esc_attr_e('Add'); ?>" tabindex="3" /></p>
</div>
<p class="howto"><?php echo esc_attr( $taxonomy->labels->separate_items_with_commas ); ?></p>
<?php endif; ?>
</div>
<div class="tagchecklist"></div>
</div>
<?php if ( current_user_can($taxonomy->cap->assign_terms) ) : ?>
<p class="hide-if-no-js"><a href="#titlediv" class="tagcloud-link" id="link-<?php echo $tax_name; ?>"><?php echo $taxonomy->labels->choose_from_most_used; ?></a></p>
<?php endif; ?>
<?php
}
/**
* Display post categories form fields.
*
* @since 2.6.0
*
* @param object $post
*/
function post_categories_meta_box( $post, $box ) {
$defaults = array('taxonomy' => 'category');
if ( !isset($box['args']) || !is_array($box['args']) )
$args = array();
else
$args = $box['args'];
extract( wp_parse_args($args, $defaults), EXTR_SKIP );
$tax = get_taxonomy($taxonomy);
?>
<div id="taxonomy-<?php echo $taxonomy; ?>" class="categorydiv">
<ul id="<?php echo $taxonomy; ?>-tabs" class="category-tabs">
<li class="tabs"><a href="#<?php echo $taxonomy; ?>-all" tabindex="3"><?php echo $tax->labels->all_items; ?></a></li>
<li class="hide-if-no-js"><a href="#<?php echo $taxonomy; ?>-pop" tabindex="3"><?php _e( 'Most Used' ); ?></a></li>
</ul>
<div id="<?php echo $taxonomy; ?>-pop" class="tabs-panel" style="display: none;">
<ul id="<?php echo $taxonomy; ?>checklist-pop" class="categorychecklist form-no-clear" >
<?php $popular_ids = wp_popular_terms_checklist($taxonomy); ?>
</ul>
</div>
<div id="<?php echo $taxonomy; ?>-all" class="tabs-panel">
<?php
$name = ( $taxonomy == 'category' ) ? 'post_category' : 'tax_input[' . $taxonomy . ']';
echo "<input type='hidden' name='{$name}[]' value='0' />"; // Allows for an empty term set to be sent. 0 is an invalid Term ID and will be ignored by empty() checks.
?>
<ul id="<?php echo $taxonomy; ?>checklist" class="list:<?php echo $taxonomy?> categorychecklist form-no-clear">
<?php wp_terms_checklist($post->ID, array( 'taxonomy' => $taxonomy, 'popular_cats' => $popular_ids ) ) ?>
</ul>
</div>
<?php if ( current_user_can($tax->cap->edit_terms) ) : ?>
<div id="<?php echo $taxonomy; ?>-adder" class="wp-hidden-children">
<h4>
<a id="<?php echo $taxonomy; ?>-add-toggle" href="#<?php echo $taxonomy; ?>-add" class="hide-if-no-js" tabindex="3">
<?php
/* translators: %s: add new taxonomy label */
printf( __( '+ %s' ), $tax->labels->add_new_item );
?>
</a>
</h4>
<p id="<?php echo $taxonomy; ?>-add" class="category-add wp-hidden-child">
<label class="screen-reader-text" for="new<?php echo $taxonomy; ?>"><?php echo $tax->labels->add_new_item; ?></label>
<input type="text" name="new<?php echo $taxonomy; ?>" id="new<?php echo $taxonomy; ?>" class="form-required form-input-tip" value="<?php echo esc_attr( $tax->labels->new_item_name ); ?>" tabindex="3" aria-required="true"/>
<label class="screen-reader-text" for="new<?php echo $taxonomy; ?>_parent">
<?php echo $tax->labels->parent_item_colon; ?>
</label>
<?php wp_dropdown_categories( array( 'taxonomy' => $taxonomy, 'hide_empty' => 0, 'name' => 'new'.$taxonomy.'_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => '— ' . $tax->labels->parent_item . ' —', 'tab_index' => 3 ) ); ?>
<input type="button" id="<?php echo $taxonomy; ?>-add-submit" class="add:<?php echo $taxonomy ?>checklist:<?php echo $taxonomy ?>-add button category-add-submit" value="<?php echo esc_attr( $tax->labels->add_new_item ); ?>" tabindex="3" />
<?php wp_nonce_field( 'add-'.$taxonomy, '_ajax_nonce-add-'.$taxonomy, false ); ?>
<span id="<?php echo $taxonomy; ?>-ajax-response"></span>
</p>
</div>
<?php endif; ?>
</div>
<?php
}
/**
* Display post excerpt form fields.
*
* @since 2.6.0
*
* @param object $post
*/
function post_excerpt_meta_box($post) {
?>
<label class="screen-reader-text" for="excerpt"><?php _e('Excerpt') ?></label><textarea rows="1" cols="40" name="excerpt" tabindex="6" id="excerpt"><?php echo $post->post_excerpt; // textarea_escaped ?></textarea>
<p><?php _e('Excerpts are optional hand-crafted summaries of your content that can be used in your theme. <a href="http://codex.wordpress.org/Excerpt" target="_blank">Learn more about manual excerpts.</a>'); ?></p>
<?php
}
/**
* Display trackback links form fields.
*
* @since 2.6.0
*
* @param object $post
*/
function post_trackback_meta_box($post) {
$form_trackback = '<input type="text" name="trackback_url" id="trackback_url" class="code" tabindex="7" value="'. esc_attr( str_replace("\n", ' ', $post->to_ping) ) .'" />';
if ('' != $post->pinged) {
$pings = '<p>'. __('Already pinged:') . '</p><ul>';
$already_pinged = explode("\n", trim($post->pinged));
foreach ($already_pinged as $pinged_url) {
$pings .= "\n\t<li>" . esc_html($pinged_url) . "</li>";
}
$pings .= '</ul>';
}
?>
<p><label for="trackback_url"><?php _e('Send trackbacks to:'); ?></label> <?php echo $form_trackback; ?><br /> (<?php _e('Separate multiple URLs with spaces'); ?>)</p>
<p><?php _e('Trackbacks are a way to notify legacy blog systems that you’ve linked to them. If you link other WordPress sites they’ll be notified automatically using <a href="http://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments" target="_blank">pingbacks</a>, no other action necessary.'); ?></p>
<?php
if ( ! empty($pings) )
echo $pings;
}
/**
* Display custom fields form fields.
*
* @since 2.6.0
*
* @param object $post
*/
function post_custom_meta_box($post) {
?>
<div id="postcustomstuff">
<div id="ajax-response"></div>
<?php
$metadata = has_meta($post->ID);
foreach ( $metadata as $key => $value ) {
if ( is_protected_meta( $metadata[ $key ][ 'meta_key' ], 'post' ) || ! current_user_can( 'edit_post_meta', $post->ID, $metadata[ $key ][ 'meta_key' ] ) )
unset( $metadata[ $key ] );
}
list_meta( $metadata );
meta_form(); ?>
</div>
<p><?php _e('Custom fields can be used to add extra metadata to a post that you can <a href="http://codex.wordpress.org/Using_Custom_Fields" target="_blank">use in your theme</a>.'); ?></p>
<?php
}
/**
* Display comments status form fields.
*
* @since 2.6.0
*
* @param object $post
*/
function post_comment_status_meta_box($post) {
?>
<input name="advanced_view" type="hidden" value="1" />
<p class="meta-options">
<label for="comment_status" class="selectit"><input name="comment_status" type="checkbox" id="comment_status" value="open" <?php checked($post->comment_status, 'open'); ?> /> <?php _e( 'Allow comments.' ) ?></label><br />
<label for="ping_status" class="selectit"><input name="ping_status" type="checkbox" id="ping_status" value="open" <?php checked($post->ping_status, 'open'); ?> /> <?php printf( __( 'Allow <a href="%s" target="_blank">trackbacks and pingbacks</a> on this page.' ), __( 'http://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments' ) ); ?></label>
<?php do_action('post_comment_status_meta_box-options', $post); ?>
</p>
<?php
}
/**
* Display comments for post table header
*
* @since 3.0.0
*
* @param array $result table header rows
* @return array
*/
function post_comment_meta_box_thead($result) {
unset($result['cb'], $result['response']);
return $result;
}
/**
* Display comments for post.
*
* @since 2.8.0
*
* @param object $post
*/
function post_comment_meta_box($post) {
global $wpdb, $post_ID;
wp_nonce_field( 'get-comments', 'add_comment_nonce', false );
?>
<p class="hide-if-no-js" id="add-new-comment"><a href="#commentstatusdiv" onclick="commentReply.addcomment(<?php echo $post_ID; ?>);return false;"><?php _e('Add comment'); ?></a></p>
<?php
$total = $wpdb->get_var($wpdb->prepare("SELECT count(1) FROM $wpdb->comments WHERE comment_post_ID = '%d' AND ( comment_approved = '0' OR comment_approved = '1')", $post_ID));
$wp_list_table = _get_list_table('WP_Post_Comments_List_Table');
$wp_list_table->display( true );
if ( 1 > $total ) {
echo '<p id="no-comments">' . __('No comments yet.') . '</p>';
} else {
$hidden = get_hidden_meta_boxes( get_current_screen() );
if ( ! in_array('commentsdiv', $hidden) ) {
?>
<script type="text/javascript">jQuery(document).ready(function(){commentsBox.get(<?php echo $total; ?>, 10);});</script>
<?php
}
?>
<p class="hide-if-no-js" id="show-comments"><a href="#commentstatusdiv" onclick="commentsBox.get(<?php echo $total; ?>);return false;"><?php _e('Show comments'); ?></a> <img class="waiting" style="display:none;" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" /></p>
<?php
}
wp_comment_trashnotice();
}
/**
* Display slug form fields.
*
* @since 2.6.0
*
* @param object $post
*/
function post_slug_meta_box($post) {
?>
<label class="screen-reader-text" for="post_name"><?php _e('Slug') ?></label><input name="post_name" type="text" size="13" id="post_name" value="<?php echo esc_attr( apply_filters('editable_slug', $post->post_name) ); ?>" />
<?php
}
/**
* Display form field with list of authors.
*
* @since 2.6.0
*
* @param object $post
*/
function post_author_meta_box($post) {
global $user_ID;
?>
<label class="screen-reader-text" for="post_author_override"><?php _e('Author'); ?></label>
<?php
wp_dropdown_users( array(
'who' => 'authors',
'name' => 'post_author_override',
'selected' => empty($post->ID) ? $user_ID : $post->post_author,
'include_selected' => true
) );
}
/**
* Display list of revisions.
*
* @since 2.6.0
*
* @param object $post
*/
function post_revisions_meta_box($post) {
wp_list_post_revisions();
}
// -- Page related Meta Boxes
/**
* Display page attributes form fields.
*
* @since 2.7.0
*
* @param object $post
*/
function page_attributes_meta_box($post) {
$post_type_object = get_post_type_object($post->post_type);
if ( $post_type_object->hierarchical ) {
$dropdown_args = array(
'post_type' => $post->post_type,
'exclude_tree' => $post->ID,
'selected' => $post->post_parent,
'name' => 'parent_id',
'show_option_none' => __('(no parent)'),
'sort_column' => 'menu_order, post_title',
'echo' => 0,
);
$dropdown_args = apply_filters( 'page_attributes_dropdown_pages_args', $dropdown_args, $post );
$pages = wp_dropdown_pages( $dropdown_args );
if ( ! empty($pages) ) {
?>
<p><strong><?php _e('Parent') ?></strong></p>
<label class="screen-reader-text" for="parent_id"><?php _e('Parent') ?></label>
<?php echo $pages; ?>
<?php
} // end empty pages check
} // end hierarchical check.
if ( 'page' == $post->post_type && 0 != count( get_page_templates() ) ) {
$template = !empty($post->page_template) ? $post->page_template : false;
?>
<p><strong><?php _e('Template') ?></strong></p>
<label class="screen-reader-text" for="page_template"><?php _e('Page Template') ?></label><select name="page_template" id="page_template">
<option value='default'><?php _e('Default Template'); ?></option>
<?php page_template_dropdown($template); ?>
</select>
<?php
} ?>
<p><strong><?php _e('Order') ?></strong></p>
<p><label class="screen-reader-text" for="menu_order"><?php _e('Order') ?></label><input name="menu_order" type="text" size="4" id="menu_order" value="<?php echo esc_attr($post->menu_order) ?>" /></p>
<p><?php if ( 'page' == $post->post_type ) _e( 'Need help? Use the Help tab in the upper right of your screen.' ); ?></p>
<?php
}
// -- Link related Meta Boxes
/**
* Display link create form fields.
*
* @since 2.7.0
*
* @param object $link
*/
function link_submit_meta_box($link) {
?>
<div class="submitbox" id="submitlink">
<div id="minor-publishing">
<?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key ?>
<div style="display:none;">
<?php submit_button( __( 'Save' ), 'button', 'save', false ); ?>
</div>
<div id="minor-publishing-actions">
<div id="preview-action">
<?php if ( !empty($link->link_id) ) { ?>
<a class="preview button" href="<?php echo $link->link_url; ?>" target="_blank" tabindex="4"><?php _e('Visit Link'); ?></a>
<?php } ?>
</div>
<div class="clear"></div>
</div>
<div id="misc-publishing-actions">
<div class="misc-pub-section">
<label for="link_private" class="selectit"><input id="link_private" name="link_visible" type="checkbox" value="N" <?php checked($link->link_visible, 'N'); ?> /> <?php _e('Keep this link private') ?></label>
</div>
</div>
</div>
<div id="major-publishing-actions">
<?php do_action('post_submitbox_start'); ?>
<div id="delete-action">
<?php
if ( !empty($_GET['action']) && 'edit' == $_GET['action'] && current_user_can('manage_links') ) { ?>
<a class="submitdelete deletion" href="<?php echo wp_nonce_url("link.php?action=delete&link_id=$link->link_id", 'delete-bookmark_' . $link->link_id); ?>" onclick="if ( confirm('<?php echo esc_js(sprintf(__("You are about to delete this link '%s'\n 'Cancel' to stop, 'OK' to delete."), $link->link_name )); ?>') ) {return true;}return false;"><?php _e('Delete'); ?></a>
<?php } ?>
</div>
<div id="publishing-action">
<?php if ( !empty($link->link_id) ) { ?>
<input name="save" type="submit" class="button-primary" id="publish" tabindex="4" accesskey="p" value="<?php esc_attr_e('Update Link') ?>" />
<?php } else { ?>
<input name="save" type="submit" class="button-primary" id="publish" tabindex="4" accesskey="p" value="<?php esc_attr_e('Add Link') ?>" />
<?php } ?>
</div>
<div class="clear"></div>
</div>
<?php do_action('submitlink_box'); ?>
<div class="clear"></div>
</div>
<?php
}
/**
* Display link categories form fields.
*
* @since 2.6.0
*
* @param object $link
*/
function link_categories_meta_box($link) {
?>
<div id="taxonomy-linkcategory" class="categorydiv">
<ul id="category-tabs" class="category-tabs">
<li class="tabs"><a href="#categories-all"><?php _e( 'All Categories' ); ?></a></li>
<li class="hide-if-no-js"><a href="#categories-pop"><?php _e( 'Most Used' ); ?></a></li>
</ul>
<div id="categories-all" class="tabs-panel">
<ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
<?php
if ( isset($link->link_id) )
wp_link_category_checklist($link->link_id);
else
wp_link_category_checklist();
?>
</ul>
</div>
<div id="categories-pop" class="tabs-panel" style="display: none;">
<ul id="categorychecklist-pop" class="categorychecklist form-no-clear">
<?php wp_popular_terms_checklist('link_category'); ?>
</ul>
</div>
<div id="category-adder" class="wp-hidden-children">
<h4><a id="category-add-toggle" href="#category-add"><?php _e( '+ Add New Category' ); ?></a></h4>
<p id="link-category-add" class="wp-hidden-child">
<label class="screen-reader-text" for="newcat"><?php _e( '+ Add New Category' ); ?></label>
<input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php esc_attr_e( 'New category name' ); ?>" aria-required="true" />
<input type="button" id="category-add-submit" class="add:categorychecklist:linkcategorydiv button" value="<?php esc_attr_e( 'Add' ); ?>" />
<?php wp_nonce_field( 'add-link-category', '_ajax_nonce', false ); ?>
<span id="category-ajax-response"></span>
</p>
</div>
</div>
<?php
}
/**
* Display form fields for changing link target.
*
* @since 2.6.0
*
* @param object $link
*/
function link_target_meta_box($link) { ?>
<fieldset><legend class="screen-reader-text"><span><?php _e('Target') ?></span></legend>
<p><label for="link_target_blank" class="selectit">
<input id="link_target_blank" type="radio" name="link_target" value="_blank" <?php echo ( isset( $link->link_target ) && ($link->link_target == '_blank') ? 'checked="checked"' : ''); ?> />
<?php _e('<code>_blank</code> — new window or tab.'); ?></label></p>
<p><label for="link_target_top" class="selectit">
<input id="link_target_top" type="radio" name="link_target" value="_top" <?php echo ( isset( $link->link_target ) && ($link->link_target == '_top') ? 'checked="checked"' : ''); ?> />
<?php _e('<code>_top</code> — current window or tab, with no frames.'); ?></label></p>
<p><label for="link_target_none" class="selectit">
<input id="link_target_none" type="radio" name="link_target" value="" <?php echo ( isset( $link->link_target ) && ($link->link_target == '') ? 'checked="checked"' : ''); ?> />
<?php _e('<code>_none</code> — same window or tab.'); ?></label></p>
</fieldset>
<p><?php _e('Choose the target frame for your link.'); ?></p>
<?php
}
/**
* Display checked checkboxes attribute for xfn microformat options.
*
* @since 1.0.1
*
* @param string $class
* @param string $value
* @param mixed $deprecated Never used.
*/
function xfn_check( $class, $value = '', $deprecated = '' ) {
global $link;
if ( !empty( $deprecated ) )
_deprecated_argument( __FUNCTION__, '0.0' ); // Never implemented
$link_rel = isset( $link->link_rel ) ? $link->link_rel : ''; // In PHP 5.3: $link_rel = $link->link_rel ?: '';
$rels = preg_split('/\s+/', $link_rel);
if ('' != $value && in_array($value, $rels) ) {
echo ' checked="checked"';
}
if ('' == $value) {
if ('family' == $class && strpos($link_rel, 'child') === false && strpos($link_rel, 'parent') === false && strpos($link_rel, 'sibling') === false && strpos($link_rel, 'spouse') === false && strpos($link_rel, 'kin') === false) echo ' checked="checked"';
if ('friendship' == $class && strpos($link_rel, 'friend') === false && strpos($link_rel, 'acquaintance') === false && strpos($link_rel, 'contact') === false) echo ' checked="checked"';
if ('geographical' == $class && strpos($link_rel, 'co-resident') === false && strpos($link_rel, 'neighbor') === false) echo ' checked="checked"';
if ('identity' == $class && in_array('me', $rels) ) echo ' checked="checked"';
}
}
/**
* Display xfn form fields.
*
* @since 2.6.0
*
* @param object $link
*/
function link_xfn_meta_box($link) {
?>
<table class="links-table" cellspacing="0">
<tr>
<th scope="row"><label for="link_rel"><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('rel:') ?></label></th>
<td><input type="text" name="link_rel" id="link_rel" value="<?php echo ( isset( $link->link_rel ) ? esc_attr($link->link_rel) : ''); ?>" /></td>
</tr>
<tr>
<th scope="row"><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('identity') ?></th>
<td><fieldset><legend class="screen-reader-text"><span><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('identity') ?></span></legend>
<label for="me">
<input type="checkbox" name="identity" value="me" id="me" <?php xfn_check('identity', 'me'); ?> />
<?php _e('another web address of mine') ?></label>
</fieldset></td>
</tr>
<tr>
<th scope="row"><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('friendship') ?></th>
<td><fieldset><legend class="screen-reader-text"><span><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('friendship') ?></span></legend>
<label for="contact">
<input class="valinp" type="radio" name="friendship" value="contact" id="contact" <?php xfn_check('friendship', 'contact'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('contact') ?>
</label>
<label for="acquaintance">
<input class="valinp" type="radio" name="friendship" value="acquaintance" id="acquaintance" <?php xfn_check('friendship', 'acquaintance'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('acquaintance') ?>
</label>
<label for="friend">
<input class="valinp" type="radio" name="friendship" value="friend" id="friend" <?php xfn_check('friendship', 'friend'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('friend') ?>
</label>
<label for="friendship">
<input name="friendship" type="radio" class="valinp" value="" id="friendship" <?php xfn_check('friendship'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('none') ?>
</label>
</fieldset></td>
</tr>
<tr>
<th scope="row"> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('physical') ?> </th>
<td><fieldset><legend class="screen-reader-text"><span><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('physical') ?></span></legend>
<label for="met">
<input class="valinp" type="checkbox" name="physical" value="met" id="met" <?php xfn_check('physical', 'met'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('met') ?>
</label>
</fieldset></td>
</tr>
<tr>
<th scope="row"> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('professional') ?> </th>
<td><fieldset><legend class="screen-reader-text"><span><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('professional') ?></span></legend>
<label for="co-worker">
<input class="valinp" type="checkbox" name="professional" value="co-worker" id="co-worker" <?php xfn_check('professional', 'co-worker'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('co-worker') ?>
</label>
<label for="colleague">
<input class="valinp" type="checkbox" name="professional" value="colleague" id="colleague" <?php xfn_check('professional', 'colleague'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('colleague') ?>
</label>
</fieldset></td>
</tr>
<tr>
<th scope="row"><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('geographical') ?></th>
<td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('geographical') ?> </span></legend>
<label for="co-resident">
<input class="valinp" type="radio" name="geographical" value="co-resident" id="co-resident" <?php xfn_check('geographical', 'co-resident'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('co-resident') ?>
</label>
<label for="neighbor">
<input class="valinp" type="radio" name="geographical" value="neighbor" id="neighbor" <?php xfn_check('geographical', 'neighbor'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('neighbor') ?>
</label>
<label for="geographical">
<input class="valinp" type="radio" name="geographical" value="" id="geographical" <?php xfn_check('geographical'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('none') ?>
</label>
</fieldset></td>
</tr>
<tr>
<th scope="row"><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('family') ?></th>
<td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('family') ?> </span></legend>
<label for="child">
<input class="valinp" type="radio" name="family" value="child" id="child" <?php xfn_check('family', 'child'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('child') ?>
</label>
<label for="kin">
<input class="valinp" type="radio" name="family" value="kin" id="kin" <?php xfn_check('family', 'kin'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('kin') ?>
</label>
<label for="parent">
<input class="valinp" type="radio" name="family" value="parent" id="parent" <?php xfn_check('family', 'parent'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('parent') ?>
</label>
<label for="sibling">
<input class="valinp" type="radio" name="family" value="sibling" id="sibling" <?php xfn_check('family', 'sibling'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('sibling') ?>
</label>
<label for="spouse">
<input class="valinp" type="radio" name="family" value="spouse" id="spouse" <?php xfn_check('family', 'spouse'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('spouse') ?>
</label>
<label for="family">
<input class="valinp" type="radio" name="family" value="" id="family" <?php xfn_check('family'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('none') ?>
</label>
</fieldset></td>
</tr>
<tr>
<th scope="row"><?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('romantic') ?></th>
<td><fieldset><legend class="screen-reader-text"><span> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('romantic') ?> </span></legend>
<label for="muse">
<input class="valinp" type="checkbox" name="romantic" value="muse" id="muse" <?php xfn_check('romantic', 'muse'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('muse') ?>
</label>
<label for="crush">
<input class="valinp" type="checkbox" name="romantic" value="crush" id="crush" <?php xfn_check('romantic', 'crush'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('crush') ?>
</label>
<label for="date">
<input class="valinp" type="checkbox" name="romantic" value="date" id="date" <?php xfn_check('romantic', 'date'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('date') ?>
</label>
<label for="romantic">
<input class="valinp" type="checkbox" name="romantic" value="sweetheart" id="romantic" <?php xfn_check('romantic', 'sweetheart'); ?> /> <?php /* translators: xfn: http://gmpg.org/xfn/ */ _e('sweetheart') ?>
</label>
</fieldset></td>
</tr>
</table>
<p><?php _e('If the link is to a person, you can specify your relationship with them using the above form. If you would like to learn more about the idea check out <a href="http://gmpg.org/xfn/">XFN</a>.'); ?></p>
<?php
}
/**
* Display advanced link options form fields.
*
* @since 2.6.0
*
* @param object $link
*/
function link_advanced_meta_box($link) {
?>
<table class="links-table" cellpadding="0">
<tr>
<th scope="row"><label for="link_image"><?php _e('Image Address') ?></label></th>
<td><input type="text" name="link_image" class="code" id="link_image" value="<?php echo ( isset( $link->link_image ) ? esc_attr($link->link_image) : ''); ?>" /></td>
</tr>
<tr>
<th scope="row"><label for="rss_uri"><?php _e('RSS Address') ?></label></th>
<td><input name="link_rss" class="code" type="text" id="rss_uri" value="<?php echo ( isset( $link->link_rss ) ? esc_attr($link->link_rss) : ''); ?>" /></td>
</tr>
<tr>
<th scope="row"><label for="link_notes"><?php _e('Notes') ?></label></th>
<td><textarea name="link_notes" id="link_notes" rows="10"><?php echo ( isset( $link->link_notes ) ? $link->link_notes : ''); // textarea_escaped ?></textarea></td>
</tr>
<tr>
<th scope="row"><label for="link_rating"><?php _e('Rating') ?></label></th>
<td><select name="link_rating" id="link_rating" size="1">
<?php
for ( $r = 0; $r <= 10; $r++ ) {
echo '<option value="' . $r . '"';
if ( isset($link->link_rating) && $link->link_rating == $r )
echo ' selected="selected"';
echo('>' . $r . '</option>');
}
?></select> <?php _e('(Leave at 0 for no rating.)') ?>
</td>
</tr>
</table>
<?php
}
/**
* Display post thumbnail meta box.
*
* @since 2.9.0
*/
function post_thumbnail_meta_box() {
global $post;
$thumbnail_id = get_post_meta( $post->ID, '_thumbnail_id', true );
echo _wp_post_thumbnail_html( $thumbnail_id );
}
| 01happy-blog | trunk/myblog/wp-admin/includes/meta-boxes.php | PHP | oos | 40,560 |
<?php
/**
* WordPress Administration Media API.
*
* @package WordPress
* @subpackage Administration
*/
/**
* {@internal Missing Short Description}}
*
* @since 2.5.0
*
* @return unknown
*/
function media_upload_tabs() {
$_default_tabs = array(
'type' => __('From Computer'), // handler action suffix => tab text
'type_url' => __('From URL'),
'gallery' => __('Gallery'),
'library' => __('Media Library')
);
return apply_filters('media_upload_tabs', $_default_tabs);
}
/**
* {@internal Missing Short Description}}
*
* @since 2.5.0
*
* @param unknown_type $tabs
* @return unknown
*/
function update_gallery_tab($tabs) {
global $wpdb;
if ( !isset($_REQUEST['post_id']) ) {
unset($tabs['gallery']);
return $tabs;
}
$post_id = intval($_REQUEST['post_id']);
if ( $post_id )
$attachments = intval( $wpdb->get_var( $wpdb->prepare( "SELECT count(*) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' AND post_parent = %d", $post_id ) ) );
if ( empty($attachments) ) {
unset($tabs['gallery']);
return $tabs;
}
$tabs['gallery'] = sprintf(__('Gallery (%s)'), "<span id='attachments-count'>$attachments</span>");
return $tabs;
}
add_filter('media_upload_tabs', 'update_gallery_tab');
/**
* {@internal Missing Short Description}}
*
* @since 2.5.0
*/
function the_media_upload_tabs() {
global $redir_tab;
$tabs = media_upload_tabs();
$default = 'type';
if ( !empty($tabs) ) {
echo "<ul id='sidemenu'>\n";
if ( isset($redir_tab) && array_key_exists($redir_tab, $tabs) )
$current = $redir_tab;
elseif ( isset($_GET['tab']) && array_key_exists($_GET['tab'], $tabs) )
$current = $_GET['tab'];
else
$current = apply_filters('media_upload_default_tab', $default);
foreach ( $tabs as $callback => $text ) {
$class = '';
if ( $current == $callback )
$class = " class='current'";
$href = add_query_arg(array('tab' => $callback, 's' => false, 'paged' => false, 'post_mime_type' => false, 'm' => false));
$link = "<a href='" . esc_url($href) . "'$class>$text</a>";
echo "\t<li id='" . esc_attr("tab-$callback") . "'>$link</li>\n";
}
echo "</ul>\n";
}
}
/**
* {@internal Missing Short Description}}
*
* @since 2.5.0
*
* @param unknown_type $id
* @param unknown_type $alt
* @param unknown_type $title
* @param unknown_type $align
* @param unknown_type $url
* @param unknown_type $rel
* @param unknown_type $size
* @return unknown
*/
function get_image_send_to_editor($id, $caption, $title, $align, $url='', $rel = false, $size='medium', $alt = '') {
$html = get_image_tag($id, $alt, $title, $align, $size);
$rel = $rel ? ' rel="attachment wp-att-' . esc_attr($id).'"' : '';
if ( $url )
$html = '<a href="' . esc_attr($url) . "\"$rel>$html</a>";
$html = apply_filters( 'image_send_to_editor', $html, $id, $caption, $title, $align, $url, $size, $alt );
return $html;
}
/**
* {@internal Missing Short Description}}
*
* @since 2.6.0
*
* @param unknown_type $html
* @param unknown_type $id
* @param unknown_type $alt
* @param unknown_type $title
* @param unknown_type $align
* @param unknown_type $url
* @param unknown_type $size
* @return unknown
*/
function image_add_caption( $html, $id, $caption, $title, $align, $url, $size, $alt = '' ) {
if ( empty($caption) || apply_filters( 'disable_captions', '' ) )
return $html;
$id = ( 0 < (int) $id ) ? 'attachment_' . $id : '';
if ( ! preg_match( '/width=["\']([0-9]+)/', $html, $matches ) )
return $html;
$width = $matches[1];
$caption = str_replace( array("\r\n", "\r"), "\n", $caption);
$caption = preg_replace_callback( '/<[a-zA-Z0-9]+(?: [^<>]+>)*/', '_cleanup_image_add_caption', $caption );
// convert any remaining line breaks to <br>
$caption = preg_replace( '/[ \n\t]*\n[ \t]*/', '<br />', $caption );
$html = preg_replace( '/(class=["\'][^\'"]*)align(none|left|right|center)\s?/', '$1', $html );
if ( empty($align) )
$align = 'none';
$shcode = '[caption id="' . $id . '" align="align' . $align . '" width="' . $width . '"]' . $html . ' ' . $caption . '[/caption]';
return apply_filters( 'image_add_caption_shortcode', $shcode, $html );
}
add_filter( 'image_send_to_editor', 'image_add_caption', 20, 8 );
/**
* Private preg_replace callback used in image_add_caption()
*
* @access private
* @since 3.4.0
*/
function _cleanup_image_add_caption( $matches ) {
// remove any line breaks from inside the tags
return preg_replace( '/[\r\n\t]+/', ' ', $matches[0] );
}
/**
* {@internal Missing Short Description}}
*
* @since 2.5.0
*
* @param unknown_type $html
*/
function media_send_to_editor($html) {
?>
<script type="text/javascript">
/* <![CDATA[ */
var win = window.dialogArguments || opener || parent || top;
win.send_to_editor('<?php echo addslashes($html); ?>');
/* ]]> */
</script>
<?php
exit;
}
/**
* {@internal Missing Short Description}}
*
* This handles the file upload POST itself, creating the attachment post.
*
* @since 2.5.0
*
* @param string $file_id Index into the {@link $_FILES} array of the upload
* @param int $post_id The post ID the media is associated with
* @param array $post_data allows you to overwrite some of the attachment
* @param array $overrides allows you to override the {@link wp_handle_upload()} behavior
* @return int the ID of the attachment
*/
function media_handle_upload($file_id, $post_id, $post_data = array(), $overrides = array( 'test_form' => false )) {
$time = current_time('mysql');
if ( $post = get_post($post_id) ) {
if ( substr( $post->post_date, 0, 4 ) > 0 )
$time = $post->post_date;
}
$name = $_FILES[$file_id]['name'];
$file = wp_handle_upload($_FILES[$file_id], $overrides, $time);
if ( isset($file['error']) )
return new WP_Error( 'upload_error', $file['error'] );
$name_parts = pathinfo($name);
$name = trim( substr( $name, 0, -(1 + strlen($name_parts['extension'])) ) );
$url = $file['url'];
$type = $file['type'];
$file = $file['file'];
$title = $name;
$content = '';
// use image exif/iptc data for title and caption defaults if possible
if ( $image_meta = @wp_read_image_metadata($file) ) {
if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) )
$title = $image_meta['title'];
if ( trim( $image_meta['caption'] ) )
$content = $image_meta['caption'];
}
// Construct the attachment array
$attachment = array_merge( array(
'post_mime_type' => $type,
'guid' => $url,
'post_parent' => $post_id,
'post_title' => $title,
'post_content' => $content,
), $post_data );
// This should never be set as it would then overwrite an existing attachment.
if ( isset( $attachment['ID'] ) )
unset( $attachment['ID'] );
// Save the data
$id = wp_insert_attachment($attachment, $file, $post_id);
if ( !is_wp_error($id) ) {
wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) );
}
return $id;
}
/**
* This handles a sideloaded file in the same way as an uploaded file is handled by {@link media_handle_upload()}
*
* @since 2.6.0
*
* @param array $file_array Array similar to a {@link $_FILES} upload array
* @param int $post_id The post ID the media is associated with
* @param string $desc Description of the sideloaded file
* @param array $post_data allows you to overwrite some of the attachment
* @return int|object The ID of the attachment or a WP_Error on failure
*/
function media_handle_sideload($file_array, $post_id, $desc = null, $post_data = array()) {
$overrides = array('test_form'=>false);
$file = wp_handle_sideload($file_array, $overrides);
if ( isset($file['error']) )
return new WP_Error( 'upload_error', $file['error'] );
$url = $file['url'];
$type = $file['type'];
$file = $file['file'];
$title = preg_replace('/\.[^.]+$/', '', basename($file));
$content = '';
// use image exif/iptc data for title and caption defaults if possible
if ( $image_meta = @wp_read_image_metadata($file) ) {
if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) )
$title = $image_meta['title'];
if ( trim( $image_meta['caption'] ) )
$content = $image_meta['caption'];
}
if ( isset( $desc ) )
$title = $desc;
// Construct the attachment array
$attachment = array_merge( array(
'post_mime_type' => $type,
'guid' => $url,
'post_parent' => $post_id,
'post_title' => $title,
'post_content' => $content,
), $post_data );
// This should never be set as it would then overwrite an existing attachment.
if ( isset( $attachment['ID'] ) )
unset( $attachment['ID'] );
// Save the attachment metadata
$id = wp_insert_attachment($attachment, $file, $post_id);
if ( !is_wp_error($id) )
wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) );
return $id;
}
/**
* {@internal Missing Short Description}}
*
* Wrap iframe content (produced by $content_func) in a doctype, html head/body
* etc any additional function args will be passed to content_func.
*
* @since 2.5.0
*
* @param unknown_type $content_func
*/
function wp_iframe($content_func /* ... */) {
_wp_admin_html_begin();
?>
<title><?php bloginfo('name') ?> › <?php _e('Uploads'); ?> — <?php _e('WordPress'); ?></title>
<?php
wp_enqueue_style( 'colors' );
// Check callback name for 'media'
if ( ( is_array( $content_func ) && ! empty( $content_func[1] ) && 0 === strpos( (string) $content_func[1], 'media' ) )
|| ( ! is_array( $content_func ) && 0 === strpos( $content_func, 'media' ) ) )
wp_enqueue_style( 'media' );
wp_enqueue_style( 'ie' );
?>
<script type="text/javascript">
//<![CDATA[
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();}}};
var userSettings = {'url':'<?php echo SITECOOKIEPATH; ?>','uid':'<?php if ( ! isset($current_user) ) $current_user = wp_get_current_user(); echo $current_user->ID; ?>','time':'<?php echo time(); ?>'};
var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>', pagenow = 'media-upload-popup', adminpage = 'media-upload-popup',
isRtl = <?php echo (int) is_rtl(); ?>;
//]]>
</script>
<?php
do_action('admin_enqueue_scripts', 'media-upload-popup');
do_action('admin_print_styles-media-upload-popup');
do_action('admin_print_styles');
do_action('admin_print_scripts-media-upload-popup');
do_action('admin_print_scripts');
do_action('admin_head-media-upload-popup');
do_action('admin_head');
if ( is_string($content_func) )
do_action( "admin_head_{$content_func}" );
?>
</head>
<body<?php if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?> class="no-js">
<script type="text/javascript">
document.body.className = document.body.className.replace('no-js', 'js');
</script>
<?php
$args = func_get_args();
$args = array_slice($args, 1);
call_user_func_array($content_func, $args);
do_action('admin_print_footer_scripts');
?>
<script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script>
</body>
</html>
<?php
}
/**
* {@internal Missing Short Description}}
*
* @since 2.5.0
*/
function media_buttons($editor_id = 'content') {
$context = apply_filters('media_buttons_context', __('Upload/Insert %s'));
$img = '<img src="' . esc_url( admin_url( 'images/media-button.png?ver=20111005' ) ) . '" width="15" height="15" />';
echo '<a href="' . esc_url( get_upload_iframe_src() ) . '" class="thickbox add_media" id="' . esc_attr( $editor_id ) . '-add_media" title="' . esc_attr__( 'Add Media' ) . '" onclick="return false;">' . sprintf( $context, $img ) . '</a>';
}
add_action( 'media_buttons', 'media_buttons' );
function _media_button($title, $icon, $type, $id) {
return "<a href='" . esc_url( get_upload_iframe_src($type) ) . "' id='{$id}-add_{$type}' class='thickbox add_$type' title='" . esc_attr( $title ) . "'><img src='" . esc_url( admin_url( $icon ) ) . "' alt='$title' onclick='return false;' /></a>";
}
function get_upload_iframe_src( $type = null, $post_id = null, $tab = null ) {
global $post_ID;
if ( empty( $post_id ) )
$post_id = $post_ID;
$upload_iframe_src = add_query_arg( 'post_id', (int) $post_id, admin_url('media-upload.php') );
if ( $type && 'media' != $type )
$upload_iframe_src = add_query_arg('type', $type, $upload_iframe_src);
if ( ! empty( $tab ) )
$upload_iframe_src = add_query_arg('tab', $tab, $upload_iframe_src);
$upload_iframe_src = apply_filters($type . '_upload_iframe_src', $upload_iframe_src);
return add_query_arg('TB_iframe', true, $upload_iframe_src);
}
/**
* {@internal Missing Short Description}}
*
* @since 2.5.0
*
* @return unknown
*/
function media_upload_form_handler() {
check_admin_referer('media-form');
$errors = null;
if ( isset($_POST['send']) ) {
$keys = array_keys($_POST['send']);
$send_id = (int) array_shift($keys);
}
if ( !empty($_POST['attachments']) ) foreach ( $_POST['attachments'] as $attachment_id => $attachment ) {
$post = $_post = get_post($attachment_id, ARRAY_A);
$post_type_object = get_post_type_object( $post[ 'post_type' ] );
if ( !current_user_can( $post_type_object->cap->edit_post, $attachment_id ) )
continue;
if ( isset($attachment['post_content']) )
$post['post_content'] = $attachment['post_content'];
if ( isset($attachment['post_title']) )
$post['post_title'] = $attachment['post_title'];
if ( isset($attachment['post_excerpt']) )
$post['post_excerpt'] = $attachment['post_excerpt'];
if ( isset($attachment['menu_order']) )
$post['menu_order'] = $attachment['menu_order'];
if ( isset($send_id) && $attachment_id == $send_id ) {
if ( isset($attachment['post_parent']) )
$post['post_parent'] = $attachment['post_parent'];
}
$post = apply_filters('attachment_fields_to_save', $post, $attachment);
if ( isset($attachment['image_alt']) ) {
$image_alt = get_post_meta($attachment_id, '_wp_attachment_image_alt', true);
if ( $image_alt != stripslashes($attachment['image_alt']) ) {
$image_alt = wp_strip_all_tags( stripslashes($attachment['image_alt']), true );
// update_meta expects slashed
update_post_meta( $attachment_id, '_wp_attachment_image_alt', addslashes($image_alt) );
}
}
if ( isset($post['errors']) ) {
$errors[$attachment_id] = $post['errors'];
unset($post['errors']);
}
if ( $post != $_post )
wp_update_post($post);
foreach ( get_attachment_taxonomies($post) as $t ) {
if ( isset($attachment[$t]) )
wp_set_object_terms($attachment_id, array_map('trim', preg_split('/,+/', $attachment[$t])), $t, false);
}
}
if ( isset($_POST['insert-gallery']) || isset($_POST['update-gallery']) ) { ?>
<script type="text/javascript">
/* <![CDATA[ */
var win = window.dialogArguments || opener || parent || top;
win.tb_remove();
/* ]]> */
</script>
<?php
exit;
}
if ( isset($send_id) ) {
$attachment = stripslashes_deep( $_POST['attachments'][$send_id] );
$html = isset( $attachment['post_title'] ) ? $attachment['post_title'] : '';
if ( !empty($attachment['url']) ) {
$rel = '';
if ( strpos($attachment['url'], 'attachment_id') || get_attachment_link($send_id) == $attachment['url'] )
$rel = " rel='attachment wp-att-" . esc_attr($send_id) . "'";
$html = "<a href='{$attachment['url']}'$rel>$html</a>";
}
$html = apply_filters('media_send_to_editor', $html, $send_id, $attachment);
return media_send_to_editor($html);
}
return $errors;
}
/**
* {@internal Missing Short Description}}
*
* @since 2.5.0
*
* @return unknown
*/
function wp_media_upload_handler() {
$errors = array();
$id = 0;
if ( isset($_POST['html-upload']) && !empty($_FILES) ) {
check_admin_referer('media-form');
// Upload File button was clicked
$id = media_handle_upload('async-upload', $_REQUEST['post_id']);
unset($_FILES);
if ( is_wp_error($id) ) {
$errors['upload_error'] = $id;
$id = false;
}
}
if ( !empty($_POST['insertonlybutton']) ) {
$src = $_POST['src'];
if ( !empty($src) && !strpos($src, '://') )
$src = "http://$src";
if ( isset( $_POST['media_type'] ) && 'image' != $_POST['media_type'] ) {
$title = esc_html( stripslashes( $_POST['title'] ) );
if ( empty( $title ) )
$title = esc_html( basename( $src ) );
if ( $title && $src )
$html = "<a href='" . esc_url($src) . "'>$title</a>";
$type = 'file';
if ( ( $ext = preg_replace( '/^.+?\.([^.]+)$/', '$1', $src ) ) && ( $ext_type = wp_ext2type( $ext ) )
&& ( 'audio' == $ext_type || 'video' == $ext_type ) )
$type = $ext_type;
$html = apply_filters( $type . '_send_to_editor_url', $html, esc_url_raw( $src ), $title );
} else {
$align = '';
$alt = esc_attr( stripslashes( $_POST['alt'] ) );
if ( isset($_POST['align']) ) {
$align = esc_attr( stripslashes( $_POST['align'] ) );
$class = " class='align$align'";
}
if ( !empty($src) )
$html = "<img src='" . esc_url($src) . "' alt='$alt'$class />";
$html = apply_filters( 'image_send_to_editor_url', $html, esc_url_raw( $src ), $alt, $align );
}
return media_send_to_editor($html);
}
if ( !empty($_POST) ) {
$return = media_upload_form_handler();
if ( is_string($return) )
return $return;
if ( is_array($return) )
$errors = $return;
}
if ( isset($_POST['save']) ) {
$errors['upload_notice'] = __('Saved.');
return media_upload_gallery();
}
if ( isset($_GET['tab']) && $_GET['tab'] == 'type_url' ) {
$type = 'image';
if ( isset( $_GET['type'] ) && in_array( $_GET['type'], array( 'video', 'audio', 'file' ) ) )
$type = $_GET['type'];
return wp_iframe( 'media_upload_type_url_form', $type, $errors, $id );
}
return wp_iframe( 'media_upload_type_form', 'image', $errors, $id );
}
/**
* Download an image from the specified URL and attach it to a post.
*
* @since 2.6.0
*
* @param string $file The URL of the image to download
* @param int $post_id The post ID the media is to be associated with
* @param string $desc Optional. Description of the image
* @return string|WP_Error Populated HTML img tag on success
*/
function media_sideload_image($file, $post_id, $desc = null) {
if ( ! empty($file) ) {
// Download file to temp location
$tmp = download_url( $file );
// Set variables for storage
// fix file filename for query strings
preg_match('/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $file, $matches);
$file_array['name'] = basename($matches[0]);
$file_array['tmp_name'] = $tmp;
// If error storing temporarily, unlink
if ( is_wp_error( $tmp ) ) {
@unlink($file_array['tmp_name']);
$file_array['tmp_name'] = '';
}
// do the validation and storage stuff
$id = media_handle_sideload( $file_array, $post_id, $desc );
// If error storing permanently, unlink
if ( is_wp_error($id) ) {
@unlink($file_array['tmp_name']);
return $id;
}
$src = wp_get_attachment_url( $id );
}
// Finally check to make sure the file has been saved, then return the html
if ( ! empty($src) ) {
$alt = isset($desc) ? esc_attr($desc) : '';
$html = "<img src='$src' alt='$alt' />";
return $html;
}
}
/**
* {@internal Missing Short Description}}
*
* @since 2.5.0
*
* @return unknown
*/
function media_upload_gallery() {
$errors = array();
if ( !empty($_POST) ) {
$return = media_upload_form_handler();
if ( is_string($return) )
return $return;
if ( is_array($return) )
$errors = $return;
}
wp_enqueue_script('admin-gallery');
return wp_iframe( 'media_upload_gallery_form', $errors );
}
/**
* {@internal Missing Short Description}}
*
* @since 2.5.0
*
* @return unknown
*/
function media_upload_library() {
$errors = array();
if ( !empty($_POST) ) {
$return = media_upload_form_handler();
if ( is_string($return) )
return $return;
if ( is_array($return) )
$errors = $return;
}
return wp_iframe( 'media_upload_library_form', $errors );
}
/**
* Retrieve HTML for the image alignment radio buttons with the specified one checked.
*
* @since 2.7.0
*
* @param unknown_type $post
* @param unknown_type $checked
* @return unknown
*/
function image_align_input_fields( $post, $checked = '' ) {
if ( empty($checked) )
$checked = get_user_setting('align', 'none');
$alignments = array('none' => __('None'), 'left' => __('Left'), 'center' => __('Center'), 'right' => __('Right'));
if ( !array_key_exists( (string) $checked, $alignments ) )
$checked = 'none';
$out = array();
foreach ( $alignments as $name => $label ) {
$name = esc_attr($name);
$out[] = "<input type='radio' name='attachments[{$post->ID}][align]' id='image-align-{$name}-{$post->ID}' value='$name'".
( $checked == $name ? " checked='checked'" : "" ) .
" /><label for='image-align-{$name}-{$post->ID}' class='align image-align-{$name}-label'>$label</label>";
}
return join("\n", $out);
}
/**
* Retrieve HTML for the size radio buttons with the specified one checked.
*
* @since 2.7.0
*
* @param unknown_type $post
* @param unknown_type $check
* @return unknown
*/
function image_size_input_fields( $post, $check = '' ) {
// get a list of the actual pixel dimensions of each possible intermediate version of this image
$size_names = apply_filters( 'image_size_names_choose', array('thumbnail' => __('Thumbnail'), 'medium' => __('Medium'), 'large' => __('Large'), 'full' => __('Full Size')) );
if ( empty($check) )
$check = get_user_setting('imgsize', 'medium');
foreach ( $size_names as $size => $label ) {
$downsize = image_downsize($post->ID, $size);
$checked = '';
// is this size selectable?
$enabled = ( $downsize[3] || 'full' == $size );
$css_id = "image-size-{$size}-{$post->ID}";
// if this size is the default but that's not available, don't select it
if ( $size == $check ) {
if ( $enabled )
$checked = " checked='checked'";
else
$check = '';
} elseif ( !$check && $enabled && 'thumbnail' != $size ) {
// if $check is not enabled, default to the first available size that's bigger than a thumbnail
$check = $size;
$checked = " checked='checked'";
}
$html = "<div class='image-size-item'><input type='radio' " . disabled( $enabled, false, false ) . "name='attachments[$post->ID][image-size]' id='{$css_id}' value='{$size}'$checked />";
$html .= "<label for='{$css_id}'>$label</label>";
// only show the dimensions if that choice is available
if ( $enabled )
$html .= " <label for='{$css_id}' class='help'>" . sprintf( "(%d × %d)", $downsize[1], $downsize[2] ). "</label>";
$html .= '</div>';
$out[] = $html;
}
return array(
'label' => __('Size'),
'input' => 'html',
'html' => join("\n", $out),
);
}
/**
* Retrieve HTML for the Link URL buttons with the default link type as specified.
*
* @since 2.7.0
*
* @param unknown_type $post
* @param unknown_type $url_type
* @return unknown
*/
function image_link_input_fields($post, $url_type = '') {
$file = wp_get_attachment_url($post->ID);
$link = get_attachment_link($post->ID);
if ( empty($url_type) )
$url_type = get_user_setting('urlbutton', 'post');
$url = '';
if ( $url_type == 'file' )
$url = $file;
elseif ( $url_type == 'post' )
$url = $link;
return "
<input type='text' class='text urlfield' name='attachments[$post->ID][url]' value='" . esc_attr($url) . "' /><br />
<button type='button' class='button urlnone' data-link-url=''>" . __('None') . "</button>
<button type='button' class='button urlfile' data-link-url='" . esc_attr($file) . "'>" . __('File URL') . "</button>
<button type='button' class='button urlpost' data-link-url='" . esc_attr($link) . "'>" . __('Attachment Post URL') . "</button>
";
}
function wp_caption_input_textarea($edit_post) {
// post data is already escaped
$name = "attachments[{$edit_post->ID}][post_excerpt]";
return '<textarea name="' . $name . '" id="' . $name . '">' . $edit_post->post_excerpt . '</textarea>';
}
/**
* {@internal Missing Short Description}}
*
* @since 2.5.0
*
* @param unknown_type $form_fields
* @param unknown_type $post
* @return unknown
*/
function image_attachment_fields_to_edit($form_fields, $post) {
if ( substr($post->post_mime_type, 0, 5) == 'image' ) {
$alt = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
if ( empty($alt) )
$alt = '';
$form_fields['post_title']['required'] = true;
$form_fields['image_alt'] = array(
'value' => $alt,
'label' => __('Alternate Text'),
'helps' => __('Alt text for the image, e.g. “The Mona Lisa”')
);
$form_fields['align'] = array(
'label' => __('Alignment'),
'input' => 'html',
'html' => image_align_input_fields($post, get_option('image_default_align')),
);
$form_fields['image-size'] = image_size_input_fields( $post, get_option('image_default_size', 'medium') );
} else {
unset( $form_fields['image_alt'] );
}
return $form_fields;
}
add_filter('attachment_fields_to_edit', 'image_attachment_fields_to_edit', 10, 2);
/**
* {@internal Missing Short Description}}
*
* @since 2.5.0
*
* @param unknown_type $form_fields
* @param unknown_type $post
* @return unknown
*/
function media_single_attachment_fields_to_edit( $form_fields, $post ) {
unset($form_fields['url'], $form_fields['align'], $form_fields['image-size']);
return $form_fields;
}
/**
* {@internal Missing Short Description}}
*
* @since 2.8.0
*
* @param unknown_type $form_fields
* @param unknown_type $post
* @return unknown
*/
function media_post_single_attachment_fields_to_edit( $form_fields, $post ) {
unset($form_fields['image_url']);
return $form_fields;
}
/**
* {@internal Missing Short Description}}
*
* @since 2.5.0
*
* @param unknown_type $post
* @param unknown_type $attachment
* @return unknown
*/
function image_attachment_fields_to_save($post, $attachment) {
if ( substr($post['post_mime_type'], 0, 5) == 'image' ) {
if ( strlen(trim($post['post_title'])) == 0 ) {
$post['post_title'] = preg_replace('/\.\w+$/', '', basename($post['guid']));
$post['errors']['post_title']['errors'][] = __('Empty Title filled from filename.');
}
}
return $post;
}
add_filter('attachment_fields_to_save', 'image_attachment_fields_to_save', 10, 2);
/**
* {@internal Missing Short Description}}
*
* @since 2.5.0
*
* @param unknown_type $html
* @param unknown_type $attachment_id
* @param unknown_type $attachment
* @return unknown
*/
function image_media_send_to_editor($html, $attachment_id, $attachment) {
$post =& get_post($attachment_id);
if ( substr($post->post_mime_type, 0, 5) == 'image' ) {
$url = $attachment['url'];
$align = !empty($attachment['align']) ? $attachment['align'] : 'none';
$size = !empty($attachment['image-size']) ? $attachment['image-size'] : 'medium';
$alt = !empty($attachment['image_alt']) ? $attachment['image_alt'] : '';
$rel = ( $url == get_attachment_link($attachment_id) );
return get_image_send_to_editor($attachment_id, $attachment['post_excerpt'], $attachment['post_title'], $align, $url, $rel, $size, $alt);
}
return $html;
}
add_filter('media_send_to_editor', 'image_media_send_to_editor', 10, 3);
/**
* {@internal Missing Short Description}}
*
* @since 2.5.0
*
* @param unknown_type $post
* @param unknown_type $errors
* @return unknown
*/
function get_attachment_fields_to_edit($post, $errors = null) {
if ( is_int($post) )
$post =& get_post($post);
if ( is_array($post) )
$post = (object) $post;
$image_url = wp_get_attachment_url($post->ID);
$edit_post = sanitize_post($post, 'edit');
$form_fields = array(
'post_title' => array(
'label' => __('Title'),
'value' => $edit_post->post_title
),
'image_alt' => array(),
'post_excerpt' => array(
'label' => __('Caption'),
'input' => 'html',
'html' => wp_caption_input_textarea($edit_post)
),
'post_content' => array(
'label' => __('Description'),
'value' => $edit_post->post_content,
'input' => 'textarea'
),
'url' => array(
'label' => __('Link URL'),
'input' => 'html',
'html' => image_link_input_fields($post, get_option('image_default_link_type')),
'helps' => __('Enter a link URL or click above for presets.')
),
'menu_order' => array(
'label' => __('Order'),
'value' => $edit_post->menu_order
),
'image_url' => array(
'label' => __('File URL'),
'input' => 'html',
'html' => "<input type='text' class='text urlfield' readonly='readonly' name='attachments[$post->ID][url]' value='" . esc_attr($image_url) . "' /><br />",
'value' => wp_get_attachment_url($post->ID),
'helps' => __('Location of the uploaded file.')
)
);
foreach ( get_attachment_taxonomies($post) as $taxonomy ) {
$t = (array) get_taxonomy($taxonomy);
if ( ! $t['public'] )
continue;
if ( empty($t['label']) )
$t['label'] = $taxonomy;
if ( empty($t['args']) )
$t['args'] = array();
$terms = get_object_term_cache($post->ID, $taxonomy);
if ( empty($terms) )
$terms = wp_get_object_terms($post->ID, $taxonomy, $t['args']);
$values = array();
foreach ( $terms as $term )
$values[] = $term->name;
$t['value'] = join(', ', $values);
$form_fields[$taxonomy] = $t;
}
// Merge default fields with their errors, so any key passed with the error (e.g. 'error', 'helps', 'value') will replace the default
// The recursive merge is easily traversed with array casting: foreach( (array) $things as $thing )
$form_fields = array_merge_recursive($form_fields, (array) $errors);
$form_fields = apply_filters('attachment_fields_to_edit', $form_fields, $post);
return $form_fields;
}
/**
* Retrieve HTML for media items of post gallery.
*
* The HTML markup retrieved will be created for the progress of SWF Upload
* component. Will also create link for showing and hiding the form to modify
* the image attachment.
*
* @since 2.5.0
*
* @param int $post_id Optional. Post ID.
* @param array $errors Errors for attachment, if any.
* @return string
*/
function get_media_items( $post_id, $errors ) {
$attachments = array();
if ( $post_id ) {
$post = get_post($post_id);
if ( $post && $post->post_type == 'attachment' )
$attachments = array($post->ID => $post);
else
$attachments = get_children( array( 'post_parent' => $post_id, 'post_type' => 'attachment', 'orderby' => 'menu_order ASC, ID', 'order' => 'DESC') );
} else {
if ( is_array($GLOBALS['wp_the_query']->posts) )
foreach ( $GLOBALS['wp_the_query']->posts as $attachment )
$attachments[$attachment->ID] = $attachment;
}
$output = '';
foreach ( (array) $attachments as $id => $attachment ) {
if ( $attachment->post_status == 'trash' )
continue;
if ( $item = get_media_item( $id, array( 'errors' => isset($errors[$id]) ? $errors[$id] : null) ) )
$output .= "\n<div id='media-item-$id' class='media-item child-of-$attachment->post_parent preloaded'><div class='progress hidden'><div class='bar'></div></div><div id='media-upload-error-$id' class='hidden'></div><div class='filename hidden'></div>$item\n</div>";
}
return $output;
}
/**
* Retrieve HTML form for modifying the image attachment.
*
* @since 2.5.0
*
* @param int $attachment_id Attachment ID for modification.
* @param string|array $args Optional. Override defaults.
* @return string HTML form for attachment.
*/
function get_media_item( $attachment_id, $args = null ) {
global $redir_tab;
if ( ( $attachment_id = intval( $attachment_id ) ) && $thumb_url = wp_get_attachment_image_src( $attachment_id, 'thumbnail', true ) )
$thumb_url = $thumb_url[0];
else
$thumb_url = false;
$post = get_post( $attachment_id );
$current_post_id = !empty( $_GET['post_id'] ) ? (int) $_GET['post_id'] : 0;
$default_args = array( 'errors' => null, 'send' => $current_post_id ? post_type_supports( get_post_type( $current_post_id ), 'editor' ) : true, 'delete' => true, 'toggle' => true, 'show_title' => true );
$args = wp_parse_args( $args, $default_args );
$args = apply_filters( 'get_media_item_args', $args );
extract( $args, EXTR_SKIP );
$toggle_on = __( 'Show' );
$toggle_off = __( 'Hide' );
$filename = esc_html( basename( $post->guid ) );
$title = esc_attr( $post->post_title );
if ( $_tags = get_the_tags( $attachment_id ) ) {
foreach ( $_tags as $tag )
$tags[] = $tag->name;
$tags = esc_attr( join( ', ', $tags ) );
}
$post_mime_types = get_post_mime_types();
$keys = array_keys( wp_match_mime_types( array_keys( $post_mime_types ), $post->post_mime_type ) );
$type = array_shift( $keys );
$type_html = "<input type='hidden' id='type-of-$attachment_id' value='" . esc_attr( $type ) . "' />";
$form_fields = get_attachment_fields_to_edit( $post, $errors );
if ( $toggle ) {
$class = empty( $errors ) ? 'startclosed' : 'startopen';
$toggle_links = "
<a class='toggle describe-toggle-on' href='#'>$toggle_on</a>
<a class='toggle describe-toggle-off' href='#'>$toggle_off</a>";
} else {
$class = '';
$toggle_links = '';
}
$display_title = ( !empty( $title ) ) ? $title : $filename; // $title shouldn't ever be empty, but just in case
$display_title = $show_title ? "<div class='filename new'><span class='title'>" . wp_html_excerpt( $display_title, 60 ) . "</span></div>" : '';
$gallery = ( ( isset( $_REQUEST['tab'] ) && 'gallery' == $_REQUEST['tab'] ) || ( isset( $redir_tab ) && 'gallery' == $redir_tab ) );
$order = '';
foreach ( $form_fields as $key => $val ) {
if ( 'menu_order' == $key ) {
if ( $gallery )
$order = "<div class='menu_order'> <input class='menu_order_input' type='text' id='attachments[$attachment_id][menu_order]' name='attachments[$attachment_id][menu_order]' value='" . esc_attr( $val['value'] ). "' /></div>";
else
$order = "<input type='hidden' name='attachments[$attachment_id][menu_order]' value='" . esc_attr( $val['value'] ) . "' />";
unset( $form_fields['menu_order'] );
break;
}
}
$media_dims = '';
$meta = wp_get_attachment_metadata( $post->ID );
if ( is_array( $meta ) && array_key_exists( 'width', $meta ) && array_key_exists( 'height', $meta ) )
$media_dims .= "<span id='media-dims-$post->ID'>{$meta['width']} × {$meta['height']}</span> ";
$media_dims = apply_filters( 'media_meta', $media_dims, $post );
$image_edit_button = '';
if ( gd_edit_image_support( $post->post_mime_type ) ) {
$nonce = wp_create_nonce( "image_editor-$post->ID" );
$image_edit_button = "<input type='button' id='imgedit-open-btn-$post->ID' onclick='imageEdit.open( $post->ID, \"$nonce\" )' class='button' value='" . esc_attr__( 'Edit Image' ) . "' /> <img src='" . esc_url( admin_url( 'images/wpspin_light.gif' ) ) . "' class='imgedit-wait-spin' alt='' />";
}
$attachment_url = get_permalink( $attachment_id );
$item = "
$type_html
$toggle_links
$order
$display_title
<table class='slidetoggle describe $class'>
<thead class='media-item-info' id='media-head-$post->ID'>
<tr valign='top'>
<td class='A1B1' id='thumbnail-head-$post->ID'>
<p><a href='$attachment_url' target='_blank'><img class='thumbnail' src='$thumb_url' alt='' /></a></p>
<p>$image_edit_button</p>
</td>
<td>
<p><strong>" . __('File name:') . "</strong> $filename</p>
<p><strong>" . __('File type:') . "</strong> $post->post_mime_type</p>
<p><strong>" . __('Upload date:') . "</strong> " . mysql2date( get_option('date_format'), $post->post_date ). '</p>';
if ( !empty( $media_dims ) )
$item .= "<p><strong>" . __('Dimensions:') . "</strong> $media_dims</p>\n";
$item .= "</td></tr>\n";
$item .= "
</thead>
<tbody>
<tr><td colspan='2' class='imgedit-response' id='imgedit-response-$post->ID'></td></tr>
<tr><td style='display:none' colspan='2' class='image-editor' id='image-editor-$post->ID'></td></tr>\n";
$defaults = array(
'input' => 'text',
'required' => false,
'value' => '',
'extra_rows' => array(),
);
if ( $send )
$send = get_submit_button( __( 'Insert into Post' ), 'button', "send[$attachment_id]", false );
if ( $delete && current_user_can( 'delete_post', $attachment_id ) ) {
if ( !EMPTY_TRASH_DAYS ) {
$delete = "<a href='" . wp_nonce_url( "post.php?action=delete&post=$attachment_id", 'delete-attachment_' . $attachment_id ) . "' id='del[$attachment_id]' class='delete'>" . __( 'Delete Permanently' ) . '</a>';
} elseif ( !MEDIA_TRASH ) {
$delete = "<a href='#' class='del-link' onclick=\"document.getElementById('del_attachment_$attachment_id').style.display='block';return false;\">" . __( 'Delete' ) . "</a>
<div id='del_attachment_$attachment_id' class='del-attachment' style='display:none;'><p>" . sprintf( __( 'You are about to delete <strong>%s</strong>.' ), $filename ) . "</p>
<a href='" . wp_nonce_url( "post.php?action=delete&post=$attachment_id", 'delete-attachment_' . $attachment_id ) . "' id='del[$attachment_id]' class='button'>" . __( 'Continue' ) . "</a>
<a href='#' class='button' onclick=\"this.parentNode.style.display='none';return false;\">" . __( 'Cancel' ) . "</a>
</div>";
} else {
$delete = "<a href='" . wp_nonce_url( "post.php?action=trash&post=$attachment_id", 'trash-attachment_' . $attachment_id ) . "' id='del[$attachment_id]' class='delete'>" . __( 'Move to Trash' ) . "</a>
<a href='" . wp_nonce_url( "post.php?action=untrash&post=$attachment_id", 'untrash-attachment_' . $attachment_id ) . "' id='undo[$attachment_id]' class='undo hidden'>" . __( 'Undo' ) . "</a>";
}
} else {
$delete = '';
}
$thumbnail = '';
$calling_post_id = 0;
if ( isset( $_GET['post_id'] ) )
$calling_post_id = absint( $_GET['post_id'] );
elseif ( isset( $_POST ) && count( $_POST ) ) // Like for async-upload where $_GET['post_id'] isn't set
$calling_post_id = $post->post_parent;
if ( 'image' == $type && $calling_post_id && current_theme_supports( 'post-thumbnails', get_post_type( $calling_post_id ) )
&& post_type_supports( get_post_type( $calling_post_id ), 'thumbnail' ) && get_post_thumbnail_id( $calling_post_id ) != $attachment_id ) {
$ajax_nonce = wp_create_nonce( "set_post_thumbnail-$calling_post_id" );
$thumbnail = "<a class='wp-post-thumbnail' id='wp-post-thumbnail-" . $attachment_id . "' href='#' onclick='WPSetAsThumbnail(\"$attachment_id\", \"$ajax_nonce\");return false;'>" . esc_html__( "Use as featured image" ) . "</a>";
}
if ( ( $send || $thumbnail || $delete ) && !isset( $form_fields['buttons'] ) )
$form_fields['buttons'] = array( 'tr' => "\t\t<tr class='submit'><td></td><td class='savesend'>$send $thumbnail $delete</td></tr>\n" );
$hidden_fields = array();
foreach ( $form_fields as $id => $field ) {
if ( $id[0] == '_' )
continue;
if ( !empty( $field['tr'] ) ) {
$item .= $field['tr'];
continue;
}
$field = array_merge( $defaults, $field );
$name = "attachments[$attachment_id][$id]";
if ( $field['input'] == 'hidden' ) {
$hidden_fields[$name] = $field['value'];
continue;
}
$required = $field['required'] ? '<span class="alignright"><abbr title="required" class="required">*</abbr></span>' : '';
$aria_required = $field['required'] ? " aria-required='true' " : '';
$class = $id;
$class .= $field['required'] ? ' form-required' : '';
$item .= "\t\t<tr class='$class'>\n\t\t\t<th valign='top' scope='row' class='label'><label for='$name'><span class='alignleft'>{$field['label']}</span>$required<br class='clear' /></label></th>\n\t\t\t<td class='field'>";
if ( !empty( $field[ $field['input'] ] ) )
$item .= $field[ $field['input'] ];
elseif ( $field['input'] == 'textarea' ) {
if ( 'post_content' == $id && user_can_richedit() ) {
// sanitize_post() skips the post_content when user_can_richedit
$field['value'] = htmlspecialchars( $field['value'], ENT_QUOTES );
}
// post_excerpt is already escaped by sanitize_post() in get_attachment_fields_to_edit()
$item .= "<textarea id='$name' name='$name' $aria_required>" . $field['value'] . '</textarea>';
} else {
$item .= "<input type='text' class='text' id='$name' name='$name' value='" . esc_attr( $field['value'] ) . "' $aria_required />";
}
if ( !empty( $field['helps'] ) )
$item .= "<p class='help'>" . join( "</p>\n<p class='help'>", array_unique( (array) $field['helps'] ) ) . '</p>';
$item .= "</td>\n\t\t</tr>\n";
$extra_rows = array();
if ( !empty( $field['errors'] ) )
foreach ( array_unique( (array) $field['errors'] ) as $error )
$extra_rows['error'][] = $error;
if ( !empty( $field['extra_rows'] ) )
foreach ( $field['extra_rows'] as $class => $rows )
foreach ( (array) $rows as $html )
$extra_rows[$class][] = $html;
foreach ( $extra_rows as $class => $rows )
foreach ( $rows as $html )
$item .= "\t\t<tr><td></td><td class='$class'>$html</td></tr>\n";
}
if ( !empty( $form_fields['_final'] ) )
$item .= "\t\t<tr class='final'><td colspan='2'>{$form_fields['_final']}</td></tr>\n";
$item .= "\t</tbody>\n";
$item .= "\t</table>\n";
foreach ( $hidden_fields as $name => $value )
$item .= "\t<input type='hidden' name='$name' id='$name' value='" . esc_attr( $value ) . "' />\n";
if ( $post->post_parent < 1 && isset( $_REQUEST['post_id'] ) ) {
$parent = (int) $_REQUEST['post_id'];
$parent_name = "attachments[$attachment_id][post_parent]";
$item .= "\t<input type='hidden' name='$parent_name' id='$parent_name' value='$parent' />\n";
}
return $item;
}
/**
* {@internal Missing Short Description}}
*
* @since 2.5.0
*/
function media_upload_header() {
?>
<script type="text/javascript">post_id = <?php echo intval($_REQUEST['post_id']); ?>;</script>
<div id="media-upload-header">
<?php the_media_upload_tabs(); ?>
</div>
<?php
}
/**
* {@internal Missing Short Description}}
*
* @since 2.5.0
*
* @param unknown_type $errors
*/
function media_upload_form( $errors = null ) {
global $type, $tab, $pagenow, $is_IE, $is_opera;
if ( ! _device_can_upload() ) {
echo '<p>' . __('The web browser on your device cannot be used to upload files. You may be able to use the <a href="http://wordpress.org/extend/mobile/">native app for your device</a> instead.') . '</p>';
return;
}
$upload_action_url = admin_url('async-upload.php');
$post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0;
$_type = isset($type) ? $type : '';
$_tab = isset($tab) ? $tab : '';
$upload_size_unit = $max_upload_size = wp_max_upload_size();
$sizes = array( 'KB', 'MB', 'GB' );
for ( $u = -1; $upload_size_unit > 1024 && $u < count( $sizes ) - 1; $u++ ) {
$upload_size_unit /= 1024;
}
if ( $u < 0 ) {
$upload_size_unit = 0;
$u = 0;
} else {
$upload_size_unit = (int) $upload_size_unit;
}
?>
<div id="media-upload-notice"><?php
if (isset($errors['upload_notice']) )
echo $errors['upload_notice'];
?></div>
<div id="media-upload-error"><?php
if (isset($errors['upload_error']) && is_wp_error($errors['upload_error']))
echo $errors['upload_error']->get_error_message();
?></div>
<?php
// Check quota for this blog if multisite
if ( is_multisite() && !is_upload_space_available() ) {
echo '<p>' . sprintf( __( 'Sorry, you have filled your storage quota (%s MB).' ), get_space_allowed() ) . '</p>';
return;
}
do_action('pre-upload-ui');
$post_params = array(
"post_id" => $post_id,
"_wpnonce" => wp_create_nonce('media-form'),
"type" => $_type,
"tab" => $_tab,
"short" => "1",
);
$post_params = apply_filters( 'upload_post_params', $post_params ); // hook change! old name: 'swfupload_post_params'
$plupload_init = array(
'runtimes' => 'html5,silverlight,flash,html4',
'browse_button' => 'plupload-browse-button',
'container' => 'plupload-upload-ui',
'drop_element' => 'drag-drop-area',
'file_data_name' => 'async-upload',
'multiple_queues' => true,
'max_file_size' => $max_upload_size . 'b',
'url' => $upload_action_url,
'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),
'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
'filters' => array( array('title' => __( 'Allowed Files' ), 'extensions' => '*') ),
'multipart' => true,
'urlstream_upload' => true,
'multipart_params' => $post_params
);
$plupload_init = apply_filters( 'plupload_init', $plupload_init );
?>
<script type="text/javascript">
<?php
// Verify size is an int. If not return default value.
$large_size_h = absint( get_option('large_size_h') );
if( !$large_size_h )
$large_size_h = 1024;
$large_size_w = absint( get_option('large_size_w') );
if( !$large_size_w )
$large_size_w = 1024;
?>
var resize_height = <?php echo $large_size_h; ?>, resize_width = <?php echo $large_size_w; ?>,
wpUploaderInit = <?php echo json_encode($plupload_init); ?>;
</script>
<div id="plupload-upload-ui" class="hide-if-no-js">
<?php do_action('pre-plupload-upload-ui'); // hook change, old name: 'pre-flash-upload-ui' ?>
<div id="drag-drop-area">
<div class="drag-drop-inside">
<p class="drag-drop-info"><?php _e('Drop files here'); ?></p>
<p><?php _ex('or', 'Uploader: Drop files here - or - Select Files'); ?></p>
<p class="drag-drop-buttons"><input id="plupload-browse-button" type="button" value="<?php esc_attr_e('Select Files'); ?>" class="button" /></p>
</div>
</div>
<?php do_action('post-plupload-upload-ui'); // hook change, old name: 'post-flash-upload-ui' ?>
</div>
<div id="html-upload-ui" class="hide-if-js">
<?php do_action('pre-html-upload-ui'); ?>
<p id="async-upload-wrap">
<label class="screen-reader-text" for="async-upload"><?php _e('Upload'); ?></label>
<input type="file" name="async-upload" id="async-upload" />
<?php submit_button( __( 'Upload' ), 'button', 'html-upload', false ); ?>
<a href="#" onclick="try{top.tb_remove();}catch(e){}; return false;"><?php _e('Cancel'); ?></a>
</p>
<div class="clear"></div>
<?php do_action('post-html-upload-ui'); ?>
</div>
<span class="max-upload-size"><?php printf( __( 'Maximum upload file size: %d%s.' ), esc_html($upload_size_unit), esc_html($sizes[$u]) ); ?></span>
<?php
if ( ($is_IE || $is_opera) && $max_upload_size > 100 * 1024 * 1024 ) { ?>
<span class="big-file-warning"><?php _e('Your browser has some limitations uploading large files with the multi-file uploader. Please use the browser uploader for files over 100MB.'); ?></span>
<?php }
do_action('post-upload-ui');
}
/**
* {@internal Missing Short Description}}
*
* @since 2.5.0
*
* @param unknown_type $type
* @param unknown_type $errors
* @param unknown_type $id
*/
function media_upload_type_form($type = 'file', $errors = null, $id = null) {
media_upload_header();
$post_id = isset( $_REQUEST['post_id'] )? intval( $_REQUEST['post_id'] ) : 0;
$form_action_url = admin_url("media-upload.php?type=$type&tab=type&post_id=$post_id");
$form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
$form_class = 'media-upload-form type-form validate';
if ( get_user_setting('uploader') )
$form_class .= ' html-uploader';
?>
<form enctype="multipart/form-data" method="post" action="<?php echo esc_attr($form_action_url); ?>" class="<?php echo $form_class; ?>" id="<?php echo $type; ?>-form">
<?php submit_button( '', 'hidden', 'save', false ); ?>
<input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
<?php wp_nonce_field('media-form'); ?>
<h3 class="media-title"><?php _e('Add media files from your computer'); ?></h3>
<?php media_upload_form( $errors ); ?>
<script type="text/javascript">
//<![CDATA[
jQuery(function($){
var preloaded = $(".media-item.preloaded");
if ( preloaded.length > 0 ) {
preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');});
}
updateMediaForm();
});
//]]>
</script>
<div id="media-items"><?php
if ( $id ) {
if ( !is_wp_error($id) ) {
add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2);
echo get_media_items( $id, $errors );
} else {
echo '<div id="media-upload-error">'.esc_html($id->get_error_message()).'</div></div>';
exit;
}
}
?></div>
<p class="savebutton ml-submit">
<?php submit_button( __( 'Save all changes' ), 'button', 'save', false ); ?>
</p>
</form>
<?php
}
/**
* {@internal Missing Short Description}}
*
* @since 2.7.0
*
* @param unknown_type $type
* @param unknown_type $errors
* @param unknown_type $id
*/
function media_upload_type_url_form($type = null, $errors = null, $id = null) {
if ( null === $type )
$type = 'image';
media_upload_header();
$post_id = intval($_REQUEST['post_id']);
$form_action_url = admin_url("media-upload.php?type=$type&tab=type&post_id=$post_id");
$form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
$form_class = 'media-upload-form type-form validate';
if ( get_user_setting('uploader') )
$form_class .= ' html-uploader';
?>
<form enctype="multipart/form-data" method="post" action="<?php echo esc_attr($form_action_url); ?>" class="<?php echo $form_class; ?>" id="<?php echo $type; ?>-form">
<input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
<?php wp_nonce_field('media-form'); ?>
<h3 class="media-title"><?php _e('Insert media from another website'); ?></h3>
<script type="text/javascript">
//<![CDATA[
var addExtImage = {
width : '',
height : '',
align : 'alignnone',
insert : function() {
var t = this, html, f = document.forms[0], cls, title = '', alt = '', caption = '';
if ( '' == f.src.value || '' == t.width )
return false;
if ( f.title.value ) {
title = f.title.value.replace(/'/g, ''').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>');
title = ' title="'+title+'"';
}
if ( f.alt.value )
alt = f.alt.value.replace(/'/g, ''').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>');
<?php if ( ! apply_filters( 'disable_captions', '' ) ) { ?>
if ( f.caption.value ) {
caption = f.caption.value.replace(/\r\n|\r/g, '\n');
caption = caption.replace(/<[a-zA-Z0-9]+( [^<>]+)?>/g, function(a){
return a.replace(/[\r\n\t]+/, ' ');
});
caption = caption.replace(/\s*\n\s*/g, '<br />');
}
<?php } ?>
cls = caption ? '' : ' class="'+t.align+'"';
html = '<img alt="'+alt+'" src="'+f.src.value+'"'+title+cls+' width="'+t.width+'" height="'+t.height+'" />';
if ( f.url.value ) {
url = f.url.value.replace(/'/g, ''').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>');
html = '<a href="'+url+'">'+html+'</a>';
}
if ( caption )
html = '[caption id="" align="'+t.align+'" width="'+t.width+'"]'+html+caption+'[/caption]';
var win = window.dialogArguments || opener || parent || top;
win.send_to_editor(html);
return false;
},
resetImageData : function() {
var t = addExtImage;
t.width = t.height = '';
document.getElementById('go_button').style.color = '#bbb';
if ( ! document.forms[0].src.value )
document.getElementById('status_img').innerHTML = '*';
else document.getElementById('status_img').innerHTML = '<img src="<?php echo esc_url( admin_url( 'images/no.png' ) ); ?>" alt="" />';
},
updateImageData : function() {
var t = addExtImage;
t.width = t.preloadImg.width;
t.height = t.preloadImg.height;
document.getElementById('go_button').style.color = '#333';
document.getElementById('status_img').innerHTML = '<img src="<?php echo esc_url( admin_url( 'images/yes.png' ) ); ?>" alt="" />';
},
getImageData : function() {
if ( jQuery('table.describe').hasClass('not-image') )
return;
var t = addExtImage, src = document.forms[0].src.value;
if ( ! src ) {
t.resetImageData();
return false;
}
document.getElementById('status_img').innerHTML = '<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />';
t.preloadImg = new Image();
t.preloadImg.onload = t.updateImageData;
t.preloadImg.onerror = t.resetImageData;
t.preloadImg.src = src;
}
}
jQuery(document).ready( function($) {
$('.media-types input').click( function() {
$('table.describe').toggleClass('not-image', $('#not-image').prop('checked') );
});
});
//]]>
</script>
<div id="media-items">
<div class="media-item media-blank">
<?php echo apply_filters( 'type_url_form_media', wp_media_insert_url_form( $type ) ); ?>
</div>
</div>
</form>
<?php
}
/**
* {@internal Missing Short Description}}
*
* @since 2.5.0
*
* @param unknown_type $errors
*/
function media_upload_gallery_form($errors) {
global $redir_tab, $type;
$redir_tab = 'gallery';
media_upload_header();
$post_id = intval($_REQUEST['post_id']);
$form_action_url = admin_url("media-upload.php?type=$type&tab=gallery&post_id=$post_id");
$form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
$form_class = 'media-upload-form validate';
if ( get_user_setting('uploader') )
$form_class .= ' html-uploader';
?>
<script type="text/javascript">
<!--
jQuery(function($){
var preloaded = $(".media-item.preloaded");
if ( preloaded.length > 0 ) {
preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');});
updateMediaForm();
}
});
-->
</script>
<div id="sort-buttons" class="hide-if-no-js">
<span>
<?php _e('All Tabs:'); ?>
<a href="#" id="showall"><?php _e('Show'); ?></a>
<a href="#" id="hideall" style="display:none;"><?php _e('Hide'); ?></a>
</span>
<?php _e('Sort Order:'); ?>
<a href="#" id="asc"><?php _e('Ascending'); ?></a> |
<a href="#" id="desc"><?php _e('Descending'); ?></a> |
<a href="#" id="clear"><?php _ex('Clear', 'verb'); ?></a>
</div>
<form enctype="multipart/form-data" method="post" action="<?php echo esc_attr($form_action_url); ?>" class="<?php echo $form_class; ?>" id="gallery-form">
<?php wp_nonce_field('media-form'); ?>
<?php //media_upload_form( $errors ); ?>
<table class="widefat" cellspacing="0">
<thead><tr>
<th><?php _e('Media'); ?></th>
<th class="order-head"><?php _e('Order'); ?></th>
<th class="actions-head"><?php _e('Actions'); ?></th>
</tr></thead>
</table>
<div id="media-items">
<?php add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2); ?>
<?php echo get_media_items($post_id, $errors); ?>
</div>
<p class="ml-submit">
<?php submit_button( __( 'Save all changes' ), 'button savebutton', 'save', false, array( 'id' => 'save-all', 'style' => 'display: none;' ) ); ?>
<input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
<input type="hidden" name="type" value="<?php echo esc_attr( $GLOBALS['type'] ); ?>" />
<input type="hidden" name="tab" value="<?php echo esc_attr( $GLOBALS['tab'] ); ?>" />
</p>
<div id="gallery-settings" style="display:none;">
<div class="title"><?php _e('Gallery Settings'); ?></div>
<table id="basic" class="describe"><tbody>
<tr>
<th scope="row" class="label">
<label>
<span class="alignleft"><?php _e('Link thumbnails to:'); ?></span>
</label>
</th>
<td class="field">
<input type="radio" name="linkto" id="linkto-file" value="file" />
<label for="linkto-file" class="radio"><?php _e('Image File'); ?></label>
<input type="radio" checked="checked" name="linkto" id="linkto-post" value="post" />
<label for="linkto-post" class="radio"><?php _e('Attachment Page'); ?></label>
</td>
</tr>
<tr>
<th scope="row" class="label">
<label>
<span class="alignleft"><?php _e('Order images by:'); ?></span>
</label>
</th>
<td class="field">
<select id="orderby" name="orderby">
<option value="menu_order" selected="selected"><?php _e('Menu order'); ?></option>
<option value="title"><?php _e('Title'); ?></option>
<option value="post_date"><?php _e('Date/Time'); ?></option>
<option value="rand"><?php _e('Random'); ?></option>
</select>
</td>
</tr>
<tr>
<th scope="row" class="label">
<label>
<span class="alignleft"><?php _e('Order:'); ?></span>
</label>
</th>
<td class="field">
<input type="radio" checked="checked" name="order" id="order-asc" value="asc" />
<label for="order-asc" class="radio"><?php _e('Ascending'); ?></label>
<input type="radio" name="order" id="order-desc" value="desc" />
<label for="order-desc" class="radio"><?php _e('Descending'); ?></label>
</td>
</tr>
<tr>
<th scope="row" class="label">
<label>
<span class="alignleft"><?php _e('Gallery columns:'); ?></span>
</label>
</th>
<td class="field">
<select id="columns" name="columns">
<option value="1">1</option>
<option value="2">2</option>
<option value="3" selected="selected">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
</select>
</td>
</tr>
</tbody></table>
<p class="ml-submit">
<input type="button" class="button" style="display:none;" onMouseDown="wpgallery.update();" name="insert-gallery" id="insert-gallery" value="<?php esc_attr_e( 'Insert gallery' ); ?>" />
<input type="button" class="button" style="display:none;" onMouseDown="wpgallery.update();" name="update-gallery" id="update-gallery" value="<?php esc_attr_e( 'Update gallery settings' ); ?>" />
</p>
</div>
</form>
<?php
}
/**
* {@internal Missing Short Description}}
*
* @since 2.5.0
*
* @param unknown_type $errors
*/
function media_upload_library_form($errors) {
global $wpdb, $wp_query, $wp_locale, $type, $tab, $post_mime_types;
media_upload_header();
$post_id = intval($_REQUEST['post_id']);
$form_action_url = admin_url("media-upload.php?type=$type&tab=library&post_id=$post_id");
$form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
$form_class = 'media-upload-form validate';
if ( get_user_setting('uploader') )
$form_class .= ' html-uploader';
$_GET['paged'] = isset( $_GET['paged'] ) ? intval($_GET['paged']) : 0;
if ( $_GET['paged'] < 1 )
$_GET['paged'] = 1;
$start = ( $_GET['paged'] - 1 ) * 10;
if ( $start < 1 )
$start = 0;
add_filter( 'post_limits', create_function( '$a', "return 'LIMIT $start, 10';" ) );
list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query();
?>
<form id="filter" action="" method="get">
<input type="hidden" name="type" value="<?php echo esc_attr( $type ); ?>" />
<input type="hidden" name="tab" value="<?php echo esc_attr( $tab ); ?>" />
<input type="hidden" name="post_id" value="<?php echo (int) $post_id; ?>" />
<input type="hidden" name="post_mime_type" value="<?php echo isset( $_GET['post_mime_type'] ) ? esc_attr( $_GET['post_mime_type'] ) : ''; ?>" />
<input type="hidden" name="context" value="<?php echo isset( $_GET['context'] ) ? esc_attr( $_GET['context'] ) : ''; ?>" />
<p id="media-search" class="search-box">
<label class="screen-reader-text" for="media-search-input"><?php _e('Search Media');?>:</label>
<input type="search" id="media-search-input" name="s" value="<?php the_search_query(); ?>" />
<?php submit_button( __( 'Search Media' ), 'button', '', false ); ?>
</p>
<ul class="subsubsub">
<?php
$type_links = array();
$_num_posts = (array) wp_count_attachments();
$matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts));
foreach ( $matches as $_type => $reals )
foreach ( $reals as $real )
if ( isset($num_posts[$_type]) )
$num_posts[$_type] += $_num_posts[$real];
else
$num_posts[$_type] = $_num_posts[$real];
// If available type specified by media button clicked, filter by that type
if ( empty($_GET['post_mime_type']) && !empty($num_posts[$type]) ) {
$_GET['post_mime_type'] = $type;
list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query();
}
if ( empty($_GET['post_mime_type']) || $_GET['post_mime_type'] == 'all' )
$class = ' class="current"';
else
$class = '';
$type_links[] = "<li><a href='" . esc_url(add_query_arg(array('post_mime_type'=>'all', 'paged'=>false, 'm'=>false))) . "'$class>".__('All Types')."</a>";
foreach ( $post_mime_types as $mime_type => $label ) {
$class = '';
if ( !wp_match_mime_types($mime_type, $avail_post_mime_types) )
continue;
if ( isset($_GET['post_mime_type']) && wp_match_mime_types($mime_type, $_GET['post_mime_type']) )
$class = ' class="current"';
$type_links[] = "<li><a href='" . esc_url(add_query_arg(array('post_mime_type'=>$mime_type, 'paged'=>false))) . "'$class>" . sprintf( translate_nooped_plural( $label[2], $num_posts[$mime_type] ), "<span id='$mime_type-counter'>" . number_format_i18n( $num_posts[$mime_type] ) . '</span>') . '</a>';
}
echo implode(' | </li>', apply_filters( 'media_upload_mime_type_links', $type_links ) ) . '</li>';
unset($type_links);
?>
</ul>
<div class="tablenav">
<?php
$page_links = paginate_links( array(
'base' => add_query_arg( 'paged', '%#%' ),
'format' => '',
'prev_text' => __('«'),
'next_text' => __('»'),
'total' => ceil($wp_query->found_posts / 10),
'current' => $_GET['paged']
));
if ( $page_links )
echo "<div class='tablenav-pages'>$page_links</div>";
?>
<div class="alignleft actions">
<?php
$arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'attachment' ORDER BY post_date DESC";
$arc_result = $wpdb->get_results( $arc_query );
$month_count = count($arc_result);
if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) { ?>
<select name='m'>
<option<?php selected( @$_GET['m'], 0 ); ?> value='0'><?php _e('Show all dates'); ?></option>
<?php
foreach ($arc_result as $arc_row) {
if ( $arc_row->yyear == 0 )
continue;
$arc_row->mmonth = zeroise( $arc_row->mmonth, 2 );
if ( isset($_GET['m']) && ( $arc_row->yyear . $arc_row->mmonth == $_GET['m'] ) )
$default = ' selected="selected"';
else
$default = '';
echo "<option$default value='" . esc_attr( $arc_row->yyear . $arc_row->mmonth ) . "'>";
echo esc_html( $wp_locale->get_month($arc_row->mmonth) . " $arc_row->yyear" );
echo "</option>\n";
}
?>
</select>
<?php } ?>
<?php submit_button( __( 'Filter »' ), 'secondary', 'post-query-submit', false ); ?>
</div>
<br class="clear" />
</div>
</form>
<form enctype="multipart/form-data" method="post" action="<?php echo esc_attr($form_action_url); ?>" class="<?php echo $form_class; ?>" id="library-form">
<?php wp_nonce_field('media-form'); ?>
<?php //media_upload_form( $errors ); ?>
<script type="text/javascript">
<!--
jQuery(function($){
var preloaded = $(".media-item.preloaded");
if ( preloaded.length > 0 ) {
preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');});
updateMediaForm();
}
});
-->
</script>
<div id="media-items">
<?php add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2); ?>
<?php echo get_media_items(null, $errors); ?>
</div>
<p class="ml-submit">
<?php submit_button( __( 'Save all changes' ), 'button savebutton', 'save', false ); ?>
<input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
</p>
</form>
<?php
}
/**
* {@internal Missing Short Description}}
*
* @since 2.7.0
*
* @return unknown
*/
function wp_media_insert_url_form( $default_view = 'image' ) {
if ( !apply_filters( 'disable_captions', '' ) ) {
$caption = '
<tr class="image-only">
<th valign="top" scope="row" class="label">
<span class="alignleft"><label for="caption">' . __('Image Caption') . '</label></span>
</th>
<td class="field"><textarea id="caption" name="caption"></textarea></td>
</tr>
';
} else {
$caption = '';
}
$default_align = get_option('image_default_align');
if ( empty($default_align) )
$default_align = 'none';
if ( 'image' == $default_view ) {
$view = 'image-only';
$table_class = '';
} else {
$view = $table_class = 'not-image';
}
return '
<p class="media-types"><label><input type="radio" name="media_type" value="image" id="image-only"' . checked( 'image-only', $view, false ) . ' /> ' . __( 'Image' ) . '</label> <label><input type="radio" name="media_type" value="generic" id="not-image"' . checked( 'not-image', $view, false ) . ' /> ' . __( 'Audio, Video, or Other File' ) . '</label></p>
<table class="describe ' . $table_class . '"><tbody>
<tr>
<th valign="top" scope="row" class="label" style="width:130px;">
<span class="alignleft"><label for="src">' . __('URL') . '</label></span>
<span class="alignright"><abbr id="status_img" title="required" class="required">*</abbr></span>
</th>
<td class="field"><input id="src" name="src" value="" type="text" aria-required="true" onblur="addExtImage.getImageData()" /></td>
</tr>
<tr>
<th valign="top" scope="row" class="label">
<span class="alignleft"><label for="title">' . __('Title') . '</label></span>
<span class="alignright"><abbr title="required" class="required">*</abbr></span>
</th>
<td class="field"><input id="title" name="title" value="" type="text" aria-required="true" /></td>
</tr>
<tr class="not-image"><td></td><td><p class="help">' . __('Link text, e.g. “Ransom Demands (PDF)”') . '</p></td></tr>
<tr class="image-only">
<th valign="top" scope="row" class="label">
<span class="alignleft"><label for="alt">' . __('Alternate Text') . '</label></span>
</th>
<td class="field"><input id="alt" name="alt" value="" type="text" aria-required="true" />
<p class="help">' . __('Alt text for the image, e.g. “The Mona Lisa”') . '</p></td>
</tr>
' . $caption . '
<tr class="align image-only">
<th valign="top" scope="row" class="label"><p><label for="align">' . __('Alignment') . '</label></p></th>
<td class="field">
<input name="align" id="align-none" value="none" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ($default_align == 'none' ? ' checked="checked"' : '').' />
<label for="align-none" class="align image-align-none-label">' . __('None') . '</label>
<input name="align" id="align-left" value="left" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ($default_align == 'left' ? ' checked="checked"' : '').' />
<label for="align-left" class="align image-align-left-label">' . __('Left') . '</label>
<input name="align" id="align-center" value="center" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ($default_align == 'center' ? ' checked="checked"' : '').' />
<label for="align-center" class="align image-align-center-label">' . __('Center') . '</label>
<input name="align" id="align-right" value="right" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ($default_align == 'right' ? ' checked="checked"' : '').' />
<label for="align-right" class="align image-align-right-label">' . __('Right') . '</label>
</td>
</tr>
<tr class="image-only">
<th valign="top" scope="row" class="label">
<span class="alignleft"><label for="url">' . __('Link Image To:') . '</label></span>
</th>
<td class="field"><input id="url" name="url" value="" type="text" /><br />
<button type="button" class="button" value="" onclick="document.forms[0].url.value=null">' . __('None') . '</button>
<button type="button" class="button" value="" onclick="document.forms[0].url.value=document.forms[0].src.value">' . __('Link to image') . '</button>
<p class="help">' . __('Enter a link URL or click above for presets.') . '</p></td>
</tr>
<tr class="image-only">
<td></td>
<td>
<input type="button" class="button" id="go_button" style="color:#bbb;" onclick="addExtImage.insert()" value="' . esc_attr__('Insert into Post') . '" />
</td>
</tr>
<tr class="not-image">
<td></td>
<td>
' . get_submit_button( __( 'Insert into Post' ), 'button', 'insertonlybutton', false ) . '
</td>
</tr>
</tbody></table>
';
}
function _insert_into_post_button($type) {
if ( !post_type_supports(get_post_type($_GET['post_id']), 'editor') )
return '';
if ( 'image' == $type )
return '
<tr>
<td></td>
<td>
<input type="button" class="button" id="go_button" style="color:#bbb;" onclick="addExtImage.insert()" value="' . esc_attr__('Insert into Post') . '" />
</td>
</tr>
';
return '
<tr>
<td></td>
<td>
' . get_submit_button( __( 'Insert into Post' ), 'button', 'insertonlybutton', false ) . '
</td>
</tr>
';
}
/**
* {@internal Missing Short Description}}
*
* @since 2.6.0
*/
function media_upload_flash_bypass() {
?>
<p class="upload-flash-bypass">
<?php _e('You are using the multi-file uploader. Problems? Try the <a href="#">browser uploader</a> instead.'); ?>
</p>
<?php
}
add_action('post-plupload-upload-ui', 'media_upload_flash_bypass');
/**
* {@internal Missing Short Description}}
*
* @since 2.6.0
*/
function media_upload_html_bypass() {
?>
<p class="upload-html-bypass hide-if-no-js">
<?php _e('You are using the browser’s built-in file uploader. The WordPress uploader includes multiple file selection and drag and drop capability. <a href="#">Switch to the multi-file uploader</a>.'); ?>
</p>
<?php
}
add_action('post-html-upload-ui', 'media_upload_html_bypass');
function media_upload_text_after() {
?>
<span class="after-file-upload"><?php _e('After a file has been uploaded, you can add titles and descriptions.'); ?></span>
<?php
}
add_action('post-upload-ui', 'media_upload_text_after', 5);
/**
* {@internal Missing Short Description}}
*
* @since 2.6.0
*/
function media_upload_max_image_resize() {
$checked = get_user_setting('upload_resize') ? ' checked="true"' : '';
$a = $end = '';
if ( current_user_can( 'manage_options' ) ) {
$a = '<a href="' . esc_url( admin_url( 'options-media.php' ) ) . '" target="_blank">';
$end = '</a>';
}
?>
<p class="hide-if-no-js"><label>
<input name="image_resize" type="checkbox" id="image_resize" value="true"<?php echo $checked; ?> />
<?php
/* translators: %1$s is link start tag, %2$s is link end tag, %3$d is width, %4$d is height*/
printf( __( 'Scale images to match the large size selected in %1$simage options%2$s (%3$d × %4$d).' ), $a, $end, (int) get_option( 'large_size_w', '1024' ), (int) get_option( 'large_size_h', '1024' ) );
?>
</label></p>
<?php
}
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_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_filter( 'media_upload_gallery', 'media_upload_gallery' );
add_filter( 'media_upload_library', 'media_upload_library' );
| 01happy-blog | trunk/myblog/wp-admin/includes/media.php | PHP | oos | 70,778 |
<?php
/**
* WordPress Core Ajax Handlers.
*
* @package WordPress
* @subpackage Administration
*/
/*
* No-privilege Ajax handlers.
*/
function wp_ajax_nopriv_autosave() {
$id = isset( $_POST['post_ID'] ) ? (int) $_POST['post_ID'] : 0;
if ( ! $id )
wp_die( -1 );
$message = sprintf( __('<strong>ALERT: You are logged out!</strong> Could not save draft. <a href="%s" target="_blank">Please log in again.</a>'), wp_login_url() );
$x = new WP_Ajax_Response( array(
'what' => 'autosave',
'id' => $id,
'data' => $message
) );
$x->send();
}
/*
* GET-based Ajax handlers.
*/
function wp_ajax_fetch_list() {
global $current_screen, $wp_list_table;
$list_class = $_GET['list_args']['class'];
check_ajax_referer( "fetch-list-$list_class", '_ajax_fetch_list_nonce' );
$current_screen = convert_to_screen( $_GET['list_args']['screen']['id'] );
define( 'WP_NETWORK_ADMIN', $current_screen->is_network );
define( 'WP_USER_ADMIN', $current_screen->is_user );
$wp_list_table = _get_list_table( $list_class );
if ( ! $wp_list_table )
wp_die( 0 );
if ( ! $wp_list_table->ajax_user_can() )
wp_die( -1 );
$wp_list_table->ajax_response();
wp_die( 0 );
}
function wp_ajax_ajax_tag_search() {
global $wpdb;
if ( isset( $_GET['tax'] ) ) {
$taxonomy = sanitize_key( $_GET['tax'] );
$tax = get_taxonomy( $taxonomy );
if ( ! $tax )
wp_die( 0 );
if ( ! current_user_can( $tax->cap->assign_terms ) )
wp_die( -1 );
} else {
wp_die( 0 );
}
$s = stripslashes( $_GET['q'] );
$comma = _x( ',', 'tag delimiter' );
if ( ',' !== $comma )
$s = str_replace( $comma, ',', $s );
if ( false !== strpos( $s, ',' ) ) {
$s = explode( ',', $s );
$s = $s[count( $s ) - 1];
}
$s = trim( $s );
if ( strlen( $s ) < 2 )
wp_die(); // require 2 chars for matching
$results = $wpdb->get_col( $wpdb->prepare( "SELECT t.name FROM $wpdb->term_taxonomy AS tt INNER JOIN $wpdb->terms AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = %s AND t.name LIKE (%s)", $taxonomy, '%' . like_escape( $s ) . '%' ) );
echo join( $results, "\n" );
wp_die();
}
function wp_ajax_wp_compression_test() {
if ( !current_user_can( 'manage_options' ) )
wp_die( -1 );
if ( ini_get('zlib.output_compression') || 'ob_gzhandler' == ini_get('output_handler') ) {
update_site_option('can_compress_scripts', 0);
wp_die( 0 );
}
if ( isset($_GET['test']) ) {
header( 'Expires: Wed, 11 Jan 1984 05:00:00 GMT' );
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
header( 'Cache-Control: no-cache, must-revalidate, max-age=0' );
header( 'Pragma: no-cache' );
header('Content-Type: application/x-javascript; charset=UTF-8');
$force_gzip = ( defined('ENFORCE_GZIP') && ENFORCE_GZIP );
$test_str = '"wpCompressionTest Lorem ipsum dolor sit amet consectetuer mollis sapien urna ut a. Eu nonummy condimentum fringilla tempor pretium platea vel nibh netus Maecenas. Hac molestie amet justo quis pellentesque est ultrices interdum nibh Morbi. Cras mattis pretium Phasellus ante ipsum ipsum ut sociis Suspendisse Lorem. Ante et non molestie. Porta urna Vestibulum egestas id congue nibh eu risus gravida sit. Ac augue auctor Ut et non a elit massa id sodales. Elit eu Nulla at nibh adipiscing mattis lacus mauris at tempus. Netus nibh quis suscipit nec feugiat eget sed lorem et urna. Pellentesque lacus at ut massa consectetuer ligula ut auctor semper Pellentesque. Ut metus massa nibh quam Curabitur molestie nec mauris congue. Volutpat molestie elit justo facilisis neque ac risus Ut nascetur tristique. Vitae sit lorem tellus et quis Phasellus lacus tincidunt nunc Fusce. Pharetra wisi Suspendisse mus sagittis libero lacinia Integer consequat ac Phasellus. Et urna ac cursus tortor aliquam Aliquam amet tellus volutpat Vestibulum. Justo interdum condimentum In augue congue tellus sollicitudin Quisque quis nibh."';
if ( 1 == $_GET['test'] ) {
echo $test_str;
wp_die();
} elseif ( 2 == $_GET['test'] ) {
if ( !isset($_SERVER['HTTP_ACCEPT_ENCODING']) )
wp_die( -1 );
if ( false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) {
header('Content-Encoding: deflate');
$out = gzdeflate( $test_str, 1 );
} elseif ( false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && function_exists('gzencode') ) {
header('Content-Encoding: gzip');
$out = gzencode( $test_str, 1 );
} else {
wp_die( -1 );
}
echo $out;
wp_die();
} elseif ( 'no' == $_GET['test'] ) {
update_site_option('can_compress_scripts', 0);
} elseif ( 'yes' == $_GET['test'] ) {
update_site_option('can_compress_scripts', 1);
}
}
wp_die( 0 );
}
function wp_ajax_imgedit_preview() {
$post_id = intval($_GET['postid']);
if ( empty($post_id) || !current_user_can('edit_post', $post_id) )
wp_die( -1 );
check_ajax_referer( "image_editor-$post_id" );
include_once( ABSPATH . 'wp-admin/includes/image-edit.php' );
if ( ! stream_preview_image($post_id) )
wp_die( -1 );
wp_die();
}
function wp_ajax_oembed_cache() {
global $wp_embed;
$return = ( $wp_embed->cache_oembed( $_GET['post'] ) ) ? '1' : '0';
wp_die( $return );
}
function wp_ajax_autocomplete_user() {
if ( ! is_multisite() || ! current_user_can( 'promote_users' ) || wp_is_large_network( 'users' ) )
wp_die( -1 );
if ( ! is_super_admin() && ! apply_filters( 'autocomplete_users_for_site_admins', false ) )
wp_die( -1 );
$return = array();
// Check the type of request
if ( isset( $_REQUEST['autocomplete_type'] ) )
$type = $_REQUEST['autocomplete_type'];
else
$type = 'add';
// Exclude current users of this blog
if ( isset( $_REQUEST['site_id'] ) )
$id = absint( $_REQUEST['site_id'] );
else
$id = get_current_blog_id();
$include_blog_users = ( $type == 'search' ? get_users( array( 'blog_id' => $id, 'fields' => 'ID' ) ) : array() );
$exclude_blog_users = ( $type == 'add' ? get_users( array( 'blog_id' => $id, 'fields' => 'ID' ) ) : array() );
$users = get_users( array(
'blog_id' => false,
'search' => '*' . $_REQUEST['term'] . '*',
'include' => $include_blog_users,
'exclude' => $exclude_blog_users,
'search_columns' => array( 'user_login', 'user_nicename', 'user_email' ),
) );
foreach ( $users as $user ) {
$return[] = array(
/* translators: 1: user_login, 2: user_email */
'label' => sprintf( __( '%1$s (%2$s)' ), $user->user_login, $user->user_email ),
'value' => $user->user_login,
);
}
wp_die( json_encode( $return ) );
}
function wp_ajax_dashboard_widgets() {
require ABSPATH . 'wp-admin/includes/dashboard.php';
switch ( $_GET['widget'] ) {
case 'dashboard_incoming_links' :
wp_dashboard_incoming_links();
break;
case 'dashboard_primary' :
wp_dashboard_primary();
break;
case 'dashboard_secondary' :
wp_dashboard_secondary();
break;
case 'dashboard_plugins' :
wp_dashboard_plugins();
break;
}
wp_die();
}
function wp_ajax_logged_in() {
wp_die( 1 );
}
/*
* Ajax helper.
*/
/**
* Sends back current comment total and new page links if they need to be updated.
*
* Contrary to normal success AJAX response ("1"), die with time() on success.
*
* @since 2.7
*
* @param int $comment_id
* @return die
*/
function _wp_ajax_delete_comment_response( $comment_id, $delta = -1 ) {
$total = (int) @$_POST['_total'];
$per_page = (int) @$_POST['_per_page'];
$page = (int) @$_POST['_page'];
$url = esc_url_raw( @$_POST['_url'] );
// JS didn't send us everything we need to know. Just die with success message
if ( !$total || !$per_page || !$page || !$url )
wp_die( time() );
$total += $delta;
if ( $total < 0 )
$total = 0;
// Only do the expensive stuff on a page-break, and about 1 other time per page
if ( 0 == $total % $per_page || 1 == mt_rand( 1, $per_page ) ) {
$post_id = 0;
$status = 'total_comments'; // What type of comment count are we looking for?
$parsed = parse_url( $url );
if ( isset( $parsed['query'] ) ) {
parse_str( $parsed['query'], $query_vars );
if ( !empty( $query_vars['comment_status'] ) )
$status = $query_vars['comment_status'];
if ( !empty( $query_vars['p'] ) )
$post_id = (int) $query_vars['p'];
}
$comment_count = wp_count_comments($post_id);
if ( isset( $comment_count->$status ) ) // We're looking for a known type of comment count
$total = $comment_count->$status;
// else use the decremented value from above
}
$time = time(); // The time since the last comment count
$x = new WP_Ajax_Response( array(
'what' => 'comment',
'id' => $comment_id, // here for completeness - not used
'supplemental' => array(
'total_items_i18n' => sprintf( _n( '1 item', '%s items', $total ), number_format_i18n( $total ) ),
'total_pages' => ceil( $total / $per_page ),
'total_pages_i18n' => number_format_i18n( ceil( $total / $per_page ) ),
'total' => $total,
'time' => $time
)
) );
$x->send();
}
/*
* POST-based Ajax handlers.
*/
function _wp_ajax_add_hierarchical_term() {
$action = $_POST['action'];
$taxonomy = get_taxonomy(substr($action, 4));
check_ajax_referer( $action, '_ajax_nonce-add-' . $taxonomy->name );
if ( !current_user_can( $taxonomy->cap->edit_terms ) )
wp_die( -1 );
$names = explode(',', $_POST['new'.$taxonomy->name]);
$parent = isset($_POST['new'.$taxonomy->name.'_parent']) ? (int) $_POST['new'.$taxonomy->name.'_parent'] : 0;
if ( 0 > $parent )
$parent = 0;
if ( $taxonomy->name == 'category' )
$post_category = isset($_POST['post_category']) ? (array) $_POST['post_category'] : array();
else
$post_category = ( isset($_POST['tax_input']) && isset($_POST['tax_input'][$taxonomy->name]) ) ? (array) $_POST['tax_input'][$taxonomy->name] : array();
$checked_categories = array_map( 'absint', (array) $post_category );
$popular_ids = wp_popular_terms_checklist($taxonomy->name, 0, 10, false);
foreach ( $names as $cat_name ) {
$cat_name = trim($cat_name);
$category_nicename = sanitize_title($cat_name);
if ( '' === $category_nicename )
continue;
if ( !$cat_id = term_exists( $cat_name, $taxonomy->name, $parent ) )
$cat_id = wp_insert_term( $cat_name, $taxonomy->name, array( 'parent' => $parent ) );
if ( is_wp_error( $cat_id ) )
continue;
else if ( is_array( $cat_id ) )
$cat_id = $cat_id['term_id'];
$checked_categories[] = $cat_id;
if ( $parent ) // Do these all at once in a second
continue;
ob_start();
wp_terms_checklist( 0, array( 'taxonomy' => $taxonomy->name, 'descendants_and_self' => $cat_id, 'selected_cats' => $checked_categories, 'popular_cats' => $popular_ids ));
$data = ob_get_contents();
ob_end_clean();
$add = array(
'what' => $taxonomy->name,
'id' => $cat_id,
'data' => str_replace( array("\n", "\t"), '', $data),
'position' => -1
);
}
if ( $parent ) { // Foncy - replace the parent and all its children
$parent = get_term( $parent, $taxonomy->name );
$term_id = $parent->term_id;
while ( $parent->parent ) { // get the top parent
$parent = &get_term( $parent->parent, $taxonomy->name );
if ( is_wp_error( $parent ) )
break;
$term_id = $parent->term_id;
}
ob_start();
wp_terms_checklist( 0, array('taxonomy' => $taxonomy->name, 'descendants_and_self' => $term_id, 'selected_cats' => $checked_categories, 'popular_cats' => $popular_ids));
$data = ob_get_contents();
ob_end_clean();
$add = array(
'what' => $taxonomy->name,
'id' => $term_id,
'data' => str_replace( array("\n", "\t"), '', $data),
'position' => -1
);
}
ob_start();
wp_dropdown_categories( array(
'taxonomy' => $taxonomy->name, 'hide_empty' => 0, 'name' => 'new'.$taxonomy->name.'_parent', 'orderby' => 'name',
'hierarchical' => 1, 'show_option_none' => '— '.$taxonomy->labels->parent_item.' —'
) );
$sup = ob_get_contents();
ob_end_clean();
$add['supplemental'] = array( 'newcat_parent' => $sup );
$x = new WP_Ajax_Response( $add );
$x->send();
}
function wp_ajax_delete_comment() {
$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
if ( !$comment = get_comment( $id ) )
wp_die( time() );
if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) )
wp_die( -1 );
check_ajax_referer( "delete-comment_$id" );
$status = wp_get_comment_status( $comment->comment_ID );
$delta = -1;
if ( isset($_POST['trash']) && 1 == $_POST['trash'] ) {
if ( 'trash' == $status )
wp_die( time() );
$r = wp_trash_comment( $comment->comment_ID );
} elseif ( isset($_POST['untrash']) && 1 == $_POST['untrash'] ) {
if ( 'trash' != $status )
wp_die( time() );
$r = wp_untrash_comment( $comment->comment_ID );
if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'trash' ) // undo trash, not in trash
$delta = 1;
} elseif ( isset($_POST['spam']) && 1 == $_POST['spam'] ) {
if ( 'spam' == $status )
wp_die( time() );
$r = wp_spam_comment( $comment->comment_ID );
} elseif ( isset($_POST['unspam']) && 1 == $_POST['unspam'] ) {
if ( 'spam' != $status )
wp_die( time() );
$r = wp_unspam_comment( $comment->comment_ID );
if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'spam' ) // undo spam, not in spam
$delta = 1;
} elseif ( isset($_POST['delete']) && 1 == $_POST['delete'] ) {
$r = wp_delete_comment( $comment->comment_ID );
} else {
wp_die( -1 );
}
if ( $r ) // Decide if we need to send back '1' or a more complicated response including page links and comment counts
_wp_ajax_delete_comment_response( $comment->comment_ID, $delta );
wp_die( 0 );
}
function wp_ajax_delete_tag() {
$tag_id = (int) $_POST['tag_ID'];
check_ajax_referer( "delete-tag_$tag_id" );
$taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag';
$tax = get_taxonomy($taxonomy);
if ( !current_user_can( $tax->cap->delete_terms ) )
wp_die( -1 );
$tag = get_term( $tag_id, $taxonomy );
if ( !$tag || is_wp_error( $tag ) )
wp_die( 1 );
if ( wp_delete_term($tag_id, $taxonomy))
wp_die( 1 );
else
wp_die( 0 );
}
function wp_ajax_delete_link() {
$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
check_ajax_referer( "delete-bookmark_$id" );
if ( !current_user_can( 'manage_links' ) )
wp_die( -1 );
$link = get_bookmark( $id );
if ( !$link || is_wp_error( $link ) )
wp_die( 1 );
if ( wp_delete_link( $id ) )
wp_die( 1 );
else
wp_die( 0 );
}
function wp_ajax_delete_meta() {
$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
check_ajax_referer( "delete-meta_$id" );
if ( !$meta = get_metadata_by_mid( 'post', $id ) )
wp_die( 1 );
if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'delete_post_meta', $meta->post_id, $meta->meta_key ) )
wp_die( -1 );
if ( delete_meta( $meta->meta_id ) )
wp_die( 1 );
wp_die( 0 );
}
function wp_ajax_delete_post( $action ) {
if ( empty( $action ) )
$action = 'delete-post';
$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
check_ajax_referer( "{$action}_$id" );
if ( !current_user_can( 'delete_post', $id ) )
wp_die( -1 );
if ( !get_post( $id ) )
wp_die( 1 );
if ( wp_delete_post( $id ) )
wp_die( 1 );
else
wp_die( 0 );
}
function wp_ajax_trash_post( $action ) {
if ( empty( $action ) )
$action = 'trash-post';
$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
check_ajax_referer( "{$action}_$id" );
if ( !current_user_can( 'delete_post', $id ) )
wp_die( -1 );
if ( !get_post( $id ) )
wp_die( 1 );
if ( 'trash-post' == $action )
$done = wp_trash_post( $id );
else
$done = wp_untrash_post( $id );
if ( $done )
wp_die( 1 );
wp_die( 0 );
}
function wp_ajax_untrash_post( $action ) {
if ( empty( $action ) )
$action = 'untrash-post';
wp_ajax_trash_post( $action );
}
function wp_ajax_delete_page( $action ) {
if ( empty( $action ) )
$action = 'delete-page';
$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
check_ajax_referer( "{$action}_$id" );
if ( !current_user_can( 'delete_page', $id ) )
wp_die( -1 );
if ( !get_page( $id ) )
wp_die( 1 );
if ( wp_delete_post( $id ) )
wp_die( 1 );
else
wp_die( 0 );
}
function wp_ajax_dim_comment() {
$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
if ( !$comment = get_comment( $id ) ) {
$x = new WP_Ajax_Response( array(
'what' => 'comment',
'id' => new WP_Error('invalid_comment', sprintf(__('Comment %d does not exist'), $id))
) );
$x->send();
}
if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) && ! current_user_can( 'moderate_comments' ) )
wp_die( -1 );
$current = wp_get_comment_status( $comment->comment_ID );
if ( $_POST['new'] == $current )
wp_die( time() );
check_ajax_referer( "approve-comment_$id" );
if ( in_array( $current, array( 'unapproved', 'spam' ) ) )
$result = wp_set_comment_status( $comment->comment_ID, 'approve', true );
else
$result = wp_set_comment_status( $comment->comment_ID, 'hold', true );
if ( is_wp_error($result) ) {
$x = new WP_Ajax_Response( array(
'what' => 'comment',
'id' => $result
) );
$x->send();
}
// Decide if we need to send back '1' or a more complicated response including page links and comment counts
_wp_ajax_delete_comment_response( $comment->comment_ID );
wp_die( 0 );
}
function wp_ajax_add_link_category( $action ) {
if ( empty( $action ) )
$action = 'add-link-category';
check_ajax_referer( $action );
if ( !current_user_can( 'manage_categories' ) )
wp_die( -1 );
$names = explode(',', $_POST['newcat']);
$x = new WP_Ajax_Response();
foreach ( $names as $cat_name ) {
$cat_name = trim($cat_name);
$slug = sanitize_title($cat_name);
if ( '' === $slug )
continue;
if ( !$cat_id = term_exists( $cat_name, 'link_category' ) )
$cat_id = wp_insert_term( $cat_name, 'link_category' );
if ( is_wp_error( $cat_id ) )
continue;
else if ( is_array( $cat_id ) )
$cat_id = $cat_id['term_id'];
$cat_name = esc_html(stripslashes($cat_name));
$x->add( array(
'what' => 'link-category',
'id' => $cat_id,
'data' => "<li id='link-category-$cat_id'><label for='in-link-category-$cat_id' class='selectit'><input value='" . esc_attr($cat_id) . "' type='checkbox' checked='checked' name='link_category[]' id='in-link-category-$cat_id'/> $cat_name</label></li>",
'position' => -1
) );
}
$x->send();
}
function wp_ajax_add_tag() {
global $wp_list_table;
check_ajax_referer( 'add-tag', '_wpnonce_add-tag' );
$post_type = !empty($_POST['post_type']) ? $_POST['post_type'] : 'post';
$taxonomy = !empty($_POST['taxonomy']) ? $_POST['taxonomy'] : 'post_tag';
$tax = get_taxonomy($taxonomy);
if ( !current_user_can( $tax->cap->edit_terms ) )
wp_die( -1 );
$x = new WP_Ajax_Response();
$tag = wp_insert_term($_POST['tag-name'], $taxonomy, $_POST );
if ( !$tag || is_wp_error($tag) || (!$tag = get_term( $tag['term_id'], $taxonomy )) ) {
$message = __('An error has occurred. Please reload the page and try again.');
if ( is_wp_error($tag) && $tag->get_error_message() )
$message = $tag->get_error_message();
$x->add( array(
'what' => 'taxonomy',
'data' => new WP_Error('error', $message )
) );
$x->send();
}
set_current_screen( $_POST['screen'] );
$wp_list_table = _get_list_table('WP_Terms_List_Table');
$level = 0;
if ( is_taxonomy_hierarchical($taxonomy) ) {
$level = count( get_ancestors( $tag->term_id, $taxonomy ) );
ob_start();
$wp_list_table->single_row( $tag, $level );
$noparents = ob_get_clean();
}
ob_start();
$wp_list_table->single_row( $tag );
$parents = ob_get_clean();
$x->add( array(
'what' => 'taxonomy',
'supplemental' => compact('parents', 'noparents')
) );
$x->add( array(
'what' => 'term',
'position' => $level,
'supplemental' => (array) $tag
) );
$x->send();
}
function wp_ajax_get_tagcloud() {
if ( isset( $_POST['tax'] ) ) {
$taxonomy = sanitize_key( $_POST['tax'] );
$tax = get_taxonomy( $taxonomy );
if ( ! $tax )
wp_die( 0 );
if ( ! current_user_can( $tax->cap->assign_terms ) )
wp_die( -1 );
} else {
wp_die( 0 );
}
$tags = get_terms( $taxonomy, array( 'number' => 45, 'orderby' => 'count', 'order' => 'DESC' ) );
if ( empty( $tags ) )
wp_die( isset( $tax->no_tagcloud ) ? $tax->no_tagcloud : __('No tags found!') );
if ( is_wp_error( $tags ) )
wp_die( $tags->get_error_message() );
foreach ( $tags as $key => $tag ) {
$tags[ $key ]->link = '#';
$tags[ $key ]->id = $tag->term_id;
}
// We need raw tag names here, so don't filter the output
$return = wp_generate_tag_cloud( $tags, array('filter' => 0) );
if ( empty($return) )
wp_die( 0 );
echo $return;
wp_die();
}
function wp_ajax_get_comments( $action ) {
global $wp_list_table, $post_id;
if ( empty( $action ) )
$action = 'get-comments';
check_ajax_referer( $action );
set_current_screen( 'edit-comments' );
$wp_list_table = _get_list_table('WP_Post_Comments_List_Table');
if ( !current_user_can( 'edit_post', $post_id ) )
wp_die( -1 );
$wp_list_table->prepare_items();
if ( !$wp_list_table->has_items() )
wp_die( 1 );
$x = new WP_Ajax_Response();
ob_start();
foreach ( $wp_list_table->items as $comment ) {
if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) )
continue;
get_comment( $comment );
$wp_list_table->single_row( $comment );
}
$comment_list_item = ob_get_contents();
ob_end_clean();
$x->add( array(
'what' => 'comments',
'data' => $comment_list_item
) );
$x->send();
}
function wp_ajax_replyto_comment( $action ) {
global $wp_list_table, $wpdb;
if ( empty( $action ) )
$action = 'replyto-comment';
check_ajax_referer( $action, '_ajax_nonce-replyto-comment' );
set_current_screen( 'edit-comments' );
$comment_post_ID = (int) $_POST['comment_post_ID'];
if ( !current_user_can( 'edit_post', $comment_post_ID ) )
wp_die( -1 );
$status = $wpdb->get_var( $wpdb->prepare("SELECT post_status FROM $wpdb->posts WHERE ID = %d", $comment_post_ID) );
if ( empty($status) )
wp_die( 1 );
elseif ( in_array($status, array('draft', 'pending', 'trash') ) )
wp_die( __('ERROR: you are replying to a comment on a draft post.') );
$user = wp_get_current_user();
if ( $user->exists() ) {
$user_ID = $user->ID;
$comment_author = $wpdb->escape($user->display_name);
$comment_author_email = $wpdb->escape($user->user_email);
$comment_author_url = $wpdb->escape($user->user_url);
$comment_content = trim($_POST['content']);
if ( current_user_can( 'unfiltered_html' ) ) {
if ( wp_create_nonce( 'unfiltered-html-comment' ) != $_POST['_wp_unfiltered_html_comment'] ) {
kses_remove_filters(); // start with a clean slate
kses_init_filters(); // set up the filters
}
}
} else {
wp_die( __( 'Sorry, you must be logged in to reply to a comment.' ) );
}
if ( '' == $comment_content )
wp_die( __( 'ERROR: please type a comment.' ) );
$comment_parent = absint($_POST['comment_ID']);
$comment_auto_approved = false;
$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID');
$comment_id = wp_new_comment( $commentdata );
$comment = get_comment($comment_id);
if ( ! $comment ) wp_die( 1 );
$position = ( isset($_POST['position']) && (int) $_POST['position'] ) ? (int) $_POST['position'] : '-1';
// automatically approve parent comment
if ( !empty($_POST['approve_parent']) ) {
$parent = get_comment( $comment_parent );
if ( $parent && $parent->comment_approved === '0' && $parent->comment_post_ID == $comment_post_ID ) {
if ( wp_set_comment_status( $parent->comment_ID, 'approve' ) )
$comment_auto_approved = true;
}
}
ob_start();
if ( 'dashboard' == $_REQUEST['mode'] ) {
require_once( ABSPATH . 'wp-admin/includes/dashboard.php' );
_wp_dashboard_recent_comments_row( $comment );
} else {
if ( 'single' == $_REQUEST['mode'] ) {
$wp_list_table = _get_list_table('WP_Post_Comments_List_Table');
} else {
$wp_list_table = _get_list_table('WP_Comments_List_Table');
}
$wp_list_table->single_row( $comment );
}
$comment_list_item = ob_get_contents();
ob_end_clean();
$response = array(
'what' => 'comment',
'id' => $comment->comment_ID,
'data' => $comment_list_item,
'position' => $position
);
if ( $comment_auto_approved )
$response['supplemental'] = array( 'parent_approved' => $parent->comment_ID );
$x = new WP_Ajax_Response();
$x->add( $response );
$x->send();
}
function wp_ajax_edit_comment() {
global $wp_list_table;
check_ajax_referer( 'replyto-comment', '_ajax_nonce-replyto-comment' );
set_current_screen( 'edit-comments' );
$comment_id = (int) $_POST['comment_ID'];
if ( ! current_user_can( 'edit_comment', $comment_id ) )
wp_die( -1 );
if ( '' == $_POST['content'] )
wp_die( __( 'ERROR: please type a comment.' ) );
$_POST['comment_status'] = $_POST['status'];
edit_comment();
$position = ( isset($_POST['position']) && (int) $_POST['position']) ? (int) $_POST['position'] : '-1';
$comments_status = isset($_POST['comments_listing']) ? $_POST['comments_listing'] : '';
$checkbox = ( isset($_POST['checkbox']) && true == $_POST['checkbox'] ) ? 1 : 0;
$wp_list_table = _get_list_table( $checkbox ? 'WP_Comments_List_Table' : 'WP_Post_Comments_List_Table' );
$comment = get_comment( $comment_id );
ob_start();
$wp_list_table->single_row( $comment );
$comment_list_item = ob_get_contents();
ob_end_clean();
$x = new WP_Ajax_Response();
$x->add( array(
'what' => 'edit_comment',
'id' => $comment->comment_ID,
'data' => $comment_list_item,
'position' => $position
));
$x->send();
}
function wp_ajax_add_menu_item() {
check_ajax_referer( 'add-menu_item', 'menu-settings-column-nonce' );
if ( ! current_user_can( 'edit_theme_options' ) )
wp_die( -1 );
require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
// For performance reasons, we omit some object properties from the checklist.
// The following is a hacky way to restore them when adding non-custom items.
$menu_items_data = array();
foreach ( (array) $_POST['menu-item'] as $menu_item_data ) {
if (
! empty( $menu_item_data['menu-item-type'] ) &&
'custom' != $menu_item_data['menu-item-type'] &&
! empty( $menu_item_data['menu-item-object-id'] )
) {
switch( $menu_item_data['menu-item-type'] ) {
case 'post_type' :
$_object = get_post( $menu_item_data['menu-item-object-id'] );
break;
case 'taxonomy' :
$_object = get_term( $menu_item_data['menu-item-object-id'], $menu_item_data['menu-item-object'] );
break;
}
$_menu_items = array_map( 'wp_setup_nav_menu_item', array( $_object ) );
$_menu_item = array_shift( $_menu_items );
// Restore the missing menu item properties
$menu_item_data['menu-item-description'] = $_menu_item->description;
}
$menu_items_data[] = $menu_item_data;
}
$item_ids = wp_save_nav_menu_items( 0, $menu_items_data );
if ( is_wp_error( $item_ids ) )
wp_die( 0 );
$menu_items = array();
foreach ( (array) $item_ids as $menu_item_id ) {
$menu_obj = get_post( $menu_item_id );
if ( ! empty( $menu_obj->ID ) ) {
$menu_obj = wp_setup_nav_menu_item( $menu_obj );
$menu_obj->label = $menu_obj->title; // don't show "(pending)" in ajax-added items
$menu_items[] = $menu_obj;
}
}
$walker_class_name = apply_filters( 'wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $_POST['menu'] );
if ( ! class_exists( $walker_class_name ) )
wp_die( 0 );
if ( ! empty( $menu_items ) ) {
$args = array(
'after' => '',
'before' => '',
'link_after' => '',
'link_before' => '',
'walker' => new $walker_class_name,
);
echo walk_nav_menu_tree( $menu_items, 0, (object) $args );
}
}
function wp_ajax_add_meta() {
check_ajax_referer( 'add-meta', '_ajax_nonce-add-meta' );
$c = 0;
$pid = (int) $_POST['post_id'];
$post = get_post( $pid );
if ( isset($_POST['metakeyselect']) || isset($_POST['metakeyinput']) ) {
if ( !current_user_can( 'edit_post', $pid ) )
wp_die( -1 );
if ( isset($_POST['metakeyselect']) && '#NONE#' == $_POST['metakeyselect'] && empty($_POST['metakeyinput']) )
wp_die( 1 );
if ( $post->post_status == 'auto-draft' ) {
$save_POST = $_POST; // Backup $_POST
$_POST = array(); // Make it empty for edit_post()
$_POST['action'] = 'draft'; // Warning fix
$_POST['post_ID'] = $pid;
$_POST['post_type'] = $post->post_type;
$_POST['post_status'] = 'draft';
$now = current_time('timestamp', 1);
$_POST['post_title'] = sprintf('Draft created on %s at %s', date(get_option('date_format'), $now), date(get_option('time_format'), $now));
if ( $pid = edit_post() ) {
if ( is_wp_error( $pid ) ) {
$x = new WP_Ajax_Response( array(
'what' => 'meta',
'data' => $pid
) );
$x->send();
}
$_POST = $save_POST; // Now we can restore original $_POST again
if ( !$mid = add_meta( $pid ) )
wp_die( __( 'Please provide a custom field value.' ) );
} else {
wp_die( 0 );
}
} else if ( !$mid = add_meta( $pid ) ) {
wp_die( __( 'Please provide a custom field value.' ) );
}
$meta = get_metadata_by_mid( 'post', $mid );
$pid = (int) $meta->post_id;
$meta = get_object_vars( $meta );
$x = new WP_Ajax_Response( array(
'what' => 'meta',
'id' => $mid,
'data' => _list_meta_row( $meta, $c ),
'position' => 1,
'supplemental' => array('postid' => $pid)
) );
} else { // Update?
$mid = (int) key( $_POST['meta'] );
$key = stripslashes( $_POST['meta'][$mid]['key'] );
$value = stripslashes( $_POST['meta'][$mid]['value'] );
if ( '' == trim($key) )
wp_die( __( 'Please provide a custom field name.' ) );
if ( '' == trim($value) )
wp_die( __( 'Please provide a custom field value.' ) );
if ( ! $meta = get_metadata_by_mid( 'post', $mid ) )
wp_die( 0 ); // if meta doesn't exist
if ( is_protected_meta( $meta->meta_key, 'post' ) || is_protected_meta( $key, 'post' ) ||
! current_user_can( 'edit_post_meta', $meta->post_id, $meta->meta_key ) ||
! current_user_can( 'edit_post_meta', $meta->post_id, $key ) )
wp_die( -1 );
if ( $meta->meta_value != $value || $meta->meta_key != $key ) {
if ( !$u = update_metadata_by_mid( 'post', $mid, $value, $key ) )
wp_die( 0 ); // We know meta exists; we also know it's unchanged (or DB error, in which case there are bigger problems).
}
$x = new WP_Ajax_Response( array(
'what' => 'meta',
'id' => $mid, 'old_id' => $mid,
'data' => _list_meta_row( array(
'meta_key' => $key,
'meta_value' => $value,
'meta_id' => $mid
), $c ),
'position' => 0,
'supplemental' => array('postid' => $meta->post_id)
) );
}
$x->send();
}
function wp_ajax_add_user( $action ) {
global $wp_list_table;
if ( empty( $action ) )
$action = 'add-user';
check_ajax_referer( $action );
if ( ! current_user_can('create_users') )
wp_die( -1 );
if ( ! $user_id = edit_user() ) {
wp_die( 0 );
} elseif ( is_wp_error( $user_id ) ) {
$x = new WP_Ajax_Response( array(
'what' => 'user',
'id' => $user_id
) );
$x->send();
}
$user_object = new WP_User( $user_id );
$wp_list_table = _get_list_table('WP_Users_List_Table');
$x = new WP_Ajax_Response( array(
'what' => 'user',
'id' => $user_id,
'data' => $wp_list_table->single_row( $user_object, '', $user_object->roles[0] ),
'supplemental' => array(
'show-link' => sprintf(__( 'User <a href="#%s">%s</a> added' ), "user-$user_id", $user_object->user_login),
'role' => $user_object->roles[0]
)
) );
$x->send();
}
function wp_ajax_autosave() {
global $login_grace_period;
define( 'DOING_AUTOSAVE', true );
$nonce_age = check_ajax_referer( 'autosave', 'autosavenonce' );
$_POST['post_category'] = explode(",", $_POST['catslist']);
if ( $_POST['post_type'] == 'page' || empty($_POST['post_category']) )
unset($_POST['post_category']);
$do_autosave = (bool) $_POST['autosave'];
$do_lock = true;
$data = $alert = '';
/* translators: draft saved date format, see http://php.net/date */
$draft_saved_date_format = __('g:i:s a');
/* translators: %s: date and time */
$message = sprintf( __('Draft saved at %s.'), date_i18n( $draft_saved_date_format ) );
$supplemental = array();
if ( isset($login_grace_period) )
$alert .= sprintf( __('Your login has expired. Please open a new browser window and <a href="%s" target="_blank">log in again</a>. '), add_query_arg( 'interim-login', 1, wp_login_url() ) );
$id = $revision_id = 0;
$post_ID = (int) $_POST['post_ID'];
$_POST['ID'] = $post_ID;
$post = get_post($post_ID);
if ( 'auto-draft' == $post->post_status )
$_POST['post_status'] = 'draft';
if ( $last = wp_check_post_lock( $post->ID ) ) {
$do_autosave = $do_lock = false;
$last_user = get_userdata( $last );
$last_user_name = $last_user ? $last_user->display_name : __( 'Someone' );
$data = __( 'Autosave disabled.' );
$supplemental['disable_autosave'] = 'disable';
$alert .= sprintf( __( '%s is currently editing this article. If you update it, you will overwrite the changes.' ), esc_html( $last_user_name ) );
}
if ( 'page' == $post->post_type ) {
if ( !current_user_can('edit_page', $post_ID) )
wp_die( __( 'You are not allowed to edit this page.' ) );
} else {
if ( !current_user_can('edit_post', $post_ID) )
wp_die( __( 'You are not allowed to edit this post.' ) );
}
if ( $do_autosave ) {
// Drafts and auto-drafts are just overwritten by autosave
if ( 'auto-draft' == $post->post_status || 'draft' == $post->post_status ) {
$id = edit_post();
} else { // Non drafts are not overwritten. The autosave is stored in a special post revision.
$revision_id = wp_create_post_autosave( $post->ID );
if ( is_wp_error($revision_id) )
$id = $revision_id;
else
$id = $post->ID;
}
$data = $message;
} else {
if ( ! empty( $_POST['auto_draft'] ) )
$id = 0; // This tells us it didn't actually save
else
$id = $post->ID;
}
if ( $do_lock && empty( $_POST['auto_draft'] ) && $id && is_numeric( $id ) ) {
$lock_result = wp_set_post_lock( $id );
$supplemental['active-post-lock'] = implode( ':', $lock_result );
}
if ( $nonce_age == 2 ) {
$supplemental['replace-autosavenonce'] = wp_create_nonce('autosave');
$supplemental['replace-getpermalinknonce'] = wp_create_nonce('getpermalink');
$supplemental['replace-samplepermalinknonce'] = wp_create_nonce('samplepermalink');
$supplemental['replace-closedpostboxesnonce'] = wp_create_nonce('closedpostboxes');
$supplemental['replace-_ajax_linking_nonce'] = wp_create_nonce( 'internal-linking' );
if ( $id ) {
if ( $_POST['post_type'] == 'post' )
$supplemental['replace-_wpnonce'] = wp_create_nonce('update-post_' . $id);
elseif ( $_POST['post_type'] == 'page' )
$supplemental['replace-_wpnonce'] = wp_create_nonce('update-page_' . $id);
}
}
if ( ! empty($alert) )
$supplemental['alert'] = $alert;
$x = new WP_Ajax_Response( array(
'what' => 'autosave',
'id' => $id,
'data' => $id ? $data : '',
'supplemental' => $supplemental
) );
$x->send();
}
function wp_ajax_closed_postboxes() {
check_ajax_referer( 'closedpostboxes', 'closedpostboxesnonce' );
$closed = isset( $_POST['closed'] ) ? explode( ',', $_POST['closed']) : array();
$closed = array_filter($closed);
$hidden = isset( $_POST['hidden'] ) ? explode( ',', $_POST['hidden']) : array();
$hidden = array_filter($hidden);
$page = isset( $_POST['page'] ) ? $_POST['page'] : '';
if ( $page != sanitize_key( $page ) )
wp_die( 0 );
if ( ! $user = wp_get_current_user() )
wp_die( -1 );
if ( is_array($closed) )
update_user_option($user->ID, "closedpostboxes_$page", $closed, true);
if ( is_array($hidden) ) {
$hidden = array_diff( $hidden, array('submitdiv', 'linksubmitdiv', 'manage-menu', 'create-menu') ); // postboxes that are always shown
update_user_option($user->ID, "metaboxhidden_$page", $hidden, true);
}
wp_die( 1 );
}
function wp_ajax_hidden_columns() {
check_ajax_referer( 'screen-options-nonce', 'screenoptionnonce' );
$hidden = isset( $_POST['hidden'] ) ? $_POST['hidden'] : '';
$hidden = explode( ',', $_POST['hidden'] );
$page = isset( $_POST['page'] ) ? $_POST['page'] : '';
if ( $page != sanitize_key( $page ) )
wp_die( 0 );
if ( ! $user = wp_get_current_user() )
wp_die( -1 );
if ( is_array($hidden) )
update_user_option($user->ID, "manage{$page}columnshidden", $hidden, true);
wp_die( 1 );
}
function wp_ajax_update_welcome_panel() {
check_ajax_referer( 'welcome-panel-nonce', 'welcomepanelnonce' );
if ( ! current_user_can( 'edit_theme_options' ) )
wp_die( -1 );
update_user_meta( get_current_user_id(), 'show_welcome_panel', empty( $_POST['visible'] ) ? 0 : 1 );
wp_die( 1 );
}
function wp_ajax_menu_get_metabox() {
if ( ! current_user_can( 'edit_theme_options' ) )
wp_die( -1 );
require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
if ( isset( $_POST['item-type'] ) && 'post_type' == $_POST['item-type'] ) {
$type = 'posttype';
$callback = 'wp_nav_menu_item_post_type_meta_box';
$items = (array) get_post_types( array( 'show_in_nav_menus' => true ), 'object' );
} elseif ( isset( $_POST['item-type'] ) && 'taxonomy' == $_POST['item-type'] ) {
$type = 'taxonomy';
$callback = 'wp_nav_menu_item_taxonomy_meta_box';
$items = (array) get_taxonomies( array( 'show_ui' => true ), 'object' );
}
if ( ! empty( $_POST['item-object'] ) && isset( $items[$_POST['item-object']] ) ) {
$item = apply_filters( 'nav_menu_meta_box_object', $items[ $_POST['item-object'] ] );
ob_start();
call_user_func_array($callback, array(
null,
array(
'id' => 'add-' . $item->name,
'title' => $item->labels->name,
'callback' => $callback,
'args' => $item,
)
));
$markup = ob_get_clean();
echo json_encode(array(
'replace-id' => $type . '-' . $item->name,
'markup' => $markup,
));
}
wp_die();
}
function wp_ajax_wp_link_ajax() {
check_ajax_referer( 'internal-linking', '_ajax_linking_nonce' );
$args = array();
if ( isset( $_POST['search'] ) )
$args['s'] = stripslashes( $_POST['search'] );
$args['pagenum'] = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1;
require(ABSPATH . WPINC . '/class-wp-editor.php');
$results = _WP_Editors::wp_link_query( $args );
if ( ! isset( $results ) )
wp_die( 0 );
echo json_encode( $results );
echo "\n";
wp_die();
}
function wp_ajax_menu_locations_save() {
if ( ! current_user_can( 'edit_theme_options' ) )
wp_die( -1 );
check_ajax_referer( 'add-menu_item', 'menu-settings-column-nonce' );
if ( ! isset( $_POST['menu-locations'] ) )
wp_die( 0 );
set_theme_mod( 'nav_menu_locations', array_map( 'absint', $_POST['menu-locations'] ) );
wp_die( 1 );
}
function wp_ajax_meta_box_order() {
check_ajax_referer( 'meta-box-order' );
$order = isset( $_POST['order'] ) ? (array) $_POST['order'] : false;
$page_columns = isset( $_POST['page_columns'] ) ? $_POST['page_columns'] : 'auto';
if ( $page_columns != 'auto' )
$page_columns = (int) $page_columns;
$page = isset( $_POST['page'] ) ? $_POST['page'] : '';
if ( $page != sanitize_key( $page ) )
wp_die( 0 );
if ( ! $user = wp_get_current_user() )
wp_die( -1 );
if ( $order )
update_user_option($user->ID, "meta-box-order_$page", $order, true);
if ( $page_columns )
update_user_option($user->ID, "screen_layout_$page", $page_columns, true);
wp_die( 1 );
}
function wp_ajax_menu_quick_search() {
if ( ! current_user_can( 'edit_theme_options' ) )
wp_die( -1 );
require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
_wp_ajax_menu_quick_search( $_POST );
wp_die();
}
function wp_ajax_get_permalink() {
check_ajax_referer( 'getpermalink', 'getpermalinknonce' );
$post_id = isset($_POST['post_id'])? intval($_POST['post_id']) : 0;
wp_die( add_query_arg( array( 'preview' => 'true' ), get_permalink( $post_id ) ) );
}
function wp_ajax_sample_permalink() {
check_ajax_referer( 'samplepermalink', 'samplepermalinknonce' );
$post_id = isset($_POST['post_id'])? intval($_POST['post_id']) : 0;
$title = isset($_POST['new_title'])? $_POST['new_title'] : '';
$slug = isset($_POST['new_slug'])? $_POST['new_slug'] : null;
wp_die( get_sample_permalink_html( $post_id, $title, $slug ) );
}
function wp_ajax_inline_save() {
global $wp_list_table;
check_ajax_referer( 'inlineeditnonce', '_inline_edit' );
if ( ! isset($_POST['post_ID']) || ! ( $post_ID = (int) $_POST['post_ID'] ) )
wp_die();
if ( 'page' == $_POST['post_type'] ) {
if ( ! current_user_can( 'edit_page', $post_ID ) )
wp_die( __( 'You are not allowed to edit this page.' ) );
} else {
if ( ! current_user_can( 'edit_post', $post_ID ) )
wp_die( __( 'You are not allowed to edit this post.' ) );
}
set_current_screen( $_POST['screen'] );
if ( $last = wp_check_post_lock( $post_ID ) ) {
$last_user = get_userdata( $last );
$last_user_name = $last_user ? $last_user->display_name : __( 'Someone' );
printf( $_POST['post_type'] == 'page' ? __( 'Saving is disabled: %s is currently editing this page.' ) : __( 'Saving is disabled: %s is currently editing this post.' ), esc_html( $last_user_name ) );
wp_die();
}
$data = &$_POST;
$post = get_post( $post_ID, ARRAY_A );
$post = add_magic_quotes($post); //since it is from db
$data['content'] = $post['post_content'];
$data['excerpt'] = $post['post_excerpt'];
// rename
$data['user_ID'] = $GLOBALS['user_ID'];
if ( isset($data['post_parent']) )
$data['parent_id'] = $data['post_parent'];
// status
if ( isset($data['keep_private']) && 'private' == $data['keep_private'] )
$data['post_status'] = 'private';
else
$data['post_status'] = $data['_status'];
if ( empty($data['comment_status']) )
$data['comment_status'] = 'closed';
if ( empty($data['ping_status']) )
$data['ping_status'] = 'closed';
// update the post
edit_post();
$wp_list_table = _get_list_table('WP_Posts_List_Table');
$mode = $_POST['post_view'];
$wp_list_table->display_rows( array( get_post( $_POST['post_ID'] ) ) );
wp_die();
}
function wp_ajax_inline_save_tax() {
global $wp_list_table;
check_ajax_referer( 'taxinlineeditnonce', '_inline_edit' );
$taxonomy = sanitize_key( $_POST['taxonomy'] );
$tax = get_taxonomy( $taxonomy );
if ( ! $tax )
wp_die( 0 );
if ( ! current_user_can( $tax->cap->edit_terms ) )
wp_die( -1 );
set_current_screen( 'edit-' . $taxonomy );
$wp_list_table = _get_list_table('WP_Terms_List_Table');
if ( ! isset($_POST['tax_ID']) || ! ( $id = (int) $_POST['tax_ID'] ) )
wp_die( -1 );
$tag = get_term( $id, $taxonomy );
$_POST['description'] = $tag->description;
$updated = wp_update_term($id, $taxonomy, $_POST);
if ( $updated && !is_wp_error($updated) ) {
$tag = get_term( $updated['term_id'], $taxonomy );
if ( !$tag || is_wp_error( $tag ) ) {
if ( is_wp_error($tag) && $tag->get_error_message() )
wp_die( $tag->get_error_message() );
wp_die( __( 'Item not updated.' ) );
}
echo $wp_list_table->single_row( $tag );
} else {
if ( is_wp_error($updated) && $updated->get_error_message() )
wp_die( $updated->get_error_message() );
wp_die( __( 'Item not updated.' ) );
}
wp_die();
}
function wp_ajax_find_posts() {
global $wpdb;
check_ajax_referer( 'find-posts' );
if ( empty($_POST['ps']) )
wp_die();
if ( !empty($_POST['post_type']) && in_array( $_POST['post_type'], get_post_types() ) )
$what = $_POST['post_type'];
else
$what = 'post';
$s = stripslashes($_POST['ps']);
preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches);
$search_terms = array_map('_search_terms_tidy', $matches[0]);
$searchand = $search = '';
foreach ( (array) $search_terms as $term ) {
$term = esc_sql( like_escape( $term ) );
$search .= "{$searchand}(($wpdb->posts.post_title LIKE '%{$term}%') OR ($wpdb->posts.post_content LIKE '%{$term}%'))";
$searchand = ' AND ';
}
$term = esc_sql( like_escape( $s ) );
if ( count($search_terms) > 1 && $search_terms[0] != $s )
$search .= " OR ($wpdb->posts.post_title LIKE '%{$term}%') OR ($wpdb->posts.post_content LIKE '%{$term}%')";
$posts = $wpdb->get_results( "SELECT ID, post_title, post_status, post_date FROM $wpdb->posts WHERE post_type = '$what' AND post_status IN ('draft', 'publish') AND ($search) ORDER BY post_date_gmt DESC LIMIT 50" );
if ( ! $posts ) {
$posttype = get_post_type_object($what);
wp_die( $posttype->labels->not_found );
}
$html = '<table class="widefat" cellspacing="0"><thead><tr><th class="found-radio"><br /></th><th>'.__('Title').'</th><th>'.__('Date').'</th><th>'.__('Status').'</th></tr></thead><tbody>';
foreach ( $posts as $post ) {
switch ( $post->post_status ) {
case 'publish' :
case 'private' :
$stat = __('Published');
break;
case 'future' :
$stat = __('Scheduled');
break;
case 'pending' :
$stat = __('Pending Review');
break;
case 'draft' :
$stat = __('Draft');
break;
}
if ( '0000-00-00 00:00:00' == $post->post_date ) {
$time = '';
} else {
/* translators: date format in table columns, see http://php.net/date */
$time = mysql2date(__('Y/m/d'), $post->post_date);
}
$html .= '<tr class="found-posts"><td class="found-radio"><input type="radio" id="found-'.$post->ID.'" name="found_post_id" value="' . esc_attr($post->ID) . '"></td>';
$html .= '<td><label for="found-'.$post->ID.'">'.esc_html( $post->post_title ).'</label></td><td>'.esc_html( $time ).'</td><td>'.esc_html( $stat ).'</td></tr>'."\n\n";
}
$html .= '</tbody></table>';
$x = new WP_Ajax_Response();
$x->add( array(
'what' => $what,
'data' => $html
));
$x->send();
}
function wp_ajax_widgets_order() {
check_ajax_referer( 'save-sidebar-widgets', 'savewidgets' );
if ( !current_user_can('edit_theme_options') )
wp_die( -1 );
unset( $_POST['savewidgets'], $_POST['action'] );
// save widgets order for all sidebars
if ( is_array($_POST['sidebars']) ) {
$sidebars = array();
foreach ( $_POST['sidebars'] as $key => $val ) {
$sb = array();
if ( !empty($val) ) {
$val = explode(',', $val);
foreach ( $val as $k => $v ) {
if ( strpos($v, 'widget-') === false )
continue;
$sb[$k] = substr($v, strpos($v, '_') + 1);
}
}
$sidebars[$key] = $sb;
}
wp_set_sidebars_widgets($sidebars);
wp_die( 1 );
}
wp_die( -1 );
}
function wp_ajax_save_widget() {
global $wp_registered_widgets, $wp_registered_widget_controls, $wp_registered_widget_updates;
check_ajax_referer( 'save-sidebar-widgets', 'savewidgets' );
if ( !current_user_can('edit_theme_options') || !isset($_POST['id_base']) )
wp_die( -1 );
unset( $_POST['savewidgets'], $_POST['action'] );
do_action('load-widgets.php');
do_action('widgets.php');
do_action('sidebar_admin_setup');
$id_base = $_POST['id_base'];
$widget_id = $_POST['widget-id'];
$sidebar_id = $_POST['sidebar'];
$multi_number = !empty($_POST['multi_number']) ? (int) $_POST['multi_number'] : 0;
$settings = isset($_POST['widget-' . $id_base]) && is_array($_POST['widget-' . $id_base]) ? $_POST['widget-' . $id_base] : false;
$error = '<p>' . __('An error has occurred. Please reload the page and try again.') . '</p>';
$sidebars = wp_get_sidebars_widgets();
$sidebar = isset($sidebars[$sidebar_id]) ? $sidebars[$sidebar_id] : array();
// delete
if ( isset($_POST['delete_widget']) && $_POST['delete_widget'] ) {
if ( !isset($wp_registered_widgets[$widget_id]) )
wp_die( $error );
$sidebar = array_diff( $sidebar, array($widget_id) );
$_POST = array('sidebar' => $sidebar_id, 'widget-' . $id_base => array(), 'the-widget-id' => $widget_id, 'delete_widget' => '1');
} elseif ( $settings && preg_match( '/__i__|%i%/', key($settings) ) ) {
if ( !$multi_number )
wp_die( $error );
$_POST['widget-' . $id_base] = array( $multi_number => array_shift($settings) );
$widget_id = $id_base . '-' . $multi_number;
$sidebar[] = $widget_id;
}
$_POST['widget-id'] = $sidebar;
foreach ( (array) $wp_registered_widget_updates as $name => $control ) {
if ( $name == $id_base ) {
if ( !is_callable( $control['callback'] ) )
continue;
ob_start();
call_user_func_array( $control['callback'], $control['params'] );
ob_end_clean();
break;
}
}
if ( isset($_POST['delete_widget']) && $_POST['delete_widget'] ) {
$sidebars[$sidebar_id] = $sidebar;
wp_set_sidebars_widgets($sidebars);
echo "deleted:$widget_id";
wp_die();
}
if ( !empty($_POST['add_new']) )
wp_die();
if ( $form = $wp_registered_widget_controls[$widget_id] )
call_user_func_array( $form['callback'], $form['params'] );
wp_die();
}
function wp_ajax_upload_attachment() {
check_ajax_referer( 'media-form' );
if ( ! current_user_can( 'upload_files' ) )
wp_die( -1 );
if ( isset( $_REQUEST['post_id'] ) ) {
$post_id = $_REQUEST['post_id'];
if ( ! current_user_can( 'edit_post', $post_id ) )
wp_die( -1 );
} else {
$post_id = null;
}
$post_data = isset( $_REQUEST['post_data'] ) ? $_REQUEST['post_data'] : array();
$attachment_id = media_handle_upload( 'async-upload', $post_id, $post_data );
if ( is_wp_error( $attachment_id ) ) {
echo json_encode( array(
'type' => 'error',
'data' => array(
'message' => $attachment_id->get_error_message(),
'filename' => $_FILES['async-upload']['name'],
),
) );
wp_die();
}
if ( isset( $post_data['context'] ) && isset( $post_data['theme'] ) ) {
if ( 'custom-background' === $post_data['context'] )
update_post_meta( $attachment_id, '_wp_attachment_is_custom_background', $post_data['theme'] );
if ( 'custom-header' === $post_data['context'] )
update_post_meta( $attachment_id, '_wp_attachment_is_custom_header', $post_data['theme'] );
}
$post = get_post( $attachment_id );
echo json_encode( array(
'type' => 'success',
'data' => array(
'id' => $attachment_id,
'title' => esc_attr( $post->post_title ),
'filename' => esc_html( basename( $post->guid ) ),
'url' => wp_get_attachment_url( $attachment_id ),
'meta' => wp_get_attachment_metadata( $attachment_id ),
),
) );
wp_die();
}
function wp_ajax_image_editor() {
$attachment_id = intval($_POST['postid']);
if ( empty($attachment_id) || !current_user_can('edit_post', $attachment_id) )
wp_die( -1 );
check_ajax_referer( "image_editor-$attachment_id" );
include_once( ABSPATH . 'wp-admin/includes/image-edit.php' );
$msg = false;
switch ( $_POST['do'] ) {
case 'save' :
$msg = wp_save_image($attachment_id);
$msg = json_encode($msg);
wp_die( $msg );
break;
case 'scale' :
$msg = wp_save_image($attachment_id);
break;
case 'restore' :
$msg = wp_restore_image($attachment_id);
break;
}
wp_image_editor($attachment_id, $msg);
wp_die();
}
function wp_ajax_set_post_thumbnail() {
$post_ID = intval( $_POST['post_id'] );
if ( !current_user_can( 'edit_post', $post_ID ) )
wp_die( -1 );
$thumbnail_id = intval( $_POST['thumbnail_id'] );
check_ajax_referer( "set_post_thumbnail-$post_ID" );
if ( $thumbnail_id == '-1' ) {
if ( delete_post_thumbnail( $post_ID ) )
wp_die( _wp_post_thumbnail_html( null, $post_ID ) );
else
wp_die( 0 );
}
if ( set_post_thumbnail( $post_ID, $thumbnail_id ) )
wp_die( _wp_post_thumbnail_html( $thumbnail_id, $post_ID ) );
wp_die( 0 );
}
function wp_ajax_date_format() {
wp_die( date_i18n( sanitize_option( 'date_format', $_POST['date'] ) ) );
}
function wp_ajax_time_format() {
wp_die( date_i18n( sanitize_option( 'time_format', $_POST['date'] ) ) );
}
function wp_ajax_wp_fullscreen_save_post() {
$post_id = isset( $_POST['post_ID'] ) ? (int) $_POST['post_ID'] : 0;
$post = $post_type = null;
if ( $post_id )
$post = get_post( $post_id );
if ( $post )
$post_type = $post->post_type;
elseif ( isset( $_POST['post_type'] ) && post_type_exists( $_POST['post_type'] ) )
$post_type = $_POST['post_type'];
check_ajax_referer('update-' . $post_type . '_' . $post_id, '_wpnonce');
$post_id = edit_post();
if ( is_wp_error($post_id) ) {
if ( $post_id->get_error_message() )
$message = $post_id->get_error_message();
else
$message = __('Save failed');
echo json_encode( array( 'message' => $message, 'last_edited' => '' ) );
wp_die();
} else {
$message = __('Saved.');
}
if ( $post ) {
$last_date = mysql2date( get_option('date_format'), $post->post_modified );
$last_time = mysql2date( get_option('time_format'), $post->post_modified );
} else {
$last_date = date_i18n( get_option('date_format') );
$last_time = date_i18n( get_option('time_format') );
}
if ( $last_id = get_post_meta($post_id, '_edit_last', true) ) {
$last_user = get_userdata($last_id);
$last_edited = sprintf( __('Last edited by %1$s on %2$s at %3$s'), esc_html( $last_user->display_name ), $last_date, $last_time );
} else {
$last_edited = sprintf( __('Last edited on %1$s at %2$s'), $last_date, $last_time );
}
echo json_encode( array( 'message' => $message, 'last_edited' => $last_edited ) );
wp_die();
}
function wp_ajax_wp_remove_post_lock() {
if ( empty( $_POST['post_ID'] ) || empty( $_POST['active_post_lock'] ) )
wp_die( 0 );
$post_id = (int) $_POST['post_ID'];
if ( ! $post = get_post( $post_id ) )
wp_die( 0 );
check_ajax_referer( 'update-' . $post->post_type . '_' . $post_id );
if ( ! current_user_can( 'edit_post', $post_id ) )
wp_die( -1 );
$active_lock = array_map( 'absint', explode( ':', $_POST['active_post_lock'] ) );
if ( $active_lock[1] != get_current_user_id() )
wp_die( 0 );
$new_lock = ( time() - apply_filters( 'wp_check_post_lock_window', AUTOSAVE_INTERVAL * 2 ) + 5 ) . ':' . $active_lock[1];
update_post_meta( $post_id, '_edit_lock', $new_lock, implode( ':', $active_lock ) );
wp_die( 1 );
}
function wp_ajax_dismiss_wp_pointer() {
$pointer = $_POST['pointer'];
if ( $pointer != sanitize_key( $pointer ) )
wp_die( 0 );
// check_ajax_referer( 'dismiss-pointer_' . $pointer );
$dismissed = array_filter( explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ) );
if ( in_array( $pointer, $dismissed ) )
wp_die( 0 );
$dismissed[] = $pointer;
$dismissed = implode( ',', $dismissed );
update_user_meta( get_current_user_id(), 'dismissed_wp_pointers', $dismissed );
wp_die( 1 );
}
| 01happy-blog | trunk/myblog/wp-admin/includes/ajax-actions.php | PHP | oos | 54,227 |
<?php
/**
* Deprecated multisite admin functions from past WordPress versions and WordPress MU.
* You shouldn't use these functions and look for the alternatives instead. The functions
* will be removed in a later version.
*
* @package WordPress
* @subpackage Deprecated
* @since 3.0.0
*/
/**
* @deprecated 3.0.0
*/
function wpmu_menu() {
_deprecated_function(__FUNCTION__, '3.0' );
// deprecated. See #11763
}
/**
* Determines if the available space defined by the admin has been exceeded by the user.
*
* @deprecated 3.0.0
* @see is_upload_space_available()
*/
function wpmu_checkAvailableSpace() {
_deprecated_function(__FUNCTION__, '3.0', 'is_upload_space_available()' );
if ( !is_upload_space_available() )
wp_die( __('Sorry, you must delete files before you can upload any more.') );
}
/**
* @deprecated 3.0.0
*/
function mu_options( $options ) {
_deprecated_function(__FUNCTION__, '3.0' );
return $options;
}
/**
* @deprecated 3.0.0
* @see activate_plugin()
*/
function activate_sitewide_plugin() {
_deprecated_function(__FUNCTION__, '3.0', 'activate_plugin()' );
return false;
}
/**
* @deprecated 3.0.0
* @see deactivate_sitewide_plugin()
*/
function deactivate_sitewide_plugin( $plugin = false ) {
_deprecated_function(__FUNCTION__, '3.0', 'deactivate_plugin()' );
return;
}
/**
* @deprecated 3.0.0
* @see is_network_only_plugin()
*/
function is_wpmu_sitewide_plugin( $file ) {
_deprecated_function(__FUNCTION__, '3.0', 'is_network_only_plugin()' );
return is_network_only_plugin( $file );
}
function get_site_allowed_themes() {
_deprecated_function( __FUNCTION__, '3.4', 'WP_Theme::get_allowed_on_network()' );
return array_map( 'intval', WP_Theme::get_allowed_on_network() );
}
function wpmu_get_blog_allowedthemes( $blog_id = 0 ) {
_deprecated_function( __FUNCTION__, '3.4', 'WP_Theme::get_allowed_on_site()' );
return array_map( 'intval', WP_Theme::get_allowed_on_site( $blog_id ) );
} | 01happy-blog | trunk/myblog/wp-admin/includes/ms-deprecated.php | PHP | oos | 1,955 |
<?php
/**
* WordPress Bookmark Administration API
*
* @package WordPress
* @subpackage Administration
*/
/**
* Add a link to using values provided in $_POST.
*
* @since 2.0.0
*
* @return int|WP_Error Value 0 or WP_Error on failure. The link ID on success.
*/
function add_link() {
return edit_link();
}
/**
* Update or insert a link using values provided in $_POST.
*
* @since 2.0.0
*
* @param int $link_id Optional. ID of the link to edit.
* @return int|WP_Error Value 0 or WP_Error on failure. The link ID on success.
*/
function edit_link( $link_id = 0 ) {
if ( !current_user_can( 'manage_links' ) )
wp_die( __( 'Cheatin’ uh?' ) );
$_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_visible'] = 'Y';
if ( !empty( $link_id ) ) {
$_POST['link_id'] = $link_id;
return wp_update_link( $_POST );
} else {
return wp_insert_link( $_POST );
}
}
/**
* Retrieve the default link for editing.
*
* @since 2.0.0
*
* @return object Default link
*/
function get_default_link_to_edit() {
$link = new stdClass;
if ( isset( $_GET['linkurl'] ) )
$link->link_url = esc_url( $_GET['linkurl'] );
else
$link->link_url = '';
if ( isset( $_GET['name'] ) )
$link->link_name = esc_attr( $_GET['name'] );
else
$link->link_name = '';
$link->link_visible = 'Y';
return $link;
}
/**
* Delete link specified from database
*
* @since 2.0.0
*
* @param int $link_id ID of the link to delete
* @return bool True
*/
function wp_delete_link( $link_id ) {
global $wpdb;
do_action( 'delete_link', $link_id );
wp_delete_object_term_relationships( $link_id, 'link_category' );
$wpdb->delete( $wpdb->links, array( 'link_id' => $link_id ) );
do_action( 'deleted_link', $link_id );
clean_bookmark_cache( $link_id );
return true;
}
/**
* Retrieves the link categories associated with the link specified.
*
* @since 2.1.0
*
* @param int $link_id Link ID to look up
* @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') );
return array_unique( $cats );
}
/**
* Retrieve link data based on ID.
*
* @since 2.0.0
*
* @param int $link_id ID of link to retrieve
* @return object Link for editing
*/
function get_link_to_edit( $link_id ) {
return get_bookmark( $link_id, OBJECT, 'edit' );
}
/**
* This function inserts/updates links into/in the database.
*
* @since 2.0.0
*
* @param array $linkdata Elements that make up the link to insert.
* @param bool $wp_error Optional. If true return WP_Error object on failure.
* @return int|WP_Error Value 0 or WP_Error on failure. The link ID on success.
*/
function wp_insert_link( $linkdata, $wp_error = false ) {
global $wpdb;
$defaults = array( 'link_id' => 0, 'link_name' => '', 'link_url' => '', 'link_rating' => 0 );
$linkdata = wp_parse_args( $linkdata, $defaults );
$linkdata = sanitize_bookmark( $linkdata, 'db' );
extract( stripslashes_deep( $linkdata ), EXTR_SKIP );
$update = false;
if ( !empty( $link_id ) )
$update = true;
if ( trim( $link_name ) == '' ) {
if ( trim( $link_url ) != '' ) {
$link_name = $link_url;
} else {
return 0;
}
}
if ( trim( $link_url ) == '' )
return 0;
if ( empty( $link_rating ) )
$link_rating = 0;
if ( empty( $link_image ) )
$link_image = '';
if ( empty( $link_target ) )
$link_target = '';
if ( empty( $link_visible ) )
$link_visible = 'Y';
if ( empty( $link_owner ) )
$link_owner = get_current_user_id();
if ( empty( $link_notes ) )
$link_notes = '';
if ( empty( $link_description ) )
$link_description = '';
if ( empty( $link_rss ) )
$link_rss = '';
if ( empty( $link_rel ) )
$link_rel = '';
// Make sure we set a valid category
if ( ! isset( $link_category ) || 0 == count( $link_category ) || !is_array( $link_category ) ) {
$link_category = array( get_option( 'default_link_category' ) );
}
if ( $update ) {
if ( false === $wpdb->update( $wpdb->links, compact('link_url', 'link_name', 'link_image', 'link_target', 'link_description', 'link_visible', 'link_rating', 'link_rel', 'link_notes', 'link_rss'), compact('link_id') ) ) {
if ( $wp_error )
return new WP_Error( 'db_update_error', __( 'Could not update link in the database' ), $wpdb->last_error );
else
return 0;
}
} else {
if ( false === $wpdb->insert( $wpdb->links, compact('link_url', 'link_name', 'link_image', 'link_target', 'link_description', 'link_visible', 'link_owner', 'link_rating', 'link_rel', 'link_notes', 'link_rss') ) ) {
if ( $wp_error )
return new WP_Error( 'db_insert_error', __( 'Could not insert link into the database' ), $wpdb->last_error );
else
return 0;
}
$link_id = (int) $wpdb->insert_id;
}
wp_set_link_cats( $link_id, $link_category );
if ( $update )
do_action( 'edit_link', $link_id );
else
do_action( 'add_link', $link_id );
clean_bookmark_cache( $link_id );
return $link_id;
}
/**
* Update link with the specified link categories.
*
* @since 2.1.0
*
* @param int $link_id ID of link to update
* @param array $link_categories Array of categories to
*/
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 ) )
$link_categories = array( get_option( 'default_link_category' ) );
$link_categories = array_map( 'intval', $link_categories );
$link_categories = array_unique( $link_categories );
wp_set_object_terms( $link_id, $link_categories, 'link_category' );
clean_bookmark_cache( $link_id );
}
/**
* Update a link in the database.
*
* @since 2.0.0
*
* @param array $linkdata Link data to update.
* @return int|WP_Error Value 0 or WP_Error on failure. The updated link ID on success.
*/
function wp_update_link( $linkdata ) {
$link_id = (int) $linkdata['link_id'];
$link = get_bookmark( $link_id, ARRAY_A );
// Escape data pulled from DB.
$link = add_magic_quotes( $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'] ) )
$link_cats = $linkdata['link_category'];
else
$link_cats = $link['link_category'];
// Merge old and new fields with new fields overwriting old ones.
$linkdata = array_merge( $link, $linkdata );
$linkdata['link_category'] = $link_cats;
return wp_insert_link( $linkdata );
}
| 01happy-blog | trunk/myblog/wp-admin/includes/bookmark.php | PHP | oos | 6,851 |
<?php
/**
* PemFTP - A Ftp implementation in pure PHP
*
* @package PemFTP
* @since 2.5
*
* @version 1.0
* @copyright Alexey Dotsenko
* @author Alexey Dotsenko
* @link http://www.phpclasses.org/browse/package/1743.html Site
* @license LGPL License http://www.opensource.org/licenses/lgpl-license.html
*/
/**
* FTP implementation using fsockopen to connect.
*
* @package PemFTP
* @subpackage Pure
* @since 2.5
*
* @version 1.0
* @copyright Alexey Dotsenko
* @author Alexey Dotsenko
* @link http://www.phpclasses.org/browse/package/1743.html Site
* @license LGPL License http://www.opensource.org/licenses/lgpl-license.html
*/
class ftp extends ftp_base {
function ftp($verb=FALSE, $le=FALSE) {
$this->__construct($verb, $le);
}
function __construct($verb=FALSE, $le=FALSE) {
parent::__construct(false, $verb, $le);
}
// <!-- --------------------------------------------------------------------------------------- -->
// <!-- Private functions -->
// <!-- --------------------------------------------------------------------------------------- -->
function _settimeout($sock) {
if(!@stream_set_timeout($sock, $this->_timeout)) {
$this->PushError('_settimeout','socket set send timeout');
$this->_quit();
return FALSE;
}
return TRUE;
}
function _connect($host, $port) {
$this->SendMSG("Creating socket");
$sock = @fsockopen($host, $port, $errno, $errstr, $this->_timeout);
if (!$sock) {
$this->PushError('_connect','socket connect failed', $errstr." (".$errno.")");
return FALSE;
}
$this->_connected=true;
return $sock;
}
function _readmsg($fnction="_readmsg"){
if(!$this->_connected) {
$this->PushError($fnction, 'Connect first');
return FALSE;
}
$result=true;
$this->_message="";
$this->_code=0;
$go=true;
do {
$tmp=@fgets($this->_ftp_control_sock, 512);
if($tmp===false) {
$go=$result=false;
$this->PushError($fnction,'Read failed');
} else {
$this->_message.=$tmp;
if(preg_match("/^([0-9]{3})(-(.*[".CRLF."]{1,2})+\\1)? [^".CRLF."]+[".CRLF."]{1,2}$/", $this->_message, $regs)) $go=false;
}
} while($go);
if($this->LocalEcho) echo "GET < ".rtrim($this->_message, CRLF).CRLF;
$this->_code=(int)$regs[1];
return $result;
}
function _exec($cmd, $fnction="_exec") {
if(!$this->_ready) {
$this->PushError($fnction,'Connect first');
return FALSE;
}
if($this->LocalEcho) echo "PUT > ",$cmd,CRLF;
$status=@fputs($this->_ftp_control_sock, $cmd.CRLF);
if($status===false) {
$this->PushError($fnction,'socket write failed');
return FALSE;
}
$this->_lastaction=time();
if(!$this->_readmsg($fnction)) return FALSE;
return TRUE;
}
function _data_prepare($mode=FTP_ASCII) {
if(!$this->_settype($mode)) return FALSE;
if($this->_passive) {
if(!$this->_exec("PASV", "pasv")) {
$this->_data_close();
return FALSE;
}
if(!$this->_checkCode()) {
$this->_data_close();
return FALSE;
}
$ip_port = explode(",", ereg_replace("^.+ \\(?([0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]+,[0-9]+)\\)?.*".CRLF."$", "\\1", $this->_message));
$this->_datahost=$ip_port[0].".".$ip_port[1].".".$ip_port[2].".".$ip_port[3];
$this->_dataport=(((int)$ip_port[4])<<8) + ((int)$ip_port[5]);
$this->SendMSG("Connecting to ".$this->_datahost.":".$this->_dataport);
$this->_ftp_data_sock=@fsockopen($this->_datahost, $this->_dataport, $errno, $errstr, $this->_timeout);
if(!$this->_ftp_data_sock) {
$this->PushError("_data_prepare","fsockopen fails", $errstr." (".$errno.")");
$this->_data_close();
return FALSE;
}
else $this->_ftp_data_sock;
} else {
$this->SendMSG("Only passive connections available!");
return FALSE;
}
return TRUE;
}
function _data_read($mode=FTP_ASCII, $fp=NULL) {
if(is_resource($fp)) $out=0;
else $out="";
if(!$this->_passive) {
$this->SendMSG("Only passive connections available!");
return FALSE;
}
while (!feof($this->_ftp_data_sock)) {
$block=fread($this->_ftp_data_sock, $this->_ftp_buff_size);
if($mode!=FTP_BINARY) $block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_local], $block);
if(is_resource($fp)) $out+=fwrite($fp, $block, strlen($block));
else $out.=$block;
}
return $out;
}
function _data_write($mode=FTP_ASCII, $fp=NULL) {
if(is_resource($fp)) $out=0;
else $out="";
if(!$this->_passive) {
$this->SendMSG("Only passive connections available!");
return FALSE;
}
if(is_resource($fp)) {
while(!feof($fp)) {
$block=fread($fp, $this->_ftp_buff_size);
if(!$this->_data_write_block($mode, $block)) return false;
}
} elseif(!$this->_data_write_block($mode, $fp)) return false;
return TRUE;
}
function _data_write_block($mode, $block) {
if($mode!=FTP_BINARY) $block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_remote], $block);
do {
if(($t=@fwrite($this->_ftp_data_sock, $block))===FALSE) {
$this->PushError("_data_write","Can't write to socket");
return FALSE;
}
$block=substr($block, $t);
} while(!empty($block));
return true;
}
function _data_close() {
@fclose($this->_ftp_data_sock);
$this->SendMSG("Disconnected data from remote host");
return TRUE;
}
function _quit($force=FALSE) {
if($this->_connected or $force) {
@fclose($this->_ftp_control_sock);
$this->_connected=false;
$this->SendMSG("Socket closed");
}
}
}
?>
| 01happy-blog | trunk/myblog/wp-admin/includes/class-ftp-pure.php | PHP | oos | 5,489 |
<?php
/**
* PemFTP - A Ftp implementation in pure PHP
*
* @package PemFTP
* @since 2.5
*
* @version 1.0
* @copyright Alexey Dotsenko
* @author Alexey Dotsenko
* @link http://www.phpclasses.org/browse/package/1743.html Site
* @license LGPL License http://www.opensource.org/licenses/lgpl-license.html
*/
/**
* Socket Based FTP implementation
*
* @package PemFTP
* @subpackage Socket
* @since 2.5
*
* @version 1.0
* @copyright Alexey Dotsenko
* @author Alexey Dotsenko
* @link http://www.phpclasses.org/browse/package/1743.html Site
* @license LGPL License http://www.opensource.org/licenses/lgpl-license.html
*/
class ftp extends ftp_base {
function ftp($verb=FALSE, $le=FALSE) {
$this->__construct($verb, $le);
}
function __construct($verb=FALSE, $le=FALSE) {
parent::__construct(true, $verb, $le);
}
// <!-- --------------------------------------------------------------------------------------- -->
// <!-- Private functions -->
// <!-- --------------------------------------------------------------------------------------- -->
function _settimeout($sock) {
if(!@socket_set_option($sock, SOL_SOCKET, SO_RCVTIMEO, array("sec"=>$this->_timeout, "usec"=>0))) {
$this->PushError('_connect','socket set receive timeout',socket_strerror(socket_last_error($sock)));
@socket_close($sock);
return FALSE;
}
if(!@socket_set_option($sock, SOL_SOCKET , SO_SNDTIMEO, array("sec"=>$this->_timeout, "usec"=>0))) {
$this->PushError('_connect','socket set send timeout',socket_strerror(socket_last_error($sock)));
@socket_close($sock);
return FALSE;
}
return true;
}
function _connect($host, $port) {
$this->SendMSG("Creating socket");
if(!($sock = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP))) {
$this->PushError('_connect','socket create failed',socket_strerror(socket_last_error($sock)));
return FALSE;
}
if(!$this->_settimeout($sock)) return FALSE;
$this->SendMSG("Connecting to \"".$host.":".$port."\"");
if (!($res = @socket_connect($sock, $host, $port))) {
$this->PushError('_connect','socket connect failed',socket_strerror(socket_last_error($sock)));
@socket_close($sock);
return FALSE;
}
$this->_connected=true;
return $sock;
}
function _readmsg($fnction="_readmsg"){
if(!$this->_connected) {
$this->PushError($fnction,'Connect first');
return FALSE;
}
$result=true;
$this->_message="";
$this->_code=0;
$go=true;
do {
$tmp=@socket_read($this->_ftp_control_sock, 4096, PHP_BINARY_READ);
if($tmp===false) {
$go=$result=false;
$this->PushError($fnction,'Read failed', socket_strerror(socket_last_error($this->_ftp_control_sock)));
} else {
$this->_message.=$tmp;
$go = !preg_match("/^([0-9]{3})(-.+\\1)? [^".CRLF."]+".CRLF."$/Us", $this->_message, $regs);
}
} while($go);
if($this->LocalEcho) echo "GET < ".rtrim($this->_message, CRLF).CRLF;
$this->_code=(int)$regs[1];
return $result;
}
function _exec($cmd, $fnction="_exec") {
if(!$this->_ready) {
$this->PushError($fnction,'Connect first');
return FALSE;
}
if($this->LocalEcho) echo "PUT > ",$cmd,CRLF;
$status=@socket_write($this->_ftp_control_sock, $cmd.CRLF);
if($status===false) {
$this->PushError($fnction,'socket write failed', socket_strerror(socket_last_error($this->stream)));
return FALSE;
}
$this->_lastaction=time();
if(!$this->_readmsg($fnction)) return FALSE;
return TRUE;
}
function _data_prepare($mode=FTP_ASCII) {
if(!$this->_settype($mode)) return FALSE;
$this->SendMSG("Creating data socket");
$this->_ftp_data_sock = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if ($this->_ftp_data_sock < 0) {
$this->PushError('_data_prepare','socket create failed',socket_strerror(socket_last_error($this->_ftp_data_sock)));
return FALSE;
}
if(!$this->_settimeout($this->_ftp_data_sock)) {
$this->_data_close();
return FALSE;
}
if($this->_passive) {
if(!$this->_exec("PASV", "pasv")) {
$this->_data_close();
return FALSE;
}
if(!$this->_checkCode()) {
$this->_data_close();
return FALSE;
}
$ip_port = explode(",", ereg_replace("^.+ \\(?([0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]{1,3},[0-9]+,[0-9]+)\\)?.*".CRLF."$", "\\1", $this->_message));
$this->_datahost=$ip_port[0].".".$ip_port[1].".".$ip_port[2].".".$ip_port[3];
$this->_dataport=(((int)$ip_port[4])<<8) + ((int)$ip_port[5]);
$this->SendMSG("Connecting to ".$this->_datahost.":".$this->_dataport);
if(!@socket_connect($this->_ftp_data_sock, $this->_datahost, $this->_dataport)) {
$this->PushError("_data_prepare","socket_connect", socket_strerror(socket_last_error($this->_ftp_data_sock)));
$this->_data_close();
return FALSE;
}
else $this->_ftp_temp_sock=$this->_ftp_data_sock;
} else {
if(!@socket_getsockname($this->_ftp_control_sock, $addr, $port)) {
$this->PushError("_data_prepare","can't get control socket information", socket_strerror(socket_last_error($this->_ftp_control_sock)));
$this->_data_close();
return FALSE;
}
if(!@socket_bind($this->_ftp_data_sock,$addr)){
$this->PushError("_data_prepare","can't bind data socket", socket_strerror(socket_last_error($this->_ftp_data_sock)));
$this->_data_close();
return FALSE;
}
if(!@socket_listen($this->_ftp_data_sock)) {
$this->PushError("_data_prepare","can't listen data socket", socket_strerror(socket_last_error($this->_ftp_data_sock)));
$this->_data_close();
return FALSE;
}
if(!@socket_getsockname($this->_ftp_data_sock, $this->_datahost, $this->_dataport)) {
$this->PushError("_data_prepare","can't get data socket information", socket_strerror(socket_last_error($this->_ftp_data_sock)));
$this->_data_close();
return FALSE;
}
if(!$this->_exec('PORT '.str_replace('.',',',$this->_datahost.'.'.($this->_dataport>>8).'.'.($this->_dataport&0x00FF)), "_port")) {
$this->_data_close();
return FALSE;
}
if(!$this->_checkCode()) {
$this->_data_close();
return FALSE;
}
}
return TRUE;
}
function _data_read($mode=FTP_ASCII, $fp=NULL) {
$NewLine=$this->_eol_code[$this->OS_local];
if(is_resource($fp)) $out=0;
else $out="";
if(!$this->_passive) {
$this->SendMSG("Connecting to ".$this->_datahost.":".$this->_dataport);
$this->_ftp_temp_sock=socket_accept($this->_ftp_data_sock);
if($this->_ftp_temp_sock===FALSE) {
$this->PushError("_data_read","socket_accept", socket_strerror(socket_last_error($this->_ftp_temp_sock)));
$this->_data_close();
return FALSE;
}
}
while(($block=@socket_read($this->_ftp_temp_sock, $this->_ftp_buff_size, PHP_BINARY_READ))!==false) {
if($block==="") break;
if($mode!=FTP_BINARY) $block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_local], $block);
if(is_resource($fp)) $out+=fwrite($fp, $block, strlen($block));
else $out.=$block;
}
return $out;
}
function _data_write($mode=FTP_ASCII, $fp=NULL) {
$NewLine=$this->_eol_code[$this->OS_local];
if(is_resource($fp)) $out=0;
else $out="";
if(!$this->_passive) {
$this->SendMSG("Connecting to ".$this->_datahost.":".$this->_dataport);
$this->_ftp_temp_sock=socket_accept($this->_ftp_data_sock);
if($this->_ftp_temp_sock===FALSE) {
$this->PushError("_data_write","socket_accept", socket_strerror(socket_last_error($this->_ftp_temp_sock)));
$this->_data_close();
return false;
}
}
if(is_resource($fp)) {
while(!feof($fp)) {
$block=fread($fp, $this->_ftp_buff_size);
if(!$this->_data_write_block($mode, $block)) return false;
}
} elseif(!$this->_data_write_block($mode, $fp)) return false;
return true;
}
function _data_write_block($mode, $block) {
if($mode!=FTP_BINARY) $block=preg_replace("/\r\n|\r|\n/", $this->_eol_code[$this->OS_remote], $block);
do {
if(($t=@socket_write($this->_ftp_temp_sock, $block))===FALSE) {
$this->PushError("_data_write","socket_write", socket_strerror(socket_last_error($this->_ftp_temp_sock)));
$this->_data_close();
return FALSE;
}
$block=substr($block, $t);
} while(!empty($block));
return true;
}
function _data_close() {
@socket_close($this->_ftp_temp_sock);
@socket_close($this->_ftp_data_sock);
$this->SendMSG("Disconnected data from remote host");
return TRUE;
}
function _quit() {
if($this->_connected) {
@socket_close($this->_ftp_control_sock);
$this->_connected=false;
$this->SendMSG("Socket closed");
}
}
}
?>
| 01happy-blog | trunk/myblog/wp-admin/includes/class-ftp-sockets.php | PHP | oos | 8,544 |
<?php
/**
* WordPress Export Administration API
*
* @package WordPress
* @subpackage Administration
*/
/**
* Version number for the export format.
*
* Bump this when something changes that might affect compatibility.
*
* @since 2.5.0
*/
define( 'WXR_VERSION', '1.2' );
/**
* Generates the WXR export file for download
*
* @since 2.1.0
*
* @param array $args Filters defining what should be included in the export
*/
function export_wp( $args = array() ) {
global $wpdb, $post;
$defaults = array( 'content' => 'all', 'author' => false, 'category' => false,
'start_date' => false, 'end_date' => false, 'status' => false,
);
$args = wp_parse_args( $args, $defaults );
do_action( 'export_wp' );
$sitename = sanitize_key( get_bloginfo( 'name' ) );
if ( ! empty($sitename) ) $sitename .= '.';
$filename = $sitename . 'wordpress.' . date( 'Y-m-d' ) . '.xml';
header( 'Content-Description: File Transfer' );
header( 'Content-Disposition: attachment; filename=' . $filename );
header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true );
if ( 'all' != $args['content'] && post_type_exists( $args['content'] ) ) {
$ptype = get_post_type_object( $args['content'] );
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 );
}
if ( $args['status'] && ( 'post' == $args['content'] || 'page' == $args['content'] ) )
$where .= $wpdb->prepare( " AND {$wpdb->posts}.post_status = %s", $args['status'] );
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)";
$where .= $wpdb->prepare( " AND {$wpdb->term_relationships}.term_taxonomy_id = %d", $term['term_taxonomy_id'] );
}
}
if ( 'post' == $args['content'] || 'page' == $args['content'] ) {
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['end_date'] )
$where .= $wpdb->prepare( " AND {$wpdb->posts}.post_date < %s", date( 'Y-m-d', strtotime('+1 month', strtotime($args['end_date'])) ) );
}
// grab a snapshot of post IDs, just in case it changes during the export
$post_ids = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} $join WHERE $where" );
// get the requested terms ready, empty unless posts filtered by category or all content
$cats = $tags = $terms = array();
if ( isset( $term ) && $term ) {
$cat = get_term( $term['term_id'], 'category' );
$cats = array( $cat->term_id => $cat );
unset( $term, $cat );
} else if ( 'all' == $args['content'] ) {
$categories = (array) get_categories( 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' ) );
// 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
$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
$custom_terms[] = $t;
}
unset( $categories, $custom_taxonomies, $custom_terms );
}
/**
* Wrap given string in XML CDATA tag.
*
* @since 2.1.0
*
* @param string $str String to wrap in XML CDATA tag.
* @return string
*/
function wxr_cdata( $str ) {
if ( seems_utf8( $str ) == false )
$str = utf8_encode( $str );
// $str = ent2ncr(esc_html($str));
$str = '<![CDATA[' . str_replace( ']]>', ']]]]><![CDATA[>', $str ) . ']]>';
return $str;
}
/**
* Return the URL of the site
*
* @since 2.5.0
*
* @return string Site URL.
*/
function wxr_site_url() {
// ms: the base url
if ( is_multisite() )
return network_home_url();
// wp: the blog url
else
return get_bloginfo_rss( 'url' );
}
/**
* Output a cat_name XML tag from a given category object
*
* @since 2.1.0
*
* @param object $category Category Object
*/
function wxr_cat_name( $category ) {
if ( empty( $category->name ) )
return;
echo '<wp:cat_name>' . wxr_cdata( $category->name ) . '</wp:cat_name>';
}
/**
* Output a category_description XML tag from a given category object
*
* @since 2.1.0
*
* @param object $category Category Object
*/
function wxr_category_description( $category ) {
if ( empty( $category->description ) )
return;
echo '<wp:category_description>' . wxr_cdata( $category->description ) . '</wp:category_description>';
}
/**
* Output a tag_name XML tag from a given tag object
*
* @since 2.3.0
*
* @param object $tag Tag Object
*/
function wxr_tag_name( $tag ) {
if ( empty( $tag->name ) )
return;
echo '<wp:tag_name>' . wxr_cdata( $tag->name ) . '</wp:tag_name>';
}
/**
* Output a tag_description XML tag from a given tag object
*
* @since 2.3.0
*
* @param object $tag Tag Object
*/
function wxr_tag_description( $tag ) {
if ( empty( $tag->description ) )
return;
echo '<wp:tag_description>' . wxr_cdata( $tag->description ) . '</wp:tag_description>';
}
/**
* Output a term_name XML tag from a given term object
*
* @since 2.9.0
*
* @param object $term Term Object
*/
function wxr_term_name( $term ) {
if ( empty( $term->name ) )
return;
echo '<wp:term_name>' . wxr_cdata( $term->name ) . '</wp:term_name>';
}
/**
* Output a term_description XML tag from a given term object
*
* @since 2.9.0
*
* @param object $term Term Object
*/
function wxr_term_description( $term ) {
if ( empty( $term->description ) )
return;
echo '<wp:term_description>' . wxr_cdata( $term->description ) . '</wp:term_description>';
}
/**
* Output list of authors with posts
*
* @since 3.1.0
*/
function wxr_authors_list() {
global $wpdb;
$authors = array();
$results = $wpdb->get_results( "SELECT DISTINCT post_author FROM $wpdb->posts" );
foreach ( (array) $results as $result )
$authors[] = get_userdata( $result->post_author );
$authors = array_filter( $authors );
foreach ( $authors as $author ) {
echo "\t<wp:author>";
echo '<wp:author_id>' . $author->ID . '</wp:author_id>';
echo '<wp:author_login>' . $author->user_login . '</wp:author_login>';
echo '<wp:author_email>' . $author->user_email . '</wp:author_email>';
echo '<wp:author_display_name>' . wxr_cdata( $author->display_name ) . '</wp:author_display_name>';
echo '<wp:author_first_name>' . wxr_cdata( $author->user_firstname ) . '</wp:author_first_name>';
echo '<wp:author_last_name>' . wxr_cdata( $author->user_lastname ) . '</wp:author_last_name>';
echo "</wp:author>\n";
}
}
/**
* Ouput all navigation menu terms
*
* @since 3.1.0
*/
function wxr_nav_menu_terms() {
$nav_menus = wp_get_nav_menus();
if ( empty( $nav_menus ) || ! is_array( $nav_menus ) )
return;
foreach ( $nav_menus as $menu ) {
echo "\t<wp:term><wp:term_id>{$menu->term_id}</wp:term_id><wp:term_taxonomy>nav_menu</wp:term_taxonomy><wp:term_slug>{$menu->slug}</wp:term_slug>";
wxr_term_name( $menu );
echo "</wp:term>\n";
}
}
/**
* Output list of taxonomy terms, in XML tag format, associated with a post
*
* @since 2.3.0
*/
function wxr_post_taxonomy() {
global $post;
$taxonomies = get_object_taxonomies( $post->post_type );
if ( empty( $taxonomies ) )
return;
$terms = wp_get_object_terms( $post->ID, $taxonomies );
foreach ( (array) $terms as $term ) {
echo "\t\t<category domain=\"{$term->taxonomy}\" nicename=\"{$term->slug}\">" . wxr_cdata( $term->name ) . "</category>\n";
}
}
function wxr_filter_postmeta( $return_me, $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";
?>
<!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your site. -->
<!-- It contains information about your site's posts, pages, comments, categories, and other content. -->
<!-- You may use this file to transfer that content from one site to another. -->
<!-- This file is not intended to serve as a complete backup of your site. -->
<!-- To import this information into a WordPress site follow these steps: -->
<!-- 1. Log in to that site as an administrator. -->
<!-- 2. Go to Tools: Import in the WordPress admin panel. -->
<!-- 3. Install the "WordPress" importer from the list. -->
<!-- 4. Activate & Run Importer. -->
<!-- 5. Upload this file using the form provided on that page. -->
<!-- 6. You will first be asked to map the authors in this export file to users -->
<!-- on the site. For each author, you may choose to map to an -->
<!-- existing user on the site or to create a new user. -->
<!-- 7. WordPress will then import each of the posts, pages, comments, categories, etc. -->
<!-- contained in this file into your site. -->
<?php the_generator( 'export' ); ?>
<rss version="2.0"
xmlns:excerpt="http://wordpress.org/export/<?php echo WXR_VERSION; ?>/excerpt/"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:wp="http://wordpress.org/export/<?php echo WXR_VERSION; ?>/"
>
<channel>
<title><?php bloginfo_rss( 'name' ); ?></title>
<link><?php bloginfo_rss( 'url' ); ?></link>
<description><?php bloginfo_rss( 'description' ); ?></description>
<pubDate><?php echo date( 'D, d M Y H:i:s +0000' ); ?></pubDate>
<language><?php bloginfo_rss( 'language' ); ?></language>
<wp:wxr_version><?php echo WXR_VERSION; ?></wp:wxr_version>
<wp:base_site_url><?php echo wxr_site_url(); ?></wp:base_site_url>
<wp:base_blog_url><?php bloginfo_rss( 'url' ); ?></wp:base_blog_url>
<?php wxr_authors_list(); ?>
<?php foreach ( $cats as $c ) : ?>
<wp:category><wp:term_id><?php echo $c->term_id ?></wp:term_id><wp:category_nicename><?php echo $c->slug; ?></wp:category_nicename><wp:category_parent><?php echo $c->parent ? $cats[$c->parent]->slug : ''; ?></wp:category_parent><?php wxr_cat_name( $c ); ?><?php wxr_category_description( $c ); ?></wp:category>
<?php endforeach; ?>
<?php foreach ( $tags as $t ) : ?>
<wp:tag><wp:term_id><?php echo $t->term_id ?></wp:term_id><wp:tag_slug><?php echo $t->slug; ?></wp:tag_slug><?php wxr_tag_name( $t ); ?><?php wxr_tag_description( $t ); ?></wp:tag>
<?php endforeach; ?>
<?php foreach ( $terms as $t ) : ?>
<wp:term><wp:term_id><?php echo $t->term_id ?></wp:term_id><wp:term_taxonomy><?php echo $t->taxonomy; ?></wp:term_taxonomy><wp:term_slug><?php echo $t->slug; ?></wp:term_slug><wp:term_parent><?php echo $t->parent ? $terms[$t->parent]->slug : ''; ?></wp:term_parent><?php wxr_term_name( $t ); ?><?php wxr_term_description( $t ); ?></wp:term>
<?php endforeach; ?>
<?php if ( 'all' == $args['content'] ) wxr_nav_menu_terms(); ?>
<?php do_action( 'rss2_head' ); ?>
<?php if ( $post_ids ) {
global $wp_query;
$wp_query->in_the_loop = true; // Fake being in the loop.
// 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" );
// Begin Loop
foreach ( $posts as $post ) {
setup_postdata( $post );
$is_sticky = is_sticky( $post->ID ) ? 1 : 0;
?>
<item>
<title><?php echo apply_filters( 'the_title_rss', $post->post_title ); ?></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 get_the_author_meta( 'login' ); ?></dc:creator>
<guid isPermaLink="false"><?php esc_url( the_guid() ); ?></guid>
<description></description>
<content:encoded><?php echo wxr_cdata( apply_filters( 'the_content_export', $post->post_content ) ); ?></content:encoded>
<excerpt:encoded><?php echo wxr_cdata( apply_filters( 'the_excerpt_export', $post->post_excerpt ) ); ?></excerpt:encoded>
<wp:post_id><?php echo $post->ID; ?></wp:post_id>
<wp:post_date><?php echo $post->post_date; ?></wp:post_date>
<wp:post_date_gmt><?php echo $post->post_date_gmt; ?></wp:post_date_gmt>
<wp:comment_status><?php echo $post->comment_status; ?></wp:comment_status>
<wp:ping_status><?php echo $post->ping_status; ?></wp:ping_status>
<wp:post_name><?php echo $post->post_name; ?></wp:post_name>
<wp:status><?php echo $post->post_status; ?></wp:status>
<wp:post_parent><?php echo $post->post_parent; ?></wp:post_parent>
<wp:menu_order><?php echo $post->menu_order; ?></wp:menu_order>
<wp:post_type><?php echo $post->post_type; ?></wp:post_type>
<wp:post_password><?php echo $post->post_password; ?></wp:post_password>
<wp:is_sticky><?php echo $is_sticky; ?></wp:is_sticky>
<?php if ( $post->post_type == 'attachment' ) : ?>
<wp:attachment_url><?php echo 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 ) :
if ( apply_filters( 'wxr_export_skip_postmeta', false, $meta->meta_key, $meta ) )
continue;
?>
<wp:postmeta>
<wp:meta_key><?php echo $meta->meta_key; ?></wp:meta_key>
<wp:meta_value><?php echo wxr_cdata( $meta->meta_value ); ?></wp:meta_value>
</wp:postmeta>
<?php endforeach; ?>
<?php $comments = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved <> 'spam'", $post->ID ) );
foreach ( $comments as $c ) : ?>
<wp:comment>
<wp:comment_id><?php echo $c->comment_ID; ?></wp:comment_id>
<wp:comment_author><?php echo wxr_cdata( $c->comment_author ); ?></wp:comment_author>
<wp:comment_author_email><?php echo $c->comment_author_email; ?></wp:comment_author_email>
<wp:comment_author_url><?php echo esc_url_raw( $c->comment_author_url ); ?></wp:comment_author_url>
<wp:comment_author_IP><?php echo $c->comment_author_IP; ?></wp:comment_author_IP>
<wp:comment_date><?php echo $c->comment_date; ?></wp:comment_date>
<wp:comment_date_gmt><?php echo $c->comment_date_gmt; ?></wp:comment_date_gmt>
<wp:comment_content><?php echo wxr_cdata( $c->comment_content ) ?></wp:comment_content>
<wp:comment_approved><?php echo $c->comment_approved; ?></wp:comment_approved>
<wp:comment_type><?php echo $c->comment_type; ?></wp:comment_type>
<wp:comment_parent><?php echo $c->comment_parent; ?></wp:comment_parent>
<wp:comment_user_id><?php echo $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 ) : ?>
<wp:commentmeta>
<wp:meta_key><?php echo $meta->meta_key; ?></wp:meta_key>
<wp:meta_value><?php echo wxr_cdata( $meta->meta_value ); ?></wp:meta_value>
</wp:commentmeta>
<?php endforeach; ?>
</wp:comment>
<?php endforeach; ?>
</item>
<?php
}
}
} ?>
</channel>
</rss>
<?php
}
| 01happy-blog | trunk/myblog/wp-admin/includes/export.php | PHP | oos | 16,050 |
<?php
/**
* Base class for displaying a list of items in an ajaxified HTML table.
*
* @package WordPress
* @subpackage List_Table
* @since 3.1.0
*/
/**
* Base class for displaying a list of items in an ajaxified HTML table.
*
* @package WordPress
* @subpackage List_Table
* @since 3.1.0
* @access private
*/
class WP_List_Table {
/**
* The current list of items
*
* @since 3.1.0
* @var array
* @access protected
*/
var $items;
/**
* Various information about the current table
*
* @since 3.1.0
* @var array
* @access private
*/
var $_args;
/**
* Various information needed for displaying the pagination
*
* @since 3.1.0
* @var array
* @access private
*/
var $_pagination_args = array();
/**
* The current screen
*
* @since 3.1.0
* @var object
* @access protected
*/
var $screen;
/**
* Cached bulk actions
*
* @since 3.1.0
* @var array
* @access private
*/
var $_actions;
/**
* Cached pagination output
*
* @since 3.1.0
* @var string
* @access private
*/
var $_pagination;
/**
* Constructor. The child class should call this constructor from it's own constructor
*
* @param array $args An associative array with information about the current table
* @access protected
*/
function __construct( $args = array() ) {
$args = wp_parse_args( $args, array(
'plural' => '',
'singular' => '',
'ajax' => false
) );
$screen = get_current_screen();
add_filter( "manage_{$screen->id}_columns", array( &$this, 'get_columns' ), 0 );
if ( !$args['plural'] )
$args['plural'] = $screen->base;
$args['plural'] = sanitize_key( $args['plural'] );
$args['singular'] = sanitize_key( $args['singular'] );
$this->_args = $args;
if ( $args['ajax'] ) {
// wp_enqueue_script( 'list-table' );
add_action( 'admin_footer', array( &$this, '_js_vars' ) );
}
}
/**
* Checks the current user's permissions
* @uses wp_die()
*
* @since 3.1.0
* @access public
* @abstract
*/
function ajax_user_can() {
die( 'function WP_List_Table::ajax_user_can() must be over-ridden in a sub-class.' );
}
/**
* Prepares the list of items for displaying.
* @uses WP_List_Table::set_pagination_args()
*
* @since 3.1.0
* @access public
* @abstract
*/
function prepare_items() {
die( 'function WP_List_Table::prepare_items() must be over-ridden in a sub-class.' );
}
/**
* An internal method that sets all the necessary pagination arguments
*
* @param array $args An associative array with information about the pagination
* @access protected
*/
function set_pagination_args( $args ) {
$args = wp_parse_args( $args, array(
'total_items' => 0,
'total_pages' => 0,
'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() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages'] ) {
wp_redirect( add_query_arg( 'paged', $args['total_pages'] ) );
exit;
}
$this->_pagination_args = $args;
}
/**
* Access the pagination args
*
* @since 3.1.0
* @access public
*
* @param string $key
* @return array
*/
function get_pagination_arg( $key ) {
if ( 'page' == $key )
return $this->get_pagenum();
if ( isset( $this->_pagination_args[$key] ) )
return $this->_pagination_args[$key];
}
/**
* Whether the table has items to display or not
*
* @since 3.1.0
* @access public
*
* @return bool
*/
function has_items() {
return !empty( $this->items );
}
/**
* Message to be displayed when there are no items
*
* @since 3.1.0
* @access public
*/
function no_items() {
_e( 'No items found.' );
}
/**
* Display the search box.
*
* @since 3.1.0
* @access public
*
* @param string $text The search button text
* @param string $input_id The search input id
*/
function search_box( $text, $input_id ) {
if ( empty( $_REQUEST['s'] ) && !$this->has_items() )
return;
$input_id = $input_id . '-search-input';
if ( ! empty( $_REQUEST['orderby'] ) )
echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />';
if ( ! empty( $_REQUEST['order'] ) )
echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
?>
<p class="search-box">
<label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label>
<input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" />
<?php submit_button( $text, 'button', false, false, array('id' => 'search-submit') ); ?>
</p>
<?php
}
/**
* Get an associative array ( id => link ) with the list
* of views available on this table.
*
* @since 3.1.0
* @access protected
*
* @return array
*/
function get_views() {
return array();
}
/**
* Display the list of views available on this table.
*
* @since 3.1.0
* @access public
*/
function views() {
$screen = get_current_screen();
$views = $this->get_views();
$views = apply_filters( 'views_' . $screen->id, $views );
if ( empty( $views ) )
return;
echo "<ul class='subsubsub'>\n";
foreach ( $views as $class => $view ) {
$views[ $class ] = "\t<li class='$class'>$view";
}
echo implode( " |</li>\n", $views ) . "</li>\n";
echo "</ul>";
}
/**
* Get an associative array ( option_name => option_title ) with the list
* of bulk actions available on this table.
*
* @since 3.1.0
* @access protected
*
* @return array
*/
function get_bulk_actions() {
return array();
}
/**
* Display the bulk actions dropdown.
*
* @since 3.1.0
* @access public
*/
function bulk_actions() {
$screen = get_current_screen();
if ( is_null( $this->_actions ) ) {
$no_new_actions = $this->_actions = $this->get_bulk_actions();
// This filter can currently only be used to remove actions.
$this->_actions = apply_filters( 'bulk_actions-' . $screen->id, $this->_actions );
$this->_actions = array_intersect_assoc( $this->_actions, $no_new_actions );
$two = '';
} else {
$two = '2';
}
if ( empty( $this->_actions ) )
return;
echo "<select name='action$two'>\n";
echo "<option value='-1' selected='selected'>" . __( 'Bulk Actions' ) . "</option>\n";
foreach ( $this->_actions as $name => $title ) {
$class = 'edit' == $name ? ' class="hide-if-no-js"' : '';
echo "\t<option value='$name'$class>$title</option>\n";
}
echo "</select>\n";
submit_button( __( 'Apply' ), 'button-secondary action', false, false, array( 'id' => "doaction$two" ) );
echo "\n";
}
/**
* Get the current action selected from the bulk actions dropdown.
*
* @since 3.1.0
* @access public
*
* @return string|bool The action name or False if no action was selected
*/
function current_action() {
if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] )
return $_REQUEST['action'];
if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] )
return $_REQUEST['action2'];
return false;
}
/**
* Generate row actions div
*
* @since 3.1.0
* @access protected
*
* @param array $actions The list of actions
* @param bool $always_visible Whether the actions should be always visible
* @return string
*/
function row_actions( $actions, $always_visible = false ) {
$action_count = count( $actions );
$i = 0;
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 .= '</div>';
return $out;
}
/**
* Display a monthly dropdown for filtering items
*
* @since 3.1.0
* @access protected
*/
function months_dropdown( $post_type ) {
global $wpdb, $wp_locale;
$months = $wpdb->get_results( $wpdb->prepare( "
SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
FROM $wpdb->posts
WHERE post_type = %s
ORDER BY post_date DESC
", $post_type ) );
$month_count = count( $months );
if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) )
return;
$m = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0;
?>
<select name='m'>
<option<?php selected( $m, 0 ); ?> value='0'><?php _e( 'Show all dates' ); ?></option>
<?php
foreach ( $months as $arc_row ) {
if ( 0 == $arc_row->year )
continue;
$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 )
);
}
?>
</select>
<?php
}
/**
* Display a view switcher
*
* @since 3.1.0
* @access protected
*/
function view_switcher( $current_mode ) {
$modes = array(
'list' => __( 'List View' ),
'excerpt' => __( 'Excerpt View' )
);
?>
<input type="hidden" name="mode" value="<?php echo esc_attr( $current_mode ); ?>" />
<div class="view-switch">
<?php
foreach ( $modes as $mode => $title ) {
$class = ( $current_mode == $mode ) ? 'class="current"' : '';
echo "<a href='" . esc_url( add_query_arg( 'mode', $mode, $_SERVER['REQUEST_URI'] ) ) . "' $class><img id='view-switch-$mode' src='" . esc_url( includes_url( 'images/blank.gif' ) ) . "' width='20' height='20' title='$title' alt='$title' /></a>\n";
}
?>
</div>
<?php
}
/**
* Display a comment count bubble
*
* @since 3.1.0
* @access protected
*
* @param int $post_id
* @param int $pending_comments
*/
function comments_bubble( $post_id, $pending_comments ) {
$pending_phrase = sprintf( __( '%s pending' ), number_format( $pending_comments ) );
if ( $pending_comments )
echo '<strong>';
echo "<a href='" . esc_url( add_query_arg( 'p', $post_id, admin_url( 'edit-comments.php' ) ) ) . "' title='" . esc_attr( $pending_phrase ) . "' class='post-com-count'><span class='comment-count'>" . number_format_i18n( get_comments_number() ) . "</span></a>";
if ( $pending_comments )
echo '</strong>';
}
/**
* Get the current page number
*
* @since 3.1.0
* @access protected
*
* @return int
*/
function get_pagenum() {
$pagenum = isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 0;
if( isset( $this->_pagination_args['total_pages'] ) && $pagenum > $this->_pagination_args['total_pages'] )
$pagenum = $this->_pagination_args['total_pages'];
return max( 1, $pagenum );
}
/**
* Get number of items to display on a single page
*
* @since 3.1.0
* @access protected
*
* @return int
*/
function get_items_per_page( $option, $default = 20 ) {
$per_page = (int) get_user_option( $option );
if ( empty( $per_page ) || $per_page < 1 )
$per_page = $default;
return (int) apply_filters( $option, $per_page );
}
/**
* Display the pagination.
*
* @since 3.1.0
* @access protected
*/
function pagination( $which ) {
if ( empty( $this->_pagination_args ) )
return;
extract( $this->_pagination_args, EXTR_SKIP );
$output = '<span class="displaying-num">' . sprintf( _n( '1 item', '%s items', $total_items ), number_format_i18n( $total_items ) ) . '</span>';
$current = $this->get_pagenum();
$current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$current_url = remove_query_arg( array( 'hotkeys_highlight_last', 'hotkeys_highlight_first' ), $current_url );
$page_links = array();
$disable_first = $disable_last = '';
if ( $current == 1 )
$disable_first = ' disabled';
if ( $current == $total_pages )
$disable_last = ' disabled';
$page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
'first-page' . $disable_first,
esc_attr__( 'Go to the first page' ),
esc_url( remove_query_arg( 'paged', $current_url ) ),
'«'
);
$page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
'prev-page' . $disable_first,
esc_attr__( 'Go to the previous page' ),
esc_url( add_query_arg( 'paged', max( 1, $current-1 ), $current_url ) ),
'‹'
);
if ( 'bottom' == $which )
$html_current_page = $current;
else
$html_current_page = sprintf( "<input class='current-page' title='%s' type='text' name='paged' value='%s' size='%d' />",
esc_attr__( 'Current page' ),
$current,
strlen( $total_pages )
);
$html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) );
$page_links[] = '<span class="paging-input">' . sprintf( _x( '%1$s of %2$s', 'paging' ), $html_current_page, $html_total_pages ) . '</span>';
$page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
'next-page' . $disable_last,
esc_attr__( 'Go to the next page' ),
esc_url( add_query_arg( 'paged', min( $total_pages, $current+1 ), $current_url ) ),
'›'
);
$page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
'last-page' . $disable_last,
esc_attr__( 'Go to the last page' ),
esc_url( add_query_arg( 'paged', $total_pages, $current_url ) ),
'»'
);
$pagination_links_class = 'pagination-links';
if ( ! empty( $infinite_scroll ) )
$pagination_links_class = ' hide-if-js';
$output .= "\n<span class='$pagination_links_class'>" . join( "\n", $page_links ) . '</span>';
if ( $total_pages )
$page_class = $total_pages < 2 ? ' one-page' : '';
else
$page_class = ' no-pages';
$this->_pagination = "<div class='tablenav-pages{$page_class}'>$output</div>";
echo $this->_pagination;
}
/**
* Get a list of columns. The format is:
* 'internal-name' => 'Title'
*
* @since 3.1.0
* @access protected
* @abstract
*
* @return array
*/
function get_columns() {
die( 'function WP_List_Table::get_columns() must be over-ridden in a sub-class.' );
}
/**
* Get a list of sortable columns. The format is:
* 'internal-name' => 'orderby'
* or
* 'internal-name' => array( 'orderby', true )
*
* The second format will make the initial sorting order be descending
*
* @since 3.1.0
* @access protected
*
* @return array
*/
function get_sortable_columns() {
return array();
}
/**
* Get a list of all, hidden and sortable columns, with filter applied
*
* @since 3.1.0
* @access protected
*
* @return array
*/
function get_column_info() {
if ( isset( $this->_column_headers ) )
return $this->_column_headers;
$screen = get_current_screen();
$columns = get_column_headers( $screen );
$hidden = get_hidden_columns( $screen );
$_sortable = apply_filters( "manage_{$screen->id}_sortable_columns", $this->get_sortable_columns() );
$sortable = array();
foreach ( $_sortable as $id => $data ) {
if ( empty( $data ) )
continue;
$data = (array) $data;
if ( !isset( $data[1] ) )
$data[1] = false;
$sortable[$id] = $data;
}
$this->_column_headers = array( $columns, $hidden, $sortable );
return $this->_column_headers;
}
/**
* Return number of visible columns
*
* @since 3.1.0
* @access public
*
* @return int
*/
function get_column_count() {
list ( $columns, $hidden ) = $this->get_column_info();
$hidden = array_intersect( array_keys( $columns ), array_filter( $hidden ) );
return count( $columns ) - count( $hidden );
}
/**
* Print column headers, accounting for hidden and sortable columns.
*
* @since 3.1.0
* @access protected
*
* @param bool $with_id Whether to set the id attribute or not
*/
function print_column_headers( $with_id = true ) {
$screen = get_current_screen();
list( $columns, $hidden, $sortable ) = $this->get_column_info();
$current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$current_url = remove_query_arg( 'paged', $current_url );
if ( isset( $_GET['orderby'] ) )
$current_orderby = $_GET['orderby'];
else
$current_orderby = '';
if ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] )
$current_order = 'desc';
else
$current_order = 'asc';
foreach ( $columns as $column_key => $column_display_name ) {
$class = array( 'manage-column', "column-$column_key" );
$style = '';
if ( in_array( $column_key, $hidden ) )
$style = 'display:none;';
$style = ' style="' . $style . '"';
if ( 'cb' == $column_key )
$class[] = 'check-column';
elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ) ) )
$class[] = 'num';
if ( isset( $sortable[$column_key] ) ) {
list( $orderby, $desc_first ) = $sortable[$column_key];
if ( $current_orderby == $orderby ) {
$order = 'asc' == $current_order ? 'desc' : 'asc';
$class[] = 'sorted';
$class[] = $current_order;
} else {
$order = $desc_first ? 'desc' : 'asc';
$class[] = 'sortable';
$class[] = $desc_first ? 'asc' : 'desc';
}
$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>';
}
$id = $with_id ? "id='$column_key'" : '';
if ( !empty( $class ) )
$class = "class='" . join( ' ', $class ) . "'";
echo "<th scope='col' $id $class $style>$column_display_name</th>";
}
}
/**
* Display the table
*
* @since 3.1.0
* @access public
*/
function display() {
extract( $this->_args );
$this->display_tablenav( 'top' );
?>
<table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>" cellspacing="0">
<thead>
<tr>
<?php $this->print_column_headers(); ?>
</tr>
</thead>
<tfoot>
<tr>
<?php $this->print_column_headers( false ); ?>
</tr>
</tfoot>
<tbody id="the-list"<?php if ( $singular ) echo " class='list:$singular'"; ?>>
<?php $this->display_rows_or_placeholder(); ?>
</tbody>
</table>
<?php
$this->display_tablenav( 'bottom' );
}
/**
* Get a list of CSS classes for the <table> tag
*
* @since 3.1.0
* @access protected
*
* @return array
*/
function get_table_classes() {
return array( 'widefat', 'fixed', $this->_args['plural'] );
}
/**
* Generate the table navigation above or below the table
*
* @since 3.1.0
* @access protected
*/
function display_tablenav( $which ) {
if ( 'top' == $which )
wp_nonce_field( 'bulk-' . $this->_args['plural'] );
?>
<div class="tablenav <?php echo esc_attr( $which ); ?>">
<div class="alignleft actions">
<?php $this->bulk_actions( $which ); ?>
</div>
<?php
$this->extra_tablenav( $which );
$this->pagination( $which );
?>
<br class="clear" />
</div>
<?php
}
/**
* Extra controls to be displayed between bulk actions and pagination
*
* @since 3.1.0
* @access protected
*/
function extra_tablenav( $which ) {}
/**
* Generate the <tbody> part of the table
*
* @since 3.1.0
* @access protected
*/
function display_rows_or_placeholder() {
if ( $this->has_items() ) {
$this->display_rows();
} else {
list( $columns, $hidden ) = $this->get_column_info();
echo '<tr class="no-items"><td class="colspanchange" colspan="' . $this->get_column_count() . '">';
$this->no_items();
echo '</td></tr>';
}
}
/**
* Generate the table rows
*
* @since 3.1.0
* @access protected
*/
function display_rows() {
foreach ( $this->items as $item )
$this->single_row( $item );
}
/**
* Generates content for a single row of the table
*
* @since 3.1.0
* @access protected
*
* @param object $item The current item
*/
function single_row( $item ) {
static $row_class = '';
$row_class = ( $row_class == '' ? ' class="alternate"' : '' );
echo '<tr' . $row_class . '>';
echo $this->single_row_columns( $item );
echo '</tr>';
}
/**
* Generates the columns for a single row of the table
*
* @since 3.1.0
* @access protected
*
* @param object $item The current item
*/
function single_row_columns( $item ) {
list( $columns, $hidden ) = $this->get_column_info();
foreach ( $columns as $column_name => $column_display_name ) {
$class = "class='$column_name column-$column_name'";
$style = '';
if ( in_array( $column_name, $hidden ) )
$style = ' style="display:none;"';
$attributes = "$class$style";
if ( 'cb' == $column_name ) {
echo '<th scope="row" class="check-column">';
echo $this->column_cb( $item );
echo '</th>';
}
elseif ( method_exists( $this, 'column_' . $column_name ) ) {
echo "<td $attributes>";
echo call_user_func( array( &$this, 'column_' . $column_name ), $item );
echo "</td>";
}
else {
echo "<td $attributes>";
echo $this->column_default( $item, $column_name );
echo "</td>";
}
}
}
/**
* Handle an incoming ajax request (called from admin-ajax.php)
*
* @since 3.1.0
* @access public
*/
function ajax_response() {
$this->prepare_items();
extract( $this->_args );
extract( $this->_pagination_args, EXTR_SKIP );
ob_start();
if ( ! empty( $_REQUEST['no_placeholder'] ) )
$this->display_rows();
else
$this->display_rows_or_placeholder();
$rows = ob_get_clean();
$response = array( 'rows' => $rows );
if ( isset( $total_items ) )
$response['total_items_i18n'] = sprintf( _n( '1 item', '%s items', $total_items ), number_format_i18n( $total_items ) );
if ( isset( $total_pages ) ) {
$response['total_pages'] = $total_pages;
$response['total_pages_i18n'] = number_format_i18n( $total_pages );
}
die( json_encode( $response ) );
}
/**
* Send required variables to JavaScript land
*
* @access private
*/
function _js_vars() {
$current_screen = get_current_screen();
$args = array(
'class' => get_class( $this ),
'screen' => array(
'id' => $current_screen->id,
'base' => $current_screen->base,
)
);
printf( "<script type='text/javascript'>list_args = %s;</script>\n", json_encode( $args ) );
}
}
| 01happy-blog | trunk/myblog/wp-admin/includes/class-wp-list-table.php | PHP | oos | 22,333 |
<?php
/**
* Base WordPress Filesystem.
*
* @package WordPress
* @subpackage Filesystem
*/
/**
* Base WordPress Filesystem class for which Filesystem implementations extend
*
* @since 2.5
*/
class WP_Filesystem_Base {
/**
* Whether to display debug data for the connection.
*
* @since 2.5
* @access public
* @var bool
*/
var $verbose = false;
/**
* Cached list of local filepaths to mapped remote filepaths.
*
* @since 2.7
* @access private
* @var array
*/
var $cache = array();
/**
* The Access method of the current connection, Set automatically.
*
* @since 2.5
* @access public
* @var string
*/
var $method = '';
/**
* Returns the path on the remote filesystem of ABSPATH
*
* @since 2.7
* @access public
* @return string The location of the remote path.
*/
function abspath() {
$folder = $this->find_folder(ABSPATH);
//Perhaps the FTP folder is rooted at the WordPress install, Check for wp-includes folder in root, Could have some false positives, but rare.
if ( ! $folder && $this->is_dir('/wp-includes') )
$folder = '/';
return $folder;
}
/**
* Returns the path on the remote filesystem of WP_CONTENT_DIR
*
* @since 2.7
* @access public
* @return string The location of the remote path.
*/
function wp_content_dir() {
return $this->find_folder(WP_CONTENT_DIR);
}
/**
* Returns the path on the remote filesystem of WP_PLUGIN_DIR
*
* @since 2.7
* @access public
*
* @return string The location of the remote path.
*/
function wp_plugins_dir() {
return $this->find_folder(WP_PLUGIN_DIR);
}
/**
* Returns the path on the remote filesystem of the Themes Directory
*
* @since 2.7
* @access public
*
* @return string The location of the remote path.
*/
function wp_themes_dir() {
return $this->wp_content_dir() . 'themes/';
}
/**
* Returns the path on the remote filesystem of WP_LANG_DIR
*
* @since 3.2.0
* @access public
*
* @return string The location of the remote path.
*/
function wp_lang_dir() {
return $this->find_folder(WP_LANG_DIR);
}
/**
* Locates a folder on the remote filesystem.
*
* Deprecated; use WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir() methods instead.
*
* @since 2.5
* @deprecated 2.7
* @access public
*
* @param string $base The folder to start searching from
* @param bool $echo True to display debug information
* @return string The location of the remote path.
*/
function find_base_dir($base = '.', $echo = false) {
_deprecated_function(__FUNCTION__, '2.7', 'WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir()' );
$this->verbose = $echo;
return $this->abspath();
}
/**
* Locates a folder on the remote filesystem.
*
* Deprecated; use WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir() methods instead.
*
* @since 2.5
* @deprecated 2.7
* @access public
*
* @param string $base The folder to start searching from
* @param bool $echo True to display debug information
* @return string The location of the remote path.
*/
function get_base_dir($base = '.', $echo = false) {
_deprecated_function(__FUNCTION__, '2.7', 'WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir()' );
$this->verbose = $echo;
return $this->abspath();
}
/**
* Locates a folder on the remote filesystem.
*
* Assumes that on Windows systems, Stripping off the Drive letter is OK
* Sanitizes \\ to / in windows filepaths.
*
* @since 2.7
* @access public
*
* @param string $folder the folder to locate
* @return string The location of the remote path.
*/
function find_folder($folder) {
if ( strpos($this->method, 'ftp') !== false ) {
$constant_overrides = array( 'FTP_BASE' => ABSPATH, 'FTP_CONTENT_DIR' => WP_CONTENT_DIR, 'FTP_PLUGIN_DIR' => WP_PLUGIN_DIR, 'FTP_LANG_DIR' => WP_LANG_DIR );
foreach ( $constant_overrides as $constant => $dir )
if ( defined($constant) && $folder === $dir )
return trailingslashit(constant($constant));
} elseif ( 'direct' == $this->method ) {
$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
if ( isset($this->cache[ $folder ] ) )
return $this->cache[ $folder ];
if ( $this->exists($folder) ) { //Folder exists at that absolute path.
$folder = trailingslashit($folder);
$this->cache[ $folder ] = $folder;
return $folder;
}
if ( $return = $this->search_for_folder($folder) )
$this->cache[ $folder ] = $return;
return $return;
}
/**
* Locates a folder on the remote filesystem.
*
* Expects Windows sanitized path
*
* @since 2.7
* @access private
*
* @param string $folder the folder to locate
* @param string $base the folder to start searching from
* @param bool $loop if the function has recursed, Internal use only
* @return string The location of the remote path.
*/
function search_for_folder($folder, $base = '.', $loop = false ) {
if ( empty( $base ) || '.' == $base )
$base = trailingslashit($this->cwd());
$folder = untrailingslashit($folder);
$folder_parts = explode('/', $folder);
$last_path = $folder_parts[ count($folder_parts) - 1 ];
$files = $this->dirlist( $base );
foreach ( $folder_parts as $key ) {
if ( $key == $last_path )
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 the current folder,
// If its found, change into it and follow through looking for it.
// If it cant find WordPress down that route, it'll continue onto the next 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 ]) ){
//Lets try that folder:
$newdir = trailingslashit(path_join($base, $key));
if ( $this->verbose )
printf( __('Changing to %s') . '<br/>', $newdir );
if ( $ret = $this->search_for_folder( $folder, $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 ( $this->verbose )
printf( __('Found %s') . '<br/>', $base . $last_path );
return trailingslashit($base . $last_path);
}
if ( $loop )
return false; //Prevent this function from looping again.
//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/.... mainly dedicated setups.
return $this->search_for_folder($folder, '/', true);
}
/**
* Returns the *nix style file permissions for a file
*
* From the PHP documentation page for fileperms()
*
* @link http://docs.php.net/fileperms
* @since 2.5
* @access public
*
* @param string $file string filename
* @return int octal representation of permissions
*/
function gethchmod($file){
$perms = $this->getchmod($file);
if (($perms & 0xC000) == 0xC000) // Socket
$info = 's';
elseif (($perms & 0xA000) == 0xA000) // Symbolic Link
$info = 'l';
elseif (($perms & 0x8000) == 0x8000) // Regular
$info = '-';
elseif (($perms & 0x6000) == 0x6000) // Block special
$info = 'b';
elseif (($perms & 0x4000) == 0x4000) // Directory
$info = 'd';
elseif (($perms & 0x2000) == 0x2000) // Character special
$info = 'c';
elseif (($perms & 0x1000) == 0x1000) // FIFO pipe
$info = 'p';
else // Unknown
$info = 'u';
// Owner
$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' : '-'));
// World
$info .= (($perms & 0x0004) ? 'r' : '-');
$info .= (($perms & 0x0002) ? 'w' : '-');
$info .= (($perms & 0x0001) ?
(($perms & 0x0200) ? 't' : 'x' ) :
(($perms & 0x0200) ? 'T' : '-'));
return $info;
}
/**
* Converts *nix style file permissions to a octal number.
*
* Converts '-rw-r--r--' to 0644
* From "info at rvgate dot nl"'s comment on the PHP documentation for chmod()
*
* @link http://docs.php.net/manual/en/function.chmod.php#49614
* @since 2.5
* @access public
*
* @param string $mode string *nix style file permission
* @return int octal representation
*/
function getnumchmodfromh($mode) {
$realmode = '';
$legal = array('', 'w', 'r', 'x', '-');
$attarray = preg_split('//', $mode);
for ($i=0; $i < count($attarray); $i++)
if ($key = array_search($attarray[$i], $legal))
$realmode .= $legal[$key];
$mode = str_pad($realmode, 9, '-');
$trans = array('-'=>'0', 'r'=>'4', 'w'=>'2', 'x'=>'1');
$mode = strtr($mode,$trans);
$newmode = '';
$newmode .= $mode[0] + $mode[1] + $mode[2];
$newmode .= $mode[3] + $mode[4] + $mode[5];
$newmode .= $mode[6] + $mode[7] + $mode[8];
return $newmode;
}
/**
* Determines if the string provided contains binary characters.
*
* @since 2.7
* @access private
*
* @param string $text String to test against
* @return bool true if string is binary, false otherwise
*/
function is_binary( $text ) {
return (bool) preg_match('|[^\x20-\x7E]|', $text); //chr(32)..chr(127)
}
}
| 01happy-blog | trunk/myblog/wp-admin/includes/class-wp-filesystem-base.php | PHP | oos | 9,700 |
<?php
/**
* WordPress user administration API.
*
* @package WordPress
* @subpackage Administration
*/
/**
* Creates a new user from the "Users" form using $_POST information.
*
* @since 2.0
*
* @return null|WP_Error|int Null when adding user, WP_Error or User ID integer when no parameters.
*/
function add_user() {
return edit_user();
}
/**
* Edit user settings based on contents of $_POST
*
* Used on user-edit.php and profile.php to manage and process user options, passwords etc.
*
* @since 2.0
*
* @param int $user_id Optional. User ID.
* @return int user id of the updated user
*/
function edit_user( $user_id = 0 ) {
global $wp_roles, $wpdb;
$user = new stdClass;
if ( $user_id ) {
$update = true;
$user->ID = (int) $user_id;
$userdata = get_userdata( $user_id );
$user->user_login = $wpdb->escape( $userdata->user_login );
} else {
$update = false;
}
if ( !$update && isset( $_POST['user_login'] ) )
$user->user_login = sanitize_user($_POST['user_login'], true);
$pass1 = $pass2 = '';
if ( isset( $_POST['pass1'] ))
$pass1 = $_POST['pass1'];
if ( isset( $_POST['pass2'] ))
$pass2 = $_POST['pass2'];
if ( isset( $_POST['role'] ) && current_user_can( 'edit_users' ) ) {
$new_role = sanitize_text_field( $_POST['role'] );
$potential_role = isset($wp_roles->role_objects[$new_role]) ? $wp_roles->role_objects[$new_role] : false;
// Don't let anyone with 'edit_users' (admins) edit their own role to something without it.
// Multisite super admins can freely edit their blog roles -- they possess all caps.
if ( ( is_multisite() && current_user_can( 'manage_sites' ) ) || $user_id != get_current_user_id() || ($potential_role && $potential_role->has_cap( 'edit_users' ) ) )
$user->role = $new_role;
// If the new role isn't editable by the logged-in user die with error
$editable_roles = get_editable_roles();
if ( ! empty( $new_role ) && empty( $editable_roles[$new_role] ) )
wp_die(__('You can’t give users that role.'));
}
if ( isset( $_POST['email'] ))
$user->user_email = sanitize_text_field( $_POST['email'] );
if ( isset( $_POST['url'] ) ) {
if ( empty ( $_POST['url'] ) || $_POST['url'] == 'http://' ) {
$user->user_url = '';
} else {
$user->user_url = esc_url_raw( $_POST['url'] );
$user->user_url = preg_match('/^(https?|ftps?|mailto|news|irc|gopher|nntp|feed|telnet):/is', $user->user_url) ? $user->user_url : 'http://'.$user->user_url;
}
}
if ( isset( $_POST['first_name'] ) )
$user->first_name = sanitize_text_field( $_POST['first_name'] );
if ( isset( $_POST['last_name'] ) )
$user->last_name = sanitize_text_field( $_POST['last_name'] );
if ( isset( $_POST['nickname'] ) )
$user->nickname = sanitize_text_field( $_POST['nickname'] );
if ( isset( $_POST['display_name'] ) )
$user->display_name = sanitize_text_field( $_POST['display_name'] );
if ( isset( $_POST['description'] ) )
$user->description = trim( $_POST['description'] );
foreach ( _wp_get_user_contactmethods( $user ) as $method => $name ) {
if ( isset( $_POST[$method] ))
$user->$method = sanitize_text_field( $_POST[$method] );
}
if ( $update ) {
$user->rich_editing = isset( $_POST['rich_editing'] ) && 'false' == $_POST['rich_editing'] ? 'false' : 'true';
$user->admin_color = isset( $_POST['admin_color'] ) ? sanitize_text_field( $_POST['admin_color'] ) : 'fresh';
$user->show_admin_bar_front = isset( $_POST['admin_bar_front'] ) ? 'true' : 'false';
}
$user->comment_shortcuts = isset( $_POST['comment_shortcuts'] ) && 'true' == $_POST['comment_shortcuts'] ? 'true' : '';
$user->use_ssl = 0;
if ( !empty($_POST['use_ssl']) )
$user->use_ssl = 1;
$errors = new WP_Error();
/* checking that username has been typed */
if ( $user->user_login == '' )
$errors->add( 'user_login', __( '<strong>ERROR</strong>: Please enter a username.' ));
/* checking the password has been typed twice */
do_action_ref_array( 'check_passwords', array ( $user->user_login, & $pass1, & $pass2 ));
if ( $update ) {
if ( empty($pass1) && !empty($pass2) )
$errors->add( 'pass', __( '<strong>ERROR</strong>: You entered your new password only once.' ), array( 'form-field' => 'pass1' ) );
elseif ( !empty($pass1) && empty($pass2) )
$errors->add( 'pass', __( '<strong>ERROR</strong>: You entered your new password only once.' ), array( 'form-field' => 'pass2' ) );
} else {
if ( empty($pass1) )
$errors->add( 'pass', __( '<strong>ERROR</strong>: Please enter your password.' ), array( 'form-field' => 'pass1' ) );
elseif ( empty($pass2) )
$errors->add( 'pass', __( '<strong>ERROR</strong>: Please enter your password twice.' ), array( 'form-field' => 'pass2' ) );
}
/* Check for "\" in password */
if ( false !== strpos( stripslashes($pass1), "\\" ) )
$errors->add( 'pass', __( '<strong>ERROR</strong>: Passwords may not contain the character "\\".' ), array( 'form-field' => 'pass1' ) );
/* checking the password has been typed twice the same */
if ( $pass1 != $pass2 )
$errors->add( 'pass', __( '<strong>ERROR</strong>: Please enter the same password in the two password fields.' ), array( 'form-field' => 'pass1' ) );
if ( !empty( $pass1 ) )
$user->user_pass = $pass1;
if ( !$update && isset( $_POST['user_login'] ) && !validate_username( $_POST['user_login'] ) )
$errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is invalid because it uses illegal characters. Please enter a valid username.' ));
if ( !$update && username_exists( $user->user_login ) )
$errors->add( 'user_login', __( '<strong>ERROR</strong>: This username is already registered. Please choose another one.' ));
/* checking e-mail address */
if ( empty( $user->user_email ) ) {
$errors->add( 'empty_email', __( '<strong>ERROR</strong>: Please enter an e-mail address.' ), array( 'form-field' => 'email' ) );
} elseif ( !is_email( $user->user_email ) ) {
$errors->add( 'invalid_email', __( '<strong>ERROR</strong>: The e-mail address isn’t correct.' ), array( 'form-field' => 'email' ) );
} elseif ( ( $owner_id = email_exists($user->user_email) ) && ( !$update || ( $owner_id != $user->ID ) ) ) {
$errors->add( 'email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.'), array( 'form-field' => 'email' ) );
}
// Allow plugins to return their own errors.
do_action_ref_array('user_profile_update_errors', array ( &$errors, $update, &$user ) );
if ( $errors->get_error_codes() )
return $errors;
if ( $update ) {
$user_id = wp_update_user( get_object_vars( $user ) );
} else {
$user_id = wp_insert_user( get_object_vars( $user ) );
wp_new_user_notification( $user_id, isset($_POST['send_password']) ? $pass1 : '' );
}
return $user_id;
}
/**
* Fetch a filtered list of user roles that the current user is
* allowed to edit.
*
* Simple function who's main purpose is to allow filtering of the
* list of roles in the $wp_roles object so that plugins can remove
* inappropriate ones depending on the situation or user making edits.
* Specifically because without filtering anyone with the edit_users
* capability can edit others to be administrators, even if they are
* only editors or authors. This filter allows admins to delegate
* user management.
*
* @since 2.8
*
* @return unknown
*/
function get_editable_roles() {
global $wp_roles;
$all_roles = $wp_roles->roles;
$editable_roles = apply_filters('editable_roles', $all_roles);
return $editable_roles;
}
/**
* Retrieve user data and filter it.
*
* @since 2.0.5
*
* @param int $user_id User ID.
* @return object WP_User object with user data.
*/
function get_user_to_edit( $user_id ) {
$user = new WP_User( $user_id );
$user->filter = 'edit';
return $user;
}
/**
* Retrieve the user's drafts.
*
* @since 2.0.0
*
* @param int $user_id User ID.
* @return array
*/
function get_users_drafts( $user_id ) {
global $wpdb;
$query = $wpdb->prepare("SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'draft' AND post_author = %d ORDER BY post_modified DESC", $user_id);
$query = apply_filters('get_users_drafts', $query);
return $wpdb->get_results( $query );
}
/**
* Remove user and optionally reassign posts and links to another user.
*
* If the $reassign parameter is not assigned to an User ID, then all posts will
* be deleted of that user. The action 'delete_user' that is passed the User ID
* being deleted will be run after the posts are either reassigned or deleted.
* The user meta will also be deleted that are for that User ID.
*
* @since 2.0.0
*
* @param int $id User ID.
* @param int $reassign Optional. Reassign posts and links to new User ID.
* @return bool True when finished.
*/
function wp_delete_user( $id, $reassign = 'novalue' ) {
global $wpdb;
$id = (int) $id;
$user = new WP_User( $id );
// allow for transaction statement
do_action('delete_user', $id);
if ( 'novalue' === $reassign || null === $reassign ) {
$post_types_to_delete = array();
foreach ( get_post_types( array(), 'objects' ) as $post_type ) {
if ( $post_type->delete_with_user ) {
$post_types_to_delete[] = $post_type->name;
} elseif ( null === $post_type->delete_with_user && post_type_supports( $post_type->name, 'author' ) ) {
$post_types_to_delete[] = $post_type->name;
}
}
$post_types_to_delete = apply_filters( 'post_types_to_delete_with_user', $post_types_to_delete, $id );
$post_types_to_delete = implode( "', '", $post_types_to_delete );
$post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d AND post_type IN ('$post_types_to_delete')", $id ) );
if ( $post_ids ) {
foreach ( $post_ids as $post_id )
wp_delete_post( $post_id );
}
// Clean links
$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 )
wp_delete_link($link_id);
}
} else {
$reassign = (int) $reassign;
$wpdb->update( $wpdb->posts, array('post_author' => $reassign), array('post_author' => $id) );
$wpdb->update( $wpdb->links, array('link_owner' => $reassign), array('link_owner' => $id) );
}
// FINALLY, delete user
if ( is_multisite() ) {
remove_user_from_blog( $id, get_current_blog_id() );
} else {
$meta = $wpdb->get_col( $wpdb->prepare( "SELECT umeta_id FROM $wpdb->usermeta WHERE user_id = %d", $id ) );
foreach ( $meta as $mid )
delete_metadata_by_mid( 'user', $mid );
$wpdb->delete( $wpdb->users, array( 'ID' => $id ) );
}
clean_user_cache( $user );
// allow for commit transaction
do_action('deleted_user', $id);
return true;
}
/**
* Remove all capabilities from user.
*
* @since 2.1.0
*
* @param int $id User ID.
*/
function wp_revoke_user($id) {
$id = (int) $id;
$user = new WP_User($id);
$user->remove_all_caps();
}
add_action('admin_init', 'default_password_nag_handler');
/**
* @since 2.8.0
*/
function default_password_nag_handler($errors = false) {
global $user_ID;
if ( ! get_user_option('default_password_nag') ) //Short circuit it.
return;
//get_user_setting = JS saved UI setting. else no-js-fallback code.
if ( 'hide' == get_user_setting('default_password_nag') || isset($_GET['default_password_nag']) && '0' == $_GET['default_password_nag'] ) {
delete_user_setting('default_password_nag');
update_user_option($user_ID, 'default_password_nag', false, true);
}
}
add_action('profile_update', 'default_password_nag_edit_user', 10, 2);
/**
* @since 2.8.0
*/
function default_password_nag_edit_user($user_ID, $old_data) {
if ( ! get_user_option('default_password_nag', $user_ID) ) //Short circuit it.
return;
$new_data = get_userdata($user_ID);
if ( $new_data->user_pass != $old_data->user_pass ) { //Remove the nag if the password has been changed.
delete_user_setting('default_password_nag', $user_ID);
update_user_option($user_ID, 'default_password_nag', false, true);
}
}
add_action('admin_notices', 'default_password_nag');
/**
* @since 2.8.0
*/
function default_password_nag() {
global $pagenow;
if ( 'profile.php' == $pagenow || ! get_user_option('default_password_nag') ) //Short circuit it.
return;
echo '<div class="error default-password-nag">';
echo '<p>';
echo '<strong>' . __('Notice:') . '</strong> ';
_e('You’re using the auto-generated password for your account. Would you like to change it to something easier to remember?');
echo '</p><p>';
printf( '<a href="%s">' . __('Yes, take me to my profile page') . '</a> | ', admin_url('profile.php') . '#password' );
printf( '<a href="%s" id="default-password-nag-no">' . __('No thanks, do not remind me again') . '</a>', '?default_password_nag=0' );
echo '</p></div>';
}
| 01happy-blog | trunk/myblog/wp-admin/includes/user.php | PHP | oos | 12,782 |
<?php
/**
* WordPress FTP Filesystem.
*
* @package WordPress
* @subpackage Filesystem
*/
/**
* WordPress Filesystem Class for implementing FTP.
*
* @since 2.5
* @package WordPress
* @subpackage Filesystem
* @uses WP_Filesystem_Base Extends class
*/
class WP_Filesystem_FTPext extends WP_Filesystem_Base {
var $link;
var $errors = null;
var $options = array();
function __construct($opt='') {
$this->method = 'ftpext';
$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'));
return false;
}
// Set defaults:
//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 ( empty($opt['port']) )
$this->options['port'] = 21;
else
$this->options['port'] = $opt['port'];
if ( empty($opt['hostname']) )
$this->errors->add('empty_hostname', __('FTP hostname is required'));
else
$this->options['hostname'] = $opt['hostname'];
if ( ! empty($opt['base']) )
$this->wp_base = $opt['base'];
// Check if the options provided are OK.
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
$this->options['password'] = $opt['password'];
$this->options['ssl'] = false;
if ( isset($opt['connection_type']) && 'ftps' == $opt['connection_type'] )
$this->options['ssl'] = true;
}
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 ( ! $this->link ) {
$this->errors->add('connect', sprintf(__('Failed to connect to FTP Server %1$s:%2$s'), $this->options['hostname'], $this->options['port']));
return false;
}
if ( ! @ftp_login($this->link,$this->options['username'], $this->options['password']) ) {
$this->errors->add('auth', sprintf(__('Username/Password incorrect for %s'), $this->options['username']));
return false;
}
//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);
return true;
}
function get_contents($file, $type = '', $resumepos = 0 ) {
if ( empty($type) )
$type = FTP_BINARY;
$tempfile = wp_tempnam($file);
$temp = fopen($tempfile, 'w+');
if ( ! $temp )
return false;
if ( ! @ftp_fget($this->link, $temp, $file, $type, $resumepos) )
return false;
fseek($temp, 0); //Skip back to the start of the file being written to
$contents = '';
while ( ! feof($temp) )
$contents .= fread($temp, 8192);
fclose($temp);
unlink($tempfile);
return $contents;
}
function get_contents_array($file) {
return explode("\n", $this->get_contents($file));
}
function put_contents($file, $contents, $mode = false ) {
$tempfile = wp_tempnam($file);
$temp = fopen($tempfile, 'w+');
if ( ! $temp )
return false;
fwrite($temp, $contents);
fseek($temp, 0); //Skip back to the start of the file being written to
$type = $this->is_binary($contents) ? FTP_BINARY : FTP_ASCII;
$ret = @ftp_fput($this->link, $file, $temp, $type);
fclose($temp);
unlink($tempfile);
$this->chmod($file, $mode);
return $ret;
}
function cwd() {
$cwd = @ftp_pwd($this->link);
if ( $cwd )
$cwd = trailingslashit($cwd);
return $cwd;
}
function chdir($dir) {
return @ftp_chdir($this->link, $dir);
}
function chgrp($file, $group, $recursive = false ) {
return false;
}
function chmod($file, $mode = false, $recursive = false) {
if ( ! $mode ) {
if ( $this->is_file($file) )
$mode = FS_CHMOD_FILE;
elseif ( $this->is_dir($file) )
$mode = FS_CHMOD_DIR;
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);
}
// 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);
}
function chown($file, $owner, $recursive = false ) {
return false;
}
function owner($file) {
$dir = $this->dirlist($file);
return $dir[$file]['owner'];
}
function getchmod($file) {
$dir = $this->dirlist($file);
return $dir[$file]['permsn'];
}
function group($file) {
$dir = $this->dirlist($file);
return $dir[$file]['group'];
}
function copy($source, $destination, $overwrite = false, $mode = false) {
if ( ! $overwrite && $this->exists($destination) )
return false;
$content = $this->get_contents($source);
if ( false === $content)
return false;
return $this->put_contents($destination, $content, $mode);
}
function move($source, $destination, $overwrite = false) {
return ftp_rename($this->link, $source, $destination);
}
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);
$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);
}
function exists($file) {
$list = @ftp_nlist($this->link, $file);
return !empty($list); //empty list = no file, so invert.
}
function is_file($file) {
return $this->exists($file) && !$this->is_dir($file);
}
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);
return true;
}
return false;
}
function is_readable($file) {
//Get dir list, Check if the file is readable by the current user??
return true;
}
function is_writable($file) {
//Get dir list, Check if the file is writable by the current user??
return true;
}
function atime($file) {
return false;
}
function mtime($file) {
return ftp_mdtm($this->link, $file);
}
function size($file) {
return ftp_size($this->link, $file);
}
function touch($file, $time = 0, $atime = 0) {
return false;
}
function mkdir($path, $chmod = false, $chown = false, $chgrp = false) {
$path = untrailingslashit($path);
if ( empty($path) )
return false;
if ( !@ftp_mkdir($this->link, $path) )
return false;
$this->chmod($path, $chmod);
if ( $chown )
$this->chown($path, $chown);
if ( $chgrp )
$this->chgrp($path, $chgrp);
return true;
}
function rmdir($path, $recursive = false) {
return $this->delete($path, $recursive);
}
function parselisting($line) {
static $is_windows;
if ( is_null($is_windows) )
$is_windows = stripos( ftp_systype($this->link), 'win') !== false;
if ( $is_windows && preg_match('/([0-9]{2})-([0-9]{2})-([0-9]{2}) +([0-9]{2}):([0-9]{2})(AM|PM) +([0-9]+|<DIR>) +(.+)/', $line, $lucifer) ) {
$b = array();
if ( $lucifer[3] < 70 )
$lucifer[3] +=2000;
else
$lucifer[3] += 1900; // 4digit year fix
$b['isdir'] = ( $lucifer[7] == '<DIR>');
if ( $b['isdir'] )
$b['type'] = 'd';
else
$b['type'] = 'f';
$b['size'] = $lucifer[7];
$b['month'] = $lucifer[1];
$b['day'] = $lucifer[2];
$b['year'] = $lucifer[3];
$b['hour'] = $lucifer[4];
$b['minute'] = $lucifer[5];
$b['time'] = @mktime($lucifer[4] + (strcasecmp($lucifer[6], "PM") == 0 ? 12 : 0), $lucifer[5], 0, $lucifer[1], $lucifer[2], $lucifer[3]);
$b['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 )
return '';
$b = array();
$b['isdir'] = $lucifer[0]{0} === 'd';
$b['islink'] = $lucifer[0]{0} === 'l';
if ( $b['isdir'] )
$b['type'] = 'd';
elseif ( $b['islink'] )
$b['type'] = 'l';
else
$b['type'] = 'f';
$b['perms'] = $lucifer[0];
$b['number'] = $lucifer[1];
$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']);
$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['minute'] = $l2[2];
} else {
$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['name'] = $lucifer[8];
}
}
return $b;
}
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
return false;
$list = @ftp_rawlist($this->link, '-a', false);
@ftp_chdir($this->link, $pwd);
if ( empty($list) ) // Empty array = non-existent folder (real folder will show . at least)
return false;
$dirlist = array();
foreach ( $list as $k => $v ) {
$entry = $this->parselisting($v);
if ( empty($entry) )
continue;
if ( '.' == $entry['name'] || '..' == $entry['name'] )
continue;
if ( ! $include_hidden && '.' == $entry['name'][0] )
continue;
if ( $limit_file && $entry['name'] != $limit_file)
continue;
$dirlist[ $entry['name'] ] = $entry;
}
$ret = array();
foreach ( (array)$dirlist as $struc ) {
if ( 'd' == $struc['type'] ) {
if ( $recursive )
$struc['files'] = $this->dirlist($path . '/' . $struc['name'], $include_hidden, $recursive);
else
$struc['files'] = array();
}
$ret[ $struc['name'] ] = $struc;
}
return $ret;
}
function __destruct() {
if ( $this->link )
ftp_close($this->link);
}
}
| 01happy-blog | trunk/myblog/wp-admin/includes/class-wp-filesystem-ftpext.php | PHP | oos | 10,970 |
<?php
/* Continent and city translations for timezone selection.
* This file is not included anywhere. It exists solely for use by xgettext.
*/
__('Africa', 'continents-cities');
__('Abidjan', 'continents-cities');
__('Accra', 'continents-cities');
__('Addis Ababa', 'continents-cities');
__('Algiers', 'continents-cities');
__('Asmara', 'continents-cities');
__('Asmera', 'continents-cities');
__('Bamako', 'continents-cities');
__('Bangui', 'continents-cities');
__('Banjul', 'continents-cities');
__('Bissau', 'continents-cities');
__('Blantyre', 'continents-cities');
__('Brazzaville', 'continents-cities');
__('Bujumbura', 'continents-cities');
__('Cairo', 'continents-cities');
__('Casablanca', 'continents-cities');
__('Ceuta', 'continents-cities');
__('Conakry', 'continents-cities');
__('Dakar', 'continents-cities');
__('Dar es Salaam', 'continents-cities');
__('Djibouti', 'continents-cities');
__('Douala', 'continents-cities');
__('El Aaiun', 'continents-cities');
__('Freetown', 'continents-cities');
__('Gaborone', 'continents-cities');
__('Harare', 'continents-cities');
__('Johannesburg', 'continents-cities');
__('Kampala', 'continents-cities');
__('Khartoum', 'continents-cities');
__('Kigali', 'continents-cities');
__('Kinshasa', 'continents-cities');
__('Lagos', 'continents-cities');
__('Libreville', 'continents-cities');
__('Lome', 'continents-cities');
__('Luanda', 'continents-cities');
__('Lubumbashi', 'continents-cities');
__('Lusaka', 'continents-cities');
__('Malabo', 'continents-cities');
__('Maputo', 'continents-cities');
__('Maseru', 'continents-cities');
__('Mbabane', 'continents-cities');
__('Mogadishu', 'continents-cities');
__('Monrovia', 'continents-cities');
__('Nairobi', 'continents-cities');
__('Ndjamena', 'continents-cities');
__('Niamey', 'continents-cities');
__('Nouakchott', 'continents-cities');
__('Ouagadougou', 'continents-cities');
__('Porto-Novo', 'continents-cities');
__('Sao Tome', 'continents-cities');
__('Timbuktu', 'continents-cities');
__('Tripoli', 'continents-cities');
__('Tunis', 'continents-cities');
__('Windhoek', 'continents-cities');
__('America', 'continents-cities');
__('Adak', 'continents-cities');
__('Anchorage', 'continents-cities');
__('Anguilla', 'continents-cities');
__('Antigua', 'continents-cities');
__('Araguaina', 'continents-cities');
__('Argentina', 'continents-cities');
__('Buenos Aires', 'continents-cities');
__('Catamarca', 'continents-cities');
__('ComodRivadavia', 'continents-cities');
__('Cordoba', 'continents-cities');
__('Jujuy', 'continents-cities');
__('La Rioja', 'continents-cities');
__('Mendoza', 'continents-cities');
__('Rio Gallegos', 'continents-cities');
__('San Juan', 'continents-cities');
__('San Luis', 'continents-cities');
__('Tucuman', 'continents-cities');
__('Ushuaia', 'continents-cities');
__('Aruba', 'continents-cities');
__('Asuncion', 'continents-cities');
__('Atikokan', 'continents-cities');
__('Atka', 'continents-cities');
__('Bahia', 'continents-cities');
__('Barbados', 'continents-cities');
__('Belem', 'continents-cities');
__('Belize', 'continents-cities');
__('Blanc-Sablon', 'continents-cities');
__('Boa Vista', 'continents-cities');
__('Bogota', 'continents-cities');
__('Boise', 'continents-cities');
__('Cambridge Bay', 'continents-cities');
__('Campo Grande', 'continents-cities');
__('Cancun', 'continents-cities');
__('Caracas', 'continents-cities');
__('Cayenne', 'continents-cities');
__('Cayman', 'continents-cities');
__('Chicago', 'continents-cities');
__('Chihuahua', 'continents-cities');
__('Coral Harbour', 'continents-cities');
__('Costa Rica', 'continents-cities');
__('Cuiaba', 'continents-cities');
__('Curacao', 'continents-cities');
__('Danmarkshavn', 'continents-cities');
__('Dawson', 'continents-cities');
__('Dawson Creek', 'continents-cities');
__('Denver', 'continents-cities');
__('Detroit', 'continents-cities');
__('Dominica', 'continents-cities');
__('Edmonton', 'continents-cities');
__('Eirunepe', 'continents-cities');
__('El Salvador', 'continents-cities');
__('Ensenada', 'continents-cities');
__('Fort Wayne', 'continents-cities');
__('Fortaleza', 'continents-cities');
__('Glace Bay', 'continents-cities');
__('Godthab', 'continents-cities');
__('Goose Bay', 'continents-cities');
__('Grand Turk', 'continents-cities');
__('Grenada', 'continents-cities');
__('Guadeloupe', 'continents-cities');
__('Guatemala', 'continents-cities');
__('Guayaquil', 'continents-cities');
__('Guyana', 'continents-cities');
__('Halifax', 'continents-cities');
__('Havana', 'continents-cities');
__('Hermosillo', 'continents-cities');
__('Indiana', 'continents-cities');
__('Indianapolis', 'continents-cities');
__('Knox', 'continents-cities');
__('Marengo', 'continents-cities');
__('Petersburg', 'continents-cities');
__('Tell City', 'continents-cities');
__('Vevay', 'continents-cities');
__('Vincennes', 'continents-cities');
__('Winamac', 'continents-cities');
__('Inuvik', 'continents-cities');
__('Iqaluit', 'continents-cities');
__('Jamaica', 'continents-cities');
__('Juneau', 'continents-cities');
__('Kentucky', 'continents-cities');
__('Louisville', 'continents-cities');
__('Monticello', 'continents-cities');
__('Knox IN', 'continents-cities');
__('La Paz', 'continents-cities');
__('Lima', 'continents-cities');
__('Los Angeles', 'continents-cities');
__('Maceio', 'continents-cities');
__('Managua', 'continents-cities');
__('Manaus', 'continents-cities');
__('Marigot', 'continents-cities');
__('Martinique', 'continents-cities');
__('Mazatlan', 'continents-cities');
__('Menominee', 'continents-cities');
__('Merida', 'continents-cities');
__('Mexico City', 'continents-cities');
__('Miquelon', 'continents-cities');
__('Moncton', 'continents-cities');
__('Monterrey', 'continents-cities');
__('Montevideo', 'continents-cities');
__('Montreal', 'continents-cities');
__('Montserrat', 'continents-cities');
__('Nassau', 'continents-cities');
__('New York', 'continents-cities');
__('Nipigon', 'continents-cities');
__('Nome', 'continents-cities');
__('Noronha', 'continents-cities');
__('North Dakota', 'continents-cities');
__('Center', 'continents-cities');
__('New Salem', 'continents-cities');
__('Panama', 'continents-cities');
__('Pangnirtung', 'continents-cities');
__('Paramaribo', 'continents-cities');
__('Phoenix', 'continents-cities');
__('Port-au-Prince', 'continents-cities');
__('Port of Spain', 'continents-cities');
__('Porto Acre', 'continents-cities');
__('Porto Velho', 'continents-cities');
__('Puerto Rico', 'continents-cities');
__('Rainy River', 'continents-cities');
__('Rankin Inlet', 'continents-cities');
__('Recife', 'continents-cities');
__('Regina', 'continents-cities');
__('Resolute', 'continents-cities');
__('Rio Branco', 'continents-cities');
__('Rosario', 'continents-cities');
__('Santiago', 'continents-cities');
__('Santo Domingo', 'continents-cities');
__('Sao Paulo', 'continents-cities');
__('Scoresbysund', 'continents-cities');
__('Shiprock', 'continents-cities');
__('St Barthelemy', 'continents-cities');
__('St Johns', 'continents-cities');
__('St Kitts', 'continents-cities');
__('St Lucia', 'continents-cities');
__('St Thomas', 'continents-cities');
__('St Vincent', 'continents-cities');
__('Swift Current', 'continents-cities');
__('Tegucigalpa', 'continents-cities');
__('Thule', 'continents-cities');
__('Thunder Bay', 'continents-cities');
__('Tijuana', 'continents-cities');
__('Toronto', 'continents-cities');
__('Tortola', 'continents-cities');
__('Vancouver', 'continents-cities');
__('Virgin', 'continents-cities');
__('Whitehorse', 'continents-cities');
__('Winnipeg', 'continents-cities');
__('Yakutat', 'continents-cities');
__('Yellowknife', 'continents-cities');
__('Antarctica', 'continents-cities');
__('Casey', 'continents-cities');
__('Davis', 'continents-cities');
__('DumontDUrville', 'continents-cities');
__('Mawson', 'continents-cities');
__('McMurdo', 'continents-cities');
__('Palmer', 'continents-cities');
__('Rothera', 'continents-cities');
__('South Pole', 'continents-cities');
__('Syowa', 'continents-cities');
__('Vostok', 'continents-cities');
__('Arctic', 'continents-cities');
__('Longyearbyen', 'continents-cities');
__('Asia', 'continents-cities');
__('Aden', 'continents-cities');
__('Almaty', 'continents-cities');
__('Amman', 'continents-cities');
__('Anadyr', 'continents-cities');
__('Aqtau', 'continents-cities');
__('Aqtobe', 'continents-cities');
__('Ashgabat', 'continents-cities');
__('Ashkhabad', 'continents-cities');
__('Baghdad', 'continents-cities');
__('Bahrain', 'continents-cities');
__('Baku', 'continents-cities');
__('Bangkok', 'continents-cities');
__('Beirut', 'continents-cities');
__('Bishkek', 'continents-cities');
__('Brunei', 'continents-cities');
__('Calcutta', 'continents-cities');
__('Choibalsan', 'continents-cities');
__('Chongqing', 'continents-cities');
__('Chungking', 'continents-cities');
__('Colombo', 'continents-cities');
__('Dacca', 'continents-cities');
__('Damascus', 'continents-cities');
__('Dhaka', 'continents-cities');
__('Dili', 'continents-cities');
__('Dubai', 'continents-cities');
__('Dushanbe', 'continents-cities');
__('Gaza', 'continents-cities');
__('Harbin', 'continents-cities');
__('Ho Chi Minh', 'continents-cities');
__('Hong Kong', 'continents-cities');
__('Hovd', 'continents-cities');
__('Irkutsk', 'continents-cities');
__('Istanbul', 'continents-cities');
__('Jakarta', 'continents-cities');
__('Jayapura', 'continents-cities');
__('Jerusalem', 'continents-cities');
__('Kabul', 'continents-cities');
__('Kamchatka', 'continents-cities');
__('Karachi', 'continents-cities');
__('Kashgar', 'continents-cities');
__('Katmandu', 'continents-cities');
__('Kolkata', 'continents-cities');
__('Krasnoyarsk', 'continents-cities');
__('Kuala Lumpur', 'continents-cities');
__('Kuching', 'continents-cities');
__('Kuwait', 'continents-cities');
__('Macao', 'continents-cities');
__('Macau', 'continents-cities');
__('Magadan', 'continents-cities');
__('Makassar', 'continents-cities');
__('Manila', 'continents-cities');
__('Muscat', 'continents-cities');
__('Nicosia', 'continents-cities');
__('Novosibirsk', 'continents-cities');
__('Omsk', 'continents-cities');
__('Oral', 'continents-cities');
__('Phnom Penh', 'continents-cities');
__('Pontianak', 'continents-cities');
__('Pyongyang', 'continents-cities');
__('Qatar', 'continents-cities');
__('Qyzylorda', 'continents-cities');
__('Rangoon', 'continents-cities');
__('Riyadh', 'continents-cities');
__('Saigon', 'continents-cities');
__('Sakhalin', 'continents-cities');
__('Samarkand', 'continents-cities');
__('Seoul', 'continents-cities');
__('Shanghai', 'continents-cities');
__('Singapore', 'continents-cities');
__('Taipei', 'continents-cities');
__('Tashkent', 'continents-cities');
__('Tbilisi', 'continents-cities');
__('Tehran', 'continents-cities');
__('Tel Aviv', 'continents-cities');
__('Thimbu', 'continents-cities');
__('Thimphu', 'continents-cities');
__('Tokyo', 'continents-cities');
__('Ujung Pandang', 'continents-cities');
__('Ulaanbaatar', 'continents-cities');
__('Ulan Bator', 'continents-cities');
__('Urumqi', 'continents-cities');
__('Vientiane', 'continents-cities');
__('Vladivostok', 'continents-cities');
__('Yakutsk', 'continents-cities');
__('Yekaterinburg', 'continents-cities');
__('Yerevan', 'continents-cities');
__('Atlantic', 'continents-cities');
__('Azores', 'continents-cities');
__('Bermuda', 'continents-cities');
__('Canary', 'continents-cities');
__('Cape Verde', 'continents-cities');
__('Faeroe', 'continents-cities');
__('Faroe', 'continents-cities');
__('Jan Mayen', 'continents-cities');
__('Madeira', 'continents-cities');
__('Reykjavik', 'continents-cities');
__('South Georgia', 'continents-cities');
__('St Helena', 'continents-cities');
__('Stanley', 'continents-cities');
__('Australia', 'continents-cities');
__('ACT', 'continents-cities');
__('Adelaide', 'continents-cities');
__('Brisbane', 'continents-cities');
__('Broken Hill', 'continents-cities');
__('Canberra', 'continents-cities');
__('Currie', 'continents-cities');
__('Darwin', 'continents-cities');
__('Eucla', 'continents-cities');
__('Hobart', 'continents-cities');
__('LHI', 'continents-cities');
__('Lindeman', 'continents-cities');
__('Lord Howe', 'continents-cities');
__('Melbourne', 'continents-cities');
__('North', 'continents-cities');
__('NSW', 'continents-cities');
__('Perth', 'continents-cities');
__('Queensland', 'continents-cities');
__('South', 'continents-cities');
__('Sydney', 'continents-cities');
__('Tasmania', 'continents-cities');
__('Victoria', 'continents-cities');
__('West', 'continents-cities');
__('Yancowinna', 'continents-cities');
__('Etc', 'continents-cities');
__('GMT', 'continents-cities');
__('GMT+0', 'continents-cities');
__('GMT+1', 'continents-cities');
__('GMT+10', 'continents-cities');
__('GMT+11', 'continents-cities');
__('GMT+12', 'continents-cities');
__('GMT+2', 'continents-cities');
__('GMT+3', 'continents-cities');
__('GMT+4', 'continents-cities');
__('GMT+5', 'continents-cities');
__('GMT+6', 'continents-cities');
__('GMT+7', 'continents-cities');
__('GMT+8', 'continents-cities');
__('GMT+9', 'continents-cities');
__('GMT-0', 'continents-cities');
__('GMT-1', 'continents-cities');
__('GMT-10', 'continents-cities');
__('GMT-11', 'continents-cities');
__('GMT-12', 'continents-cities');
__('GMT-13', 'continents-cities');
__('GMT-14', 'continents-cities');
__('GMT-2', 'continents-cities');
__('GMT-3', 'continents-cities');
__('GMT-4', 'continents-cities');
__('GMT-5', 'continents-cities');
__('GMT-6', 'continents-cities');
__('GMT-7', 'continents-cities');
__('GMT-8', 'continents-cities');
__('GMT-9', 'continents-cities');
__('GMT0', 'continents-cities');
__('Greenwich', 'continents-cities');
__('UCT', 'continents-cities');
__('Universal', 'continents-cities');
__('UTC', 'continents-cities');
__('Zulu', 'continents-cities');
__('Europe', 'continents-cities');
__('Amsterdam', 'continents-cities');
__('Andorra', 'continents-cities');
__('Athens', 'continents-cities');
__('Belfast', 'continents-cities');
__('Belgrade', 'continents-cities');
__('Berlin', 'continents-cities');
__('Bratislava', 'continents-cities');
__('Brussels', 'continents-cities');
__('Bucharest', 'continents-cities');
__('Budapest', 'continents-cities');
__('Chisinau', 'continents-cities');
__('Copenhagen', 'continents-cities');
__('Dublin', 'continents-cities');
__('Gibraltar', 'continents-cities');
__('Guernsey', 'continents-cities');
__('Helsinki', 'continents-cities');
__('Isle of Man', 'continents-cities');
__('Jersey', 'continents-cities');
__('Kaliningrad', 'continents-cities');
__('Kiev', 'continents-cities');
__('Lisbon', 'continents-cities');
__('Ljubljana', 'continents-cities');
__('London', 'continents-cities');
__('Luxembourg', 'continents-cities');
__('Madrid', 'continents-cities');
__('Malta', 'continents-cities');
__('Mariehamn', 'continents-cities');
__('Minsk', 'continents-cities');
__('Monaco', 'continents-cities');
__('Moscow', 'continents-cities');
__('Oslo', 'continents-cities');
__('Paris', 'continents-cities');
__('Podgorica', 'continents-cities');
__('Prague', 'continents-cities');
__('Riga', 'continents-cities');
__('Rome', 'continents-cities');
__('Samara', 'continents-cities');
__('San Marino', 'continents-cities');
__('Sarajevo', 'continents-cities');
__('Simferopol', 'continents-cities');
__('Skopje', 'continents-cities');
__('Sofia', 'continents-cities');
__('Stockholm', 'continents-cities');
__('Tallinn', 'continents-cities');
__('Tirane', 'continents-cities');
__('Tiraspol', 'continents-cities');
__('Uzhgorod', 'continents-cities');
__('Vaduz', 'continents-cities');
__('Vatican', 'continents-cities');
__('Vienna', 'continents-cities');
__('Vilnius', 'continents-cities');
__('Volgograd', 'continents-cities');
__('Warsaw', 'continents-cities');
__('Zagreb', 'continents-cities');
__('Zaporozhye', 'continents-cities');
__('Zurich', 'continents-cities');
__('Indian', 'continents-cities');
__('Antananarivo', 'continents-cities');
__('Chagos', 'continents-cities');
__('Christmas', 'continents-cities');
__('Cocos', 'continents-cities');
__('Comoro', 'continents-cities');
__('Kerguelen', 'continents-cities');
__('Mahe', 'continents-cities');
__('Maldives', 'continents-cities');
__('Mauritius', 'continents-cities');
__('Mayotte', 'continents-cities');
__('Reunion', 'continents-cities');
__('Pacific', 'continents-cities');
__('Apia', 'continents-cities');
__('Auckland', 'continents-cities');
__('Chatham', 'continents-cities');
__('Easter', 'continents-cities');
__('Efate', 'continents-cities');
__('Enderbury', 'continents-cities');
__('Fakaofo', 'continents-cities');
__('Fiji', 'continents-cities');
__('Funafuti', 'continents-cities');
__('Galapagos', 'continents-cities');
__('Gambier', 'continents-cities');
__('Guadalcanal', 'continents-cities');
__('Guam', 'continents-cities');
__('Honolulu', 'continents-cities');
__('Johnston', 'continents-cities');
__('Kiritimati', 'continents-cities');
__('Kosrae', 'continents-cities');
__('Kwajalein', 'continents-cities');
__('Majuro', 'continents-cities');
__('Marquesas', 'continents-cities');
__('Midway', 'continents-cities');
__('Nauru', 'continents-cities');
__('Niue', 'continents-cities');
__('Norfolk', 'continents-cities');
__('Noumea', 'continents-cities');
__('Pago Pago', 'continents-cities');
__('Palau', 'continents-cities');
__('Pitcairn', 'continents-cities');
__('Ponape', 'continents-cities');
__('Port Moresby', 'continents-cities');
__('Rarotonga', 'continents-cities');
__('Saipan', 'continents-cities');
__('Samoa', 'continents-cities');
__('Tahiti', 'continents-cities');
__('Tarawa', 'continents-cities');
__('Tongatapu', 'continents-cities');
__('Truk', 'continents-cities');
__('Wake', 'continents-cities');
__('Wallis', 'continents-cities');
__('Yap', 'continents-cities');
| 01happy-blog | trunk/myblog/wp-admin/includes/continents-cities.php | PHP | oos | 17,877 |
<?php
/**
* WordPress Theme Install Administration API
*
* @package WordPress
* @subpackage Administration
*/
$themes_allowedtags = array('a' => array('href' => array(), 'title' => array(), 'target' => array()),
'abbr' => array('title' => array()), 'acronym' => array('title' => array()),
'code' => array(), 'pre' => array(), 'em' => array(), 'strong' => array(),
'div' => array(), 'p' => array(), 'ul' => array(), 'ol' => array(), 'li' => array(),
'h1' => array(), 'h2' => array(), 'h3' => array(), 'h4' => array(), 'h5' => array(), 'h6' => array(),
'img' => array('src' => array(), 'class' => array(), 'alt' => array())
);
$theme_field_defaults = array( 'description' => true, 'sections' => false, 'tested' => true, 'requires' => true,
'rating' => true, 'downloaded' => true, 'downloadlink' => true, 'last_updated' => true, 'homepage' => true,
'tags' => true, 'num_ratings' => true
);
/**
* Retrieve list of WordPress theme features (aka theme tags)
*
* @since 2.8.0
*
* @deprecated since 3.1.0 Use get_theme_feature_list() instead.
*
* @return array
*/
function install_themes_feature_list( ) {
if ( !$cache = get_transient( 'wporg_theme_feature_list' ) )
set_transient( 'wporg_theme_feature_list', array( ), 10800);
if ( $cache )
return $cache;
$feature_list = themes_api( 'feature_list', array( ) );
if ( is_wp_error( $feature_list ) )
return $features;
set_transient( 'wporg_theme_feature_list', $feature_list, 10800 );
return $feature_list;
}
/**
* Display search form for searching themes.
*
* @since 2.8.0
*/
function install_theme_search_form( $type_selector = true ) {
$type = isset( $_REQUEST['type'] ) ? stripslashes( $_REQUEST['type'] ) : 'term';
$term = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '';
if ( ! $type_selector )
echo '<p class="install-help">' . __( 'Search for themes by keyword.' ) . '</p>';
?>
<form id="search-themes" method="get" action="">
<input type="hidden" name="tab" value="search" />
<?php if ( $type_selector ) : ?>
<select name="type" id="typeselector">
<option value="term" <?php selected('term', $type) ?>><?php _e('Keyword'); ?></option>
<option value="author" <?php selected('author', $type) ?>><?php _e('Author'); ?></option>
<option value="tag" <?php selected('tag', $type) ?>><?php _ex('Tag', 'Theme Installer'); ?></option>
</select>
<?php endif; ?>
<input type="search" name="s" size="30" value="<?php echo esc_attr($term) ?>" />
<?php submit_button( __( 'Search' ), 'button', 'search', false ); ?>
</form>
<?php
}
/**
* Display tags filter for themes.
*
* @since 2.8.0
*/
function install_themes_dashboard() {
install_theme_search_form( false );
?>
<h4><?php _e('Feature Filter') ?></h4>
<p class="install-help"><?php _e( 'Find a theme based on specific features.' ); ?></p>
<form method="get" action="">
<input type="hidden" name="tab" value="search" />
<?php
$feature_list = get_theme_feature_list( );
echo '<div class="feature-filter">';
foreach ( (array) $feature_list as $feature_name => $features ) {
$feature_name = esc_html( $feature_name );
echo '<div class="feature-name">' . $feature_name . '</div>';
echo '<ol class="feature-group">';
foreach ( $features as $feature => $feature_name ) {
$feature_name = esc_html( $feature_name );
$feature = esc_attr($feature);
?>
<li>
<input type="checkbox" name="features[]" id="feature-id-<?php echo $feature; ?>" value="<?php echo $feature; ?>" />
<label for="feature-id-<?php echo $feature; ?>"><?php echo $feature_name; ?></label>
</li>
<?php } ?>
</ol>
<br class="clear" />
<?php
} ?>
</div>
<br class="clear" />
<?php submit_button( __( 'Find Themes' ), 'button', 'search' ); ?>
</form>
<?php
}
add_action('install_themes_dashboard', 'install_themes_dashboard');
function install_themes_upload($page = 1) {
?>
<h4><?php _e('Install a theme in .zip format') ?></h4>
<p class="install-help"><?php _e('If you have a theme in a .zip format, you may install it by uploading it here.') ?></p>
<form method="post" enctype="multipart/form-data" action="<?php echo self_admin_url('update.php?action=upload-theme') ?>">
<?php wp_nonce_field( 'theme-upload') ?>
<input type="file" name="themezip" />
<?php submit_button( __( 'Install Now' ), 'button', 'install-theme-submit', false ); ?>
</form>
<?php
}
add_action('install_themes_upload', 'install_themes_upload', 10, 1);
/**
* Prints a theme on the Install Themes pages.
*
* @deprecated 3.4.0
*/
function display_theme( $theme ) {
_deprecated_function( __FUNCTION__, '3.4' );
global $wp_list_table;
return $wp_list_table->single_row( $theme );
}
/**
* Display theme content based on theme list.
*
* @since 2.8.0
*/
function display_themes() {
global $wp_list_table;
$wp_list_table->display();
}
add_action('install_themes_search', 'display_themes');
add_action('install_themes_featured', 'display_themes');
add_action('install_themes_new', 'display_themes');
add_action('install_themes_updated', 'display_themes');
/**
* Display theme information in dialog box form.
*
* @since 2.8.0
*/
function install_theme_information() {
global $tab, $themes_allowedtags, $wp_list_table;
$theme = themes_api( 'theme_information', array( 'slug' => stripslashes( $_REQUEST['theme'] ) ) );
if ( is_wp_error( $theme ) )
wp_die( $theme );
iframe_header( __('Theme Install') );
$wp_list_table->theme_installer_single( $theme );
iframe_footer();
exit;
}
add_action('install_themes_pre_theme-information', 'install_theme_information');
| 01happy-blog | trunk/myblog/wp-admin/includes/theme-install.php | PHP | oos | 5,511 |
<?php
/**
* MS Themes List Table class.
*
* @package WordPress
* @subpackage List_Table
* @since 3.1.0
* @access private
*/
class WP_MS_Themes_List_Table extends WP_List_Table {
var $site_id;
var $is_site_themes;
function __construct() {
global $status, $page;
$status = isset( $_REQUEST['theme_status'] ) ? $_REQUEST['theme_status'] : 'all';
if ( !in_array( $status, array( 'all', 'enabled', 'disabled', 'upgrade', 'search', 'broken' ) ) )
$status = 'all';
$page = $this->get_pagenum();
$screen = get_current_screen();
$this->is_site_themes = ( 'site-themes-network' == $screen->id ) ? true : false;
if ( $this->is_site_themes )
$this->site_id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
parent::__construct( array(
'plural' => 'themes'
) );
}
function get_table_classes() {
return array( 'widefat', 'plugins' ); // todo: remove and add CSS for .themes
}
function ajax_user_can() {
$menu_perms = get_site_option( 'menu_items', array() );
if ( empty( $menu_perms['themes'] ) && ! is_super_admin() )
return false;
if ( $this->is_site_themes && !current_user_can('manage_sites') )
return false;
elseif ( !$this->is_site_themes && !current_user_can('manage_network_themes') )
return false;
return true;
}
function prepare_items() {
global $status, $totals, $page, $orderby, $order, $s;
wp_reset_vars( array( 'orderby', 'order', 's' ) );
$themes = 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 ) ),
);
if ( $this->is_site_themes ) {
$themes_per_page = $this->get_items_per_page( 'site_themes_network_per_page' );
$allowed_where = 'site';
} else {
$themes_per_page = $this->get_items_per_page( 'themes_network_per_page' );
$allowed_where = 'network';
}
$maybe_update = current_user_can( 'update_themes' ) && ! $this->is_site_themes && $current = get_site_transient( 'update_themes' );
foreach ( (array) $themes['all'] as $key => $theme ) {
if ( $this->is_site_themes && $theme->is_allowed( 'network' ) ) {
unset( $themes['all'][ $key ] );
continue;
}
if ( $maybe_update && isset( $current->response[ $key ] ) ) {
$themes['all'][ $key ]->update = true;
$themes['upgrade'][ $key ] = $themes['all'][ $key ];
}
$filter = $theme->is_allowed( $allowed_where, $this->site_id ) ? 'enabled' : 'disabled';
$themes[ $filter ][ $key ] = $themes['all'][ $key ];
}
if ( $s ) {
$status = 'search';
$themes['search'] = array_filter( array_merge( $themes['all'], $themes['broken'] ), array( &$this, '_search_callback' ) );
}
$totals = array();
foreach ( $themes as $type => $list )
$totals[ $type ] = count( $list );
if ( empty( $themes[ $status ] ) && !in_array( $status, array( 'all', 'search' ) ) )
$status = 'all';
$this->items = $themes[ $status ];
WP_Theme::sort_by_name( $this->items );
$this->has_items = ! empty( $themes['all'] );
$total_this_page = $totals[ $status ];
if ( $orderby ) {
$orderby = ucfirst( $orderby );
$order = strtoupper( $order );
if ( $orderby == 'Name' ) {
if ( 'ASC' == $order )
$this->items = array_reverse( $this->items );
} else {
uasort( $this->items, array( &$this, '_order_callback' ) );
}
}
$start = ( $page - 1 ) * $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,
) );
}
function _search_callback( $theme ) {
static $term;
if ( is_null( $term ) )
$term = stripslashes( $_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 ) )
return true;
}
if ( false !== stripos( $theme->get_stylesheet(), $term ) )
return true;
if ( false !== stripos( $theme->get_template(), $term ) )
return true;
return false;
}
// Not used by any core columns.
function _order_callback( $theme_a, $theme_b ) {
global $orderby, $order;
$a = $theme_a[ $orderby ];
$b = $theme_b[ $orderby ];
if ( $a == $b )
return 0;
if ( 'DESC' == $order )
return ( $a < $b ) ? 1 : -1;
else
return ( $a < $b ) ? -1 : 1;
}
function no_items() {
if ( ! $this->has_items )
_e( 'No themes found.' );
else
_e( 'You do not appear to have any themes available at this time.' );
}
function get_columns() {
global $status;
return array(
'cb' => '<input type="checkbox" />',
'name' => __( 'Theme' ),
'description' => __( 'Description' ),
);
}
function get_sortable_columns() {
return array(
'name' => 'name',
);
}
function get_views() {
global $totals, $status;
$status_links = array();
foreach ( $totals as $type => $count ) {
if ( !$count )
continue;
switch ( $type ) {
case 'all':
$text = _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $count, 'themes' );
break;
case 'enabled':
$text = _n( 'Enabled <span class="count">(%s)</span>', 'Enabled <span class="count">(%s)</span>', $count );
break;
case 'disabled':
$text = _n( 'Disabled <span class="count">(%s)</span>', 'Disabled <span class="count">(%s)</span>', $count );
break;
case 'upgrade':
$text = _n( 'Update Available <span class="count">(%s)</span>', 'Update Available <span class="count">(%s)</span>', $count );
break;
case 'broken' :
$text = _n( 'Broken <span class="count">(%s)</span>', 'Broken <span class="count">(%s)</span>', $count );
break;
}
if ( $this->is_site_themes )
$url = 'site-themes.php?id=' . $this->site_id;
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) ),
( $type == $status ) ? ' class="current"' : '',
sprintf( $text, number_format_i18n( $count ) )
);
}
}
return $status_links;
}
function get_bulk_actions() {
global $status;
$actions = array();
if ( 'enabled' != $status )
$actions['enable-selected'] = $this->is_site_themes ? __( 'Enable' ) : __( 'Network Enable' );
if ( 'disabled' != $status )
$actions['disable-selected'] = $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' );
if ( ! $this->is_site_themes ) {
if ( current_user_can( 'delete_themes' ) )
$actions['delete-selected'] = __( 'Delete' );
if ( current_user_can( 'update_themes' ) )
$actions['update-selected'] = __( 'Update' );
}
return $actions;
}
function bulk_actions( $which ) {
global $status;
parent::bulk_actions( $which );
}
function current_action() {
return parent::current_action();
}
function display_rows() {
foreach ( $this->items as $key => $theme )
$this->single_row( $key, $theme );
}
function single_row( $key, $theme ) {
global $status, $page, $s, $totals;
$context = $status;
if ( $this->is_site_themes ) {
$url = "site-themes.php?id={$this->site_id}&";
$allowed = $theme->is_allowed( 'site', $this->site_id );
} else {
$url = 'themes.php?';
$allowed = $theme->is_allowed( 'network' );
}
// preorder
$actions = array(
'enable' => '',
'disable' => '',
'edit' => '',
'delete' => ''
);
$theme_key = $theme->get_stylesheet();
if ( ! $allowed ) {
if ( ! $theme->errors() )
$actions['enable'] = '<a href="' . esc_url( wp_nonce_url($url . 'action=enable&theme=' . $theme_key . '&paged=' . $page . '&s=' . $s, 'enable-theme_' . $theme_key) ) . '" title="' . esc_attr__('Enable this theme') . '" class="edit">' . ( $this->is_site_themes ? __( 'Enable' ) : __( 'Network Enable' ) ) . '</a>';
} else {
$actions['disable'] = '<a href="' . esc_url( wp_nonce_url($url . 'action=disable&theme=' . $theme_key . '&paged=' . $page . '&s=' . $s, 'disable-theme_' . $theme_key) ) . '" title="' . esc_attr__('Disable this theme') . '">' . ( $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' ) ) . '</a>';
}
if ( current_user_can('edit_themes') )
$actions['edit'] = '<a href="' . esc_url('theme-editor.php?theme=' . $theme_key ) . '" title="' . esc_attr__('Open this theme in the Theme Editor') . '" class="edit">' . __('Edit') . '</a>';
if ( ! $allowed && current_user_can( 'delete_themes' ) && ! $this->is_site_themes && $theme_key != get_option( 'stylesheet' ) && $theme_key != get_option( 'template' ) )
$actions['delete'] = '<a href="' . esc_url( wp_nonce_url( 'themes.php?action=delete-selected&checked[]=' . $theme_key . '&theme_status=' . $context . '&paged=' . $page . '&s=' . $s, 'bulk-themes' ) ) . '" title="' . esc_attr__( 'Delete this theme' ) . '" class="delete">' . __( 'Delete' ) . '</a>';
$actions = apply_filters( 'theme_action_links', array_filter( $actions ), $theme_key, $theme, $context );
$actions = apply_filters( "theme_action_links_$theme_key", $actions, $theme_key, $theme, $context );
$class = ! $allowed ? 'inactive' : 'active';
$checkbox_id = "checkbox_" . md5( $theme->get('Name') );
$checkbox = "<input type='checkbox' name='checked[]' value='" . esc_attr( $theme_key ) . "' id='" . $checkbox_id . "' /><label class='screen-reader-text' for='" . $checkbox_id . "' >" . __('Select') . " " . $theme->display('Name') . "</label>";
$id = sanitize_html_class( $theme->get_stylesheet() );
if ( ! empty( $totals['upgrade'] ) && ! empty( $theme->update ) )
$class .= ' update';
echo "<tr id='$id' class='$class'>";
list( $columns, $hidden ) = $this->get_column_info();
foreach ( $columns as $column_name => $column_display_name ) {
$style = '';
if ( in_array( $column_name, $hidden ) )
$style = ' style="display:none;"';
switch ( $column_name ) {
case 'cb':
echo "<th scope='row' class='check-column'>$checkbox</th>";
break;
case 'name':
echo "<td class='theme-title'$style><strong>" . $theme->display('Name') . "</strong>";
echo $this->row_actions( $actions, true );
echo "</td>";
break;
case 'description':
echo "<td class='column-description desc'$style>";
if ( $theme->errors() ) {
$pre = $status == 'broken' ? '' : __( 'Broken Theme:' ) . ' ';
echo '<p><strong class="attention">' . $pre . $theme->errors()->get_error_message() . '</strong></p>';
}
echo "<div class='theme-description'><p>" . $theme->display( 'Description' ) . "</p></div>
<div class='$class second theme-version-author-uri'>";
$theme_meta = array();
if ( $theme->get('Version') )
$theme_meta[] = sprintf( __( 'Version %s' ), $theme->display('Version') );
$theme_meta[] = sprintf( __( 'By %s' ), $theme->display('Author') );
if ( $theme->get('ThemeURI') )
$theme_meta[] = '<a href="' . $theme->display('ThemeURI') . '" title="' . esc_attr__( 'Visit theme homepage' ) . '">' . __( 'Visit Theme Site' ) . '</a>';
$theme_meta = apply_filters( 'theme_row_meta', $theme_meta, $theme_key, $theme, $status );
echo implode( ' | ', $theme_meta );
echo "</div></td>";
break;
default:
echo "<td class='$column_name column-$column_name'$style>";
do_action( 'manage_themes_custom_column', $column_name, $theme_key, $theme );
echo "</td>";
}
}
echo "</tr>";
if ( $this->is_site_themes )
remove_action( "after_theme_row_$theme_key", 'wp_theme_update_row' );
do_action( 'after_theme_row', $theme_key, $theme, $status );
do_action( "after_theme_row_$theme_key", $theme_key, $theme, $status );
}
}
| 01happy-blog | trunk/myblog/wp-admin/includes/class-wp-ms-themes-list-table.php | PHP | oos | 11,954 |
<?php
/**
* Includes all of the WordPress Administration API files.
*
* @package WordPress
* @subpackage Administration
*/
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
// load_default_textdomain() will not have done so in this context.
load_textdomain( 'default', WP_LANG_DIR . '/admin-' . get_locale() . '.mo' );
}
/** WordPress Bookmark Administration API */
require_once(ABSPATH . 'wp-admin/includes/bookmark.php');
/** WordPress Comment Administration API */
require_once(ABSPATH . 'wp-admin/includes/comment.php');
/** WordPress Administration File API */
require_once(ABSPATH . 'wp-admin/includes/file.php');
/** WordPress Image Administration API */
require_once(ABSPATH . 'wp-admin/includes/image.php');
/** WordPress Media Administration API */
require_once(ABSPATH . 'wp-admin/includes/media.php');
/** WordPress Import Administration API */
require_once(ABSPATH . 'wp-admin/includes/import.php');
/** WordPress Misc Administration API */
require_once(ABSPATH . 'wp-admin/includes/misc.php');
/** WordPress Plugin Administration API */
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
/** WordPress Post Administration API */
require_once(ABSPATH . 'wp-admin/includes/post.php');
/** WordPress Administration Screen API */
require_once(ABSPATH . 'wp-admin/includes/screen.php');
/** WordPress Taxonomy Administration API */
require_once(ABSPATH . 'wp-admin/includes/taxonomy.php');
/** WordPress Template Administration API */
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/list-table.php');
/** WordPress Theme Administration API */
require_once(ABSPATH . 'wp-admin/includes/theme.php');
/** WordPress User Administration API */
require_once(ABSPATH . 'wp-admin/includes/user.php');
/** WordPress Update Administration API */
require_once(ABSPATH . 'wp-admin/includes/update.php');
/** WordPress Deprecated Administration API */
require_once(ABSPATH . 'wp-admin/includes/deprecated.php');
/** WordPress Multisite support API */
if ( is_multisite() ) {
require_once(ABSPATH . 'wp-admin/includes/ms.php');
require_once(ABSPATH . 'wp-admin/includes/ms-deprecated.php');
}
| 01happy-blog | trunk/myblog/wp-admin/includes/admin.php | PHP | oos | 2,443 |
<?php
/**
* WordPress Dashboard Widget Administration Screen API
*
* @package WordPress
* @subpackage Administration
*/
/**
* Registers dashboard widgets.
*
* Handles POST data, sets up filters.
*
* @since 2.5.0
*/
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();
$update = false;
$widget_options = get_option( 'dashboard_widget_options' );
if ( !$widget_options || !is_array($widget_options) )
$widget_options = array();
/* Register Widgets and Controls */
$response = wp_check_browser_version();
if ( $response && $response['upgrade'] ) {
add_filter( 'postbox_classes_dashboard_dashboard_browser_nag', 'dashboard_browser_nag_class' );
if ( $response['insecure'] )
wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'You are using an insecure browser!' ), 'wp_dashboard_browser_nag' );
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') )
wp_add_dashboard_widget( 'dashboard_right_now', __( 'Right Now' ), 'wp_dashboard_right_now' );
if ( is_network_admin() )
wp_add_dashboard_widget( 'network_dashboard_right_now', __( 'Right Now' ), 'wp_network_dashboard_right_now' );
// Recent Comments Widget
if ( is_blog_admin() && current_user_can('moderate_comments') ) {
if ( !isset( $widget_options['dashboard_recent_comments'] ) || !isset( $widget_options['dashboard_recent_comments']['items'] ) ) {
$update = true;
$widget_options['dashboard_recent_comments'] = array(
'items' => 5,
);
}
$recent_comments_title = __( 'Recent Comments' );
wp_add_dashboard_widget( 'dashboard_recent_comments', $recent_comments_title, 'wp_dashboard_recent_comments', 'wp_dashboard_recent_comments_control' );
}
// Incoming Links Widget
if ( is_blog_admin() && current_user_can('publish_posts') ) {
if ( !isset( $widget_options['dashboard_incoming_links'] ) || !isset( $widget_options['dashboard_incoming_links']['home'] ) || $widget_options['dashboard_incoming_links']['home'] != get_option('home') ) {
$update = true;
$num_items = isset($widget_options['dashboard_incoming_links']['items']) ? $widget_options['dashboard_incoming_links']['items'] : 10;
$widget_options['dashboard_incoming_links'] = array(
'home' => get_option('home'),
'link' => apply_filters( 'dashboard_incoming_links_link', 'http://blogsearch.google.com/blogsearch?scoring=d&partner=wordpress&q=link:' . trailingslashit( get_option('home') ) ),
'url' => isset($widget_options['dashboard_incoming_links']['url']) ? apply_filters( 'dashboard_incoming_links_feed', $widget_options['dashboard_incoming_links']['url'] ) : apply_filters( 'dashboard_incoming_links_feed', 'http://blogsearch.google.com/blogsearch_feeds?scoring=d&ie=utf-8&num=' . $num_items . '&output=rss&partner=wordpress&q=link:' . trailingslashit( get_option('home') ) ),
'items' => $num_items,
'show_date' => isset($widget_options['dashboard_incoming_links']['show_date']) ? $widget_options['dashboard_incoming_links']['show_date'] : false
);
}
wp_add_dashboard_widget( 'dashboard_incoming_links', __( 'Incoming Links' ), 'wp_dashboard_incoming_links', 'wp_dashboard_incoming_links_control' );
}
// WP Plugins Widget
if ( ( ! is_multisite() && is_blog_admin() && current_user_can( 'install_plugins' ) ) || ( is_network_admin() && current_user_can( 'manage_network_plugins' ) && current_user_can( 'install_plugins' ) ) )
wp_add_dashboard_widget( 'dashboard_plugins', __( 'Plugins' ), 'wp_dashboard_plugins' );
// QuickPress Widget
if ( is_blog_admin() && current_user_can('edit_posts') )
wp_add_dashboard_widget( 'dashboard_quick_press', __( 'QuickPress' ), 'wp_dashboard_quick_press' );
// Recent Drafts
if ( is_blog_admin() && current_user_can('edit_posts') )
wp_add_dashboard_widget( 'dashboard_recent_drafts', __('Recent Drafts'), 'wp_dashboard_recent_drafts' );
// Primary feed (Dev Blog) Widget
if ( !isset( $widget_options['dashboard_primary'] ) ) {
$update = true;
$widget_options['dashboard_primary'] = array(
'link' => apply_filters( 'dashboard_primary_link', __( 'http://wordpress.org/news/' ) ),
'url' => apply_filters( 'dashboard_primary_feed', __( 'http://wordpress.org/news/feed/' ) ),
'title' => apply_filters( 'dashboard_primary_title', __( 'WordPress Blog' ) ),
'items' => 2,
'show_summary' => 1,
'show_author' => 0,
'show_date' => 1,
);
}
wp_add_dashboard_widget( 'dashboard_primary', $widget_options['dashboard_primary']['title'], 'wp_dashboard_primary', 'wp_dashboard_primary_control' );
// Secondary Feed (Planet) Widget
if ( !isset( $widget_options['dashboard_secondary'] ) ) {
$update = true;
$widget_options['dashboard_secondary'] = array(
'link' => apply_filters( 'dashboard_secondary_link', __( 'http://planet.wordpress.org/' ) ),
'url' => apply_filters( 'dashboard_secondary_feed', __( 'http://planet.wordpress.org/feed/' ) ),
'title' => apply_filters( 'dashboard_secondary_title', __( 'Other WordPress News' ) ),
'items' => 5,
'show_summary' => 0,
'show_author' => 0,
'show_date' => 0,
);
}
wp_add_dashboard_widget( 'dashboard_secondary', $widget_options['dashboard_secondary']['title'], 'wp_dashboard_secondary', 'wp_dashboard_secondary_control' );
// Hook to register new widgets
// Filter widget order
if ( is_network_admin() ) {
do_action( 'wp_network_dashboard_setup' );
$dashboard_widgets = apply_filters( 'wp_network_dashboard_widgets', array() );
} elseif ( is_user_admin() ) {
do_action( 'wp_user_dashboard_setup' );
$dashboard_widgets = apply_filters( 'wp_user_dashboard_widgets', array() );
} else {
do_action( 'wp_dashboard_setup' );
$dashboard_widgets = apply_filters( 'wp_dashboard_widgets', array() );
}
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'] );
}
if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget_id']) ) {
ob_start(); // hack - but the same hack wp-admin/widgets.php uses
wp_dashboard_trigger_widget_control( $_POST['widget_id'] );
ob_end_clean();
wp_redirect( remove_query_arg( 'edit' ) );
exit;
}
if ( $update )
update_option( 'dashboard_widget_options', $widget_options );
do_action('do_meta_boxes', $screen->id, 'normal', '');
do_action('do_meta_boxes', $screen->id, 'side', '');
}
function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_callback = null ) {
$screen = get_current_screen();
global $wp_dashboard_control_callbacks;
if ( $control_callback && current_user_can( 'edit_dashboard' ) && is_callable( $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 );
$widget_name .= ' <span class="postbox-title-action"><a href="' . esc_url( $url ) . '">' . __( 'Cancel' ) . '</a></span>';
$callback = '_wp_dashboard_control_callback';
} else {
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>';
}
}
if ( is_blog_admin () )
$side_widgets = array('dashboard_quick_press', 'dashboard_recent_drafts', 'dashboard_primary', 'dashboard_secondary');
else if (is_network_admin() )
$side_widgets = array('dashboard_primary', 'dashboard_secondary');
else
$side_widgets = array();
$location = 'normal';
if ( in_array($widget_id, $side_widgets) )
$location = 'side';
$priority = 'core';
if ( 'dashboard_browser_nag' === $widget_id )
$priority = 'high';
add_meta_box( $widget_id, $widget_name, $callback, $screen, $location, $priority );
}
function _wp_dashboard_control_callback( $dashboard, $meta_box ) {
echo '<form action="" method="post" class="dashboard-widget-control-form">';
wp_dashboard_trigger_widget_control( $meta_box['id'] );
echo '<input type="hidden" name="widget_id" value="' . esc_attr($meta_box['id']) . '" />';
submit_button( __('Submit') );
echo '</form>';
}
/**
* Displays the dashboard.
*
* @since 2.5.0
*/
function wp_dashboard() {
$screen = get_current_screen();
$class = 'columns-' . get_current_screen()->get_columns();
?>
<div id="dashboard-widgets" class="metabox-holder <?php echo $class; ?>">
<div id='postbox-container-1' class='postbox-container'>
<?php do_meta_boxes( $screen->id, 'normal', '' ); ?>
</div>
<div id='postbox-container-2' class='postbox-container'>
<?php do_meta_boxes( $screen->id, 'side', '' ); ?>
</div>
<div id='postbox-container-3' class='postbox-container'>
<?php do_meta_boxes( $screen->id, 'column3', '' ); ?>
</div>
<div id='postbox-container-4' class='postbox-container'>
<?php do_meta_boxes( $screen->id, 'column4', '' ); ?>
</div>
</div>
<?php
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
}
/* Dashboard Widgets */
function wp_dashboard_right_now() {
global $wp_registered_sidebars;
$num_posts = wp_count_posts( 'post' );
$num_pages = wp_count_posts( 'page' );
$num_cats = wp_count_terms('category');
$num_tags = wp_count_terms('post_tag');
$num_comm = wp_count_comments( );
echo "\n\t".'<div class="table table_content">';
echo "\n\t".'<p class="sub">' . __('Content') . '</p>'."\n\t".'<table>';
echo "\n\t".'<tr class="first">';
// Posts
$num = number_format_i18n( $num_posts->publish );
$text = _n( 'Post', 'Posts', intval($num_posts->publish) );
if ( current_user_can( 'edit_posts' ) ) {
$num = "<a href='edit.php'>$num</a>";
$text = "<a href='edit.php'>$text</a>";
}
echo '<td class="first b b-posts">' . $num . '</td>';
echo '<td class="t posts">' . $text . '</td>';
echo '</tr><tr>';
/* TODO: Show status breakdown on hover
if ( $can_edit_pages && !empty($num_pages->publish) ) { // how many pages is not exposed in feeds. Don't show if !current_user_can
$post_type_texts[] = '<a href="edit-pages.php">'.sprintf( _n( '%s page', '%s pages', $num_pages->publish ), number_format_i18n( $num_pages->publish ) ).'</a>';
}
if ( $can_edit_posts && !empty($num_posts->draft) ) {
$post_type_texts[] = '<a href="edit.php?post_status=draft">'.sprintf( _n( '%s draft', '%s drafts', $num_posts->draft ), number_format_i18n( $num_posts->draft ) ).'</a>';
}
if ( $can_edit_posts && !empty($num_posts->future) ) {
$post_type_texts[] = '<a href="edit.php?post_status=future">'.sprintf( _n( '%s scheduled post', '%s scheduled posts', $num_posts->future ), number_format_i18n( $num_posts->future ) ).'</a>';
}
if ( current_user_can('publish_posts') && !empty($num_posts->pending) ) {
$pending_text = sprintf( _n( 'There is <a href="%1$s">%2$s post</a> pending your review.', 'There are <a href="%1$s">%2$s posts</a> pending your review.', $num_posts->pending ), 'edit.php?post_status=pending', number_format_i18n( $num_posts->pending ) );
} else {
$pending_text = '';
}
*/
// Pages
$num = number_format_i18n( $num_pages->publish );
$text = _n( 'Page', 'Pages', $num_pages->publish );
if ( current_user_can( 'edit_pages' ) ) {
$num = "<a href='edit.php?post_type=page'>$num</a>";
$text = "<a href='edit.php?post_type=page'>$text</a>";
}
echo '<td class="first b b_pages">' . $num . '</td>';
echo '<td class="t pages">' . $text . '</td>';
echo '</tr><tr>';
// Categories
$num = number_format_i18n( $num_cats );
$text = _n( 'Category', 'Categories', $num_cats );
if ( current_user_can( 'manage_categories' ) ) {
$num = "<a href='edit-tags.php?taxonomy=category'>$num</a>";
$text = "<a href='edit-tags.php?taxonomy=category'>$text</a>";
}
echo '<td class="first b b-cats">' . $num . '</td>';
echo '<td class="t cats">' . $text . '</td>';
echo '</tr><tr>';
// Tags
$num = number_format_i18n( $num_tags );
$text = _n( 'Tag', 'Tags', $num_tags );
if ( current_user_can( 'manage_categories' ) ) {
$num = "<a href='edit-tags.php'>$num</a>";
$text = "<a href='edit-tags.php'>$text</a>";
}
echo '<td class="first b b-tags">' . $num . '</td>';
echo '<td class="t tags">' . $text . '</td>';
echo "</tr>";
do_action('right_now_content_table_end');
echo "\n\t</table>\n\t</div>";
echo "\n\t".'<div class="table table_discussion">';
echo "\n\t".'<p class="sub">' . __('Discussion') . '</p>'."\n\t".'<table>';
echo "\n\t".'<tr class="first">';
// Total Comments
$num = '<span class="total-count">' . number_format_i18n($num_comm->total_comments) . '</span>';
$text = _n( 'Comment', 'Comments', $num_comm->total_comments );
if ( current_user_can( 'moderate_comments' ) ) {
$num = '<a href="edit-comments.php">' . $num . '</a>';
$text = '<a href="edit-comments.php">' . $text . '</a>';
}
echo '<td class="b b-comments">' . $num . '</td>';
echo '<td class="last t comments">' . $text . '</td>';
echo '</tr><tr>';
// Approved Comments
$num = '<span class="approved-count">' . number_format_i18n($num_comm->approved) . '</span>';
$text = _nx( 'Approved', 'Approved', $num_comm->approved, 'Right Now' );
if ( current_user_can( 'moderate_comments' ) ) {
$num = "<a href='edit-comments.php?comment_status=approved'>$num</a>";
$text = "<a class='approved' href='edit-comments.php?comment_status=approved'>$text</a>";
}
echo '<td class="b b_approved">' . $num . '</td>';
echo '<td class="last t">' . $text . '</td>';
echo "</tr>\n\t<tr>";
// Pending Comments
$num = '<span class="pending-count">' . number_format_i18n($num_comm->moderated) . '</span>';
$text = _n( 'Pending', 'Pending', $num_comm->moderated );
if ( current_user_can( 'moderate_comments' ) ) {
$num = "<a href='edit-comments.php?comment_status=moderated'>$num</a>";
$text = "<a class='waiting' href='edit-comments.php?comment_status=moderated'>$text</a>";
}
echo '<td class="b b-waiting">' . $num . '</td>';
echo '<td class="last t">' . $text . '</td>';
echo "</tr>\n\t<tr>";
// Spam Comments
$num = number_format_i18n($num_comm->spam);
$text = _nx( 'Spam', 'Spam', $num_comm->spam, 'comment' );
if ( current_user_can( 'moderate_comments' ) ) {
$num = "<a href='edit-comments.php?comment_status=spam'><span class='spam-count'>$num</span></a>";
$text = "<a class='spam' href='edit-comments.php?comment_status=spam'>$text</a>";
}
echo '<td class="b b-spam">' . $num . '</td>';
echo '<td class="last t">' . $text . '</td>';
echo "</tr>";
do_action('right_now_table_end');
do_action('right_now_discussion_table_end');
echo "\n\t</table>\n\t</div>";
echo "\n\t".'<div class="versions">';
$theme = wp_get_theme();
echo "\n\t<p>";
if ( $theme->errors() ) {
if ( ! is_multisite() || is_super_admin() )
echo '<span class="error-message">' . __('ERROR: The themes directory is either empty or doesn’t exist. Please check your installation.') . '</span>';
} elseif ( ! empty($wp_registered_sidebars) ) {
$sidebars_widgets = wp_get_sidebars_widgets();
$num_widgets = 0;
foreach ( (array) $sidebars_widgets as $k => $v ) {
if ( 'wp_inactive_widgets' == $k || 'orphaned_widgets' == substr( $k, 0, 16 ) )
continue;
if ( is_array($v) )
$num_widgets = $num_widgets + count($v);
}
$num = number_format_i18n( $num_widgets );
$switch_themes = $theme->display('Name');
if ( current_user_can( 'switch_themes') )
$switch_themes = '<a href="themes.php">' . $switch_themes . '</a>';
if ( current_user_can( 'edit_theme_options' ) ) {
printf(_n('Theme <span class="b">%1$s</span> with <span class="b"><a href="widgets.php">%2$s Widget</a></span>', 'Theme <span class="b">%1$s</span> with <span class="b"><a href="widgets.php">%2$s Widgets</a></span>', $num_widgets), $switch_themes, $num);
} else {
printf(_n('Theme <span class="b">%1$s</span> with <span class="b">%2$s Widget</span>', 'Theme <span class="b">%1$s</span> with <span class="b">%2$s Widgets</span>', $num_widgets), $switch_themes, $num);
}
} else {
if ( current_user_can( 'switch_themes' ) )
printf( __('Theme <span class="b"><a href="themes.php">%1$s</a></span>'), $theme->display('Name') );
else
printf( __('Theme <span class="b">%1$s</span>'), $theme->display('Name') );
}
echo '</p>';
// Check if search engines are blocked.
if ( !is_network_admin() && !is_user_admin() && current_user_can('manage_options') && '1' != get_option('blog_public') ) {
$title = apply_filters('privacy_on_link_title', __('Your site is asking search engines not to index its content') );
$content = apply_filters('privacy_on_link_text', __('Search Engines Blocked') );
echo "<p><a href='options-privacy.php' title='$title'>$content</a></p>";
}
update_right_now_message();
echo "\n\t".'<br class="clear" /></div>';
do_action( 'rightnow_end' );
do_action( 'activity_box_end' );
}
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>';
$c_users = get_user_count();
$c_blogs = get_blog_count();
$user_text = sprintf( _n( '%s user', '%s users', $c_users ), number_format_i18n( $c_users ) );
$blog_text = sprintf( _n( '%s site', '%s sites', $c_blogs ), number_format_i18n( $c_blogs ) );
$sentence = sprintf( __( 'You have %1$s and %2$s.' ), $blog_text, $user_text );
if ( $actions ) {
echo '<ul class="subsubsub">';
foreach ( $actions as $class => $action ) {
$actions[ $class ] = "\t<li class='$class'>$action";
}
echo implode( " |</li>\n", $actions ) . "</li>\n";
echo '</ul>';
}
?>
<br class="clear" />
<p class="youhave"><?php echo $sentence; ?></p>
<?php do_action( 'wpmuadminresult', '' ); ?>
<form action="<?php echo network_admin_url('users.php'); ?>" method="get">
<p>
<input type="search" name="s" value="" size="30" autocomplete="off" />
<?php submit_button( __( 'Search Users' ), 'button', 'submit', false, array( 'id' => 'submit_users' ) ); ?>
</p>
</form>
<form action="<?php echo network_admin_url('sites.php'); ?>" method="get">
<p>
<input type="search" name="s" value="" size="30" autocomplete="off" />
<?php submit_button( __( 'Search Sites' ), 'button', 'submit', false, array( 'id' => 'submit_sites' ) ); ?>
</p>
</form>
<?php
do_action( 'mu_rightnow_end' );
do_action( 'mu_activity_box_end' );
}
function wp_dashboard_quick_press() {
global $post_ID;
$drafts = false;
if ( 'post' === strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['action'] ) && 0 === strpos( $_POST['action'], 'post-quickpress' ) && (int) $_POST['post_ID'] ) {
$view = get_permalink( $_POST['post_ID'] );
$edit = esc_url( get_edit_post_link( $_POST['post_ID'] ) );
if ( 'post-quickpress-publish' == $_POST['action'] ) {
if ( current_user_can('publish_posts') )
printf( '<div class="updated"><p>' . __( 'Post published. <a href="%s">View post</a> | <a href="%s">Edit post</a>' ) . '</p></div>', esc_url( $view ), $edit );
else
printf( '<div class="updated"><p>' . __( 'Post submitted. <a href="%s">Preview post</a> | <a href="%s">Edit post</a>' ) . '</p></div>', esc_url( add_query_arg( 'preview', 1, $view ) ), $edit );
} else {
printf( '<div class="updated"><p>' . __( 'Draft saved. <a href="%s">Preview post</a> | <a href="%s">Edit post</a>' ) . '</p></div>', esc_url( add_query_arg( 'preview', 1, $view ) ), $edit );
$drafts_query = new WP_Query( array(
'post_type' => 'post',
'post_status' => 'draft',
'author' => $GLOBALS['current_user']->ID,
'posts_per_page' => 1,
'orderby' => 'modified',
'order' => 'DESC'
) );
if ( $drafts_query->posts )
$drafts =& $drafts_query->posts;
}
printf('<p class="textright">' . __('You can also try %s, easy blogging from anywhere on the Web.') . '</p>', '<a href="' . esc_url( admin_url( 'tools.php' ) ) . '">' . __('Press This') . '</a>' );
$_REQUEST = array(); // hack for get_default_post_to_edit()
}
/* Check if a new auto-draft (= no new post_ID) is needed or if the old can be used */
$last_post_id = (int) get_user_option( 'dashboard_quick_press_last_post_id' ); // Get the last post_ID
if ( $last_post_id ) {
$post = get_post( $last_post_id );
if ( empty( $post ) || $post->post_status != 'auto-draft' ) { // auto-draft doesn't exists anymore
$post = get_default_post_to_edit('post', true);
update_user_option( (int) $GLOBALS['current_user']->ID, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID
} else {
$post->post_title = ''; // Remove the auto draft title
}
} else {
$post = get_default_post_to_edit('post', true);
update_user_option( (int) $GLOBALS['current_user']->ID, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID
}
$post_ID = (int) $post->ID;
?>
<form name="post" action="<?php echo esc_url( admin_url( 'post.php' ) ); ?>" method="post" id="quick-press">
<h4 id="quick-post-title"><label for="title"><?php _e('Title') ?></label></h4>
<div class="input-text-wrap">
<input type="text" name="post_title" id="title" tabindex="1" autocomplete="off" value="<?php echo esc_attr( $post->post_title ); ?>" />
</div>
<?php if ( current_user_can( 'upload_files' ) ) : ?>
<div id="wp-content-wrap" class="wp-editor-wrap hide-if-no-js wp-media-buttons">
<?php do_action( 'media_buttons', 'content' ); ?>
</div>
<?php endif; ?>
<h4 id="content-label"><label for="content"><?php _e('Content') ?></label></h4>
<div class="textarea-wrap">
<textarea name="content" id="content" class="mceEditor" rows="3" cols="15" tabindex="2"><?php echo esc_textarea( $post->post_content ); ?></textarea>
</div>
<script type="text/javascript">edCanvas = document.getElementById('content');edInsertContent = null;</script>
<h4><label for="tags-input"><?php _e('Tags') ?></label></h4>
<div class="input-text-wrap">
<input type="text" name="tags_input" id="tags-input" tabindex="3" value="<?php echo get_tags_to_edit( $post->ID ); ?>" />
</div>
<p class="submit">
<input type="hidden" name="action" id="quickpost-action" value="post-quickpress-save" />
<input type="hidden" name="post_ID" value="<?php echo $post_ID; ?>" />
<input type="hidden" name="post_type" value="post" />
<?php wp_nonce_field('add-post'); ?>
<?php submit_button( __( 'Save Draft' ), 'button', 'save', false, array( 'id' => 'save-post', 'tabindex'=> 4 ) ); ?>
<input type="reset" value="<?php esc_attr_e( 'Reset' ); ?>" class="button" />
<span id="publishing-action">
<input type="submit" name="publish" id="publish" accesskey="p" tabindex="5" class="button-primary" value="<?php current_user_can('publish_posts') ? esc_attr_e('Publish') : esc_attr_e('Submit for Review'); ?>" />
<img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
</span>
<br class="clear" />
</p>
</form>
<?php
if ( $drafts )
wp_dashboard_recent_drafts( $drafts );
}
function wp_dashboard_recent_drafts( $drafts = false ) {
if ( !$drafts ) {
$drafts_query = new WP_Query( array(
'post_type' => 'post',
'post_status' => 'draft',
'author' => $GLOBALS['current_user']->ID,
'posts_per_page' => 5,
'orderby' => 'modified',
'order' => 'DESC'
) );
$drafts =& $drafts_query->posts;
}
if ( $drafts && is_array( $drafts ) ) {
$list = array();
foreach ( $drafts as $draft ) {
$url = get_edit_post_link( $draft->ID );
$title = _draft_or_post_title( $draft->ID );
$item = "<h4><a href='$url' title='" . sprintf( __( 'Edit “%s”' ), esc_attr( $title ) ) . "'>" . esc_html($title) . "</a> <abbr title='" . get_the_time(__('Y/m/d g:i:s A'), $draft) . "'>" . get_the_time( get_option( 'date_format' ), $draft ) . '</abbr></h4>';
if ( $the_content = preg_split( '#\s#', strip_tags( $draft->post_content ), 11, PREG_SPLIT_NO_EMPTY ) )
$item .= '<p>' . join( ' ', array_slice( $the_content, 0, 10 ) ) . ( 10 < count( $the_content ) ? '…' : '' ) . '</p>';
$list[] = $item;
}
?>
<ul>
<li><?php echo join( "</li>\n<li>", $list ); ?></li>
</ul>
<p class="textright"><a href="edit.php?post_status=draft" ><?php _e('View all'); ?></a></p>
<?php
} else {
_e('There are no drafts at the moment');
}
}
/**
* Display recent comments dashboard widget content.
*
* @since 2.5.0
*/
function wp_dashboard_recent_comments() {
global $wpdb;
// Select all comment types and filter out spam later for better query performance.
$comments = array();
$start = 0;
$widgets = get_option( 'dashboard_widget_options' );
$total_items = isset( $widgets['dashboard_recent_comments'] ) && isset( $widgets['dashboard_recent_comments']['items'] )
? absint( $widgets['dashboard_recent_comments']['items'] ) : 5;
$comments_query = array( 'number' => $total_items * 5, 'offset' => 0 );
if ( ! current_user_can( 'edit_posts' ) )
$comments_query['status'] = 'approve';
while ( count( $comments ) < $total_items && $possible = get_comments( $comments_query ) ) {
foreach ( $possible as $comment ) {
if ( ! current_user_can( 'read_post', $comment->comment_post_ID ) )
continue;
$comments[] = $comment;
if ( count( $comments ) == $total_items )
break 2;
}
$comments_query['offset'] += $comments_query['number'];
$comments_query['number'] = $total_items * 10;
}
if ( $comments ) {
echo '<div id="the-comment-list" class="list:comment">';
foreach ( $comments as $comment )
_wp_dashboard_recent_comments_row( $comment );
echo '</div>';
if ( current_user_can('edit_posts') )
_get_list_table('WP_Comments_List_Table')->views();
wp_comment_reply( -1, false, 'dashboard', false );
wp_comment_trashnotice();
} else {
echo '<p>' . __( 'No comments yet.' ) . '</p>';
}
}
function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
$GLOBALS['comment'] =& $comment;
$comment_post_url = get_edit_post_link( $comment->comment_post_ID );
$comment_post_title = strip_tags(get_the_title( $comment->comment_post_ID ));
$comment_post_link = "<a href='$comment_post_url'>$comment_post_title</a>";
$comment_link = '<a class="comment-link" href="' . esc_url(get_comment_link()) . '">#</a>';
$actions_string = '';
if ( current_user_can( 'edit_comment', $comment->comment_ID ) ) {
// preorder it: Approve | Reply | Edit | Spam | Trash
$actions = array(
'approve' => '', 'unapprove' => '',
'reply' => '',
'edit' => '',
'spam' => '',
'trash' => '', 'delete' => ''
);
$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" );
$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" );
$actions['approve'] = "<a href='$approve_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved vim-a' title='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
$actions['unapprove'] = "<a href='$unapprove_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved vim-u' title='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
$actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' title='" . esc_attr__('Edit comment') . "'>". __('Edit') . '</a>';
$actions['reply'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$comment->comment_post_ID.'\');return false;" class="vim-r hide-if-no-js" title="'.esc_attr__('Reply to this comment').'" href="#">' . __('Reply') . '</a>';
$actions['spam'] = "<a href='$spam_url' class='delete:the-comment-list:comment-$comment->comment_ID::spam=1 vim-s vim-destructive' title='" . 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' class='delete:the-comment-list:comment-$comment->comment_ID::trash=1 delete vim-d vim-destructive'>" . __('Delete Permanently') . '</a>';
else
$actions['trash'] = "<a href='$trash_url' class='delete:the-comment-list:comment-$comment->comment_ID::trash=1 delete vim-d vim-destructive' title='" . esc_attr__( 'Move this comment to the trash' ) . "'>" . _x('Trash', 'verb') . '</a>';
$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 = ' | ';
// Reply and quickedit need a hide-if-no-js span
if ( 'reply' == $action || 'quickedit' == $action )
$action .= ' hide-if-no-js';
$actions_string .= "<span class='$action'>$sep$link</span>";
}
}
?>
<div id="comment-<?php echo $comment->comment_ID; ?>" <?php comment_class( array( 'comment-item', wp_get_comment_status($comment->comment_ID) ) ); ?>>
<?php if ( !$comment->comment_type || 'comment' == $comment->comment_type ) : ?>
<?php echo get_avatar( $comment, 50 ); ?>
<div class="dashboard-comment-wrap">
<h4 class="comment-meta">
<?php 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() . '</cite>', $comment_post_link.' '.$comment_link, ' <span class="approve">' . __( '[Pending]' ) . '</span>' ); ?>
</h4>
<?php
else :
switch ( $comment->comment_type ) :
case 'pingback' :
$type = __( 'Pingback' );
break;
case 'trackback' :
$type = __( 'Trackback' );
break;
default :
$type = ucwords( $comment->comment_type );
endswitch;
$type = esc_html( $type );
?>
<div class="dashboard-comment-wrap">
<?php /* translators: %1$s is type of comment, %2$s is link to the post */ ?>
<h4 class="comment-meta"><?php printf( _x( '%1$s on %2$s', 'dashboard' ), "<strong>$type</strong>", $comment_post_link." ".$comment_link ); ?></h4>
<p class="comment-author"><?php comment_author_link(); ?></p>
<?php endif; // comment_type ?>
<blockquote><p><?php comment_excerpt(); ?></p></blockquote>
<p class="row-actions"><?php echo $actions_string; ?></p>
</div>
</div>
<?php
}
/**
* The recent comments dashboard widget control.
*
* @since 3.0.0
*/
function wp_dashboard_recent_comments_control() {
if ( !$widget_options = get_option( 'dashboard_widget_options' ) )
$widget_options = array();
if ( !isset($widget_options['dashboard_recent_comments']) )
$widget_options['dashboard_recent_comments'] = array();
if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget-recent-comments']) ) {
$number = absint( $_POST['widget-recent-comments']['items'] );
$widget_options['dashboard_recent_comments']['items'] = $number;
update_option( 'dashboard_widget_options', $widget_options );
}
$number = isset( $widget_options['dashboard_recent_comments']['items'] ) ? (int) $widget_options['dashboard_recent_comments']['items'] : '';
echo '<p><label for="comments-number">' . __('Number of comments to show:') . '</label>';
echo '<input id="comments-number" name="widget-recent-comments[items]" type="text" value="' . $number . '" size="3" /></p>';
}
function wp_dashboard_incoming_links() {
wp_dashboard_cached_rss_widget( 'dashboard_incoming_links', 'wp_dashboard_incoming_links_output' );
}
/**
* Display incoming links dashboard widget content.
*
* @since 2.5.0
*/
function wp_dashboard_incoming_links_output() {
$widgets = get_option( 'dashboard_widget_options' );
@extract( @$widgets['dashboard_incoming_links'], EXTR_SKIP );
$rss = fetch_feed( $url );
if ( is_wp_error($rss) ) {
if ( is_admin() || current_user_can('manage_options') ) {
echo '<p>';
printf(__('<strong>RSS Error</strong>: %s'), $rss->get_error_message());
echo '</p>';
}
return;
}
if ( !$rss->get_item_quantity() ) {
echo '<p>' . __('This dashboard widget queries <a href="http://blogsearch.google.com/">Google Blog Search</a> so that when another blog links to your site it will show up here. It has found no incoming links… yet. It’s okay — there is no rush.') . "</p>\n";
$rss->__destruct();
unset($rss);
return;
}
echo "<ul>\n";
if ( !isset($items) )
$items = 10;
foreach ( $rss->get_items(0, $items) as $item ) {
$publisher = '';
$site_link = '';
$link = '';
$content = '';
$date = '';
$link = esc_url( strip_tags( $item->get_link() ) );
$author = $item->get_author();
if ( $author ) {
$site_link = esc_url( strip_tags( $author->get_link() ) );
if ( !$publisher = esc_html( strip_tags( $author->get_name() ) ) )
$publisher = __( 'Somebody' );
} else {
$publisher = __( 'Somebody' );
}
if ( $site_link )
$publisher = "<a href='$site_link'>$publisher</a>";
else
$publisher = "<strong>$publisher</strong>";
$content = $item->get_content();
$content = wp_html_excerpt($content, 50) . ' ...';
if ( $link )
/* translators: incoming links feed, %1$s is other person, %3$s is content */
$text = __( '%1$s linked here <a href="%2$s">saying</a>, "%3$s"' );
else
/* translators: incoming links feed, %1$s is other person, %3$s is content */
$text = __( '%1$s linked here saying, "%3$s"' );
if ( !empty($show_date) ) {
if ( !empty($show_author) || !empty($show_summary) )
/* translators: incoming links feed, %4$s is the date */
$text .= ' ' . __( 'on %4$s' );
$date = esc_html( strip_tags( $item->get_date() ) );
$date = strtotime( $date );
$date = gmdate( get_option( 'date_format' ), $date );
}
echo "\t<li>" . sprintf( $text, $publisher, $link, $content, $date ) . "</li>\n";
}
echo "</ul>\n";
$rss->__destruct();
unset($rss);
}
function wp_dashboard_incoming_links_control() {
wp_dashboard_rss_control( 'dashboard_incoming_links', array( 'title' => false, 'show_summary' => false, 'show_author' => false ) );
}
function wp_dashboard_primary() {
wp_dashboard_cached_rss_widget( 'dashboard_primary', 'wp_dashboard_rss_output' );
}
function wp_dashboard_primary_control() {
wp_dashboard_rss_control( 'dashboard_primary' );
}
/**
* {@internal Missing Short Description}}
*
* @since 2.5.0
*
* @param string $widget_id
*/
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>";
}
function wp_dashboard_secondary() {
wp_dashboard_cached_rss_widget( 'dashboard_secondary', 'wp_dashboard_secondary_output' );
}
function wp_dashboard_secondary_control() {
wp_dashboard_rss_control( 'dashboard_secondary' );
}
/**
* Display secondary dashboard RSS widget feed.
*
* @since 2.5.0
*
* @return unknown
*/
function wp_dashboard_secondary_output() {
$widgets = get_option( 'dashboard_widget_options' );
@extract( @$widgets['dashboard_secondary'], EXTR_SKIP );
$rss = @fetch_feed( $url );
if ( is_wp_error($rss) ) {
if ( is_admin() || current_user_can('manage_options') ) {
echo '<div class="rss-widget"><p>';
printf(__('<strong>RSS Error</strong>: %s'), $rss->get_error_message());
echo '</p></div>';
}
} elseif ( !$rss->get_item_quantity() ) {
$rss->__destruct();
unset($rss);
return false;
} else {
echo '<div class="rss-widget">';
wp_widget_rss_output( $rss, $widgets['dashboard_secondary'] );
echo '</div>';
$rss->__destruct();
unset($rss);
}
}
function wp_dashboard_plugins() {
wp_dashboard_cached_rss_widget( 'dashboard_plugins', 'wp_dashboard_plugins_output', array(
'http://wordpress.org/extend/plugins/rss/browse/popular/',
'http://wordpress.org/extend/plugins/rss/browse/new/'
) );
}
/**
* Display plugins most popular, newest plugins, and recently updated widget text.
*
* @since 2.5.0
*/
function wp_dashboard_plugins_output() {
$popular = fetch_feed( 'http://wordpress.org/extend/plugins/rss/browse/popular/' );
$new = fetch_feed( 'http://wordpress.org/extend/plugins/rss/browse/new/' );
if ( false === $plugin_slugs = get_transient( 'plugin_slugs' ) ) {
$plugin_slugs = array_keys( get_plugins() );
set_transient( 'plugin_slugs', $plugin_slugs, 86400 );
}
foreach ( array( 'popular' => __('Most Popular'), 'new' => __('Newest Plugins') ) as $feed => $label ) {
if ( is_wp_error($$feed) || !$$feed->get_item_quantity() )
continue;
$items = $$feed->get_items(0, 5);
// Pick a random, non-installed plugin
while ( true ) {
// Abort this foreach loop iteration if there's no plugins left of this type
if ( 0 == count($items) )
continue 2;
$item_key = array_rand($items);
$item = $items[$item_key];
list($link, $frag) = explode( '#', $item->get_link() );
$link = esc_url($link);
if ( preg_match( '|/([^/]+?)/?$|', $link, $matches ) )
$slug = $matches[1];
else {
unset( $items[$item_key] );
continue;
}
// Is this random plugin's slug already installed? If so, try again.
reset( $plugin_slugs );
foreach ( $plugin_slugs as $plugin_slug ) {
if ( $slug == substr( $plugin_slug, 0, strlen( $slug ) ) ) {
unset( $items[$item_key] );
continue 2;
}
}
// If we get to this point, then the random plugin isn't installed and we can stop the while().
break;
}
// Eliminate some common badly formed plugin descriptions
while ( ( null !== $item_key = array_rand($items) ) && false !== strpos( $items[$item_key]->get_description(), 'Plugin Name:' ) )
unset($items[$item_key]);
if ( !isset($items[$item_key]) )
continue;
// current bbPress feed item titles are: user on "topic title"
if ( preg_match( '/"(.*)"/s', $item->get_title(), $matches ) )
$title = $matches[1];
else // but let's make it forward compatible if things change
$title = $item->get_title();
$title = esc_html( $title );
$description = esc_html( strip_tags(@html_entity_decode($item->get_description(), ENT_QUOTES, get_option('blog_charset'))) );
$ilink = wp_nonce_url('plugin-install.php?tab=plugin-information&plugin=' . $slug, 'install-plugin_' . $slug) .
'&TB_iframe=true&width=600&height=800';
echo "<h4>$label</h4>\n";
echo "<h5><a href='$link'>$title</a></h5> <span>(<a href='$ilink' class='thickbox' title='$title'>" . __( 'Install' ) . "</a>)</span>\n";
echo "<p>$description</p>\n";
$$feed->__destruct();
unset($$feed);
}
}
/**
* Checks to see if all of the feed url in $check_urls are cached.
*
* If $check_urls is empty, look for the rss feed url found in the dashboard
* widget options of $widget_id. If cached, call $callback, a function that
* echoes out output for this widget. If not cache, echo a "Loading..." stub
* which is later replaced by AJAX call (see top of /wp-admin/index.php)
*
* @since 2.5.0
*
* @param string $widget_id
* @param callback $callback
* @param array $check_urls RSS feeds
* @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><p class="hide-if-js">' . __( 'This widget requires JavaScript.' ) . '</p>';
$doing_ajax = ( defined('DOING_AJAX') && DOING_AJAX );
if ( empty($check_urls) ) {
$widgets = get_option( 'dashboard_widget_options' );
if ( empty($widgets[$widget_id]['url']) && ! $doing_ajax ) {
echo $loading;
return false;
}
$check_urls = array( $widgets[$widget_id]['url'] );
}
$cache_key = 'dash_' . md5( $widget_id );
if ( false !== ( $output = get_transient( $cache_key ) ) ) {
echo $output;
return true;
}
if ( ! $doing_ajax ) {
echo $loading;
return false;
}
if ( $callback && is_callable( $callback ) ) {
$args = array_slice( func_get_args(), 2 );
array_unshift( $args, $widget_id );
ob_start();
call_user_func_array( $callback, $args );
set_transient( $cache_key, ob_get_flush(), 43200); // Default lifetime in cache of 12 hours (same as the feeds)
}
return true;
}
/* Dashboard Widgets Controls */
// Calls widget_control callback
/**
* Calls widget control callback.
*
* @since 2.5.0
*
* @param int $widget_control_id Registered Widget ID.
*/
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] ) );
}
}
/**
* The RSS dashboard widget control.
*
* Sets up $args to be used as input to wp_widget_rss_form(). Handles POST data
* from RSS-type widgets.
*
* @since 2.5.0
*
* @param string $widget_id
* @param array $form_inputs
*/
function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) {
if ( !$widget_options = get_option( 'dashboard_widget_options' ) )
$widget_options = 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;
if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget-rss'][$number]) ) {
$_POST['widget-rss'][$number] = stripslashes_deep( $_POST['widget-rss'][$number] );
$widget_options[$widget_id] = wp_widget_rss_process( $_POST['widget-rss'][$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'));
} else {
$widget_options[$widget_id]['title'] = htmlentities(strip_tags($rss->get_title()));
$rss->__destruct();
unset($rss);
}
}
update_option( 'dashboard_widget_options', $widget_options );
$cache_key = 'dash_' . md5( $widget_id );
delete_transient( $cache_key );
}
wp_widget_rss_form( $widget_options[$widget_id], $form_inputs );
}
// Display File upload quota on dashboard
function wp_dashboard_quota() {
if ( !is_multisite() || !current_user_can('upload_files') || get_site_option( 'upload_space_check_disabled' ) )
return true;
$quota = get_space_allowed();
$used = get_dirsize( BLOGUPLOADDIR ) / 1024 / 1024;
if ( $used > $quota )
$percentused = '100';
else
$percentused = ( $used / $quota ) * 100;
$used_color = ( $percentused >= 70 ) ? ' spam' : '';
$used = round( $used, 2 );
$percentused = number_format( $percentused );
?>
<p class="sub musub"><?php _e( 'Storage Space' ); ?></p>
<div class="table table_content musubtable">
<table>
<tr class="first">
<td class="first b b-posts"><?php printf( __( '<a href="%1$s" title="Manage Uploads" class="musublink">%2$sMB</a>' ), esc_url( admin_url( 'upload.php' ) ), $quota ); ?></td>
<td class="t posts"><?php _e( 'Space Allowed' ); ?></td>
</tr>
</table>
</div>
<div class="table table_discussion musubtable">
<table>
<tr class="first">
<td class="b b-comments"><?php printf( __( '<a href="%1$s" title="Manage Uploads" class="musublink">%2$sMB (%3$s%%)</a>' ), esc_url( admin_url( 'upload.php' ) ), $used, $percentused ); ?></td>
<td class="last t comments<?php echo $used_color;?>"><?php _e( 'Space Used' );?></td>
</tr>
</table>
</div>
<br class="clear" />
<?php
}
add_action( 'activity_box_end', 'wp_dashboard_quota' );
// Display Browser Nag Meta Box
function wp_dashboard_browser_nag() {
$notice = '';
$response = wp_check_browser_version();
if ( $response ) {
if ( $response['insecure'] ) {
$msg = sprintf( __( "It looks like you're using an insecure version of <a href='%s'>%s</a>. Using an outdated browser makes your computer unsafe. For the best WordPress experience, please update your browser." ), esc_attr( $response['update_url'] ), esc_html( $response['name'] ) );
} else {
$msg = sprintf( __( "It looks like you're using an old version of <a href='%s'>%s</a>. For the best WordPress experience, please update your browser." ), esc_attr( $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'];
$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 = 'http://browsehappy.com/';
$locale = get_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">' . __( 'Dismiss' ) . '</a></p>';
$notice .= '<div class="clear"></div>';
}
echo apply_filters( 'browse-happy-notice', $notice, $response );
}
function dashboard_browser_nag_class( $classes ) {
$response = wp_check_browser_version();
if ( $response && $response['insecure'] )
$classes[] = 'browser-insecure';
return $classes;
}
/**
* Check if the user needs a browser update
*
* @since 3.2.0
*
* @return array|bool False on failure, array of browser data on success.
*/
function wp_check_browser_version() {
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) )
return false;
$key = md5( $_SERVER['HTTP_USER_AGENT'] );
if ( false === ($response = get_site_transient('browser_' . $key) ) ) {
global $wp_version;
$options = array(
'body' => array( 'useragent' => $_SERVER['HTTP_USER_AGENT'] ),
'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url()
);
$response = wp_remote_post( 'http://api.wordpress.org/core/browse-happy/1.0/', $options );
if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) )
return false;
/**
* Response should be an array with:
* 'name' - string - A user friendly browser name
* 'version' - string - The most recent version of the browser
* 'current_version' - string - The version of the browser the user is using
* 'upgrade' - boolean - Whether the browser needs an upgrade
* 'insecure' - boolean - Whether the browser is deemed insecure
* 'upgrade_url' - string - The url to visit to upgrade
* 'img_src' - string - An image representing the browser
* 'img_src_ssl' - string - An image (over SSL) representing the browser
*/
$response = maybe_unserialize( wp_remote_retrieve_body( $response ) );
if ( ! is_array( $response ) )
return false;
set_site_transient( 'browser_' . $key, $response, 604800 ); // cache for 1 week
}
return $response;
}
/**
* Empty function usable by plugins to output empty dashboard widget (to be populated later by JS).
*/
function wp_dashboard_empty() {}
/**
* Displays a welcome panel to introduce users to WordPress.
*
* @since 3.3.0
*/
function wp_welcome_panel() {
global $wp_version;
if ( ! current_user_can( 'edit_theme_options' ) )
return;
$classes = 'welcome-panel';
$option = get_user_meta( get_current_user_id(), 'show_welcome_panel', true );
// 0 = hide, 1 = toggled to show or single site creator, 2 = multisite site owner
$hide = 0 == $option || ( 2 == $option && wp_get_current_user()->user_email != get_option( 'admin_email' ) );
if ( $hide )
$classes .= ' hidden';
list( $display_version ) = explode( '-', $wp_version );
?>
<div id="welcome-panel" class="<?php echo esc_attr( $classes ); ?>">
<?php wp_nonce_field( 'welcome-panel-nonce', 'welcomepanelnonce', false ); ?>
<a class="welcome-panel-close" href="<?php echo esc_url( admin_url( '?welcome=0' ) ); ?>"><?php _e('Dismiss'); ?></a>
<div class="wp-badge"><?php printf( __( 'Version %s' ), $display_version ); ?></div>
<div class="welcome-panel-content">
<h3><?php _e( 'Welcome to your new WordPress site!' ); ?></h3>
<p class="about-description"><?php _e( 'If you need help getting started, check out our documentation on <a href="http://codex.wordpress.org/First_Steps_With_WordPress">First Steps with WordPress</a>. If you’d rather dive right in, here are a few things most people do first when they set up a new WordPress site. If you need help, use the Help tabs in the upper right corner to get information on how to use your current screen and where to go for more assistance.' ); ?></p>
<div class="welcome-panel-column-container">
<div class="welcome-panel-column">
<h4><span class="icon16 icon-settings"></span> <?php _e( 'Basic Settings' ); ?></h4>
<p><?php _e( 'Here are a few easy things you can do to get your feet wet. Make sure to click Save on each Settings screen.' ); ?></p>
<ul>
<li><?php echo sprintf( __( '<a href="%s">Choose your privacy setting</a>' ), esc_url( admin_url('options-privacy.php') ) ); ?></li>
<li><?php echo sprintf( __( '<a href="%s">Select your tagline and time zone</a>' ), esc_url( admin_url('options-general.php') ) ); ?></li>
<li><?php echo sprintf( __( '<a href="%s">Turn comments on or off</a>' ), esc_url( admin_url('options-discussion.php') ) ); ?></li>
<li><?php echo sprintf( __( '<a href="%s">Fill in your profile</a>' ), esc_url( admin_url('profile.php') ) ); ?></li>
</ul>
</div>
<div class="welcome-panel-column">
<h4><span class="icon16 icon-page"></span> <?php _e( 'Add Real Content' ); ?></h4>
<p><?php _e( 'Check out the sample page & post editors to see how it all works, then delete the default content and write your own!' ); ?></p>
<ul>
<li><?php echo sprintf( __( 'View the <a href="%1$s">sample page</a> and <a href="%2$s">post</a>' ), esc_url( get_permalink( 2 ) ), esc_url( get_permalink( 1 ) ) ); ?></li>
<li><?php echo sprintf( __( 'Delete the <a href="%1$s">sample page</a> and <a href="%2$s">post</a>' ), esc_url( admin_url('edit.php?post_type=page') ), esc_url( admin_url('edit.php') ) ); ?></li>
<li><?php echo sprintf( __( '<a href="%s">Create an About Me page</a>' ), esc_url( admin_url('edit.php?post_type=page') ) ); ?></li>
<li><?php echo sprintf( __( '<a href="%s">Write your first post</a>' ), esc_url( admin_url('post-new.php') ) ); ?></li>
</ul>
</div>
<div class="welcome-panel-column welcome-panel-last">
<h4><span class="icon16 icon-appearance"></span> <?php _e( 'Customize Your Site' ); ?></h4>
<?php
$theme = wp_get_theme();
if ( $theme->errors() ) :
echo '<p>';
printf( __( '<a href="%s">Install a theme</a> to get started customizing your site.' ), esc_url( admin_url( 'themes.php' ) ) );
echo '</p>';
else:
$customize_links = array();
if ( 'twentyeleven' == $theme->get_stylesheet() )
$customize_links[] = sprintf( __( '<a href="%s">Choose light or dark</a>' ), esc_url( admin_url( 'themes.php?page=theme_options' ) ) );
if ( current_theme_supports( 'custom-background' ) )
$customize_links[] = sprintf( __( '<a href="%s">Set a background color</a>' ), esc_url( admin_url( 'themes.php?page=custom-background' ) ) );
if ( current_theme_supports( 'custom-header' ) )
$customize_links[] = sprintf( __( '<a href="%s">Select a new header image</a>' ), esc_url( admin_url( 'themes.php?page=custom-header' ) ) );
if ( current_theme_supports( 'widgets' ) )
$customize_links[] = sprintf( __( '<a href="%s">Add some widgets</a>' ), esc_url( admin_url( 'widgets.php' ) ) );
if ( ! empty( $customize_links ) ) {
echo '<p>';
printf( __( 'Use the current theme — %1$s — or <a href="%2$s">choose a new one</a>. If you stick with %1$s, here are a few ways to make your site look unique.' ), $theme->display('Name'), esc_url( admin_url( 'themes.php' ) ) );
echo '</p>';
?>
<ul>
<?php foreach ( $customize_links as $customize_link ) : ?>
<li><?php echo $customize_link ?></li>
<?php endforeach; ?>
</ul>
<?php
} else {
echo '<p>';
printf( __( 'Use the current theme — %1$s — or <a href="%2$s">choose a new one</a>.' ), $theme->display('Name'), esc_url( admin_url( 'themes.php' ) ) );
echo '</p>';
}
endif; ?>
</div>
</div>
<p class="welcome-panel-dismiss"><?php printf( __( 'Already know what you’re doing? <a href="%s">Dismiss this message</a>.' ), esc_url( admin_url( '?welcome=0' ) ) ); ?></p>
</div>
</div>
<?php
}
| 01happy-blog | trunk/myblog/wp-admin/includes/dashboard.php | PHP | oos | 54,282 |
<?php
/**
* PemFTP - A Ftp implementation in pure PHP
*
* @package PemFTP
* @since 2.5
*
* @version 1.0
* @copyright Alexey Dotsenko
* @author Alexey Dotsenko
* @link http://www.phpclasses.org/browse/package/1743.html Site
* @license LGPL License http://www.opensource.org/licenses/lgpl-license.html
*/
/**
* Defines the newline characters, if not defined already.
*
* This can be redefined.
*
* @since 2.5
* @var string
*/
if(!defined('CRLF')) define('CRLF',"\r\n");
/**
* Sets whatever to autodetect ASCII mode.
*
* This can be redefined.
*
* @since 2.5
* @var int
*/
if(!defined("FTP_AUTOASCII")) define("FTP_AUTOASCII", -1);
/**
*
* This can be redefined.
* @since 2.5
* @var int
*/
if(!defined("FTP_BINARY")) define("FTP_BINARY", 1);
/**
*
* This can be redefined.
* @since 2.5
* @var int
*/
if(!defined("FTP_ASCII")) define("FTP_ASCII", 0);
/**
* Whether to force FTP.
*
* This can be redefined.
*
* @since 2.5
* @var bool
*/
if(!defined('FTP_FORCE')) define('FTP_FORCE', true);
/**
* @since 2.5
* @var string
*/
define('FTP_OS_Unix','u');
/**
* @since 2.5
* @var string
*/
define('FTP_OS_Windows','w');
/**
* @since 2.5
* @var string
*/
define('FTP_OS_Mac','m');
/**
* PemFTP base class
*
*/
class ftp_base {
/* Public variables */
var $LocalEcho;
var $Verbose;
var $OS_local;
var $OS_remote;
/* Private variables */
var $_lastaction;
var $_errors;
var $_type;
var $_umask;
var $_timeout;
var $_passive;
var $_host;
var $_fullhost;
var $_port;
var $_datahost;
var $_dataport;
var $_ftp_control_sock;
var $_ftp_data_sock;
var $_ftp_temp_sock;
var $_ftp_buff_size;
var $_login;
var $_password;
var $_connected;
var $_ready;
var $_code;
var $_message;
var $_can_restore;
var $_port_available;
var $_curtype;
var $_features;
var $_error_array;
var $AuthorizedTransferMode;
var $OS_FullName;
var $_eol_code;
var $AutoAsciiExt;
/* Constructor */
function ftp_base($port_mode=FALSE) {
$this->__construct($port_mode);
}
function __construct($port_mode=FALSE, $verb=FALSE, $le=FALSE) {
$this->LocalEcho=$le;
$this->Verbose=$verb;
$this->_lastaction=NULL;
$this->_error_array=array();
$this->_eol_code=array(FTP_OS_Unix=>"\n", FTP_OS_Mac=>"\r", FTP_OS_Windows=>"\r\n");
$this->AuthorizedTransferMode=array(FTP_AUTOASCII, FTP_ASCII, FTP_BINARY);
$this->OS_FullName=array(FTP_OS_Unix => 'UNIX', FTP_OS_Windows => 'WINDOWS', FTP_OS_Mac => 'MACOS');
$this->AutoAsciiExt=array("ASP","BAT","C","CPP","CSS","CSV","JS","H","HTM","HTML","SHTML","INI","LOG","PHP3","PHTML","PL","PERL","SH","SQL","TXT");
$this->_port_available=($port_mode==TRUE);
$this->SendMSG("Staring FTP client class".($this->_port_available?"":" without PORT mode support"));
$this->_connected=FALSE;
$this->_ready=FALSE;
$this->_can_restore=FALSE;
$this->_code=0;
$this->_message="";
$this->_ftp_buff_size=4096;
$this->_curtype=NULL;
$this->SetUmask(0022);
$this->SetType(FTP_AUTOASCII);
$this->SetTimeout(30);
$this->Passive(!$this->_port_available);
$this->_login="anonymous";
$this->_password="anon@ftp.com";
$this->_features=array();
$this->OS_local=FTP_OS_Unix;
$this->OS_remote=FTP_OS_Unix;
$this->features=array();
if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') $this->OS_local=FTP_OS_Windows;
elseif(strtoupper(substr(PHP_OS, 0, 3)) === 'MAC') $this->OS_local=FTP_OS_Mac;
}
// <!-- --------------------------------------------------------------------------------------- -->
// <!-- Public functions -->
// <!-- --------------------------------------------------------------------------------------- -->
function parselisting($line) {
$is_windows = ($this->OS_remote == FTP_OS_Windows);
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 { $lucifer[3]+=1900; } // 4digit year fix
$b['isdir'] = ($lucifer[7]=="<DIR>");
if ( $b['isdir'] )
$b['type'] = 'd';
else
$b['type'] = 'f';
$b['size'] = $lucifer[7];
$b['month'] = $lucifer[1];
$b['day'] = $lucifer[2];
$b['year'] = $lucifer[3];
$b['hour'] = $lucifer[4];
$b['minute'] = $lucifer[5];
$b['time'] = @mktime($lucifer[4]+(strcasecmp($lucifer[6],"PM")==0?12:0),$lucifer[5],0,$lucifer[1],$lucifer[2],$lucifer[3]);
$b['am/pm'] = $lucifer[6];
$b['name'] = $lucifer[8];
} else if (!$is_windows && $lucifer=preg_split("/[ ]/",$line,9,PREG_SPLIT_NO_EMPTY)) {
//echo $line."\n";
$lcount=count($lucifer);
if ($lcount<8) return '';
$b = array();
$b['isdir'] = $lucifer[0]{0} === "d";
$b['islink'] = $lucifer[0]{0} === "l";
if ( $b['isdir'] )
$b['type'] = 'd';
elseif ( $b['islink'] )
$b['type'] = 'l';
else
$b['type'] = 'f';
$b['perms'] = $lucifer[0];
$b['number'] = $lucifer[1];
$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']);
$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['minute'] = $l2[2];
} else {
$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['name'] = $lucifer[8];
}
}
return $b;
}
function SendMSG($message = "", $crlf=true) {
if ($this->Verbose) {
echo $message.($crlf?CRLF:"");
flush();
}
return TRUE;
}
function SetType($mode=FTP_AUTOASCII) {
if(!in_array($mode, $this->AuthorizedTransferMode)) {
$this->SendMSG("Wrong type");
return FALSE;
}
$this->_type=$mode;
$this->SendMSG("Transfer type: ".($this->_type==FTP_BINARY?"binary":($this->_type==FTP_ASCII?"ASCII":"auto ASCII") ) );
return TRUE;
}
function _settype($mode=FTP_ASCII) {
if($this->_ready) {
if($mode==FTP_BINARY) {
if($this->_curtype!=FTP_BINARY) {
if(!$this->_exec("TYPE I", "SetType")) return FALSE;
$this->_curtype=FTP_BINARY;
}
} elseif($this->_curtype!=FTP_ASCII) {
if(!$this->_exec("TYPE A", "SetType")) return FALSE;
$this->_curtype=FTP_ASCII;
}
} else return FALSE;
return TRUE;
}
function Passive($pasv=NULL) {
if(is_null($pasv)) $this->_passive=!$this->_passive;
else $this->_passive=$pasv;
if(!$this->_port_available and !$this->_passive) {
$this->SendMSG("Only passive connections available!");
$this->_passive=TRUE;
return FALSE;
}
$this->SendMSG("Passive mode ".($this->_passive?"on":"off"));
return TRUE;
}
function SetServer($host, $port=21, $reconnect=true) {
if(!is_long($port)) {
$this->verbose=true;
$this->SendMSG("Incorrect port syntax");
return FALSE;
} else {
$ip=@gethostbyname($host);
$dns=@gethostbyaddr($host);
if(!$ip) $ip=$host;
if(!$dns) $dns=$host;
// Validate the IPAddress PHP4 returns -1 for invalid, PHP5 false
// -1 === "255.255.255.255" which is the broadcast address which is also going to be invalid
$ipaslong = ip2long($ip);
if ( ($ipaslong == false) || ($ipaslong === -1) ) {
$this->SendMSG("Wrong host name/address \"".$host."\"");
return FALSE;
}
$this->_host=$ip;
$this->_fullhost=$dns;
$this->_port=$port;
$this->_dataport=$port-1;
}
$this->SendMSG("Host \"".$this->_fullhost."(".$this->_host."):".$this->_port."\"");
if($reconnect){
if($this->_connected) {
$this->SendMSG("Reconnecting");
if(!$this->quit(FTP_FORCE)) return FALSE;
if(!$this->connect()) return FALSE;
}
}
return TRUE;
}
function SetUmask($umask=0022) {
$this->_umask=$umask;
umask($this->_umask);
$this->SendMSG("UMASK 0".decoct($this->_umask));
return TRUE;
}
function SetTimeout($timeout=30) {
$this->_timeout=$timeout;
$this->SendMSG("Timeout ".$this->_timeout);
if($this->_connected)
if(!$this->_settimeout($this->_ftp_control_sock)) return FALSE;
return TRUE;
}
function connect($server=NULL) {
if(!empty($server)) {
if(!$this->SetServer($server)) return false;
}
if($this->_ready) return true;
$this->SendMsg('Local OS : '.$this->OS_FullName[$this->OS_local]);
if(!($this->_ftp_control_sock = $this->_connect($this->_host, $this->_port))) {
$this->SendMSG("Error : Cannot connect to remote host \"".$this->_fullhost." :".$this->_port."\"");
return FALSE;
}
$this->SendMSG("Connected to remote host \"".$this->_fullhost.":".$this->_port."\". Waiting for greeting.");
do {
if(!$this->_readmsg()) return FALSE;
if(!$this->_checkCode()) return FALSE;
$this->_lastaction=time();
} while($this->_code<200);
$this->_ready=true;
$syst=$this->systype();
if(!$syst) $this->SendMSG("Can't detect remote OS");
else {
if(preg_match("/win|dos|novell/i", $syst[0])) $this->OS_remote=FTP_OS_Windows;
elseif(preg_match("/os/i", $syst[0])) $this->OS_remote=FTP_OS_Mac;
elseif(preg_match("/(li|u)nix/i", $syst[0])) $this->OS_remote=FTP_OS_Unix;
else $this->OS_remote=FTP_OS_Mac;
$this->SendMSG("Remote OS: ".$this->OS_FullName[$this->OS_remote]);
}
if(!$this->features()) $this->SendMSG("Can't get features list. All supported - disabled");
else $this->SendMSG("Supported features: ".implode(", ", array_keys($this->_features)));
return TRUE;
}
function quit($force=false) {
if($this->_ready) {
if(!$this->_exec("QUIT") and !$force) return FALSE;
if(!$this->_checkCode() and !$force) return FALSE;
$this->_ready=false;
$this->SendMSG("Session finished");
}
$this->_quit();
return TRUE;
}
function login($user=NULL, $pass=NULL) {
if(!is_null($user)) $this->_login=$user;
else $this->_login="anonymous";
if(!is_null($pass)) $this->_password=$pass;
else $this->_password="anon@anon.com";
if(!$this->_exec("USER ".$this->_login, "login")) return FALSE;
if(!$this->_checkCode()) return FALSE;
if($this->_code!=230) {
if(!$this->_exec((($this->_code==331)?"PASS ":"ACCT ").$this->_password, "login")) return FALSE;
if(!$this->_checkCode()) return FALSE;
}
$this->SendMSG("Authentication succeeded");
if(empty($this->_features)) {
if(!$this->features()) $this->SendMSG("Can't get features list. All supported - disabled");
else $this->SendMSG("Supported features: ".implode(", ", array_keys($this->_features)));
}
return TRUE;
}
function pwd() {
if(!$this->_exec("PWD", "pwd")) return FALSE;
if(!$this->_checkCode()) return FALSE;
return ereg_replace("^[0-9]{3} \"(.+)\".+", "\\1", $this->_message);
}
function cdup() {
if(!$this->_exec("CDUP", "cdup")) return FALSE;
if(!$this->_checkCode()) return FALSE;
return true;
}
function chdir($pathname) {
if(!$this->_exec("CWD ".$pathname, "chdir")) return FALSE;
if(!$this->_checkCode()) return FALSE;
return TRUE;
}
function rmdir($pathname) {
if(!$this->_exec("RMD ".$pathname, "rmdir")) return FALSE;
if(!$this->_checkCode()) return FALSE;
return TRUE;
}
function mkdir($pathname) {
if(!$this->_exec("MKD ".$pathname, "mkdir")) return FALSE;
if(!$this->_checkCode()) return FALSE;
return TRUE;
}
function rename($from, $to) {
if(!$this->_exec("RNFR ".$from, "rename")) return FALSE;
if(!$this->_checkCode()) return FALSE;
if($this->_code==350) {
if(!$this->_exec("RNTO ".$to, "rename")) return FALSE;
if(!$this->_checkCode()) return FALSE;
} else return FALSE;
return TRUE;
}
function filesize($pathname) {
if(!isset($this->_features["SIZE"])) {
$this->PushError("filesize", "not supported by server");
return FALSE;
}
if(!$this->_exec("SIZE ".$pathname, "filesize")) return FALSE;
if(!$this->_checkCode()) return FALSE;
return ereg_replace("^[0-9]{3} ([0-9]+)".CRLF, "\\1", $this->_message);
}
function abort() {
if(!$this->_exec("ABOR", "abort")) return FALSE;
if(!$this->_checkCode()) {
if($this->_code!=426) return FALSE;
if(!$this->_readmsg("abort")) return FALSE;
if(!$this->_checkCode()) return FALSE;
}
return true;
}
function mdtm($pathname) {
if(!isset($this->_features["MDTM"])) {
$this->PushError("mdtm", "not supported by server");
return FALSE;
}
if(!$this->_exec("MDTM ".$pathname, "mdtm")) return FALSE;
if(!$this->_checkCode()) return FALSE;
$mdtm = ereg_replace("^[0-9]{3} ([0-9]+)".CRLF, "\\1", $this->_message);
$date = sscanf($mdtm, "%4d%2d%2d%2d%2d%2d");
$timestamp = mktime($date[3], $date[4], $date[5], $date[1], $date[2], $date[0]);
return $timestamp;
}
function systype() {
if(!$this->_exec("SYST", "systype")) return FALSE;
if(!$this->_checkCode()) return FALSE;
$DATA = explode(" ", $this->_message);
return array($DATA[1], $DATA[3]);
}
function delete($pathname) {
if(!$this->_exec("DELE ".$pathname, "delete")) return FALSE;
if(!$this->_checkCode()) return FALSE;
return TRUE;
}
function site($command, $fnction="site") {
if(!$this->_exec("SITE ".$command, $fnction)) return FALSE;
if(!$this->_checkCode()) return FALSE;
return TRUE;
}
function chmod($pathname, $mode) {
if(!$this->site( sprintf('CHMOD %o %s', $mode, $pathname), "chmod")) return FALSE;
return TRUE;
}
function restore($from) {
if(!isset($this->_features["REST"])) {
$this->PushError("restore", "not supported by server");
return FALSE;
}
if($this->_curtype!=FTP_BINARY) {
$this->PushError("restore", "can't restore in ASCII mode");
return FALSE;
}
if(!$this->_exec("REST ".$from, "resore")) return FALSE;
if(!$this->_checkCode()) return FALSE;
return TRUE;
}
function features() {
if(!$this->_exec("FEAT", "features")) return FALSE;
if(!$this->_checkCode()) return FALSE;
$f=preg_split("/[".CRLF."]+/", preg_replace("/[0-9]{3}[ -].*[".CRLF."]+/", "", $this->_message), -1, PREG_SPLIT_NO_EMPTY);
$this->_features=array();
foreach($f as $k=>$v) {
$v=explode(" ", trim($v));
$this->_features[array_shift($v)]=$v;
}
return true;
}
function rawlist($pathname="", $arg="") {
return $this->_list(($arg?" ".$arg:"").($pathname?" ".$pathname:""), "LIST", "rawlist");
}
function nlist($pathname="") {
return $this->_list(($arg?" ".$arg:"").($pathname?" ".$pathname:""), "NLST", "nlist");
}
function is_exists($pathname) {
return $this->file_exists($pathname);
}
function file_exists($pathname) {
$exists=true;
if(!$this->_exec("RNFR ".$pathname, "rename")) $exists=FALSE;
else {
if(!$this->_checkCode()) $exists=FALSE;
$this->abort();
}
if($exists) $this->SendMSG("Remote file ".$pathname." exists");
else $this->SendMSG("Remote file ".$pathname." does not exist");
return $exists;
}
function fget($fp, $remotefile,$rest=0) {
if($this->_can_restore and $rest!=0) fseek($fp, $rest);
$pi=pathinfo($remotefile);
if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode=FTP_ASCII;
else $mode=FTP_BINARY;
if(!$this->_data_prepare($mode)) {
return FALSE;
}
if($this->_can_restore and $rest!=0) $this->restore($rest);
if(!$this->_exec("RETR ".$remotefile, "get")) {
$this->_data_close();
return FALSE;
}
if(!$this->_checkCode()) {
$this->_data_close();
return FALSE;
}
$out=$this->_data_read($mode, $fp);
$this->_data_close();
if(!$this->_readmsg()) return FALSE;
if(!$this->_checkCode()) return FALSE;
return $out;
}
function get($remotefile, $localfile=NULL, $rest=0) {
if(is_null($localfile)) $localfile=$remotefile;
if (@file_exists($localfile)) $this->SendMSG("Warning : local file will be overwritten");
$fp = @fopen($localfile, "w");
if (!$fp) {
$this->PushError("get","can't open local file", "Cannot create \"".$localfile."\"");
return FALSE;
}
if($this->_can_restore and $rest!=0) fseek($fp, $rest);
$pi=pathinfo($remotefile);
if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode=FTP_ASCII;
else $mode=FTP_BINARY;
if(!$this->_data_prepare($mode)) {
fclose($fp);
return FALSE;
}
if($this->_can_restore and $rest!=0) $this->restore($rest);
if(!$this->_exec("RETR ".$remotefile, "get")) {
$this->_data_close();
fclose($fp);
return FALSE;
}
if(!$this->_checkCode()) {
$this->_data_close();
fclose($fp);
return FALSE;
}
$out=$this->_data_read($mode, $fp);
fclose($fp);
$this->_data_close();
if(!$this->_readmsg()) return FALSE;
if(!$this->_checkCode()) return FALSE;
return $out;
}
function fput($remotefile, $fp) {
if($this->_can_restore and $rest!=0) fseek($fp, $rest);
$pi=pathinfo($remotefile);
if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode=FTP_ASCII;
else $mode=FTP_BINARY;
if(!$this->_data_prepare($mode)) {
return FALSE;
}
if($this->_can_restore and $rest!=0) $this->restore($rest);
if(!$this->_exec("STOR ".$remotefile, "put")) {
$this->_data_close();
return FALSE;
}
if(!$this->_checkCode()) {
$this->_data_close();
return FALSE;
}
$ret=$this->_data_write($mode, $fp);
$this->_data_close();
if(!$this->_readmsg()) return FALSE;
if(!$this->_checkCode()) return FALSE;
return $ret;
}
function put($localfile, $remotefile=NULL, $rest=0) {
if(is_null($remotefile)) $remotefile=$localfile;
if (!file_exists($localfile)) {
$this->PushError("put","can't open local file", "No such file or directory \"".$localfile."\"");
return FALSE;
}
$fp = @fopen($localfile, "r");
if (!$fp) {
$this->PushError("put","can't open local file", "Cannot read file \"".$localfile."\"");
return FALSE;
}
if($this->_can_restore and $rest!=0) fseek($fp, $rest);
$pi=pathinfo($localfile);
if($this->_type==FTP_ASCII or ($this->_type==FTP_AUTOASCII and in_array(strtoupper($pi["extension"]), $this->AutoAsciiExt))) $mode=FTP_ASCII;
else $mode=FTP_BINARY;
if(!$this->_data_prepare($mode)) {
fclose($fp);
return FALSE;
}
if($this->_can_restore and $rest!=0) $this->restore($rest);
if(!$this->_exec("STOR ".$remotefile, "put")) {
$this->_data_close();
fclose($fp);
return FALSE;
}
if(!$this->_checkCode()) {
$this->_data_close();
fclose($fp);
return FALSE;
}
$ret=$this->_data_write($mode, $fp);
fclose($fp);
$this->_data_close();
if(!$this->_readmsg()) return FALSE;
if(!$this->_checkCode()) return FALSE;
return $ret;
}
function mput($local=".", $remote=NULL, $continious=false) {
$local=realpath($local);
if(!@file_exists($local)) {
$this->PushError("mput","can't open local folder", "Cannot stat folder \"".$local."\"");
return FALSE;
}
if(!is_dir($local)) return $this->put($local, $remote);
if(empty($remote)) $remote=".";
elseif(!$this->file_exists($remote) and !$this->mkdir($remote)) return FALSE;
if($handle = opendir($local)) {
$list=array();
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") $list[]=$file;
}
closedir($handle);
} else {
$this->PushError("mput","can't open local folder", "Cannot read folder \"".$local."\"");
return FALSE;
}
if(empty($list)) return TRUE;
$ret=true;
foreach($list as $el) {
if(is_dir($local."/".$el)) $t=$this->mput($local."/".$el, $remote."/".$el);
else $t=$this->put($local."/".$el, $remote."/".$el);
if(!$t) {
$ret=FALSE;
if(!$continious) break;
}
}
return $ret;
}
function mget($remote, $local=".", $continious=false) {
$list=$this->rawlist($remote, "-lA");
if($list===false) {
$this->PushError("mget","can't read remote folder list", "Can't read remote folder \"".$remote."\" contents");
return FALSE;
}
if(empty($list)) return true;
if(!@file_exists($local)) {
if(!@mkdir($local)) {
$this->PushError("mget","can't create local folder", "Cannot create folder \"".$local."\"");
return FALSE;
}
}
foreach($list as $k=>$v) {
$list[$k]=$this->parselisting($v);
if($list[$k]["name"]=="." or $list[$k]["name"]=="..") unset($list[$k]);
}
$ret=true;
foreach($list as $el) {
if($el["type"]=="d") {
if(!$this->mget($remote."/".$el["name"], $local."/".$el["name"], $continious)) {
$this->PushError("mget", "can't copy folder", "Can't copy remote folder \"".$remote."/".$el["name"]."\" to local \"".$local."/".$el["name"]."\"");
$ret=false;
if(!$continious) break;
}
} else {
if(!$this->get($remote."/".$el["name"], $local."/".$el["name"])) {
$this->PushError("mget", "can't copy file", "Can't copy remote file \"".$remote."/".$el["name"]."\" to local \"".$local."/".$el["name"]."\"");
$ret=false;
if(!$continious) break;
}
}
@chmod($local."/".$el["name"], $el["perms"]);
$t=strtotime($el["date"]);
if($t!==-1 and $t!==false) @touch($local."/".$el["name"], $t);
}
return $ret;
}
function mdel($remote, $continious=false) {
$list=$this->rawlist($remote, "-la");
if($list===false) {
$this->PushError("mdel","can't read remote folder list", "Can't read remote folder \"".$remote."\" contents");
return false;
}
foreach($list as $k=>$v) {
$list[$k]=$this->parselisting($v);
if($list[$k]["name"]=="." or $list[$k]["name"]=="..") unset($list[$k]);
}
$ret=true;
foreach($list as $el) {
if ( empty($el) )
continue;
if($el["type"]=="d") {
if(!$this->mdel($remote."/".$el["name"], $continious)) {
$ret=false;
if(!$continious) break;
}
} else {
if (!$this->delete($remote."/".$el["name"])) {
$this->PushError("mdel", "can't delete file", "Can't delete remote file \"".$remote."/".$el["name"]."\"");
$ret=false;
if(!$continious) break;
}
}
}
if(!$this->rmdir($remote)) {
$this->PushError("mdel", "can't delete folder", "Can't delete remote folder \"".$remote."/".$el["name"]."\"");
$ret=false;
}
return $ret;
}
function mmkdir($dir, $mode = 0777) {
if(empty($dir)) return FALSE;
if($this->is_exists($dir) or $dir == "/" ) return TRUE;
if(!$this->mmkdir(dirname($dir), $mode)) return false;
$r=$this->mkdir($dir, $mode);
$this->chmod($dir,$mode);
return $r;
}
function glob($pattern, $handle=NULL) {
$path=$output=null;
if(PHP_OS=='WIN32') $slash='\\';
else $slash='/';
$lastpos=strrpos($pattern,$slash);
if(!($lastpos===false)) {
$path=substr($pattern,0,-$lastpos-1);
$pattern=substr($pattern,$lastpos);
} else $path=getcwd();
if(is_array($handle) and !empty($handle)) {
while($dir=each($handle)) {
if($this->glob_pattern_match($pattern,$dir))
$output[]=$dir;
}
} else {
$handle=@opendir($path);
if($handle===false) return false;
while($dir=readdir($handle)) {
if($this->glob_pattern_match($pattern,$dir))
$output[]=$dir;
}
closedir($handle);
}
if(is_array($output)) return $output;
return false;
}
function glob_pattern_match($pattern,$string) {
$out=null;
$chunks=explode(';',$pattern);
foreach($chunks as $pattern) {
$escape=array('$','^','.','{','}','(',')','[',']','|');
while(strpos($pattern,'**')!==false)
$pattern=str_replace('**','*',$pattern);
foreach($escape as $probe)
$pattern=str_replace($probe,"\\$probe",$pattern);
$pattern=str_replace('?*','*',
str_replace('*?','*',
str_replace('*',".*",
str_replace('?','.{1,1}',$pattern))));
$out[]=$pattern;
}
if(count($out)==1) return($this->glob_regexp("^$out[0]$",$string));
else {
foreach($out as $tester)
if($this->my_regexp("^$tester$",$string)) return true;
}
return false;
}
function glob_regexp($pattern,$probe) {
$sensitive=(PHP_OS!='WIN32');
return ($sensitive?
ereg($pattern,$probe):
eregi($pattern,$probe)
);
}
function dirlist($remote) {
$list=$this->rawlist($remote, "-la");
if($list===false) {
$this->PushError("dirlist","can't read remote folder list", "Can't read remote folder \"".$remote."\" contents");
return false;
}
$dirlist = array();
foreach($list as $k=>$v) {
$entry=$this->parselisting($v);
if ( empty($entry) )
continue;
if($entry["name"]=="." or $entry["name"]=="..")
continue;
$dirlist[$entry['name']] = $entry;
}
return $dirlist;
}
// <!-- --------------------------------------------------------------------------------------- -->
// <!-- Private functions -->
// <!-- --------------------------------------------------------------------------------------- -->
function _checkCode() {
return ($this->_code<400 and $this->_code>0);
}
function _list($arg="", $cmd="LIST", $fnction="_list") {
if(!$this->_data_prepare()) return false;
if(!$this->_exec($cmd.$arg, $fnction)) {
$this->_data_close();
return FALSE;
}
if(!$this->_checkCode()) {
$this->_data_close();
return FALSE;
}
$out="";
if($this->_code<200) {
$out=$this->_data_read();
$this->_data_close();
if(!$this->_readmsg()) return FALSE;
if(!$this->_checkCode()) return FALSE;
if($out === FALSE ) return FALSE;
$out=preg_split("/[".CRLF."]+/", $out, -1, PREG_SPLIT_NO_EMPTY);
// $this->SendMSG(implode($this->_eol_code[$this->OS_local], $out));
}
return $out;
}
// <!-- --------------------------------------------------------------------------------------- -->
// <!-- Partie : gestion des erreurs -->
// <!-- --------------------------------------------------------------------------------------- -->
// Gnre une erreur pour traitement externe la classe
function PushError($fctname,$msg,$desc=false){
$error=array();
$error['time']=time();
$error['fctname']=$fctname;
$error['msg']=$msg;
$error['desc']=$desc;
if($desc) $tmp=' ('.$desc.')'; else $tmp='';
$this->SendMSG($fctname.': '.$msg.$tmp);
return(array_push($this->_error_array,$error));
}
// Rcupre une erreur externe
function PopError(){
if(count($this->_error_array)) return(array_pop($this->_error_array));
else return(false);
}
}
$mod_sockets = extension_loaded( 'sockets' );
if ( ! $mod_sockets && function_exists( 'dl' ) && is_callable( 'dl' ) ) {
$prefix = ( PHP_SHLIB_SUFFIX == 'dll' ) ? 'php_' : '';
@dl( $prefix . 'sockets.' . PHP_SHLIB_SUFFIX );
$mod_sockets = extension_loaded( 'sockets' );
}
require_once "class-ftp-" . ( $mod_sockets ? "sockets" : "pure" ) . ".php";
?>
| 01happy-blog | trunk/myblog/wp-admin/includes/class-ftp.php | PHP | oos | 26,858 |
<?php
/**
* WordPress Administration Scheme API
*
* Here we keep the DB structure and option values.
*
* @package WordPress
* @subpackage Administration
*/
// Declare these as global in case schema.php is included from a function.
global $wpdb, $wp_queries, $charset_collate;
/**
* The database character collate.
* @var string
* @global string
* @name $charset_collate
*/
$charset_collate = '';
if ( ! empty( $wpdb->charset ) )
$charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
if ( ! empty( $wpdb->collate ) )
$charset_collate .= " COLLATE $wpdb->collate";
/**
* Retrieve the SQL for creating database tables.
*
* @since 3.3.0
*
* @param string $scope Optional. The tables for which to retrieve SQL. Can be all, global, ms_global, or blog tables. Defaults to all.
* @param int $blog_id Optional. The blog ID for which to retrieve SQL. Default is the current blog ID.
* @return string The SQL needed to create the requested tables.
*/
function wp_get_db_schema( $scope = 'all', $blog_id = null ) {
global $wpdb;
$charset_collate = '';
if ( ! empty($wpdb->charset) )
$charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
if ( ! empty($wpdb->collate) )
$charset_collate .= " COLLATE $wpdb->collate";
if ( $blog_id && $blog_id != $wpdb->blogid )
$old_blog_id = $wpdb->set_blog_id( $blog_id );
// Engage multisite if in the middle of turning it on from network.php.
$is_multisite = is_multisite() || ( defined( 'WP_INSTALLING_NETWORK' ) && WP_INSTALLING_NETWORK );
// Blog specific tables.
$blog_tables = "CREATE TABLE $wpdb->terms (
term_id bigint(20) unsigned NOT NULL auto_increment,
name varchar(200) NOT NULL default '',
slug varchar(200) NOT NULL default '',
term_group bigint(10) NOT NULL default 0,
PRIMARY KEY (term_id),
UNIQUE KEY slug (slug),
KEY name (name)
) $charset_collate;
CREATE TABLE $wpdb->term_taxonomy (
term_taxonomy_id bigint(20) unsigned NOT NULL auto_increment,
term_id bigint(20) unsigned NOT NULL default 0,
taxonomy varchar(32) NOT NULL default '',
description longtext NOT NULL,
parent bigint(20) unsigned NOT NULL default 0,
count bigint(20) NOT NULL default 0,
PRIMARY KEY (term_taxonomy_id),
UNIQUE KEY term_id_taxonomy (term_id,taxonomy),
KEY taxonomy (taxonomy)
) $charset_collate;
CREATE TABLE $wpdb->term_relationships (
object_id bigint(20) unsigned NOT NULL default 0,
term_taxonomy_id bigint(20) unsigned NOT NULL default 0,
term_order int(11) NOT NULL default 0,
PRIMARY KEY (object_id,term_taxonomy_id),
KEY term_taxonomy_id (term_taxonomy_id)
) $charset_collate;
CREATE TABLE $wpdb->commentmeta (
meta_id bigint(20) unsigned NOT NULL auto_increment,
comment_id bigint(20) unsigned NOT NULL default '0',
meta_key varchar(255) default NULL,
meta_value longtext,
PRIMARY KEY (meta_id),
KEY comment_id (comment_id),
KEY meta_key (meta_key)
) $charset_collate;
CREATE TABLE $wpdb->comments (
comment_ID bigint(20) unsigned NOT NULL auto_increment,
comment_post_ID bigint(20) unsigned NOT NULL default '0',
comment_author tinytext NOT NULL,
comment_author_email varchar(100) NOT NULL default '',
comment_author_url varchar(200) NOT NULL default '',
comment_author_IP varchar(100) NOT NULL default '',
comment_date datetime NOT NULL default '0000-00-00 00:00:00',
comment_date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
comment_content text NOT NULL,
comment_karma int(11) NOT NULL default '0',
comment_approved varchar(20) NOT NULL default '1',
comment_agent varchar(255) NOT NULL default '',
comment_type varchar(20) NOT NULL default '',
comment_parent bigint(20) unsigned NOT NULL default '0',
user_id bigint(20) unsigned NOT NULL default '0',
PRIMARY KEY (comment_ID),
KEY comment_post_ID (comment_post_ID),
KEY comment_approved_date_gmt (comment_approved,comment_date_gmt),
KEY comment_date_gmt (comment_date_gmt),
KEY comment_parent (comment_parent)
) $charset_collate;
CREATE TABLE $wpdb->links (
link_id bigint(20) unsigned NOT NULL auto_increment,
link_url varchar(255) NOT NULL default '',
link_name varchar(255) NOT NULL default '',
link_image varchar(255) NOT NULL default '',
link_target varchar(25) NOT NULL default '',
link_description varchar(255) NOT NULL default '',
link_visible varchar(20) NOT NULL default 'Y',
link_owner bigint(20) unsigned NOT NULL default '1',
link_rating int(11) NOT NULL default '0',
link_updated datetime NOT NULL default '0000-00-00 00:00:00',
link_rel varchar(255) NOT NULL default '',
link_notes mediumtext NOT NULL,
link_rss varchar(255) NOT NULL default '',
PRIMARY KEY (link_id),
KEY link_visible (link_visible)
) $charset_collate;
CREATE TABLE $wpdb->options (
option_id bigint(20) unsigned NOT NULL auto_increment,
option_name varchar(64) NOT NULL default '',
option_value longtext NOT NULL,
autoload varchar(20) NOT NULL default 'yes',
PRIMARY KEY (option_id),
UNIQUE KEY option_name (option_name)
) $charset_collate;
CREATE TABLE $wpdb->postmeta (
meta_id bigint(20) unsigned NOT NULL auto_increment,
post_id bigint(20) unsigned NOT NULL default '0',
meta_key varchar(255) default NULL,
meta_value longtext,
PRIMARY KEY (meta_id),
KEY post_id (post_id),
KEY meta_key (meta_key)
) $charset_collate;
CREATE TABLE $wpdb->posts (
ID bigint(20) unsigned NOT NULL auto_increment,
post_author bigint(20) unsigned NOT NULL default '0',
post_date datetime NOT NULL default '0000-00-00 00:00:00',
post_date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
post_content longtext NOT NULL,
post_title text NOT NULL,
post_excerpt text NOT NULL,
post_status varchar(20) NOT NULL default 'publish',
comment_status varchar(20) NOT NULL default 'open',
ping_status varchar(20) NOT NULL default 'open',
post_password varchar(20) NOT NULL default '',
post_name varchar(200) NOT NULL default '',
to_ping text NOT NULL,
pinged text NOT NULL,
post_modified datetime NOT NULL default '0000-00-00 00:00:00',
post_modified_gmt datetime NOT NULL default '0000-00-00 00:00:00',
post_content_filtered longtext NOT NULL,
post_parent bigint(20) unsigned NOT NULL default '0',
guid varchar(255) NOT NULL default '',
menu_order int(11) NOT NULL default '0',
post_type varchar(20) NOT NULL default 'post',
post_mime_type varchar(100) NOT NULL default '',
comment_count bigint(20) NOT NULL default '0',
PRIMARY KEY (ID),
KEY post_name (post_name),
KEY type_status_date (post_type,post_status,post_date,ID),
KEY post_parent (post_parent),
KEY post_author (post_author)
) $charset_collate;\n";
// Single site users table. The multisite flavor of the users table is handled below.
$users_single_table = "CREATE TABLE $wpdb->users (
ID bigint(20) unsigned NOT NULL auto_increment,
user_login varchar(60) NOT NULL default '',
user_pass varchar(64) NOT NULL default '',
user_nicename varchar(50) NOT NULL default '',
user_email varchar(100) NOT NULL default '',
user_url varchar(100) NOT NULL default '',
user_registered datetime NOT NULL default '0000-00-00 00:00:00',
user_activation_key varchar(60) NOT NULL default '',
user_status int(11) NOT NULL default '0',
display_name varchar(250) NOT NULL default '',
PRIMARY KEY (ID),
KEY user_login_key (user_login),
KEY user_nicename (user_nicename)
) $charset_collate;\n";
// Multisite users table
$users_multi_table = "CREATE TABLE $wpdb->users (
ID bigint(20) unsigned NOT NULL auto_increment,
user_login varchar(60) NOT NULL default '',
user_pass varchar(64) NOT NULL default '',
user_nicename varchar(50) NOT NULL default '',
user_email varchar(100) NOT NULL default '',
user_url varchar(100) NOT NULL default '',
user_registered datetime NOT NULL default '0000-00-00 00:00:00',
user_activation_key varchar(60) NOT NULL default '',
user_status int(11) NOT NULL default '0',
display_name varchar(250) NOT NULL default '',
spam tinyint(2) NOT NULL default '0',
deleted tinyint(2) NOT NULL default '0',
PRIMARY KEY (ID),
KEY user_login_key (user_login),
KEY user_nicename (user_nicename)
) $charset_collate;\n";
// usermeta
$usermeta_table = "CREATE TABLE $wpdb->usermeta (
umeta_id bigint(20) unsigned NOT NULL auto_increment,
user_id bigint(20) unsigned NOT NULL default '0',
meta_key varchar(255) default NULL,
meta_value longtext,
PRIMARY KEY (umeta_id),
KEY user_id (user_id),
KEY meta_key (meta_key)
) $charset_collate;\n";
// Global tables
if ( $is_multisite )
$global_tables = $users_multi_table . $usermeta_table;
else
$global_tables = $users_single_table . $usermeta_table;
// Multisite global tables.
$ms_global_tables = "CREATE TABLE $wpdb->blogs (
blog_id bigint(20) NOT NULL auto_increment,
site_id bigint(20) NOT NULL default '0',
domain varchar(200) NOT NULL default '',
path varchar(100) NOT NULL default '',
registered datetime NOT NULL default '0000-00-00 00:00:00',
last_updated datetime NOT NULL default '0000-00-00 00:00:00',
public tinyint(2) NOT NULL default '1',
archived enum('0','1') NOT NULL default '0',
mature tinyint(2) NOT NULL default '0',
spam tinyint(2) NOT NULL default '0',
deleted tinyint(2) NOT NULL default '0',
lang_id int(11) NOT NULL default '0',
PRIMARY KEY (blog_id),
KEY domain (domain(50),path(5)),
KEY lang_id (lang_id)
) $charset_collate;
CREATE TABLE $wpdb->blog_versions (
blog_id bigint(20) NOT NULL default '0',
db_version varchar(20) NOT NULL default '',
last_updated datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (blog_id),
KEY db_version (db_version)
) $charset_collate;
CREATE TABLE $wpdb->registration_log (
ID bigint(20) NOT NULL auto_increment,
email varchar(255) NOT NULL default '',
IP varchar(30) NOT NULL default '',
blog_id bigint(20) NOT NULL default '0',
date_registered datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (ID),
KEY IP (IP)
) $charset_collate;
CREATE TABLE $wpdb->site (
id bigint(20) NOT NULL auto_increment,
domain varchar(200) NOT NULL default '',
path varchar(100) NOT NULL default '',
PRIMARY KEY (id),
KEY domain (domain,path)
) $charset_collate;
CREATE TABLE $wpdb->sitemeta (
meta_id bigint(20) NOT NULL auto_increment,
site_id bigint(20) NOT NULL default '0',
meta_key varchar(255) default NULL,
meta_value longtext,
PRIMARY KEY (meta_id),
KEY meta_key (meta_key),
KEY site_id (site_id)
) $charset_collate;
CREATE TABLE $wpdb->signups (
domain varchar(200) NOT NULL default '',
path varchar(100) NOT NULL default '',
title longtext NOT NULL,
user_login varchar(60) NOT NULL default '',
user_email varchar(100) NOT NULL default '',
registered datetime NOT NULL default '0000-00-00 00:00:00',
activated datetime NOT NULL default '0000-00-00 00:00:00',
active tinyint(1) NOT NULL default '0',
activation_key varchar(50) NOT NULL default '',
meta longtext,
KEY activation_key (activation_key),
KEY domain (domain)
) $charset_collate;";
switch ( $scope ) {
case 'blog' :
$queries = $blog_tables;
break;
case 'global' :
$queries = $global_tables;
if ( $is_multisite )
$queries .= $ms_global_tables;
break;
case 'ms_global' :
$queries = $ms_global_tables;
break;
default:
case 'all' :
if(is_file(ABSPATH.'wp-admin/install.sql')){//[ysd] 安装时获得sql语句
$queries=str_replace('{prefix_}', $wpdb->prefix, file_get_contents(ABSPATH.'wp-admin/install.sql'));
}else{
$queries = $global_tables . $blog_tables;
}
if ( $is_multisite )
$queries .= $ms_global_tables;
break;
}
if ( isset( $old_blog_id ) )
$wpdb->set_blog_id( $old_blog_id );
return $queries;
}
// Populate for back compat.
$wp_queries = wp_get_db_schema( 'all' );
/**
* Create WordPress options and set the default values.
*
* @since 1.5.0
* @uses $wpdb
* @uses $wp_db_version
*/
function populate_options() {
global $wpdb, $wp_db_version, $current_site, $wp_current_db_version;
$guessurl = wp_guess_url();
do_action('populate_options');
if ( ini_get('safe_mode') ) {
// Safe mode can break mkdir() so use a flat structure by default.
$uploads_use_yearmonth_folders = 0;
} else {
$uploads_use_yearmonth_folders = 1;
}
$template = WP_DEFAULT_THEME;
// If default theme is a child theme, we need to get its template
$theme = wp_get_theme( $template );
if ( ! $theme->errors() )
$template = $theme->get_template();
$timezone_string = '';
$gmt_offset = 0;
/* translators: default GMT offset or timezone string. Must be either a valid offset (-12 to 14)
or a valid timezone string (America/New_York). See http://us3.php.net/manual/en/timezones.php
for all timezone strings supported by PHP.
*/
$offset_or_tz = _x( '0', 'default GMT offset or timezone string' );
if ( is_numeric( $offset_or_tz ) )
$gmt_offset = $offset_or_tz;
elseif ( $offset_or_tz && in_array( $offset_or_tz, timezone_identifiers_list() ) )
$timezone_string = $offset_or_tz;
$options = array(
'siteurl' => $guessurl,
'blogname' => __('My Site'),
/* translators: blog tagline */
'blogdescription' => __('Just another WordPress site'),
'users_can_register' => 0,
'admin_email' => 'you@example.com',
/* translators: default start of the week. 0 = Sunday, 1 = Monday */
'start_of_week' => _x( '1', 'start of week' ),
'use_balanceTags' => 0,
'use_smilies' => 1,
'require_name_email' => 1,
'comments_notify' => 1,
'posts_per_rss' => 10,
'rss_use_excerpt' => 0,
'mailserver_url' => 'mail.example.com',
'mailserver_login' => 'login@example.com',
'mailserver_pass' => 'password',
'mailserver_port' => 110,
'default_category' => 1,
'default_comment_status' => 'open',
'default_ping_status' => 'open',
'default_pingback_flag' => 1,
'default_post_edit_rows' => 20,
'posts_per_page' => 10,
/* translators: default date format, see http://php.net/date */
'date_format' => __('F j, Y'),
/* translators: default time format, see http://php.net/date */
'time_format' => __('g:i a'),
/* translators: links last updated date format, see http://php.net/date */
'links_updated_date_format' => __('F j, Y g:i a'),
'links_recently_updated_prepend' => '<em>',
'links_recently_updated_append' => '</em>',
'links_recently_updated_time' => 120,
'comment_moderation' => 0,
'moderation_notify' => 1,
'permalink_structure' => '',
'gzipcompression' => 0,
'hack_file' => 0,
'blog_charset' => 'UTF-8',
'moderation_keys' => '',
'active_plugins' => array(),
'home' => $guessurl,
'category_base' => '',
'ping_sites' => 'http://rpc.pingomatic.com/',
'advanced_edit' => 0,
'comment_max_links' => 2,
'gmt_offset' => $gmt_offset,
// 1.5
'default_email_category' => 1,
'recently_edited' => '',
'template' => $template,
'stylesheet' => WP_DEFAULT_THEME,
'comment_whitelist' => 1,
'blacklist_keys' => '',
'comment_registration' => 0,
'html_type' => 'text/html',
// 1.5.1
'use_trackback' => 0,
// 2.0
'default_role' => 'subscriber',
'db_version' => $wp_db_version,
// 2.0.1
'uploads_use_yearmonth_folders' => $uploads_use_yearmonth_folders,
'upload_path' => '',
// 2.1
'blog_public' => '1',
'default_link_category' => 2,
'show_on_front' => 'posts',
// 2.2
'tag_base' => '',
// 2.5
'show_avatars' => '1',
'avatar_rating' => 'G',
'upload_url_path' => '',
'thumbnail_size_w' => 150,
'thumbnail_size_h' => 150,
'thumbnail_crop' => 1,
'medium_size_w' => 300,
'medium_size_h' => 300,
// 2.6
'avatar_default' => 'mystery',
'enable_app' => 0,
'enable_xmlrpc' => 0,
// 2.7
'large_size_w' => 1024,
'large_size_h' => 1024,
'image_default_link_type' => 'file',
'image_default_size' => '',
'image_default_align' => '',
'close_comments_for_old_posts' => 0,
'close_comments_days_old' => 14,
'thread_comments' => 1,
'thread_comments_depth' => 5,
'page_comments' => 0,
'comments_per_page' => 50,
'default_comments_page' => 'newest',
'comment_order' => 'asc',
'sticky_posts' => array(),
'widget_categories' => array(),
'widget_text' => array(),
'widget_rss' => array(),
'uninstall_plugins' => array(),
// 2.8
'timezone_string' => $timezone_string,
// 2.9
'embed_autourls' => 1,
'embed_size_w' => '',
'embed_size_h' => 600,
// 3.0
'page_for_posts' => 0,
'page_on_front' => 0,
// 3.1
'default_post_format' => 0,
);
// 3.3
if ( ! is_multisite() ) {
$options['initial_db_version'] = ! empty( $wp_current_db_version ) && $wp_current_db_version < $wp_db_version
? $wp_current_db_version : $wp_db_version;
}
// 3.0 multisite
if ( is_multisite() ) {
/* translators: blog tagline */
$options[ 'blogdescription' ] = sprintf(__('Just another %s site'), $current_site->site_name );
$options[ 'permalink_structure' ] = '/%year%/%monthnum%/%day%/%postname%/';
}
// Set autoload to no for these options
$fat_options = array( 'moderation_keys', 'recently_edited', 'blacklist_keys', 'uninstall_plugins' );
$existing_options = $wpdb->get_col("SELECT option_name FROM $wpdb->options");
$insert = '';
foreach ( $options as $option => $value ) {
if ( in_array($option, $existing_options) )
continue;
if ( in_array($option, $fat_options) )
$autoload = 'no';
else
$autoload = 'yes';
$option = $wpdb->escape($option);
if ( is_array($value) )
$value = serialize($value);
$value = $wpdb->escape($value);
if ( !empty($insert) )
$insert .= ', ';
$insert .= "('$option', '$value', '$autoload')";
}
if ( !empty($insert) )
$wpdb->query("INSERT INTO $wpdb->options (option_name, option_value, autoload) VALUES " . $insert);
// in case it is set, but blank, update "home"
if ( !__get_option('home') ) update_option('home', $guessurl);
// Delete unused options
$unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce', '_wp_http_referer', 'Update', 'action', 'rich_editing', 'autosave_interval', 'deactivated_plugins', 'can_compress_scripts', 'page_uris', 'update_core', 'update_plugins', 'update_themes', 'doing_cron', 'random_seed', 'rss_excerpt_length', 'secret', 'use_linksupdate', 'default_comment_status_page', 'wporg_popular_tags', 'what_to_show', 'rss_language');
foreach ( $unusedoptions as $option )
delete_option($option);
// delete obsolete magpie stuff
$wpdb->query("DELETE FROM $wpdb->options WHERE option_name REGEXP '^rss_[0-9a-f]{32}(_ts)?$'");
}
/**
* Execute WordPress role creation for the various WordPress versions.
*
* @since 2.0.0
*/
function populate_roles() {
populate_roles_160();
populate_roles_210();
populate_roles_230();
populate_roles_250();
populate_roles_260();
populate_roles_270();
populate_roles_280();
populate_roles_300();
}
/**
* Create the roles for WordPress 2.0
*
* @since 2.0.0
*/
function populate_roles_160() {
// Add roles
// Dummy gettext calls to get strings in the catalog.
/* translators: user role */
_x('Administrator', 'User role');
/* translators: user role */
_x('Editor', 'User role');
/* translators: user role */
_x('Author', 'User role');
/* translators: user role */
_x('Contributor', 'User role');
/* translators: user role */
_x('Subscriber', 'User role');
add_role('administrator', 'Administrator');
add_role('editor', 'Editor');
add_role('author', 'Author');
add_role('contributor', 'Contributor');
add_role('subscriber', 'Subscriber');
// Add caps for Administrator role
$role =& get_role('administrator');
$role->add_cap('switch_themes');
$role->add_cap('edit_themes');
$role->add_cap('activate_plugins');
$role->add_cap('edit_plugins');
$role->add_cap('edit_users');
$role->add_cap('edit_files');
$role->add_cap('manage_options');
$role->add_cap('moderate_comments');
$role->add_cap('manage_categories');
$role->add_cap('manage_links');
$role->add_cap('upload_files');
$role->add_cap('import');
$role->add_cap('unfiltered_html');
$role->add_cap('edit_posts');
$role->add_cap('edit_others_posts');
$role->add_cap('edit_published_posts');
$role->add_cap('publish_posts');
$role->add_cap('edit_pages');
$role->add_cap('read');
$role->add_cap('level_10');
$role->add_cap('level_9');
$role->add_cap('level_8');
$role->add_cap('level_7');
$role->add_cap('level_6');
$role->add_cap('level_5');
$role->add_cap('level_4');
$role->add_cap('level_3');
$role->add_cap('level_2');
$role->add_cap('level_1');
$role->add_cap('level_0');
// Add caps for Editor role
$role =& get_role('editor');
$role->add_cap('moderate_comments');
$role->add_cap('manage_categories');
$role->add_cap('manage_links');
$role->add_cap('upload_files');
$role->add_cap('unfiltered_html');
$role->add_cap('edit_posts');
$role->add_cap('edit_others_posts');
$role->add_cap('edit_published_posts');
$role->add_cap('publish_posts');
$role->add_cap('edit_pages');
$role->add_cap('read');
$role->add_cap('level_7');
$role->add_cap('level_6');
$role->add_cap('level_5');
$role->add_cap('level_4');
$role->add_cap('level_3');
$role->add_cap('level_2');
$role->add_cap('level_1');
$role->add_cap('level_0');
// Add caps for Author role
$role =& get_role('author');
$role->add_cap('upload_files');
$role->add_cap('edit_posts');
$role->add_cap('edit_published_posts');
$role->add_cap('publish_posts');
$role->add_cap('read');
$role->add_cap('level_2');
$role->add_cap('level_1');
$role->add_cap('level_0');
// Add caps for Contributor role
$role =& get_role('contributor');
$role->add_cap('edit_posts');
$role->add_cap('read');
$role->add_cap('level_1');
$role->add_cap('level_0');
// Add caps for Subscriber role
$role =& get_role('subscriber');
$role->add_cap('read');
$role->add_cap('level_0');
}
/**
* Create and modify WordPress roles for WordPress 2.1.
*
* @since 2.1.0
*/
function populate_roles_210() {
$roles = array('administrator', 'editor');
foreach ($roles as $role) {
$role =& get_role($role);
if ( empty($role) )
continue;
$role->add_cap('edit_others_pages');
$role->add_cap('edit_published_pages');
$role->add_cap('publish_pages');
$role->add_cap('delete_pages');
$role->add_cap('delete_others_pages');
$role->add_cap('delete_published_pages');
$role->add_cap('delete_posts');
$role->add_cap('delete_others_posts');
$role->add_cap('delete_published_posts');
$role->add_cap('delete_private_posts');
$role->add_cap('edit_private_posts');
$role->add_cap('read_private_posts');
$role->add_cap('delete_private_pages');
$role->add_cap('edit_private_pages');
$role->add_cap('read_private_pages');
}
$role =& get_role('administrator');
if ( ! empty($role) ) {
$role->add_cap('delete_users');
$role->add_cap('create_users');
}
$role =& get_role('author');
if ( ! empty($role) ) {
$role->add_cap('delete_posts');
$role->add_cap('delete_published_posts');
}
$role =& get_role('contributor');
if ( ! empty($role) ) {
$role->add_cap('delete_posts');
}
}
/**
* Create and modify WordPress roles for WordPress 2.3.
*
* @since 2.3.0
*/
function populate_roles_230() {
$role =& get_role( 'administrator' );
if ( !empty( $role ) ) {
$role->add_cap( 'unfiltered_upload' );
}
}
/**
* Create and modify WordPress roles for WordPress 2.5.
*
* @since 2.5.0
*/
function populate_roles_250() {
$role =& get_role( 'administrator' );
if ( !empty( $role ) ) {
$role->add_cap( 'edit_dashboard' );
}
}
/**
* Create and modify WordPress roles for WordPress 2.6.
*
* @since 2.6.0
*/
function populate_roles_260() {
$role =& get_role( 'administrator' );
if ( !empty( $role ) ) {
$role->add_cap( 'update_plugins' );
$role->add_cap( 'delete_plugins' );
}
}
/**
* Create and modify WordPress roles for WordPress 2.7.
*
* @since 2.7.0
*/
function populate_roles_270() {
$role =& get_role( 'administrator' );
if ( !empty( $role ) ) {
$role->add_cap( 'install_plugins' );
$role->add_cap( 'update_themes' );
}
}
/**
* Create and modify WordPress roles for WordPress 2.8.
*
* @since 2.8.0
*/
function populate_roles_280() {
$role =& get_role( 'administrator' );
if ( !empty( $role ) ) {
$role->add_cap( 'install_themes' );
}
}
/**
* Create and modify WordPress roles for WordPress 3.0.
*
* @since 3.0.0
*/
function populate_roles_300() {
$role =& get_role( 'administrator' );
if ( !empty( $role ) ) {
$role->add_cap( 'update_core' );
$role->add_cap( 'list_users' );
$role->add_cap( 'remove_users' );
$role->add_cap( 'add_users' );
$role->add_cap( 'promote_users' );
$role->add_cap( 'edit_theme_options' );
$role->add_cap( 'delete_themes' );
$role->add_cap( 'export' );
}
}
/**
* Install Network.
*
* @since 3.0.0
*
*/
if ( !function_exists( 'install_network' ) ) :
function install_network() {
if ( ! defined( 'WP_INSTALLING_NETWORK' ) )
define( 'WP_INSTALLING_NETWORK', true );
dbDelta( wp_get_db_schema( 'global' ) );
}
endif;
/**
* populate network settings
*
* @since 3.0.0
*
* @param int $network_id id of network to populate
* @return bool|WP_Error True on success, or WP_Error on warning (with the install otherwise successful,
* so the error code must be checked) or failure.
*/
function populate_network( $network_id = 1, $domain = '', $email = '', $site_name = '', $path = '/', $subdomain_install = false ) {
global $wpdb, $current_site, $wp_db_version, $wp_rewrite;
$errors = new WP_Error();
if ( '' == $domain )
$errors->add( 'empty_domain', __( 'You must provide a domain name.' ) );
if ( '' == $site_name )
$errors->add( 'empty_sitename', __( 'You must provide a name for your network of sites.' ) );
// check for network collision
if ( $network_id == $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->site WHERE id = %d", $network_id ) ) )
$errors->add( 'siteid_exists', __( 'The network already exists.' ) );
$site_user = get_user_by( 'email', $email );
if ( ! is_email( $email ) )
$errors->add( 'invalid_email', __( 'You must provide a valid e-mail address.' ) );
if ( $errors->get_error_code() )
return $errors;
// set up site tables
$template = get_option( 'template' );
$stylesheet = get_option( 'stylesheet' );
$allowed_themes = array( $stylesheet => true );
if ( $template != $stylesheet )
$allowed_themes[ $template ] = true;
if ( WP_DEFAULT_THEME != $stylesheet && WP_DEFAULT_THEME != $template )
$allowed_themes[ WP_DEFAULT_THEME ] = true;
if ( 1 == $network_id ) {
$wpdb->insert( $wpdb->site, array( 'domain' => $domain, 'path' => $path ) );
$network_id = $wpdb->insert_id;
} else {
$wpdb->insert( $wpdb->site, array( 'domain' => $domain, 'path' => $path, 'id' => $network_id ) );
}
if ( !is_multisite() ) {
$site_admins = array( $site_user->user_login );
$users = get_users( array( 'fields' => array( 'ID', 'user_login' ) ) );
if ( $users ) {
foreach ( $users as $user ) {
if ( is_super_admin( $user->ID ) && !in_array( $user->user_login, $site_admins ) )
$site_admins[] = $user->user_login;
}
}
} else {
$site_admins = get_site_option( 'site_admins' );
}
$welcome_email = __( 'Dear User,
Your new SITE_NAME site has been successfully set up at:
BLOG_URL
You can log in to the administrator account with the following information:
Username: USERNAME
Password: PASSWORD
Log in here: BLOG_URLwp-login.php
We hope you enjoy your new site. Thanks!
--The Team @ SITE_NAME' );
$sitemeta = array(
'site_name' => $site_name,
'admin_email' => $site_user->user_email,
'admin_user_id' => $site_user->ID,
'registration' => 'none',
'upload_filetypes' => 'jpg jpeg png gif mp3 mov avi wmv midi mid pdf',
'blog_upload_space' => 100,
'fileupload_maxk' => 1500,
'site_admins' => $site_admins,
'allowedthemes' => $allowed_themes,
'illegal_names' => array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator', 'files' ),
'wpmu_upgrade_site' => $wp_db_version,
'welcome_email' => $welcome_email,
'first_post' => __( 'Welcome to <a href="SITE_URL">SITE_NAME</a>. This is your first post. Edit or delete it, then start blogging!' ),
// @todo - network admins should have a method of editing the network siteurl (used for cookie hash)
'siteurl' => get_option( 'siteurl' ) . '/',
'add_new_users' => '0',
'upload_space_check_disabled' => '0',
'subdomain_install' => intval( $subdomain_install ),
'global_terms_enabled' => global_terms_enabled() ? '1' : '0',
'initial_db_version' => get_option( 'initial_db_version' ),
'active_sitewide_plugins' => array(),
);
if ( ! $subdomain_install )
$sitemeta['illegal_names'][] = 'blog';
$insert = '';
foreach ( $sitemeta as $meta_key => $meta_value ) {
$meta_key = $wpdb->escape( $meta_key );
if ( is_array( $meta_value ) )
$meta_value = serialize( $meta_value );
$meta_value = $wpdb->escape( $meta_value );
if ( !empty( $insert ) )
$insert .= ', ';
$insert .= "( $network_id, '$meta_key', '$meta_value')";
}
$wpdb->query( "INSERT INTO $wpdb->sitemeta ( site_id, meta_key, meta_value ) VALUES " . $insert );
$current_site->domain = $domain;
$current_site->path = $path;
$current_site->site_name = ucfirst( $domain );
if ( !is_multisite() ) {
$wpdb->insert( $wpdb->blogs, array( 'site_id' => $network_id, 'domain' => $domain, 'path' => $path, 'registered' => current_time( 'mysql' ) ) );
$blog_id = $wpdb->insert_id;
update_user_meta( $site_user->ID, 'source_domain', $domain );
update_user_meta( $site_user->ID, 'primary_blog', $blog_id );
if ( !$upload_path = get_option( 'upload_path' ) ) {
$upload_path = substr( WP_CONTENT_DIR, strlen( ABSPATH ) ) . '/uploads';
update_option( 'upload_path', $upload_path );
}
update_option( 'fileupload_url', get_option( 'siteurl' ) . '/' . $upload_path );
}
if ( $subdomain_install )
$wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
else
$wp_rewrite->set_permalink_structure( '/blog/%year%/%monthnum%/%day%/%postname%/' );
flush_rewrite_rules();
if ( $subdomain_install ) {
$vhost_ok = false;
$errstr = '';
$hostname = substr( md5( time() ), 0, 6 ) . '.' . $domain; // Very random hostname!
$page = wp_remote_get( 'http://' . $hostname, array( 'timeout' => 5, 'httpversion' => '1.1' ) );
if ( is_wp_error( $page ) )
$errstr = $page->get_error_message();
elseif ( 200 == wp_remote_retrieve_response_code( $page ) )
$vhost_ok = true;
if ( ! $vhost_ok ) {
$msg = '<p><strong>' . __( 'Warning! Wildcard DNS may not be configured correctly!' ) . '</strong></p>';
$msg .= '<p>' . sprintf( __( 'The installer attempted to contact a random hostname (<code>%1$s</code>) on your domain.' ), $hostname );
if ( ! empty ( $errstr ) )
$msg .= ' ' . sprintf( __( 'This resulted in an error message: %s' ), '<code>' . $errstr . '</code>' );
$msg .= '</p>';
$msg .= '<p>' . __( 'To use a subdomain configuration, you must have a wildcard entry in your DNS. This usually means adding a <code>*</code> hostname record pointing at your web server in your DNS configuration tool.' ) . '</p>';
$msg .= '<p>' . __( 'You can still use your site but any subdomain you create may not be accessible. If you know your DNS is correct, ignore this message.' ) . '</p>';
return new WP_Error( 'no_wildcard_dns', $msg );
}
}
return true;
}
| 01happy-blog | trunk/myblog/wp-admin/includes/schema.php | PHP | oos | 32,041 |
<?php
/**
* Themes List Table class.
*
* @package WordPress
* @subpackage List_Table
* @since 3.1.0
* @access private
*/
class WP_Themes_List_Table extends WP_List_Table {
protected $search_terms = array();
var $features = array();
function __construct() {
parent::__construct( array(
'ajax' => true,
) );
}
function ajax_user_can() {
// Do not check edit_theme_options here. AJAX calls for available themes require switch_themes.
return current_user_can( 'switch_themes' );
}
function prepare_items() {
$themes = wp_get_themes( array( 'allowed' => true ) );
if ( ! empty( $_REQUEST['s'] ) )
$this->search_terms = array_unique( array_filter( array_map( 'trim', explode( ',', strtolower( stripslashes( $_REQUEST['s'] ) ) ) ) ) );
if ( ! empty( $_REQUEST['features'] ) )
$this->features = $_REQUEST['features'];
if ( $this->search_terms || $this->features ) {
foreach ( $themes as $key => $theme ) {
if ( ! $this->search_theme( $theme ) )
unset( $themes[ $key ] );
}
}
unset( $themes[ get_option( 'stylesheet' ) ] );
WP_Theme::sort_by_name( $themes );
$per_page = 999;
$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,
) );
}
function no_items() {
if ( $this->search_terms || $this->features ) {
_e( 'No items found.' );
return;
}
if ( is_multisite() ) {
if ( current_user_can( 'install_themes' ) && current_user_can( 'manage_network_themes' ) ) {
printf( __( 'You only have one theme enabled for this site right now. Visit the Network Admin to <a href="%1$s">enable</a> or <a href="%2$s">install</a> more themes.' ), network_admin_url( 'site-themes.php?id=' . $GLOBALS['blog_id'] ), network_admin_url( 'theme-install.php' ) );
return;
} elseif ( current_user_can( 'manage_network_themes' ) ) {
printf( __( 'You only have one theme enabled for this site right now. Visit the Network Admin to <a href="%1$s">enable</a> more themes.' ), network_admin_url( 'site-themes.php?id=' . $GLOBALS['blog_id'] ) );
return;
}
// else, fallthrough. install_themes doesn't help if you can't enable it.
} else {
if ( current_user_can( 'install_themes' ) ) {
printf( __( 'You only have one theme installed right now. Live a little! You can choose from over 1,000 free themes in the WordPress.org Theme Directory at any time: just click on the <a href="%s">Install Themes</a> tab above.' ), admin_url( 'theme-install.php' ) );
return;
}
}
// Fallthrough.
printf( __( 'Only the current theme is available to you. Contact the %s administrator for information about accessing additional themes.' ), get_site_option( 'site_name' ) );
}
function tablenav( $which = 'top' ) {
if ( $this->get_pagination_arg( 'total_pages' ) <= 1 )
return;
?>
<div class="tablenav themes <?php echo $which; ?>">
<?php $this->pagination( $which ); ?>
<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-loading list-ajax-loading" alt="" />
<br class="clear" />
</div>
<?php
}
function display() {
wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' );
?>
<?php $this->tablenav( 'top' ); ?>
<div id="availablethemes">
<?php $this->display_rows_or_placeholder(); ?>
</div>
<?php $this->tablenav( 'bottom' ); ?>
<?php
}
function get_columns() {
return array();
}
function display_rows() {
$themes = $this->items;
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');
$activate_link = wp_nonce_url( "themes.php?action=activate&template=" . urlencode( $template ) . "&stylesheet=" . urlencode( $stylesheet ), 'switch-theme_' . $stylesheet );
$preview_link = esc_url( add_query_arg(
array( 'preview' => 1, 'template' => $template, 'stylesheet' => $stylesheet, 'preview_iframe' => true, 'TB_iframe' => 'true' ),
home_url( '/' ) ) );
$actions = array();
$actions['activate'] = '<a href="' . $activate_link . '" class="activatelink" title="'
. esc_attr( sprintf( __( 'Activate “%s”' ), $title ) ) . '">' . __( 'Activate' ) . '</a>';
$actions['preview'] = '<a href="' . $preview_link . '" class="hide-if-customize" title="'
. esc_attr( sprintf( __( 'Preview “%s”' ), $title ) ) . '">' . __( 'Preview' ) . '</a>';
if ( current_user_can( 'edit_theme_options' ) )
$actions['preview'] .= '<a href="' . wp_customize_url( $stylesheet ) . '" class="load-customize hide-if-no-customize">'
. __( 'Live Preview' ) . '</a>';
if ( ! is_multisite() && current_user_can( 'delete_themes' ) )
$actions['delete'] = '<a class="submitdelete deletion" href="' . wp_nonce_url( "themes.php?action=delete&stylesheet=$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>';
$actions = apply_filters( 'theme_action_links', $actions, $theme );
$delete_action = isset( $actions['delete'] ) ? '<div class="delete-theme">' . $actions['delete'] . '</div>' : '';
unset( $actions['delete'] );
?>
<a href="<?php echo $preview_link; ?>" class="screenshot hide-if-customize">
<?php if ( $screenshot = $theme->get_screenshot() ) : ?>
<img src="<?php echo esc_url( $screenshot ); ?>" alt="" />
<?php endif; ?>
</a>
<a href="<?php echo wp_customize_url( $stylesheet ); ?>" class="screenshot load-customize hide-if-no-customize">
<?php if ( $screenshot = $theme->get_screenshot() ) : ?>
<img src="<?php echo esc_url( $screenshot ); ?>" alt="" />
<?php endif; ?>
</a>
<h3><?php echo $title; ?></h3>
<div class="theme-author"><?php printf( __( 'By %s' ), $author ); ?></div>
<div class="action-links">
<ul>
<?php foreach ( $actions as $action ): ?>
<li><?php echo $action; ?></li>
<?php endforeach; ?>
<li class="hide-if-no-js"><a href="#" class="theme-detail" tabindex='4'><?php _e('Details') ?></a></li>
</ul>
<?php echo $delete_action; ?>
<?php theme_update_available( $theme ); ?>
</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 ( current_user_can( 'edit_themes' ) && $theme->parent() ) :
/* translators: 1: theme title, 2: template dir, 3: stylesheet_dir, 4: theme title, 5: parent_theme */ ?>
<p><?php printf( __( 'The template files are located in <code>%2$s</code>. The stylesheet files are located in <code>%3$s</code>. <strong>%4$s</strong> uses templates from <strong>%5$s</strong>. Changes made to the templates will affect both themes.' ),
$title, str_replace( WP_CONTENT_DIR, '', $theme->get_template_directory() ), str_replace( WP_CONTENT_DIR, '', $theme->get_stylesheet_directory() ), $title, $theme->parent()->display('Name') ); ?></p>
<?php else :
/* translators: 1: theme title, 2: template dir, 3: stylesheet_dir */ ?>
<p><?php printf( __( 'All of this theme’s files are located in <code>%2$s</code>.' ),
$title, str_replace( WP_CONTENT_DIR, '', $theme->get_template_directory() ), str_replace( WP_CONTENT_DIR, '', $theme->get_stylesheet_directory() ) ); ?></p>
<?php endif; ?>
</div>
</div>
<?php
endforeach;
}
function search_theme( $theme ) {
// Search the features
foreach ( $this->features as $word ) {
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') ) )
continue;
foreach ( array( 'Name', 'Description', 'Author', 'AuthorURI' ) as $header ) {
// Don't mark up; Do translate.
if ( false !== stripos( $theme->display( $header, false, true ), $word ) )
continue 2;
}
if ( false !== stripos( $theme->get_stylesheet(), $word ) )
continue;
if ( false !== stripos( $theme->get_template(), $word ) )
continue;
return false;
}
return true;
}
/**
* Send required variables to JavaScript land
*
* @since 3.4
* @access private
*
* @uses $this->features Array of all feature search terms.
* @uses get_pagenum()
* @uses _pagination_args['total_pages']
*/
function _js_vars( $extra_args = array() ) {
$search_string = isset( $_REQUEST['s'] ) ? esc_attr( stripslashes( $_REQUEST['s'] ) ) : '';
$args = array(
'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 ) )
$args = array_merge( $args, $extra_args );
printf( "<script type='text/javascript'>var theme_list_args = %s;</script>\n", json_encode( $args ) );
parent::_js_vars();
}
}
| 01happy-blog | trunk/myblog/wp-admin/includes/class-wp-themes-list-table.php | PHP | oos | 9,406 |
<?php
/**
* Misc WordPress Administration API.
*
* @package WordPress
* @subpackage Administration
*/
/**
* {@internal Missing Short Description}}
*
* @since 2.0.0
*
* @return unknown
*/
function got_mod_rewrite() {
$got_rewrite = apache_mod_loaded('mod_rewrite', true);
return apply_filters('got_rewrite', $got_rewrite);
}
/**
* {@internal Missing Short Description}}
*
* @since 1.5.0
*
* @param unknown_type $filename
* @param unknown_type $marker
* @return array An array of strings from a file (.htaccess ) from between BEGIN and END markers.
*/
function extract_from_markers( $filename, $marker ) {
$result = array ();
if (!file_exists( $filename ) ) {
return $result;
}
if ( $markerdata = explode( "\n", implode( '', file( $filename ) ) ));
{
$state = false;
foreach ( $markerdata as $markerline ) {
if (strpos($markerline, '# END ' . $marker) !== false)
$state = false;
if ( $state )
$result[] = $markerline;
if (strpos($markerline, '# BEGIN ' . $marker) !== false)
$state = true;
}
}
return $result;
}
/**
* {@internal Missing Short Description}}
*
* Inserts an array of strings into a file (.htaccess ), placing it between
* BEGIN and END markers. Replaces existing marked info. Retains surrounding
* data. Creates file if none exists.
*
* @since 1.5.0
*
* @param unknown_type $filename
* @param unknown_type $marker
* @param unknown_type $insertion
* @return bool True on write success, false on failure.
*/
function insert_with_markers( $filename, $marker, $insertion ) {
if (!file_exists( $filename ) || is_writeable( $filename ) ) {
if (!file_exists( $filename ) ) {
$markerdata = '';
} else {
$markerdata = explode( "\n", implode( '', file( $filename ) ) );
}
if ( !$f = @fopen( $filename, 'w' ) )
return false;
$foundit = false;
if ( $markerdata ) {
$state = true;
foreach ( $markerdata as $n => $markerline ) {
if (strpos($markerline, '# BEGIN ' . $marker) !== false)
$state = false;
if ( $state ) {
if ( $n + 1 < count( $markerdata ) )
fwrite( $f, "{$markerline}\n" );
else
fwrite( $f, "{$markerline}" );
}
if (strpos($markerline, '# END ' . $marker) !== false) {
fwrite( $f, "# BEGIN {$marker}\n" );
if ( is_array( $insertion ))
foreach ( $insertion as $insertline )
fwrite( $f, "{$insertline}\n" );
fwrite( $f, "# END {$marker}\n" );
$state = true;
$foundit = true;
}
}
}
if (!$foundit) {
fwrite( $f, "\n# BEGIN {$marker}\n" );
foreach ( $insertion as $insertline )
fwrite( $f, "{$insertline}\n" );
fwrite( $f, "# END {$marker}\n" );
}
fclose( $f );
return true;
} else {
return false;
}
}
/**
* Updates the htaccess file with the current rules if it is writable.
*
* Always writes to the file if it exists and is writable to ensure that we
* blank out old rules.
*
* @since 1.5.0
*/
function save_mod_rewrite_rules() {
if ( is_multisite() )
return;
global $wp_rewrite;
$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 ( got_mod_rewrite() ) {
$rules = explode( "\n", $wp_rewrite->mod_rewrite_rules() );
return insert_with_markers( $htaccess_file, 'WordPress', $rules );
}
}
return false;
}
/**
* Updates the IIS web.config file with the current rules if it is writable.
* If the permalinks do not require rewrite rules then the rules are deleted from the web.config file.
*
* @since 2.8.0
*
* @return bool True if web.config was updated successfully
*/
function iis7_save_url_rewrite_rules(){
if ( is_multisite() )
return;
global $wp_rewrite;
$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);
} else {
return iis7_delete_rewrite_rule($web_config_file);
}
}
return false;
}
/**
* {@internal Missing Short Description}}
*
* @since 1.5.0
*
* @param unknown_type $file
*/
function update_recently_edited( $file ) {
$oldfiles = (array ) get_option( 'recently_edited' );
if ( $oldfiles ) {
$oldfiles = array_reverse( $oldfiles );
$oldfiles[] = $file;
$oldfiles = array_reverse( $oldfiles );
$oldfiles = array_unique( $oldfiles );
if ( 5 < count( $oldfiles ))
array_pop( $oldfiles );
} else {
$oldfiles[] = $file;
}
update_option( 'recently_edited', $oldfiles );
}
/**
* If siteurl or home changed, flush rewrite rules.
*
* @since 2.1.0
*
* @param string $old_value
* @param string $value
*/
function update_home_siteurl( $old_value, $value ) {
if ( defined( "WP_INSTALLING" ) )
return;
// If home changed, write rewrite rules to new location.
flush_rewrite_rules();
}
add_action( 'update_option_home', 'update_home_siteurl', 10, 2 );
add_action( 'update_option_siteurl', 'update_home_siteurl', 10, 2 );
/**
* Shorten an URL, to be used as link text
*
* @since 1.2.1
*
* @param string $url
* @return string
*/
function url_shorten( $url ) {
$short_url = str_replace( 'http://', '', stripslashes( $url ));
$short_url = str_replace( 'www.', '', $short_url );
$short_url = untrailingslashit( $short_url );
if ( strlen( $short_url ) > 35 )
$short_url = substr( $short_url, 0, 32 ) . '...';
return $short_url;
}
/**
* Resets global variables based on $_GET and $_POST
*
* This function resets global variables based on the names passed
* in the $vars array to the value of $_POST[$var] or $_GET[$var] or ''
* if neither is defined.
*
* @since 2.0.0
*
* @param array $vars An array of globals to reset.
*/
function wp_reset_vars( $vars ) {
for ( $i=0; $i<count( $vars ); $i += 1 ) {
$var = $vars[$i];
global $$var;
if ( empty( $_POST[$var] ) ) {
if ( empty( $_GET[$var] ) )
$$var = '';
else
$$var = $_GET[$var];
} else {
$$var = $_POST[$var];
}
}
}
/**
* {@internal Missing Short Description}}
*
* @since 2.1.0
*
* @param unknown_type $message
*/
function show_message($message) {
if ( is_wp_error($message) ){
if ( $message->get_error_data() )
$message = $message->get_error_message() . ': ' . $message->get_error_data();
else
$message = $message->get_error_message();
}
echo "<p>$message</p>\n";
wp_ob_end_flush_all();
flush();
}
function wp_doc_link_parse( $content ) {
if ( !is_string( $content ) || empty( $content ) )
return array();
if ( !function_exists('token_get_all') )
return array();
$tokens = token_get_all( $content );
$functions = array();
$ignore_functions = array();
for ( $t = 0, $count = count( $tokens ); $t < $count; $t++ ) {
if ( !is_array( $tokens[$t] ) ) continue;
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];
}
// Add this to our stack of unique references
$functions[] = $tokens[$t][1];
}
}
$functions = array_unique( $functions );
sort( $functions );
$ignore_functions = apply_filters( 'documentation_ignore_functions', $ignore_functions );
$ignore_functions = array_unique( $ignore_functions );
$out = array();
foreach ( $functions as $function ) {
if ( in_array( $function, $ignore_functions ) )
continue;
$out[] = $function;
}
return $out;
}
/**
* Saves option for number of rows when listing posts, pages, comments, etc.
*
* @since 2.8
**/
function set_screen_options() {
if ( isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options']) ) {
check_admin_referer( 'screen-options-nonce', 'screenoptionnonce' );
if ( !$user = wp_get_current_user() )
return;
$option = $_POST['wp_screen_options']['option'];
$value = $_POST['wp_screen_options']['value'];
if ( !preg_match( '/^[a-z_-]+$/', $option ) )
return;
$option = str_replace('-', '_', $option);
$map_option = $option;
$type = str_replace('edit_', '', $map_option);
$type = str_replace('_per_page', '', $type);
if ( in_array($type, get_post_types()) )
$map_option = 'edit_per_page';
if ( in_array( $type, get_taxonomies()) )
$map_option = 'edit_tags_per_page';
switch ( $map_option ) {
case 'edit_per_page':
case 'users_per_page':
case 'edit_comments_per_page':
case 'upload_per_page':
case 'edit_tags_per_page':
case 'plugins_per_page':
// Network admin
case 'sites_network_per_page':
case 'users_network_per_page':
case 'site_users_network_per_page':
case 'plugins_network_per_page':
case 'themes_network_per_page':
case 'site_themes_network_per_page':
$value = (int) $value;
if ( $value < 1 || $value > 999 )
return;
break;
default:
$value = apply_filters('set-screen-option', false, $option, $value);
if ( false === $value )
return;
break;
}
update_user_meta($user->ID, $option, $value);
wp_safe_redirect( remove_query_arg( array('pagenum', 'apage', 'paged'), wp_get_referer() ) );
exit;
}
}
/**
* Check if rewrite rule for WordPress already exists in the IIS 7 configuration file
*
* @since 2.8.0
*
* @return bool
* @param string $filename The file path to the configuration file
*/
function iis7_rewrite_rule_exists($filename) {
if ( ! file_exists($filename) )
return false;
if ( ! class_exists('DOMDocument') )
return false;
$doc = new DOMDocument();
if ( $doc->load($filename) === false )
return false;
$xpath = new DOMXPath($doc);
$rules = $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')]');
if ( $rules->length == 0 )
return false;
else
return true;
}
/**
* Delete WordPress rewrite rule from web.config file if it exists there
*
* @since 2.8.0
*
* @param string $filename Name of the configuration file
* @return bool
*/
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) )
return true;
if ( ! class_exists('DOMDocument') )
return false;
$doc = new DOMDocument();
$doc->preserveWhiteSpace = 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\')]');
if ( $rules->length > 0 ) {
$child = $rules->item(0);
$parent = $child->parentNode;
$parent->removeChild($child);
$doc->formatOutput = true;
saveDomDocument($doc, $filename);
}
return true;
}
/**
* Add WordPress rewrite rule to the IIS 7 configuration file.
*
* @since 2.8.0
*
* @param string $filename The file path to the configuration file
* @param string $rewrite_rule The XML fragment with URL Rewrite rule
* @return bool
*/
function iis7_add_rewrite_rule($filename, $rewrite_rule) {
if ( ! class_exists('DOMDocument') )
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);
}
$doc = new DOMDocument();
$doc->preserveWhiteSpace = false;
if ( $doc->load($filename) === false )
return false;
$xpath = new DOMXPath($doc);
// First check if the rule already exists as in that case there is no need to re-add it
$wordpress_rules = $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')]');
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');
if ( $xmlnodes->length > 0 ) {
$rules_node = $xmlnodes->item(0);
} else {
$rules_node = $doc->createElement('rules');
$xmlnodes = $xpath->query('/configuration/system.webServer/rewrite');
if ( $xmlnodes->length > 0 ) {
$rewrite_node = $xmlnodes->item(0);
$rewrite_node->appendChild($rules_node);
} else {
$rewrite_node = $doc->createElement('rewrite');
$rewrite_node->appendChild($rules_node);
$xmlnodes = $xpath->query('/configuration/system.webServer');
if ( $xmlnodes->length > 0 ) {
$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);
$xmlnodes = $xpath->query('/configuration');
if ( $xmlnodes->length > 0 ) {
$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);
}
}
}
}
$rule_fragment = $doc->createDocumentFragment();
$rule_fragment->appendXML($rewrite_rule);
$rules_node->appendChild($rule_fragment);
$doc->encoding = "UTF-8";
$doc->formatOutput = true;
saveDomDocument($doc, $filename);
return true;
}
/**
* Saves the XML document into a file
*
* @since 2.8.0
*
* @param DOMDocument $doc
* @param string $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);
}
/**
* Workaround for Windows bug in is_writable() function
*
* @since 2.8.0
*
* @param string $path
* @return bool
*/
function win_is_writable( $path ) {
/* will work in despite of Windows ACLs bug
* NOTE: use a trailing slash for folders!!!
* see http://bugs.php.net/bug.php?id=27609
* see http://bugs.php.net/bug.php?id=30931
*/
if ( $path[strlen( $path ) - 1] == '/' ) // recursively return a temporary file path
return win_is_writable( $path . uniqid( mt_rand() ) . '.tmp');
else if ( is_dir( $path ) )
return win_is_writable( $path . '/' . uniqid( mt_rand() ) . '.tmp' );
// check tmp file for read/write capabilities
$should_delete_tmp_file = !file_exists( $path );
$f = @fopen( $path, 'a' );
if ( $f === false )
return false;
fclose( $f );
if ( $should_delete_tmp_file )
unlink( $path );
return true;
}
/**
* Display the default admin color scheme picker (Used in user-edit.php)
*
* @since 3.0.0
*/
function admin_color_scheme_picker() {
global $_wp_admin_css_colors, $user_id; ?>
<fieldset><legend class="screen-reader-text"><span><?php _e('Admin Color Scheme')?></span></legend>
<?php
$current_color = get_user_option('admin_color', $user_id);
if ( empty($current_color) )
$current_color = 'fresh';
foreach ( $_wp_admin_css_colors as $color => $color_info ): ?>
<div class="color-option"><input name="admin_color" id="admin_color_<?php echo $color; ?>" type="radio" value="<?php echo esc_attr($color) ?>" class="tog" <?php checked($color, $current_color); ?> />
<table class="color-palette">
<tr>
<?php foreach ( $color_info->colors as $html_color ): ?>
<td style="background-color: <?php echo $html_color ?>" title="<?php echo $color ?>"> </td>
<?php endforeach; ?>
</tr>
</table>
<label for="admin_color_<?php echo $color; ?>"><?php echo $color_info->name ?></label>
</div>
<?php endforeach; ?>
</fieldset>
<?php
}
function _ipad_meta() {
if ( wp_is_mobile() ) {
?>
<meta name="viewport" id="viewport-meta" content="width=device-width, initial-scale=1">
<?php
}
}
add_action('admin_head', '_ipad_meta');
| 01happy-blog | trunk/myblog/wp-admin/includes/misc.php | PHP | oos | 16,270 |
<?php
/**
* Template WordPress Administration API.
*
* A Big Mess. Also some neat functions that are nicely written.
*
* @package WordPress
* @subpackage Administration
*/
//
// Category Checklists
//
/**
* Walker to output an unordered list of category checkbox <input> elements.
*
* @see Walker
* @see wp_category_checklist()
* @see wp_terms_checklist()
* @since 2.5.1
*/
class Walker_Category_Checklist extends Walker {
var $tree_type = 'category';
var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this
function start_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat("\t", $depth);
$output .= "$indent<ul class='children'>\n";
}
function end_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat("\t", $depth);
$output .= "$indent</ul>\n";
}
function start_el( &$output, $category, $depth, $args, $id = 0 ) {
extract($args);
if ( empty($taxonomy) )
$taxonomy = 'category';
if ( $taxonomy == 'category' )
$name = 'post_category';
else
$name = 'tax_input['.$taxonomy.']';
$class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category"' : '';
$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 . '"' . checked( in_array( $category->term_id, $selected_cats ), true, false ) . disabled( empty( $args['disabled'] ), false, false ) . ' /> ' . esc_html( apply_filters('the_category', $category->name )) . '</label>';
}
function end_el( &$output, $category, $depth = 0, $args = array() ) {
$output .= "</li>\n";
}
}
/**
* Output an unordered list of checkbox <input> elements labelled
* with category names.
*
* @see wp_terms_checklist()
* @since 2.5.1
*
* @param int $post_id Mark categories associated with this post as checked. $selected_cats must not be an array.
* @param int $descendants_and_self ID of the category to output along with its descendents.
* @param bool|array $selected_cats List of categories to mark as checked.
* @param bool|array $popular_cats Override the list of categories that receive the "popular-category" class.
* @param object $walker Walker object to use to build the output.
* @param bool $checked_ontop Move checked items out of the hierarchy and to the top of the list.
*/
function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null, $checked_ontop = true ) {
wp_terms_checklist( $post_id, array(
'taxonomy' => 'category',
'descendants_and_self' => $descendants_and_self,
'selected_cats' => $selected_cats,
'popular_cats' => $popular_cats,
'walker' => $walker,
'checked_ontop' => $checked_ontop
) );
}
/**
* Output an unordered list of checkbox <input> elements labelled
* with term names. Taxonomy independent version of wp_category_checklist().
*
* @since 3.0.0
*
* @param int $post_id
* @param array $args
*/
function wp_terms_checklist($post_id = 0, $args = array()) {
$defaults = array(
'descendants_and_self' => 0,
'selected_cats' => false,
'popular_cats' => false,
'walker' => null,
'taxonomy' => 'category',
'checked_ontop' => true
);
$args = apply_filters( 'wp_terms_checklist_args', $args, $post_id );
extract( wp_parse_args($args, $defaults), EXTR_SKIP );
if ( empty($walker) || !is_a($walker, 'Walker') )
$walker = new Walker_Category_Checklist;
$descendants_and_self = (int) $descendants_and_self;
$args = array('taxonomy' => $taxonomy);
$tax = get_taxonomy($taxonomy);
$args['disabled'] = !current_user_can($tax->cap->assign_terms);
if ( is_array( $selected_cats ) )
$args['selected_cats'] = $selected_cats;
elseif ( $post_id )
$args['selected_cats'] = wp_get_object_terms($post_id, $taxonomy, array_merge($args, array('fields' => 'ids')));
else
$args['selected_cats'] = array();
if ( is_array( $popular_cats ) )
$args['popular_cats'] = $popular_cats;
else
$args['popular_cats'] = get_terms( $taxonomy, array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) );
if ( $descendants_and_self ) {
$categories = (array) get_terms($taxonomy, array( 'child_of' => $descendants_and_self, 'hierarchical' => 0, 'hide_empty' => 0 ) );
$self = get_term( $descendants_and_self, $taxonomy );
array_unshift( $categories, $self );
} else {
$categories = (array) get_terms($taxonomy, array('get' => 'all'));
}
if ( $checked_ontop ) {
// Post process $categories rather than adding an exclude to the get_terms() query to keep the query the same across all posts (for any query cache)
$checked_categories = array();
$keys = array_keys( $categories );
foreach( $keys as $k ) {
if ( in_array( $categories[$k]->term_id, $args['selected_cats'] ) ) {
$checked_categories[] = $categories[$k];
unset( $categories[$k] );
}
}
// Put checked cats on top
echo call_user_func_array(array(&$walker, 'walk'), array($checked_categories, 0, $args));
}
// Then the rest of them
echo call_user_func_array(array(&$walker, 'walk'), array($categories, 0, $args));
}
/**
* Retrieve a list of the most popular terms from the specified taxonomy.
*
* If the $echo argument is true then the elements for a list of checkbox
* <input> elements labelled with the names of the selected terms is output.
* If the $post_ID global isn't empty then the terms associated with that
* post will be marked as checked.
*
* @since 2.5.0
*
* @param string $taxonomy Taxonomy to retrieve terms from.
* @param int $default Unused.
* @param int $number Number of terms to retrieve. Defaults to 10.
* @param bool $echo Optionally output the list as well. Defaults to true.
* @return array List of popular term IDs.
*/
function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) {
global $post_ID;
if ( $post_ID )
$checked_terms = wp_get_object_terms($post_ID, $taxonomy, array('fields'=>'ids'));
else
$checked_terms = array();
$terms = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number, 'hierarchical' => false ) );
$tax = get_taxonomy($taxonomy);
if ( ! current_user_can($tax->cap->assign_terms) )
$disabled = 'disabled="disabled"';
else
$disabled = '';
$popular_ids = array();
foreach ( (array) $terms as $term ) {
$popular_ids[] = $term->term_id;
if ( !$echo ) // hack for AJAX use
continue;
$id = "popular-$taxonomy-$term->term_id";
$checked = in_array( $term->term_id, $checked_terms ) ? 'checked="checked"' : '';
?>
<li id="<?php echo $id; ?>" class="popular-category">
<label class="selectit">
<input id="in-<?php echo $id; ?>" type="checkbox" <?php echo $checked; ?> value="<?php echo (int) $term->term_id; ?>" <?php echo $disabled ?>/>
<?php echo esc_html( apply_filters( 'the_category', $term->name ) ); ?>
</label>
</li>
<?php
}
return $popular_ids;
}
/**
* {@internal Missing Short Description}}
*
* @since 2.5.1
*
* @param unknown_type $link_id
*/
function wp_link_category_checklist( $link_id = 0 ) {
$default = 1;
if ( $link_id ) {
$checked_categories = wp_get_link_cats( $link_id );
// No selected categories, strange
if ( ! count( $checked_categories ) )
$checked_categories[] = $default;
} else {
$checked_categories[] = $default;
}
$categories = get_terms( 'link_category', array( 'orderby' => 'name', 'hide_empty' => 0 ) );
if ( empty( $categories ) )
return;
foreach ( $categories as $category ) {
$cat_id = $category->term_id;
$name = esc_html( apply_filters( 'the_category', $category->name ) );
$checked = in_array( $cat_id, $checked_categories ) ? ' checked="checked"' : '';
echo '<li id="link-category-', $cat_id, '"><label for="in-link-category-', $cat_id, '" class="selectit"><input value="', $cat_id, '" type="checkbox" name="link_category[]" id="in-link-category-', $cat_id, '"', $checked, '/> ', $name, "</label></li>";
}
}
// adds hidden fields with the data for use in the inline editor for posts and pages
/**
* {@internal Missing Short Description}}
*
* @since 2.7.0
*
* @param unknown_type $post
*/
function get_inline_data($post) {
$post_type_object = get_post_type_object($post->post_type);
if ( ! current_user_can($post_type_object->cap->edit_post, $post->ID) )
return;
$title = esc_textarea( trim( $post->post_title ) );
echo '
<div class="hidden" id="inline_' . $post->ID . '">
<div class="post_title">' . $title . '</div>
<div class="post_name">' . apply_filters('editable_slug', $post->post_name) . '</div>
<div class="post_author">' . $post->post_author . '</div>
<div class="comment_status">' . esc_html( $post->comment_status ) . '</div>
<div class="ping_status">' . esc_html( $post->ping_status ) . '</div>
<div class="_status">' . esc_html( $post->post_status ) . '</div>
<div class="jj">' . mysql2date( 'd', $post->post_date, false ) . '</div>
<div class="mm">' . mysql2date( 'm', $post->post_date, false ) . '</div>
<div class="aa">' . mysql2date( 'Y', $post->post_date, false ) . '</div>
<div class="hh">' . mysql2date( 'H', $post->post_date, false ) . '</div>
<div class="mn">' . mysql2date( 'i', $post->post_date, false ) . '</div>
<div class="ss">' . mysql2date( 's', $post->post_date, false ) . '</div>
<div class="post_password">' . esc_html( $post->post_password ) . '</div>';
if ( $post_type_object->hierarchical )
echo '<div class="post_parent">' . $post->post_parent . '</div>';
if ( $post->post_type == 'page' )
echo '<div class="page_template">' . esc_html( get_post_meta( $post->ID, '_wp_page_template', true ) ) . '</div>';
if ( post_type_supports( $post->post_type, 'page-attributes' ) )
echo '<div class="menu_order">' . $post->menu_order . '</div>';
$taxonomy_names = get_object_taxonomies( $post->post_type );
foreach ( $taxonomy_names as $taxonomy_name) {
$taxonomy = get_taxonomy( $taxonomy_name );
if ( $taxonomy->hierarchical && $taxonomy->show_ui ) {
echo '<div class="post_category" id="' . $taxonomy_name . '_' . $post->ID . '">'
. implode( ',', wp_get_object_terms( $post->ID, $taxonomy_name, array( 'fields' => 'ids' ) ) ) . '</div>';
} elseif ( $taxonomy->show_ui ) {
echo '<div class="tags_input" id="'.$taxonomy_name.'_'.$post->ID.'">'
. esc_html( str_replace( ',', ', ', get_terms_to_edit( $post->ID, $taxonomy_name ) ) ) . '</div>';
}
}
if ( !$post_type_object->hierarchical )
echo '<div class="sticky">' . (is_sticky($post->ID) ? 'sticky' : '') . '</div>';
if ( post_type_supports( $post->post_type, 'post-formats' ) )
echo '<div class="post_format">' . esc_html( get_post_format( $post->ID ) ) . '</div>';
echo '</div>';
}
/**
* {@internal Missing Short Description}}
*
* @since 2.7.0
*
* @param unknown_type $position
* @param unknown_type $checkbox
* @param unknown_type $mode
*/
function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single', $table_row = true) {
// allow plugin to replace the popup content
$content = apply_filters( 'wp_comment_reply', '', array('position' => $position, 'checkbox' => $checkbox, 'mode' => $mode) );
if ( ! empty($content) ) {
echo $content;
return;
}
if ( $mode == 'single' ) {
$wp_list_table = _get_list_table('WP_Post_Comments_List_Table');
} else {
$wp_list_table = _get_list_table('WP_Comments_List_Table');
}
?>
<form method="get" action="">
<?php if ( $table_row ) : ?>
<table style="display:none;"><tbody id="com-reply"><tr id="replyrow" style="display:none;"><td colspan="<?php echo $wp_list_table->get_column_count(); ?>" class="colspanchange">
<?php else : ?>
<div id="com-reply" style="display:none;"><div id="replyrow" style="display:none;">
<?php endif; ?>
<div id="replyhead" style="display:none;"><h5><?php _e( 'Reply to Comment' ); ?></h5></div>
<div id="addhead" style="display:none;"><h5><?php _e('Add new Comment'); ?></h5></div>
<div id="edithead" style="display:none;">
<div class="inside">
<label for="author"><?php _e('Name') ?></label>
<input type="text" name="newcomment_author" size="50" value="" tabindex="101" id="author" />
</div>
<div class="inside">
<label for="author-email"><?php _e('E-mail') ?></label>
<input type="text" name="newcomment_author_email" size="50" value="" tabindex="102" id="author-email" />
</div>
<div class="inside">
<label for="author-url"><?php _e('URL') ?></label>
<input type="text" id="author-url" name="newcomment_author_url" size="103" value="" tabindex="103" />
</div>
<div style="clear:both;"></div>
</div>
<div id="replycontainer">
<?php
$quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,spell,close' );
wp_editor( '', 'replycontent', array( 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings, 'tabindex' => 104 ) );
?>
</div>
<p id="replysubmit" class="submit">
<a href="#comments-form" class="cancel button-secondary alignleft" tabindex="106"><?php _e('Cancel'); ?></a>
<a href="#comments-form" class="save button-primary alignright" tabindex="104">
<span id="addbtn" style="display:none;"><?php _e('Add Comment'); ?></span>
<span id="savebtn" style="display:none;"><?php _e('Update Comment'); ?></span>
<span id="replybtn" style="display:none;"><?php _e('Submit Reply'); ?></span></a>
<img class="waiting" style="display:none;" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
<span class="error" style="display:none;"></span>
<br class="clear" />
</p>
<input type="hidden" name="user_ID" id="user_ID" value="<?php echo get_current_user_id(); ?>" />
<input type="hidden" name="action" id="action" value="" />
<input type="hidden" name="comment_ID" id="comment_ID" value="" />
<input type="hidden" name="comment_post_ID" id="comment_post_ID" value="" />
<input type="hidden" name="status" id="status" value="" />
<input type="hidden" name="position" id="position" value="<?php echo $position; ?>" />
<input type="hidden" name="checkbox" id="checkbox" value="<?php echo $checkbox ? 1 : 0; ?>" />
<input type="hidden" name="mode" id="mode" value="<?php echo esc_attr($mode); ?>" />
<?php
wp_nonce_field( 'replyto-comment', '_ajax_nonce-replyto-comment', false );
if ( current_user_can( 'unfiltered_html' ) )
wp_nonce_field( 'unfiltered-html-comment', '_wp_unfiltered_html_comment', false );
?>
<?php if ( $table_row ) : ?>
</td></tr></tbody></table>
<?php else : ?>
</div></div>
<?php endif; ?>
</form>
<?php
}
/**
* Output 'undo move to trash' text for comments
*
* @since 2.9.0
*/
function wp_comment_trashnotice() {
?>
<div class="hidden" id="trash-undo-holder">
<div class="trash-undo-inside"><?php printf(__('Comment by %s moved to the trash.'), '<strong></strong>'); ?> <span class="undo untrash"><a href="#"><?php _e('Undo'); ?></a></span></div>
</div>
<div class="hidden" id="spam-undo-holder">
<div class="spam-undo-inside"><?php printf(__('Comment by %s marked as spam.'), '<strong></strong>'); ?> <span class="undo unspam"><a href="#"><?php _e('Undo'); ?></a></span></div>
</div>
<?php
}
/**
* {@internal Missing Short Description}}
*
* @since 1.2.0
*
* @param unknown_type $meta
*/
function list_meta( $meta ) {
// Exit if no meta
if ( ! $meta ) {
echo '
<table id="list-table" style="display: none;">
<thead>
<tr>
<th class="left">' . _x( 'Name', 'meta name' ) . '</th>
<th>' . __( 'Value' ) . '</th>
</tr>
</thead>
<tbody id="the-list" class="list:meta">
<tr><td></td></tr>
</tbody>
</table>'; //TBODY needed for list-manipulation JS
return;
}
$count = 0;
?>
<table id="list-table">
<thead>
<tr>
<th class="left"><?php _ex( 'Name', 'meta name' ) ?></th>
<th><?php _e( 'Value' ) ?></th>
</tr>
</thead>
<tbody id='the-list' class='list:meta'>
<?php
foreach ( $meta as $entry )
echo _list_meta_row( $entry, $count );
?>
</tbody>
</table>
<?php
}
/**
* {@internal Missing Short Description}}
*
* @since 2.5.0
*
* @param unknown_type $entry
* @param unknown_type $count
* @return unknown
*/
function _list_meta_row( $entry, &$count ) {
static $update_nonce = false;
if ( is_protected_meta( $entry['meta_key'], 'post' ) )
return;
if ( !$update_nonce )
$update_nonce = wp_create_nonce( 'add-meta' );
$r = '';
++ $count;
if ( $count % 2 )
$style = 'alternate';
else
$style = '';
if ( is_serialized( $entry['meta_value'] ) ) {
if ( is_serialized_string( $entry['meta_value'] ) ) {
// this is a serialized string, so we should display it
$entry['meta_value'] = maybe_unserialize( $entry['meta_value'] );
} else {
// this is a serialized array/object so we should NOT display it
--$count;
return;
}
}
$entry['meta_key'] = esc_attr($entry['meta_key']);
$entry['meta_value'] = esc_textarea( $entry['meta_value'] ); // using a <textarea />
$entry['meta_id'] = (int) $entry['meta_id'];
$delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] );
$r .= "\n\t<tr id='meta-{$entry['meta_id']}' class='$style'>";
$r .= "\n\t\t<td class='left'><label class='screen-reader-text' for='meta[{$entry['meta_id']}][key]'>" . __( 'Key' ) . "</label><input name='meta[{$entry['meta_id']}][key]' id='meta[{$entry['meta_id']}][key]' tabindex='6' type='text' size='20' value='{$entry['meta_key']}' />";
$r .= "\n\t\t<div class='submit'>";
$r .= get_submit_button( __( 'Delete' ), "delete:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$delete_nonce deletemeta", "deletemeta[{$entry['meta_id']}]", false, array( 'tabindex' => '6' ) );
$r .= "\n\t\t";
$r .= get_submit_button( __( 'Update' ), "add:the-list:meta-{$entry['meta_id']}::_ajax_nonce-add-meta=$update_nonce updatemeta" , 'updatemeta', false, array( 'tabindex' => '6' ) );
$r .= "</div>";
$r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false );
$r .= "</td>";
$r .= "\n\t\t<td><label class='screen-reader-text' for='meta[{$entry['meta_id']}][value]'>" . __( 'Value' ) . "</label><textarea name='meta[{$entry['meta_id']}][value]' id='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>\n\t</tr>";
return $r;
}
/**
* {@internal Missing Short Description}}
*
* @since 1.2.0
*/
function meta_form() {
global $wpdb;
$limit = (int) apply_filters( 'postmeta_form_limit', 30 );
$keys = $wpdb->get_col( "
SELECT meta_key
FROM $wpdb->postmeta
GROUP BY meta_key
HAVING meta_key NOT LIKE '\_%'
ORDER BY meta_key
LIMIT $limit" );
if ( $keys )
natcasesort($keys);
?>
<p><strong><?php _e( 'Add New Custom Field:' ) ?></strong></p>
<table id="newmeta">
<thead>
<tr>
<th class="left"><label for="metakeyselect"><?php _ex( 'Name', 'meta name' ) ?></label></th>
<th><label for="metavalue"><?php _e( 'Value' ) ?></label></th>
</tr>
</thead>
<tbody>
<tr>
<td id="newmetaleft" class="left">
<?php if ( $keys ) { ?>
<select id="metakeyselect" name="metakeyselect" tabindex="7">
<option value="#NONE#"><?php _e( '— Select —' ); ?></option>
<?php
foreach ( $keys as $key ) {
echo "\n<option value='" . esc_attr($key) . "'>" . esc_html($key) . "</option>";
}
?>
</select>
<input class="hide-if-js" type="text" id="metakeyinput" name="metakeyinput" tabindex="7" value="" />
<a href="#postcustomstuff" class="hide-if-no-js" onclick="jQuery('#metakeyinput, #metakeyselect, #enternew, #cancelnew').toggle();return false;">
<span id="enternew"><?php _e('Enter new'); ?></span>
<span id="cancelnew" class="hidden"><?php _e('Cancel'); ?></span></a>
<?php } else { ?>
<input type="text" id="metakeyinput" name="metakeyinput" tabindex="7" value="" />
<?php } ?>
</td>
<td><textarea id="metavalue" name="metavalue" rows="2" cols="25" tabindex="8"></textarea></td>
</tr>
<tr><td colspan="2" class="submit">
<?php submit_button( __( 'Add Custom Field' ), 'add:the-list:newmeta', 'addmeta', false, array( 'id' => 'addmetasub', 'tabindex' => '9' ) ); ?>
<?php wp_nonce_field( 'add-meta', '_ajax_nonce-add-meta', false ); ?>
</td></tr>
</tbody>
</table>
<?php
}
/**
* {@internal Missing Short Description}}
*
* @since 0.71
*
* @param unknown_type $edit
* @param unknown_type $for_post
* @param unknown_type $tab_index
* @param unknown_type $multi
*/
function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
global $wp_locale, $post, $comment;
if ( $for_post )
$edit = ! ( in_array($post->post_status, array('draft', 'pending') ) && (!$post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt ) );
$tab_index_attribute = '';
if ( (int) $tab_index > 0 )
$tab_index_attribute = " tabindex=\"$tab_index\"";
// echo '<label for="timestamp" style="display: block;"><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp"'.$tab_index_attribute.' /> '.__( 'Edit timestamp' ).'</label><br />';
$time_adj = current_time('timestamp');
$post_date = ($for_post) ? $post->post_date : $comment->comment_date;
$jj = ($edit) ? mysql2date( 'd', $post_date, false ) : gmdate( 'd', $time_adj );
$mm = ($edit) ? mysql2date( 'm', $post_date, false ) : gmdate( 'm', $time_adj );
$aa = ($edit) ? mysql2date( 'Y', $post_date, false ) : gmdate( 'Y', $time_adj );
$hh = ($edit) ? mysql2date( 'H', $post_date, false ) : gmdate( 'H', $time_adj );
$mn = ($edit) ? mysql2date( 'i', $post_date, false ) : gmdate( 'i', $time_adj );
$ss = ($edit) ? mysql2date( 's', $post_date, false ) : gmdate( 's', $time_adj );
$cur_jj = gmdate( 'd', $time_adj );
$cur_mm = gmdate( 'm', $time_adj );
$cur_aa = gmdate( 'Y', $time_adj );
$cur_hh = gmdate( 'H', $time_adj );
$cur_mn = gmdate( 'i', $time_adj );
$month = "<select " . ( $multi ? '' : 'id="mm" ' ) . "name=\"mm\"$tab_index_attribute>\n";
for ( $i = 1; $i < 13; $i = $i +1 ) {
$monthnum = zeroise($i, 2);
$month .= "\t\t\t" . '<option value="' . $monthnum . '"';
if ( $i == $mm )
$month .= ' selected="selected"';
/* translators: 1: month number (01, 02, etc.), 2: month abbreviation */
$month .= '>' . sprintf( __( '%1$s-%2$s' ), $monthnum, $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ) ) . "</option>\n";
}
$month .= '</select>';
$day = '<input type="text" ' . ( $multi ? '' : 'id="jj" ' ) . 'name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
$year = '<input type="text" ' . ( $multi ? '' : 'id="aa" ' ) . 'name="aa" value="' . $aa . '" size="4" maxlength="4"' . $tab_index_attribute . ' autocomplete="off" />';
$hour = '<input type="text" ' . ( $multi ? '' : 'id="hh" ' ) . 'name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
$minute = '<input type="text" ' . ( $multi ? '' : 'id="mn" ' ) . 'name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
echo '<div class="timestamp-wrap">';
/* translators: 1: month input, 2: day input, 3: year input, 4: hour input, 5: minute input */
printf(__('%1$s%2$s, %3$s @ %4$s : %5$s'), $month, $day, $year, $hour, $minute);
echo '</div><input type="hidden" id="ss" name="ss" value="' . $ss . '" />';
if ( $multi ) return;
echo "\n\n";
foreach ( array('mm', 'jj', 'aa', 'hh', 'mn') as $timeunit ) {
echo '<input type="hidden" id="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . $$timeunit . '" />' . "\n";
$cur_timeunit = 'cur_' . $timeunit;
echo '<input type="hidden" id="'. $cur_timeunit . '" name="'. $cur_timeunit . '" value="' . $$cur_timeunit . '" />' . "\n";
}
?>
<p>
<a href="#edit_timestamp" class="save-timestamp hide-if-no-js button"><?php _e('OK'); ?></a>
<a href="#edit_timestamp" class="cancel-timestamp hide-if-no-js"><?php _e('Cancel'); ?></a>
</p>
<?php
}
/**
* {@internal Missing Short Description}}
*
* @since 1.5.0
*
* @param unknown_type $default
*/
function page_template_dropdown( $default = '' ) {
$templates = get_page_templates();
ksort( $templates );
foreach (array_keys( $templates ) as $template )
: if ( $default == $templates[$template] )
$selected = " selected='selected'";
else
$selected = '';
echo "\n\t<option value='".$templates[$template]."' $selected>$template</option>";
endforeach;
}
/**
* {@internal Missing Short Description}}
*
* @since 1.5.0
*
* @param unknown_type $default
* @param unknown_type $parent
* @param unknown_type $level
* @return unknown
*/
function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) {
global $wpdb, $post_ID;
$items = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' ORDER BY menu_order", $parent) );
if ( $items ) {
foreach ( $items as $item ) {
// A page cannot be its own parent.
if (!empty ( $post_ID ) ) {
if ( $item->ID == $post_ID ) {
continue;
}
}
$pad = str_repeat( ' ', $level * 3 );
if ( $item->ID == $default)
$current = ' selected="selected"';
else
$current = '';
echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad " . esc_html($item->post_title) . "</option>";
parent_dropdown( $default, $item->ID, $level +1 );
}
} else {
return false;
}
}
/**
* {@internal Missing Short Description}}
*
* @since 2.0.0
*
* @param unknown_type $id
* @return unknown
*/
function the_attachment_links( $id = false ) {
$id = (int) $id;
$post = & get_post( $id );
if ( $post->post_type != 'attachment' )
return false;
$icon = wp_get_attachment_image( $post->ID, 'thumbnail', true );
$attachment_data = wp_get_attachment_metadata( $id );
$thumb = isset( $attachment_data['thumb'] );
?>
<form id="the-attachment-links">
<table>
<col />
<col class="widefat" />
<tr>
<th scope="row"><?php _e( 'URL' ) ?></th>
<td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><?php echo esc_textarea( wp_get_attachment_url() ); ?></textarea></td>
</tr>
<?php if ( $icon ) : ?>
<tr>
<th scope="row"><?php $thumb ? _e( 'Thumbnail linked to file' ) : _e( 'Image linked to file' ); ?></th>
<td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo wp_get_attachment_url(); ?>"><?php echo $icon ?></a></textarea></td>
</tr>
<tr>
<th scope="row"><?php $thumb ? _e( 'Thumbnail linked to page' ) : _e( 'Image linked to page' ); ?></th>
<td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link( $post->ID ) ?>" rel="attachment wp-att-<?php echo $post->ID; ?>"><?php echo $icon ?></a></textarea></td>
</tr>
<?php else : ?>
<tr>
<th scope="row"><?php _e( 'Link to file' ) ?></th>
<td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo wp_get_attachment_url(); ?>" class="attachmentlink"><?php echo basename( wp_get_attachment_url() ); ?></a></textarea></td>
</tr>
<tr>
<th scope="row"><?php _e( 'Link to page' ) ?></th>
<td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link( $post->ID ) ?>" rel="attachment wp-att-<?php echo $post->ID ?>"><?php the_title(); ?></a></textarea></td>
</tr>
<?php endif; ?>
</table>
</form>
<?php
}
/**
* Print out <option> html elements for role selectors
*
* @since 2.1.0
*
* @param string $selected slug for the role that should be already selected
*/
function wp_dropdown_roles( $selected = false ) {
$p = '';
$r = '';
$editable_roles = get_editable_roles();
foreach ( $editable_roles as $role => $details ) {
$name = translate_user_role($details['name'] );
if ( $selected == $role ) // preselect specified role
$p = "\n\t<option selected='selected' value='" . esc_attr($role) . "'>$name</option>";
else
$r .= "\n\t<option value='" . esc_attr($role) . "'>$name</option>";
}
echo $p . $r;
}
/**
* {@internal Missing Short Description}}
*
* @since 2.3.0
*
* @param unknown_type $size
* @return unknown
*/
function wp_convert_hr_to_bytes( $size ) {
$size = strtolower($size);
$bytes = (int) $size;
if ( strpos($size, 'k') !== false )
$bytes = intval($size) * 1024;
elseif ( strpos($size, 'm') !== false )
$bytes = intval($size) * 1024 * 1024;
elseif ( strpos($size, 'g') !== false )
$bytes = intval($size) * 1024 * 1024 * 1024;
return $bytes;
}
/**
* {@internal Missing Short Description}}
*
* @since 2.3.0
*
* @param unknown_type $bytes
* @return unknown
*/
function wp_convert_bytes_to_hr( $bytes ) {
$units = array( 0 => 'B', 1 => 'kB', 2 => 'MB', 3 => 'GB' );
$log = log( $bytes, 1024 );
$power = (int) $log;
$size = pow(1024, $log - $power);
return $size . $units[$power];
}
/**
* {@internal Missing Short Description}}
*
* @since 2.5.0
*
* @return unknown
*/
function wp_max_upload_size() {
$u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize' ) );
$p_bytes = wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) );
$bytes = apply_filters( 'upload_size_limit', min($u_bytes, $p_bytes), $u_bytes, $p_bytes );
return $bytes;
}
/**
* Outputs the form used by the importers to accept the data to be imported
*
* @since 2.0.0
*
* @param string $action The action attribute for the form.
*/
function wp_import_upload_form( $action ) {
$bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() );
$size = wp_convert_bytes_to_hr( $bytes );
$upload_dir = wp_upload_dir();
if ( ! empty( $upload_dir['error'] ) ) :
?><div class="error"><p><?php _e('Before you can upload your import file, you will need to fix the following error:'); ?></p>
<p><strong><?php echo $upload_dir['error']; ?></strong></p></div><?php
else :
?>
<form enctype="multipart/form-data" id="import-upload-form" method="post" action="<?php echo esc_attr(wp_nonce_url($action, 'import-upload')); ?>">
<p>
<label for="upload"><?php _e( 'Choose a file from your computer:' ); ?></label> (<?php printf( __('Maximum size: %s' ), $size ); ?>)
<input type="file" id="upload" name="import" size="25" />
<input type="hidden" name="action" value="save" />
<input type="hidden" name="max_file_size" value="<?php echo $bytes; ?>" />
</p>
<?php submit_button( __('Upload file and import'), 'button' ); ?>
</form>
<?php
endif;
}
/**
* Add a meta box to an edit form.
*
* @since 2.5.0
*
* @param string $id String for use in the 'id' attribute of tags.
* @param string $title Title of the meta box.
* @param string $callback Function that fills the box with the desired content. The function should echo its output.
* @param string|object $screen Optional. The screen on which to show the box (post, page, link). Defaults to current screen.
* @param string $context Optional. The context within the page where the boxes should show ('normal', 'advanced').
* @param string $priority Optional. The priority within the context where the boxes should show ('high', 'low').
*/
function add_meta_box( $id, $title, $callback, $screen = null, $context = 'advanced', $priority = 'default', $callback_args = null ) {
global $wp_meta_boxes;
if ( empty( $screen ) )
$screen = get_current_screen();
elseif ( is_string( $screen ) )
$screen = convert_to_screen( $screen );
$page = $screen->id;
if ( !isset($wp_meta_boxes) )
$wp_meta_boxes = array();
if ( !isset($wp_meta_boxes[$page]) )
$wp_meta_boxes[$page] = array();
if ( !isset($wp_meta_boxes[$page][$context]) )
$wp_meta_boxes[$page][$context] = array();
foreach ( array_keys($wp_meta_boxes[$page]) as $a_context ) {
foreach ( array('high', 'core', 'default', 'low') as $a_priority ) {
if ( !isset($wp_meta_boxes[$page][$a_context][$a_priority][$id]) )
continue;
// If a core box was previously added or removed by a plugin, don't add.
if ( 'core' == $priority ) {
// If core box previously deleted, don't add
if ( false === $wp_meta_boxes[$page][$a_context][$a_priority][$id] )
return;
// If box was added with default priority, give it core priority to maintain sort order
if ( 'default' == $a_priority ) {
$wp_meta_boxes[$page][$a_context]['core'][$id] = $wp_meta_boxes[$page][$a_context]['default'][$id];
unset($wp_meta_boxes[$page][$a_context]['default'][$id]);
}
return;
}
// If no priority given and id already present, use existing priority
if ( empty($priority) ) {
$priority = $a_priority;
// else if we're adding to the sorted priority, we don't know the title or callback. Grab them from the previously added context/priority.
} elseif ( 'sorted' == $priority ) {
$title = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['title'];
$callback = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['callback'];
$callback_args = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['args'];
}
// An id can be in only one priority and one context
if ( $priority != $a_priority || $context != $a_context )
unset($wp_meta_boxes[$page][$a_context][$a_priority][$id]);
}
}
if ( empty($priority) )
$priority = 'low';
if ( !isset($wp_meta_boxes[$page][$context][$priority]) )
$wp_meta_boxes[$page][$context][$priority] = array();
$wp_meta_boxes[$page][$context][$priority][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $callback_args);
}
/**
* Meta-Box template function
*
* @since 2.5.0
*
* @param string|object $screen Screen identifier
* @param string $context box context
* @param mixed $object gets passed to the box callback function as first parameter
* @return int number of meta_boxes
*/
function do_meta_boxes( $screen, $context, $object ) {
global $wp_meta_boxes;
static $already_sorted = false;
if ( empty( $screen ) )
$screen = get_current_screen();
elseif ( is_string( $screen ) )
$screen = convert_to_screen( $screen );
$page = $screen->id;
$hidden = get_hidden_meta_boxes( $screen );
printf('<div id="%s-sortables" class="meta-box-sortables">', htmlspecialchars($context));
$i = 0;
do {
// Grab the ones the user has manually sorted. Pull them out of their previous context/priority and into the one the user chose
if ( !$already_sorted && $sorted = get_user_option( "meta-box-order_$page" ) ) {
foreach ( $sorted as $box_context => $ids ) {
foreach ( explode(',', $ids ) as $id ) {
if ( $id && 'dashboard_browser_nag' !== $id )
add_meta_box( $id, null, null, $screen, $box_context, 'sorted' );
}
}
}
$already_sorted = true;
if ( !isset($wp_meta_boxes) || !isset($wp_meta_boxes[$page]) || !isset($wp_meta_boxes[$page][$context]) )
break;
foreach ( array('high', 'sorted', 'core', 'default', 'low') as $priority ) {
if ( isset($wp_meta_boxes[$page][$context][$priority]) ) {
foreach ( (array) $wp_meta_boxes[$page][$context][$priority] as $box ) {
if ( false == $box || ! $box['title'] )
continue;
$i++;
$style = '';
$hidden_class = in_array($box['id'], $hidden) ? ' hide-if-js' : '';
echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id'], $page) . $hidden_class . '" ' . '>' . "\n";
if ( 'dashboard_browser_nag' != $box['id'] )
echo '<div class="handlediv" title="' . esc_attr__('Click to toggle') . '"><br /></div>';
echo "<h3 class='hndle'><span>{$box['title']}</span></h3>\n";
echo '<div class="inside">' . "\n";
call_user_func($box['callback'], $object, $box);
echo "</div>\n";
echo "</div>\n";
}
}
}
} while(0);
echo "</div>";
return $i;
}
/**
* Remove a meta box from an edit form.
*
* @since 2.6.0
*
* @param string $id String for use in the 'id' attribute of tags.
* @param string|object $screen The screen on which to show the box (post, page, link).
* @param string $context The context within the page where the boxes should show ('normal', 'advanced').
*/
function remove_meta_box($id, $screen, $context) {
global $wp_meta_boxes;
if ( empty( $screen ) )
$screen = get_current_screen();
elseif ( is_string( $screen ) )
$screen = convert_to_screen( $screen );
$page = $screen->id;
if ( !isset($wp_meta_boxes) )
$wp_meta_boxes = array();
if ( !isset($wp_meta_boxes[$page]) )
$wp_meta_boxes[$page] = array();
if ( !isset($wp_meta_boxes[$page][$context]) )
$wp_meta_boxes[$page][$context] = array();
foreach ( array('high', 'core', 'default', 'low') as $priority )
$wp_meta_boxes[$page][$context][$priority][$id] = false;
}
/**
* Add a new section to a settings page.
*
* Part of the Settings API. Use this to define new settings sections for an admin page.
* Show settings sections in your admin page callback function with do_settings_sections().
* Add settings fields to your section with add_settings_field()
*
* The $callback argument should be the name of a function that echoes out any
* content you want to show at the top of the settings section before the actual
* fields. It can output nothing if you want.
*
* @since 2.7.0
*
* @global $wp_settings_sections Storage array of all settings sections added to admin pages
*
* @param string $id Slug-name to identify the section. Used in the 'id' attribute of tags.
* @param string $title Formatted title of the section. Shown as the heading for the section.
* @param string $callback Function that echos out any content at the top of the section (between heading and fields).
* @param string $page The slug-name of the settings page on which to show the section. Built-in pages include 'general', 'reading', 'writing', 'discussion', 'media', etc. Create your own using add_options_page();
*/
function add_settings_section($id, $title, $callback, $page) {
global $wp_settings_sections;
if ( 'misc' == $page ) {
_deprecated_argument( __FUNCTION__, '3.0', __( 'The miscellaneous options group has been removed. Use another settings group.' ) );
$page = 'general';
}
if ( !isset($wp_settings_sections) )
$wp_settings_sections = array();
if ( !isset($wp_settings_sections[$page]) )
$wp_settings_sections[$page] = array();
if ( !isset($wp_settings_sections[$page][$id]) )
$wp_settings_sections[$page][$id] = array();
$wp_settings_sections[$page][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback);
}
/**
* Add a new field to a section of a settings page
*
* Part of the Settings API. Use this to define a settings field that will show
* as part of a settings section inside a settings page. The fields are shown using
* do_settings_fields() in do_settings-sections()
*
* The $callback argument should be the name of a function that echoes out the
* html input tags for this setting field. Use get_option() to retrieve existing
* values to show.
*
* @since 2.7.0
*
* @global $wp_settings_fields Storage array of settings fields and info about their pages/sections
*
* @param string $id Slug-name to identify the field. Used in the 'id' attribute of tags.
* @param string $title Formatted title of the field. Shown as the label for the field during output.
* @param string $callback Function that fills the field with the desired form inputs. The function should echo its output.
* @param string $page The slug-name of the settings page on which to show the section (general, reading, writing, ...).
* @param string $section The slug-name of the section of the settings page in which to show the box (default, ...).
* @param array $args Additional arguments
*/
function add_settings_field($id, $title, $callback, $page, $section = 'default', $args = array()) {
global $wp_settings_fields;
if ( 'misc' == $page ) {
_deprecated_argument( __FUNCTION__, '3.0', __( 'The miscellaneous options group has been removed. Use another settings group.' ) );
$page = 'general';
}
if ( !isset($wp_settings_fields) )
$wp_settings_fields = array();
if ( !isset($wp_settings_fields[$page]) )
$wp_settings_fields[$page] = array();
if ( !isset($wp_settings_fields[$page][$section]) )
$wp_settings_fields[$page][$section] = array();
$wp_settings_fields[$page][$section][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $args);
}
/**
* Prints out all settings sections added to a particular settings page
*
* Part of the Settings API. Use this in a settings page callback function
* to output all the sections and fields that were added to that $page with
* add_settings_section() and add_settings_field()
*
* @global $wp_settings_sections Storage array of all settings sections added to admin pages
* @global $wp_settings_fields Storage array of settings fields and info about their pages/sections
* @since 2.7.0
*
* @param string $page The slug name of the page whos settings sections you want to output
*/
function do_settings_sections($page) {
global $wp_settings_sections, $wp_settings_fields;
if ( !isset($wp_settings_sections) || !isset($wp_settings_sections[$page]) )
return;
foreach ( (array) $wp_settings_sections[$page] as $section ) {
if ( $section['title'] )
echo "<h3>{$section['title']}</h3>\n";
call_user_func($section['callback'], $section);
if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section['id']]) )
continue;
echo '<table class="form-table">';
do_settings_fields($page, $section['id']);
echo '</table>';
}
}
/**
* Print out the settings fields for a particular settings section
*
* Part of the Settings API. Use this in a settings page to output
* a specific section. Should normally be called by do_settings_sections()
* rather than directly.
*
* @global $wp_settings_fields Storage array of settings fields and their pages/sections
*
* @since 2.7.0
*
* @param string $page Slug title of the admin page who's settings fields you want to show.
* @param section $section Slug title of the settings section who's fields you want to show.
*/
function do_settings_fields($page, $section) {
global $wp_settings_fields;
if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section]) )
return;
foreach ( (array) $wp_settings_fields[$page][$section] as $field ) {
echo '<tr valign="top">';
if ( !empty($field['args']['label_for']) )
echo '<th scope="row"><label for="' . $field['args']['label_for'] . '">' . $field['title'] . '</label></th>';
else
echo '<th scope="row">' . $field['title'] . '</th>';
echo '<td>';
call_user_func($field['callback'], $field['args']);
echo '</td>';
echo '</tr>';
}
}
/**
* Register a settings error to be displayed to the user
*
* Part of the Settings API. Use this to show messages to users about settings validation
* problems, missing settings or anything else.
*
* Settings errors should be added inside the $sanitize_callback function defined in
* register_setting() for a given setting to give feedback about the submission.
*
* By default messages will show immediately after the submission that generated the error.
* Additional calls to settings_errors() can be used to show errors even when the settings
* page is first accessed.
*
* @since 3.0.0
*
* @global array $wp_settings_errors Storage array of errors registered during this pageload
*
* @param string $setting Slug title of the setting to which this error applies
* @param string $code Slug-name to identify the error. Used as part of 'id' attribute in HTML output.
* @param string $message The formatted message text to display to the user (will be shown inside styled <div> and <p>)
* @param string $type The type of message it is, controls HTML class. Use 'error' or 'updated'.
*/
function add_settings_error( $setting, $code, $message, $type = 'error' ) {
global $wp_settings_errors;
if ( !isset($wp_settings_errors) )
$wp_settings_errors = array();
$new_error = array(
'setting' => $setting,
'code' => $code,
'message' => $message,
'type' => $type
);
$wp_settings_errors[] = $new_error;
}
/**
* Fetch settings errors registered by add_settings_error()
*
* Checks the $wp_settings_errors array for any errors declared during the current
* pageload and returns them.
*
* If changes were just submitted ($_GET['settings-updated']) and settings errors were saved
* to the 'settings_errors' transient then those errors will be returned instead. This
* is used to pass errors back across pageloads.
*
* Use the $sanitize argument to manually re-sanitize the option before returning errors.
* This is useful if you have errors or notices you want to show even when the user
* hasn't submitted data (i.e. when they first load an options page, or in admin_notices action hook)
*
* @since 3.0.0
*
* @global array $wp_settings_errors Storage array of errors registered during this pageload
*
* @param string $setting Optional slug title of a specific setting who's errors you want.
* @param boolean $sanitize Whether to re-sanitize the setting value before returning errors.
* @return array Array of settings errors
*/
function get_settings_errors( $setting = '', $sanitize = false ) {
global $wp_settings_errors;
// If $sanitize is true, manually re-run the sanitizisation for this option
// This allows the $sanitize_callback from register_setting() to run, adding
// any settings errors you want to show by default.
if ( $sanitize )
sanitize_option( $setting, get_option($setting));
// If settings were passed back from options.php then use them
// Ignore transients if $sanitize is true, we don't want the old values anyway
if ( isset($_GET['settings-updated']) && $_GET['settings-updated'] && get_transient('settings_errors') ) {
$settings_errors = get_transient('settings_errors');
delete_transient('settings_errors');
// Otherwise check global in case validation has been run on this pageload
} elseif ( count( $wp_settings_errors ) ) {
$settings_errors = $wp_settings_errors;
} else {
return;
}
// Filter the results to those of a specific setting if one was set
if ( $setting ) {
foreach ( (array) $settings_errors as $key => $details )
if ( $setting != $details['setting'] )
unset( $settings_errors[$key] );
}
return $settings_errors;
}
/**
* Display settings errors registered by add_settings_error()
*
* Part of the Settings API. Outputs a <div> for each error retrieved by get_settings_errors().
*
* This is called automatically after a settings page based on the Settings API is submitted.
* Errors should be added during the validation callback function for a setting defined in register_setting()
*
* The $sanitize option is passed into get_settings_errors() and will re-run the setting sanitization
* on its current value.
*
* The $hide_on_update option will cause errors to only show when the settings page is first loaded.
* if the user has already saved new values it will be hidden to avoid repeating messages already
* shown in the default error reporting after submission. This is useful to show general errors like missing
* settings when the user arrives at the settings page.
*
* @since 3.0.0
*
* @param string $setting Optional slug title of a specific setting who's errors you want.
* @param boolean $sanitize Whether to re-sanitize the setting value before returning errors.
* @param boolean $hide_on_update If set to true errors will not be shown if the settings page has already been submitted.
*/
function settings_errors( $setting = '', $sanitize = false, $hide_on_update = false ) {
if ( $hide_on_update && ! empty( $_GET['settings-updated'] ) )
return;
$settings_errors = get_settings_errors( $setting, $sanitize );
if ( ! is_array( $settings_errors ) )
return;
$output = '';
foreach ( $settings_errors as $key => $details ) {
$css_id = 'setting-error-' . $details['code'];
$css_class = $details['type'] . ' settings-error';
$output .= "<div id='$css_id' class='$css_class'> \n";
$output .= "<p><strong>{$details['message']}</strong></p>";
$output .= "</div> \n";
}
echo $output;
}
/**
* {@internal Missing Short Description}}
*
* @since 2.7.0
*
* @param unknown_type $found_action
*/
function find_posts_div($found_action = '') {
?>
<div id="find-posts" class="find-box" style="display:none;">
<div id="find-posts-head" class="find-box-head"><?php _e('Find Posts or Pages'); ?></div>
<div class="find-box-inside">
<div class="find-box-search">
<?php if ( $found_action ) { ?>
<input type="hidden" name="found_action" value="<?php echo esc_attr($found_action); ?>" />
<?php } ?>
<input type="hidden" name="affected" id="affected" value="" />
<?php wp_nonce_field( 'find-posts', '_ajax_nonce', false ); ?>
<label class="screen-reader-text" for="find-posts-input"><?php _e( 'Search' ); ?></label>
<input type="text" id="find-posts-input" name="ps" value="" />
<input type="button" id="find-posts-search" value="<?php esc_attr_e( 'Search' ); ?>" class="button" /><br />
<?php
$post_types = get_post_types( array('public' => true), 'objects' );
foreach ( $post_types as $post ) {
if ( 'attachment' == $post->name )
continue;
?>
<input type="radio" name="find-posts-what" id="find-posts-<?php echo esc_attr($post->name); ?>" value="<?php echo esc_attr($post->name); ?>" <?php checked($post->name, 'post'); ?> />
<label for="find-posts-<?php echo esc_attr($post->name); ?>"><?php echo $post->label; ?></label>
<?php
} ?>
</div>
<div id="find-posts-response"></div>
</div>
<div class="find-box-buttons">
<input id="find-posts-close" type="button" class="button alignleft" value="<?php esc_attr_e('Close'); ?>" />
<?php submit_button( __( 'Select' ), 'button-primary alignright', 'find-posts-submit', false ); ?>
</div>
</div>
<?php
}
/**
* Display the post password.
*
* The password is passed through {@link esc_attr()} to ensure that it
* is safe for placing in an html attribute.
*
* @uses attr
* @since 2.7.0
*/
function the_post_password() {
global $post;
if ( isset( $post->post_password ) ) echo esc_attr( $post->post_password );
}
/**
* Get the post title.
*
* The post title is fetched and if it is blank then a default string is
* returned.
*
* @since 2.7.0
* @param int $post_id The post id. If not supplied the global $post is used.
* @return string The post title if set
*/
function _draft_or_post_title( $post_id = 0 ) {
$title = get_the_title($post_id);
if ( empty($title) )
$title = __('(no title)');
return $title;
}
/**
* Display the search query.
*
* A simple wrapper to display the "s" parameter in a GET URI. This function
* should only be used when {@link the_search_query()} cannot.
*
* @uses attr
* @since 2.7.0
*
*/
function _admin_search_query() {
echo isset($_REQUEST['s']) ? esc_attr( stripslashes( $_REQUEST['s'] ) ) : '';
}
/**
* Generic Iframe header for use with Thickbox
*
* @since 2.7.0
* @param string $title Title of the Iframe page.
* @param bool $limit_styles Limit styles to colour-related styles only (unless others are enqueued).
*
*/
function iframe_header( $title = '', $limit_styles = false ) {
show_admin_bar( false );
global $hook_suffix, $current_user, $admin_body_class, $wp_locale;
$admin_body_class = preg_replace('/[^a-z0-9_-]+/i', '-', $hook_suffix);
$current_screen = get_current_screen();
_wp_admin_html_begin();
?>
<title><?php bloginfo('name') ?> › <?php echo $title ?> — <?php _e('WordPress'); ?></title>
<?php
wp_enqueue_style( 'colors' );
?>
<script type="text/javascript">
//<![CDATA[
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();}}};
function tb_close(){var win=window.dialogArguments||opener||parent||top;win.tb_remove();}
var userSettings = {
'url': '<?php echo SITECOOKIEPATH; ?>',
'uid': '<?php if ( ! isset($current_user) ) $current_user = wp_get_current_user(); echo $current_user->ID; ?>',
'time':'<?php echo time() ?>'
},
ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>',
pagenow = '<?php echo $current_screen->id; ?>',
typenow = '<?php echo $current_screen->post_type; ?>',
adminpage = '<?php echo $admin_body_class; ?>',
thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>',
decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>',
isRtl = <?php echo (int) is_rtl(); ?>;
//]]>
</script>
<?php
do_action('admin_enqueue_scripts', $hook_suffix);
do_action("admin_print_styles-$hook_suffix");
do_action('admin_print_styles');
do_action("admin_print_scripts-$hook_suffix");
do_action('admin_print_scripts');
do_action("admin_head-$hook_suffix");
do_action('admin_head');
$admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) );
?>
</head>
<body<?php if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?> class="wp-admin no-js iframe <?php echo apply_filters( 'admin_body_class', '' ) . ' ' . $admin_body_class; ?>">
<script type="text/javascript">
//<![CDATA[
(function(){
var c = document.body.className;
c = c.replace(/no-js/, 'js');
document.body.className = c;
})();
//]]>
</script>
<?php
}
/**
* Generic Iframe footer for use with Thickbox
*
* @since 2.7.0
*
*/
function iframe_footer() {
//We're going to hide any footer output on iframe pages, but run the hooks anyway since they output Javascript or other needed content. ?>
<div class="hidden">
<?php
do_action('admin_footer', '');
do_action('admin_print_footer_scripts'); ?>
</div>
<script type="text/javascript">if(typeof wpOnload=="function")wpOnload();</script>
</body>
</html>
<?php
}
function _post_states($post) {
$post_states = array();
if ( isset( $_REQUEST['post_status'] ) )
$post_status = $_REQUEST['post_status'];
else
$post_status = '';
if ( !empty($post->post_password) )
$post_states['protected'] = __('Password protected');
if ( 'private' == $post->post_status && 'private' != $post_status )
$post_states['private'] = __('Private');
if ( 'draft' == $post->post_status && 'draft' != $post_status )
$post_states['draft'] = __('Draft');
if ( 'pending' == $post->post_status && 'pending' != $post_status )
/* translators: post state */
$post_states['pending'] = _x('Pending', 'post state');
if ( is_sticky($post->ID) )
$post_states['sticky'] = __('Sticky');
$post_states = apply_filters( 'display_post_states', $post_states );
if ( ! empty($post_states) ) {
$state_count = count($post_states);
$i = 0;
echo ' - ';
foreach ( $post_states as $state ) {
++$i;
( $i == $state_count ) ? $sep = '' : $sep = ', ';
echo "<span class='post-state'>$state$sep</span>";
}
}
if ( get_post_format( $post->ID ) )
echo ' - <span class="post-state-format">' . get_post_format_string( get_post_format( $post->ID ) ) . '</span>';
}
function _media_states( $post ) {
$media_states = array();
$stylesheet = get_option('stylesheet');
if ( current_theme_supports( 'custom-header') ) {
$meta_header = get_post_meta($post->ID, '_wp_attachment_is_custom_header', true );
if ( ! empty( $meta_header ) && $meta_header == $stylesheet )
$media_states[] = __( 'Header Image' );
}
if ( current_theme_supports( 'custom-background') ) {
$meta_background = get_post_meta($post->ID, '_wp_attachment_is_custom_background', true );
if ( ! empty( $meta_background ) && $meta_background == $stylesheet )
$media_states[] = __( 'Background Image' );
}
$media_states = apply_filters( 'display_media_states', $media_states );
if ( ! empty( $media_states ) ) {
$state_count = count( $media_states );
$i = 0;
echo ' - ';
foreach ( $media_states as $state ) {
++$i;
( $i == $state_count ) ? $sep = '' : $sep = ', ';
echo "<span class='post-state'>$state$sep</span>";
}
}
}
/**
* Test support for compressing JavaScript from PHP
*
* Outputs JavaScript that tests if compression from PHP works as expected
* and sets an option with the result. Has no effect when the current user
* is not an administrator. To run the test again the option 'can_compress_scripts'
* has to be deleted.
*
* @since 2.8.0
*/
function compression_test() {
?>
<script type="text/javascript">
/* <![CDATA[ */
var testCompression = {
get : function(test) {
var x;
if ( window.XMLHttpRequest ) {
x = new XMLHttpRequest();
} else {
try{x=new ActiveXObject('Msxml2.XMLHTTP');}catch(e){try{x=new ActiveXObject('Microsoft.XMLHTTP');}catch(e){};}
}
if (x) {
x.onreadystatechange = function() {
var r, h;
if ( x.readyState == 4 ) {
r = x.responseText.substr(0, 18);
h = x.getResponseHeader('Content-Encoding');
testCompression.check(r, h, test);
}
}
x.open('GET', ajaxurl + '?action=wp-compression-test&test='+test+'&'+(new Date()).getTime(), true);
x.send('');
}
},
check : function(r, h, test) {
if ( ! r && ! test )
this.get(1);
if ( 1 == test ) {
if ( h && ( h.match(/deflate/i) || h.match(/gzip/i) ) )
this.get('no');
else
this.get(2);
return;
}
if ( 2 == test ) {
if ( '"wpCompressionTest' == r )
this.get('yes');
else
this.get('no');
}
}
};
testCompression.check();
/* ]]> */
</script>
<?php
}
/**
* Echos a submit button, with provided text and appropriate class
*
* @since 3.1.0
*
* @param string $text The text of the button (defaults to 'Save Changes')
* @param string $type The type of button. One of: primary, secondary, delete
* @param string $name The HTML name of the submit button. Defaults to "submit". If no id attribute
* is given in $other_attributes below, $name will be used as the button's id.
* @param bool $wrap True if the output button should be wrapped in a paragraph tag,
* false otherwise. Defaults to true
* @param array|string $other_attributes Other attributes that should be output with the button,
* mapping attributes to their values, such as array( 'tabindex' => '1' ).
* These attributes will be output as attribute="value", such as tabindex="1".
* Defaults to no other attributes. Other attributes can also be provided as a
* string such as 'tabindex="1"', though the array format is typically cleaner.
*/
function submit_button( $text = null, $type = 'primary', $name = 'submit', $wrap = true, $other_attributes = null ) {
echo get_submit_button( $text, $type, $name, $wrap, $other_attributes );
}
/**
* Returns a submit button, with provided text and appropriate class
*
* @since 3.1.0
*
* @param string $text The text of the button (defaults to 'Save Changes')
* @param string $type The type of button. One of: primary, secondary, delete
* @param string $name The HTML name of the submit button. Defaults to "submit". If no id attribute
* is given in $other_attributes below, $name will be used as the button's id.
* @param bool $wrap True if the output button should be wrapped in a paragraph tag,
* false otherwise. Defaults to true
* @param array|string $other_attributes Other attributes that should be output with the button,
* mapping attributes to their values, such as array( 'tabindex' => '1' ).
* These attributes will be output as attribute="value", such as tabindex="1".
* Defaults to no other attributes. Other attributes can also be provided as a
* string such as 'tabindex="1"', though the array format is typically cleaner.
*/
function get_submit_button( $text = null, $type = 'primary', $name = 'submit', $wrap = true, $other_attributes = null ) {
switch ( $type ) :
case 'primary' :
case 'secondary' :
$class = 'button-' . $type;
break;
case 'delete' :
$class = 'button-secondary delete';
break;
default :
$class = $type; // Custom cases can just pass in the classes they want to be used
endswitch;
$text = ( null == $text ) ? __( 'Save Changes' ) : $text;
// Default the id attribute to $name unless an id was specifically provided in $other_attributes
$id = $name;
if ( is_array( $other_attributes ) && isset( $other_attributes['id'] ) ) {
$id = $other_attributes['id'];
unset( $other_attributes['id'] );
}
$attributes = '';
if ( is_array( $other_attributes ) ) {
foreach ( $other_attributes as $attribute => $value ) {
$attributes .= $attribute . '="' . esc_attr( $value ) . '" '; // Trailing space is important
}
} else if ( !empty( $other_attributes ) ) { // Attributes provided as a string
$attributes = $other_attributes;
}
$button = '<input type="submit" name="' . esc_attr( $name ) . '" id="' . esc_attr( $id ) . '" class="' . esc_attr( $class );
$button .= '" value="' . esc_attr( $text ) . '" ' . $attributes . ' />';
if ( $wrap ) {
$button = '<p class="submit">' . $button . '</p>';
}
return $button;
}
function _wp_admin_html_begin() {
$admin_html_class = ( is_admin_bar_showing() ) ? 'wp-toolbar' : '';
?>
<!DOCTYPE html>
<!--[if IE 8]>
<html xmlns="http://www.w3.org/1999/xhtml" class="ie8 <?php echo $admin_html_class; ?>" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>>
<![endif]-->
<!--[if !(IE 8) ]><!-->
<html xmlns="http://www.w3.org/1999/xhtml" class="<?php echo $admin_html_class; ?>" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>>
<!--<![endif]-->
<head>
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
<?php
}
final class WP_Internal_Pointers {
/**
* Initializes the new feature pointers.
*
* @since 3.3.0
*
* All pointers can be disabled using the following:
* remove_action( 'admin_enqueue_scripts', array( 'WP_Internal_Pointers', 'enqueue_scripts' ) );
*
* Individual pointers (e.g. wp330_toolbar) can be disabled using the following:
* remove_action( 'admin_print_footer_scripts', array( 'WP_Internal_Pointers', 'pointer_wp330_toolbar' ) );
*/
public static function enqueue_scripts( $hook_suffix ) {
/*
* Register feature pointers
* Format: array( hook_suffix => pointer_id )
*/
$registered_pointers = array(
'index.php' => 'wp330_toolbar',
'post-new.php' => 'wp330_media_uploader',
'post.php' => 'wp330_media_uploader',
'themes.php' => array( 'wp330_saving_widgets', 'wp340_customize_current_theme_link' ),
'appearance_page_custom-header' => 'wp340_choose_image_from_library',
'appearance_page_custom-background' => 'wp340_choose_image_from_library',
);
// Check if screen related pointer is registered
if ( empty( $registered_pointers[ $hook_suffix ] ) )
return;
$pointers = (array) $registered_pointers[ $hook_suffix ];
$caps_required = array(
'wp330_media_uploader' => array( 'upload_files' ),
'wp330_saving_widgets' => array( 'edit_theme_options', 'switch_themes' ),
'wp340_customize_current_theme_link' => array( 'edit_theme_options' ),
'wp340_choose_image_from_library' => array( 'edit_theme_options' ),
);
// Get dismissed pointers
$dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
$got_pointers = false;
foreach ( array_diff( $pointers, $dismissed ) as $pointer ) {
if ( isset( $caps_required[ $pointer ] ) ) {
foreach ( $caps_required[ $pointer ] as $cap ) {
if ( ! current_user_can( $cap ) )
continue 2;
}
}
// Bind pointer print function
add_action( 'admin_print_footer_scripts', array( 'WP_Internal_Pointers', 'pointer_' . $pointer ) );
$got_pointers = true;
}
if ( ! $got_pointers )
return;
// Add pointers script and style to queue
wp_enqueue_style( 'wp-pointer' );
wp_enqueue_script( 'wp-pointer' );
}
/**
* Print the pointer javascript data.
*
* @since 3.3.0
*
* @param string $pointer_id The pointer ID.
* @param string $selector The HTML elements, on which the pointer should be attached.
* @param array $args Arguments to be passed to the pointer JS (see wp-pointer.dev.js).
*/
private static function print_js( $pointer_id, $selector, $args ) {
if ( empty( $pointer_id ) || empty( $selector ) || empty( $args ) || empty( $args['content'] ) )
return;
?>
<script type="text/javascript">
//<![CDATA[
(function($){
var options = <?php echo json_encode( $args ); ?>, setup;
if ( ! options )
return;
options = $.extend( options, {
close: function() {
$.post( ajaxurl, {
pointer: '<?php echo $pointer_id; ?>',
action: 'dismiss-wp-pointer'
});
}
});
setup = function() {
$('<?php echo $selector; ?>').pointer( options ).pointer('open');
};
if ( options.position && options.position.defer_loading )
$(window).bind( 'load.wp-pointers', setup );
else
$(document).ready( setup );
})( jQuery );
//]]>
</script>
<?php
}
public static function pointer_wp330_toolbar() {
$content = '<h3>' . __( 'New Feature: Toolbar' ) . '</h3>';
$content .= '<p>' . __( 'We’ve combined the admin bar and the old Dashboard header into one persistent toolbar. Hover over the toolbar items to see what’s new.' ) . '</p>';
if ( is_multisite() && is_super_admin() )
$content .= '<p>' . __( 'Network Admin is now located in the My Sites menu.' ) . '</p>';
WP_Internal_Pointers::print_js( 'wp330_toolbar', '#wpadminbar', array(
'content' => $content,
'position' => array( 'edge' => 'top', 'align' => 'center' ),
) );
}
/**
* Print 'Updated Media Uploader' for 3.3.0.
*
* @since 3.3.0
*/
public static function pointer_wp330_media_uploader() {
$content = '<h3>' . __( 'Updated Media Uploader' ) . '</h3>';
$content .= '<p>' . __( 'The single media icon now launches the uploader for all file types, and the new drag and drop interface makes uploading a breeze.' ) . '</p>';
WP_Internal_Pointers::print_js( 'wp330_media_uploader', '#content-add_media', array(
'content' => $content,
'position' => array( 'edge' => is_rtl() ? 'right' : 'left', 'align' => 'center' ),
) );
}
/**
* Print 'New Feature: Saving Widgets' for 3.3.0.
*
* @since 3.3.0
*/
public static function pointer_wp330_saving_widgets() {
$content = '<h3>' . __( 'New Feature: Saving Widgets' ) . '</h3>';
$content .= '<p>' . __( 'If you change your mind and revert to your previous theme, we’ll put the widgets back the way you had them.' ) . '</p>';
WP_Internal_Pointers::print_js( 'wp330_saving_widgets', '#message2', array(
'content' => $content,
'position' => array( 'edge' => 'top', 'align' => is_rtl() ? 'right' : 'left' ),
) );
}
/**
* Print 'New Feature: Current Theme Customize Link' for 3.4.0.
*
* @since 3.4.0
*/
public static function pointer_wp340_customize_current_theme_link() {
$content = '<h3>' . __( 'New Feature: Customizer' ) . '</h3>';
$content .= '<p>' . __( 'Click Customize to change the header, background, title and menus of the current theme, all in one place.' ) . '</p>';
$content .= '<p>' . __( 'Click the Live Preview links in the Available Themes list below to customize and preview another theme before activating it.' ) . '</p>';
WP_Internal_Pointers::print_js( 'wp340_customize_current_theme_link', '#customize-current-theme-link', array(
'content' => $content,
'position' => array( 'edge' => 'top', 'align' => is_rtl() ? 'right' : 'left', 'offset' => is_rtl() ? '32 0' : '-32 0' ),
) );
}
/**
* Print 'New Feature: Choose Image from Library' for 3.4.0.
*
* @since 3.4.0
*/
public static function pointer_wp340_choose_image_from_library() {
$content = '<h3>' . __( 'New Feature: Choose Image from Library' ) . '</h3>';
$content .= '<p>' . __( 'Want to use an image you uploaded earlier? Select it from your media library instead of uploading it again.' ) . '</p>';
WP_Internal_Pointers::print_js( 'wp340_choose_image_from_library', '#choose-from-library-link', array(
'content' => $content,
'position' => array( 'edge' => 'top', 'align' => is_rtl() ? 'right' : 'left', 'defer_loading' => true ),
) );
}
/**
* Prevents new users from seeing existing 'new feature' pointers.
*
* @since 3.3.0
*/
public static function dismiss_pointers_for_new_users( $user_id ) {
add_user_meta( $user_id, 'dismissed_wp_pointers', 'wp330_toolbar,wp330_media_uploader,wp330_saving_widgets,wp340_choose_image_from_library,wp340_customize_current_theme_link' );
}
}
add_action( 'admin_enqueue_scripts', array( 'WP_Internal_Pointers', 'enqueue_scripts' ) );
add_action( 'user_register', array( 'WP_Internal_Pointers', 'dismiss_pointers_for_new_users' ) );
/**
* Convert a screen string to a screen object
*
* @since 3.0.0
*
* @param string $hook_name The hook name (also known as the hook suffix) used to determine the screen.
* @return WP_Screen Screen object.
*/
function convert_to_screen( $hook_name ) {
if ( ! class_exists( 'WP_Screen' ) ) {
_doing_it_wrong( 'convert_to_screen(), add_meta_box()', __( "Likely direct inclusion of wp-admin/includes/template.php in order to use add_meta_box(). This is very wrong. Hook the add_meta_box() call into the add_meta_boxes action instead." ), '3.3' );
return (object) array( 'id' => '_invalid', 'base' => '_are_belong_to_us' );
}
return WP_Screen::get( $hook_name );
}
| 01happy-blog | trunk/myblog/wp-admin/includes/template.php | PHP | oos | 69,519 |
<?php
/**
* WordPress Administration Screen API.
*
* @package WordPress
* @subpackage Administration
*/
/**
* Get the column headers for a screen
*
* @since 2.7.0
*
* @param string|WP_Screen $screen The screen you want the headers for
* @return array Containing the headers in the format id => UI String
*/
function get_column_headers( $screen ) {
if ( is_string( $screen ) )
$screen = convert_to_screen( $screen );
static $column_headers = array();
if ( ! isset( $column_headers[ $screen->id ] ) )
$column_headers[ $screen->id ] = apply_filters( 'manage_' . $screen->id . '_columns', array() );
return $column_headers[ $screen->id ];
}
/**
* Get a list of hidden columns.
*
* @since 2.7.0
*
* @param string|WP_Screen $screen The screen you want the hidden columns for
* @return array
*/
function get_hidden_columns( $screen ) {
if ( is_string( $screen ) )
$screen = convert_to_screen( $screen );
return (array) get_user_option( 'manage' . $screen->id . 'columnshidden' );
}
/**
* Prints the meta box preferences for screen meta.
*
* @since 2.7.0
*
* @param string|WP_Screen $screen
*/
function meta_box_prefs( $screen ) {
global $wp_meta_boxes;
if ( is_string( $screen ) )
$screen = convert_to_screen( $screen );
if ( empty($wp_meta_boxes[$screen->id]) )
return;
$hidden = get_hidden_meta_boxes($screen);
foreach ( array_keys($wp_meta_boxes[$screen->id]) as $context ) {
foreach ( array_keys($wp_meta_boxes[$screen->id][$context]) as $priority ) {
foreach ( $wp_meta_boxes[$screen->id][$context][$priority] as $box ) {
if ( false == $box || ! $box['title'] )
continue;
// Submit box cannot be hidden
if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] )
continue;
$box_id = $box['id'];
echo '<label for="' . $box_id . '-hide">';
echo '<input class="hide-postbox-tog" name="' . $box_id . '-hide" type="checkbox" id="' . $box_id . '-hide" value="' . $box_id . '"' . (! in_array($box_id, $hidden) ? ' checked="checked"' : '') . ' />';
echo "{$box['title']}</label>\n";
}
}
}
}
/**
* Get Hidden Meta Boxes
*
* @since 2.7.0
*
* @param string|WP_Screen $screen Screen identifier
* @return array Hidden Meta Boxes
*/
function get_hidden_meta_boxes( $screen ) {
if ( is_string( $screen ) )
$screen = convert_to_screen( $screen );
$hidden = get_user_option( "metaboxhidden_{$screen->id}" );
$use_defaults = ! is_array( $hidden );
// Hide slug boxes by default
if ( $use_defaults ) {
$hidden = array();
if ( 'post' == $screen->base ) {
if ( 'post' == $screen->post_type || 'page' == $screen->post_type )
$hidden = array('slugdiv', 'trackbacksdiv', 'postcustom', 'postexcerpt', 'commentstatusdiv', 'commentsdiv', 'authordiv', 'revisionsdiv');
else
$hidden = array( 'slugdiv' );
}
$hidden = apply_filters( 'default_hidden_meta_boxes', $hidden, $screen );
}
return apply_filters( 'hidden_meta_boxes', $hidden, $screen, $use_defaults );
}
/**
* Register and configure an admin screen option
*
* @since 3.1.0
*
* @param string $option An option name.
* @param mixed $args Option-dependent arguments.
*/
function add_screen_option( $option, $args = array() ) {
$current_screen = get_current_screen();
if ( ! $current_screen )
return;
$current_screen->add_option( $option, $args );
}
/**
* Displays a screen icon.
*
* @uses get_screen_icon()
* @since 2.7.0
*
* @param string|WP_Screen $screen Optional. Accepts a screen object (and defaults to the current screen object)
* which it uses to determine an icon HTML ID. Or, if a string is provided, it is used to form the icon HTML ID.
*/
function screen_icon( $screen = '' ) {
echo get_screen_icon( $screen );
}
/**
* Gets a screen icon.
*
* @since 3.2.0
*
* @param string|WP_Screen $screen Optional. Accepts a screen object (and defaults to the current screen object)
* which it uses to determine an icon HTML ID. Or, if a string is provided, it is used to form the icon HTML ID.
* @return string HTML for the screen icon.
*/
function get_screen_icon( $screen = '' ) {
if ( empty( $screen ) )
$screen = get_current_screen();
elseif ( is_string( $screen ) )
$icon_id = $screen;
$class = 'icon32';
if ( empty( $icon_id ) ) {
if ( ! empty( $screen->parent_base ) )
$icon_id = $screen->parent_base;
else
$icon_id = $screen->base;
if ( 'page' == $screen->post_type )
$icon_id = 'edit-pages';
if ( $screen->post_type )
$class .= ' ' . sanitize_html_class( 'icon32-posts-' . $screen->post_type );
}
return '<div id="icon-' . esc_attr( $icon_id ) . '" class="' . $class . '"><br /></div>';
}
/**
* Get the current screen object
*
* @since 3.1.0
*
* @return WP_Screen Current screen object
*/
function get_current_screen() {
global $current_screen;
if ( ! isset( $current_screen ) )
return null;
return $current_screen;
}
/**
* Set the current screen object
*
* @since 3.0.0
* @uses $current_screen
*
* @param mixed $hook_name Optional. The hook name (also known as the hook suffix) used to determine the screen,
* or an existing screen object.
*/
function set_current_screen( $hook_name = '' ) {
WP_Screen::get( $hook_name )->set_current_screen();
}
/**
* A class representing the admin screen.
*
* @since 3.3.0
* @access public
*/
final class WP_Screen {
/**
* Any action associated with the screen. 'add' for *-add.php and *-new.php screens. Empty otherwise.
*
* @since 3.3.0
* @var string
* @access public
*/
public $action;
/**
* The base type of the screen. This is typically the same as $id but with any post types and taxonomies stripped.
* For example, for an $id of 'edit-post' the base is 'edit'.
*
* @since 3.3.0
* @var string
* @access public
*/
public $base;
/**
* The number of columns to display. Access with get_columns().
*
* @since 3.4.0
* @var int
* @access private
*/
private $columns = 0;
/**
* The unique ID of the screen.
*
* @since 3.3.0
* @var string
* @access public
*/
public $id;
/**
* Whether the screen is in the network admin.
*
* @since 3.3.0
* @var bool
* @access public
*/
public $is_network;
/**
* Whether the screen is in the user admin.
*
* @since 3.3.0
* @var bool
* @access public
*/
public $is_user;
/**
* The base menu parent.
* This is derived from $parent_file by removing the query string and any .php extension.
* $parent_file values of 'edit.php?post_type=page' and 'edit.php?post_type=post' have a $parent_base of 'edit'.
*
* @since 3.3.0
* @var string
* @access public
*/
public $parent_base;
/**
* The parent_file for the screen per the admin menu system.
* Some $parent_file values are 'edit.php?post_type=page', 'edit.php', and 'options-general.php'.
*
* @since 3.3.0
* @var string
* @access public
*/
public $parent_file;
/**
* The post type associated with the screen, if any.
* The 'edit.php?post_type=page' screen has a post type of 'page'.
* The 'edit-tags.php?taxonomy=$taxonomy&post_type=page' screen has a post type of 'page'.
*
* @since 3.3.0
* @var string
* @access public
*/
public $post_type;
/**
* 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
* @access public
*/
public $taxonomy;
/**
* The help tab data associated with the screen, if any.
*
* @since 3.3.0
* @var array
* @access private
*/
private $_help_tabs = array();
/**
* The help sidebar data associated with screen, if any.
*
* @since 3.3.0
* @var string
* @access private
*/
private $_help_sidebar = '';
/**
* Stores old string-based help.
*/
private static $_old_compat_help = array();
/**
* The screen options associated with screen, if any.
*
* @since 3.3.0
* @var array
* @access private
*/
private $_options = array();
/**
* The screen object registry.
*
* @since 3.3.0
* @var array
* @access private
*/
private static $_registry = array();
/**
* Stores the result of the public show_screen_options function.
*
* @since 3.3.0
* @var bool
* @access private
*/
private $_show_screen_options;
/**
* Stores the 'screen_settings' section of screen options.
*
* @since 3.3.0
* @var string
* @access private
*/
private $_screen_settings;
/**
* Fetches a screen object.
*
* @since 3.3.0
* @access public
*
* @param string $hook_name Optional. The hook name (also known as the hook suffix) used to determine the screen.
* Defaults to the current $hook_suffix global.
* @return WP_Screen Screen object.
*/
public static function get( $hook_name = '' ) {
if ( is_a( $hook_name, 'WP_Screen' ) )
return $hook_name;
$post_type = $taxonomy = null;
$is_network = $is_user = false;
$action = '';
if ( $hook_name )
$id = $hook_name;
else
$id = $GLOBALS['hook_suffix'];
// For those pesky meta boxes.
if ( $hook_name && post_type_exists( $hook_name ) ) {
$post_type = $id;
$id = 'post'; // changes later. ends up being $base.
} else {
if ( '.php' == substr( $id, -4 ) )
$id = substr( $id, 0, -4 );
if ( 'post-new' == $id || 'link-add' == $id || 'media-new' == $id || 'user-new' == $id ) {
$id = substr( $id, 0, -4 );
$action = 'add';
}
}
if ( ! $post_type && $hook_name ) {
if ( '-network' == substr( $id, -8 ) ) {
$id = substr( $id, 0, -8 );
$is_network = true;
} elseif ( '-user' == substr( $id, -5 ) ) {
$id = substr( $id, 0, -5 );
$is_user = true;
}
$id = sanitize_key( $id );
if ( 'edit-comments' != $id && 'edit-tags' != $id && 'edit-' == substr( $id, 0, 5 ) ) {
$maybe = substr( $id, 5 );
if ( taxonomy_exists( $maybe ) ) {
$id = 'edit-tags';
$taxonomy = $maybe;
} elseif ( post_type_exists( $maybe ) ) {
$id = 'edit';
$post_type = $maybe;
}
}
} else {
$is_network = is_network_admin();
$is_user = is_user_admin();
}
if ( 'index' == $id )
$id = 'dashboard';
$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'] ) )
$post_type = post_type_exists( $_REQUEST['post_type'] ) ? $_REQUEST['post_type'] : false;
if ( isset( $_REQUEST['taxonomy'] ) )
$taxonomy = taxonomy_exists( $_REQUEST['taxonomy'] ) ? $_REQUEST['taxonomy'] : false;
switch ( $base ) {
case 'post' :
if ( isset( $_GET['post'] ) )
$post_id = (int) $_GET['post'];
elseif ( isset( $_POST['post_ID'] ) )
$post_id = (int) $_POST['post_ID'];
else
$post_id = 0;
if ( $post_id ) {
$post = get_post( $post_id );
if ( $post )
$post_type = $post->post_type;
}
break;
case 'edit-tags' :
if ( null === $post_type && is_object_in_taxonomy( 'post', $taxonomy ? $taxonomy : 'post_tag' ) )
$post_type = 'post';
break;
}
}
switch ( $base ) {
case 'post' :
if ( null === $post_type )
$post_type = 'post';
$id = $post_type;
break;
case 'edit' :
if ( null === $post_type )
$post_type = 'post';
$id .= '-' . $post_type;
break;
case 'edit-tags' :
if ( null === $taxonomy )
$taxonomy = 'post_tag';
$id = 'edit-' . $taxonomy;
break;
}
if ( $is_network ) {
$id .= '-network';
$base .= '-network';
} elseif ( $is_user ) {
$id .= '-user';
$base .= '-user';
}
if ( isset( self::$_registry[ $id ] ) ) {
$screen = self::$_registry[ $id ];
if ( $screen === get_current_screen() )
return $screen;
} else {
$screen = new WP_Screen();
$screen->id = $id;
}
$screen->base = $base;
$screen->action = $action;
$screen->post_type = (string) $post_type;
$screen->taxonomy = (string) $taxonomy;
$screen->is_user = $is_user;
$screen->is_network = $is_network;
self::$_registry[ $id ] = $screen;
return $screen;
}
/**
* Makes the screen object the current screen.
*
* @see set_current_screen()
* @since 3.3.0
*/
function set_current_screen() {
global $current_screen, $taxnow, $typenow;
$current_screen = $this;
$taxnow = $this->taxonomy;
$typenow = $this->post_type;
do_action( 'current_screen', $current_screen );
}
/**
* Constructor
*
* @since 3.3.0
* @access private
*/
private function __construct() {}
/**
* Sets the old string-based contextual help for the screen.
*
* For backwards compatibility.
*
* @since 3.3.0
*
* @param WP_Screen $screen A screen object.
* @param string $help Help text.
*/
static function add_old_compat_help( $screen, $help ) {
self::$_old_compat_help[ $screen->id ] = $help;
}
/**
* Set the parent information for the screen.
* This is called in admin-header.php after the menu parent for the screen has been determined.
*
* @since 3.3.0
*
* @param string $parent_file The parent file of the screen. Typically the $parent_file global.
*/
function set_parentage( $parent_file ) {
$this->parent_file = $parent_file;
list( $this->parent_base ) = explode( '?', $parent_file );
$this->parent_base = str_replace( '.php', '', $this->parent_base );
}
/**
* Adds an option for the screen.
* Call this in template files after admin.php is loaded and before admin-header.php is loaded to add screen options.
*
* @since 3.3.0
*
* @param string $option Option ID
* @param mixed $args Option-dependent arguments.
*/
public function add_option( $option, $args = array() ) {
$this->_options[ $option ] = $args;
}
/**
* Gets the arguments for an option for the screen.
*
* @since 3.3.0
*
* @param string $option Option ID.
* @param mixed $key Optional. Specific array key for when the option is an array.
*/
public function get_option( $option, $key = false ) {
if ( ! isset( $this->_options[ $option ] ) )
return null;
if ( $key ) {
if ( isset( $this->_options[ $option ][ $key ] ) )
return $this->_options[ $option ][ $key ];
return null;
}
return $this->_options[ $option ];
}
/**
* Gets the help tabs registered for the screen.
*
* @since 3.4.0
*
* @return array Help tabs with arguments.
*/
public function get_help_tabs() {
return $this->_help_tabs;
}
/**
* Gets the arguments for a help tab.
*
* @since 3.4.0
*
* @param string $id Help Tab ID.
* @return array Help tab arguments.
*/
public function get_help_tab( $id ) {
if ( ! isset( $this->_help_tabs[ $id ] ) )
return null;
return $this->_help_tabs[ $id ];
}
/**
* Add a help tab to the contextual help for the screen.
* Call this on the load-$pagenow hook for the relevant screen.
*
* @since 3.3.0
*
* @param array $args
* - string - title - Title for the tab.
* - string - id - Tab ID. Must be HTML-safe.
* - string - content - Help tab content in plain text or HTML. Optional.
* - callback - callback - A callback to generate the tab content. Optional.
*
*/
public function add_help_tab( $args ) {
$defaults = array(
'title' => false,
'id' => false,
'content' => '',
'callback' => false,
);
$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'] )
return;
// Allows for overriding an existing tab with that ID.
$this->_help_tabs[ $args['id'] ] = $args;
}
/**
* Removes a help tab from the contextual help for the screen.
*
* @since 3.3.0
*
* @param string $id The help tab ID.
*/
public function remove_help_tab( $id ) {
unset( $this->_help_tabs[ $id ] );
}
/**
* Removes all help tabs from the contextual help for the screen.
*
* @since 3.3.0
*/
public function remove_help_tabs() {
$this->_help_tabs = array();
}
/**
* Gets the content from a contextual help sidebar.
*
* @since 3.4.0
*
* @return string Contents of the help sidebar.
*/
public function get_help_sidebar() {
return $this->_help_sidebar;
}
/**
* Add a sidebar to the contextual help for the screen.
* Call this in template files after admin.php is loaded and before admin-header.php is loaded to add a sidebar to the contextual help.
*
* @since 3.3.0
*
* @param string $content Sidebar content in plain text or HTML.
*/
public function set_help_sidebar( $content ) {
$this->_help_sidebar = $content;
}
/**
* Gets the number of layout columns the user has selected.
*
* The layout_columns option controls the max number and default number of
* columns. This method returns the number of columns within that range selected
* by the user via Screen Options. If no selection has been made, the default
* provisioned in layout_columns is returned. If the screen does not support
* selecting the number of layout columns, 0 is returned.
*
* @since 3.4.0
*
* @return int Number of columns to display.
*/
public function get_columns() {
return $this->columns;
}
/**
* Render the screen's help section.
*
* This will trigger the deprecated filters for backwards compatibility.
*
* @since 3.3.0
*/
public function render_screen_meta() {
// Call old contextual_help_list filter.
self::$_old_compat_help = apply_filters( 'contextual_help_list', self::$_old_compat_help, $this );
$old_help = isset( self::$_old_compat_help[ $this->id ] ) ? self::$_old_compat_help[ $this->id ] : '';
$old_help = apply_filters( 'contextual_help', $old_help, $this->id, $this );
// Default help only if there is no old-style block of text and no new-style help tabs.
if ( empty( $old_help ) && ! $this->get_help_tabs() ) {
$default_help = apply_filters( 'default_contextual_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,
) );
}
$help_sidebar = $this->get_help_sidebar();
$help_class = 'hidden';
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 ); ?>">
<div id="contextual-help-back"></div>
<div id="contextual-help-columns">
<div class="contextual-help-tabs">
<ul>
<?php
$class = ' class="active"';
foreach ( $this->get_help_tabs() as $tab ) :
$link_id = "tab-link-{$tab['id']}";
$panel_id = "tab-panel-{$tab['id']}";
?>
<li id="<?php echo esc_attr( $link_id ); ?>"<?php echo $class; ?>>
<a href="<?php echo esc_url( "#$panel_id" ); ?>">
<?php echo esc_html( $tab['title'] ); ?>
</a>
</li>
<?php
$class = '';
endforeach;
?>
</ul>
</div>
<?php if ( $help_sidebar ) : ?>
<div class="contextual-help-sidebar">
<?php echo $help_sidebar; ?>
</div>
<?php endif; ?>
<div class="contextual-help-tabs-wrap">
<?php
$classes = 'help-tab-content active';
foreach ( $this->get_help_tabs() as $tab ):
$panel_id = "tab-panel-{$tab['id']}";
?>
<div id="<?php echo esc_attr( $panel_id ); ?>" class="<?php echo $classes; ?>">
<?php
// Print tab content.
echo $tab['content'];
// If it exists, fire tab callback.
if ( ! empty( $tab['callback'] ) )
call_user_func_array( $tab['callback'], array( $this, $tab ) );
?>
</div>
<?php
$classes = 'help-tab-content';
endforeach;
?>
</div>
</div>
</div>
<?php
// Setup layout columns
// Back compat for plugins using the filter instead of add_screen_option()
$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 ( $this->get_option( 'layout_columns' ) ) {
$this->columns = (int) get_user_option("screen_layout_$this->id");
if ( ! $this->columns && $this->get_option( 'layout_columns', 'default' ) )
$this->columns = $this->get_option( 'layout_columns', 'default' );
}
$GLOBALS[ 'screen_layout_columns' ] = $this->columns; // Set the global for back-compat.
// Add screen options
if ( $this->show_screen_options() )
$this->render_screen_options();
?>
</div>
<?php
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">
<a href="#contextual-help-wrap" id="contextual-help-link" class="show-settings"><?php _e( 'Help' ); ?></a>
</div>
<?php endif;
if ( $this->show_screen_options() ) : ?>
<div id="screen-options-link-wrap" class="hide-if-no-js screen-meta-toggle">
<a href="#screen-options-wrap" id="show-settings-link" class="show-settings"><?php _e( 'Screen Options' ); ?></a>
</div>
<?php endif; ?>
</div>
<?php
}
public function show_screen_options() {
global $wp_meta_boxes;
if ( is_bool( $this->_show_screen_options ) )
return $this->_show_screen_options;
$columns = get_column_headers( $this );
$show_screen = ! empty( $wp_meta_boxes[ $this->id ] ) || $columns || $this->get_option( 'per_page' );
$this->_screen_settings = apply_filters( 'screen_settings', '', $this );
switch ( $this->id ) {
case 'widgets':
$this->_screen_settings = '<p><a id="access-on" href="widgets.php?widgets-access=on">' . __('Enable accessibility mode') . '</a><a id="access-off" href="widgets.php?widgets-access=off">' . __('Disable accessibility mode') . "</a></p>\n";
break;
}
if ( $this->_screen_settings || $this->_options )
$show_screen = true;
$this->_show_screen_options = apply_filters( 'screen_options_show_screen', $show_screen, $this );
return $this->_show_screen_options;
}
/**
* Render the screen options tab.
*
* @since 3.3.0
*/
public function render_screen_options() {
global $wp_meta_boxes, $wp_list_table;
$columns = get_column_headers( $this );
$hidden = get_hidden_columns( $this );
?>
<div id="screen-options-wrap" class="hidden">
<form id="adv-settings" action="" method="post">
<?php if ( isset( $wp_meta_boxes[ $this->id ] ) || $this->get_option( 'per_page' ) || ( $columns && empty( $columns['_title'] ) ) ) : ?>
<h5><?php _e( 'Show on screen' ); ?></h5>
<?php
endif;
if ( isset( $wp_meta_boxes[ $this->id ] ) ) : ?>
<div class="metabox-prefs">
<?php
meta_box_prefs( $this );
if ( 'dashboard' === $this->id && 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";
}
?>
<br class="clear" />
</div>
<?php endif;
if ( $columns ) :
if ( ! empty( $columns['_title'] ) ) : ?>
<h5><?php echo $columns['_title']; ?></h5>
<?php endif; ?>
<div class="metabox-prefs">
<?php
$special = array('_title', 'cb', 'comment', 'media', 'name', 'title', 'username', 'blogname');
foreach ( $columns as $column => $title ) {
// Can't hide these for they are special
if ( in_array( $column, $special ) )
continue;
if ( empty( $title ) )
continue;
if ( 'comments' == $column )
$title = __( 'Comments' );
$id = "$column-hide";
echo '<label for="' . $id . '">';
echo '<input class="hide-column-tog" name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $column . '"' . checked( !in_array($column, $hidden), true, false ) . ' />';
echo "$title</label>\n";
}
?>
<br class="clear" />
</div>
<?php endif;
$this->render_screen_layout();
$this->render_per_page_options();
echo $this->_screen_settings;
?>
<div><?php wp_nonce_field( 'screen-options-nonce', 'screenoptionnonce', false ); ?></div>
</form>
</div>
<?php
}
/**
* Render the option for number of columns on the page
*
* @since 3.3.0
*/
function render_screen_layout() {
if ( ! $this->get_option('layout_columns') )
return;
$screen_layout_columns = $this->get_columns();
$num = $this->get_option( 'layout_columns', 'max' );
?>
<h5 class="screen-layout"><?php _e('Screen Layout'); ?></h5>
<div class='columns-prefs'><?php
_e('Number of Columns:');
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 echo esc_html( $i ); ?>
</label>
<?php
endfor; ?>
</div>
<?php
}
/**
* Render the items per page option
*
* @since 3.3.0
*/
function render_per_page_options() {
if ( ! $this->get_option( 'per_page' ) )
return;
$per_page_label = $this->get_option( 'per_page', 'label' );
$option = $this->get_option( 'per_page', 'option' );
if ( ! $option )
$option = str_replace( '-', '_', "{$this->id}_per_page" );
$per_page = (int) get_user_option( $option );
if ( empty( $per_page ) || $per_page < 1 ) {
$per_page = $this->get_option( 'per_page', 'default' );
if ( ! $per_page )
$per_page = 20;
}
if ( 'edit_comments_per_page' == $option ) {
$comment_status = isset( $_REQUEST['comment_status'] ) ? $_REQUEST['comment_status'] : 'all';
$per_page = apply_filters( 'comments_per_page', $per_page, $comment_status );
} elseif ( 'categories_per_page' == $option ) {
$per_page = apply_filters( 'edit_categories_per_page', $per_page );
} else {
$per_page = apply_filters( $option, $per_page );
}
// Back compat
if ( isset( $this->post_type ) )
$per_page = apply_filters( 'edit_posts_per_page', $per_page, $this->post_type );
?>
<div class="screen-options">
<?php if ( $per_page_label ) : ?>
<input type="number" step="1" min="1" max="999" class="screen-per-page" name="wp_screen_options[value]"
id="<?php echo esc_attr( $option ); ?>" maxlength="3"
value="<?php echo esc_attr( $per_page ); ?>" />
<label for="<?php echo esc_attr( $option ); ?>">
<?php echo esc_html( $per_page_label ); ?>
</label>
<?php endif;
echo get_submit_button( __( 'Apply' ), 'button', 'screen-options-apply', false ); ?>
<input type='hidden' name='wp_screen_options[option]' value='<?php echo esc_attr($option); ?>' />
</div>
<?php
}
}
| 01happy-blog | trunk/myblog/wp-admin/includes/screen.php | PHP | oos | 27,342 |
<?php
/**
* File contains all the administration image manipulation functions.
*
* @package WordPress
* @subpackage Administration
*/
/**
* Create a thumbnail from an Image given a maximum side size.
*
* This function can handle most image file formats which PHP supports. If PHP
* does not have the functionality to save in a file of the same format, the
* thumbnail will be created as a jpeg.
*
* @since 1.2.0
*
* @param mixed $file Filename of the original image, Or attachment id.
* @param int $max_side Maximum length of a single side for the thumbnail.
* @param mixed $deprecated Never used.
* @return string Thumbnail path on success, Error string on failure.
*/
function wp_create_thumbnail( $file, $max_side, $deprecated = '' ) {
if ( !empty( $deprecated ) )
_deprecated_argument( __FUNCTION__, '1.2' );
$thumbpath = image_resize( $file, $max_side, $max_side );
return apply_filters( 'wp_create_thumbnail', $thumbpath );
}
/**
* Crop an Image to a given size.
*
* @since 2.1.0
*
* @param string|int $src The source file or Attachment ID.
* @param int $src_x The start x position to crop from.
* @param int $src_y The start y position to crop from.
* @param int $src_w The width to crop.
* @param int $src_h The height to crop.
* @param int $dst_w The destination width.
* @param int $dst_h The destination height.
* @param int $src_abs Optional. If the source crop points are absolute.
* @param string $dst_file Optional. The destination file to write to.
* @return string|WP_Error|false New filepath on success, WP_Error or false on failure.
*/
function wp_crop_image( $src, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs = false, $dst_file = false ) {
if ( is_numeric( $src ) ) { // Handle int as attachment ID
$src_file = get_attached_file( $src );
if ( ! file_exists( $src_file ) ) {
// If the file doesn't exist, attempt a url fopen on the src link.
// This can occur with certain file replication plugins.
$post = get_post( $src );
$image_type = $post->post_mime_type;
$src = load_image_to_edit( $src, $post->post_mime_type, 'full' );
} else {
$size = @getimagesize( $src_file );
$image_type = ( $size ) ? $size['mime'] : '';
$src = wp_load_image( $src_file );
}
} else {
$size = @getimagesize( $src );
$image_type = ( $size ) ? $size['mime'] : '';
$src = wp_load_image( $src );
}
if ( ! is_resource( $src ) )
return new WP_Error( 'error_loading_image', $src, $src_file );
$dst = wp_imagecreatetruecolor( $dst_w, $dst_h );
if ( $src_abs ) {
$src_w -= $src_x;
$src_h -= $src_y;
}
if ( function_exists( 'imageantialias' ) )
imageantialias( $dst, true );
imagecopyresampled( $dst, $src, 0, 0, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h );
imagedestroy( $src ); // Free up memory
if ( ! $dst_file )
$dst_file = str_replace( basename( $src_file ), 'cropped-' . basename( $src_file ), $src_file );
if ( 'image/png' != $image_type )
$dst_file = preg_replace( '/\\.[^\\.]+$/', '.jpg', $dst_file );
// The directory containing the original file may no longer exist when
// using a replication plugin.
wp_mkdir_p( dirname( $dst_file ) );
$dst_file = dirname( $dst_file ) . '/' . wp_unique_filename( dirname( $dst_file ), basename( $dst_file ) );
if ( 'image/png' == $image_type && imagepng( $dst, $dst_file ) )
return $dst_file;
elseif ( imagejpeg( $dst, $dst_file, apply_filters( 'jpeg_quality', 90, 'wp_crop_image' ) ) )
return $dst_file;
else
return false;
}
/**
* Generate post thumbnail attachment meta data.
*
* @since 2.1.0
*
* @param int $attachment_id Attachment Id to process.
* @param string $file Filepath of the Attached image.
* @return mixed Metadata for attachment.
*/
function wp_generate_attachment_metadata( $attachment_id, $file ) {
$attachment = get_post( $attachment_id );
$metadata = array();
if ( preg_match('!^image/!', get_post_mime_type( $attachment )) && file_is_displayable_image($file) ) {
$imagesize = getimagesize( $file );
$metadata['width'] = $imagesize[0];
$metadata['height'] = $imagesize[1];
list($uwidth, $uheight) = wp_constrain_dimensions($metadata['width'], $metadata['height'], 128, 96);
$metadata['hwstring_small'] = "height='$uheight' width='$uwidth'";
// Make the file path relative to the upload dir
$metadata['file'] = _wp_relative_upload_path($file);
// make thumbnails and other intermediate sizes
global $_wp_additional_image_sizes;
foreach ( get_intermediate_image_sizes() as $s ) {
$sizes[$s] = array( 'width' => '', 'height' => '', 'crop' => false );
if ( isset( $_wp_additional_image_sizes[$s]['width'] ) )
$sizes[$s]['width'] = intval( $_wp_additional_image_sizes[$s]['width'] ); // For theme-added sizes
else
$sizes[$s]['width'] = get_option( "{$s}_size_w" ); // For default sizes set in options
if ( isset( $_wp_additional_image_sizes[$s]['height'] ) )
$sizes[$s]['height'] = intval( $_wp_additional_image_sizes[$s]['height'] ); // For theme-added sizes
else
$sizes[$s]['height'] = get_option( "{$s}_size_h" ); // For default sizes set in options
if ( isset( $_wp_additional_image_sizes[$s]['crop'] ) )
$sizes[$s]['crop'] = intval( $_wp_additional_image_sizes[$s]['crop'] ); // For theme-added sizes
else
$sizes[$s]['crop'] = get_option( "{$s}_crop" ); // For default sizes set in options
}
$sizes = apply_filters( 'intermediate_image_sizes_advanced', $sizes );
foreach ($sizes as $size => $size_data ) {
$resized = image_make_intermediate_size( $file, $size_data['width'], $size_data['height'], $size_data['crop'] );
if ( $resized )
$metadata['sizes'][$size] = $resized;
}
// fetch additional metadata from exif/iptc
$image_meta = wp_read_image_metadata( $file );
if ( $image_meta )
$metadata['image_meta'] = $image_meta;
}
return apply_filters( 'wp_generate_attachment_metadata', $metadata, $attachment_id );
}
/**
* Calculated the new dimensions for a downsampled image.
*
* @since 2.0.0
* @see wp_constrain_dimensions()
*
* @param int $width Current width of the image
* @param int $height Current height of the image
* @return mixed Array(height,width) of shrunk dimensions.
*/
function get_udims( $width, $height) {
return wp_constrain_dimensions( $width, $height, 128, 96 );
}
/**
* Convert a fraction string to a decimal.
*
* @since 2.5.0
*
* @param string $str
* @return int|float
*/
function wp_exif_frac2dec($str) {
@list( $n, $d ) = explode( '/', $str );
if ( !empty($d) )
return $n / $d;
return $str;
}
/**
* Convert the exif date format to a unix timestamp.
*
* @since 2.5.0
*
* @param string $str
* @return int
*/
function wp_exif_date2ts($str) {
@list( $date, $time ) = explode( ' ', trim($str) );
@list( $y, $m, $d ) = explode( ':', $date );
return strtotime( "{$y}-{$m}-{$d} {$time}" );
}
/**
* Get extended image metadata, exif or iptc as available.
*
* Retrieves the EXIF metadata aperture, credit, camera, caption, copyright, iso
* created_timestamp, focal_length, shutter_speed, and title.
*
* The IPTC metadata that is retrieved is APP13, credit, byline, created date
* and time, caption, copyright, and title. Also includes FNumber, Model,
* DateTimeDigitized, FocalLength, ISOSpeedRatings, and ExposureTime.
*
* @todo Try other exif libraries if available.
* @since 2.5.0
*
* @param string $file
* @return bool|array False on failure. Image metadata array on success.
*/
function wp_read_image_metadata( $file ) {
if ( ! file_exists( $file ) )
return false;
list( , , $sourceImageType ) = getimagesize( $file );
// exif contains a bunch of data we'll probably never need formatted in ways
// that are difficult to use. We'll normalize it and just extract the fields
// that are likely to be useful. Fractions and numbers are converted to
// floats, dates to unix timestamps, and everything else to strings.
$meta = array(
'aperture' => 0,
'credit' => '',
'camera' => '',
'caption' => '',
'created_timestamp' => 0,
'copyright' => '',
'focal_length' => 0,
'iso' => 0,
'shutter_speed' => 0,
'title' => '',
);
// read iptc first, since it might contain data not available in exif such
// as caption, description etc
if ( is_callable( 'iptcparse' ) ) {
getimagesize( $file, $info );
if ( ! empty( $info['APP13'] ) ) {
$iptc = iptcparse( $info['APP13'] );
// headline, "A brief synopsis of the caption."
if ( ! empty( $iptc['2#105'][0] ) )
$meta['title'] = utf8_encode( 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."
elseif ( ! empty( $iptc['2#005'][0] ) )
$meta['title'] = utf8_encode( trim( $iptc['2#005'][0] ) );
if ( ! empty( $iptc['2#120'][0] ) ) { // description / legacy caption
$caption = utf8_encode( trim( $iptc['2#120'][0] ) );
if ( empty( $meta['title'] ) ) {
// Assume the title is stored in 2:120 if it's short.
if ( strlen( $caption ) < 80 )
$meta['title'] = $caption;
else
$meta['caption'] = $caption;
} elseif ( $caption != $meta['title'] ) {
$meta['caption'] = $caption;
}
}
if ( ! empty( $iptc['2#110'][0] ) ) // credit
$meta['credit'] = utf8_encode(trim($iptc['2#110'][0]));
elseif ( ! empty( $iptc['2#080'][0] ) ) // creator / legacy byline
$meta['credit'] = utf8_encode(trim($iptc['2#080'][0]));
if ( ! empty( $iptc['2#055'][0] ) and ! 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
$meta['copyright'] = utf8_encode( trim( $iptc['2#116'][0] ) );
}
}
// fetch additional info from exif if available
if ( is_callable( 'exif_read_data' ) && in_array( $sourceImageType, apply_filters( 'wp_read_image_metadata_types', array( IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM ) ) ) ) {
$exif = @exif_read_data( $file );
if ( !empty( $exif['Title'] ) )
$meta['title'] = utf8_encode( trim( $exif['Title'] ) );
if ( ! empty( $exif['ImageDescription'] ) ) {
if ( empty( $meta['title'] ) && strlen( $exif['ImageDescription'] ) < 80 ) {
// Assume the title is stored in ImageDescription
$meta['title'] = utf8_encode( trim( $exif['ImageDescription'] ) );
if ( ! empty( $exif['COMPUTED']['UserComment'] ) && trim( $exif['COMPUTED']['UserComment'] ) != $meta['title'] )
$meta['caption'] = utf8_encode( trim( $exif['COMPUTED']['UserComment'] ) );
} elseif ( trim( $exif['ImageDescription'] ) != $meta['title'] ) {
$meta['caption'] = utf8_encode( trim( $exif['ImageDescription'] ) );
}
} elseif ( ! empty( $exif['Comments'] ) && trim( $exif['Comments'] ) != $meta['title'] ) {
$meta['caption'] = utf8_encode( trim( $exif['Comments'] ) );
}
if ( ! empty( $exif['Artist'] ) )
$meta['credit'] = utf8_encode( trim( $exif['Artist'] ) );
elseif ( ! empty($exif['Author'] ) )
$meta['credit'] = utf8_encode( trim( $exif['Author'] ) );
if ( ! empty( $exif['Copyright'] ) )
$meta['copyright'] = utf8_encode( trim( $exif['Copyright'] ) );
if ( ! empty($exif['FNumber'] ) )
$meta['aperture'] = round( wp_exif_frac2dec( $exif['FNumber'] ), 2 );
if ( ! empty($exif['Model'] ) )
$meta['camera'] = utf8_encode( trim( $exif['Model'] ) );
if ( ! empty($exif['DateTimeDigitized'] ) )
$meta['created_timestamp'] = wp_exif_date2ts($exif['DateTimeDigitized'] );
if ( ! empty($exif['FocalLength'] ) )
$meta['focal_length'] = wp_exif_frac2dec( $exif['FocalLength'] );
if ( ! empty($exif['ISOSpeedRatings'] ) ) {
$meta['iso'] = is_array( $exif['ISOSpeedRatings'] ) ? reset( $exif['ISOSpeedRatings'] ) : $exif['ISOSpeedRatings'];
$meta['iso'] = utf8_encode( trim( $meta['iso'] ) );
}
if ( ! empty($exif['ExposureTime'] ) )
$meta['shutter_speed'] = wp_exif_frac2dec( $exif['ExposureTime'] );
}
return apply_filters( 'wp_read_image_metadata', $meta, $file, $sourceImageType );
}
/**
* Validate that file is an image.
*
* @since 2.5.0
*
* @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);
}
/**
* Validate that file is suitable for displaying within a web page.
*
* @since 2.5.0
* @uses apply_filters() Calls 'file_is_displayable_image' on $result and $path.
*
* @param string $path File path to test.
* @return bool True if suitable, false if not suitable.
*/
function file_is_displayable_image($path) {
$info = @getimagesize($path);
if ( empty($info) )
$result = false;
elseif ( !in_array($info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG)) ) // only gif, jpeg and png images can reliably be displayed
$result = false;
else
$result = true;
return apply_filters('file_is_displayable_image', $result, $path);
}
/**
* Load an image resource for editing.
*
* @since 2.9.0
*
* @param string $attachment_id Attachment ID.
* @param string $mime_type Image mime type.
* @param string $size Optional. Image size, defaults to 'full'.
* @return resource|false The resulting image resource on success, false on failure.
*/
function load_image_to_edit( $attachment_id, $mime_type, $size = 'full' ) {
$filepath = _load_image_to_edit_path( $attachment_id, $size );
if ( empty( $filepath ) )
return false;
switch ( $mime_type ) {
case 'image/jpeg':
$image = imagecreatefromjpeg($filepath);
break;
case 'image/png':
$image = imagecreatefrompng($filepath);
break;
case 'image/gif':
$image = imagecreatefromgif($filepath);
break;
default:
$image = false;
break;
}
if ( is_resource($image) ) {
$image = apply_filters('load_image_to_edit', $image, $attachment_id, $size);
if ( function_exists('imagealphablending') && function_exists('imagesavealpha') ) {
imagealphablending($image, false);
imagesavealpha($image, true);
}
}
return $image;
}
/**
* Retrieve the path or url of an attachment's attached file.
*
* If the attached file is not present on the local filesystem (usually due to replication plugins),
* then the url of the file is returned if url fopen is supported.
*
* @since 3.4.0
* @access private
*
* @param string $attachment_id Attachment ID.
* @param string $size Optional. Image size, defaults to 'full'.
* @return string|false File path or url on success, false on failure.
*/
function _load_image_to_edit_path( $attachment_id, $size = 'full' ) {
$filepath = get_attached_file( $attachment_id );
if ( $filepath && file_exists( $filepath ) ) {
if ( 'full' != $size && ( $data = image_get_intermediate_size( $attachment_id, $size ) ) ) {
$filepath = apply_filters( 'load_image_to_edit_filesystempath', path_join( dirname( $filepath ), $data['file'] ), $attachment_id, $size );
}
} elseif ( function_exists( 'fopen' ) && function_exists( 'ini_get' ) && true == ini_get( 'allow_url_fopen' ) ) {
$filepath = apply_filters( 'load_image_to_edit_attachmenturl', wp_get_attachment_url( $attachment_id ), $attachment_id, $size );
}
return apply_filters( 'load_image_to_edit_path', $filepath, $attachment_id, $size );
}
/**
* Copy an existing image file.
*
* @since 3.4.0
* @access private
*
* @param string $attachment_id Attachment ID.
* @return string|false New file path on success, false on failure.
*/
function _copy_image_file( $attachment_id ) {
$dst_file = $src_file = get_attached_file( $attachment_id );
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 );
$dst_file = dirname( $dst_file ) . '/' . wp_unique_filename( dirname( $dst_file ), basename( $dst_file ) );
// The directory containing the original file may no longer exist when
// using a replication plugin.
wp_mkdir_p( dirname( $dst_file ) );
if ( ! @copy( $src_file, $dst_file ) )
$dst_file = false;
} else {
$dst_file = false;
}
return $dst_file;
}
| 01happy-blog | trunk/myblog/wp-admin/includes/image.php | PHP | oos | 16,162 |
<?php
/**
* Theme Installer List Table class.
*
* @package WordPress
* @subpackage List_Table
* @since 3.1.0
* @access private
*/
class WP_Theme_Install_List_Table extends WP_Themes_List_Table {
var $features = array();
function ajax_user_can() {
return current_user_can( 'install_themes' );
}
function prepare_items() {
include( ABSPATH . 'wp-admin/includes/theme-install.php' );
global $tabs, $tab, $paged, $type, $theme_field_defaults;
wp_reset_vars( array( 'tab' ) );
$search_terms = array();
$search_string = '';
if ( ! empty( $_REQUEST['s'] ) ){
$search_string = strtolower( stripslashes( $_REQUEST['s'] ) );
$search_terms = array_unique( array_filter( array_map( 'trim', explode( ',', $search_string ) ) ) );
}
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['dashboard'] = __( 'Search' );
if ( 'search' == $tab )
$tabs['search'] = __( 'Search Results' );
$tabs['upload'] = __( 'Upload' );
$tabs['featured'] = _x( 'Featured','Theme Installer' );
//$tabs['popular'] = _x( 'Popular','Theme Installer' );
$tabs['new'] = _x( 'Newest','Theme Installer' );
$tabs['updated'] = _x( 'Recently Updated','Theme Installer' );
$nonmenu_tabs = array( 'theme-information' ); // Valid actions to perform which do not have a Menu item.
$tabs = apply_filters( 'install_themes_tabs', $tabs );
$nonmenu_tabs = apply_filters( 'install_themes_nonmenu_tabs', $nonmenu_tabs );
// If a non-valid menu tab has been selected, And its not a non-menu action.
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 );
switch ( $tab ) {
case 'search':
$type = isset( $_REQUEST['type'] ) ? stripslashes( $_REQUEST['type'] ) : 'term';
switch ( $type ) {
case 'tag':
$args['tag'] = array_map( 'sanitize_key', $search_terms );
break;
case 'term':
$args['search'] = $search_string;
break;
case 'author':
$args['author'] = $search_string;
break;
}
if ( ! empty( $this->features ) ) {
$args['tag'] = $this->features;
$_REQUEST['s'] = implode( ',', $this->features );
$_REQUEST['type'] = 'tag';
}
add_action( 'install_themes_table_header', 'install_theme_search_form', 10, 0 );
break;
case 'featured':
//case 'popular':
case 'new':
case 'updated':
$args['browse'] = $tab;
break;
default:
$args = false;
}
if ( ! $args )
return;
$api = themes_api( 'query_themes', $args );
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' => $per_page,
'infinite_scroll' => true,
) );
}
function no_items() {
_e( 'No themes match your request.' );
}
function get_views() {
global $tabs, $tab;
$display_tabs = array();
foreach ( (array) $tabs as $action => $text ) {
$class = ( $action == $tab ) ? ' class="current"' : '';
$href = self_admin_url('theme-install.php?tab=' . $action);
$display_tabs['theme-install-'.$action] = "<a href='$href'$class>$text</a>";
}
return $display_tabs;
}
function display() {
wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' );
?>
<div class="tablenav top themes">
<div class="alignleft actions">
<?php do_action( 'install_themes_table_header' ); ?>
</div>
<?php $this->pagination( 'top' ); ?>
<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-loading list-ajax-loading" alt="" />
<br class="clear" />
</div>
<div id="availablethemes">
<?php $this->display_rows_or_placeholder(); ?>
</div>
<?php
parent::tablenav( 'bottom' );
}
function display_rows() {
$themes = $this->items;
foreach ( $themes as $theme ) {
?>
<div class="available-theme installable-theme"><?php
$this->single_row( $theme );
?></div>
<?php } // end foreach $theme_names
$this->theme_installer();
}
/*
* Prints a theme from the WordPress.org API.
*
* @param object $theme An object that contains theme data returned by the WordPress.org API.
*
* Example theme data:
* object(stdClass)[59]
* public 'name' => string 'Magazine Basic' (length=14)
* public 'slug' => string 'magazine-basic' (length=14)
* public 'version' => string '1.1' (length=3)
* public 'author' => string 'tinkerpriest' (length=12)
* public 'preview_url' => string 'http://wp-themes.com/?magazine-basic' (length=36)
* public 'screenshot_url' => string 'http://wp-themes.com/wp-content/themes/magazine-basic/screenshot.png' (length=68)
* public 'rating' => float 80
* public 'num_ratings' => int 1
* public 'homepage' => string 'http://wordpress.org/extend/themes/magazine-basic' (length=49)
* public 'description' => string 'A basic magazine style layout with a fully customizable layout through a backend interface. Designed by <a href="http://bavotasan.com">c.bavota</a> of <a href="http://tinkerpriestmedia.com">Tinker Priest Media</a>.' (length=214)
* public 'download_link' => string 'http://wordpress.org/extend/themes/download/magazine-basic.1.1.zip' (length=66)
*/
function single_row( $theme ) {
global $themes_allowedtags;
if ( empty( $theme ) )
return;
$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,
) );
$actions = array();
$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' ) );
$status = $this->_get_theme_status( $theme );
switch ( $status ) {
default:
case 'install':
$actions[] = '<a class="install-now" href="' . esc_url( wp_nonce_url( $install_url, 'install-theme_' . $theme->slug ) ) . '" title="' . esc_attr( sprintf( __( 'Install %s' ), $name ) ) . '">' . __( 'Install Now' ) . '</a>';
break;
case 'update_available':
$actions[] = '<a class="install-now" 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':
$actions[] = '<span class="install-now" title="' . esc_attr__( 'This theme is already installed and is up to date' ) . '">' . _x( 'Installed', 'theme' ) . '</span>';
break;
}
$actions[] = '<a class="install-theme-preview" href="' . esc_url( $preview_url ) . '" title="' . esc_attr( sprintf( __( 'Preview %s' ), $name ) ) . '">' . __( 'Preview' ) . '</a>';
$actions = apply_filters( 'theme_install_actions', $actions, $theme );
?>
<a class="screenshot install-theme-preview" href="<?php echo esc_url( $preview_url ); ?>" title="<?php echo esc_attr( $preview_title ); ?>">
<img src='<?php echo esc_url( $theme->screenshot_url ); ?>' width='150' />
</a>
<h3><?php echo $name; ?></h3>
<div class="theme-author"><?php printf( __( 'By %s' ), $author ); ?></div>
<div class="action-links">
<ul>
<?php foreach ( $actions as $action ): ?>
<li><?php echo $action; ?></li>
<?php endforeach; ?>
<li class="hide-if-no-js"><a href="#" class="theme-detail" tabindex='4'><?php _e('Details') ?></a></li>
</ul>
</div>
<?php
$this->install_theme_info( $theme );
}
/*
* Prints the wrapper for the theme installer.
*/
function theme_installer() {
?>
<div id="theme-installer" class="wp-full-overlay expanded">
<div class="wp-full-overlay-sidebar">
<div class="wp-full-overlay-header">
<a href="#" class="close-full-overlay"><?php _e( '← Close' ); ?></a>
</div>
<div class="wp-full-overlay-sidebar-content">
<div class="install-theme-info"></div>
</div>
<div class="wp-full-overlay-footer">
<a href="#" class="collapse-sidebar button-secondary" title="<?php esc_attr_e('Collapse Sidebar'); ?>">
<span class="collapse-sidebar-label"><?php _e('Collapse'); ?></span>
<span class="collapse-sidebar-arrow"></span>
</a>
</div>
</div>
<div class="wp-full-overlay-main"></div>
</div>
<?php
}
/*
* Prints the wrapper for the theme installer with a provided theme's data.
* Used to make the theme installer work for no-js.
*
* @param object $theme - A WordPress.org Theme API object.
*/
function theme_installer_single( $theme ) {
?>
<div id="theme-installer" class="wp-full-overlay single-theme">
<div class="wp-full-overlay-sidebar">
<?php $this->install_theme_info( $theme ); ?>
</div>
<div class="wp-full-overlay-main">
<iframe src="<?php echo esc_url( $theme->preview_url ); ?>"></iframe>
</div>
</div>
<?php
}
/*
* Prints the info for a theme (to be used in the theme installer modal).
*
* @param object $theme - A WordPress.org Theme API object.
*/
function install_theme_info( $theme ) {
global $themes_allowedtags;
if ( empty( $theme ) )
return;
$name = wp_kses( $theme->name, $themes_allowedtags );
$author = wp_kses( $theme->author, $themes_allowedtags );
$num_ratings = sprintf( _n( '(based on %s rating)', '(based on %s ratings)', $theme->num_ratings ), number_format_i18n( $theme->num_ratings ) );
$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' ) );
$status = $this->_get_theme_status( $theme );
?>
<div class="install-theme-info"><?php
switch ( $status ) {
default:
case 'install':
echo '<a class="theme-install button-primary" href="' . esc_url( wp_nonce_url( $install_url, 'install-theme_' . $theme->slug ) ) . '">' . __( 'Install' ) . '</a>';
break;
case 'update_available':
echo '<a class="theme-install 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;
} ?>
<h3 class="theme-name"><?php echo $name; ?></h3>
<span class="theme-by"><?php printf( __( 'By %s' ), $author ); ?></span>
<?php if ( isset( $theme->screenshot_url ) ): ?>
<img class="theme-screenshot" src="<?php echo esc_url( $theme->screenshot_url ); ?>" />
<?php endif; ?>
<div class="theme-details">
<div class="star-holder" title="<?php echo esc_attr( $num_ratings ); ?>">
<div class="star-rating" style="width:<?php echo esc_attr( intval( $theme->rating ) . 'px' ); ?>;"></div>
</div>
<div class="theme-version">
<strong><?php _e('Version:') ?> </strong>
<?php echo wp_kses( $theme->version, $themes_allowedtags ); ?>
</div>
<div class="theme-description">
<?php echo wp_kses( $theme->description, $themes_allowedtags ); ?>
</div>
</div>
<input class="theme-preview-url" type="hidden" value="<?php echo esc_url( $theme->preview_url ); ?>" />
</div>
<?php
}
/**
* Send required variables to JavaScript land
*
* @since 3.4
* @access private
*
* @uses $tab Global; current tab within Themes->Install screen
* @uses $type Global; type of search.
*/
function _js_vars() {
global $tab, $type;
parent::_js_vars( compact( 'tab', 'type' ) );
}
/**
* Check to see if the theme is already installed.
*
* @since 3.4
* @access private
*
* @param object $theme - A WordPress.org Theme API object.
* @return string Theme status.
*/
private function _get_theme_status( $theme ) {
$status = 'install';
$installed_theme = wp_get_theme( $theme->slug );
if ( $installed_theme->exists() ) {
if ( version_compare( $installed_theme->get('Version'), $theme->version, '=' ) )
$status = 'latest_installed';
elseif ( version_compare( $installed_theme->get('Version'), $theme->version, '>' ) )
$status = 'newer_installed';
else
$status = 'update_available';
}
return $status;
}
}
| 01happy-blog | trunk/myblog/wp-admin/includes/class-wp-theme-install-list-table.php | PHP | oos | 13,091 |
<?php
/**
* Terms List Table class.
*
* @package WordPress
* @subpackage List_Table
* @since 3.1.0
* @access private
*/
class WP_Terms_List_Table extends WP_List_Table {
var $callback_args;
function __construct() {
global $post_type, $taxonomy, $tax;
wp_reset_vars( array( 'action', 'taxonomy', 'post_type' ) );
if ( empty( $taxonomy ) )
$taxonomy = 'post_tag';
if ( !taxonomy_exists( $taxonomy ) )
wp_die( __( 'Invalid taxonomy' ) );
$tax = get_taxonomy( $taxonomy );
if ( empty( $post_type ) || !in_array( $post_type, get_post_types( array( 'show_ui' => true ) ) ) )
$post_type = 'post';
parent::__construct( array(
'plural' => 'tags',
'singular' => 'tag',
) );
}
function ajax_user_can() {
global $tax;
return current_user_can( $tax->cap->manage_terms );
}
function prepare_items() {
global $taxonomy;
$tags_per_page = $this->get_items_per_page( 'edit_' . $taxonomy . '_per_page' );
if ( 'post_tag' == $taxonomy ) {
$tags_per_page = apply_filters( 'edit_tags_per_page', $tags_per_page );
$tags_per_page = apply_filters( 'tagsperpage', $tags_per_page ); // Old filter
} elseif ( 'category' == $taxonomy ) {
$tags_per_page = apply_filters( 'edit_categories_per_page', $tags_per_page ); // Old filter
}
$search = !empty( $_REQUEST['s'] ) ? trim( stripslashes( $_REQUEST['s'] ) ) : '';
$args = array(
'search' => $search,
'page' => $this->get_pagenum(),
'number' => $tags_per_page,
);
if ( !empty( $_REQUEST['orderby'] ) )
$args['orderby'] = trim( stripslashes( $_REQUEST['orderby'] ) );
if ( !empty( $_REQUEST['order'] ) )
$args['order'] = trim( stripslashes( $_REQUEST['order'] ) );
$this->callback_args = $args;
$this->set_pagination_args( array(
'total_items' => wp_count_terms( $taxonomy, compact( 'search' ) ),
'per_page' => $tags_per_page,
) );
}
function has_items() {
// todo: populate $this->items in prepare_items()
return true;
}
function get_bulk_actions() {
$actions = array();
$actions['delete'] = __( 'Delete' );
return $actions;
}
function current_action() {
if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['delete_tags'] ) && ( 'delete' == $_REQUEST['action'] || 'delete' == $_REQUEST['action2'] ) )
return 'bulk-delete';
return parent::current_action();
}
function get_columns() {
global $taxonomy, $post_type;
$columns = array(
'cb' => '<input type="checkbox" />',
'name' => _x( 'Name', 'term name' ),
'description' => __( 'Description' ),
'slug' => __( 'Slug' ),
);
if ( 'link_category' == $taxonomy ) {
$columns['links'] = __( 'Links' );
} else {
$post_type_object = get_post_type_object( $post_type );
$columns['posts'] = $post_type_object ? $post_type_object->labels->name : __( 'Posts' );
}
return $columns;
}
function get_sortable_columns() {
return array(
'name' => 'name',
'description' => 'description',
'slug' => 'slug',
'posts' => 'count',
'links' => 'count'
);
}
function display_rows_or_placeholder() {
global $taxonomy;
$args = wp_parse_args( $this->callback_args, array(
'page' => 1,
'number' => 20,
'search' => '',
'hide_empty' => 0
) );
extract( $args, EXTR_SKIP );
$args['offset'] = $offset = ( $page - 1 ) * $number;
// convert it to table rows
$out = '';
$count = 0;
$terms = array();
if ( is_taxonomy_hierarchical( $taxonomy ) && !isset( $orderby ) ) {
// We'll need the full set of terms then.
$args['number'] = $args['offset'] = 0;
$terms = get_terms( $taxonomy, $args );
if ( !empty( $search ) ) // Ignore children on searches.
$children = array();
else
$children = _get_term_hierarchy( $taxonomy );
// Some funky recursion to get the job done( Paging & parents mainly ) is contained within, Skip it for non-hierarchical taxonomies for performance sake
$out .= $this->_rows( $taxonomy, $terms, $children, $offset, $number, $count );
} else {
$terms = get_terms( $taxonomy, $args );
foreach ( $terms as $term )
$out .= $this->single_row( $term, 0, $taxonomy );
$count = $number; // Only displaying a single page.
}
if ( empty( $terms ) ) {
list( $columns, $hidden ) = $this->get_column_info();
echo '<tr class="no-items"><td class="colspanchange" colspan="' . $this->get_column_count() . '">';
$this->no_items();
echo '</td></tr>';
} else {
echo $out;
}
}
function _rows( $taxonomy, $terms, &$children, $start = 0, $per_page = 20, &$count, $parent = 0, $level = 0 ) {
$end = $start + $per_page;
$output = '';
foreach ( $terms as $key => $term ) {
if ( $count >= $end )
break;
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;
while ( $p ) {
$my_parent = get_term( $p, $taxonomy );
$my_parents[] = $my_parent;
$p = $my_parent->parent;
if ( in_array( $p, $parent_ids ) ) // Prevent parent loops.
break;
$parent_ids[] = $p;
}
unset( $parent_ids );
$num_parents = count( $my_parents );
while ( $my_parent = array_pop( $my_parents ) ) {
$output .= "\t" . $this->single_row( $my_parent, $level - $num_parents, $taxonomy );
$num_parents--;
}
}
if ( $count >= $start )
$output .= "\t" . $this->single_row( $term, $level, $taxonomy );
++$count;
unset( $terms[$key] );
if ( isset( $children[$term->term_id] ) && empty( $_REQUEST['s'] ) )
$output .= $this->_rows( $taxonomy, $terms, $children, $start, $per_page, $count, $term->term_id, $level + 1 );
}
return $output;
}
function single_row( $tag, $level = 0 ) {
static $row_class = '';
$row_class = ( $row_class == '' ? ' class="alternate"' : '' );
$this->level = $level;
echo '<tr id="tag-' . $tag->term_id . '"' . $row_class . '>';
echo $this->single_row_columns( $tag );
echo '</tr>';
}
function column_cb( $tag ) {
global $taxonomy, $tax;
$default_term = get_option( 'default_' . $taxonomy );
if ( current_user_can( $tax->cap->delete_terms ) && $tag->term_id != $default_term )
return '<input type="checkbox" name="delete_tags[]" value="' . $tag->term_id . '" />';
else
return ' ';
}
function column_name( $tag ) {
global $taxonomy, $tax, $post_type;
$default_term = get_option( 'default_' . $taxonomy );
$pad = str_repeat( '— ', max( 0, $this->level ) );
$name = apply_filters( 'term_name', $pad . ' ' . $tag->name, $tag );
$qe_data = get_term( $tag->term_id, $taxonomy, OBJECT, 'edit' );
$edit_link = esc_url( get_edit_term_link( $tag->term_id, $taxonomy, $post_type ) );
$out = '<strong><a class="row-title" href="' . $edit_link . '" title="' . esc_attr( sprintf( __( 'Edit “%s”' ), $name ) ) . '">' . $name . '</a></strong><br />';
$actions = array();
if ( current_user_can( $tax->cap->edit_terms ) ) {
$actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
$actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __( 'Quick Edit' ) . '</a>';
}
if ( current_user_can( $tax->cap->delete_terms ) && $tag->term_id != $default_term )
$actions['delete'] = "<a class='delete-tag' href='" . wp_nonce_url( "edit-tags.php?action=delete&taxonomy=$taxonomy&tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id ) . "'>" . __( 'Delete' ) . "</a>";
$actions['view'] = '<a href="' . get_term_link( $tag ) . '">' . __( 'View' ) . '</a>';
$actions = apply_filters( 'tag_row_actions', $actions, $tag );
$actions = apply_filters( "{$taxonomy}_row_actions", $actions, $tag );
$out .= $this->row_actions( $actions );
$out .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
$out .= '<div class="name">' . $qe_data->name . '</div>';
$out .= '<div class="slug">' . apply_filters( 'editable_slug', $qe_data->slug ) . '</div>';
$out .= '<div class="parent">' . $qe_data->parent . '</div></div>';
return $out;
}
function column_description( $tag ) {
return $tag->description;
}
function column_slug( $tag ) {
return apply_filters( 'editable_slug', $tag->slug );
}
function column_posts( $tag ) {
global $taxonomy, $post_type;
$count = number_format_i18n( $tag->count );
$tax = get_taxonomy( $taxonomy );
$ptype_object = get_post_type_object( $post_type );
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 );
}
if ( 'post' != $post_type )
$args['post_type'] = $post_type;
return "<a href='" . esc_url ( add_query_arg( $args, 'edit.php' ) ) . "'>$count</a>";
}
function column_links( $tag ) {
$count = number_format_i18n( $tag->count );
if ( $count )
$count = "<a href='link-manager.php?cat_id=$tag->term_id'>$count</a>";
return $count;
}
function column_default( $tag, $column_name ) {
$screen = get_current_screen();
return apply_filters( "manage_{$screen->taxonomy}_custom_column", '', $column_name, $tag->term_id );
}
/**
* Outputs the hidden row displayed when inline editing
*
* @since 3.1.0
*/
function inline_edit() {
global $post_type, $tax;
if ( ! current_user_can( $tax->cap->edit_terms ) )
return;
?>
<form method="get" action=""><table style="display: none"><tbody id="inlineedit">
<tr id="inline-edit" class="inline-edit-row" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange">
<fieldset><div class="inline-edit-col">
<h4><?php _e( 'Quick Edit' ); ?></h4>
<label>
<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() ) { ?>
<label>
<span class="title"><?php _e( 'Slug' ); ?></span>
<span class="input-text-wrap"><input type="text" name="slug" class="ptitle" value="" /></span>
</label>
<?php } ?>
</div></fieldset>
<?php
$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;
do_action( 'quick_edit_custom_box', $column_name, 'edit-tags', $tax->name );
}
?>
<p class="inline-edit-save submit">
<a accesskey="c" href="#inline-edit" title="<?php esc_attr_e( 'Cancel' ); ?>" class="cancel button-secondary alignleft"><?php _e( 'Cancel' ); ?></a>
<?php $update_text = $tax->labels->update_item; ?>
<a accesskey="s" href="#inline-edit" title="<?php echo esc_attr( $update_text ); ?>" class="save button-primary alignright"><?php echo $update_text; ?></a>
<img class="waiting" style="display:none;" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
<span class="error" style="display:none;"></span>
<?php wp_nonce_field( 'taxinlineeditnonce', '_inline_edit', false ); ?>
<input type="hidden" name="taxonomy" value="<?php echo esc_attr( $tax->name ); ?>" />
<input type="hidden" name="post_type" value="<?php echo esc_attr( $post_type ); ?>" />
<br class="clear" />
</p>
</td></tr>
</tbody></table></form>
<?php
}
}
| 01happy-blog | trunk/myblog/wp-admin/includes/class-wp-terms-list-table.php | PHP | oos | 11,588 |
<?php
/**
* Helper functions for displaying a list of items in an ajaxified HTML table.
*
* @package WordPress
* @subpackage List_Table
* @since 3.1.0
*/
/**
* Fetch an instance of a WP_List_Table class.
*
* @access private
* @since 3.1.0
*
* @param string $class The type of the list table, which is the class name.
* @return object|bool Object on success, false if the class does not exist.
*/
function _get_list_table( $class ) {
$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' => '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',
// Network Admin
'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 )
require_once( ABSPATH . 'wp-admin/includes/class-wp-' . $required . '-list-table.php' );
return new $class;
}
return false;
}
/**
* Register column headers for a particular screen.
*
* @since 2.7.0
*
* @param string $screen The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions.
* @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) {
$wp_list_table = new _WP_List_Table_Compat($screen, $columns);
}
/**
* Prints column headers for a particular screen.
*
* @since 2.7.0
*/
function print_column_headers($screen, $id = true) {
$wp_list_table = new _WP_List_Table_Compat($screen);
$wp_list_table->print_column_headers($id);
}
/**
* Helper class to be used only by back compat functions
*
* @since 3.1.0
*/
class _WP_List_Table_Compat extends WP_List_Table {
var $_screen;
var $_columns;
function _WP_List_Table_Compat( $screen, $columns = array() ) {
if ( is_string( $screen ) )
$screen = convert_to_screen( $screen );
$this->_screen = $screen;
if ( !empty( $columns ) ) {
$this->_columns = $columns;
add_filter( 'manage_' . $screen->id . '_columns', array( &$this, 'get_columns' ), 0 );
}
}
function get_column_info() {
$columns = get_column_headers( $this->_screen );
$hidden = get_hidden_columns( $this->_screen );
$sortable = array();
return array( $columns, $hidden, $sortable );
}
function get_columns() {
return $this->_columns;
}
}
| 01happy-blog | trunk/myblog/wp-admin/includes/list-table.php | PHP | oos | 2,869 |
<?php
/**
* WordPress core upgrade functionality.
*
* @package WordPress
* @subpackage Administration
* @since 2.7.0
*/
/**
* Stores files to be deleted.
*
* @since 2.7.0
* @global array $_old_files
* @var array
* @name $_old_files
*/
global $_old_files;
$_old_files = array(
// 2.0
'wp-admin/import-b2.php',
'wp-admin/import-blogger.php',
'wp-admin/import-greymatter.php',
'wp-admin/import-livejournal.php',
'wp-admin/import-mt.php',
'wp-admin/import-rss.php',
'wp-admin/import-textpattern.php',
'wp-admin/quicktags.js',
'wp-images/fade-butt.png',
'wp-images/get-firefox.png',
'wp-images/header-shadow.png',
'wp-images/smilies',
'wp-images/wp-small.png',
'wp-images/wpminilogo.png',
'wp.php',
// 2.0.8
'wp-includes/js/tinymce/plugins/inlinepopups/readme.txt',
// 2.1
'wp-admin/edit-form-ajax-cat.php',
'wp-admin/execute-pings.php',
'wp-admin/inline-uploading.php',
'wp-admin/link-categories.php',
'wp-admin/list-manipulation.js',
'wp-admin/list-manipulation.php',
'wp-includes/comment-functions.php',
'wp-includes/feed-functions.php',
'wp-includes/functions-compat.php',
'wp-includes/functions-formatting.php',
'wp-includes/functions-post.php',
'wp-includes/js/dbx-key.js',
'wp-includes/js/tinymce/plugins/autosave/langs/cs.js',
'wp-includes/js/tinymce/plugins/autosave/langs/sv.js',
'wp-includes/links.php',
'wp-includes/pluggable-functions.php',
'wp-includes/template-functions-author.php',
'wp-includes/template-functions-category.php',
'wp-includes/template-functions-general.php',
'wp-includes/template-functions-links.php',
'wp-includes/template-functions-post.php',
'wp-includes/wp-l10n.php',
// 2.2
'wp-admin/cat-js.php',
'wp-admin/import/b2.php',
'wp-includes/js/autosave-js.php',
'wp-includes/js/list-manipulation-js.php',
'wp-includes/js/wp-ajax-js.php',
// 2.3
'wp-admin/admin-db.php',
'wp-admin/cat.js',
'wp-admin/categories.js',
'wp-admin/custom-fields.js',
'wp-admin/dbx-admin-key.js',
'wp-admin/edit-comments.js',
'wp-admin/install-rtl.css',
'wp-admin/install.css',
'wp-admin/upgrade-schema.php',
'wp-admin/upload-functions.php',
'wp-admin/upload-rtl.css',
'wp-admin/upload.css',
'wp-admin/upload.js',
'wp-admin/users.js',
'wp-admin/widgets-rtl.css',
'wp-admin/widgets.css',
'wp-admin/xfn.js',
'wp-includes/js/tinymce/license.html',
// 2.5
'wp-admin/css/upload.css',
'wp-admin/images/box-bg-left.gif',
'wp-admin/images/box-bg-right.gif',
'wp-admin/images/box-bg.gif',
'wp-admin/images/box-butt-left.gif',
'wp-admin/images/box-butt-right.gif',
'wp-admin/images/box-butt.gif',
'wp-admin/images/box-head-left.gif',
'wp-admin/images/box-head-right.gif',
'wp-admin/images/box-head.gif',
'wp-admin/images/heading-bg.gif',
'wp-admin/images/login-bkg-bottom.gif',
'wp-admin/images/login-bkg-tile.gif',
'wp-admin/images/notice.gif',
'wp-admin/images/toggle.gif',
'wp-admin/includes/upload.php',
'wp-admin/js/dbx-admin-key.js',
'wp-admin/js/link-cat.js',
'wp-admin/profile-update.php',
'wp-admin/templates.php',
'wp-includes/images/wlw/WpComments.png',
'wp-includes/images/wlw/WpIcon.png',
'wp-includes/images/wlw/WpWatermark.png',
'wp-includes/js/dbx.js',
'wp-includes/js/fat.js',
'wp-includes/js/list-manipulation.js',
'wp-includes/js/tinymce/langs/en.js',
'wp-includes/js/tinymce/plugins/autosave/editor_plugin_src.js',
'wp-includes/js/tinymce/plugins/autosave/langs',
'wp-includes/js/tinymce/plugins/directionality/images',
'wp-includes/js/tinymce/plugins/directionality/langs',
'wp-includes/js/tinymce/plugins/inlinepopups/css',
'wp-includes/js/tinymce/plugins/inlinepopups/images',
'wp-includes/js/tinymce/plugins/inlinepopups/jscripts',
'wp-includes/js/tinymce/plugins/paste/images',
'wp-includes/js/tinymce/plugins/paste/jscripts',
'wp-includes/js/tinymce/plugins/paste/langs',
'wp-includes/js/tinymce/plugins/spellchecker/classes/HttpClient.class.php',
'wp-includes/js/tinymce/plugins/spellchecker/classes/TinyGoogleSpell.class.php',
'wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspell.class.php',
'wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspellShell.class.php',
'wp-includes/js/tinymce/plugins/spellchecker/css/spellchecker.css',
'wp-includes/js/tinymce/plugins/spellchecker/images',
'wp-includes/js/tinymce/plugins/spellchecker/langs',
'wp-includes/js/tinymce/plugins/spellchecker/tinyspell.php',
'wp-includes/js/tinymce/plugins/wordpress/images',
'wp-includes/js/tinymce/plugins/wordpress/langs',
'wp-includes/js/tinymce/plugins/wordpress/wordpress.css',
'wp-includes/js/tinymce/plugins/wphelp',
'wp-includes/js/tinymce/themes/advanced/css',
'wp-includes/js/tinymce/themes/advanced/images',
'wp-includes/js/tinymce/themes/advanced/jscripts',
'wp-includes/js/tinymce/themes/advanced/langs',
// 2.5.1
'wp-includes/js/tinymce/tiny_mce_gzip.php',
// 2.6
'wp-admin/bookmarklet.php',
'wp-includes/js/jquery/jquery.dimensions.min.js',
'wp-includes/js/tinymce/plugins/wordpress/popups.css',
'wp-includes/js/wp-ajax.js',
// 2.7
'wp-admin/css/press-this-ie-rtl.css',
'wp-admin/css/press-this-ie.css',
'wp-admin/css/upload-rtl.css',
'wp-admin/edit-form.php',
'wp-admin/images/comment-pill.gif',
'wp-admin/images/comment-stalk-classic.gif',
'wp-admin/images/comment-stalk-fresh.gif',
'wp-admin/images/comment-stalk-rtl.gif',
'wp-admin/images/del.png',
'wp-admin/images/gear.png',
'wp-admin/images/media-button-gallery.gif',
'wp-admin/images/media-buttons.gif',
'wp-admin/images/postbox-bg.gif',
'wp-admin/images/tab.png',
'wp-admin/images/tail.gif',
'wp-admin/js/forms.js',
'wp-admin/js/upload.js',
'wp-admin/link-import.php',
'wp-includes/images/audio.png',
'wp-includes/images/css.png',
'wp-includes/images/default.png',
'wp-includes/images/doc.png',
'wp-includes/images/exe.png',
'wp-includes/images/html.png',
'wp-includes/images/js.png',
'wp-includes/images/pdf.png',
'wp-includes/images/swf.png',
'wp-includes/images/tar.png',
'wp-includes/images/text.png',
'wp-includes/images/video.png',
'wp-includes/images/zip.png',
'wp-includes/js/tinymce/tiny_mce_config.php',
'wp-includes/js/tinymce/tiny_mce_ext.js',
// 2.8
'wp-admin/js/users.js',
'wp-includes/js/swfupload/plugins/swfupload.documentready.js',
'wp-includes/js/swfupload/plugins/swfupload.graceful_degradation.js',
'wp-includes/js/swfupload/swfupload_f9.swf',
'wp-includes/js/tinymce/plugins/autosave',
'wp-includes/js/tinymce/plugins/paste/css',
'wp-includes/js/tinymce/utils/mclayer.js',
'wp-includes/js/tinymce/wordpress.css',
// 2.8.5
'wp-admin/import/btt.php',
'wp-admin/import/jkw.php',
// 2.9
'wp-admin/js/page.dev.js',
'wp-admin/js/page.js',
'wp-admin/js/set-post-thumbnail-handler.dev.js',
'wp-admin/js/set-post-thumbnail-handler.js',
'wp-admin/js/slug.dev.js',
'wp-admin/js/slug.js',
'wp-includes/gettext.php',
'wp-includes/js/tinymce/plugins/wordpress/js',
'wp-includes/streams.php',
// MU
'README.txt',
'htaccess.dist',
'index-install.php',
'wp-admin/css/mu-rtl.css',
'wp-admin/css/mu.css',
'wp-admin/images/site-admin.png',
'wp-admin/includes/mu.php',
'wp-admin/wpmu-admin.php',
'wp-admin/wpmu-blogs.php',
'wp-admin/wpmu-edit.php',
'wp-admin/wpmu-options.php',
'wp-admin/wpmu-themes.php',
'wp-admin/wpmu-upgrade-site.php',
'wp-admin/wpmu-users.php',
'wp-includes/images/wordpress-mu.png',
'wp-includes/wpmu-default-filters.php',
'wp-includes/wpmu-functions.php',
'wpmu-settings.php',
// 3.0
'wp-admin/categories.php',
'wp-admin/edit-category-form.php',
'wp-admin/edit-page-form.php',
'wp-admin/edit-pages.php',
'wp-admin/images/admin-header-footer.png',
'wp-admin/images/browse-happy.gif',
'wp-admin/images/ico-add.png',
'wp-admin/images/ico-close.png',
'wp-admin/images/ico-edit.png',
'wp-admin/images/ico-viewpage.png',
'wp-admin/images/fav-top.png',
'wp-admin/images/screen-options-left.gif',
'wp-admin/images/wp-logo-vs.gif',
'wp-admin/images/wp-logo.gif',
'wp-admin/import',
'wp-admin/js/wp-gears.dev.js',
'wp-admin/js/wp-gears.js',
'wp-admin/options-misc.php',
'wp-admin/page-new.php',
'wp-admin/page.php',
'wp-admin/rtl.css',
'wp-admin/rtl.dev.css',
'wp-admin/update-links.php',
'wp-admin/wp-admin.css',
'wp-admin/wp-admin.dev.css',
'wp-includes/js/codepress',
'wp-includes/js/codepress/engines/khtml.js',
'wp-includes/js/codepress/engines/older.js',
'wp-includes/js/jquery/autocomplete.dev.js',
'wp-includes/js/jquery/autocomplete.js',
'wp-includes/js/jquery/interface.js',
'wp-includes/js/scriptaculous/prototype.js',
'wp-includes/js/tinymce/wp-tinymce.js',
// 3.1
'wp-admin/edit-attachment-rows.php',
'wp-admin/edit-link-categories.php',
'wp-admin/edit-link-category-form.php',
'wp-admin/edit-post-rows.php',
'wp-admin/images/button-grad-active-vs.png',
'wp-admin/images/button-grad-vs.png',
'wp-admin/images/fav-arrow-vs-rtl.gif',
'wp-admin/images/fav-arrow-vs.gif',
'wp-admin/images/fav-top-vs.gif',
'wp-admin/images/list-vs.png',
'wp-admin/images/screen-options-right-up.gif',
'wp-admin/images/screen-options-right.gif',
'wp-admin/images/visit-site-button-grad-vs.gif',
'wp-admin/images/visit-site-button-grad.gif',
'wp-admin/link-category.php',
'wp-admin/sidebar.php',
'wp-includes/classes.php',
'wp-includes/js/tinymce/blank.htm',
'wp-includes/js/tinymce/plugins/media/css/content.css',
'wp-includes/js/tinymce/plugins/media/img',
'wp-includes/js/tinymce/plugins/safari',
// 3.2
'wp-admin/images/logo-login.gif',
'wp-admin/images/star.gif',
'wp-admin/js/list-table.dev.js',
'wp-admin/js/list-table.js',
'wp-includes/default-embeds.php',
'wp-includes/js/tinymce/plugins/wordpress/img/help.gif',
'wp-includes/js/tinymce/plugins/wordpress/img/more.gif',
'wp-includes/js/tinymce/plugins/wordpress/img/toolbars.gif',
'wp-includes/js/tinymce/themes/advanced/img/fm.gif',
'wp-includes/js/tinymce/themes/advanced/img/sflogo.png',
// 3.3
'wp-admin/css/colors-classic-rtl.css',
'wp-admin/css/colors-classic-rtl.dev.css',
'wp-admin/css/colors-fresh-rtl.css',
'wp-admin/css/colors-fresh-rtl.dev.css',
'wp-admin/css/dashboard-rtl.css',
'wp-admin/css/dashboard-rtl.dev.css',
'wp-admin/css/dashboard.css',
'wp-admin/css/dashboard.dev.css',
'wp-admin/css/farbtastic-rtl.css',
'wp-admin/css/global-rtl.css',
'wp-admin/css/global-rtl.dev.css',
'wp-admin/css/global.css',
'wp-admin/css/global.dev.css',
'wp-admin/css/install-rtl.css',
'wp-admin/css/install-rtl.dev.css',
'wp-admin/css/login-rtl.css',
'wp-admin/css/login-rtl.dev.css',
'wp-admin/css/login.css',
'wp-admin/css/login.dev.css',
'wp-admin/css/ms.css',
'wp-admin/css/ms.dev.css',
'wp-admin/css/nav-menu-rtl.css',
'wp-admin/css/nav-menu-rtl.dev.css',
'wp-admin/css/nav-menu.css',
'wp-admin/css/nav-menu.dev.css',
'wp-admin/css/plugin-install-rtl.css',
'wp-admin/css/plugin-install-rtl.dev.css',
'wp-admin/css/plugin-install.css',
'wp-admin/css/plugin-install.dev.css',
'wp-admin/css/press-this-rtl.css',
'wp-admin/css/press-this-rtl.dev.css',
'wp-admin/css/press-this.css',
'wp-admin/css/press-this.dev.css',
'wp-admin/css/theme-editor-rtl.css',
'wp-admin/css/theme-editor-rtl.dev.css',
'wp-admin/css/theme-editor.css',
'wp-admin/css/theme-editor.dev.css',
'wp-admin/css/theme-install-rtl.css',
'wp-admin/css/theme-install-rtl.dev.css',
'wp-admin/css/theme-install.css',
'wp-admin/css/theme-install.dev.css',
'wp-admin/css/widgets-rtl.css',
'wp-admin/css/widgets-rtl.dev.css',
'wp-admin/css/widgets.css',
'wp-admin/css/widgets.dev.css',
'wp-admin/includes/internal-linking.php',
'wp-includes/images/admin-bar-sprite-rtl.png',
'wp-includes/js/jquery/ui.button.js',
'wp-includes/js/jquery/ui.core.js',
'wp-includes/js/jquery/ui.dialog.js',
'wp-includes/js/jquery/ui.draggable.js',
'wp-includes/js/jquery/ui.droppable.js',
'wp-includes/js/jquery/ui.mouse.js',
'wp-includes/js/jquery/ui.position.js',
'wp-includes/js/jquery/ui.resizable.js',
'wp-includes/js/jquery/ui.selectable.js',
'wp-includes/js/jquery/ui.sortable.js',
'wp-includes/js/jquery/ui.tabs.js',
'wp-includes/js/jquery/ui.widget.js',
'wp-includes/js/l10n.dev.js',
'wp-includes/js/l10n.js',
'wp-includes/js/tinymce/plugins/wplink/css',
'wp-includes/js/tinymce/plugins/wplink/img',
'wp-includes/js/tinymce/plugins/wplink/js',
'wp-includes/js/tinymce/themes/advanced/img/wpicons.png',
'wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/butt2.png',
'wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/button_bg.png',
'wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/down_arrow.gif',
'wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/fade-butt.png',
'wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/separator.gif',
// Don't delete, yet: 'wp-rss.php',
// Don't delete, yet: 'wp-rdf.php',
// Don't delete, yet: 'wp-rss2.php',
// Don't delete, yet: 'wp-commentsrss2.php',
// Don't delete, yet: 'wp-atom.php',
// Don't delete, yet: 'wp-feed.php',
// 3.4
'wp-admin/images/gray-star.png',
'wp-admin/images/logo-login.png',
'wp-admin/images/star.png',
'wp-admin/index-extra.php',
'wp-admin/network/index-extra.php',
'wp-admin/user/index-extra.php',
'wp-admin/images/screenshots/admin-flyouts.png',
'wp-admin/images/screenshots/coediting.png',
'wp-admin/images/screenshots/drag-and-drop.png',
'wp-admin/images/screenshots/help-screen.png',
'wp-admin/images/screenshots/media-icon.png',
'wp-admin/images/screenshots/new-feature-pointer.png',
'wp-admin/images/screenshots/welcome-screen.png',
'wp-includes/css/editor-buttons.css',
'wp-includes/css/editor-buttons.dev.css',
'wp-includes/js/tinymce/plugins/paste/blank.htm',
'wp-includes/js/tinymce/plugins/wordpress/css',
'wp-includes/js/tinymce/plugins/wordpress/editor_plugin.dev.js',
'wp-includes/js/tinymce/plugins/wordpress/img/embedded.png',
'wp-includes/js/tinymce/plugins/wordpress/img/more_bug.gif',
'wp-includes/js/tinymce/plugins/wordpress/img/page_bug.gif',
'wp-includes/js/tinymce/plugins/wpdialogs/editor_plugin.dev.js',
'wp-includes/js/tinymce/plugins/wpeditimage/css/editimage-rtl.css',
'wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin.dev.js',
'wp-includes/js/tinymce/plugins/wpfullscreen/editor_plugin.dev.js',
'wp-includes/js/tinymce/plugins/wpgallery/editor_plugin.dev.js',
'wp-includes/js/tinymce/plugins/wpgallery/img/gallery.png',
'wp-includes/js/tinymce/plugins/wplink/editor_plugin.dev.js',
// Don't delete, yet: 'wp-pass.php',
// Don't delete, yet: 'wp-register.php',
);
/**
* Stores new files in wp-content to copy
*
* The contents of this array indicate any new bundled plugins/themes which
* should be installed with the WordPress Upgrade. These items will not be
* re-installed in future upgrades, this behaviour is controlled by the
* introduced version present here being older than the current installed version.
*
* The content of this array should follow the following format:
* Filename (relative to wp-content) => Introduced version
* Directories should be noted by suffixing it with a trailing slash (/)
*
* @since 3.2.0
* @global array $_new_bundled_files
* @var array
* @name $_new_bundled_files
*/
global $_new_bundled_files;
$_new_bundled_files = array(
'plugins/akismet/' => '2.0',
'themes/twentyten/' => '3.0',
'themes/twentyeleven/' => '3.2'
);
/**
* Upgrade the core of WordPress.
*
* This will create a .maintenance file at the base of the WordPress directory
* to ensure that people can not access the web site, when the files are being
* copied to their locations.
*
* The files in the {@link $_old_files} list will be removed and the new files
* copied from the zip file after the database is upgraded.
*
* The files in the {@link $_new_bundled_files} list will be added to the installation
* if the version is greater than or equal to the old version being upgraded.
*
* The steps for the upgrader for after the new release is downloaded and
* unzipped is:
* 1. Test unzipped location for select files to ensure that unzipped worked.
* 2. Create the .maintenance file in current WordPress base.
* 3. Copy new WordPress directory over old WordPress files.
* 4. Upgrade WordPress to new version.
* 4.1. Copy all files/folders other than wp-content
* 4.2. Copy any language files to WP_LANG_DIR (which may differ from WP_CONTENT_DIR
* 4.3. Copy any new bundled themes/plugins to their respective locations
* 5. Delete new WordPress directory path.
* 6. Delete .maintenance file.
* 7. Remove old files.
* 8. Delete 'update_core' option.
*
* There are several areas of failure. For instance if PHP times out before step
* 6, then you will not be able to access any portion of your site. Also, since
* the upgrade will not continue where it left off, you will not be able to
* automatically remove old files and remove the 'update_core' option. This
* isn't that bad.
*
* If the copy of the new WordPress over the old fails, then the worse is that
* the new WordPress directory will remain.
*
* If it is assumed that every file will be copied over, including plugins and
* themes, then if you edit the default theme, you should rename it, so that
* your changes remain.
*
* @since 2.7.0
*
* @param string $from New release unzipped path.
* @param string $to Path to old WordPress installation.
* @return WP_Error|null WP_Error on failure, null on success.
*/
function update_core($from, $to) {
global $wp_filesystem, $_old_files, $_new_bundled_files, $wpdb;
@set_time_limit( 300 );
$php_version = phpversion();
$mysql_version = $wpdb->db_version();
$required_php_version = '5.2.4';
$required_mysql_version = '5.0';
$wp_version = '3.4.1';
$php_compat = version_compare( $php_version, $required_php_version, '>=' );
if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) )
$mysql_compat = true;
else
$mysql_compat = version_compare( $mysql_version, $required_mysql_version, '>=' );
if ( !$mysql_compat || !$php_compat )
$wp_filesystem->delete($from, true);
if ( !$mysql_compat && !$php_compat )
return new WP_Error( 'php_mysql_not_compatible', sprintf( __('The update cannot be installed because WordPress %1$s requires PHP version %2$s or higher and MySQL version %3$s or higher. You are running PHP version %4$s and MySQL version %5$s.'), $wp_version, $required_php_version, $required_mysql_version, $php_version, $mysql_version ) );
elseif ( !$php_compat )
return new WP_Error( 'php_not_compatible', sprintf( __('The update cannot be installed because WordPress %1$s requires PHP version %2$s or higher. You are running version %3$s.'), $wp_version, $required_php_version, $php_version ) );
elseif ( !$mysql_compat )
return new WP_Error( 'mysql_not_compatible', sprintf( __('The update cannot be installed because WordPress %1$s requires MySQL version %2$s or higher. You are running version %3$s.'), $wp_version, $required_mysql_version, $mysql_version ) );
// Sanity check the unzipped distribution
apply_filters('update_feedback', __('Verifying the unpacked files…'));
$distro = '';
$roots = array( '/wordpress/', '/wordpress-mu/' );
foreach( $roots as $root ) {
if ( $wp_filesystem->exists($from . $root . 'readme.html') && $wp_filesystem->exists($from . $root . 'wp-includes/version.php') ) {
$distro = $root;
break;
}
}
if ( !$distro ) {
$wp_filesystem->delete($from, true);
return new WP_Error('insane_distro', __('The update could not be unpacked') );
}
apply_filters('update_feedback', __('Installing the latest version…'));
// Create maintenance file to signal that we are upgrading
$maintenance_string = '<?php $upgrading = ' . time() . '; ?>';
$maintenance_file = $to . '.maintenance';
$wp_filesystem->delete($maintenance_file);
$wp_filesystem->put_contents($maintenance_file, $maintenance_string, FS_CHMOD_FILE);
// Copy new versions of WP files into place.
$result = _copy_dir($from . $distro, $to, array('wp-content') );
// Custom Content Directory needs updating now.
// Copy Languages
if ( !is_wp_error($result) && $wp_filesystem->is_dir($from . $distro . 'wp-content/languages') ) {
if ( WP_LANG_DIR != ABSPATH . WPINC . '/languages' || @is_dir(WP_LANG_DIR) )
$lang_dir = WP_LANG_DIR;
else
$lang_dir = WP_CONTENT_DIR . '/languages';
if ( !@is_dir($lang_dir) && 0 === strpos($lang_dir, ABSPATH) ) { // Check the language directory exists first
$wp_filesystem->mkdir($to . str_replace(ABSPATH, '', $lang_dir), FS_CHMOD_DIR); // If it's within the ABSPATH we can handle it here, otherwise they're out of luck.
clearstatcache(); // for FTP, Need to clear the stat cache
}
if ( @is_dir($lang_dir) ) {
$wp_lang_dir = $wp_filesystem->find_folder($lang_dir);
if ( $wp_lang_dir )
$result = copy_dir($from . $distro . 'wp-content/languages/', $wp_lang_dir);
}
}
// Copy New bundled plugins & themes
// This gives us the ability to install new plugins & themes bundled with future versions of WordPress whilst avoiding the re-install upon upgrade issue.
if ( !is_wp_error($result) && ( ! defined('CORE_UPGRADE_SKIP_NEW_BUNDLED') || ! CORE_UPGRADE_SKIP_NEW_BUNDLED ) ) {
$old_version = $GLOBALS['wp_version']; // $wp_version in local scope == new version
foreach ( (array) $_new_bundled_files as $file => $introduced_version ) {
// If $introduced version is greater than what the site was previously running
if ( version_compare($introduced_version, $old_version, '>') ) {
$directory = ('/' == $file[ strlen($file)-1 ]);
list($type, $filename) = explode('/', $file, 2);
if ( 'plugins' == $type )
$dest = $wp_filesystem->wp_plugins_dir();
elseif ( 'themes' == $type )
$dest = trailingslashit($wp_filesystem->wp_themes_dir()); // Back-compat, ::wp_themes_dir() did not return trailingslash'd pre-3.2
else
continue;
if ( ! $directory ) {
if ( $wp_filesystem->exists($dest . $filename) )
continue;
if ( ! $wp_filesystem->copy($from . $distro . 'wp-content/' . $file, $dest . $filename, FS_CHMOD_FILE) )
$result = new WP_Error('copy_failed', __('Could not copy file.'), $dest . $filename);
} else {
if ( $wp_filesystem->is_dir($dest . $filename) )
continue;
$wp_filesystem->mkdir($dest . $filename, FS_CHMOD_DIR);
$_result = copy_dir( $from . $distro . 'wp-content/' . $file, $dest . $filename);
if ( is_wp_error($_result) ) //If a error occurs partway through this final step, keep the error flowing through, but keep process going.
$result = $_result;
}
}
} //end foreach
}
// Handle $result error from the above blocks
if ( is_wp_error($result) ) {
$wp_filesystem->delete($maintenance_file);
$wp_filesystem->delete($from, true);
return $result;
}
// Remove old files
foreach ( $_old_files as $old_file ) {
$old_file = $to . $old_file;
if ( !$wp_filesystem->exists($old_file) )
continue;
$wp_filesystem->delete($old_file, true);
}
// Upgrade DB with separate request
apply_filters('update_feedback', __('Upgrading database…'));
$db_upgrade_url = admin_url('upgrade.php?step=upgrade_db');
wp_remote_post($db_upgrade_url, array('timeout' => 60));
// Remove working directory
$wp_filesystem->delete($from, true);
// Force refresh of update information
if ( function_exists('delete_site_transient') )
delete_site_transient('update_core');
else
delete_option('update_core');
// Remove maintenance file, we're done.
$wp_filesystem->delete($maintenance_file);
// If we made it this far:
do_action( '_core_updated_successfully', $wp_version );
return $wp_version;
}
/**
* Copies a directory from one location to another via the WordPress Filesystem Abstraction.
* Assumes that WP_Filesystem() has already been called and setup.
*
* This is a temporary function for the 3.1 -> 3.2 upgrade only and will be removed in 3.3
*
* @ignore
* @since 3.2.0
* @see copy_dir()
*
* @param string $from source directory
* @param string $to destination directory
* @param array $skip_list a list of files/folders to skip copying
* @return mixed WP_Error on failure, True on success.
*/
function _copy_dir($from, $to, $skip_list = array() ) {
global $wp_filesystem;
$dirlist = $wp_filesystem->dirlist($from);
$from = trailingslashit($from);
$to = trailingslashit($to);
$skip_regex = '';
foreach ( (array)$skip_list as $key => $skip_file )
$skip_regex .= preg_quote($skip_file, '!') . '|';
if ( !empty($skip_regex) )
$skip_regex = '!(' . rtrim($skip_regex, '|') . ')$!i';
foreach ( (array) $dirlist as $filename => $fileinfo ) {
if ( !empty($skip_regex) )
if ( preg_match($skip_regex, $from . $filename) )
continue;
if ( 'f' == $fileinfo['type'] ) {
if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) ) {
// If copy failed, chmod file to 0644 and try again.
$wp_filesystem->chmod($to . $filename, 0644);
if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) )
return new WP_Error('copy_failed', __('Could not copy file.'), $to . $filename);
}
} elseif ( 'd' == $fileinfo['type'] ) {
if ( !$wp_filesystem->is_dir($to . $filename) ) {
if ( !$wp_filesystem->mkdir($to . $filename, FS_CHMOD_DIR) )
return new WP_Error('mkdir_failed', __('Could not create directory.'), $to . $filename);
}
$result = _copy_dir($from . $filename, $to . $filename, $skip_list);
if ( is_wp_error($result) )
return $result;
}
}
return true;
}
/**
* Redirect to the About WordPress page after a successful upgrade.
*
* This function is only needed when the existing install is older than 3.4.0.
*
* @since 3.3.0
*
*/
function _redirect_to_about_wordpress( $new_version ) {
global $wp_version, $pagenow, $action;
if ( version_compare( $wp_version, '3.4-RC1', '>=' ) )
return;
// Ensure we only run this on the update-core.php page. wp_update_core() could be called in other contexts.
if ( 'update-core.php' != $pagenow )
return;
if ( 'do-core-upgrade' != $action && 'do-core-reinstall' != $action )
return;
// Load the updated default text localization domain for new strings
load_default_textdomain();
// See do_core_upgrade()
show_message( __('WordPress updated successfully') );
show_message( '<span class="hide-if-no-js">' . sprintf( __( 'Welcome to WordPress %1$s. You will be redirected to the About WordPress screen. If not, click <a href="%s">here</a>.' ), $new_version, esc_url( self_admin_url( 'about.php?updated' ) ) ) . '</span>' );
show_message( '<span class="hide-if-js">' . sprintf( __( 'Welcome to WordPress %1$s. <a href="%2$s">Learn more</a>.' ), $new_version, esc_url( self_admin_url( 'about.php?updated' ) ) ) . '</span>' );
echo '</div>';
?>
<script type="text/javascript">
window.location = '<?php echo self_admin_url( 'about.php?updated' ); ?>';
</script>
<?php
// Include admin-footer.php and exit
include(ABSPATH . 'wp-admin/admin-footer.php');
exit();
}
add_action( '_core_updated_successfully', '_redirect_to_about_wordpress' );
| 01happy-blog | trunk/myblog/wp-admin/includes/update-core.php | PHP | oos | 26,598 |
<?php
/**
* Links Manager List Table class.
*
* @package WordPress
* @subpackage List_Table
* @since 3.1.0
* @access private
*/
class WP_Links_List_Table extends WP_List_Table {
function __construct() {
parent::__construct( array(
'plural' => 'bookmarks',
) );
}
function ajax_user_can() {
return current_user_can( 'manage_links' );
}
function prepare_items() {
global $cat_id, $s, $orderby, $order;
wp_reset_vars( array( 'action', 'cat_id', 'linkurl', 'name', 'image', 'description', 'visible', 'target', 'category', 'link_id', 'submit', 'orderby', 'order', 'links_show_cat_id', 'rating', 'rel', 'notes', 'linkcheck[]', 's' ) );
$args = array( 'hide_invisible' => 0, 'hide_empty' => 0 );
if ( 'all' != $cat_id )
$args['category'] = $cat_id;
if ( !empty( $s ) )
$args['search'] = $s;
if ( !empty( $orderby ) )
$args['orderby'] = $orderby;
if ( !empty( $order ) )
$args['order'] = $order;
$this->items = get_bookmarks( $args );
}
function no_items() {
_e( 'No links found.' );
}
function get_bulk_actions() {
$actions = array();
$actions['delete'] = __( 'Delete' );
return $actions;
}
function extra_tablenav( $which ) {
global $cat_id;
if ( 'top' != $which )
return;
?>
<div class="alignleft actions">
<?php
$dropdown_options = array(
'selected' => $cat_id,
'name' => 'cat_id',
'taxonomy' => 'link_category',
'show_option_all' => __( 'View all categories' ),
'hide_empty' => true,
'hierarchical' => 1,
'show_count' => 0,
'orderby' => 'name',
);
wp_dropdown_categories( $dropdown_options );
submit_button( __( 'Filter' ), 'secondary', false, false, array( 'id' => 'post-query-submit' ) );
?>
</div>
<?php
}
function get_columns() {
return array(
'cb' => '<input type="checkbox" />',
'name' => _x( 'Name', 'link name' ),
'url' => __( 'URL' ),
'categories' => __( 'Categories' ),
'rel' => __( 'Relationship' ),
'visible' => __( 'Visible' ),
'rating' => __( 'Rating' )
);
}
function get_sortable_columns() {
return array(
'name' => 'name',
'url' => 'url',
'visible' => 'visible',
'rating' => 'rating'
);
}
function display_rows() {
global $cat_id;
$alt = 0;
foreach ( $this->items as $link ) {
$link = sanitize_bookmark( $link );
$link->link_name = esc_attr( $link->link_name );
$link->link_category = wp_get_link_cats( $link->link_id );
$short_url = url_shorten( $link->link_url );
$visible = ( $link->link_visible == 'Y' ) ? __( 'Yes' ) : __( 'No' );
$rating = $link->link_rating;
$style = ( $alt++ % 2 ) ? '' : ' class="alternate"';
$edit_link = get_edit_bookmark_link( $link );
?>
<tr id="link-<?php echo $link->link_id; ?>" valign="middle" <?php echo $style; ?>>
<?php
list( $columns, $hidden ) = $this->get_column_info();
foreach ( $columns as $column_name => $column_display_name ) {
$class = "class='column-$column_name'";
$style = '';
if ( in_array( $column_name, $hidden ) )
$style = ' style="display:none;"';
$attributes = $class . $style;
switch ( $column_name ) {
case 'cb':
echo '<th scope="row" class="check-column"><input type="checkbox" name="linkcheck[]" value="'. esc_attr( $link->link_id ) .'" /></th>';
break;
case 'name':
echo "<td $attributes><strong><a class='row-title' href='$edit_link' title='" . esc_attr( sprintf( __( 'Edit “%s”' ), $link->link_name ) ) . "'>$link->link_name</a></strong><br />";
$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>";
echo $this->row_actions( $actions );
echo '</td>';
break;
case 'url':
echo "<td $attributes><a href='$link->link_url' title='". esc_attr( sprintf( __( 'Visit %s' ), $link->link_name ) )."'>$short_url</a></td>";
break;
case 'categories':
?><td <?php echo $attributes ?>><?php
$cat_names = array();
foreach ( $link->link_category as $category ) {
$cat = get_term( $category, 'link_category', OBJECT, 'display' );
if ( is_wp_error( $cat ) )
echo $cat->get_error_message();
$cat_name = $cat->name;
if ( $cat_id != $category )
$cat_name = "<a href='link-manager.php?cat_id=$category'>$cat_name</a>";
$cat_names[] = $cat_name;
}
echo implode( ', ', $cat_names );
?></td><?php
break;
case 'rel':
?><td <?php echo $attributes ?>><?php echo empty( $link->link_rel ) ? '<br />' : $link->link_rel; ?></td><?php
break;
case 'visible':
?><td <?php echo $attributes ?>><?php echo $visible; ?></td><?php
break;
case 'rating':
?><td <?php echo $attributes ?>><?php echo $rating; ?></td><?php
break;
default:
?>
<td <?php echo $attributes ?>><?php do_action( 'manage_link_custom_column', $column_name, $link->link_id ); ?></td>
<?php
break;
}
}
?>
</tr>
<?php
}
}
}
| 01happy-blog | trunk/myblog/wp-admin/includes/class-wp-links-list-table.php | PHP | oos | 5,438 |
<?php
/**
* WordPress Post Administration API.
*
* @package WordPress
* @subpackage Administration
*/
/**
* Rename $_POST data from form names to DB post columns.
*
* Manipulates $_POST directly.
*
* @package WordPress
* @since 2.6.0
*
* @param bool $update Are we updating a pre-existing post?
* @param array $post_data Array of post data. Defaults to the contents of $_POST.
* @return object|bool WP_Error on failure, true on success.
*/
function _wp_translate_postdata( $update = false, $post_data = null ) {
if ( empty($post_data) )
$post_data = &$_POST;
if ( $update )
$post_data['ID'] = (int) $post_data['post_ID'];
if ( isset( $post_data['content'] ) )
$post_data['post_content'] = $post_data['content'];
if ( isset( $post_data['excerpt'] ) )
$post_data['post_excerpt'] = $post_data['excerpt'];
if ( isset( $post_data['parent_id'] ) )
$post_data['post_parent'] = (int) $post_data['parent_id'];
if ( isset($post_data['trackback_url']) )
$post_data['to_ping'] = $post_data['trackback_url'];
if ( !isset($post_data['user_ID']) )
$post_data['user_ID'] = $GLOBALS['user_ID'];
if (!empty ( $post_data['post_author_override'] ) ) {
$post_data['post_author'] = (int) $post_data['post_author_override'];
} else {
if (!empty ( $post_data['post_author'] ) ) {
$post_data['post_author'] = (int) $post_data['post_author'];
} else {
$post_data['post_author'] = (int) $post_data['user_ID'];
}
}
$ptype = get_post_type_object( $post_data['post_type'] );
if ( isset($post_data['user_ID']) && ($post_data['post_author'] != $post_data['user_ID']) ) {
if ( !current_user_can( $ptype->cap->edit_others_posts ) ) {
if ( 'page' == $post_data['post_type'] ) {
return new WP_Error( 'edit_others_pages', $update ?
__( 'You are not allowed to edit pages as this user.' ) :
__( 'You are not allowed to create pages as this user.' )
);
} else {
return new WP_Error( 'edit_others_posts', $update ?
__( 'You are not allowed to edit posts as this user.' ) :
__( 'You are not allowed to post as this user.' )
);
}
}
}
// What to do based on which button they pressed
if ( isset($post_data['saveasdraft']) && '' != $post_data['saveasdraft'] )
$post_data['post_status'] = 'draft';
if ( isset($post_data['saveasprivate']) && '' != $post_data['saveasprivate'] )
$post_data['post_status'] = 'private';
if ( isset($post_data['publish']) && ( '' != $post_data['publish'] ) && ( !isset($post_data['post_status']) || $post_data['post_status'] != 'private' ) )
$post_data['post_status'] = 'publish';
if ( isset($post_data['advanced']) && '' != $post_data['advanced'] )
$post_data['post_status'] = 'draft';
if ( isset($post_data['pending']) && '' != $post_data['pending'] )
$post_data['post_status'] = 'pending';
if ( isset( $post_data['ID'] ) )
$post_id = $post_data['ID'];
else
$post_id = false;
$previous_status = $post_id ? get_post_field( 'post_status', $post_id ) : false;
// Posts 'submitted for approval' present are submitted to $_POST the same as if they were being published.
// Change status from 'publish' to 'pending' if user lacks permissions to publish or to resave published posts.
if ( isset($post_data['post_status']) && ('publish' == $post_data['post_status'] && !current_user_can( $ptype->cap->publish_posts )) )
if ( $previous_status != 'publish' || !current_user_can( 'edit_post', $post_id ) )
$post_data['post_status'] = 'pending';
if ( ! isset($post_data['post_status']) )
$post_data['post_status'] = $previous_status;
if (!isset( $post_data['comment_status'] ))
$post_data['comment_status'] = 'closed';
if (!isset( $post_data['ping_status'] ))
$post_data['ping_status'] = 'closed';
foreach ( array('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit ) {
if ( !empty( $post_data['hidden_' . $timeunit] ) && $post_data['hidden_' . $timeunit] != $post_data[$timeunit] ) {
$post_data['edit_date'] = '1';
break;
}
}
if ( !empty( $post_data['edit_date'] ) ) {
$aa = $post_data['aa'];
$mm = $post_data['mm'];
$jj = $post_data['jj'];
$hh = $post_data['hh'];
$mn = $post_data['mn'];
$ss = $post_data['ss'];
$aa = ($aa <= 0 ) ? date('Y') : $aa;
$mm = ($mm <= 0 ) ? date('n') : $mm;
$jj = ($jj > 31 ) ? 31 : $jj;
$jj = ($jj <= 0 ) ? date('j') : $jj;
$hh = ($hh > 23 ) ? $hh -24 : $hh;
$mn = ($mn > 59 ) ? $mn -60 : $mn;
$ss = ($ss > 59 ) ? $ss -60 : $ss;
$post_data['post_date'] = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss );
$post_data['post_date_gmt'] = get_gmt_from_date( $post_data['post_date'] );
}
return $post_data;
}
/**
* Update an existing post with values provided in $_POST.
*
* @since 1.5.0
*
* @param array $post_data Optional.
* @return int Post ID.
*/
function edit_post( $post_data = null ) {
if ( empty($post_data) )
$post_data = &$_POST;
// Clear out any data in internal vars.
unset( $post_data['filter'] );
$post_ID = (int) $post_data['post_ID'];
$post = get_post( $post_ID );
$post_data['post_type'] = $post->post_type;
$post_data['post_mime_type'] = $post->post_mime_type;
$ptype = get_post_type_object($post_data['post_type']);
if ( !current_user_can( $ptype->cap->edit_post, $post_ID ) ) {
if ( 'page' == $post_data['post_type'] )
wp_die( __('You are not allowed to edit this page.' ));
else
wp_die( __('You are not allowed to edit this post.' ));
}
// Autosave shouldn't save too soon after a real save
if ( 'autosave' == $post_data['action'] ) {
$post =& get_post( $post_ID );
$now = time();
$then = strtotime($post->post_date_gmt . ' +0000');
$delta = AUTOSAVE_INTERVAL / 2;
if ( ($now - $then) < $delta )
return $post_ID;
}
$post_data = _wp_translate_postdata( true, $post_data );
if ( is_wp_error($post_data) )
wp_die( $post_data->get_error_message() );
if ( 'autosave' != $post_data['action'] && 'auto-draft' == $post_data['post_status'] )
$post_data['post_status'] = 'draft';
if ( isset($post_data['visibility']) ) {
switch ( $post_data['visibility'] ) {
case 'public' :
$post_data['post_password'] = '';
break;
case 'password' :
unset( $post_data['sticky'] );
break;
case 'private' :
$post_data['post_status'] = 'private';
$post_data['post_password'] = '';
unset( $post_data['sticky'] );
break;
}
}
// Post Formats
if ( isset( $post_data['post_format'] ) ) {
if ( current_theme_supports( 'post-formats', $post_data['post_format'] ) )
set_post_format( $post_ID, $post_data['post_format'] );
elseif ( '0' == $post_data['post_format'] )
set_post_format( $post_ID, false );
}
// Meta Stuff
if ( isset($post_data['meta']) && $post_data['meta'] ) {
foreach ( $post_data['meta'] as $key => $value ) {
if ( !$meta = get_post_meta_by_id( $key ) )
continue;
if ( $meta->post_id != $post_ID )
continue;
if ( is_protected_meta( $value['key'], 'post' ) || ! current_user_can( 'edit_post_meta', $post_ID, $value['key'] ) )
continue;
update_meta( $key, $value['key'], $value['value'] );
}
}
if ( isset($post_data['deletemeta']) && $post_data['deletemeta'] ) {
foreach ( $post_data['deletemeta'] as $key => $value ) {
if ( !$meta = get_post_meta_by_id( $key ) )
continue;
if ( $meta->post_id != $post_ID )
continue;
if ( is_protected_meta( $meta->meta_key, 'post' ) || ! current_user_can( 'delete_post_meta', $post_ID, $meta->meta_key ) )
continue;
delete_meta( $key );
}
}
add_meta( $post_ID );
update_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID );
wp_update_post( $post_data );
// Now that we have an ID we can fix any attachment anchor hrefs
_fix_attachment_links( $post_ID );
wp_set_post_lock( $post_ID );
if ( current_user_can( $ptype->cap->edit_others_posts ) ) {
if ( ! empty( $post_data['sticky'] ) )
stick_post( $post_ID );
else
unstick_post( $post_ID );
}
return $post_ID;
}
/**
* Process the post data for the bulk editing of posts.
*
* Updates all bulk edited posts/pages, adding (but not removing) tags and
* categories. Skips pages when they would be their own parent or child.
*
* @since 2.7.0
*
* @param array $post_data Optional, the array of post data to process if not provided will use $_POST superglobal.
* @return array
*/
function bulk_edit_posts( $post_data = null ) {
global $wpdb;
if ( empty($post_data) )
$post_data = &$_POST;
if ( isset($post_data['post_type']) )
$ptype = get_post_type_object($post_data['post_type']);
else
$ptype = get_post_type_object('post');
if ( !current_user_can( $ptype->cap->edit_posts ) ) {
if ( 'page' == $ptype->name )
wp_die( __('You are not allowed to edit pages.'));
else
wp_die( __('You are not allowed to edit posts.'));
}
if ( -1 == $post_data['_status'] ) {
$post_data['post_status'] = null;
unset($post_data['post_status']);
} else {
$post_data['post_status'] = $post_data['_status'];
}
unset($post_data['_status']);
$post_IDs = array_map( 'intval', (array) $post_data['post'] );
$reset = array( 'post_author', 'post_status', 'post_password', 'post_parent', 'page_template', 'comment_status', 'ping_status', 'keep_private', 'tax_input', 'post_category', 'sticky' );
foreach ( $reset as $field ) {
if ( isset($post_data[$field]) && ( '' == $post_data[$field] || -1 == $post_data[$field] ) )
unset($post_data[$field]);
}
if ( isset($post_data['post_category']) ) {
if ( is_array($post_data['post_category']) && ! empty($post_data['post_category']) )
$new_cats = array_map( 'absint', $post_data['post_category'] );
else
unset($post_data['post_category']);
}
$tax_input = array();
if ( isset($post_data['tax_input'])) {
foreach ( $post_data['tax_input'] as $tax_name => $terms ) {
if ( empty($terms) )
continue;
if ( is_taxonomy_hierarchical( $tax_name ) ) {
$tax_input[ $tax_name ] = array_map( 'absint', $terms );
} else {
$comma = _x( ',', 'tag delimiter' );
if ( ',' !== $comma )
$terms = str_replace( $comma, ',', $terms );
$tax_input[ $tax_name ] = explode( ',', trim( $terms, " \n\t\r\0\x0B," ) );
}
}
}
if ( isset($post_data['post_parent']) && ($parent = (int) $post_data['post_parent']) ) {
$pages = $wpdb->get_results("SELECT ID, post_parent FROM $wpdb->posts WHERE post_type = 'page'");
$children = array();
for ( $i = 0; $i < 50 && $parent > 0; $i++ ) {
$children[] = $parent;
foreach ( $pages as $page ) {
if ( $page->ID == $parent ) {
$parent = $page->post_parent;
break;
}
}
}
}
if ( isset( $post_data['post_format'] ) ) {
if ( '0' == $post_data['post_format'] )
$post_data['post_format'] = false;
// don't change the post format if it's not supported or not '0' (standard)
elseif ( ! current_theme_supports( 'post-formats', $post_data['post_format'] ) )
unset( $post_data['post_format'] );
}
$updated = $skipped = $locked = array();
foreach ( $post_IDs as $post_ID ) {
$post_type_object = get_post_type_object( get_post_type( $post_ID ) );
if ( !isset( $post_type_object ) || ( isset($children) && in_array($post_ID, $children) ) || !current_user_can( $post_type_object->cap->edit_post, $post_ID ) ) {
$skipped[] = $post_ID;
continue;
}
if ( wp_check_post_lock( $post_ID ) ) {
$locked[] = $post_ID;
continue;
}
$post = get_post( $post_ID );
$tax_names = get_object_taxonomies( $post );
foreach ( $tax_names as $tax_name ) {
$taxonomy_obj = get_taxonomy($tax_name);
if ( isset( $tax_input[$tax_name]) && current_user_can( $taxonomy_obj->cap->assign_terms ) )
$new_terms = $tax_input[$tax_name];
else
$new_terms = array();
if ( $taxonomy_obj->hierarchical )
$current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'ids') );
else
$current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array('fields' => 'names') );
$post_data['tax_input'][$tax_name] = array_merge( $current_terms, $new_terms );
}
if ( isset($new_cats) && in_array( 'category', $tax_names ) ) {
$cats = (array) wp_get_post_categories($post_ID);
$post_data['post_category'] = array_unique( array_merge($cats, $new_cats) );
unset( $post_data['tax_input']['category'] );
}
$post_data['post_mime_type'] = $post->post_mime_type;
$post_data['guid'] = $post->guid;
$post_data['ID'] = $post_ID;
$updated[] = wp_update_post( $post_data );
if ( isset( $post_data['sticky'] ) && current_user_can( $ptype->cap->edit_others_posts ) ) {
if ( 'sticky' == $post_data['sticky'] )
stick_post( $post_ID );
else
unstick_post( $post_ID );
}
if ( isset( $post_data['post_format'] ) )
set_post_format( $post_ID, $post_data['post_format'] );
}
return array( 'updated' => $updated, 'skipped' => $skipped, 'locked' => $locked );
}
/**
* Default post information to use when populating the "Write Post" form.
*
* @since 2.0.0
*
* @param string $post_type A post type string, defaults to 'post'.
* @return object stdClass object containing all the default post data as attributes
*/
function get_default_post_to_edit( $post_type = 'post', $create_in_db = false ) {
global $wpdb;
$post_title = '';
if ( !empty( $_REQUEST['post_title'] ) )
$post_title = esc_html( stripslashes( $_REQUEST['post_title'] ));
$post_content = '';
if ( !empty( $_REQUEST['content'] ) )
$post_content = esc_html( stripslashes( $_REQUEST['content'] ));
$post_excerpt = '';
if ( !empty( $_REQUEST['excerpt'] ) )
$post_excerpt = esc_html( stripslashes( $_REQUEST['excerpt'] ));
if ( $create_in_db ) {
$post_id = wp_insert_post( array( 'post_title' => __( 'Auto Draft' ), 'post_type' => $post_type, 'post_status' => 'auto-draft' ) );
$post = get_post( $post_id );
if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) && get_option( 'default_post_format' ) )
set_post_format( $post, get_option( 'default_post_format' ) );
} else {
$post = new stdClass;
$post->ID = 0;
$post->post_author = '';
$post->post_date = '';
$post->post_date_gmt = '';
$post->post_password = '';
$post->post_type = $post_type;
$post->post_status = 'draft';
$post->to_ping = '';
$post->pinged = '';
$post->comment_status = get_option( 'default_comment_status' );
$post->ping_status = get_option( 'default_ping_status' );
$post->post_pingback = get_option( 'default_pingback_flag' );
$post->post_category = get_option( 'default_category' );
$post->page_template = 'default';
$post->post_parent = 0;
$post->menu_order = 0;
}
$post->post_content = apply_filters( 'default_content', $post_content, $post );
$post->post_title = apply_filters( 'default_title', $post_title, $post );
$post->post_excerpt = apply_filters( 'default_excerpt', $post_excerpt, $post );
$post->post_name = '';
return $post;
}
/**
* Get the default page information to use.
*
* @since 2.5.0
*
* @return object stdClass object containing all the default post data as attributes
*/
function get_default_page_to_edit() {
$page = get_default_post_to_edit();
$page->post_type = 'page';
return $page;
}
/**
* Get an existing post and format it for editing.
*
* @since 2.0.0
*
* @param unknown_type $id
* @return unknown
*/
function get_post_to_edit( $id ) {
$post = get_post( $id, OBJECT, 'edit' );
if ( $post->post_type == 'page' )
$post->page_template = get_post_meta( $id, '_wp_page_template', true );
return $post;
}
/**
* Determine if a post exists based on title, content, and date
*
* @since 2.0.0
*
* @param string $title Post title
* @param string $content Optional post content
* @param string $date Optional post date
* @return int Post ID if post exists, 0 otherwise.
*/
function post_exists($title, $content = '', $date = '') {
global $wpdb;
$post_title = stripslashes( sanitize_post_field( 'post_title', $title, 0, 'db' ) );
$post_content = stripslashes( sanitize_post_field( 'post_content', $content, 0, 'db' ) );
$post_date = stripslashes( sanitize_post_field( 'post_date', $date, 0, 'db' ) );
$query = "SELECT ID FROM $wpdb->posts WHERE 1=1";
$args = array();
if ( !empty ( $date ) ) {
$query .= ' AND post_date = %s';
$args[] = $post_date;
}
if ( !empty ( $title ) ) {
$query .= ' AND post_title = %s';
$args[] = $post_title;
}
if ( !empty ( $content ) ) {
$query .= 'AND post_content = %s';
$args[] = $post_content;
}
if ( !empty ( $args ) )
return $wpdb->get_var( $wpdb->prepare($query, $args) );
return 0;
}
/**
* Creates a new post from the "Write Post" form using $_POST information.
*
* @since 2.1.0
*
* @return unknown
*/
function wp_write_post() {
global $user_ID;
if ( isset($_POST['post_type']) )
$ptype = get_post_type_object($_POST['post_type']);
else
$ptype = get_post_type_object('post');
if ( !current_user_can( $ptype->cap->edit_posts ) ) {
if ( 'page' == $ptype->name )
return new WP_Error( 'edit_pages', __( 'You are not allowed to create pages on this site.' ) );
else
return new WP_Error( 'edit_posts', __( 'You are not allowed to create posts or drafts on this site.' ) );
}
$_POST['post_mime_type'] = '';
// Clear out any data in internal vars.
unset( $_POST['filter'] );
// Edit don't write if we have a post id.
if ( isset( $_POST['post_ID'] ) )
return edit_post();
$translated = _wp_translate_postdata( false );
if ( is_wp_error($translated) )
return $translated;
if ( isset($_POST['visibility']) ) {
switch ( $_POST['visibility'] ) {
case 'public' :
$_POST['post_password'] = '';
break;
case 'password' :
unset( $_POST['sticky'] );
break;
case 'private' :
$_POST['post_status'] = 'private';
$_POST['post_password'] = '';
unset( $_POST['sticky'] );
break;
}
}
// Create the post.
$post_ID = wp_insert_post( $_POST );
if ( is_wp_error( $post_ID ) )
return $post_ID;
if ( empty($post_ID) )
return 0;
add_meta( $post_ID );
add_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID );
// Now that we have an ID we can fix any attachment anchor hrefs
_fix_attachment_links( $post_ID );
wp_set_post_lock( $post_ID );
return $post_ID;
}
/**
* Calls wp_write_post() and handles the errors.
*
* @since 2.0.0
* @uses wp_write_post()
* @uses is_wp_error()
* @uses wp_die()
* @return unknown
*/
function write_post() {
$result = wp_write_post();
if ( is_wp_error( $result ) )
wp_die( $result->get_error_message() );
else
return $result;
}
//
// Post Meta
//
/**
* {@internal Missing Short Description}}
*
* @since 1.2.0
*
* @param unknown_type $post_ID
* @return unknown
*/
function add_meta( $post_ID ) {
global $wpdb;
$post_ID = (int) $post_ID;
$metakeyselect = isset($_POST['metakeyselect']) ? stripslashes( trim( $_POST['metakeyselect'] ) ) : '';
$metakeyinput = isset($_POST['metakeyinput']) ? stripslashes( trim( $_POST['metakeyinput'] ) ) : '';
$metavalue = isset($_POST['metavalue']) ? $_POST['metavalue'] : '';
if ( is_string( $metavalue ) )
$metavalue = trim( $metavalue );
if ( ('0' === $metavalue || ! empty ( $metavalue ) ) && ( ( ( '#NONE#' != $metakeyselect ) && !empty ( $metakeyselect) ) || !empty ( $metakeyinput ) ) ) {
// We have a key/value pair. If both the select and the
// input for the key have data, the input takes precedence:
if ( '#NONE#' != $metakeyselect )
$metakey = $metakeyselect;
if ( $metakeyinput )
$metakey = $metakeyinput; // default
if ( is_protected_meta( $metakey, 'post' ) || ! current_user_can( 'add_post_meta', $post_ID, $metakey ) )
return false;
$metakey = esc_sql( $metakey );
return add_post_meta( $post_ID, $metakey, $metavalue );
}
return false;
} // add_meta
/**
* {@internal Missing Short Description}}
*
* @since 1.2.0
*
* @param unknown_type $mid
* @return unknown
*/
function delete_meta( $mid ) {
return delete_metadata_by_mid( 'post' , $mid );
}
/**
* Get a list of previously defined keys.
*
* @since 1.2.0
*
* @return unknown
*/
function get_meta_keys() {
global $wpdb;
$keys = $wpdb->get_col( "
SELECT meta_key
FROM $wpdb->postmeta
GROUP BY meta_key
ORDER BY meta_key" );
return $keys;
}
/**
* {@internal Missing Short Description}}
*
* @since 2.1.0
*
* @param unknown_type $mid
* @return unknown
*/
function get_post_meta_by_id( $mid ) {
return get_metadata_by_mid( 'post', $mid );
}
/**
* {@internal Missing Short Description}}
*
* Some postmeta stuff.
*
* @since 1.2.0
*
* @param unknown_type $postid
* @return unknown
*/
function has_meta( $postid ) {
global $wpdb;
return $wpdb->get_results( $wpdb->prepare("SELECT meta_key, meta_value, meta_id, post_id
FROM $wpdb->postmeta WHERE post_id = %d
ORDER BY meta_key,meta_id", $postid), ARRAY_A );
}
/**
* {@internal Missing Short Description}}
*
* @since 1.2.0
*
* @param unknown_type $meta_id
* @param unknown_type $meta_key Expect Slashed
* @param unknown_type $meta_value Expect Slashed
* @return unknown
*/
function update_meta( $meta_id, $meta_key, $meta_value ) {
$meta_key = stripslashes( $meta_key );
$meta_value = stripslashes_deep( $meta_value );
return update_metadata_by_mid( 'post', $meta_id, $meta_value, $meta_key );
}
//
// Private
//
/**
* Replace hrefs of attachment anchors with up-to-date permalinks.
*
* @since 2.3.0
* @access private
*
* @param unknown_type $post_ID
* @return unknown
*/
function _fix_attachment_links( $post_ID ) {
$post = & get_post( $post_ID, ARRAY_A );
$content = $post['post_content'];
// quick sanity check, don't run if no pretty permalinks or post is not published
if ( !get_option('permalink_structure') || $post['post_status'] != 'publish' )
return;
// Short if there aren't any links or no '?attachment_id=' strings (strpos cannot be zero)
if ( !strpos($content, '?attachment_id=') || !preg_match_all( '/<a ([^>]+)>[\s\S]+?<\/a>/', $content, $link_matches ) )
return;
$site_url = get_bloginfo('url');
$site_url = substr( $site_url, (int) strpos($site_url, '://') ); // remove the http(s)
$replace = '';
foreach ( $link_matches[1] as $key => $value ) {
if ( !strpos($value, '?attachment_id=') || !strpos($value, 'wp-att-')
|| !preg_match( '/href=(["\'])[^"\']*\?attachment_id=(\d+)[^"\']*\\1/', $value, $url_match )
|| !preg_match( '/rel=["\'][^"\']*wp-att-(\d+)/', $value, $rel_match ) )
continue;
$quote = $url_match[1]; // the quote (single or double)
$url_id = (int) $url_match[2];
$rel_id = (int) $rel_match[1];
if ( !$url_id || !$rel_id || $url_id != $rel_id || strpos($url_match[0], $site_url) === false )
continue;
$link = $link_matches[0][$key];
$replace = str_replace( $url_match[0], 'href=' . $quote . get_attachment_link( $url_id ) . $quote, $link );
$content = str_replace( $link, $replace, $content );
}
if ( $replace ) {
$post['post_content'] = $content;
// Escape data pulled from DB.
$post = add_magic_quotes($post);
return wp_update_post($post);
}
}
/**
* Move child posts to a new parent.
*
* @since 2.3.0
* @access private
*
* @param unknown_type $old_ID
* @param unknown_type $new_ID
* @return unknown
*/
function _relocate_children( $old_ID, $new_ID ) {
global $wpdb;
$old_ID = (int) $old_ID;
$new_ID = (int) $new_ID;
$children = $wpdb->get_col( $wpdb->prepare("
SELECT post_id
FROM $wpdb->postmeta
WHERE meta_key = '_wp_attachment_temp_parent'
AND meta_value = %d", $old_ID) );
foreach ( $children as $child_id ) {
$wpdb->update($wpdb->posts, array('post_parent' => $new_ID), array('ID' => $child_id) );
delete_post_meta($child_id, '_wp_attachment_temp_parent');
}
}
/**
* Get all the possible statuses for a post_type
*
* @since 2.5.0
*
* @param string $type The post_type you want the statuses for
* @return array As array of all the statuses for the supplied post type
*/
function get_available_post_statuses($type = 'post') {
$stati = wp_count_posts($type);
return array_keys(get_object_vars($stati));
}
/**
* Run the wp query to fetch the posts for listing on the edit posts page
*
* @since 2.5.0
*
* @param array|bool $q Array of query variables to use to build the query or false to use $_GET superglobal.
* @return array
*/
function wp_edit_posts_query( $q = false ) {
if ( false === $q )
$q = $_GET;
$q['m'] = isset($q['m']) ? (int) $q['m'] : 0;
$q['cat'] = isset($q['cat']) ? (int) $q['cat'] : 0;
$post_stati = get_post_stati();
if ( isset($q['post_type']) && in_array( $q['post_type'], get_post_types() ) )
$post_type = $q['post_type'];
else
$post_type = 'post';
$avail_post_stati = get_available_post_statuses($post_type);
if ( isset($q['post_status']) && in_array( $q['post_status'], $post_stati ) ) {
$post_status = $q['post_status'];
$perm = 'readable';
}
if ( isset($q['orderby']) )
$orderby = $q['orderby'];
elseif ( isset($q['post_status']) && in_array($q['post_status'], array('pending', 'draft')) )
$orderby = 'modified';
if ( isset($q['order']) )
$order = $q['order'];
elseif ( isset($q['post_status']) && 'pending' == $q['post_status'] )
$order = 'ASC';
$per_page = 'edit_' . $post_type . '_per_page';
$posts_per_page = (int) get_user_option( $per_page );
if ( empty( $posts_per_page ) || $posts_per_page < 1 )
$posts_per_page = 20;
$posts_per_page = apply_filters( $per_page, $posts_per_page );
$posts_per_page = apply_filters( 'edit_posts_per_page', $posts_per_page, $post_type );
$query = compact('post_type', 'post_status', 'perm', 'order', 'orderby', 'posts_per_page');
// Hierarchical types require special args.
if ( is_post_type_hierarchical( $post_type ) && !isset($orderby) ) {
$query['orderby'] = 'menu_order title';
$query['order'] = 'asc';
$query['posts_per_page'] = -1;
$query['posts_per_archive_page'] = -1;
}
if ( ! empty( $q['show_sticky'] ) )
$query['post__in'] = (array) get_option( 'sticky_posts' );
wp( $query );
return $avail_post_stati;
}
/**
* Get default post mime types
*
* @since 2.9.0
*
* @return array
*/
function get_post_mime_types() {
$post_mime_types = array( // array( adj, noun )
'image' => array(__('Images'), __('Manage Images'), _n_noop('Image <span class="count">(%s)</span>', 'Images <span class="count">(%s)</span>')),
'audio' => array(__('Audio'), __('Manage Audio'), _n_noop('Audio <span class="count">(%s)</span>', 'Audio <span class="count">(%s)</span>')),
'video' => array(__('Video'), __('Manage Video'), _n_noop('Video <span class="count">(%s)</span>', 'Video <span class="count">(%s)</span>')),
);
return apply_filters('post_mime_types', $post_mime_types);
}
/**
* {@internal Missing Short Description}}
*
* @since 2.5.0
*
* @param unknown_type $type
* @return unknown
*/
function get_available_post_mime_types($type = 'attachment') {
global $wpdb;
$types = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT post_mime_type FROM $wpdb->posts WHERE post_type = %s", $type));
return $types;
}
/**
* {@internal Missing Short Description}}
*
* @since 2.5.0
*
* @param unknown_type $q
* @return unknown
*/
function wp_edit_attachments_query( $q = false ) {
if ( false === $q )
$q = $_GET;
$q['m'] = isset( $q['m'] ) ? (int) $q['m'] : 0;
$q['cat'] = isset( $q['cat'] ) ? (int) $q['cat'] : 0;
$q['post_type'] = 'attachment';
$post_type = get_post_type_object( 'attachment' );
$states = 'inherit';
if ( current_user_can( $post_type->cap->read_private_posts ) )
$states .= ',private';
$q['post_status'] = isset( $q['status'] ) && 'trash' == $q['status'] ? 'trash' : $states;
$media_per_page = (int) get_user_option( 'upload_per_page' );
if ( empty( $media_per_page ) || $media_per_page < 1 )
$media_per_page = 20;
$q['posts_per_page'] = apply_filters( 'upload_per_page', $media_per_page );
$post_mime_types = get_post_mime_types();
$avail_post_mime_types = get_available_post_mime_types('attachment');
if ( isset($q['post_mime_type']) && !array_intersect( (array) $q['post_mime_type'], array_keys($post_mime_types) ) )
unset($q['post_mime_type']);
if ( isset($q['detached']) )
add_filter('posts_where', '_edit_attachments_query_helper');
wp( $q );
if ( isset($q['detached']) )
remove_filter('posts_where', '_edit_attachments_query_helper');
return array($post_mime_types, $avail_post_mime_types);
}
function _edit_attachments_query_helper($where) {
global $wpdb;
return $where .= " AND {$wpdb->posts}.post_parent < 1";
}
/**
* Returns the list of classes to be used by a metabox
*
* @uses get_user_option()
* @since 2.5.0
*
* @param unknown_type $id
* @param unknown_type $page
* @return unknown
*/
function postbox_classes( $id, $page ) {
if ( isset( $_GET['edit'] ) && $_GET['edit'] == $id ) {
$classes = array( '' );
} elseif ( $closed = get_user_option('closedpostboxes_'.$page ) ) {
if ( !is_array( $closed ) ) {
$classes = array( '' );
} else {
$classes = in_array( $id, $closed ) ? array( 'closed' ) : array( '' );
}
} else {
$classes = array( '' );
}
$classes = apply_filters( "postbox_classes_{$page}_{$id}", $classes );
return implode( ' ', $classes );
}
/**
* {@internal Missing Short Description}}
*
* @since 2.5.0
*
* @param int|object $id Post ID or post object.
* @param string $title (optional) Title
* @param string $name (optional) Name
* @return array With two entries of type string
*/
function get_sample_permalink($id, $title = null, $name = null) {
$post = &get_post($id);
if ( !$post->ID )
return array('', '');
$ptype = get_post_type_object($post->post_type);
$original_status = $post->post_status;
$original_date = $post->post_date;
$original_name = $post->post_name;
// Hack: get_permalink would return ugly permalink for
// drafts, so we will fake, that our post is published
if ( in_array($post->post_status, array('draft', 'pending')) ) {
$post->post_status = 'publish';
$post->post_name = sanitize_title($post->post_name ? $post->post_name : $post->post_title, $post->ID);
}
// If the user wants to set a new name -- override the current one
// Note: if empty name is supplied -- use the title instead, see #6072
if ( !is_null($name) )
$post->post_name = sanitize_title($name ? $name : $title, $post->ID);
$post->post_name = wp_unique_post_slug($post->post_name, $post->ID, $post->post_status, $post->post_type, $post->post_parent);
$post->filter = 'sample';
$permalink = get_permalink($post, true);
// Replace custom post_type Token with generic pagename token for ease of use.
$permalink = str_replace("%$post->post_type%", '%pagename%', $permalink);
// Handle page hierarchy
if ( $ptype->hierarchical ) {
$uri = get_page_uri($post);
$uri = untrailingslashit($uri);
$uri = strrev( stristr( strrev( $uri ), '/' ) );
$uri = untrailingslashit($uri);
$uri = apply_filters( 'editable_slug', $uri );
if ( !empty($uri) )
$uri .= '/';
$permalink = str_replace('%pagename%', "{$uri}%pagename%", $permalink);
}
$permalink = array($permalink, apply_filters('editable_slug', $post->post_name));
$post->post_status = $original_status;
$post->post_date = $original_date;
$post->post_name = $original_name;
unset($post->filter);
return $permalink;
}
/**
* sample permalink html
*
* intended to be used for the inplace editor of the permalink post slug on in the post (and page?) editor.
*
* @since 2.5.0
*
* @param int|object $id Post ID or post object.
* @param string $new_title (optional) New title
* @param string $new_slug (optional) New slug
* @return string intended to be used for the inplace editor of the permalink post slug on in the post (and page?) editor.
*/
function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) {
global $wpdb;
$post = &get_post($id);
list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug);
if ( 'publish' == $post->post_status ) {
$ptype = get_post_type_object($post->post_type);
$view_post = $ptype->labels->view_item;
$title = __('Click to edit this part of the permalink');
} else {
$title = __('Temporary permalink. Click to edit this part.');
}
if ( false === strpos($permalink, '%postname%') && false === strpos($permalink, '%pagename%') ) {
$return = '<strong>' . __('Permalink:') . "</strong>\n" . '<span id="sample-permalink">' . $permalink . "</span>\n";
if ( '' == get_option( 'permalink_structure' ) && current_user_can( 'manage_options' ) && !( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') ) )
$return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button" target="_blank">' . __('Change Permalinks') . "</a></span>\n";
if ( isset($view_post) )
$return .= "<span id='view-post-btn'><a href='$permalink' class='button' target='_blank'>$view_post</a></span>\n";
$return = apply_filters('get_sample_permalink_html', $return, $id, $new_title, $new_slug);
return $return;
}
if ( function_exists('mb_strlen') ) {
if ( mb_strlen($post_name) > 30 ) {
$post_name_abridged = mb_substr($post_name, 0, 14). '…' . mb_substr($post_name, -14);
} else {
$post_name_abridged = $post_name;
}
} else {
if ( strlen($post_name) > 30 ) {
$post_name_abridged = substr($post_name, 0, 14). '…' . substr($post_name, -14);
} else {
$post_name_abridged = $post_name;
}
}
$post_name_html = '<span id="editable-post-name" title="' . $title . '">' . $post_name_abridged . '</span>';
$display_link = str_replace(array('%pagename%','%postname%'), $post_name_html, $permalink);
$view_link = str_replace(array('%pagename%','%postname%'), $post_name, $permalink);
$return = '<strong>' . __('Permalink:') . "</strong>\n";
$return .= '<span id="sample-permalink">' . $display_link . "</span>\n";
$return .= '‎'; // Fix bi-directional text display defect in RTL languages.
$return .= '<span id="edit-slug-buttons"><a href="#post_name" class="edit-slug button hide-if-no-js" onclick="editPermalink(' . $id . '); return false;">' . __('Edit') . "</a></span>\n";
$return .= '<span id="editable-post-name-full">' . $post_name . "</span>\n";
if ( isset($view_post) )
$return .= "<span id='view-post-btn'><a href='$view_link' class='button' target='_blank'>$view_post</a></span>\n";
$return = apply_filters('get_sample_permalink_html', $return, $id, $new_title, $new_slug);
return $return;
}
/**
* Output HTML for the post thumbnail meta-box.
*
* @since 2.9.0
*
* @param int $thumbnail_id ID of the attachment used for thumbnail
* @param int $post_id ID of the post associated with the thumbnail, defaults to global $post_ID
* @return string html
*/
function _wp_post_thumbnail_html( $thumbnail_id = null, $post_id = null ) {
global $content_width, $_wp_additional_image_sizes, $post_ID;
if ( empty( $post_id ) )
$post_id = $post_ID;
$upload_iframe_src = esc_url( get_upload_iframe_src('image', $post_id) );
$set_thumbnail_link = '<p class="hide-if-no-js"><a title="' . esc_attr__( 'Set featured image' ) . '" href="%s" id="set-post-thumbnail" class="thickbox">%s</a></p>';
$content = sprintf( $set_thumbnail_link, $upload_iframe_src, esc_html__( 'Set featured image' ) );
if ( $thumbnail_id && get_post( $thumbnail_id ) ) {
$old_content_width = $content_width;
$content_width = 266;
if ( !isset( $_wp_additional_image_sizes['post-thumbnail'] ) )
$thumbnail_html = wp_get_attachment_image( $thumbnail_id, array( $content_width, $content_width ) );
else
$thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'post-thumbnail' );
if ( !empty( $thumbnail_html ) ) {
$ajax_nonce = wp_create_nonce( "set_post_thumbnail-$post_id" );
$content = sprintf( $set_thumbnail_link, $upload_iframe_src, $thumbnail_html );
$content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail" onclick="WPRemoveThumbnail(\'' . $ajax_nonce . '\');return false;">' . esc_html__( 'Remove featured image' ) . '</a></p>';
}
$content_width = $old_content_width;
}
return apply_filters( 'admin_post_thumbnail_html', $content );
}
/**
* Check to see if the post is currently being edited by another user.
*
* @since 2.5.0
*
* @param int $post_id ID of the post to check for editing
* @return bool|int False: not locked or locked by current user. Int: user ID of user with lock.
*/
function wp_check_post_lock( $post_id ) {
if ( !$post = get_post( $post_id ) )
return false;
if ( !$lock = get_post_meta( $post->ID, '_edit_lock', true ) )
return false;
$lock = explode( ':', $lock );
$time = $lock[0];
$user = isset( $lock[1] ) ? $lock[1] : get_post_meta( $post->ID, '_edit_last', true );
$time_window = apply_filters( 'wp_check_post_lock_window', AUTOSAVE_INTERVAL * 2 );
if ( $time && $time > time() - $time_window && $user != get_current_user_id() )
return $user;
return false;
}
/**
* Mark the post as currently being edited by the current user
*
* @since 2.5.0
*
* @param int $post_id ID of the post to being edited
* @return bool|array Returns false if the post doesn't exist of there is no current user, or
* an array of the lock time and the user ID.
*/
function wp_set_post_lock( $post_id ) {
if ( !$post = get_post( $post_id ) )
return false;
if ( 0 == ($user_id = get_current_user_id()) )
return false;
$now = time();
$lock = "$now:$user_id";
update_post_meta( $post->ID, '_edit_lock', $lock );
return array( $now, $user_id );
}
/**
* Outputs the notice message to say that someone else is editing this post at the moment.
*
* @since 2.8.5
* @return none
*/
function _admin_notice_post_locked() {
global $post;
$lock = explode( ':', get_post_meta( $post->ID, '_edit_lock', true ) );
$user = isset( $lock[1] ) ? $lock[1] : get_post_meta( $post->ID, '_edit_last', true );
$last_user = get_userdata( $user );
$last_user_name = $last_user ? $last_user->display_name : __('Somebody');
switch ($post->post_type) {
case 'post':
$message = __( 'Warning: %s is currently editing this post' );
break;
case 'page':
$message = __( 'Warning: %s is currently editing this page' );
break;
default:
$message = __( 'Warning: %s is currently editing this.' );
}
$message = sprintf( $message, esc_html( $last_user_name ) );
echo "<div class='error'><p>$message</p></div>";
}
/**
* Creates autosave data for the specified post from $_POST data.
*
* @package WordPress
* @subpackage Post_Revisions
* @since 2.6.0
*
* @uses _wp_translate_postdata()
* @uses _wp_post_revision_fields()
*
* @return unknown
*/
function wp_create_post_autosave( $post_id ) {
$translated = _wp_translate_postdata( true );
if ( is_wp_error( $translated ) )
return $translated;
// Only store one autosave. If there is already an autosave, overwrite it.
if ( $old_autosave = wp_get_post_autosave( $post_id ) ) {
$new_autosave = _wp_post_revision_fields( $_POST, true );
$new_autosave['ID'] = $old_autosave->ID;
$new_autosave['post_author'] = get_current_user_id();
return wp_update_post( $new_autosave );
}
// _wp_put_post_revision() expects unescaped.
$_POST = stripslashes_deep($_POST);
// Otherwise create the new autosave as a special post revision
return _wp_put_post_revision( $_POST, true );
}
/**
* Save draft or manually autosave for showing preview.
*
* @package WordPress
* @since 2.7.0
*
* @uses get_post_status()
* @uses edit_post()
* @uses get_post()
* @uses current_user_can()
* @uses wp_die()
* @uses wp_create_post_autosave()
* @uses add_query_arg()
* @uses wp_create_nonce()
*
* @return str URL to redirect to show the preview
*/
function post_preview() {
$post_ID = (int) $_POST['post_ID'];
$status = get_post_status( $post_ID );
if ( 'auto-draft' == $status )
wp_die( __('Preview not available. Please save as a draft first.') );
if ( isset($_POST['catslist']) )
$_POST['post_category'] = explode(",", $_POST['catslist']);
if ( isset($_POST['tags_input']) )
$_POST['tags_input'] = explode(",", $_POST['tags_input']);
if ( $_POST['post_type'] == 'page' || empty($_POST['post_category']) )
unset($_POST['post_category']);
$_POST['ID'] = $post_ID;
$post = get_post($post_ID);
if ( 'page' == $post->post_type ) {
if ( !current_user_can('edit_page', $post_ID) )
wp_die(__('You are not allowed to edit this page.'));
} else {
if ( !current_user_can('edit_post', $post_ID) )
wp_die(__('You are not allowed to edit this post.'));
}
if ( 'draft' == $post->post_status ) {
$id = edit_post();
} else { // Non drafts are not overwritten. The autosave is stored in a special post revision.
$id = wp_create_post_autosave( $post->ID );
if ( ! is_wp_error($id) )
$id = $post->ID;
}
if ( is_wp_error($id) )
wp_die( $id->get_error_message() );
if ( $_POST['post_status'] == 'draft' ) {
$url = add_query_arg( 'preview', 'true', get_permalink($id) );
} else {
$nonce = wp_create_nonce('post_preview_' . $id);
$url = add_query_arg( array( 'preview' => 'true', 'preview_id' => $id, 'preview_nonce' => $nonce ), get_permalink($id) );
}
return $url;
}
| 01happy-blog | trunk/myblog/wp-admin/includes/post.php | PHP | oos | 41,028 |
<?php
if ( !defined('ABSPATH') )
exit;
require(ABSPATH . 'wp-includes/version.php');
$man_version = md5( $tinymce_version . $manifest_version );
$mce_ver = "ver=$tinymce_version";
/**
* Retrieve list of all cacheable WP files
*
* Array format: file, version (optional), bool (whether to use src and set ignoreQuery, defaults to true)
*/
function &get_manifest() {
global $mce_ver;
$files = array(
array('images/align-center.png'),
array('images/align-left.png'),
array('images/align-none.png'),
array('images/align-right.png'),
array('images/archive-link.png'),
array('images/blue-grad.png'),
array('images/bubble_bg.gif'),
array('images/bubble_bg-rtl.gif'),
array('images/button-grad.png'),
array('images/button-grad-active.png'),
array('images/comment-grey-bubble.png'),
array('images/date-button.gif'),
array('images/ed-bg.gif'),
array('images/fade-butt.png'),
array('images/fav.png'),
array('images/fav-arrow.gif'),
array('images/fav-arrow-rtl.gif'),
array('images/generic.png'),
array('images/gray-grad.png'),
array('images/icons32.png'),
array('images/icons32-vs.png'),
array('images/list.png'),
array('images/wpspin_light.gif'),
array('images/wpspin_dark.gif'),
array('images/logo.gif'),
array('images/logo-ghost.png'),
array('images/media-button-image.gif'),
array('images/media-button-music.gif'),
array('images/media-button-other.gif'),
array('images/media-button-video.gif'),
array('images/menu.png'),
array('images/menu-vs.png'),
array('images/menu-arrows.gif'),
array('images/menu-bits.gif'),
array('images/menu-bits-rtl.gif'),
array('images/menu-dark.gif'),
array('images/menu-dark-rtl.gif'),
array('images/no.png'),
array('images/required.gif'),
array('images/resize.gif'),
array('images/screen-options-right.gif'),
array('images/screen-options-right-up.gif'),
array('images/se.png'),
array('images/star.gif'),
array('images/toggle-arrow.gif'),
array('images/toggle-arrow-rtl.gif'),
array('images/white-grad.png'),
array('images/white-grad-active.png'),
array('images/wordpress-logo.png'),
array('images/wp-logo.png'),
array('images/xit.gif'),
array('images/yes.png'),
array('../wp-includes/images/crystal/archive.png'),
array('../wp-includes/images/crystal/audio.png'),
array('../wp-includes/images/crystal/code.png'),
array('../wp-includes/images/crystal/default.png'),
array('../wp-includes/images/crystal/document.png'),
array('../wp-includes/images/crystal/interactive.png'),
array('../wp-includes/images/crystal/text.png'),
array('../wp-includes/images/crystal/video.png'),
array('../wp-includes/images/crystal/spreadsheet.png'),
array('../wp-includes/images/rss.png'),
array('../wp-includes/images/blank.gif'),
array('../wp-includes/images/upload.png'),
array('../wp-includes/js/thickbox/loadingAnimation.gif'),
array('../wp-includes/js/thickbox/tb-close.png'),
);
if ( @is_file('../wp-includes/js/tinymce/tiny_mce.js') ) :
$mce = array(
array('../wp-includes/js/tinymce/wp-tinymce.php', $mce_ver),
array('../wp-includes/js/tinymce/tiny_mce.js', $mce_ver),
array('../wp-includes/js/tinymce/langs/wp-langs-en.js', $mce_ver),
array('../wp-includes/js/tinymce/utils/mctabs.js', $mce_ver),
array('../wp-includes/js/tinymce/utils/validate.js', $mce_ver),
array('../wp-includes/js/tinymce/utils/form_utils.js', $mce_ver),
array('../wp-includes/js/tinymce/utils/editable_selects.js', $mce_ver),
array('../wp-includes/js/tinymce/tiny_mce_popup.js', $mce_ver),
array('../wp-includes/js/tinymce/themes/advanced/editor_template.js', $mce_ver),
array('../wp-includes/js/tinymce/themes/advanced/source_editor.htm', $mce_ver),
array('../wp-includes/js/tinymce/themes/advanced/anchor.htm', $mce_ver),
array('../wp-includes/js/tinymce/themes/advanced/image.htm', $mce_ver),
array('../wp-includes/js/tinymce/themes/advanced/link.htm', $mce_ver),
array('../wp-includes/js/tinymce/themes/advanced/color_picker.htm', $mce_ver),
array('../wp-includes/js/tinymce/themes/advanced/charmap.htm', $mce_ver),
array('../wp-includes/js/tinymce/themes/advanced/js/color_picker.js', $mce_ver),
array('../wp-includes/js/tinymce/themes/advanced/js/charmap.js', $mce_ver),
array('../wp-includes/js/tinymce/themes/advanced/js/image.js', $mce_ver),
array('../wp-includes/js/tinymce/themes/advanced/js/link.js', $mce_ver),
array('../wp-includes/js/tinymce/themes/advanced/js/source_editor.js', $mce_ver),
array('../wp-includes/js/tinymce/themes/advanced/js/anchor.js', $mce_ver),
array('../wp-includes/js/tinymce/themes/advanced/skins/wp_theme/ui.css', $mce_ver),
array('../wp-includes/js/tinymce/themes/advanced/skins/wp_theme/content.css', $mce_ver),
array('../wp-includes/js/tinymce/themes/advanced/skins/wp_theme/dialog.css', $mce_ver),
array('../wp-includes/js/tinymce/plugins/fullscreen/editor_plugin.js', $mce_ver),
array('../wp-includes/js/tinymce/plugins/fullscreen/fullscreen.htm', $mce_ver),
array('../wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js', $mce_ver),
array('../wp-includes/js/tinymce/plugins/inlinepopups/template.htm', $mce_ver),
array('../wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/window.css', $mce_ver),
array('../wp-includes/js/tinymce/plugins/media/editor_plugin.js', $mce_ver),
array('../wp-includes/js/tinymce/plugins/media/js/media.js', $mce_ver),
array('../wp-includes/js/tinymce/plugins/media/media.htm', $mce_ver),
array('../wp-includes/js/tinymce/plugins/media/css/content.css', $mce_ver),
array('../wp-includes/js/tinymce/plugins/media/css/media.css', $mce_ver),
array('../wp-includes/js/tinymce/plugins/paste/editor_plugin.js', $mce_ver),
array('../wp-includes/js/tinymce/plugins/paste/js/pasteword.js', $mce_ver),
array('../wp-includes/js/tinymce/plugins/paste/js/pastetext.js', $mce_ver),
array('../wp-includes/js/tinymce/plugins/paste/pasteword.htm', $mce_ver),
array('../wp-includes/js/tinymce/plugins/paste/blank.htm', $mce_ver),
array('../wp-includes/js/tinymce/plugins/paste/pastetext.htm', $mce_ver),
array('../wp-includes/js/tinymce/plugins/safari/editor_plugin.js', $mce_ver),
array('../wp-includes/js/tinymce/plugins/spellchecker/editor_plugin.js', $mce_ver),
array('../wp-includes/js/tinymce/plugins/spellchecker/css/content.css', $mce_ver),
array('../wp-includes/js/tinymce/plugins/tabfocus/editor_plugin.js', $mce_ver),
array('../wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js', $mce_ver),
array('../wp-includes/js/tinymce/plugins/wordpress/css/content.css', $mce_ver),
array('../wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin.js', $mce_ver),
array('../wp-includes/js/tinymce/plugins/wpeditimage/editimage.html', $mce_ver),
array('../wp-includes/js/tinymce/plugins/wpeditimage/js/editimage.js', $mce_ver),
array('../wp-includes/js/tinymce/plugins/wpeditimage/css/editimage.css', $mce_ver),
array('../wp-includes/js/tinymce/plugins/wpeditimage/css/editimage-rtl.css', $mce_ver),
array('../wp-includes/js/tinymce/plugins/wpgallery/editor_plugin.js', $mce_ver),
array('../wp-includes/js/tinymce/themes/advanced/img/icons.gif'),
array('../wp-includes/js/tinymce/themes/advanced/img/colorpicker.jpg'),
array('../wp-includes/js/tinymce/themes/advanced/img/fm.gif'),
array('../wp-includes/js/tinymce/themes/advanced/img/gotmoxie.png'),
array('../wp-includes/js/tinymce/themes/advanced/img/sflogo.png'),
array('../wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/fade-butt.png'),
array('../wp-includes/js/tinymce/themes/advanced/skins/wp_theme/img/tabs.gif'),
array('../wp-includes/images/down_arrow.gif'),
array('../wp-includes/js/tinymce/themes/advanced/skins/default/img/progress.gif'),
array('../wp-includes/js/tinymce/themes/advanced/skins/default/img/menu_check.gif'),
array('../wp-includes/js/tinymce/themes/advanced/skins/default/img/menu_arrow.gif'),
array('../wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/drag.gif'),
array('../wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/corners.gif'),
array('../wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/buttons.gif'),
array('../wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/horizontal.gif'),
array('../wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/alert.gif'),
array('../wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/button.gif'),
array('../wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/confirm.gif'),
array('../wp-includes/js/tinymce/plugins/inlinepopups/skins/clearlooks2/img/vertical.gif'),
array('../wp-includes/js/tinymce/plugins/media/img/flash.gif'),
array('../wp-includes/js/tinymce/plugins/media/img/quicktime.gif'),
array('../wp-includes/js/tinymce/plugins/media/img/realmedia.gif'),
array('../wp-includes/js/tinymce/plugins/media/img/shockwave.gif'),
array('../wp-includes/js/tinymce/plugins/media/img/windowsmedia.gif'),
array('../wp-includes/js/tinymce/plugins/media/img/trans.gif'),
array('../wp-includes/js/tinymce/plugins/spellchecker/img/wline.gif'),
array('../wp-includes/js/tinymce/plugins/wordpress/img/more.gif'),
array('../wp-includes/js/tinymce/plugins/wordpress/img/more_bug.gif'),
array('../wp-includes/js/tinymce/plugins/wordpress/img/page.gif'),
array('../wp-includes/js/tinymce/plugins/wordpress/img/page_bug.gif'),
array('../wp-includes/js/tinymce/plugins/wordpress/img/toolbars.gif'),
array('../wp-includes/js/tinymce/plugins/wordpress/img/help.gif'),
array('../wp-includes/js/tinymce/plugins/wordpress/img/image.gif'),
array('../wp-includes/js/tinymce/plugins/wordpress/img/media.gif'),
array('../wp-includes/js/tinymce/plugins/wordpress/img/video.gif'),
array('../wp-includes/js/tinymce/plugins/wordpress/img/audio.gif'),
array('../wp-includes/js/tinymce/plugins/wpeditimage/img/image.png'),
array('../wp-includes/js/tinymce/plugins/wpeditimage/img/delete.png'),
array('../wp-includes/js/tinymce/plugins/wpgallery/img/delete.png'),
array('../wp-includes/js/tinymce/plugins/wpgallery/img/edit.png'),
array('../wp-includes/js/tinymce/plugins/wpgallery/img/gallery.png')
);
$files = array_merge($files, $mce);
endif;
return $files;
}
| 01happy-blog | trunk/myblog/wp-admin/includes/manifest.php | PHP | oos | 10,298 |
<?php
/**
* Plugin Installer List Table class.
*
* @package WordPress
* @subpackage List_Table
* @since 3.1.0
* @access private
*/
class WP_Plugin_Install_List_Table extends WP_List_Table {
function ajax_user_can() {
return current_user_can('install_plugins');
}
function prepare_items() {
include( ABSPATH . 'wp-admin/includes/plugin-install.php' );
global $tabs, $tab, $paged, $type, $term;
wp_reset_vars( array( 'tab' ) );
$paged = $this->get_pagenum();
$per_page = 30;
// These are the tabs which are shown on the page
$tabs = array();
$tabs['dashboard'] = __( 'Search' );
if ( 'search' == $tab )
$tabs['search'] = __( 'Search Results' );
$tabs['upload'] = __( 'Upload' );
$tabs['featured'] = _x( 'Featured','Plugin Installer' );
$tabs['popular'] = _x( 'Popular','Plugin Installer' );
$tabs['new'] = _x( 'Newest','Plugin Installer' );
$nonmenu_tabs = array( 'plugin-information' ); //Valid actions to perform which do not have a Menu item.
$tabs = apply_filters( 'install_plugins_tabs', $tabs );
$nonmenu_tabs = apply_filters( 'install_plugins_nonmenu_tabs', $nonmenu_tabs );
// If a non-valid menu tab has been selected, And its not a non-menu action.
if ( empty( $tab ) || ( !isset( $tabs[ $tab ] ) && !in_array( $tab, (array) $nonmenu_tabs ) ) )
$tab = key( $tabs );
$args = array( 'page' => $paged, 'per_page' => $per_page );
switch ( $tab ) {
case 'search':
$type = isset( $_REQUEST['type'] ) ? stripslashes( $_REQUEST['type'] ) : 'term';
$term = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '';
switch ( $type ) {
case 'tag':
$args['tag'] = sanitize_title_with_dashes( $term );
break;
case 'term':
$args['search'] = $term;
break;
case 'author':
$args['author'] = $term;
break;
}
add_action( 'install_plugins_table_header', 'install_search_form', 10, 0 );
break;
case 'featured':
case 'popular':
case 'new':
$args['browse'] = $tab;
break;
default:
$args = false;
}
if ( !$args )
return;
$api = plugins_api( 'query_plugins', $args );
if ( is_wp_error( $api ) )
wp_die( $api->get_error_message() . '</p> <p class="hide-if-no-js"><a href="#" onclick="document.location.reload(); return false;">' . __( 'Try again' ) . '</a>' );
$this->items = $api->plugins;
$this->set_pagination_args( array(
'total_items' => $api->info['results'],
'per_page' => $per_page,
) );
}
function no_items() {
_e( 'No plugins match your request.' );
}
function get_views() {
global $tabs, $tab;
$display_tabs = array();
foreach ( (array) $tabs as $action => $text ) {
$class = ( $action == $tab ) ? ' class="current"' : '';
$href = self_admin_url('plugin-install.php?tab=' . $action);
$display_tabs['plugin-install-'.$action] = "<a href='$href'$class>$text</a>";
}
return $display_tabs;
}
function display_tablenav( $which ) {
if ( 'top' == $which ) { ?>
<div class="tablenav top">
<div class="alignleft actions">
<?php do_action( 'install_plugins_table_header' ); ?>
</div>
<?php $this->pagination( $which ); ?>
<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-loading list-ajax-loading" alt="" />
<br class="clear" />
</div>
<?php } else { ?>
<div class="tablenav bottom">
<?php $this->pagination( $which ); ?>
<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-loading list-ajax-loading" alt="" />
<br class="clear" />
</div>
<?php
}
}
function get_table_classes() {
extract( $this->_args );
return array( 'widefat', $plural );
}
function get_columns() {
return array(
'name' => _x( 'Name', 'plugin name' ),
'version' => __( 'Version' ),
'rating' => __( 'Rating' ),
'description' => __( 'Description' ),
);
}
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()
);
list( $columns, $hidden ) = $this->get_column_info();
$style = array();
foreach ( $columns as $column_name => $column_display_name ) {
$style[ $column_name ] = in_array( $column_name, $hidden ) ? 'style="display:none;"' : '';
}
foreach ( (array) $this->items as $plugin ) {
if ( is_object( $plugin ) )
$plugin = (array) $plugin;
$title = wp_kses( $plugin['name'], $plugins_allowedtags );
//Limit description to 400char, and remove any HTML.
$description = strip_tags( $plugin['description'] );
if ( strlen( $description ) > 400 )
$description = mb_substr( $description, 0, 400 ) . '…';
//remove any trailing entities
$description = preg_replace( '/&[^;\s]{0,6}$/', '', $description );
//strip leading/trailing & multiple consecutive lines
$description = trim( $description );
$description = preg_replace( "|(\r?\n)+|", "\n", $description );
//\n => <br>
$description = nl2br( $description );
$version = wp_kses( $plugin['version'], $plugins_allowedtags );
$name = strip_tags( $title . ' ' . $version );
$author = $plugin['author'];
if ( ! empty( $plugin['author'] ) )
$author = ' <cite>' . sprintf( __( 'By %s' ), $author ) . '.</cite>';
$author = wp_kses( $author, $plugins_allowedtags );
$action_links = array();
$action_links[] = '<a href="' . self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $plugin['slug'] .
'&TB_iframe=true&width=600&height=550' ) . '" class="thickbox" title="' .
esc_attr( sprintf( __( 'More information about %s' ), $name ) ) . '">' . __( 'Details' ) . '</a>';
if ( current_user_can( 'install_plugins' ) || current_user_can( 'update_plugins' ) ) {
$status = install_plugin_install_status( $plugin );
switch ( $status['status'] ) {
case 'install':
if ( $status['url'] )
$action_links[] = '<a class="install-now" href="' . $status['url'] . '" title="' . esc_attr( sprintf( __( 'Install %s' ), $name ) ) . '">' . __( 'Install Now' ) . '</a>';
break;
case 'update_available':
if ( $status['url'] )
$action_links[] = '<a href="' . $status['url'] . '" title="' . esc_attr( sprintf( __( 'Update to version %s' ), $status['version'] ) ) . '">' . sprintf( __( 'Update Now' ), $status['version'] ) . '</a>';
break;
case 'latest_installed':
case 'newer_installed':
$action_links[] = '<span title="' . esc_attr__( 'This plugin is already installed and is up to date' ) . ' ">' . _x( 'Installed', 'plugin' ) . '</span>';
break;
}
}
$action_links = apply_filters( 'plugin_install_action_links', $action_links, $plugin );
?>
<tr>
<td class="name column-name"<?php echo $style['name']; ?>><strong><?php echo $title; ?></strong>
<div class="action-links"><?php if ( !empty( $action_links ) ) echo implode( ' | ', $action_links ); ?></div>
</td>
<td class="vers column-version"<?php echo $style['version']; ?>><?php echo $version; ?></td>
<td class="vers column-rating"<?php echo $style['rating']; ?>>
<div class="star-holder" title="<?php printf( _n( '(based on %s rating)', '(based on %s ratings)', $plugin['num_ratings'] ), number_format_i18n( $plugin['num_ratings'] ) ) ?>">
<div class="star star-rating" style="width: <?php echo esc_attr( str_replace( ',', '.', $plugin['rating'] ) ); ?>px"></div>
</div>
</td>
<td class="desc column-description"<?php echo $style['description']; ?>><?php echo $description, $author; ?></td>
</tr>
<?php
}
}
}
| 01happy-blog | trunk/myblog/wp-admin/includes/class-wp-plugin-install-list-table.php | PHP | oos | 7,866 |
<?php
/**
* WordPress Plugin Administration API
*
* @package WordPress
* @subpackage Administration
*/
/**
* Parse the plugin contents to retrieve plugin's metadata.
*
* The metadata of the plugin's data searches for the following in the plugin's
* header. All plugin data must be on its own line. For plugin description, it
* must not have any newlines or only parts of the description will be displayed
* and the same goes for the plugin data. The below is formatted for printing.
*
* <code>
* /*
* Plugin Name: Name of Plugin
* Plugin URI: Link to plugin information
* Description: Plugin Description
* Author: Plugin author's name
* Author URI: Link to the author's web site
* Version: Must be set in the plugin for WordPress 2.3+
* Text Domain: Optional. Unique identifier, should be same as the one used in
* plugin_text_domain()
* Domain Path: Optional. Only useful if the translations are located in a
* folder above the plugin's base path. For example, if .mo files are
* located in the locale folder then Domain Path will be "/locale/" and
* must have the first slash. Defaults to the base folder the plugin is
* located in.
* Network: Optional. Specify "Network: true" to require that a plugin is activated
* across all sites in an installation. This will prevent a plugin from being
* activated on a single site when Multisite is enabled.
* * / # Remove the space to close comment
* </code>
*
* Plugin data returned array contains the following:
* 'Name' - Name of the plugin, must be unique.
* 'Title' - Title of the plugin and the link to the plugin's web site.
* 'Description' - Description of what the plugin does and/or notes
* from the author.
* 'Author' - The author's name
* 'AuthorURI' - The authors web site address.
* 'Version' - The plugin version number.
* 'PluginURI' - Plugin web site address.
* 'TextDomain' - Plugin's text domain for localization.
* 'DomainPath' - Plugin's relative directory path to .mo files.
* 'Network' - Boolean. Whether the plugin can only be activated network wide.
*
* Some users have issues with opening large files and manipulating the contents
* for want is usually the first 1kiB or 2kiB. This function stops pulling in
* the plugin contents when it has all of the required plugin data.
*
* The first 8kiB of the file will be pulled in and if the plugin data is not
* within that first 8kiB, then the plugin author should correct their plugin
* and move the plugin data headers to the top.
*
* The plugin file is assumed to have permissions to allow for scripts to read
* the file. This is not checked however and the file is only opened for
* reading.
*
* @link http://trac.wordpress.org/ticket/5651 Previous Optimizations.
* @link http://trac.wordpress.org/ticket/7372 Further and better Optimizations.
* @since 1.5.0
*
* @param string $plugin_file Path to the plugin file
* @param bool $markup Optional. If the returned data should have HTML markup applied. Defaults to true.
* @param bool $translate Optional. If the returned data should be translated. Defaults to true.
* @return array See above for description.
*/
function get_plugin_data( $plugin_file, $markup = true, $translate = true ) {
$default_headers = array(
'Name' => 'Plugin Name',
'PluginURI' => 'Plugin URI',
'Version' => 'Version',
'Description' => 'Description',
'Author' => 'Author',
'AuthorURI' => 'Author URI',
'TextDomain' => 'Text Domain',
'DomainPath' => 'Domain Path',
'Network' => 'Network',
// Site Wide Only is deprecated in favor of Network.
'_sitewide' => 'Site Wide Only',
);
$plugin_data = get_file_data( $plugin_file, $default_headers, 'plugin' );
// Site Wide Only is the old header for Network
if ( ! $plugin_data['Network'] && $plugin_data['_sitewide'] ) {
_deprecated_argument( __FUNCTION__, '3.0', sprintf( __( 'The <code>%1$s</code> plugin header is deprecated. Use <code>%2$s</code> instead.' ), 'Site Wide Only: true', 'Network: true' ) );
$plugin_data['Network'] = $plugin_data['_sitewide'];
}
$plugin_data['Network'] = ( 'true' == strtolower( $plugin_data['Network'] ) );
unset( $plugin_data['_sitewide'] );
if ( $markup || $translate ) {
$plugin_data = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup, $translate );
} else {
$plugin_data['Title'] = $plugin_data['Name'];
$plugin_data['AuthorName'] = $plugin_data['Author'];
}
return $plugin_data;
}
/**
* Sanitizes plugin data, optionally adds markup, optionally translates.
*
* @since 2.7.0
* @access private
* @see get_plugin_data()
*/
function _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup = true, $translate = true ) {
// Translate fields
if ( $translate ) {
if ( $textdomain = $plugin_data['TextDomain'] ) {
if ( $plugin_data['DomainPath'] )
load_plugin_textdomain( $textdomain, false, dirname( $plugin_file ) . $plugin_data['DomainPath'] );
else
load_plugin_textdomain( $textdomain, false, dirname( $plugin_file ) );
} elseif ( in_array( basename( $plugin_file ), array( 'hello.php', 'akismet.php' ) ) ) {
$textdomain = 'default';
}
if ( $textdomain ) {
foreach ( array( 'Name', 'PluginURI', 'Description', 'Author', 'AuthorURI', 'Version' ) as $field )
$plugin_data[ $field ] = translate( $plugin_data[ $field ], $textdomain );
}
}
// Sanitize fields
$allowed_tags = $allowed_tags_in_links = array(
'abbr' => array( 'title' => true ),
'acronym' => array( 'title' => true ),
'code' => true,
'em' => true,
'strong' => true,
);
$allowed_tags['a'] = array( 'href' => true, 'title' => true );
// Name is marked up inside <a> tags. Don't allow these.
// Author is too, but some plugins have used <a> here (omitting Author URI).
$plugin_data['Name'] = wp_kses( $plugin_data['Name'], $allowed_tags_in_links );
$plugin_data['Author'] = wp_kses( $plugin_data['Author'], $allowed_tags );
$plugin_data['Description'] = wp_kses( $plugin_data['Description'], $allowed_tags );
$plugin_data['Version'] = wp_kses( $plugin_data['Version'], $allowed_tags );
$plugin_data['PluginURI'] = esc_url( $plugin_data['PluginURI'] );
$plugin_data['AuthorURI'] = esc_url( $plugin_data['AuthorURI'] );
$plugin_data['Title'] = $plugin_data['Name'];
$plugin_data['AuthorName'] = $plugin_data['Author'];
// Apply markup
if ( $markup ) {
if ( $plugin_data['PluginURI'] && $plugin_data['Name'] )
$plugin_data['Title'] = '<a href="' . $plugin_data['PluginURI'] . '" title="' . esc_attr__( 'Visit plugin homepage' ) . '">' . $plugin_data['Name'] . '</a>';
if ( $plugin_data['AuthorURI'] && $plugin_data['Author'] )
$plugin_data['Author'] = '<a href="' . $plugin_data['AuthorURI'] . '" title="' . esc_attr__( 'Visit author homepage' ) . '">' . $plugin_data['Author'] . '</a>';
$plugin_data['Description'] = wptexturize( $plugin_data['Description'] );
if ( $plugin_data['Author'] )
$plugin_data['Description'] .= ' <cite>' . sprintf( __('By %s.'), $plugin_data['Author'] ) . '</cite>';
}
return $plugin_data;
}
/**
* Get a list of a plugin's files.
*
* @since 2.8.0
*
* @param string $plugin Plugin ID
* @return array List of files relative to the plugin root.
*/
function get_plugin_files($plugin) {
$plugin_file = WP_PLUGIN_DIR . '/' . $plugin;
$dir = dirname($plugin_file);
$plugin_files = array($plugin);
if ( is_dir($dir) && $dir != WP_PLUGIN_DIR ) {
$plugins_dir = @ opendir( $dir );
if ( $plugins_dir ) {
while (($file = readdir( $plugins_dir ) ) !== false ) {
if ( substr($file, 0, 1) == '.' )
continue;
if ( is_dir( $dir . '/' . $file ) ) {
$plugins_subdir = @ opendir( $dir . '/' . $file );
if ( $plugins_subdir ) {
while (($subfile = readdir( $plugins_subdir ) ) !== false ) {
if ( substr($subfile, 0, 1) == '.' )
continue;
$plugin_files[] = plugin_basename("$dir/$file/$subfile");
}
@closedir( $plugins_subdir );
}
} else {
if ( plugin_basename("$dir/$file") != $plugin )
$plugin_files[] = plugin_basename("$dir/$file");
}
}
@closedir( $plugins_dir );
}
}
return $plugin_files;
}
/**
* Check the plugins directory and retrieve all plugin files with plugin data.
*
* WordPress only supports plugin files in the base plugins directory
* (wp-content/plugins) and in one directory above the plugins directory
* (wp-content/plugins/my-plugin). The file it looks for has the plugin data and
* must be found in those two locations. It is recommended that do keep your
* plugin files in directories.
*
* The file with the plugin data is the file that will be included and therefore
* needs to have the main execution for the plugin. This does not mean
* everything must be contained in the file and it is recommended that the file
* be split for maintainability. Keep everything in one file for extreme
* optimization purposes.
*
* @since 1.5.0
*
* @param string $plugin_folder Optional. Relative path to single plugin folder.
* @return array Key is the plugin file path and the value is an array of the plugin data.
*/
function get_plugins($plugin_folder = '') {
if ( ! $cache_plugins = wp_cache_get('plugins', 'plugins') )
$cache_plugins = array();
if ( isset($cache_plugins[ $plugin_folder ]) )
return $cache_plugins[ $plugin_folder ];
$wp_plugins = array ();
$plugin_root = WP_PLUGIN_DIR;
if ( !empty($plugin_folder) )
$plugin_root .= $plugin_folder;
// Files in wp-content/plugins directory
$plugins_dir = @ opendir( $plugin_root);
$plugin_files = array();
if ( $plugins_dir ) {
while (($file = readdir( $plugins_dir ) ) !== false ) {
if ( substr($file, 0, 1) == '.' )
continue;
if ( is_dir( $plugin_root.'/'.$file ) ) {
$plugins_subdir = @ opendir( $plugin_root.'/'.$file );
if ( $plugins_subdir ) {
while (($subfile = readdir( $plugins_subdir ) ) !== false ) {
if ( substr($subfile, 0, 1) == '.' )
continue;
if ( substr($subfile, -4) == '.php' )
$plugin_files[] = "$file/$subfile";
}
closedir( $plugins_subdir );
}
} else {
if ( substr($file, -4) == '.php' )
$plugin_files[] = $file;
}
}
closedir( $plugins_dir );
}
if ( empty($plugin_files) )
return $wp_plugins;
foreach ( $plugin_files as $plugin_file ) {
if ( !is_readable( "$plugin_root/$plugin_file" ) )
continue;
$plugin_data = get_plugin_data( "$plugin_root/$plugin_file", false, false ); //Do not apply markup/translate as it'll be cached.
if ( empty ( $plugin_data['Name'] ) )
continue;
$wp_plugins[plugin_basename( $plugin_file )] = $plugin_data;
}
uasort( $wp_plugins, '_sort_uname_callback' );
$cache_plugins[ $plugin_folder ] = $wp_plugins;
wp_cache_set('plugins', $cache_plugins, 'plugins');
return $wp_plugins;
}
/**
* Check the mu-plugins directory and retrieve all mu-plugin files with any plugin data.
*
* WordPress only includes mu-plugin files in the base mu-plugins directory (wp-content/mu-plugins).
*
* @since 3.0.0
* @return array Key is the mu-plugin file path and the value is an array of the mu-plugin data.
*/
function get_mu_plugins() {
$wp_plugins = array();
// Files in wp-content/mu-plugins directory
$plugin_files = array();
if ( ! is_dir( WPMU_PLUGIN_DIR ) )
return $wp_plugins;
if ( $plugins_dir = @ opendir( WPMU_PLUGIN_DIR ) ) {
while ( ( $file = readdir( $plugins_dir ) ) !== false ) {
if ( substr( $file, -4 ) == '.php' )
$plugin_files[] = $file;
}
} else {
return $wp_plugins;
}
@closedir( $plugins_dir );
if ( empty($plugin_files) )
return $wp_plugins;
foreach ( $plugin_files as $plugin_file ) {
if ( !is_readable( WPMU_PLUGIN_DIR . "/$plugin_file" ) )
continue;
$plugin_data = get_plugin_data( WPMU_PLUGIN_DIR . "/$plugin_file", false, false ); //Do not apply markup/translate as it'll be cached.
if ( empty ( $plugin_data['Name'] ) )
$plugin_data['Name'] = $plugin_file;
$wp_plugins[ $plugin_file ] = $plugin_data;
}
if ( isset( $wp_plugins['index.php'] ) && filesize( WPMU_PLUGIN_DIR . '/index.php') <= 30 ) // silence is golden
unset( $wp_plugins['index.php'] );
uasort( $wp_plugins, '_sort_uname_callback' );
return $wp_plugins;
}
/**
* Callback to sort array by a 'Name' key.
*
* @since 3.1.0
* @access private
*/
function _sort_uname_callback( $a, $b ) {
return strnatcasecmp( $a['Name'], $b['Name'] );
}
/**
* Check the wp-content directory and retrieve all drop-ins with any plugin data.
*
* @since 3.0.0
* @return array Key is the file path and the value is an array of the plugin data.
*/
function get_dropins() {
$dropins = array();
$plugin_files = array();
$_dropins = _get_dropins();
// These exist in the wp-content directory
if ( $plugins_dir = @ opendir( WP_CONTENT_DIR ) ) {
while ( ( $file = readdir( $plugins_dir ) ) !== false ) {
if ( isset( $_dropins[ $file ] ) )
$plugin_files[] = $file;
}
} else {
return $dropins;
}
@closedir( $plugins_dir );
if ( empty($plugin_files) )
return $dropins;
foreach ( $plugin_files as $plugin_file ) {
if ( !is_readable( WP_CONTENT_DIR . "/$plugin_file" ) )
continue;
$plugin_data = get_plugin_data( WP_CONTENT_DIR . "/$plugin_file", false, false ); //Do not apply markup/translate as it'll be cached.
if ( empty( $plugin_data['Name'] ) )
$plugin_data['Name'] = $plugin_file;
$dropins[ $plugin_file ] = $plugin_data;
}
uksort( $dropins, 'strnatcasecmp' );
return $dropins;
}
/**
* Returns drop-ins that WordPress uses.
*
* Includes Multisite drop-ins only when is_multisite()
*
* @since 3.0.0
* @return array Key is file name. The value is an array, with the first value the
* purpose of the drop-in and the second value the name of the constant that must be
* true for the drop-in to be used, or true if no constant is required.
*/
function _get_dropins() {
$dropins = array(
'advanced-cache.php' => array( __( 'Advanced caching plugin.' ), 'WP_CACHE' ), // WP_CACHE
'db.php' => array( __( 'Custom database class.' ), true ), // auto on load
'db-error.php' => array( __( 'Custom database error message.' ), true ), // auto on error
'install.php' => array( __( 'Custom install script.' ), true ), // auto on install
'maintenance.php' => array( __( 'Custom maintenance message.' ), true ), // auto on maintenance
'object-cache.php' => array( __( 'External object cache.' ), true ), // auto on load
);
if ( is_multisite() ) {
$dropins['sunrise.php' ] = array( __( 'Executed before Multisite is loaded.' ), 'SUNRISE' ); // SUNRISE
$dropins['blog-deleted.php' ] = array( __( 'Custom site deleted message.' ), true ); // auto on deleted blog
$dropins['blog-inactive.php' ] = array( __( 'Custom site inactive message.' ), true ); // auto on inactive blog
$dropins['blog-suspended.php'] = array( __( 'Custom site suspended message.' ), true ); // auto on archived or spammed blog
}
return $dropins;
}
/**
* Check whether the plugin is active by checking the active_plugins list.
*
* @since 2.5.0
*
* @param string $plugin Base plugin path from plugins directory.
* @return bool True, if in the active plugins list. False, not in the list.
*/
function is_plugin_active( $plugin ) {
return in_array( $plugin, (array) get_option( 'active_plugins', array() ) ) || is_plugin_active_for_network( $plugin );
}
/**
* Check whether the plugin is inactive.
*
* Reverse of is_plugin_active(). Used as a callback.
*
* @since 3.1.0
* @see is_plugin_active()
*
* @param string $plugin Base plugin path from plugins directory.
* @return bool True if inactive. False if active.
*/
function is_plugin_inactive( $plugin ) {
return ! is_plugin_active( $plugin );
}
/**
* Check whether the plugin is active for the entire network.
*
* @since 3.0.0
*
* @param string $plugin Base plugin path from plugins directory.
* @return bool True, if active for the network, otherwise false.
*/
function is_plugin_active_for_network( $plugin ) {
if ( !is_multisite() )
return false;
$plugins = get_site_option( 'active_sitewide_plugins');
if ( isset($plugins[$plugin]) )
return true;
return false;
}
/**
* Checks for "Network: true" in the plugin header to see if this should
* be activated only as a network wide plugin. The plugin would also work
* when Multisite is not enabled.
*
* Checks for "Site Wide Only: true" for backwards compatibility.
*
* @since 3.0.0
*
* @param string $plugin Plugin to check
* @return bool True if plugin is network only, false otherwise.
*/
function is_network_only_plugin( $plugin ) {
$plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
if ( $plugin_data )
return $plugin_data['Network'];
return false;
}
/**
* Attempts activation of plugin in a "sandbox" and redirects on success.
*
* A plugin that is already activated will not attempt to be activated again.
*
* The way it works is by setting the redirection to the error before trying to
* include the plugin file. If the plugin fails, then the redirection will not
* be overwritten with the success message. Also, the options will not be
* updated and the activation hook will not be called on plugin error.
*
* It should be noted that in no way the below code will actually prevent errors
* within the file. The code should not be used elsewhere to replicate the
* "sandbox", which uses redirection to work.
* {@source 13 1}
*
* If any errors are found or text is outputted, then it will be captured to
* ensure that the success redirection will update the error redirection.
*
* @since 2.5.0
*
* @param string $plugin Plugin path to main plugin file with plugin data.
* @param string $redirect Optional. URL to redirect to.
* @param bool $network_wide Whether to enable the plugin for all sites in the
* network or just the current site. Multisite only. Default is false.
* @param bool $silent Prevent calling activation hooks. Optional, default is false.
* @return WP_Error|null WP_Error on invalid file or null on success.
*/
function activate_plugin( $plugin, $redirect = '', $network_wide = false, $silent = false ) {
$plugin = plugin_basename( trim( $plugin ) );
if ( is_multisite() && ( $network_wide || is_network_only_plugin($plugin) ) ) {
$network_wide = true;
$current = get_site_option( 'active_sitewide_plugins', array() );
$_GET['networkwide'] = 1; // Back compat for plugins looking for this value.
} else {
$current = get_option( 'active_plugins', array() );
}
$valid = validate_plugin($plugin);
if ( is_wp_error($valid) )
return $valid;
if ( !in_array($plugin, $current) ) {
if ( !empty($redirect) )
wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), $redirect)); // we'll override this later if the plugin can be included without fatal error
ob_start();
include_once(WP_PLUGIN_DIR . '/' . $plugin);
if ( ! $silent ) {
do_action( 'activate_plugin', $plugin, $network_wide );
do_action( 'activate_' . $plugin, $network_wide );
}
if ( $network_wide ) {
$current[$plugin] = time();
update_site_option( 'active_sitewide_plugins', $current );
} else {
$current[] = $plugin;
sort($current);
update_option('active_plugins', $current);
}
if ( ! $silent ) {
do_action( 'activated_plugin', $plugin, $network_wide );
}
if ( ob_get_length() > 0 ) {
$output = ob_get_clean();
return new WP_Error('unexpected_output', __('The plugin generated unexpected output.'), $output);
}
ob_end_clean();
}
return null;
}
/**
* Deactivate a single plugin or multiple plugins.
*
* The deactivation hook is disabled by the plugin upgrader by using the $silent
* parameter.
*
* @since 2.5.0
*
* @param string|array $plugins Single plugin or list of plugins to deactivate.
* @param mixed $network_wide Whether to deactivate the plugin for all sites in the network.
* A value of null (the default) will deactivate plugins for both the site and the network.
* @param bool $silent Prevent calling deactivation hooks. Default is false.
*/
function deactivate_plugins( $plugins, $silent = false, $network_wide = null ) {
if ( is_multisite() )
$network_current = get_site_option( 'active_sitewide_plugins', array() );
$current = get_option( 'active_plugins', array() );
$do_blog = $do_network = false;
foreach ( (array) $plugins as $plugin ) {
$plugin = plugin_basename( trim( $plugin ) );
if ( ! is_plugin_active($plugin) )
continue;
$network_deactivating = false !== $network_wide && is_plugin_active_for_network( $plugin );
if ( ! $silent )
do_action( 'deactivate_plugin', $plugin, $network_deactivating );
if ( false !== $network_wide ) {
if ( is_plugin_active_for_network( $plugin ) ) {
$do_network = true;
unset( $network_current[ $plugin ] );
} elseif ( $network_wide ) {
continue;
}
}
if ( true !== $network_wide ) {
$key = array_search( $plugin, $current );
if ( false !== $key ) {
$do_blog = true;
array_splice( $current, $key, 1 );
}
}
if ( ! $silent ) {
do_action( 'deactivate_' . $plugin, $network_deactivating );
do_action( 'deactivated_plugin', $plugin, $network_deactivating );
}
}
if ( $do_blog )
update_option('active_plugins', $current);
if ( $do_network )
update_site_option( 'active_sitewide_plugins', $network_current );
}
/**
* Activate multiple plugins.
*
* When WP_Error is returned, it does not mean that one of the plugins had
* errors. It means that one or more of the plugins file path was invalid.
*
* The execution will be halted as soon as one of the plugins has an error.
*
* @since 2.6.0
*
* @param string|array $plugins
* @param string $redirect Redirect to page after successful activation.
* @param bool $network_wide Whether to enable the plugin for all sites in the network.
* @param bool $silent Prevent calling activation hooks. Default is false.
* @return bool|WP_Error True when finished or WP_Error if there were errors during a plugin activation.
*/
function activate_plugins( $plugins, $redirect = '', $network_wide = false, $silent = false ) {
if ( !is_array($plugins) )
$plugins = array($plugins);
$errors = array();
foreach ( $plugins as $plugin ) {
if ( !empty($redirect) )
$redirect = add_query_arg('plugin', $plugin, $redirect);
$result = activate_plugin($plugin, $redirect, $network_wide, $silent);
if ( is_wp_error($result) )
$errors[$plugin] = $result;
}
if ( !empty($errors) )
return new WP_Error('plugins_invalid', __('One of the plugins is invalid.'), $errors);
return true;
}
/**
* Remove directory and files of a plugin for a single or list of plugin(s).
*
* If the plugins parameter list is empty, false will be returned. True when
* completed.
*
* @since 2.6.0
*
* @param array $plugins List of plugin
* @param string $redirect Redirect to page when complete.
* @return mixed
*/
function delete_plugins($plugins, $redirect = '' ) {
global $wp_filesystem;
if ( empty($plugins) )
return false;
$checked = array();
foreach( $plugins as $plugin )
$checked[] = 'checked[]=' . $plugin;
ob_start();
$url = wp_nonce_url('plugins.php?action=delete-selected&verify-delete=1&' . implode('&', $checked), 'bulk-plugins');
if ( false === ($credentials = request_filesystem_credentials($url)) ) {
$data = ob_get_contents();
ob_end_clean();
if ( ! empty($data) ){
include_once( ABSPATH . 'wp-admin/admin-header.php');
echo $data;
include( ABSPATH . 'wp-admin/admin-footer.php');
exit;
}
return;
}
if ( ! WP_Filesystem($credentials) ) {
request_filesystem_credentials($url, '', true); //Failed to connect, Error and request again
$data = ob_get_contents();
ob_end_clean();
if ( ! empty($data) ){
include_once( ABSPATH . 'wp-admin/admin-header.php');
echo $data;
include( ABSPATH . 'wp-admin/admin-footer.php');
exit;
}
return;
}
if ( ! is_object($wp_filesystem) )
return new WP_Error('fs_unavailable', __('Could not access filesystem.'));
if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() )
return new WP_Error('fs_error', __('Filesystem error.'), $wp_filesystem->errors);
//Get the base plugin folder
$plugins_dir = $wp_filesystem->wp_plugins_dir();
if ( empty($plugins_dir) )
return new WP_Error('fs_no_plugins_dir', __('Unable to locate WordPress Plugin directory.'));
$plugins_dir = trailingslashit( $plugins_dir );
$errors = array();
foreach( $plugins as $plugin_file ) {
// Run Uninstall hook
if ( is_uninstallable_plugin( $plugin_file ) )
uninstall_plugin($plugin_file);
$this_plugin_dir = trailingslashit( dirname($plugins_dir . $plugin_file) );
// If plugin is in its own directory, recursively delete the directory.
if ( strpos($plugin_file, '/') && $this_plugin_dir != $plugins_dir ) //base check on if plugin includes directory separator AND that its not the root plugin folder
$deleted = $wp_filesystem->delete($this_plugin_dir, true);
else
$deleted = $wp_filesystem->delete($plugins_dir . $plugin_file);
if ( ! $deleted )
$errors[] = $plugin_file;
}
if ( ! empty($errors) )
return new WP_Error('could_not_remove_plugin', sprintf(__('Could not fully remove the plugin(s) %s.'), implode(', ', $errors)) );
// Force refresh of plugin update information
if ( $current = get_site_transient('update_plugins') ) {
unset( $current->response[ $plugin_file ] );
set_site_transient('update_plugins', $current);
}
return true;
}
/**
* Validate active plugins
*
* Validate all active plugins, deactivates invalid and
* returns an array of deactivated ones.
*
* @since 2.5.0
* @return array invalid plugins, plugin as key, error as value
*/
function validate_active_plugins() {
$plugins = get_option( 'active_plugins', array() );
// validate vartype: array
if ( ! is_array( $plugins ) ) {
update_option( 'active_plugins', array() );
$plugins = array();
}
if ( is_multisite() && is_super_admin() ) {
$network_plugins = (array) get_site_option( 'active_sitewide_plugins', array() );
$plugins = array_merge( $plugins, array_keys( $network_plugins ) );
}
if ( empty( $plugins ) )
return;
$invalid = array();
// invalid plugins get deactivated
foreach ( $plugins as $plugin ) {
$result = validate_plugin( $plugin );
if ( is_wp_error( $result ) ) {
$invalid[$plugin] = $result;
deactivate_plugins( $plugin, true );
}
}
return $invalid;
}
/**
* Validate the plugin path.
*
* Checks that the file exists and {@link validate_file() is valid file}.
*
* @since 2.5.0
*
* @param string $plugin Plugin Path
* @return WP_Error|int 0 on success, WP_Error on failure.
*/
function validate_plugin($plugin) {
if ( validate_file($plugin) )
return new WP_Error('plugin_invalid', __('Invalid plugin path.'));
if ( ! file_exists(WP_PLUGIN_DIR . '/' . $plugin) )
return new WP_Error('plugin_not_found', __('Plugin file does not exist.'));
$installed_plugins = get_plugins();
if ( ! isset($installed_plugins[$plugin]) )
return new WP_Error('no_plugin_header', __('The plugin does not have a valid header.'));
return 0;
}
/**
* Whether the plugin can be uninstalled.
*
* @since 2.7.0
*
* @param string $plugin Plugin path to check.
* @return bool Whether plugin can be uninstalled.
*/
function is_uninstallable_plugin($plugin) {
$file = plugin_basename($plugin);
$uninstallable_plugins = (array) get_option('uninstall_plugins');
if ( isset( $uninstallable_plugins[$file] ) || file_exists( WP_PLUGIN_DIR . '/' . dirname($file) . '/uninstall.php' ) )
return true;
return false;
}
/**
* Uninstall a single plugin.
*
* Calls the uninstall hook, if it is available.
*
* @since 2.7.0
*
* @param string $plugin Relative plugin path from Plugin Directory.
*/
function uninstall_plugin($plugin) {
$file = plugin_basename($plugin);
$uninstallable_plugins = (array) get_option('uninstall_plugins');
if ( file_exists( WP_PLUGIN_DIR . '/' . dirname($file) . '/uninstall.php' ) ) {
if ( isset( $uninstallable_plugins[$file] ) ) {
unset($uninstallable_plugins[$file]);
update_option('uninstall_plugins', $uninstallable_plugins);
}
unset($uninstallable_plugins);
define('WP_UNINSTALL_PLUGIN', $file);
include WP_PLUGIN_DIR . '/' . dirname($file) . '/uninstall.php';
return true;
}
if ( isset( $uninstallable_plugins[$file] ) ) {
$callable = $uninstallable_plugins[$file];
unset($uninstallable_plugins[$file]);
update_option('uninstall_plugins', $uninstallable_plugins);
unset($uninstallable_plugins);
include WP_PLUGIN_DIR . '/' . $file;
add_action( 'uninstall_' . $file, $callable );
do_action( 'uninstall_' . $file );
}
}
//
// Menu
//
/**
* Add a top level menu page
*
* This function takes a capability which will be used to determine whether
* or not a page is included in the menu.
*
* The function which is hooked in to handle the output of the page must check
* that the user has the required capability as well.
*
* @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
* @param string $menu_title The text to be used for the menu
* @param string $capability The capability required for this menu to be displayed to the user.
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
* @param callback $function The function to be called to output the content for this page.
* @param string $icon_url The url to the icon to be used for this menu
* @param int $position The position in the menu order this one should appear
*
* @return string The resulting page's hook_suffix
*/
function add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '', $position = null ) {
global $menu, $admin_page_hooks, $_registered_pages, $_parent_pages;
$menu_slug = plugin_basename( $menu_slug );
$admin_page_hooks[$menu_slug] = sanitize_title( $menu_title );
$hookname = get_plugin_page_hookname( $menu_slug, '' );
if ( !empty( $function ) && !empty( $hookname ) && current_user_can( $capability ) )
add_action( $hookname, $function );
if ( empty($icon_url) )
$icon_url = esc_url( admin_url( 'images/generic.png' ) );
elseif ( is_ssl() && 0 === strpos($icon_url, 'http://') )
$icon_url = 'https://' . substr($icon_url, 7);
$new_menu = array( $menu_title, $capability, $menu_slug, $page_title, 'menu-top ' . $hookname, $hookname, $icon_url );
if ( null === $position )
$menu[] = $new_menu;
else
$menu[$position] = $new_menu;
$_registered_pages[$hookname] = true;
// No parent as top level
$_parent_pages[$menu_slug] = false;
return $hookname;
}
/**
* Add a top level menu page in the 'objects' section
*
* This function takes a capability which will be used to determine whether
* or not a page is included in the menu.
*
* The function which is hooked in to handle the output of the page must check
* that the user has the required capability as well.
*
* @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
* @param string $menu_title The text to be used for the menu
* @param string $capability The capability required for this menu to be displayed to the user.
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
* @param callback $function The function to be called to output the content for this page.
* @param string $icon_url The url to the icon to be used for this menu
*
* @return string The resulting page's hook_suffix
*/
function add_object_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '') {
global $_wp_last_object_menu;
$_wp_last_object_menu++;
return add_menu_page($page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $_wp_last_object_menu);
}
/**
* Add a top level menu page in the 'utility' section
*
* This function takes a capability which will be used to determine whether
* or not a page is included in the menu.
*
* The function which is hooked in to handle the output of the page must check
* that the user has the required capability as well.
*
* @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
* @param string $menu_title The text to be used for the menu
* @param string $capability The capability required for this menu to be displayed to the user.
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
* @param callback $function The function to be called to output the content for this page.
* @param string $icon_url The url to the icon to be used for this menu
*
* @return string The resulting page's hook_suffix
*/
function add_utility_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '') {
global $_wp_last_utility_menu;
$_wp_last_utility_menu++;
return add_menu_page($page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $_wp_last_utility_menu);
}
/**
* Add a sub menu page
*
* This function takes a capability which will be used to determine whether
* or not a page is included in the menu.
*
* The function which is hooked in to handle the output of the page must check
* that the user has the required capability as well.
*
* @param string $parent_slug The slug name for the parent menu (or the file name of a standard WordPress admin page)
* @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
* @param string $menu_title The text to be used for the menu
* @param string $capability The capability required for this menu to be displayed to the user.
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
* @param callback $function The function to be called to output the content for this page.
*
* @return string|bool The resulting page's hook_suffix, or false if the user does not have the capability required.
*/
function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
global $submenu;
global $menu;
global $_wp_real_parent_file;
global $_wp_submenu_nopriv;
global $_registered_pages;
global $_parent_pages;
$menu_slug = plugin_basename( $menu_slug );
$parent_slug = plugin_basename( $parent_slug);
if ( isset( $_wp_real_parent_file[$parent_slug] ) )
$parent_slug = $_wp_real_parent_file[$parent_slug];
if ( !current_user_can( $capability ) ) {
$_wp_submenu_nopriv[$parent_slug][$menu_slug] = true;
return false;
}
// If the parent doesn't already have a submenu, add a link to the parent
// as the first item in the submenu. If the submenu file is the same as the
// parent file someone is trying to link back to the parent manually. In
// this case, don't automatically add a link back to avoid duplication.
if (!isset( $submenu[$parent_slug] ) && $menu_slug != $parent_slug ) {
foreach ( (array)$menu as $parent_menu ) {
if ( $parent_menu[2] == $parent_slug && current_user_can( $parent_menu[1] ) )
$submenu[$parent_slug][] = $parent_menu;
}
}
$submenu[$parent_slug][] = array ( $menu_title, $capability, $menu_slug, $page_title );
$hookname = get_plugin_page_hookname( $menu_slug, $parent_slug);
if (!empty ( $function ) && !empty ( $hookname ))
add_action( $hookname, $function );
$_registered_pages[$hookname] = true;
// backwards-compatibility for plugins using add_management page. See wp-admin/admin.php for redirect from edit.php to tools.php
if ( 'tools.php' == $parent_slug )
$_registered_pages[get_plugin_page_hookname( $menu_slug, 'edit.php')] = true;
// No parent as top level
$_parent_pages[$menu_slug] = $parent_slug;
return $hookname;
}
/**
* Add sub menu page to the tools main menu.
*
* This function takes a capability which will be used to determine whether
* or not a page is included in the menu.
*
* The function which is hooked in to handle the output of the page must check
* that the user has the required capability as well.
*
* @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
* @param string $menu_title The text to be used for the menu
* @param string $capability The capability required for this menu to be displayed to the user.
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
* @param callback $function The function to be called to output the content for this page.
*
* @return string|bool The resulting page's hook_suffix, or false if the user does not have the capability required.
*/
function add_management_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
return add_submenu_page( 'tools.php', $page_title, $menu_title, $capability, $menu_slug, $function );
}
/**
* Add sub menu page to the options main menu.
*
* This function takes a capability which will be used to determine whether
* or not a page is included in the menu.
*
* The function which is hooked in to handle the output of the page must check
* that the user has the required capability as well.
*
* @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
* @param string $menu_title The text to be used for the menu
* @param string $capability The capability required for this menu to be displayed to the user.
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
* @param callback $function The function to be called to output the content for this page.
*
* @return string|bool The resulting page's hook_suffix, or false if the user does not have the capability required.
*/
function add_options_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
return add_submenu_page( 'options-general.php', $page_title, $menu_title, $capability, $menu_slug, $function );
}
/**
* Add sub menu page to the themes main menu.
*
* This function takes a capability which will be used to determine whether
* or not a page is included in the menu.
*
* The function which is hooked in to handle the output of the page must check
* that the user has the required capability as well.
*
* @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
* @param string $menu_title The text to be used for the menu
* @param string $capability The capability required for this menu to be displayed to the user.
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
* @param callback $function The function to be called to output the content for this page.
*
* @return string|bool The resulting page's hook_suffix, or false if the user does not have the capability required.
*/
function add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
return add_submenu_page( 'themes.php', $page_title, $menu_title, $capability, $menu_slug, $function );
}
/**
* Add sub menu page to the plugins main menu.
*
* This function takes a capability which will be used to determine whether
* or not a page is included in the menu.
*
* The function which is hooked in to handle the output of the page must check
* that the user has the required capability as well.
*
* @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
* @param string $menu_title The text to be used for the menu
* @param string $capability The capability required for this menu to be displayed to the user.
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
* @param callback $function The function to be called to output the content for this page.
*
* @return string|bool The resulting page's hook_suffix, or false if the user does not have the capability required.
*/
function add_plugins_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
return add_submenu_page( 'plugins.php', $page_title, $menu_title, $capability, $menu_slug, $function );
}
/**
* Add sub menu page to the Users/Profile main menu.
*
* This function takes a capability which will be used to determine whether
* or not a page is included in the menu.
*
* The function which is hooked in to handle the output of the page must check
* that the user has the required capability as well.
*
* @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
* @param string $menu_title The text to be used for the menu
* @param string $capability The capability required for this menu to be displayed to the user.
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
* @param callback $function The function to be called to output the content for this page.
*
* @return string|bool The resulting page's hook_suffix, or false if the user does not have the capability required.
*/
function add_users_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
if ( current_user_can('edit_users') )
$parent = 'users.php';
else
$parent = 'profile.php';
return add_submenu_page( $parent, $page_title, $menu_title, $capability, $menu_slug, $function );
}
/**
* Add sub menu page to the Dashboard main menu.
*
* This function takes a capability which will be used to determine whether
* or not a page is included in the menu.
*
* The function which is hooked in to handle the output of the page must check
* that the user has the required capability as well.
*
* @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
* @param string $menu_title The text to be used for the menu
* @param string $capability The capability required for this menu to be displayed to the user.
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
* @param callback $function The function to be called to output the content for this page.
*
* @return string|bool The resulting page's hook_suffix, or false if the user does not have the capability required.
*/
function add_dashboard_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
return add_submenu_page( 'index.php', $page_title, $menu_title, $capability, $menu_slug, $function );
}
/**
* Add sub menu page to the posts main menu.
*
* This function takes a capability which will be used to determine whether
* or not a page is included in the menu.
*
* The function which is hooked in to handle the output of the page must check
* that the user has the required capability as well.
*
* @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
* @param string $menu_title The text to be used for the menu
* @param string $capability The capability required for this menu to be displayed to the user.
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
* @param callback $function The function to be called to output the content for this page.
*
* @return string|bool The resulting page's hook_suffix, or false if the user does not have the capability required.
*/
function add_posts_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
return add_submenu_page( 'edit.php', $page_title, $menu_title, $capability, $menu_slug, $function );
}
/**
* Add sub menu page to the media main menu.
*
* This function takes a capability which will be used to determine whether
* or not a page is included in the menu.
*
* The function which is hooked in to handle the output of the page must check
* that the user has the required capability as well.
*
* @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
* @param string $menu_title The text to be used for the menu
* @param string $capability The capability required for this menu to be displayed to the user.
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
* @param callback $function The function to be called to output the content for this page.
*
* @return string|bool The resulting page's hook_suffix, or false if the user does not have the capability required.
*/
function add_media_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
return add_submenu_page( 'upload.php', $page_title, $menu_title, $capability, $menu_slug, $function );
}
/**
* Add sub menu page to the links main menu.
*
* This function takes a capability which will be used to determine whether
* or not a page is included in the menu.
*
* The function which is hooked in to handle the output of the page must check
* that the user has the required capability as well.
*
* @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
* @param string $menu_title The text to be used for the menu
* @param string $capability The capability required for this menu to be displayed to the user.
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
* @param callback $function The function to be called to output the content for this page.
*
* @return string|bool The resulting page's hook_suffix, or false if the user does not have the capability required.
*/
function add_links_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
return add_submenu_page( 'link-manager.php', $page_title, $menu_title, $capability, $menu_slug, $function );
}
/**
* Add sub menu page to the pages main menu.
*
* This function takes a capability which will be used to determine whether
* or not a page is included in the menu.
*
* The function which is hooked in to handle the output of the page must check
* that the user has the required capability as well.
*
* @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
* @param string $menu_title The text to be used for the menu
* @param string $capability The capability required for this menu to be displayed to the user.
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
* @param callback $function The function to be called to output the content for this page.
*
* @return string|bool The resulting page's hook_suffix, or false if the user does not have the capability required.
*/
function add_pages_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
return add_submenu_page( 'edit.php?post_type=page', $page_title, $menu_title, $capability, $menu_slug, $function );
}
/**
* Add sub menu page to the comments main menu.
*
* This function takes a capability which will be used to determine whether
* or not a page is included in the menu.
*
* The function which is hooked in to handle the output of the page must check
* that the user has the required capability as well.
*
* @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
* @param string $menu_title The text to be used for the menu
* @param string $capability The capability required for this menu to be displayed to the user.
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
* @param callback $function The function to be called to output the content for this page.
*
* @return string|bool The resulting page's hook_suffix, or false if the user does not have the capability required.
*/
function add_comments_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) {
return add_submenu_page( 'edit-comments.php', $page_title, $menu_title, $capability, $menu_slug, $function );
}
/**
* Remove a top level admin menu
*
* @since 3.1.0
*
* @param string $menu_slug The slug of the menu
* @return array|bool The removed menu on success, False if not found
*/
function remove_menu_page( $menu_slug ) {
global $menu;
foreach ( $menu as $i => $item ) {
if ( $menu_slug == $item[2] ) {
unset( $menu[$i] );
return $item;
}
}
return false;
}
/**
* Remove an admin submenu
*
* @since 3.1.0
*
* @param string $menu_slug The slug for the parent menu
* @param string $submenu_slug The slug of the submenu
* @return array|bool The removed submenu on success, False if not found
*/
function remove_submenu_page( $menu_slug, $submenu_slug ) {
global $submenu;
if ( !isset( $submenu[$menu_slug] ) )
return false;
foreach ( $submenu[$menu_slug] as $i => $item ) {
if ( $submenu_slug == $item[2] ) {
unset( $submenu[$menu_slug][$i] );
return $item;
}
}
return false;
}
/**
* Get the url to access a particular menu page based on the slug it was registered with.
*
* If the slug hasn't been registered properly no url will be returned
*
* @since 3.0
*
* @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
* @param bool $echo Whether or not to echo the url - default is true
* @return string the url
*/
function menu_page_url($menu_slug, $echo = true) {
global $_parent_pages;
if ( isset( $_parent_pages[$menu_slug] ) ) {
$parent_slug = $_parent_pages[$menu_slug];
if ( $parent_slug && ! isset( $_parent_pages[$parent_slug] ) ) {
$url = admin_url( add_query_arg( 'page', $menu_slug, $parent_slug ) );
} else {
$url = admin_url( 'admin.php?page=' . $menu_slug );
}
} else {
$url = '';
}
$url = esc_url($url);
if ( $echo )
echo $url;
return $url;
}
//
// Pluggable Menu Support -- Private
//
function get_admin_page_parent( $parent = '' ) {
global $parent_file;
global $menu;
global $submenu;
global $pagenow;
global $typenow;
global $plugin_page;
global $_wp_real_parent_file;
global $_wp_menu_nopriv;
global $_wp_submenu_nopriv;
if ( !empty ( $parent ) && 'admin.php' != $parent ) {
if ( isset( $_wp_real_parent_file[$parent] ) )
$parent = $_wp_real_parent_file[$parent];
return $parent;
}
/*
if ( !empty ( $parent_file ) ) {
if ( isset( $_wp_real_parent_file[$parent_file] ) )
$parent_file = $_wp_real_parent_file[$parent_file];
return $parent_file;
}
*/
if ( $pagenow == 'admin.php' && isset( $plugin_page ) ) {
foreach ( (array)$menu as $parent_menu ) {
if ( $parent_menu[2] == $plugin_page ) {
$parent_file = $plugin_page;
if ( isset( $_wp_real_parent_file[$parent_file] ) )
$parent_file = $_wp_real_parent_file[$parent_file];
return $parent_file;
}
}
if ( isset( $_wp_menu_nopriv[$plugin_page] ) ) {
$parent_file = $plugin_page;
if ( isset( $_wp_real_parent_file[$parent_file] ) )
$parent_file = $_wp_real_parent_file[$parent_file];
return $parent_file;
}
}
if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$pagenow][$plugin_page] ) ) {
$parent_file = $pagenow;
if ( isset( $_wp_real_parent_file[$parent_file] ) )
$parent_file = $_wp_real_parent_file[$parent_file];
return $parent_file;
}
foreach (array_keys( (array)$submenu ) as $parent) {
foreach ( $submenu[$parent] as $submenu_array ) {
if ( isset( $_wp_real_parent_file[$parent] ) )
$parent = $_wp_real_parent_file[$parent];
if ( !empty($typenow) && ($submenu_array[2] == "$pagenow?post_type=$typenow") ) {
$parent_file = $parent;
return $parent;
} elseif ( $submenu_array[2] == $pagenow && empty($typenow) && ( empty($parent_file) || false === strpos($parent_file, '?') ) ) {
$parent_file = $parent;
return $parent;
} else
if ( isset( $plugin_page ) && ($plugin_page == $submenu_array[2] ) ) {
$parent_file = $parent;
return $parent;
}
}
}
if ( empty($parent_file) )
$parent_file = '';
return '';
}
function get_admin_page_title() {
global $title;
global $menu;
global $submenu;
global $pagenow;
global $plugin_page;
global $typenow;
if ( ! empty ( $title ) )
return $title;
$hook = get_plugin_page_hook( $plugin_page, $pagenow );
$parent = $parent1 = get_admin_page_parent();
if ( empty ( $parent) ) {
foreach ( (array)$menu as $menu_array ) {
if ( isset( $menu_array[3] ) ) {
if ( $menu_array[2] == $pagenow ) {
$title = $menu_array[3];
return $menu_array[3];
} else
if ( isset( $plugin_page ) && ($plugin_page == $menu_array[2] ) && ($hook == $menu_array[3] ) ) {
$title = $menu_array[3];
return $menu_array[3];
}
} else {
$title = $menu_array[0];
return $title;
}
}
} else {
foreach ( array_keys( $submenu ) as $parent ) {
foreach ( $submenu[$parent] as $submenu_array ) {
if ( isset( $plugin_page ) &&
( $plugin_page == $submenu_array[2] ) &&
(
( $parent == $pagenow ) ||
( $parent == $plugin_page ) ||
( $plugin_page == $hook ) ||
( $pagenow == 'admin.php' && $parent1 != $submenu_array[2] ) ||
( !empty($typenow) && $parent == $pagenow . '?post_type=' . $typenow)
)
) {
$title = $submenu_array[3];
return $submenu_array[3];
}
if ( $submenu_array[2] != $pagenow || isset( $_GET['page'] ) ) // not the current page
continue;
if ( isset( $submenu_array[3] ) ) {
$title = $submenu_array[3];
return $submenu_array[3];
} else {
$title = $submenu_array[0];
return $title;
}
}
}
if ( empty ( $title ) ) {
foreach ( $menu as $menu_array ) {
if ( isset( $plugin_page ) &&
( $plugin_page == $menu_array[2] ) &&
( $pagenow == 'admin.php' ) &&
( $parent1 == $menu_array[2] ) )
{
$title = $menu_array[3];
return $menu_array[3];
}
}
}
}
return $title;
}
function get_plugin_page_hook( $plugin_page, $parent_page ) {
$hook = get_plugin_page_hookname( $plugin_page, $parent_page );
if ( has_action($hook) )
return $hook;
else
return null;
}
function get_plugin_page_hookname( $plugin_page, $parent_page ) {
global $admin_page_hooks;
$parent = get_admin_page_parent( $parent_page );
$page_type = 'admin';
if ( empty ( $parent_page ) || 'admin.php' == $parent_page || isset( $admin_page_hooks[$plugin_page] ) ) {
if ( isset( $admin_page_hooks[$plugin_page] ) )
$page_type = 'toplevel';
else
if ( isset( $admin_page_hooks[$parent] ))
$page_type = $admin_page_hooks[$parent];
} else if ( isset( $admin_page_hooks[$parent] ) ) {
$page_type = $admin_page_hooks[$parent];
}
$plugin_name = preg_replace( '!\.php!', '', $plugin_page );
return $page_type . '_page_' . $plugin_name;
}
function user_can_access_admin_page() {
global $pagenow;
global $menu;
global $submenu;
global $_wp_menu_nopriv;
global $_wp_submenu_nopriv;
global $plugin_page;
global $_registered_pages;
$parent = get_admin_page_parent();
if ( !isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$parent][$pagenow] ) )
return false;
if ( isset( $plugin_page ) ) {
if ( isset( $_wp_submenu_nopriv[$parent][$plugin_page] ) )
return false;
$hookname = get_plugin_page_hookname($plugin_page, $parent);
if ( !isset($_registered_pages[$hookname]) )
return false;
}
if ( empty( $parent) ) {
if ( isset( $_wp_menu_nopriv[$pagenow] ) )
return false;
if ( isset( $_wp_submenu_nopriv[$pagenow][$pagenow] ) )
return false;
if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$pagenow][$plugin_page] ) )
return false;
if ( isset( $plugin_page ) && isset( $_wp_menu_nopriv[$plugin_page] ) )
return false;
foreach (array_keys( $_wp_submenu_nopriv ) as $key ) {
if ( isset( $_wp_submenu_nopriv[$key][$pagenow] ) )
return false;
if ( isset( $plugin_page ) && isset( $_wp_submenu_nopriv[$key][$plugin_page] ) )
return false;
}
return true;
}
if ( isset( $plugin_page ) && ( $plugin_page == $parent ) && isset( $_wp_menu_nopriv[$plugin_page] ) )
return false;
if ( isset( $submenu[$parent] ) ) {
foreach ( $submenu[$parent] as $submenu_array ) {
if ( isset( $plugin_page ) && ( $submenu_array[2] == $plugin_page ) ) {
if ( current_user_can( $submenu_array[1] ))
return true;
else
return false;
} else if ( $submenu_array[2] == $pagenow ) {
if ( current_user_can( $submenu_array[1] ))
return true;
else
return false;
}
}
}
foreach ( $menu as $menu_array ) {
if ( $menu_array[2] == $parent) {
if ( current_user_can( $menu_array[1] ))
return true;
else
return false;
}
}
return true;
}
/* Whitelist functions */
/**
* Register a setting and its sanitization callback
*
* @since 2.7.0
*
* @param string $option_group A settings group name. Should correspond to a whitelisted option key name.
* Default whitelisted option key names include "general," "discussion," and "reading," among others.
* @param string $option_name The name of an option to sanitize and save.
* @param unknown_type $sanitize_callback A callback function that sanitizes the option's value.
* @return unknown
*/
function register_setting( $option_group, $option_name, $sanitize_callback = '' ) {
global $new_whitelist_options;
if ( 'misc' == $option_group ) {
_deprecated_argument( __FUNCTION__, '3.0', __( 'The miscellaneous options group has been removed. Use another settings group.' ) );
$option_group = 'general';
}
$new_whitelist_options[ $option_group ][] = $option_name;
if ( $sanitize_callback != '' )
add_filter( "sanitize_option_{$option_name}", $sanitize_callback );
}
/**
* Unregister a setting
*
* @since 2.7.0
*
* @param unknown_type $option_group
* @param unknown_type $option_name
* @param unknown_type $sanitize_callback
* @return unknown
*/
function unregister_setting( $option_group, $option_name, $sanitize_callback = '' ) {
global $new_whitelist_options;
if ( 'misc' == $option_group ) {
_deprecated_argument( __FUNCTION__, '3.0', __( 'The miscellaneous options group has been removed. Use another settings group.' ) );
$option_group = 'general';
}
$pos = array_search( $option_name, (array) $new_whitelist_options );
if ( $pos !== false )
unset( $new_whitelist_options[ $option_group ][ $pos ] );
if ( $sanitize_callback != '' )
remove_filter( "sanitize_option_{$option_name}", $sanitize_callback );
}
/**
* {@internal Missing Short Description}}
*
* @since 2.7.0
*
* @param unknown_type $options
* @return unknown
*/
function option_update_filter( $options ) {
global $new_whitelist_options;
if ( is_array( $new_whitelist_options ) )
$options = add_option_whitelist( $new_whitelist_options, $options );
return $options;
}
add_filter( 'whitelist_options', 'option_update_filter' );
/**
* {@internal Missing Short Description}}
*
* @since 2.7.0
*
* @param unknown_type $new_options
* @param unknown_type $options
* @return unknown
*/
function add_option_whitelist( $new_options, $options = '' ) {
if ( $options == '' )
global $whitelist_options;
else
$whitelist_options = $options;
foreach ( $new_options as $page => $keys ) {
foreach ( $keys as $key ) {
if ( !isset($whitelist_options[ $page ]) || !is_array($whitelist_options[ $page ]) ) {
$whitelist_options[ $page ] = array();
$whitelist_options[ $page ][] = $key;
} else {
$pos = array_search( $key, $whitelist_options[ $page ] );
if ( $pos === false )
$whitelist_options[ $page ][] = $key;
}
}
}
return $whitelist_options;
}
/**
* {@internal Missing Short Description}}
*
* @since 2.7.0
*
* @param unknown_type $del_options
* @param unknown_type $options
* @return unknown
*/
function remove_option_whitelist( $del_options, $options = '' ) {
if ( $options == '' )
global $whitelist_options;
else
$whitelist_options = $options;
foreach ( $del_options as $page => $keys ) {
foreach ( $keys as $key ) {
if ( isset($whitelist_options[ $page ]) && is_array($whitelist_options[ $page ]) ) {
$pos = array_search( $key, $whitelist_options[ $page ] );
if ( $pos !== false )
unset( $whitelist_options[ $page ][ $pos ] );
}
}
}
return $whitelist_options;
}
/**
* Output nonce, action, and option_page fields for a settings page.
*
* @since 2.7.0
*
* @param string $option_group A settings group name. This should match the group name used in register_setting().
*/
function settings_fields($option_group) {
echo "<input type='hidden' name='option_page' value='" . esc_attr($option_group) . "' />";
echo '<input type="hidden" name="action" value="update" />';
wp_nonce_field("$option_group-options");
}
| 01happy-blog | trunk/myblog/wp-admin/includes/plugin.php | PHP | oos | 60,834 |
<?php
/**
* A File upgrader class for WordPress.
*
* This set of classes are designed to be used to upgrade/install a local set of files on the filesystem via the Filesystem Abstraction classes.
*
* @link http://trac.wordpress.org/ticket/7875 consolidate plugin/theme/core upgrade/install functions
*
* @package WordPress
* @subpackage Upgrader
* @since 2.8.0
*/
/**
* WordPress Upgrader class for Upgrading/Installing a local set of files via the Filesystem Abstraction classes from a Zip file.
*
* @TODO More Detailed docs, for methods as well.
*
* @package WordPress
* @subpackage Upgrader
* @since 2.8.0
*/
class WP_Upgrader {
var $strings = array();
var $skin = null;
var $result = array();
function __construct($skin = null) {
if ( null == $skin )
$this->skin = new WP_Upgrader_Skin();
else
$this->skin = $skin;
}
function init() {
$this->skin->set_upgrader($this);
$this->generic_strings();
}
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.');
/* translators: %s: directory name */
$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['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['maintenance_start'] = __('Enabling Maintenance mode…');
$this->strings['maintenance_end'] = __('Disabling Maintenance mode…');
}
function fs_connect( $directories = array() ) {
global $wp_filesystem;
if ( false === ($credentials = $this->skin->request_filesystem_credentials()) )
return false;
if ( ! WP_Filesystem($credentials) ) {
$error = true;
if ( is_object($wp_filesystem) && $wp_filesystem->errors->get_error_code() )
$error = $wp_filesystem->errors;
$this->skin->request_filesystem_credentials($error); //Failed to connect, Error and request again
return false;
}
if ( ! is_object($wp_filesystem) )
return new WP_Error('fs_unavailable', $this->strings['fs_unavailable'] );
if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() )
return new WP_Error('fs_error', $this->strings['fs_error'], $wp_filesystem->errors);
foreach ( (array)$directories as $dir ) {
switch ( $dir ) {
case ABSPATH:
if ( ! $wp_filesystem->abspath() )
return new WP_Error('fs_no_root_dir', $this->strings['fs_no_root_dir']);
break;
case WP_CONTENT_DIR:
if ( ! $wp_filesystem->wp_content_dir() )
return new WP_Error('fs_no_content_dir', $this->strings['fs_no_content_dir']);
break;
case WP_PLUGIN_DIR:
if ( ! $wp_filesystem->wp_plugins_dir() )
return new WP_Error('fs_no_plugins_dir', $this->strings['fs_no_plugins_dir']);
break;
case WP_CONTENT_DIR . '/themes':
if ( ! $wp_filesystem->find_folder(WP_CONTENT_DIR . '/themes') )
return new WP_Error('fs_no_themes_dir', $this->strings['fs_no_themes_dir']);
break;
default:
if ( ! $wp_filesystem->find_folder($dir) )
return new WP_Error('fs_no_folder', sprintf($this->strings['fs_no_folder'], $dir));
break;
}
}
return true;
} //end fs_connect();
function download_package($package) {
if ( ! preg_match('!^(http|https|ftp)://!i', $package) && file_exists($package) ) //Local file or remote?
return $package; //must be a local file..
if ( empty($package) )
return new WP_Error('no_package', $this->strings['no_package']);
$this->skin->feedback('downloading_package', $package);
$download_file = download_url($package);
if ( is_wp_error($download_file) )
return new WP_Error('download_failed', $this->strings['download_failed'], $download_file->get_error_message());
return $download_file;
}
function unpack_package($package, $delete_package = true) {
global $wp_filesystem;
$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);
}
//We need a working directory
$working_dir = $upgrade_folder . basename($package, '.zip');
// Clean up working directory
if ( $wp_filesystem->is_dir($working_dir) )
$wp_filesystem->delete($working_dir, true);
// Unzip package to working directory
$result = unzip_file($package, $working_dir); //TODO optimizations, Copy when Move/Rename would suffice?
// Once extracted, delete the package if required.
if ( $delete_package )
unlink($package);
if ( is_wp_error($result) ) {
$wp_filesystem->delete($working_dir, true);
if ( 'incompatible_archive' == $result->get_error_code() ) {
return new WP_Error( 'incompatible_archive', $this->strings['incompatible_archive'], $result->get_error_data() );
}
return $result;
}
return $working_dir;
}
function install_package($args = array()) {
global $wp_filesystem;
$defaults = array( 'source' => '', 'destination' => '', //Please always pass these
'clear_destination' => false, 'clear_working' => false,
'hook_extra' => array());
$args = wp_parse_args($args, $defaults);
extract($args);
@set_time_limit( 300 );
if ( empty($source) || empty($destination) )
return new WP_Error('bad_request', $this->strings['bad_request']);
$this->skin->feedback('installing_package');
$res = apply_filters('upgrader_pre_install', true, $hook_extra);
if ( is_wp_error($res) )
return $res;
//Retain the Original source and destinations
$remote_source = $source;
$local_destination = $destination;
$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.
if ( 1 == count($source_files) && $wp_filesystem->is_dir( trailingslashit($source) . $source_files[0] . '/') ) //Only one folder? Then we want its contents.
$source = trailingslashit($source) . trailingslashit($source_files[0]);
elseif ( count($source_files) == 0 )
return new WP_Error( 'incompatible_archive', $this->strings['incompatible_archive'], __( 'The plugin contains no files.' ) ); //There are no files?
else //Its only a single file, The upgrader will use the foldername of this file as the destination folder. foldername is based on zip filename.
$source = trailingslashit($source);
//Hook ability to change the source file location..
$source = apply_filters('upgrader_source_selection', $source, $remote_source, $this);
if ( is_wp_error($source) )
return $source;
//Has the source location changed? If so, we need a new source_files list.
if ( $source !== $remote_source )
$source_files = array_keys( $wp_filesystem->dirlist($source) );
//Protection against deleting files in any important base directories.
if ( in_array( $destination, array(ABSPATH, WP_CONTENT_DIR, WP_PLUGIN_DIR, WP_CONTENT_DIR . '/themes') ) ) {
$remote_destination = trailingslashit($remote_destination) . trailingslashit(basename($source));
$destination = trailingslashit($destination) . trailingslashit(basename($source));
}
if ( $clear_destination ) {
//We're going to clear the destination if there's something there
$this->skin->feedback('remove_old');
$removed = true;
if ( $wp_filesystem->exists($remote_destination) )
$removed = $wp_filesystem->delete($remote_destination, true);
$removed = apply_filters('upgrader_clear_destination', $removed, $local_destination, $remote_destination, $hook_extra);
if ( is_wp_error($removed) )
return $removed;
else if ( ! $removed )
return new WP_Error('remove_old_failed', $this->strings['remove_old_failed']);
} elseif ( $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 );
}
}
//Create destination if needed
if ( !$wp_filesystem->exists($remote_destination) )
if ( !$wp_filesystem->mkdir($remote_destination, FS_CHMOD_DIR) )
return new WP_Error('mkdir_failed', $this->strings['mkdir_failed'], $remote_destination);
// Copy new version of item into place.
$result = copy_dir($source, $remote_destination);
if ( is_wp_error($result) ) {
if ( $clear_working )
$wp_filesystem->delete($remote_source, true);
return $result;
}
//Clear the Working folder?
if ( $clear_working )
$wp_filesystem->delete($remote_source, true);
$destination_name = basename( str_replace($local_destination, '', $destination) );
if ( '.' == $destination_name )
$destination_name = '';
$this->result = compact('local_source', 'source', 'source_name', 'source_files', 'destination', 'destination_name', 'local_destination', 'remote_destination', 'clear_destination', 'delete_source_dir');
$res = apply_filters('upgrader_post_install', true, $hook_extra, $this->result);
if ( is_wp_error($res) ) {
$this->result = $res;
return $res;
}
//Bombard the calling function will all the info which we've just used.
return $this->result;
}
function run($options) {
$defaults = array( 'package' => '', //Please always pass this.
'destination' => '', //And this
'clear_destination' => false,
'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);
extract($options);
//Connect to the Filesystem first.
$res = $this->fs_connect( array(WP_CONTENT_DIR, $destination) );
if ( ! $res ) //Mainly for non-connected filesystem.
return false;
if ( is_wp_error($res) ) {
$this->skin->error($res);
return $res;
}
if ( !$is_multi ) // call $this->header separately if running multiple times
$this->skin->header();
$this->skin->before();
//Download the package (Note, This just returns the filename of the file if the package is a local file)
$download = $this->download_package( $package );
if ( is_wp_error($download) ) {
$this->skin->error($download);
$this->skin->after();
return $download;
}
$delete_package = ($download != $package); // Do not delete a "local" file
//Unzips the file into a temporary directory
$working_dir = $this->unpack_package( $download, $delete_package );
if ( is_wp_error($working_dir) ) {
$this->skin->error($working_dir);
$this->skin->after();
return $working_dir;
}
//With the given options, this installs it to the destination directory.
$result = $this->install_package( array(
'source' => $working_dir,
'destination' => $destination,
'clear_destination' => $clear_destination,
'clear_working' => $clear_working,
'hook_extra' => $hook_extra
) );
$this->skin->set_result($result);
if ( is_wp_error($result) ) {
$this->skin->error($result);
$this->skin->feedback('process_failed');
} else {
//Install Succeeded
$this->skin->feedback('process_success');
}
$this->skin->after();
if ( !$is_multi )
$this->skin->footer();
return $result;
}
function maintenance_mode($enable = false) {
global $wp_filesystem;
$file = $wp_filesystem->abspath() . '.maintenance';
if ( $enable ) {
$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);
} else if ( !$enable && $wp_filesystem->exists($file) ) {
$this->skin->feedback('maintenance_end');
$wp_filesystem->delete($file);
}
}
}
/**
* Plugin Upgrader class for WordPress Plugins, It is designed to upgrade/install plugins from a local zip, remote zip URL, or uploaded zip file.
*
* @TODO More Detailed docs, for methods as well.
*
* @package WordPress
* @subpackage Upgrader
* @since 2.8.0
*/
class Plugin_Upgrader extends WP_Upgrader {
var $result;
var $bulk = false;
var $show_before = '';
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['downloading_package'] = __('Downloading update from <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.');
}
function install_strings() {
$this->strings['no_package'] = __('Install package not available.');
$this->strings['downloading_package'] = __('Downloading install package from <span class="code">%s</span>…');
$this->strings['unpack_package'] = __('Unpacking the package…');
$this->strings['installing_package'] = __('Installing the plugin…');
$this->strings['process_failed'] = __('Plugin install failed.');
$this->strings['process_success'] = __('Plugin installed successfully.');
}
function install($package) {
$this->init();
$this->install_strings();
add_filter('upgrader_source_selection', array(&$this, 'check_package') );
$this->run(array(
'package' => $package,
'destination' => WP_PLUGIN_DIR,
'clear_destination' => false, //Do not overwrite files.
'clear_working' => true,
'hook_extra' => array()
));
remove_filter('upgrader_source_selection', array(&$this, 'check_package') );
if ( ! $this->result || is_wp_error($this->result) )
return $this->result;
// Force refresh of plugin update information
delete_site_transient('update_plugins');
wp_cache_delete( 'plugins', 'plugins' );
return true;
}
function upgrade($plugin) {
$this->init();
$this->upgrade_strings();
$current = get_site_transient( 'update_plugins' );
if ( !isset( $current->response[ $plugin ] ) ) {
$this->skin->before();
$this->skin->set_result(false);
$this->skin->error('up_to_date');
$this->skin->after();
return false;
}
// 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);
//'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.
$this->run(array(
'package' => $r->package,
'destination' => WP_PLUGIN_DIR,
'clear_destination' => true,
'clear_working' => true,
'hook_extra' => array(
'plugin' => $plugin
)
));
// Cleanup our hooks, in case something else does a upgrade on this connection.
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) )
return $this->result;
// Force refresh of plugin update information
delete_site_transient('update_plugins');
wp_cache_delete( 'plugins', 'plugins' );
}
function bulk_upgrade($plugins) {
$this->init();
$this->bulk = true;
$this->upgrade_strings();
$current = get_site_transient( 'update_plugins' );
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) );
if ( ! $res ) {
$this->skin->footer();
return false;
}
$this->skin->bulk_header();
// Only start maintenance mode if running in Multisite OR the plugin is in use
$maintenance = is_multisite(); // @TODO: This should only kick in for individual sites if at all possible.
foreach ( $plugins as $plugin )
$maintenance = $maintenance || (is_plugin_active($plugin) && isset($current->response[ $plugin ]) ); // Only activate Maintenance mode if a plugin is active AND has an update available
if ( $maintenance )
$this->maintenance_mode(true);
$results = array();
$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);
if ( !isset( $current->response[ $plugin ] ) ) {
$this->skin->set_result(false);
$this->skin->before();
$this->skin->error('up_to_date');
$this->skin->after();
$results[$plugin] = false;
continue;
}
// Get the URL to the zip file
$r = $current->response[ $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
)
));
$results[$plugin] = $this->result;
// Prevent credentials auth screen from displaying multiple times
if ( false === $result )
break;
} //end foreach $plugins
$this->maintenance_mode(false);
$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'));
// Force refresh of plugin update information
delete_site_transient('update_plugins');
wp_cache_delete( 'plugins', 'plugins' );
return $results;
}
function check_package($source) {
global $wp_filesystem;
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, lets not prevent installation.
return $source;
// Check the folder contains at least 1 valid plugin.
$plugins_found = false;
foreach ( glob( $working_directory . '*.php' ) as $file ) {
$info = get_plugin_data($file, false, false);
if ( !empty( $info['Name'] ) ) {
$plugins_found = true;
break;
}
}
if ( ! $plugins_found )
return new WP_Error( 'incompatible_archive', $this->strings['incompatible_archive'], __('No valid plugins were found.') );
return $source;
}
//return plugin info.
function plugin_info() {
if ( ! is_array($this->result) )
return false;
if ( empty($this->result['destination_name']) )
return false;
$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
return $this->result['destination_name'] . '/' . $pluginfiles[0];
}
//Hooked to pre_install
function deactivate_plugin_before_upgrade($return, $plugin) {
if ( is_wp_error($return) ) //Bypass.
return $return;
$plugin = isset($plugin['plugin']) ? $plugin['plugin'] : '';
if ( empty($plugin) )
return new WP_Error('bad_request', $this->strings['bad_request']);
if ( is_plugin_active($plugin) ) {
//Deactivate the plugin silently, Prevent deactivation hooks from running.
deactivate_plugins($plugin, true);
}
}
//Hooked to upgrade_clear_destination
function delete_old_plugin($removed, $local_destination, $remote_destination, $plugin) {
global $wp_filesystem;
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']);
$plugins_dir = $wp_filesystem->wp_plugins_dir();
$this_plugin_dir = trailingslashit( dirname($plugins_dir . $plugin) );
if ( ! $wp_filesystem->exists($this_plugin_dir) ) //If its 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 its 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']);
return true;
}
}
/**
* Theme Upgrader class for WordPress Themes, It is designed to upgrade/install themes from a local zip, remote zip URL, or uploaded zip file.
*
* @TODO More Detailed docs, for methods as well.
*
* @package WordPress
* @subpackage Upgrader
* @since 2.8.0
*/
class Theme_Upgrader extends WP_Upgrader {
var $result;
var $bulk = false;
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['downloading_package'] = __('Downloading update from <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.');
}
function install_strings() {
$this->strings['no_package'] = __('Install package not available.');
$this->strings['downloading_package'] = __('Downloading install package from <span class="code">%s</span>…');
$this->strings['unpack_package'] = __('Unpacking the package…');
$this->strings['installing_package'] = __('Installing the theme…');
$this->strings['process_failed'] = __('Theme install 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…');
/* translators: 1: theme name, 2: version */
$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.');
/* 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_not_found'] = __('<strong>The parent theme could not be found.</strong> You will need to install the parent theme, <strong>%s</strong>, before you can use this child theme.');
}
function check_parent_theme_filter($install_result, $hook_extra, $child_result) {
// Check to see if we need to install a parent theme
$theme_info = $this->theme_info();
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') );
// We already have the theme, fall through.
return $install_result;
}
// We don't have the parent theme, lets 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.
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 install
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_success_message = $this->strings['process_success'];
// Override them
$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);
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' => WP_CONTENT_DIR . '/themes',
'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') );
// Start cleaning up after the parents installation
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->strings['process_success'] = $child_success_message;
return $install_result;
}
function hide_activate_preview_actions($actions) {
unset($actions['activate'], $actions['preview']);
return $actions;
}
function install($package) {
$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);
$options = array(
'package' => $package,
'destination' => WP_CONTENT_DIR . '/themes',
'clear_destination' => false, //Do not overwrite files.
'clear_working' => true
);
$this->run($options);
remove_filter('upgrader_source_selection', array(&$this, 'check_package') );
remove_filter('upgrader_post_install', array(&$this, 'check_parent_theme_filter'), 10, 3);
if ( ! $this->result || is_wp_error($this->result) )
return $this->result;
// Force refresh of theme update information
delete_site_transient('update_themes');
search_theme_directories( true );
foreach ( wp_get_themes() as $theme )
$theme->cache_delete();
return true;
}
function upgrade($theme) {
$this->init();
$this->upgrade_strings();
// Is an update available?
$current = get_site_transient( 'update_themes' );
if ( !isset( $current->response[ $theme ] ) ) {
$this->skin->before();
$this->skin->set_result(false);
$this->skin->error('up_to_date');
$this->skin->after();
return false;
}
$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);
$options = array(
'package' => $r['package'],
'destination' => WP_CONTENT_DIR . '/themes',
'clear_destination' => true,
'clear_working' => true,
'hook_extra' => array(
'theme' => $theme
)
);
$this->run($options);
remove_filter('upgrader_pre_install', array(&$this, 'current_before'), 10, 2);
remove_filter('upgrader_post_install', array(&$this, 'current_after'), 10, 2);
remove_filter('upgrader_clear_destination', array(&$this, 'delete_old_theme'), 10, 4);
if ( ! $this->result || is_wp_error($this->result) )
return $this->result;
// Force refresh of theme update information
delete_site_transient('update_themes');
search_theme_directories( true );
foreach ( wp_get_themes() as $theme )
$theme->cache_delete();
return true;
}
function bulk_upgrade($themes) {
$this->init();
$this->bulk = true;
$this->upgrade_strings();
$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);
$this->skin->header();
// Connect to the Filesystem first.
$res = $this->fs_connect( array(WP_CONTENT_DIR) );
if ( ! $res ) {
$this->skin->footer();
return false;
}
$this->skin->bulk_header();
// Only start maintenance mode if running in Multisite OR the theme is in use
$maintenance = is_multisite(); // @TODO: This should only kick in for individual sites if at all possible.
foreach ( $themes as $theme )
$maintenance = $maintenance || $theme == get_stylesheet() || $theme == get_template();
if ( $maintenance )
$this->maintenance_mode(true);
$results = array();
$this->update_count = count($themes);
$this->update_current = 0;
foreach ( $themes as $theme ) {
$this->update_current++;
if ( !isset( $current->response[ $theme ] ) ) {
$this->skin->set_result(false);
$this->skin->before();
$this->skin->error('up_to_date');
$this->skin->after();
$results[$theme] = false;
continue;
}
$this->skin->theme_info = $this->theme_info($theme);
// Get the URL to the zip file
$r = $current->response[ $theme ];
$options = array(
'package' => $r['package'],
'destination' => WP_CONTENT_DIR . '/themes',
'clear_destination' => true,
'clear_working' => true,
'hook_extra' => array(
'theme' => $theme
)
);
$result = $this->run($options);
$results[$theme] = $this->result;
// Prevent credentials auth screen from displaying multiple times
if ( false === $result )
break;
} //end foreach $plugins
$this->maintenance_mode(false);
$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'), 10, 2);
remove_filter('upgrader_post_install', array(&$this, 'current_after'), 10, 2);
remove_filter('upgrader_clear_destination', array(&$this, 'delete_old_theme'), 10, 4);
// Force refresh of theme update information
delete_site_transient('update_themes');
search_theme_directories( true );
foreach ( wp_get_themes() as $theme )
$theme->cache_delete();
return $results;
}
function check_package($source) {
global $wp_filesystem;
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, lets 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', $this->strings['incompatible_archive'], __('The theme is missing the <code>style.css</code> stylesheet.') );
$info = get_file_data( $working_directory . 'style.css', array( 'Name' => 'Theme Name', 'Template' => 'Template' ) );
if ( empty( $info['Name'] ) )
return new WP_Error( 'incompatible_archive', $this->strings['incompatible_archive'], __("The <code>style.css</code> stylesheet doesn't contain a valid theme header.") );
// 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', $this->strings['incompatible_archive'], __('The theme is missing the <code>index.php</code> file.') );
return $source;
}
function current_before($return, $theme) {
if ( is_wp_error($return) )
return $return;
$theme = isset($theme['theme']) ? $theme['theme'] : '';
if ( $theme != get_stylesheet() ) //If not current
return $return;
//Change to maintenance mode now.
if ( ! $this->bulk )
$this->maintenance_mode(true);
return $return;
}
function current_after($return, $theme) {
if ( is_wp_error($return) )
return $return;
$theme = isset($theme['theme']) ? $theme['theme'] : '';
if ( $theme != get_stylesheet() ) // If not current
return $return;
// Ensure stylesheet name hasnt changed after the upgrade:
// @TODO: Note, This doesn't handle the Template changing, or the Template name changing.
if ( $theme == get_stylesheet() && $theme != $this->result['destination_name'] ) {
$theme_info = $this->theme_info();
$stylesheet = $this->result['destination_name'];
$template = $theme_info->get_template();
switch_theme($template, $stylesheet, true);
}
//Time to remove maintenance mode
if ( ! $this->bulk )
$this->maintenance_mode(false);
return $return;
}
function delete_old_theme($removed, $local_destination, $remote_destination, $theme) {
global $wp_filesystem;
$theme = isset($theme['theme']) ? $theme['theme'] : '';
if ( is_wp_error($removed) || empty($theme) )
return $removed; //Pass errors through.
$themes_dir = $wp_filesystem->wp_themes_dir();
if ( $wp_filesystem->exists( trailingslashit($themes_dir) . $theme ) )
if ( ! $wp_filesystem->delete( trailingslashit($themes_dir) . $theme, true ) )
return false;
return true;
}
function theme_info($theme = null) {
if ( empty($theme) ) {
if ( !empty($this->result['destination_name']) )
$theme = $this->result['destination_name'];
else
return false;
}
return wp_get_theme( $theme, WP_CONTENT_DIR . '/themes/' );
}
}
/**
* Core Upgrader class for WordPress. It allows for WordPress to upgrade itself in combination with the wp-admin/includes/update-core.php file
*
* @TODO More Detailed docs, for methods as well.
*
* @package WordPress
* @subpackage Upgrader
* @since 2.8.0
*/
class Core_Upgrader extends WP_Upgrader {
function upgrade_strings() {
$this->strings['up_to_date'] = __('WordPress is at the latest version.');
$this->strings['no_package'] = __('Update package not available.');
$this->strings['downloading_package'] = __('Downloading update from <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.' );
}
function upgrade($current) {
global $wp_filesystem, $wp_version;
$this->init();
$this->upgrade_strings();
if ( !empty($feedback) )
add_filter('update_feedback', $feedback);
// Is an update available?
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) );
if ( is_wp_error($res) )
return $res;
$wp_dir = trailingslashit($wp_filesystem->abspath());
// If partial update is returned from the API, use that, unless we're doing a reinstall.
// If we cross the new_bundled version number, then use 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 ( $current->packages->partial && 'reinstall' != $current->response && $wp_version == $current->partial_version )
$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 ) )
$to_download = 'new_bundled';
elseif ( $current->packages->no_content )
$to_download = 'no_content';
else
$to_download = 'full';
$download = $this->download_package( $current->packages->$to_download );
if ( is_wp_error($download) )
return $download;
$working_dir = $this->unpack_package( $download );
if ( is_wp_error($working_dir) )
return $working_dir;
// 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);
return new WP_Error('copy_failed', $this->strings['copy_failed']);
}
$wp_filesystem->chmod($wp_dir . 'wp-admin/includes/update-core.php', FS_CHMOD_FILE);
require(ABSPATH . 'wp-admin/includes/update-core.php');
if ( ! function_exists( 'update_core' ) )
return new WP_Error( 'copy_failed_space', $this->strings['copy_failed_space'] );
return update_core($working_dir, $wp_dir);
}
}
/**
* Generic Skin for the WordPress Upgrader classes. This skin is designed to be extended for specific purposes.
*
* @TODO More Detailed docs, for methods as well.
*
* @package WordPress
* @subpackage Upgrader
* @since 2.8.0
*/
class WP_Upgrader_Skin {
var $upgrader;
var $done_header = false;
var $result = false;
function __construct($args = array()) {
$defaults = array( 'url' => '', 'nonce' => '', 'title' => '', 'context' => false );
$this->options = wp_parse_args($args, $defaults);
}
function set_upgrader(&$upgrader) {
if ( is_object($upgrader) )
$this->upgrader =& $upgrader;
$this->add_strings();
}
function add_strings() {
}
function set_result($result) {
$this->result = $result;
}
function request_filesystem_credentials($error = false) {
$url = $this->options['url'];
$context = $this->options['context'];
if ( !empty($this->options['nonce']) )
$url = wp_nonce_url($url, $this->options['nonce']);
return request_filesystem_credentials($url, '', $error, $context); //Possible to bring inline, Leaving as is for now.
}
function header() {
if ( $this->done_header )
return;
$this->done_header = true;
echo '<div class="wrap">';
echo screen_icon();
echo '<h2>' . $this->options['title'] . '</h2>';
}
function footer() {
echo '</div>';
}
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() ) {
foreach ( $errors->get_error_messages() as $message ) {
if ( $errors->get_error_data() )
$this->feedback($message . ' ' . $errors->get_error_data() );
else
$this->feedback($message);
}
}
}
function feedback($string) {
if ( isset( $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) )
$string = vsprintf($string, $args);
}
if ( empty($string) )
return;
show_message($string);
}
function before() {}
function after() {}
}
/**
* Plugin Upgrader Skin for WordPress Plugin Upgrades.
*
* @TODO More Detailed docs, for methods as well.
*
* @package WordPress
* @subpackage Upgrader
* @since 2.8.0
*/
class Plugin_Upgrader_Skin extends WP_Upgrader_Skin {
var $plugin = '';
var $plugin_active = false;
var $plugin_network_active = false;
function __construct($args = array()) {
$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_network_active = is_plugin_active_for_network( $this->plugin );
parent::__construct($args);
}
function after() {
$this->plugin = $this->upgrader->plugin_info();
if ( !empty($this->plugin) && !is_wp_error($this->result) && $this->plugin_active ){
echo '<iframe style="border:0;overflow:hidden" width="100%" height="170px" src="' . wp_nonce_url('update.php?action=activate-plugin&networkwide=' . $this->plugin_network_active . '&plugin=' . $this->plugin, 'activate-plugin_' . $this->plugin) .'"></iframe>';
}
$update_actions = array(
'activate_plugin' => '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . $this->plugin, 'activate-plugin_' . $this->plugin) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin') . '</a>',
'plugins_page' => '<a href="' . self_admin_url('plugins.php') . '" title="' . esc_attr__('Go to plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>'
);
if ( $this->plugin_active )
unset( $update_actions['activate_plugin'] );
if ( ! $this->result || is_wp_error($this->result) )
unset( $update_actions['activate_plugin'] );
$update_actions = apply_filters('update_plugin_complete_actions', $update_actions, $this->plugin);
if ( ! empty($update_actions) )
$this->feedback(implode(' | ', (array)$update_actions));
}
function before() {
if ( $this->upgrader->show_before ) {
echo $this->upgrader->show_before;
$this->upgrader->show_before = '';
}
}
}
/**
* Plugin Upgrader Skin for WordPress Plugin Upgrades.
*
* @package WordPress
* @subpackage Upgrader
* @since 3.0.0
*/
class Bulk_Upgrader_Skin extends WP_Upgrader_Skin {
var $in_loop = false;
var $error = false;
function __construct($args = array()) {
$defaults = array( 'url' => '', 'nonce' => '' );
$args = wp_parse_args($args, $defaults);
parent::__construct($args);
}
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_update_failed_error'] = __('An error occurred while updating %1$s: <strong>%2$s</strong>.');
$this->upgrader->strings['skin_update_failed'] = __('The update of %1$s failed.');
$this->upgrader->strings['skin_update_successful'] = __('%1$s updated successfully.').' <a onclick="%2$s" href="#" class="hide-if-no-js"><span>'.__('Show Details').'</span><span class="hidden">'.__('Hide Details').'</span>.</a>';
$this->upgrader->strings['skin_upgrade_end'] = __('All updates have been completed.');
}
function feedback($string) {
if ( isset( $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) )
$string = vsprintf($string, $args);
}
if ( empty($string) )
return;
if ( $this->in_loop )
echo "$string<br />\n";
else
echo "<p>$string</p>\n";
}
function header() {
// Nothing, This will be displayed within a iframe.
}
function footer() {
// Nothing, This will be displayed within a iframe.
}
function error($error) {
if ( is_string($error) && isset( $this->upgrader->strings[$error] ) )
$this->error = $this->upgrader->strings[$error];
if ( is_wp_error($error) ) {
foreach ( $error->get_error_messages() as $emessage ) {
if ( $error->get_error_data() )
$messages[] = $emessage . ' ' . $error->get_error_data();
else
$messages[] = $emessage;
}
$this->error = implode(', ', $messages);
}
echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').hide();</script>';
}
function bulk_header() {
$this->feedback('skin_upgrade_start');
}
function bulk_footer() {
$this->feedback('skin_upgrade_end');
}
function before($title = '') {
$this->in_loop = true;
printf( '<h4>' . $this->upgrader->strings['skin_before_update_header'] . ' <img alt="" src="' . admin_url( 'images/wpspin_light.gif' ) . '" class="hidden waiting-' . $this->upgrader->update_current . '" style="vertical-align:middle;" /></h4>', $title, $this->upgrader->update_current, $this->upgrader->update_count);
echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').show();</script>';
echo '<div class="update-messages hide-if-js" id="progress-' . esc_attr($this->upgrader->update_current) . '"><p>';
$this->flush_output();
}
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, $this->error) . '</p></div>';
else
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>';
}
if ( !empty($this->result) && !is_wp_error($this->result) ) {
echo '<div class="updated"><p>' . sprintf($this->upgrader->strings['skin_update_successful'], $title, 'jQuery(\'#progress-' . esc_js($this->upgrader->update_current) . '\').toggle();jQuery(\'span\', this).toggle(); return false;') . '</p></div>';
echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js($this->upgrader->update_current) . '\').hide();</script>';
}
$this->reset();
$this->flush_output();
}
function reset() {
$this->in_loop = false;
$this->error = false;
}
function flush_output() {
wp_ob_end_flush_all();
flush();
}
}
class Bulk_Plugin_Upgrader_Skin extends Bulk_Upgrader_Skin {
var $plugin_info = array(); // Plugin_Upgrader::bulk() will fill this in.
function __construct($args = array()) {
parent::__construct($args);
}
function add_strings() {
parent::add_strings();
$this->upgrader->strings['skin_before_update_header'] = __('Updating Plugin %1$s (%2$d/%3$d)');
}
function before() {
parent::before($this->plugin_info['Title']);
}
function after() {
parent::after($this->plugin_info['Title']);
}
function bulk_footer() {
parent::bulk_footer();
$update_actions = array(
'plugins_page' => '<a href="' . self_admin_url('plugins.php') . '" title="' . esc_attr__('Go to plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>',
'updates_page' => '<a href="' . self_admin_url('update-core.php') . '" title="' . esc_attr__('Go to WordPress Updates page') . '" target="_parent">' . __('Return to WordPress Updates') . '</a>'
);
$update_actions = apply_filters('update_bulk_plugins_complete_actions', $update_actions, $this->plugin_info);
if ( ! empty($update_actions) )
$this->feedback(implode(' | ', (array)$update_actions));
}
}
class Bulk_Theme_Upgrader_Skin extends Bulk_Upgrader_Skin {
var $theme_info = array(); // Theme_Upgrader::bulk() will fill this in.
function __construct($args = array()) {
parent::__construct($args);
}
function add_strings() {
parent::add_strings();
$this->upgrader->strings['skin_before_update_header'] = __('Updating Theme %1$s (%2$d/%3$d)');
}
function before() {
parent::before( $this->theme_info->display('Name') );
}
function after() {
parent::after( $this->theme_info->display('Name') );
}
function bulk_footer() {
parent::bulk_footer();
$update_actions = array(
'themes_page' => '<a href="' . self_admin_url('themes.php') . '" title="' . esc_attr__('Go to themes page') . '" target="_parent">' . __('Return to Themes page') . '</a>',
'updates_page' => '<a href="' . self_admin_url('update-core.php') . '" title="' . esc_attr__('Go to WordPress Updates page') . '" target="_parent">' . __('Return to WordPress Updates') . '</a>'
);
$update_actions = apply_filters('update_bulk_theme_complete_actions', $update_actions, $this->theme_info );
if ( ! empty($update_actions) )
$this->feedback(implode(' | ', (array)$update_actions));
}
}
/**
* Plugin Installer Skin for WordPress Plugin Installer.
*
* @TODO More Detailed docs, for methods as well.
*
* @package WordPress
* @subpackage Upgrader
* @since 2.8.0
*/
class Plugin_Installer_Skin extends WP_Upgrader_Skin {
var $api;
var $type;
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();
parent::__construct($args);
}
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);
}
function after() {
$plugin_file = $this->upgrader->plugin_info();
$install_actions = array();
$from = isset($_GET['from']) ? stripslashes($_GET['from']) : 'plugins';
if ( 'import' == $from )
$install_actions['activate_plugin'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&from=import&plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin & Run Importer') . '</a>';
else
$install_actions['activate_plugin'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin') . '</a>';
if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) {
$install_actions['network_activate'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&networkwide=1&plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin for all sites in this network') . '" target="_parent">' . __('Network Activate') . '</a>';
unset( $install_actions['activate_plugin'] );
}
if ( 'import' == $from )
$install_actions['importers_page'] = '<a href="' . admin_url('import.php') . '" title="' . esc_attr__('Return to Importers') . '" target="_parent">' . __('Return to Importers') . '</a>';
else if ( $this->type == 'web' )
$install_actions['plugins_page'] = '<a href="' . self_admin_url('plugin-install.php') . '" title="' . esc_attr__('Return to Plugin Installer') . '" target="_parent">' . __('Return to Plugin Installer') . '</a>';
else
$install_actions['plugins_page'] = '<a href="' . self_admin_url('plugins.php') . '" title="' . esc_attr__('Return to Plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>';
if ( ! $this->result || is_wp_error($this->result) ) {
unset( $install_actions['activate_plugin'] );
unset( $install_actions['network_activate'] );
}
$install_actions = apply_filters('install_plugin_complete_actions', $install_actions, $this->api, $plugin_file);
if ( ! empty($install_actions) )
$this->feedback(implode(' | ', (array)$install_actions));
}
}
/**
* Theme Installer Skin for the WordPress Theme Installer.
*
* @TODO More Detailed docs, for methods as well.
*
* @package WordPress
* @subpackage Upgrader
* @since 2.8.0
*/
class Theme_Installer_Skin extends WP_Upgrader_Skin {
var $api;
var $type;
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();
parent::__construct($args);
}
function before() {
if ( !empty($this->api) )
$this->upgrader->strings['process_success'] = sprintf( $this->upgrader->strings['process_success_specific'], $this->api->name, $this->api->version);
}
function after() {
if ( empty($this->upgrader->result['destination_name']) )
return;
$theme_info = $this->upgrader->theme_info();
if ( empty( $theme_info ) )
return;
$name = $theme_info->display('Name');
$stylesheet = $this->upgrader->result['destination_name'];
$template = $theme_info->get_template();
$preview_link = add_query_arg( array(
'preview' => 1,
'template' => $template,
'stylesheet' => $stylesheet,
), trailingslashit( get_home_url() ) );
$activate_link = add_query_arg( array(
'action' => 'activate',
'template' => $template,
'stylesheet' => $stylesheet,
), admin_url('themes.php') );
$activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet );
$install_actions = array();
$install_actions['preview'] = '<a href="' . esc_url( $preview_link ) . '" class="hide-if-customize" title="' . esc_attr( sprintf( __('Preview “%s”'), $name ) ) . '">' . __('Preview') . '</a>';
$install_actions['preview'] .= '<a href="' . wp_customize_url( $stylesheet ) . '" class="hide-if-no-customize load-customize" title="' . esc_attr( sprintf( __('Preview “%s”'), $name ) ) . '">' . __('Live Preview') . '</a>';
$install_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink" title="' . esc_attr( sprintf( __('Activate “%s”'), $name ) ) . '">' . __('Activate') . '</a>';
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=' . $stylesheet, 'enable-theme_' . $stylesheet ) ) . '" title="' . esc_attr__( 'Enable this theme for all sites in this network' ) . '" target="_parent">' . __( 'Network Enable' ) . '</a>';
if ( $this->type == 'web' )
$install_actions['themes_page'] = '<a href="' . self_admin_url('theme-install.php') . '" title="' . esc_attr__('Return to Theme Installer') . '" target="_parent">' . __('Return to Theme Installer') . '</a>';
else
$install_actions['themes_page'] = '<a href="' . self_admin_url('themes.php') . '" title="' . esc_attr__('Themes page') . '" target="_parent">' . __('Return to Themes page') . '</a>';
if ( ! $this->result || is_wp_error($this->result) || is_network_admin() )
unset( $install_actions['activate'], $install_actions['preview'] );
$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));
}
}
/**
* Theme Upgrader Skin for WordPress Theme Upgrades.
*
* @TODO More Detailed docs, for methods as well.
*
* @package WordPress
* @subpackage Upgrader
* @since 2.8.0
*/
class Theme_Upgrader_Skin extends WP_Upgrader_Skin {
var $theme = '';
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);
}
function after() {
$update_actions = array();
if ( ! empty( $this->upgrader->result['destination_name'] ) && $theme_info = $this->upgrader->theme_info() ) {
$name = $theme_info->display('Name');
$stylesheet = $this->upgrader->result['destination_name'];
$template = $theme_info->get_template();
$preview_link = add_query_arg( array(
'preview' => 1,
'template' => $template,
'stylesheet' => $stylesheet,
), trailingslashit( get_home_url() ) );
$activate_link = add_query_arg( array(
'action' => 'activate',
'template' => $template,
'stylesheet' => $stylesheet,
), admin_url('themes.php') );
$activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet );
if ( get_stylesheet() == $stylesheet ) {
$update_actions['preview'] = '<a href="' . wp_customize_url( $stylesheet ) . '" class="hide-if-no-customize load-customize" title="' . esc_attr( sprintf( __('Customize “%s”'), $name ) ) . '">' . __('Customize') . '</a>';
} else {
$update_actions['preview'] = '<a href="' . esc_url( $preview_link ) . '" class="hide-if-customize" title="' . esc_attr( sprintf( __('Preview “%s”'), $name ) ) . '">' . __('Preview') . '</a>';
$update_actions['preview'] .= '<a href="' . wp_customize_url( $stylesheet ) . '" class="hide-if-no-customize load-customize" title="' . esc_attr( sprintf( __('Preview “%s”'), $name ) ) . '">' . __('Live Preview') . '</a>';
$update_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink" title="' . esc_attr( sprintf( __('Activate “%s”'), $name ) ) . '">' . __('Activate') . '</a>';
}
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') . '" title="' . esc_attr__('Return to Themes page') . '" target="_parent">' . __('Return to Themes page') . '</a>';
$update_actions = apply_filters('update_theme_complete_actions', $update_actions, $this->theme);
if ( ! empty($update_actions) )
$this->feedback(implode(' | ', (array)$update_actions));
}
}
/**
* Upgrade Skin helper for File uploads. This class handles the upload process and passes it as if its a local file to the Upgrade/Installer functions.
*
* @TODO More Detailed docs, for methods as well.
*
* @package WordPress
* @subpackage Upgrader
* @since 2.8.0
*/
class File_Upload_Upgrader {
var $package;
var $filename;
var $id = 0;
function __construct($form, $urlholder) {
if ( empty($_FILES[$form]['name']) && empty($_GET[$urlholder]) )
wp_die(__('Please select a file'));
//Handle a newly uploaded file, Else assume its already been uploaded
if ( ! empty($_FILES) ) {
$overrides = array( 'test_form' => false, 'test_type' => false );
$file = wp_handle_upload( $_FILES[$form], $overrides );
if ( isset( $file['error'] ) )
wp_die( $file['error'] );
$this->filename = $_FILES[$form]['name'];
$this->package = $file['file'];
// Construct the object array
$object = array(
'post_title' => $this->filename,
'post_content' => $file['url'],
'post_mime_type' => $file['type'],
'guid' => $file['url'],
'context' => 'upgrader',
'post_status' => 'private'
);
// Save the data
$this->id = wp_insert_attachment( $object, $file['file'] );
// schedule a cleanup for 2 hours from now in case of failed install
wp_schedule_single_event( time() + 7200, 'upgrader_scheduled_cleanup', array( $this->id ) );
} elseif ( is_numeric( $_GET[$urlholder] ) ) {
// Numeric Package = previously uploaded file, see above.
$this->id = (int) $_GET[$urlholder];
$attachment = get_post( $this->id );
if ( empty($attachment) )
wp_die(__('Please select a file'));
$this->filename = $attachment->post_title;
$this->package = get_attached_file( $attachment->ID );
} else {
// Else, It's set to something, Back compat for plugins using the old (pre-3.3) File_Uploader handler.
if ( ! ( ( $uploads = wp_upload_dir() ) && false === $uploads['error'] ) )
wp_die( $uploads['error'] );
$this->filename = $_GET[$urlholder];
$this->package = $uploads['basedir'] . '/' . $this->filename;
}
}
function cleanup() {
if ( $this->id )
wp_delete_attachment( $this->id );
elseif ( file_exists( $this->package ) )
return @unlink( $this->package );
return true;
}
} | 01happy-blog | trunk/myblog/wp-admin/includes/class-wp-upgrader.php | PHP | oos | 60,668 |
<?php
/**
* WordPress Upgrade API
*
* Most of the functions are pluggable and can be overwritten
*
* @package WordPress
* @subpackage Administration
*/
/** Include user install customize script. */
if ( file_exists(WP_CONTENT_DIR . '/install.php') )
require (WP_CONTENT_DIR . '/install.php');
/** WordPress Administration API */
require_once(ABSPATH . 'wp-admin/includes/admin.php');
/** WordPress Schema API */
require_once(ABSPATH . 'wp-admin/includes/schema.php');
if ( !function_exists('wp_install') ) :
/**
* Installs the blog
*
* {@internal Missing Long Description}}
*
* @since 2.1.0
*
* @param string $blog_title Blog title.
* @param string $user_name User's username.
* @param string $user_email User's email.
* @param bool $public Whether blog is public.
* @param null $deprecated Optional. Not used.
* @param string $user_password Optional. User's chosen password. Will default to a random password.
* @return array Array keys 'url', 'user_id', 'password', 'password_message'.
*/
function wp_install( $blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '' ) {
if ( !empty( $deprecated ) )
_deprecated_argument( __FUNCTION__, '2.6' );
wp_check_mysql_version();
wp_cache_flush();
make_db_current_silent();
if(!is_file(ABSPATH.'wp-admin/install.sql')){//[ysd]如果有install.sql不设置默认options数据
populate_options();
}else{
validate_active_plugins();//[ysd] 禁用 不可用的插件
}
populate_roles();
update_option('blogname', $blog_title);
update_option('admin_email', $user_email);
update_option('blog_public', $public);
//$guessurl = wp_guess_url();
$guessurl = 'http://'.substr($_SERVER['HTTP_APPNAME'],5).'.1kapp.com';//[ysd] 固定了guessurl
update_option('siteurl', $guessurl);
update_option('home', $guessurl);
get_option('siteurl');
// If not a public blog, don't ping.
if ( ! $public )
update_option('default_pingback_flag', 0);
// Create default user. If the user already exists, the user tables are
// being shared among blogs. Just set the role in that case.
$user_id = username_exists($user_name);
$user_password = trim($user_password);
$email_password = false;
if ( !$user_id && empty($user_password) ) {
$user_password = wp_generate_password( 12, false );
$message = __('<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.');
$user_id = wp_create_user($user_name, $user_password, $user_email);
update_user_option($user_id, 'default_password_nag', true, true);
$email_password = true;
} else if ( !$user_id ) {
// Password has been provided
$message = '<em>'.__('Your chosen password.').'</em>';
$user_id = wp_create_user($user_name, $user_password, $user_email);
} else {
$message = __('User already exists. Password inherited.');
}
$user = new WP_User($user_id);
$user->set_role('administrator');
wp_install_defaults($user_id);
flush_rewrite_rules();
wp_new_blog_notification($blog_title, $guessurl, $user_id, ($email_password ? $user_password : __('The password you chose during the install.') ) );
wp_cache_flush();
return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $user_password, 'password_message' => $message);
}
endif;
if ( !function_exists('wp_install_defaults') ) :
/**
* {@internal Missing Short Description}}
*
* {@internal Missing Long Description}}
*
* @since 2.1.0
*
* @param int $user_id User ID.
*/
function wp_install_defaults($user_id) {
global $wpdb, $wp_rewrite, $current_site, $table_prefix;
// Default category
$cat_name = __('Uncategorized');
/* translators: Default category slug */
$cat_slug = sanitize_title(_x('Uncategorized', 'Default category slug'));
if ( global_terms_enabled() ) {
$cat_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug ) );
if ( $cat_id == null ) {
$wpdb->insert( $wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true)) );
$cat_id = $wpdb->insert_id;
}
update_option('default_category', $cat_id);
} else {
$cat_id = 1;
}
$wpdb->insert( $wpdb->terms, array('term_id' => $cat_id, 'name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0) );
$wpdb->insert( $wpdb->term_taxonomy, array('term_id' => $cat_id, 'taxonomy' => 'category', 'description' => '', 'parent' => 0, 'count' => 1));
$cat_tt_id = $wpdb->insert_id;
// Default link category
$cat_name = __('Blogroll');
/* translators: Default link category slug */
$cat_slug = sanitize_title(_x('Blogroll', 'Default link category slug'));
if ( global_terms_enabled() ) {
$blogroll_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug ) );
if ( $blogroll_id == null ) {
$wpdb->insert( $wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true)) );
$blogroll_id = $wpdb->insert_id;
}
update_option('default_link_category', $blogroll_id);
} else {
$blogroll_id = 2;
}
$wpdb->insert( $wpdb->terms, array('term_id' => $blogroll_id, 'name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0) );
$wpdb->insert( $wpdb->term_taxonomy, array('term_id' => $blogroll_id, 'taxonomy' => 'link_category', 'description' => '', 'parent' => 0, 'count' => 7));
$blogroll_tt_id = $wpdb->insert_id;
// Now drop in some default links
$default_links = array();
$default_links[] = array( 'link_url' => __( 'http://codex.wordpress.org/' ),
'link_name' => __( 'Documentation' ),
'link_rss' => '',
'link_notes' => '');
$default_links[] = array( 'link_url' => __( 'http://wordpress.org/news/' ),
'link_name' => __( 'WordPress Blog' ),
'link_rss' => __( 'http://wordpress.org/news/feed/' ),
'link_notes' => '');
$default_links[] = array( 'link_url' => __( 'http://wordpress.org/support/' ),
'link_name' => _x( 'Support Forums', 'default link' ),
'link_rss' => '',
'link_notes' =>'');
$default_links[] = array( 'link_url' => 'http://wordpress.org/extend/plugins/',
'link_name' => _x( 'Plugins', 'Default link to wordpress.org/extend/plugins/' ),
'link_rss' => '',
'link_notes' =>'');
$default_links[] = array( 'link_url' => 'http://wordpress.org/extend/themes/',
'link_name' => _x( 'Themes', 'Default link to wordpress.org/extend/themes/' ),
'link_rss' => '',
'link_notes' =>'');
$default_links[] = array( 'link_url' => __( 'http://wordpress.org/support/forum/requests-and-feedback' ),
'link_name' => __( 'Feedback' ),
'link_rss' => '',
'link_notes' =>'');
$default_links[] = array( 'link_url' => __( 'http://planet.wordpress.org/' ),
'link_name' => __( 'WordPress Planet' ),
'link_rss' => '',
'link_notes' =>'');
foreach ( $default_links as $link ) {
$wpdb->insert( $wpdb->links, $link);
$wpdb->insert( $wpdb->term_relationships, array('term_taxonomy_id' => $blogroll_tt_id, 'object_id' => $wpdb->insert_id) );
}
// First post
$now = date('Y-m-d H:i:s');
$now_gmt = gmdate('Y-m-d H:i:s');
$first_post_guid = get_option('home') . '/?p=1';
if ( is_multisite() ) {
$first_post = get_site_option( 'first_post' );
if ( empty($first_post) )
$first_post = stripslashes( __( 'Welcome to <a href="SITE_URL">SITE_NAME</a>. This is your first post. Edit or delete it, then start blogging!' ) );
$first_post = str_replace( "SITE_URL", esc_url( network_home_url() ), $first_post );
$first_post = str_replace( "SITE_NAME", $current_site->site_name, $first_post );
} else {
$first_post = __('Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!');
}
$wpdb->insert( $wpdb->posts, array(
'post_author' => $user_id,
'post_date' => $now,
'post_date_gmt' => $now_gmt,
'post_content' => $first_post,
'post_excerpt' => '',
'post_title' => __('Hello world!'),
/* translators: Default post slug */
'post_name' => sanitize_title( _x('hello-world', 'Default post slug') ),
'post_modified' => $now,
'post_modified_gmt' => $now_gmt,
'guid' => $first_post_guid,
'comment_count' => 1,
'to_ping' => '',
'pinged' => '',
'post_content_filtered' => ''
));
$wpdb->insert( $wpdb->term_relationships, array('term_taxonomy_id' => $cat_tt_id, 'object_id' => 1) );
// Default comment
$first_comment_author = __('Mr WordPress');
$first_comment_url = 'http://wordpress.org/';
$first_comment = __('Hi, this is a comment.<br />To delete a comment, just log in and view the post's comments. There you will have the option to edit or delete them.');
if ( is_multisite() ) {
$first_comment_author = get_site_option( 'first_comment_author', $first_comment_author );
$first_comment_url = get_site_option( 'first_comment_url', network_home_url() );
$first_comment = get_site_option( 'first_comment', $first_comment );
}
$wpdb->insert( $wpdb->comments, array(
'comment_post_ID' => 1,
'comment_author' => $first_comment_author,
'comment_author_email' => '',
'comment_author_url' => $first_comment_url,
'comment_date' => $now,
'comment_date_gmt' => $now_gmt,
'comment_content' => $first_comment
));
// First Page
$first_page = sprintf( __( "This is an example page. It's different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this:
<blockquote>Hi there! I'm a bike messenger by day, aspiring actor by night, and this is my blog. I live in Los Angeles, have a great dog named Jack, and I like piña coladas. (And gettin' caught in the rain.)</blockquote>
...or something like this:
<blockquote>The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickies to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.</blockquote>
As a new WordPress user, you should go to <a href=\"%s\">your dashboard</a> to delete this page and create new pages for your content. Have fun!" ), admin_url() );
if ( is_multisite() )
$first_page = get_site_option( 'first_page', $first_page );
$first_post_guid = get_option('home') . '/?page_id=2';
$wpdb->insert( $wpdb->posts, array(
'post_author' => $user_id,
'post_date' => $now,
'post_date_gmt' => $now_gmt,
'post_content' => $first_page,
'post_excerpt' => '',
'post_title' => __( 'Sample Page' ),
/* translators: Default page slug */
'post_name' => __( 'sample-page' ),
'post_modified' => $now,
'post_modified_gmt' => $now_gmt,
'guid' => $first_post_guid,
'post_type' => 'page',
'to_ping' => '',
'pinged' => '',
'post_content_filtered' => ''
));
$wpdb->insert( $wpdb->postmeta, array( 'post_id' => 2, 'meta_key' => '_wp_page_template', 'meta_value' => 'default' ) );
// Set up default widgets for default theme.
update_option( 'widget_search', array ( 2 => array ( 'title' => '' ), '_multiwidget' => 1 ) );
update_option( 'widget_recent-posts', array ( 2 => array ( 'title' => '', 'number' => 5 ), '_multiwidget' => 1 ) );
update_option( 'widget_recent-comments', array ( 2 => array ( 'title' => '', 'number' => 5 ), '_multiwidget' => 1 ) );
update_option( 'widget_archives', array ( 2 => array ( 'title' => '', 'count' => 0, 'dropdown' => 0 ), '_multiwidget' => 1 ) );
update_option( 'widget_categories', array ( 2 => array ( 'title' => '', 'count' => 0, 'hierarchical' => 0, 'dropdown' => 0 ), '_multiwidget' => 1 ) );
update_option( 'widget_meta', array ( 2 => array ( 'title' => '' ), '_multiwidget' => 1 ) );
update_option( 'sidebars_widgets', array ( 'wp_inactive_widgets' => array ( ), 'sidebar-1' => array ( 0 => 'search-2', 1 => 'recent-posts-2', 2 => 'recent-comments-2', 3 => 'archives-2', 4 => 'categories-2', 5 => 'meta-2', ), 'sidebar-2' => array ( ), 'sidebar-3' => array ( ), 'sidebar-4' => array ( ), 'sidebar-5' => array ( ), 'array_version' => 3 ) );
if ( ! is_multisite() )
update_user_meta( $user_id, 'show_welcome_panel', 1 );
elseif ( ! is_super_admin( $user_id ) && ! metadata_exists( 'user', $user_id, 'show_welcome_panel' ) )
update_user_meta( $user_id, 'show_welcome_panel', 2 );
if ( is_multisite() ) {
// Flush rules to pick up the new page.
$wp_rewrite->init();
$wp_rewrite->flush_rules();
$user = new WP_User($user_id);
$wpdb->update( $wpdb->options, array('option_value' => $user->user_email), array('option_name' => 'admin_email') );
// Remove all perms except for the login user.
$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix.'user_level') );
$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix.'capabilities') );
// Delete any caps that snuck into the previously active blog. (Hardcoded to blog 1 for now.) TODO: Get previous_blog_id.
if ( !is_super_admin( $user_id ) && $user_id != 1 )
$wpdb->delete( $wpdb->usermeta, array( 'user_id' => $user_id , 'meta_key' => $wpdb->base_prefix.'1_capabilities' ) );
}
}
endif;
if ( !function_exists('wp_new_blog_notification') ) :
/**
* {@internal Missing Short Description}}
*
* {@internal Missing Long Description}}
*
* @since 2.1.0
*
* @param string $blog_title Blog title.
* @param string $blog_url Blog url.
* @param int $user_id User ID.
* @param string $password User's Password.
*/
function wp_new_blog_notification($blog_title, $blog_url, $user_id, $password) {
$user = new WP_User($user_id);
$email = $user->user_email;
$name = $user->user_login;
$message = sprintf(__("Your new WordPress site has been successfully set up at:
%1\$s
You can log in to the administrator account with the following information:
Username: %2\$s
Password: %3\$s
We hope you enjoy your new site. Thanks!
--The WordPress Team
http://wordpress.org/
"), $blog_url, $name, $password);
@wp_mail($email, __('New WordPress Site'), $message);
}
endif;
if ( !function_exists('wp_upgrade') ) :
/**
* Run WordPress Upgrade functions.
*
* {@internal Missing Long Description}}
*
* @since 2.1.0
*
* @return null
*/
function wp_upgrade() {
global $wp_current_db_version, $wp_db_version, $wpdb;
$wp_current_db_version = __get_option('db_version');
// We are up-to-date. Nothing to do.
if ( $wp_db_version == $wp_current_db_version )
return;
if ( ! is_blog_installed() )
return;
wp_check_mysql_version();
wp_cache_flush();
pre_schema_upgrade();
make_db_current_silent();
upgrade_all();
if ( is_multisite() && is_main_site() )
upgrade_network();
wp_cache_flush();
if ( is_multisite() ) {
if ( $wpdb->get_row( "SELECT blog_id FROM {$wpdb->blog_versions} WHERE blog_id = '{$wpdb->blogid}'" ) )
$wpdb->query( "UPDATE {$wpdb->blog_versions} SET db_version = '{$wp_db_version}' WHERE blog_id = '{$wpdb->blogid}'" );
else
$wpdb->query( "INSERT INTO {$wpdb->blog_versions} ( `blog_id` , `db_version` , `last_updated` ) VALUES ( '{$wpdb->blogid}', '{$wp_db_version}', NOW());" );
}
}
endif;
/**
* Functions to be called in install and upgrade scripts.
*
* {@internal Missing Long Description}}
*
* @since 1.0.1
*/
function upgrade_all() {
global $wp_current_db_version, $wp_db_version;
$wp_current_db_version = __get_option('db_version');
// We are up-to-date. Nothing to do.
if ( $wp_db_version == $wp_current_db_version )
return;
// If the version is not set in the DB, try to guess the version.
if ( empty($wp_current_db_version) ) {
$wp_current_db_version = 0;
// If the template option exists, we have 1.5.
$template = __get_option('template');
if ( !empty($template) )
$wp_current_db_version = 2541;
}
if ( $wp_current_db_version < 6039 )
upgrade_230_options_table();
populate_options();
if ( $wp_current_db_version < 2541 ) {
upgrade_100();
upgrade_101();
upgrade_110();
upgrade_130();
}
if ( $wp_current_db_version < 3308 )
upgrade_160();
if ( $wp_current_db_version < 4772 )
upgrade_210();
if ( $wp_current_db_version < 4351 )
upgrade_old_slugs();
if ( $wp_current_db_version < 5539 )
upgrade_230();
if ( $wp_current_db_version < 6124 )
upgrade_230_old_tables();
if ( $wp_current_db_version < 7499 )
upgrade_250();
if ( $wp_current_db_version < 7935 )
upgrade_252();
if ( $wp_current_db_version < 8201 )
upgrade_260();
if ( $wp_current_db_version < 8989 )
upgrade_270();
if ( $wp_current_db_version < 10360 )
upgrade_280();
if ( $wp_current_db_version < 11958 )
upgrade_290();
if ( $wp_current_db_version < 15260 )
upgrade_300();
if ( $wp_current_db_version < 19389 )
upgrade_330();
if ( $wp_current_db_version < 20080 )
upgrade_340();
maybe_disable_automattic_widgets();
update_option( 'db_version', $wp_db_version );
update_option( 'db_upgraded', true );
}
/**
* Execute changes made in WordPress 1.0.
*
* @since 1.0.0
*/
function upgrade_100() {
global $wpdb;
// Get the title and ID of every post, post_name to check if it already has a value
$posts = $wpdb->get_results("SELECT ID, post_title, post_name FROM $wpdb->posts WHERE post_name = ''");
if ($posts) {
foreach($posts as $post) {
if ('' == $post->post_name) {
$newtitle = sanitize_title($post->post_title);
$wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_name = %s WHERE ID = %d", $newtitle, $post->ID) );
}
}
}
$categories = $wpdb->get_results("SELECT cat_ID, cat_name, category_nicename FROM $wpdb->categories");
foreach ($categories as $category) {
if ('' == $category->category_nicename) {
$newtitle = sanitize_title($category->cat_name);
$wpdb>update( $wpdb->categories, array('category_nicename' => $newtitle), array('cat_ID' => $category->cat_ID) );
}
}
$wpdb->query("UPDATE $wpdb->options SET option_value = REPLACE(option_value, 'wp-links/links-images/', 'wp-images/links/')
WHERE option_name LIKE 'links_rating_image%'
AND option_value LIKE 'wp-links/links-images/%'");
$done_ids = $wpdb->get_results("SELECT DISTINCT post_id FROM $wpdb->post2cat");
if ($done_ids) :
foreach ($done_ids as $done_id) :
$done_posts[] = $done_id->post_id;
endforeach;
$catwhere = ' AND ID NOT IN (' . implode(',', $done_posts) . ')';
else:
$catwhere = '';
endif;
$allposts = $wpdb->get_results("SELECT ID, post_category FROM $wpdb->posts WHERE post_category != '0' $catwhere");
if ($allposts) :
foreach ($allposts as $post) {
// Check to see if it's already been imported
$cat = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->post2cat WHERE post_id = %d AND category_id = %d", $post->ID, $post->post_category) );
if (!$cat && 0 != $post->post_category) { // If there's no result
$wpdb->insert( $wpdb->post2cat, array('post_id' => $post->ID, 'category_id' => $post->post_category) );
}
}
endif;
}
/**
* Execute changes made in WordPress 1.0.1.
*
* @since 1.0.1
*/
function upgrade_101() {
global $wpdb;
// Clean up indices, add a few
add_clean_index($wpdb->posts, 'post_name');
add_clean_index($wpdb->posts, 'post_status');
add_clean_index($wpdb->categories, 'category_nicename');
add_clean_index($wpdb->comments, 'comment_approved');
add_clean_index($wpdb->comments, 'comment_post_ID');
add_clean_index($wpdb->links , 'link_category');
add_clean_index($wpdb->links , 'link_visible');
}
/**
* Execute changes made in WordPress 1.2.
*
* @since 1.2.0
*/
function upgrade_110() {
global $wpdb;
// Set user_nicename.
$users = $wpdb->get_results("SELECT ID, user_nickname, user_nicename FROM $wpdb->users");
foreach ($users as $user) {
if ('' == $user->user_nicename) {
$newname = sanitize_title($user->user_nickname);
$wpdb->update( $wpdb->users, array('user_nicename' => $newname), array('ID' => $user->ID) );
}
}
$users = $wpdb->get_results("SELECT ID, user_pass from $wpdb->users");
foreach ($users as $row) {
if (!preg_match('/^[A-Fa-f0-9]{32}$/', $row->user_pass)) {
$wpdb->update( $wpdb->users, array('user_pass' => md5($row->user_pass)), array('ID' => $row->ID) );
}
}
// Get the GMT offset, we'll use that later on
$all_options = get_alloptions_110();
$time_difference = $all_options->time_difference;
$server_time = time()+date('Z');
$weblogger_time = $server_time + $time_difference*3600;
$gmt_time = time();
$diff_gmt_server = ($gmt_time - $server_time) / 3600;
$diff_weblogger_server = ($weblogger_time - $server_time) / 3600;
$diff_gmt_weblogger = $diff_gmt_server - $diff_weblogger_server;
$gmt_offset = -$diff_gmt_weblogger;
// Add a gmt_offset option, with value $gmt_offset
add_option('gmt_offset', $gmt_offset);
// Check if we already set the GMT fields (if we did, then
// MAX(post_date_gmt) can't be '0000-00-00 00:00:00'
// <michel_v> I just slapped myself silly for not thinking about it earlier
$got_gmt_fields = ! ($wpdb->get_var("SELECT MAX(post_date_gmt) FROM $wpdb->posts") == '0000-00-00 00:00:00');
if (!$got_gmt_fields) {
// Add or subtract time to all dates, to get GMT dates
$add_hours = intval($diff_gmt_weblogger);
$add_minutes = intval(60 * ($diff_gmt_weblogger - $add_hours));
$wpdb->query("UPDATE $wpdb->posts SET post_date_gmt = DATE_ADD(post_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)");
$wpdb->query("UPDATE $wpdb->posts SET post_modified = post_date");
$wpdb->query("UPDATE $wpdb->posts SET post_modified_gmt = DATE_ADD(post_modified, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE) WHERE post_modified != '0000-00-00 00:00:00'");
$wpdb->query("UPDATE $wpdb->comments SET comment_date_gmt = DATE_ADD(comment_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)");
$wpdb->query("UPDATE $wpdb->users SET user_registered = DATE_ADD(user_registered, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)");
}
}
/**
* Execute changes made in WordPress 1.5.
*
* @since 1.5.0
*/
function upgrade_130() {
global $wpdb;
// Remove extraneous backslashes.
$posts = $wpdb->get_results("SELECT ID, post_title, post_content, post_excerpt, guid, post_date, post_name, post_status, post_author FROM $wpdb->posts");
if ($posts) {
foreach($posts as $post) {
$post_content = addslashes(deslash($post->post_content));
$post_title = addslashes(deslash($post->post_title));
$post_excerpt = addslashes(deslash($post->post_excerpt));
if ( empty($post->guid) )
$guid = get_permalink($post->ID);
else
$guid = $post->guid;
$wpdb->update( $wpdb->posts, compact('post_title', 'post_content', 'post_excerpt', 'guid'), array('ID' => $post->ID) );
}
}
// Remove extraneous backslashes.
$comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_content FROM $wpdb->comments");
if ($comments) {
foreach($comments as $comment) {
$comment_content = deslash($comment->comment_content);
$comment_author = deslash($comment->comment_author);
$wpdb->update($wpdb->comments, compact('comment_content', 'comment_author'), array('comment_ID' => $comment->comment_ID) );
}
}
// Remove extraneous backslashes.
$links = $wpdb->get_results("SELECT link_id, link_name, link_description FROM $wpdb->links");
if ($links) {
foreach($links as $link) {
$link_name = deslash($link->link_name);
$link_description = deslash($link->link_description);
$wpdb->update( $wpdb->links, compact('link_name', 'link_description'), array('link_id' => $link->link_id) );
}
}
$active_plugins = __get_option('active_plugins');
// If plugins are not stored in an array, they're stored in the old
// newline separated format. Convert to new format.
if ( !is_array( $active_plugins ) ) {
$active_plugins = explode("\n", trim($active_plugins));
update_option('active_plugins', $active_plugins);
}
// Obsolete tables
$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optionvalues');
$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiontypes');
$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiongroups');
$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiongroup_options');
// Update comments table to use comment_type
$wpdb->query("UPDATE $wpdb->comments SET comment_type='trackback', comment_content = REPLACE(comment_content, '<trackback />', '') WHERE comment_content LIKE '<trackback />%'");
$wpdb->query("UPDATE $wpdb->comments SET comment_type='pingback', comment_content = REPLACE(comment_content, '<pingback />', '') WHERE comment_content LIKE '<pingback />%'");
// Some versions have multiple duplicate option_name rows with the same values
$options = $wpdb->get_results("SELECT option_name, COUNT(option_name) AS dupes FROM `$wpdb->options` GROUP BY option_name");
foreach ( $options as $option ) {
if ( 1 != $option->dupes ) { // Could this be done in the query?
$limit = $option->dupes - 1;
$dupe_ids = $wpdb->get_col( $wpdb->prepare("SELECT option_id FROM $wpdb->options WHERE option_name = %s LIMIT %d", $option->option_name, $limit) );
if ( $dupe_ids ) {
$dupe_ids = join($dupe_ids, ',');
$wpdb->query("DELETE FROM $wpdb->options WHERE option_id IN ($dupe_ids)");
}
}
}
make_site_theme();
}
/**
* Execute changes made in WordPress 2.0.
*
* @since 2.0.0
*/
function upgrade_160() {
global $wpdb, $wp_current_db_version;
populate_roles_160();
$users = $wpdb->get_results("SELECT * FROM $wpdb->users");
foreach ( $users as $user ) :
if ( !empty( $user->user_firstname ) )
update_user_meta( $user->ID, 'first_name', $wpdb->escape($user->user_firstname) );
if ( !empty( $user->user_lastname ) )
update_user_meta( $user->ID, 'last_name', $wpdb->escape($user->user_lastname) );
if ( !empty( $user->user_nickname ) )
update_user_meta( $user->ID, 'nickname', $wpdb->escape($user->user_nickname) );
if ( !empty( $user->user_level ) )
update_user_meta( $user->ID, $wpdb->prefix . 'user_level', $user->user_level );
if ( !empty( $user->user_icq ) )
update_user_meta( $user->ID, 'icq', $wpdb->escape($user->user_icq) );
if ( !empty( $user->user_aim ) )
update_user_meta( $user->ID, 'aim', $wpdb->escape($user->user_aim) );
if ( !empty( $user->user_msn ) )
update_user_meta( $user->ID, 'msn', $wpdb->escape($user->user_msn) );
if ( !empty( $user->user_yim ) )
update_user_meta( $user->ID, 'yim', $wpdb->escape($user->user_icq) );
if ( !empty( $user->user_description ) )
update_user_meta( $user->ID, 'description', $wpdb->escape($user->user_description) );
if ( isset( $user->user_idmode ) ):
$idmode = $user->user_idmode;
if ($idmode == 'nickname') $id = $user->user_nickname;
if ($idmode == 'login') $id = $user->user_login;
if ($idmode == 'firstname') $id = $user->user_firstname;
if ($idmode == 'lastname') $id = $user->user_lastname;
if ($idmode == 'namefl') $id = $user->user_firstname.' '.$user->user_lastname;
if ($idmode == 'namelf') $id = $user->user_lastname.' '.$user->user_firstname;
if (!$idmode) $id = $user->user_nickname;
$wpdb->update( $wpdb->users, array('display_name' => $id), array('ID' => $user->ID) );
endif;
// FIXME: RESET_CAPS is temporary code to reset roles and caps if flag is set.
$caps = get_user_meta( $user->ID, $wpdb->prefix . 'capabilities');
if ( empty($caps) || defined('RESET_CAPS') ) {
$level = get_user_meta($user->ID, $wpdb->prefix . 'user_level', true);
$role = translate_level_to_role($level);
update_user_meta( $user->ID, $wpdb->prefix . 'capabilities', array($role => true) );
}
endforeach;
$old_user_fields = array( 'user_firstname', 'user_lastname', 'user_icq', 'user_aim', 'user_msn', 'user_yim', 'user_idmode', 'user_ip', 'user_domain', 'user_browser', 'user_description', 'user_nickname', 'user_level' );
$wpdb->hide_errors();
foreach ( $old_user_fields as $old )
$wpdb->query("ALTER TABLE $wpdb->users DROP $old");
$wpdb->show_errors();
// populate comment_count field of posts table
$comments = $wpdb->get_results( "SELECT comment_post_ID, COUNT(*) as c FROM $wpdb->comments WHERE comment_approved = '1' GROUP BY comment_post_ID" );
if ( is_array( $comments ) )
foreach ($comments as $comment)
$wpdb->update( $wpdb->posts, array('comment_count' => $comment->c), array('ID' => $comment->comment_post_ID) );
// Some alpha versions used a post status of object instead of attachment and put
// the mime type in post_type instead of post_mime_type.
if ( $wp_current_db_version > 2541 && $wp_current_db_version <= 3091 ) {
$objects = $wpdb->get_results("SELECT ID, post_type FROM $wpdb->posts WHERE post_status = 'object'");
foreach ($objects as $object) {
$wpdb->update( $wpdb->posts, array( 'post_status' => 'attachment',
'post_mime_type' => $object->post_type,
'post_type' => ''),
array( 'ID' => $object->ID ) );
$meta = get_post_meta($object->ID, 'imagedata', true);
if ( ! empty($meta['file']) )
update_attached_file( $object->ID, $meta['file'] );
}
}
}
/**
* Execute changes made in WordPress 2.1.
*
* @since 2.1.0
*/
function upgrade_210() {
global $wpdb, $wp_current_db_version;
if ( $wp_current_db_version < 3506 ) {
// Update status and type.
$posts = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts");
if ( ! empty($posts) ) foreach ($posts as $post) {
$status = $post->post_status;
$type = 'post';
if ( 'static' == $status ) {
$status = 'publish';
$type = 'page';
} else if ( 'attachment' == $status ) {
$status = 'inherit';
$type = 'attachment';
}
$wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_status = %s, post_type = %s WHERE ID = %d", $status, $type, $post->ID) );
}
}
if ( $wp_current_db_version < 3845 ) {
populate_roles_210();
}
if ( $wp_current_db_version < 3531 ) {
// Give future posts a post_status of future.
$now = gmdate('Y-m-d H:i:59');
$wpdb->query ("UPDATE $wpdb->posts SET post_status = 'future' WHERE post_status = 'publish' AND post_date_gmt > '$now'");
$posts = $wpdb->get_results("SELECT ID, post_date FROM $wpdb->posts WHERE post_status ='future'");
if ( !empty($posts) )
foreach ( $posts as $post )
wp_schedule_single_event(mysql2date('U', $post->post_date, false), 'publish_future_post', array($post->ID));
}
}
/**
* Execute changes made in WordPress 2.3.
*
* @since 2.3.0
*/
function upgrade_230() {
global $wp_current_db_version, $wpdb;
if ( $wp_current_db_version < 5200 ) {
populate_roles_230();
}
// Convert categories to terms.
$tt_ids = array();
$have_tags = false;
$categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY cat_ID");
foreach ($categories as $category) {
$term_id = (int) $category->cat_ID;
$name = $category->cat_name;
$description = $category->category_description;
$slug = $category->category_nicename;
$parent = $category->category_parent;
$term_group = 0;
// Associate terms with the same slug in a term group and make slugs unique.
if ( $exists = $wpdb->get_results( $wpdb->prepare("SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $slug) ) ) {
$term_group = $exists[0]->term_group;
$id = $exists[0]->term_id;
$num = 2;
do {
$alt_slug = $slug . "-$num";
$num++;
$slug_check = $wpdb->get_var( $wpdb->prepare("SELECT slug FROM $wpdb->terms WHERE slug = %s", $alt_slug) );
} while ( $slug_check );
$slug = $alt_slug;
if ( empty( $term_group ) ) {
$term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms GROUP BY term_group") + 1;
$wpdb->query( $wpdb->prepare("UPDATE $wpdb->terms SET term_group = %d WHERE term_id = %d", $term_group, $id) );
}
}
$wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->terms (term_id, name, slug, term_group) VALUES
(%d, %s, %s, %d)", $term_id, $name, $slug, $term_group) );
$count = 0;
if ( !empty($category->category_count) ) {
$count = (int) $category->category_count;
$taxonomy = 'category';
$wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ( %d, %s, %s, %d, %d)", $term_id, $taxonomy, $description, $parent, $count) );
$tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id;
}
if ( !empty($category->link_count) ) {
$count = (int) $category->link_count;
$taxonomy = 'link_category';
$wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ( %d, %s, %s, %d, %d)", $term_id, $taxonomy, $description, $parent, $count) );
$tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id;
}
if ( !empty($category->tag_count) ) {
$have_tags = true;
$count = (int) $category->tag_count;
$taxonomy = 'post_tag';
$wpdb->insert( $wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent', 'count') );
$tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id;
}
if ( empty($count) ) {
$count = 0;
$taxonomy = 'category';
$wpdb->insert( $wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent', 'count') );
$tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id;
}
}
$select = 'post_id, category_id';
if ( $have_tags )
$select .= ', rel_type';
$posts = $wpdb->get_results("SELECT $select FROM $wpdb->post2cat GROUP BY post_id, category_id");
foreach ( $posts as $post ) {
$post_id = (int) $post->post_id;
$term_id = (int) $post->category_id;
$taxonomy = 'category';
if ( !empty($post->rel_type) && 'tag' == $post->rel_type)
$taxonomy = 'tag';
$tt_id = $tt_ids[$term_id][$taxonomy];
if ( empty($tt_id) )
continue;
$wpdb->insert( $wpdb->term_relationships, array('object_id' => $post_id, 'term_taxonomy_id' => $tt_id) );
}
// < 3570 we used linkcategories. >= 3570 we used categories and link2cat.
if ( $wp_current_db_version < 3570 ) {
// Create link_category terms for link categories. Create a map of link cat IDs
// to link_category terms.
$link_cat_id_map = array();
$default_link_cat = 0;
$tt_ids = array();
$link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM " . $wpdb->prefix . 'linkcategories');
foreach ( $link_cats as $category) {
$cat_id = (int) $category->cat_id;
$term_id = 0;
$name = $wpdb->escape($category->cat_name);
$slug = sanitize_title($name);
$term_group = 0;
// Associate terms with the same slug in a term group and make slugs unique.
if ( $exists = $wpdb->get_results( $wpdb->prepare("SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $slug) ) ) {
$term_group = $exists[0]->term_group;
$term_id = $exists[0]->term_id;
}
if ( empty($term_id) ) {
$wpdb->insert( $wpdb->terms, compact('name', 'slug', 'term_group') );
$term_id = (int) $wpdb->insert_id;
}
$link_cat_id_map[$cat_id] = $term_id;
$default_link_cat = $term_id;
$wpdb->insert( $wpdb->term_taxonomy, array('term_id' => $term_id, 'taxonomy' => 'link_category', 'description' => '', 'parent' => 0, 'count' => 0) );
$tt_ids[$term_id] = (int) $wpdb->insert_id;
}
// Associate links to cats.
$links = $wpdb->get_results("SELECT link_id, link_category FROM $wpdb->links");
if ( !empty($links) ) foreach ( $links as $link ) {
if ( 0 == $link->link_category )
continue;
if ( ! isset($link_cat_id_map[$link->link_category]) )
continue;
$term_id = $link_cat_id_map[$link->link_category];
$tt_id = $tt_ids[$term_id];
if ( empty($tt_id) )
continue;
$wpdb->insert( $wpdb->term_relationships, array('object_id' => $link->link_id, 'term_taxonomy_id' => $tt_id) );
}
// Set default to the last category we grabbed during the upgrade loop.
update_option('default_link_category', $default_link_cat);
} else {
$links = $wpdb->get_results("SELECT link_id, category_id FROM $wpdb->link2cat GROUP BY link_id, category_id");
foreach ( $links as $link ) {
$link_id = (int) $link->link_id;
$term_id = (int) $link->category_id;
$taxonomy = 'link_category';
$tt_id = $tt_ids[$term_id][$taxonomy];
if ( empty($tt_id) )
continue;
$wpdb->insert( $wpdb->term_relationships, array('object_id' => $link_id, 'term_taxonomy_id' => $tt_id) );
}
}
if ( $wp_current_db_version < 4772 ) {
// Obsolete linkcategories table
$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'linkcategories');
}
// Recalculate all counts
$terms = $wpdb->get_results("SELECT term_taxonomy_id, taxonomy FROM $wpdb->term_taxonomy");
foreach ( (array) $terms as $term ) {
if ( ('post_tag' == $term->taxonomy) || ('category' == $term->taxonomy) )
$count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type = 'post' AND term_taxonomy_id = %d", $term->term_taxonomy_id) );
else
$count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term->term_taxonomy_id) );
$wpdb->update( $wpdb->term_taxonomy, array('count' => $count), array('term_taxonomy_id' => $term->term_taxonomy_id) );
}
}
/**
* Remove old options from the database.
*
* @since 2.3.0
*/
function upgrade_230_options_table() {
global $wpdb;
$old_options_fields = array( 'option_can_override', 'option_type', 'option_width', 'option_height', 'option_description', 'option_admin_level' );
$wpdb->hide_errors();
foreach ( $old_options_fields as $old )
$wpdb->query("ALTER TABLE $wpdb->options DROP $old");
$wpdb->show_errors();
}
/**
* Remove old categories, link2cat, and post2cat database tables.
*
* @since 2.3.0
*/
function upgrade_230_old_tables() {
global $wpdb;
$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'categories');
$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'link2cat');
$wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'post2cat');
}
/**
* Upgrade old slugs made in version 2.2.
*
* @since 2.2.0
*/
function upgrade_old_slugs() {
// upgrade people who were using the Redirect Old Slugs plugin
global $wpdb;
$wpdb->query("UPDATE $wpdb->postmeta SET meta_key = '_wp_old_slug' WHERE meta_key = 'old_slug'");
}
/**
* Execute changes made in WordPress 2.5.0.
*
* @since 2.5.0
*/
function upgrade_250() {
global $wp_current_db_version;
if ( $wp_current_db_version < 6689 ) {
populate_roles_250();
}
}
/**
* Execute changes made in WordPress 2.5.2.
*
* @since 2.5.2
*/
function upgrade_252() {
global $wpdb;
$wpdb->query("UPDATE $wpdb->users SET user_activation_key = ''");
}
/**
* Execute changes made in WordPress 2.6.
*
* @since 2.6.0
*/
function upgrade_260() {
global $wp_current_db_version;
if ( $wp_current_db_version < 8000 )
populate_roles_260();
if ( $wp_current_db_version < 8201 ) {
update_option('enable_app', 1);
update_option('enable_xmlrpc', 1);
}
}
/**
* Execute changes made in WordPress 2.7.
*
* @since 2.7.0
*/
function upgrade_270() {
global $wpdb, $wp_current_db_version;
if ( $wp_current_db_version < 8980 )
populate_roles_270();
// Update post_date for unpublished posts with empty timestamp
if ( $wp_current_db_version < 8921 )
$wpdb->query( "UPDATE $wpdb->posts SET post_date = post_modified WHERE post_date = '0000-00-00 00:00:00'" );
}
/**
* Execute changes made in WordPress 2.8.
*
* @since 2.8.0
*/
function upgrade_280() {
global $wp_current_db_version, $wpdb;
if ( $wp_current_db_version < 10360 )
populate_roles_280();
if ( is_multisite() ) {
$start = 0;
while( $rows = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options ORDER BY option_id LIMIT $start, 20" ) ) {
foreach( $rows as $row ) {
$value = $row->option_value;
if ( !@unserialize( $value ) )
$value = stripslashes( $value );
if ( $value !== $row->option_value ) {
update_option( $row->option_name, $value );
}
}
$start += 20;
}
refresh_blog_details( $wpdb->blogid );
}
}
/**
* Execute changes made in WordPress 2.9.
*
* @since 2.9.0
*/
function upgrade_290() {
global $wp_current_db_version;
if ( $wp_current_db_version < 11958 ) {
// Previously, setting depth to 1 would redundantly disable threading, but now 2 is the minimum depth to avoid confusion
if ( get_option( 'thread_comments_depth' ) == '1' ) {
update_option( 'thread_comments_depth', 2 );
update_option( 'thread_comments', 0 );
}
}
}
/**
* Execute changes made in WordPress 3.0.
*
* @since 3.0.0
*/
function upgrade_300() {
global $wp_current_db_version, $wpdb;
if ( $wp_current_db_version < 15093 )
populate_roles_300();
if ( $wp_current_db_version < 14139 && is_multisite() && is_main_site() && ! defined( 'MULTISITE' ) && get_site_option( 'siteurl' ) === false )
add_site_option( 'siteurl', '' );
// 3.0 screen options key name changes.
if ( is_main_site() && !defined('DO_NOT_UPGRADE_GLOBAL_TABLES') ) {
$prefix = like_escape($wpdb->base_prefix);
$wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key LIKE '{$prefix}%meta-box-hidden%' OR meta_key LIKE '{$prefix}%closedpostboxes%' OR meta_key LIKE '{$prefix}%manage-%-columns-hidden%' OR meta_key LIKE '{$prefix}%meta-box-order%' OR meta_key LIKE '{$prefix}%metaboxorder%' OR meta_key LIKE '{$prefix}%screen_layout%'
OR meta_key = 'manageedittagscolumnshidden' OR meta_key='managecategoriescolumnshidden' OR meta_key = 'manageedit-tagscolumnshidden' OR meta_key = 'manageeditcolumnshidden' OR meta_key = 'categories_per_page' OR meta_key = 'edit_tags_per_page'" );
}
}
/**
* Execute changes made in WordPress 3.3.
*
* @since 3.3.0
*/
function upgrade_330() {
global $wp_current_db_version, $wpdb, $wp_registered_widgets, $sidebars_widgets;
if ( $wp_current_db_version < 19061 && is_main_site() && ! defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) {
$wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key IN ('show_admin_bar_admin', 'plugins_last_view')" );
}
if ( $wp_current_db_version >= 11548 )
return;
$sidebars_widgets = get_option( 'sidebars_widgets', array() );
$_sidebars_widgets = array();
if ( isset($sidebars_widgets['wp_inactive_widgets']) || empty($sidebars_widgets) )
$sidebars_widgets['array_version'] = 3;
elseif ( !isset($sidebars_widgets['array_version']) )
$sidebars_widgets['array_version'] = 1;
switch ( $sidebars_widgets['array_version'] ) {
case 1 :
foreach ( (array) $sidebars_widgets as $index => $sidebar )
if ( is_array($sidebar) )
foreach ( (array) $sidebar as $i => $name ) {
$id = strtolower($name);
if ( isset($wp_registered_widgets[$id]) ) {
$_sidebars_widgets[$index][$i] = $id;
continue;
}
$id = sanitize_title($name);
if ( isset($wp_registered_widgets[$id]) ) {
$_sidebars_widgets[$index][$i] = $id;
continue;
}
$found = false;
foreach ( $wp_registered_widgets as $widget_id => $widget ) {
if ( strtolower($widget['name']) == strtolower($name) ) {
$_sidebars_widgets[$index][$i] = $widget['id'];
$found = true;
break;
} elseif ( sanitize_title($widget['name']) == sanitize_title($name) ) {
$_sidebars_widgets[$index][$i] = $widget['id'];
$found = true;
break;
}
}
if ( $found )
continue;
unset($_sidebars_widgets[$index][$i]);
}
$_sidebars_widgets['array_version'] = 2;
$sidebars_widgets = $_sidebars_widgets;
unset($_sidebars_widgets);
case 2 :
$sidebars_widgets = retrieve_widgets();
$sidebars_widgets['array_version'] = 3;
update_option( 'sidebars_widgets', $sidebars_widgets );
}
}
/**
* Execute changes made in WordPress 3.4.
*
* @since 3.4.0
*/
function upgrade_340() {
global $wp_current_db_version, $wpdb;
if ( $wp_current_db_version < 19798 ) {
$wpdb->hide_errors();
$wpdb->query( "ALTER TABLE $wpdb->options DROP COLUMN blog_id" );
$wpdb->show_errors();
}
if ( $wp_current_db_version < 19799 ) {
$wpdb->hide_errors();
$wpdb->query("ALTER TABLE $wpdb->comments DROP INDEX comment_approved");
$wpdb->show_errors();
}
if ( $wp_current_db_version < 20022 && is_main_site() && ! defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) {
$wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key = 'themes_last_view'" );
}
if ( $wp_current_db_version < 20080 ) {
if ( 'yes' == $wpdb->get_var( "SELECT autoload FROM $wpdb->options WHERE option_name = 'uninstall_plugins'" ) ) {
$uninstall_plugins = get_option( 'uninstall_plugins' );
delete_option( 'uninstall_plugins' );
add_option( 'uninstall_plugins', $uninstall_plugins, null, 'no' );
}
}
}
/**
* Execute network level changes
*
* @since 3.0.0
*/
function upgrade_network() {
global $wp_current_db_version, $wpdb;
// 2.8
if ( $wp_current_db_version < 11549 ) {
$wpmu_sitewide_plugins = get_site_option( 'wpmu_sitewide_plugins' );
$active_sitewide_plugins = get_site_option( 'active_sitewide_plugins' );
if ( $wpmu_sitewide_plugins ) {
if ( !$active_sitewide_plugins )
$sitewide_plugins = (array) $wpmu_sitewide_plugins;
else
$sitewide_plugins = array_merge( (array) $active_sitewide_plugins, (array) $wpmu_sitewide_plugins );
update_site_option( 'active_sitewide_plugins', $sitewide_plugins );
}
delete_site_option( 'wpmu_sitewide_plugins' );
delete_site_option( 'deactivated_sitewide_plugins' );
$start = 0;
while( $rows = $wpdb->get_results( "SELECT meta_key, meta_value FROM {$wpdb->sitemeta} ORDER BY meta_id LIMIT $start, 20" ) ) {
foreach( $rows as $row ) {
$value = $row->meta_value;
if ( !@unserialize( $value ) )
$value = stripslashes( $value );
if ( $value !== $row->meta_value ) {
update_site_option( $row->meta_key, $value );
}
}
$start += 20;
}
}
// 3.0
if ( $wp_current_db_version < 13576 )
update_site_option( 'global_terms_enabled', '1' );
// 3.3
if ( $wp_current_db_version < 19390 )
update_site_option( 'initial_db_version', $wp_current_db_version );
if ( $wp_current_db_version < 19470 ) {
if ( false === get_site_option( 'active_sitewide_plugins' ) )
update_site_option( 'active_sitewide_plugins', array() );
}
// 3.4
if ( $wp_current_db_version < 20148 ) {
// 'allowedthemes' keys things by stylesheet. 'allowed_themes' keyed things by name.
$allowedthemes = get_site_option( 'allowedthemes' );
$allowed_themes = get_site_option( 'allowed_themes' );
if ( false === $allowedthemes && is_array( $allowed_themes ) && $allowed_themes ) {
$converted = array();
$themes = wp_get_themes();
foreach ( $themes as $stylesheet => $theme_data ) {
if ( isset( $allowed_themes[ $theme_data->get('Name') ] ) )
$converted[ $stylesheet ] = true;
}
update_site_option( 'allowedthemes', $converted );
delete_site_option( 'allowed_themes' );
}
}
}
// The functions we use to actually do stuff
// General
/**
* {@internal Missing Short Description}}
*
* {@internal Missing Long Description}}
*
* @since 1.0.0
*
* @param string $table_name Database table name to create.
* @param string $create_ddl SQL statement to create table.
* @return bool If table already exists or was created by function.
*/
function maybe_create_table($table_name, $create_ddl) {
global $wpdb;
if ( $wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name )
return true;
//didn't find it try to create it.
$q = $wpdb->query($create_ddl);
// we cannot directly tell that whether this succeeded!
if ( $wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name )
return true;
return false;
}
/**
* {@internal Missing Short Description}}
*
* {@internal Missing Long Description}}
*
* @since 1.0.1
*
* @param string $table Database table name.
* @param string $index Index name to drop.
* @return bool True, when finished.
*/
function drop_index($table, $index) {
global $wpdb;
$wpdb->hide_errors();
$wpdb->query("ALTER TABLE `$table` DROP INDEX `$index`");
// Now we need to take out all the extra ones we may have created
for ($i = 0; $i < 25; $i++) {
$wpdb->query("ALTER TABLE `$table` DROP INDEX `{$index}_$i`");
}
$wpdb->show_errors();
return true;
}
/**
* {@internal Missing Short Description}}
*
* {@internal Missing Long Description}}
*
* @since 1.0.1
*
* @param string $table Database table name.
* @param string $index Database table index column.
* @return bool True, when done with execution.
*/
function add_clean_index($table, $index) {
global $wpdb;
drop_index($table, $index);
$wpdb->query("ALTER TABLE `$table` ADD INDEX ( `$index` )");
return true;
}
/**
** maybe_add_column()
** Add column to db table if it doesn't exist.
** Returns: true if already exists or on successful completion
** false on error
*/
function maybe_add_column($table_name, $column_name, $create_ddl) {
global $wpdb;
foreach ($wpdb->get_col("DESC $table_name", 0) as $column ) {
if ($column == $column_name) {
return true;
}
}
//didn't find it try to create it.
$q = $wpdb->query($create_ddl);
// we cannot directly tell that whether this succeeded!
foreach ($wpdb->get_col("DESC $table_name", 0) as $column ) {
if ($column == $column_name) {
return true;
}
}
return false;
}
/**
* Retrieve all options as it was for 1.2.
*
* @since 1.2.0
*
* @return array List of options.
*/
function get_alloptions_110() {
global $wpdb;
$all_options = new stdClass;
if ( $options = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" ) ) {
foreach ( $options as $option ) {
if ( 'siteurl' == $option->option_name || 'home' == $option->option_name || 'category_base' == $option->option_name )
$option->option_value = untrailingslashit( $option->option_value );
$all_options->{$option->option_name} = stripslashes( $option->option_value );
}
}
return $all_options;
}
/**
* Version of get_option that is private to install/upgrade.
*
* @since 1.5.1
* @access private
*
* @param string $setting Option name.
* @return mixed
*/
function __get_option($setting) {
global $wpdb;
if ( $setting == 'home' && defined( 'WP_HOME' ) )
return untrailingslashit( WP_HOME );
if ( $setting == 'siteurl' && defined( 'WP_SITEURL' ) )
return untrailingslashit( WP_SITEURL );
$option = $wpdb->get_var( $wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = %s", $setting ) );
if ( 'home' == $setting && '' == $option )
return __get_option( 'siteurl' );
if ( 'siteurl' == $setting || 'home' == $setting || 'category_base' == $setting || 'tag_base' == $setting )
$option = untrailingslashit( $option );
@ $kellogs = unserialize( $option );
if ( $kellogs !== false )
return $kellogs;
else
return $option;
}
/**
* {@internal Missing Short Description}}
*
* {@internal Missing Long Description}}
*
* @since 1.5.0
*
* @param string $content
* @return string
*/
function deslash($content) {
// Note: \\\ inside a regex denotes a single backslash.
// Replace one or more backslashes followed by a single quote with
// a single quote.
$content = preg_replace("/\\\+'/", "'", $content);
// Replace one or more backslashes followed by a double quote with
// a double quote.
$content = preg_replace('/\\\+"/', '"', $content);
// Replace one or more backslashes with one backslash.
$content = preg_replace("/\\\+/", "\\", $content);
return $content;
}
/**
* {@internal Missing Short Description}}
*
* {@internal Missing Long Description}}
*
* @since 1.5.0
*
* @param unknown_type $queries
* @param unknown_type $execute
* @return unknown
*/
function dbDelta( $queries = '', $execute = true ) {
global $wpdb;
if ( in_array( $queries, array( '', 'all', 'blog', 'global', 'ms_global' ), true ) )
$queries = wp_get_db_schema( $queries );
// Separate individual queries into an array
if ( !is_array($queries) ) {
$queries = explode( ";\n", $queries );//[ysd]修正分隔符
$queries = array_filter( $queries );
}
$queries = apply_filters( 'dbdelta_queries', $queries );
$cqueries = array(); // Creation Queries
$iqueries = array(); // Insertion Queries
$for_update = array();
// Create a tablename index for an array ($cqueries) of queries
foreach($queries as $qry) {
if (preg_match("|CREATE TABLE ([^ ]*)|", $qry, $matches)) {
$cqueries[ trim( $matches[1], '`' ) ] = $qry;
$for_update[$matches[1]] = 'Created table '.$matches[1];
} else if (preg_match("|CREATE DATABASE ([^ ]*)|", $qry, $matches)) {
array_unshift($cqueries, $qry);
} else if (preg_match("|INSERT INTO ([^ ]*)|", $qry, $matches)) {
$iqueries[] = $qry;
} else if (preg_match("|UPDATE ([^ ]*)|", $qry, $matches)) {
$iqueries[] = $qry;
} else {
// Unrecognized query type
}
}
$cqueries = apply_filters( 'dbdelta_create_queries', $cqueries );
$iqueries = apply_filters( 'dbdelta_insert_queries', $iqueries );
$global_tables = $wpdb->tables( 'global' );
foreach ( $cqueries as $table => $qry ) {
// Upgrade global tables only for the main site. Don't upgrade at all if DO_NOT_UPGRADE_GLOBAL_TABLES is defined.
if ( in_array( $table, $global_tables ) && ( !is_main_site() || defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) )
continue;
// Fetch the table column structure from the database
$wpdb->suppress_errors();
$tablefields = $wpdb->get_results("DESCRIBE {$table};");
$wpdb->suppress_errors( false );
if ( ! $tablefields )
continue;
// Clear the field and index arrays
$cfields = $indices = array();
// Get all of the field names in the query from between the parens
preg_match("|\((.*)\)|ms", $qry, $match2);
$qryline = trim($match2[1]);
// Separate field lines into an array
$flds = explode("\n", $qryline);
//echo "<hr/><pre>\n".print_r(strtolower($table), true).":\n".print_r($cqueries, true)."</pre><hr/>";
// For every field line specified in the query
foreach ($flds as $fld) {
// Extract the field name
preg_match("|^([^ ]*)|", trim($fld), $fvals);
$fieldname = trim( $fvals[1], '`' );
// Verify the found field name
$validfield = true;
switch (strtolower($fieldname)) {
case '':
case 'primary':
case 'index':
case 'fulltext':
case 'unique':
case 'key':
$validfield = false;
$indices[] = trim(trim($fld), ", \n");
break;
}
$fld = trim($fld);
// If it's a valid field, add it to the field array
if ($validfield) {
$cfields[strtolower($fieldname)] = trim($fld, ", \n");
}
}
// For every field in the table
foreach ($tablefields as $tablefield) {
// If the table field exists in the field array...
if (array_key_exists(strtolower($tablefield->Field), $cfields)) {
// Get the field type from the query
preg_match("|".$tablefield->Field." ([^ ]*( unsigned)?)|i", $cfields[strtolower($tablefield->Field)], $matches);
$fieldtype = $matches[1];
// Is actual field type different from the field type in query?
if ($tablefield->Type != $fieldtype) {
// Add a query to change the column type
$cqueries[] = "ALTER TABLE {$table} CHANGE COLUMN {$tablefield->Field} " . $cfields[strtolower($tablefield->Field)];
$for_update[$table.'.'.$tablefield->Field] = "Changed type of {$table}.{$tablefield->Field} from {$tablefield->Type} to {$fieldtype}";
}
// Get the default value from the array
//echo "{$cfields[strtolower($tablefield->Field)]}<br>";
if (preg_match("| DEFAULT '(.*)'|i", $cfields[strtolower($tablefield->Field)], $matches)) {
$default_value = $matches[1];
if ($tablefield->Default != $default_value) {
// Add a query to change the column's default value
$cqueries[] = "ALTER TABLE {$table} ALTER COLUMN {$tablefield->Field} SET DEFAULT '{$default_value}'";
$for_update[$table.'.'.$tablefield->Field] = "Changed default value of {$table}.{$tablefield->Field} from {$tablefield->Default} to {$default_value}";
}
}
// Remove the field from the array (so it's not added)
unset($cfields[strtolower($tablefield->Field)]);
} else {
// This field exists in the table, but not in the creation queries?
}
}
// For every remaining field specified for the table
foreach ($cfields as $fieldname => $fielddef) {
// Push a query line into $cqueries that adds the field to that table
$cqueries[] = "ALTER TABLE {$table} ADD COLUMN $fielddef";
$for_update[$table.'.'.$fieldname] = 'Added column '.$table.'.'.$fieldname;
}
// Index stuff goes here
// Fetch the table index structure from the database
$tableindices = $wpdb->get_results("SHOW INDEX FROM {$table};");
if ($tableindices) {
// Clear the index array
unset($index_ary);
// For every index in the table
foreach ($tableindices as $tableindex) {
// Add the index to the index data array
$keyname = $tableindex->Key_name;
$index_ary[$keyname]['columns'][] = array('fieldname' => $tableindex->Column_name, 'subpart' => $tableindex->Sub_part);
$index_ary[$keyname]['unique'] = ($tableindex->Non_unique == 0)?true:false;
}
// For each actual index in the index array
foreach ($index_ary as $index_name => $index_data) {
// Build a create string to compare to the query
$index_string = '';
if ($index_name == 'PRIMARY') {
$index_string .= 'PRIMARY ';
} else if($index_data['unique']) {
$index_string .= 'UNIQUE ';
}
$index_string .= 'KEY ';
if ($index_name != 'PRIMARY') {
$index_string .= $index_name;
}
$index_columns = '';
// For each column in the index
foreach ($index_data['columns'] as $column_data) {
if ($index_columns != '') $index_columns .= ',';
// Add the field to the column list string
$index_columns .= $column_data['fieldname'];
if ($column_data['subpart'] != '') {
$index_columns .= '('.$column_data['subpart'].')';
}
}
// Add the column list to the index create string
$index_string .= ' ('.$index_columns.')';
if (!(($aindex = array_search($index_string, $indices)) === false)) {
unset($indices[$aindex]);
//echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">{$table}:<br />Found index:".$index_string."</pre>\n";
}
//else echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">{$table}:<br /><b>Did not find index:</b>".$index_string."<br />".print_r($indices, true)."</pre>\n";
}
}
// For every remaining index specified for the table
foreach ( (array) $indices as $index ) {
// Push a query line into $cqueries that adds the index to that table
$cqueries[] = "ALTER TABLE {$table} ADD $index";
$for_update[$table.'.'.$fieldname] = 'Added index '.$table.' '.$index;
}
// Remove the original table creation query from processing
unset( $cqueries[ $table ], $for_update[ $table ] );
}
$allqueries = array_merge($cqueries, $iqueries);
if ($execute) {
foreach ($allqueries as $query) {
//echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">".print_r($query, true)."</pre>\n";
$wpdb->query($query);
}
}
return $for_update;
}
/**
* {@internal Missing Short Description}}
*
* {@internal Missing Long Description}}
*
* @since 1.5.0
*/
function make_db_current( $tables = 'all' ) {
$alterations = dbDelta( $tables );
echo "<ol>\n";
foreach($alterations as $alteration) echo "<li>$alteration</li>\n";
echo "</ol>\n";
}
/**
* {@internal Missing Short Description}}
*
* {@internal Missing Long Description}}
*
* @since 1.5.0
*/
function make_db_current_silent( $tables = 'all' ) {
$alterations = dbDelta( $tables );
}
/**
* {@internal Missing Short Description}}
*
* {@internal Missing Long Description}}
*
* @since 1.5.0
*
* @param unknown_type $theme_name
* @param unknown_type $template
* @return unknown
*/
function make_site_theme_from_oldschool($theme_name, $template) {
$home_path = get_home_path();
$site_dir = WP_CONTENT_DIR . "/themes/$template";
if (! file_exists("$home_path/index.php"))
return false;
// Copy files from the old locations to the site theme.
// TODO: This does not copy arbitrary include dependencies. Only the
// standard WP files are copied.
$files = array('index.php' => 'index.php', 'wp-layout.css' => 'style.css', 'wp-comments.php' => 'comments.php', 'wp-comments-popup.php' => 'comments-popup.php');
foreach ($files as $oldfile => $newfile) {
if ($oldfile == 'index.php')
$oldpath = $home_path;
else
$oldpath = ABSPATH;
if ($oldfile == 'index.php') { // Check to make sure it's not a new index
$index = implode('', file("$oldpath/$oldfile"));
if (strpos($index, 'WP_USE_THEMES') !== false) {
if (! @copy(WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME . '/index.php', "$site_dir/$newfile"))
return false;
continue; // Don't copy anything
}
}
if (! @copy("$oldpath/$oldfile", "$site_dir/$newfile"))
return false;
chmod("$site_dir/$newfile", 0777);
// Update the blog header include in each file.
$lines = explode("\n", implode('', file("$site_dir/$newfile")));
if ($lines) {
$f = fopen("$site_dir/$newfile", 'w');
foreach ($lines as $line) {
if (preg_match('/require.*wp-blog-header/', $line))
$line = '//' . $line;
// Update stylesheet references.
$line = str_replace("<?php echo __get_option('siteurl'); ?>/wp-layout.css", "<?php bloginfo('stylesheet_url'); ?>", $line);
// Update comments template inclusion.
$line = str_replace("<?php include(ABSPATH . 'wp-comments.php'); ?>", "<?php comments_template(); ?>", $line);
fwrite($f, "{$line}\n");
}
fclose($f);
}
}
// Add a theme header.
$header = "/*\nTheme Name: $theme_name\nTheme URI: " . __get_option('siteurl') . "\nDescription: A theme automatically created by the update.\nVersion: 1.0\nAuthor: Moi\n*/\n";
$stylelines = file_get_contents("$site_dir/style.css");
if ($stylelines) {
$f = fopen("$site_dir/style.css", 'w');
fwrite($f, $header);
fwrite($f, $stylelines);
fclose($f);
}
return true;
}
/**
* {@internal Missing Short Description}}
*
* {@internal Missing Long Description}}
*
* @since 1.5.0
*
* @param unknown_type $theme_name
* @param unknown_type $template
* @return unknown
*/
function make_site_theme_from_default($theme_name, $template) {
$site_dir = WP_CONTENT_DIR . "/themes/$template";
$default_dir = WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME;
// Copy files from the default theme to the site theme.
//$files = array('index.php', 'comments.php', 'comments-popup.php', 'footer.php', 'header.php', 'sidebar.php', 'style.css');
$theme_dir = @ opendir($default_dir);
if ($theme_dir) {
while(($theme_file = readdir( $theme_dir )) !== false) {
if (is_dir("$default_dir/$theme_file"))
continue;
if (! @copy("$default_dir/$theme_file", "$site_dir/$theme_file"))
return;
chmod("$site_dir/$theme_file", 0777);
}
}
@closedir($theme_dir);
// Rewrite the theme header.
$stylelines = explode("\n", implode('', file("$site_dir/style.css")));
if ($stylelines) {
$f = fopen("$site_dir/style.css", 'w');
foreach ($stylelines as $line) {
if (strpos($line, 'Theme Name:') !== false) $line = 'Theme Name: ' . $theme_name;
elseif (strpos($line, 'Theme URI:') !== false) $line = 'Theme URI: ' . __get_option('url');
elseif (strpos($line, 'Description:') !== false) $line = 'Description: Your theme.';
elseif (strpos($line, 'Version:') !== false) $line = 'Version: 1';
elseif (strpos($line, 'Author:') !== false) $line = 'Author: You';
fwrite($f, $line . "\n");
}
fclose($f);
}
// Copy the images.
umask(0);
if (! mkdir("$site_dir/images", 0777)) {
return false;
}
$images_dir = @ opendir("$default_dir/images");
if ($images_dir) {
while(($image = readdir($images_dir)) !== false) {
if (is_dir("$default_dir/images/$image"))
continue;
if (! @copy("$default_dir/images/$image", "$site_dir/images/$image"))
return;
chmod("$site_dir/images/$image", 0777);
}
}
@closedir($images_dir);
}
// Create a site theme from the default theme.
/**
* {@internal Missing Short Description}}
*
* {@internal Missing Long Description}}
*
* @since 1.5.0
*
* @return unknown
*/
function make_site_theme() {
// Name the theme after the blog.
$theme_name = __get_option('blogname');
$template = sanitize_title($theme_name);
$site_dir = WP_CONTENT_DIR . "/themes/$template";
// If the theme already exists, nothing to do.
if ( is_dir($site_dir)) {
return false;
}
// We must be able to write to the themes dir.
if (! is_writable(WP_CONTENT_DIR . "/themes")) {
return false;
}
umask(0);
if (! mkdir($site_dir, 0777)) {
return false;
}
if (file_exists(ABSPATH . 'wp-layout.css')) {
if (! make_site_theme_from_oldschool($theme_name, $template)) {
// TODO: rm -rf the site theme directory.
return false;
}
} else {
if (! make_site_theme_from_default($theme_name, $template))
// TODO: rm -rf the site theme directory.
return false;
}
// Make the new site theme active.
$current_template = __get_option('template');
if ($current_template == WP_DEFAULT_THEME) {
update_option('template', $template);
update_option('stylesheet', $template);
}
return $template;
}
/**
* Translate user level to user role name.
*
* @since 2.0.0
*
* @param int $level User level.
* @return string User role name.
*/
function translate_level_to_role($level) {
switch ($level) {
case 10:
case 9:
case 8:
return 'administrator';
case 7:
case 6:
case 5:
return 'editor';
case 4:
case 3:
case 2:
return 'author';
case 1:
return 'contributor';
case 0:
return 'subscriber';
}
}
/**
* {@internal Missing Short Description}}
*
* {@internal Missing Long Description}}
*
* @since 2.1.0
*/
function wp_check_mysql_version() {
global $wpdb;
$result = $wpdb->check_database_version();
if ( is_wp_error( $result ) )
die( $result->get_error_message() );
}
/**
* {@internal Missing Short Description}}
*
* {@internal Missing Long Description}}
*
* @since 2.2.0
*/
function maybe_disable_automattic_widgets() {
$plugins = __get_option( 'active_plugins' );
foreach ( (array) $plugins as $plugin ) {
if ( basename( $plugin ) == 'widgets.php' ) {
array_splice( $plugins, array_search( $plugin, $plugins ), 1 );
update_option( 'active_plugins', $plugins );
break;
}
}
}
/**
* Runs before the schema is upgraded.
*
* @since 2.9.0
*/
function pre_schema_upgrade() {
global $wp_current_db_version, $wp_db_version, $wpdb;
// Upgrade versions prior to 2.9
if ( $wp_current_db_version < 11557 ) {
// Delete duplicate options. Keep the option with the highest option_id.
$wpdb->query("DELETE o1 FROM $wpdb->options AS o1 JOIN $wpdb->options AS o2 USING (`option_name`) WHERE o2.option_id > o1.option_id");
// Drop the old primary key and add the new.
$wpdb->query("ALTER TABLE $wpdb->options DROP PRIMARY KEY, ADD PRIMARY KEY(option_id)");
// Drop the old option_name index. dbDelta() doesn't do the drop.
$wpdb->query("ALTER TABLE $wpdb->options DROP INDEX option_name");
}
}
/**
* Install global terms.
*
* @since 3.0.0
*
*/
if ( !function_exists( 'install_global_terms' ) ) :
function install_global_terms() {
global $wpdb, $charset_collate;
$ms_queries = "
CREATE TABLE $wpdb->sitecategories (
cat_ID bigint(20) NOT NULL auto_increment,
cat_name varchar(55) NOT NULL default '',
category_nicename varchar(200) NOT NULL default '',
last_updated timestamp NOT NULL,
PRIMARY KEY (cat_ID),
KEY category_nicename (category_nicename),
KEY last_updated (last_updated)
) $charset_collate;
";
// now create tables
dbDelta( $ms_queries );
}
endif;
| 01happy-blog | trunk/myblog/wp-admin/includes/upgrade.php | PHP | oos | 67,947 |
<?php
/**
* WordPress FTP Sockets Filesystem.
*
* @package WordPress
* @subpackage Filesystem
*/
/**
* WordPress Filesystem Class for implementing FTP Sockets.
*
* @since 2.5
* @package WordPress
* @subpackage Filesystem
* @uses WP_Filesystem_Base Extends class
*/
class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
var $ftp = false;
var $errors = null;
var $options = array();
function __construct($opt = '') {
$this->method = 'ftpsockets';
$this->errors = new WP_Error();
//Check if possible to use ftp functions.
if ( ! @include_once ABSPATH . 'wp-admin/includes/class-ftp.php' )
return false;
$this->ftp = new ftp();
//Set defaults:
if ( empty($opt['port']) )
$this->options['port'] = 21;
else
$this->options['port'] = $opt['port'];
if ( empty($opt['hostname']) )
$this->errors->add('empty_hostname', __('FTP hostname is required'));
else
$this->options['hostname'] = $opt['hostname'];
if ( ! empty($opt['base']) )
$this->wp_base = $opt['base'];
// Check if the options provided are OK.
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
$this->options['password'] = $opt['password'];
}
function connect() {
if ( ! $this->ftp )
return false;
$this->ftp->setTimeout(FS_CONNECT_TIMEOUT);
if ( ! $this->ftp->SetServer($this->options['hostname'], $this->options['port']) ) {
$this->errors->add('connect', sprintf(__('Failed to connect to FTP Server %1$s:%2$s'), $this->options['hostname'], $this->options['port']));
return false;
}
if ( ! $this->ftp->connect() ) {
$this->errors->add('connect', sprintf(__('Failed to connect to FTP Server %1$s:%2$s'), $this->options['hostname'], $this->options['port']));
return false;
}
if ( ! $this->ftp->login($this->options['username'], $this->options['password']) ) {
$this->errors->add('auth', sprintf(__('Username/Password incorrect for %s'), $this->options['username']));
return false;
}
$this->ftp->SetType(FTP_AUTOASCII);
$this->ftp->Passive(true);
$this->ftp->setTimeout(FS_TIMEOUT);
return true;
}
function get_contents($file, $type = '', $resumepos = 0) {
if ( ! $this->exists($file) )
return false;
if ( empty($type) )
$type = FTP_AUTOASCII;
$this->ftp->SetType($type);
$temp = wp_tempnam( $file );
if ( ! $temphandle = fopen($temp, 'w+') )
return false;
if ( ! $this->ftp->fget($temphandle, $file) ) {
fclose($temphandle);
unlink($temp);
return ''; //Blank document, File does exist, Its just blank.
}
fseek($temphandle, 0); //Skip back to the start of the file being written to
$contents = '';
while ( ! feof($temphandle) )
$contents .= fread($temphandle, 8192);
fclose($temphandle);
unlink($temp);
return $contents;
}
function get_contents_array($file) {
return explode("\n", $this->get_contents($file) );
}
function put_contents($file, $contents, $mode = false ) {
$temp = wp_tempnam( $file );
if ( ! $temphandle = @fopen($temp, 'w+') ) {
unlink($temp);
return false;
}
fwrite($temphandle, $contents);
fseek($temphandle, 0); //Skip back to the start of the file being written to
$type = $this->is_binary($contents) ? FTP_BINARY : FTP_ASCII;
$this->ftp->SetType($type);
$ret = $this->ftp->fput($file, $temphandle);
fclose($temphandle);
unlink($temp);
$this->chmod($file, $mode);
return $ret;
}
function cwd() {
$cwd = $this->ftp->pwd();
if ( $cwd )
$cwd = trailingslashit($cwd);
return $cwd;
}
function chdir($file) {
return $this->ftp->chdir($file);
}
function chgrp($file, $group, $recursive = false ) {
return false;
}
function chmod($file, $mode = false, $recursive = false ) {
if ( ! $mode ) {
if ( $this->is_file($file) )
$mode = FS_CHMOD_FILE;
elseif ( $this->is_dir($file) )
$mode = FS_CHMOD_DIR;
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);
}
// chmod the file or directory
return $this->ftp->chmod($file, $mode);
}
function chown($file, $owner, $recursive = false ) {
return false;
}
function owner($file) {
$dir = $this->dirlist($file);
return $dir[$file]['owner'];
}
function getchmod($file) {
$dir = $this->dirlist($file);
return $dir[$file]['permsn'];
}
function group($file) {
$dir = $this->dirlist($file);
return $dir[$file]['group'];
}
function copy($source, $destination, $overwrite = false, $mode = false) {
if ( ! $overwrite && $this->exists($destination) )
return false;
$content = $this->get_contents($source);
if ( false === $content )
return false;
return $this->put_contents($destination, $content, $mode);
}
function move($source, $destination, $overwrite = false ) {
return $this->ftp->rename($source, $destination);
}
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);
return $this->ftp->mdel($file);
}
function exists($file) {
return $this->ftp->is_exists($file);
}
function is_file($file) {
if ( $this->is_dir($file) )
return false;
if ( $this->exists($file) )
return true;
return false;
}
function is_dir($path) {
$cwd = $this->cwd();
if ( $this->chdir($path) ) {
$this->chdir($cwd);
return true;
}
return false;
}
function is_readable($file) {
//Get dir list, Check if the file is writable by the current user??
return true;
}
function is_writable($file) {
//Get dir list, Check if the file is writable by the current user??
return true;
}
function atime($file) {
return false;
}
function mtime($file) {
return $this->ftp->mdtm($file);
}
function size($file) {
return $this->ftp->filesize($file);
}
function touch($file, $time = 0, $atime = 0 ) {
return false;
}
function mkdir($path, $chmod = false, $chown = false, $chgrp = false ) {
$path = untrailingslashit($path);
if ( empty($path) )
return false;
if ( ! $this->ftp->mkdir($path) )
return false;
if ( ! $chmod )
$chmod = FS_CHMOD_DIR;
$this->chmod($path, $chmod);
if ( $chown )
$this->chown($path, $chown);
if ( $chgrp )
$this->chgrp($path, $chgrp);
return true;
}
function rmdir($path, $recursive = false ) {
$this->delete($path, $recursive);
}
function dirlist($path = '.', $include_hidden = true, $recursive = false ) {
if ( $this->is_file($path) ) {
$limit_file = basename($path);
$path = dirname($path) . '/';
} else {
$limit_file = false;
}
$list = $this->ftp->dirlist($path);
if ( empty($list) && !$this->exists($path) )
return false;
$ret = array();
foreach ( $list as $struc ) {
if ( '.' == $struc['name'] || '..' == $struc['name'] )
continue;
if ( ! $include_hidden && '.' == $struc['name'][0] )
continue;
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
$struc['files'] = array();
}
$ret[ $struc['name'] ] = $struc;
}
return $ret;
}
function __destruct() {
$this->ftp->quit();
}
}
| 01happy-blog | trunk/myblog/wp-admin/includes/class-wp-filesystem-ftpsockets.php | PHP | oos | 7,680 |
<?php
/**
* Users List Table class.
*
* @package WordPress
* @subpackage List_Table
* @since 3.1.0
* @access private
*/
class WP_Users_List_Table extends WP_List_Table {
var $site_id;
var $is_site_users;
function __construct() {
$screen = get_current_screen();
$this->is_site_users = 'site-users-network' == $screen->id;
if ( $this->is_site_users )
$this->site_id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
parent::__construct( array(
'singular' => 'user',
'plural' => 'users'
) );
}
function ajax_user_can() {
if ( $this->is_site_users )
return current_user_can( 'manage_sites' );
else
return current_user_can( 'list_users' );
}
function prepare_items() {
global $role, $usersearch;
$usersearch = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
$role = isset( $_REQUEST['role'] ) ? $_REQUEST['role'] : '';
$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();
$args = array(
'number' => $users_per_page,
'offset' => ( $paged-1 ) * $users_per_page,
'role' => $role,
'search' => $usersearch,
'fields' => 'all_with_meta'
);
if ( '' !== $args['search'] )
$args['search'] = '*' . $args['search'] . '*';
if ( $this->is_site_users )
$args['blog_id'] = $this->site_id;
if ( isset( $_REQUEST['orderby'] ) )
$args['orderby'] = $_REQUEST['orderby'];
if ( isset( $_REQUEST['order'] ) )
$args['order'] = $_REQUEST['order'];
// Query the user IDs for this page
$wp_user_search = new WP_User_Query( $args );
$this->items = $wp_user_search->get_results();
$this->set_pagination_args( array(
'total_items' => $wp_user_search->get_total(),
'per_page' => $users_per_page,
) );
}
function no_items() {
_e( 'No matching users were found.' );
}
function get_views() {
global $wp_roles, $role;
if ( $this->is_site_users ) {
$url = 'site-users.php?id=' . $this->site_id;
switch_to_blog( $this->site_id );
$users_of_blog = count_users();
restore_current_blog();
} else {
$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);
$current_role = false;
$class = empty($role) ? ' class="current"' : '';
$role_links = array();
$role_links['all'] = "<a href='$url'$class>" . 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]) )
continue;
$class = '';
if ( $this_role == $role ) {
$current_role = $role;
$class = ' class="current"';
}
$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 ) ) . "'$class>$name</a>";
}
return $role_links;
}
function get_bulk_actions() {
$actions = array();
if ( is_multisite() ) {
if ( current_user_can( 'remove_users' ) )
$actions['remove'] = __( 'Remove' );
} else {
if ( current_user_can( 'delete_users' ) )
$actions['delete'] = __( 'Delete' );
}
return $actions;
}
function extra_tablenav( $which ) {
if ( 'top' != $which )
return;
if ( ! current_user_can( 'promote_users' ) )
return;
?>
<div class="alignleft actions">
<label class="screen-reader-text" for="new_role"><?php _e( 'Change role to…' ) ?></label>
<select name="new_role" id="new_role">
<option value=''><?php _e( 'Change role to…' ) ?></option>
<?php wp_dropdown_roles(); ?>
</select>
<?php submit_button( __( 'Change' ), 'secondary', 'changeit', false ); ?>
</div>
<?php
}
function current_action() {
if ( isset($_REQUEST['changeit']) && !empty($_REQUEST['new_role']) )
return 'promote';
return parent::current_action();
}
function get_columns() {
$c = array(
'cb' => '<input type="checkbox" />',
'username' => __( 'Username' ),
'name' => __( 'Name' ),
'email' => __( 'E-mail' ),
'role' => __( 'Role' ),
'posts' => __( 'Posts' )
);
if ( $this->is_site_users )
unset( $c['posts'] );
return $c;
}
function get_sortable_columns() {
$c = array(
'username' => 'login',
'name' => 'name',
'email' => 'email',
);
if ( $this->is_site_users )
unset( $c['posts'] );
return $c;
}
function display_rows() {
// Query the post counts for this page
if ( ! $this->is_site_users )
$post_counts = count_many_users_posts( array_keys( $this->items ) );
$style = '';
foreach ( $this->items as $userid => $user_object ) {
$role = reset( $user_object->roles );
if ( is_multisite() && empty( $role ) )
continue;
$style = ( ' class="alternate"' == $style ) ? '' : ' class="alternate"';
echo "\n\t", $this->single_row( $user_object, $style, $role, isset( $post_counts ) ? $post_counts[ $userid ] : 0 );
}
}
/**
* Generate HTML for a single row on the users.php admin panel.
*
* @since 2.1.0
*
* @param object $user_object
* @param string $style Optional. Attributes added to the TR element. Must be sanitized.
* @param string $role Key for the $wp_roles array.
* @param int $numposts Optional. Post count to display for this user. Defaults to zero, as in, a new user has made zero posts.
* @return string
*/
function single_row( $user_object, $style = '', $role = '', $numposts = 0 ) {
global $wp_roles;
if ( !( is_object( $user_object ) && is_a( $user_object, 'WP_User' ) ) )
$user_object = new WP_User( (int) $user_object );
$user_object->filter = 'display';
$email = $user_object->user_email;
if ( $this->is_site_users )
$url = "site-users.php?id={$this->site_id}&";
else
$url = 'users.php?';
$checkbox = '';
// Check if the user for this row is editable
if ( current_user_can( 'list_users' ) ) {
// Set up the user editing link
// TODO: make profile/user-edit determination a separate function
if ( get_current_user_id() == $user_object->ID ) {
$edit_link = 'profile.php';
} else {
$edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( stripslashes( $_SERVER['REQUEST_URI'] ) ), "user-edit.php?user_id=$user_object->ID" ) );
}
// Set up the hover actions for this user
$actions = array();
if ( current_user_can( 'edit_user', $user_object->ID ) ) {
$edit = "<strong><a href=\"$edit_link\">$user_object->user_login</a></strong><br />";
$actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
} else {
$edit = "<strong>$user_object->user_login</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>";
$actions = apply_filters( 'user_row_actions', $actions, $user_object );
$edit .= $this->row_actions( $actions );
// Set up the checkbox ( because the user is editable, otherwise its empty )
$checkbox = "<input type='checkbox' name='users[]' id='user_{$user_object->ID}' class='$role' value='{$user_object->ID}' />";
} else {
$edit = '<strong>' . $user_object->user_login . '</strong>';
}
$role_name = isset( $wp_roles->role_names[$role] ) ? translate_user_role( $wp_roles->role_names[$role] ) : __( 'None' );
$avatar = get_avatar( $user_object->ID, 32 );
$r = "<tr id='user-$user_object->ID'$style>";
list( $columns, $hidden ) = $this->get_column_info();
foreach ( $columns as $column_name => $column_display_name ) {
$class = "class=\"$column_name column-$column_name\"";
$style = '';
if ( in_array( $column_name, $hidden ) )
$style = ' style="display:none;"';
$attributes = "$class$style";
switch ( $column_name ) {
case 'cb':
$r .= "<th scope='row' class='check-column'>$checkbox</th>";
break;
case 'username':
$r .= "<td $attributes>$avatar $edit</td>";
break;
case 'name':
$r .= "<td $attributes>$user_object->first_name $user_object->last_name</td>";
break;
case 'email':
$r .= "<td $attributes><a href='mailto:$email' title='" . esc_attr( sprintf( __( 'E-mail: %s' ), $email ) ) . "'>$email</a></td>";
break;
case 'role':
$r .= "<td $attributes>$role_name</td>";
break;
case 'posts':
$attributes = 'class="posts column-posts num"' . $style;
$r .= "<td $attributes>";
if ( $numposts > 0 ) {
$r .= "<a href='edit.php?author=$user_object->ID' title='" . esc_attr__( 'View posts by this author' ) . "' class='edit'>";
$r .= $numposts;
$r .= '</a>';
} else {
$r .= 0;
}
$r .= "</td>";
break;
default:
$r .= "<td $attributes>";
$r .= apply_filters( 'manage_users_custom_column', '', $column_name, $user_object->ID );
$r .= "</td>";
}
}
$r .= '</tr>';
return $r;
}
}
| 01happy-blog | trunk/myblog/wp-admin/includes/class-wp-users-list-table.php | PHP | oos | 9,669 |
<?php
/**
* Sites List Table class.
*
* @package WordPress
* @subpackage List_Table
* @since 3.1.0
* @access private
*/
class WP_MS_Sites_List_Table extends WP_List_Table {
function __construct() {
parent::__construct( array(
'plural' => 'sites',
) );
}
function ajax_user_can() {
return current_user_can( 'manage_sites' );
}
function prepare_items() {
global $s, $mode, $wpdb, $current_site;
$mode = ( empty( $_REQUEST['mode'] ) ) ? 'list' : $_REQUEST['mode'];
$per_page = $this->get_items_per_page( 'sites_network_per_page' );
$pagenum = $this->get_pagenum();
$s = isset( $_REQUEST['s'] ) ? stripslashes( trim( $_REQUEST[ 's' ] ) ) : '';
$wild = '';
if ( false !== strpos($s, '*') ) {
$wild = '%';
$s = trim($s, '*');
}
$like_s = esc_sql( like_escape( $s ) );
// If the network is large and a search is not being performed, show only the latest blogs with no paging in order
// to avoid expensive count queries.
if ( !$s && wp_is_large_network() ) {
if ( !isset($_REQUEST['orderby']) )
$_GET['orderby'] = $_REQUEST['orderby'] = '';
if ( !isset($_REQUEST['order']) )
$_GET['order'] = $_REQUEST['order'] = 'DESC';
}
$query = "SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' ";
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
$reg_blog_ids = $wpdb->get_col( "SELECT blog_id FROM {$wpdb->registration_log} WHERE {$wpdb->registration_log}.IP LIKE ( '{$like_s}$wild' )" );
if ( !$reg_blog_ids )
$reg_blog_ids = array( 0 );
$query = "SELECT *
FROM {$wpdb->blogs}
WHERE site_id = '{$wpdb->siteid}'
AND {$wpdb->blogs}.blog_id IN (" . implode( ', ', $reg_blog_ids ) . ")";
} else {
if ( is_numeric($s) && empty( $wild ) ) {
$query .= " AND ( {$wpdb->blogs}.blog_id = '{$like_s}' )";
} elseif ( is_subdomain_install() ) {
$blog_s = str_replace( '.' . $current_site->domain, '', $like_s );
$blog_s .= $wild . '.' . $current_site->domain;
$query .= " AND ( {$wpdb->blogs}.domain LIKE '$blog_s' ) ";
} else {
if ( $like_s != trim('/', $current_site->path) )
$blog_s = $current_site->path . $like_s . $wild . '/';
else
$blog_s = $like_s;
$query .= " AND ( {$wpdb->blogs}.path LIKE '$blog_s' )";
}
}
$order_by = isset( $_REQUEST['orderby'] ) ? $_REQUEST['orderby'] : '';
if ( $order_by == 'registered' ) {
$query .= ' ORDER BY registered ';
} elseif ( $order_by == 'lastupdated' ) {
$query .= ' ORDER BY last_updated ';
} elseif ( $order_by == 'blogname' ) {
if ( is_subdomain_install() )
$query .= ' ORDER BY domain ';
else
$query .= ' ORDER BY path ';
} elseif ( $order_by == 'blog_id' ) {
$query .= ' ORDER BY blog_id ';
} else {
$order_by = null;
}
if ( isset( $order_by ) ) {
$order = ( isset( $_REQUEST['order'] ) && 'DESC' == strtoupper( $_REQUEST['order'] ) ) ? "DESC" : "ASC";
$query .= $order;
}
// Don't do an unbounded count on large networks
if ( ! wp_is_large_network() )
$total = $wpdb->get_var( str_replace( 'SELECT *', 'SELECT COUNT( blog_id )', $query ) );
$query .= " LIMIT " . intval( ( $pagenum - 1 ) * $per_page ) . ", " . intval( $per_page );
$this->items = $wpdb->get_results( $query, ARRAY_A );
if ( wp_is_large_network() )
$total = count($this->items);
$this->set_pagination_args( array(
'total_items' => $total,
'per_page' => $per_page,
) );
}
function no_items() {
_e( 'No sites found.' );
}
function get_bulk_actions() {
$actions = array();
if ( current_user_can( 'delete_sites' ) )
$actions['delete'] = __( 'Delete' );
$actions['spam'] = _x( 'Mark as Spam', 'site' );
$actions['notspam'] = _x( 'Not Spam', 'site' );
return $actions;
}
function pagination( $which ) {
global $mode;
parent::pagination( $which );
if ( 'top' == $which )
$this->view_switcher( $mode );
}
function get_columns() {
$blogname_columns = ( is_subdomain_install() ) ? __( 'Domain' ) : __( 'Path' );
$sites_columns = array(
'cb' => '<input type="checkbox" />',
'blogname' => $blogname_columns,
'lastupdated' => __( 'Last Updated' ),
'registered' => _x( 'Registered', 'site' ),
'users' => __( 'Users' )
);
if ( has_filter( 'wpmublogsaction' ) )
$sites_columns['plugins'] = __( 'Actions' );
$sites_columns = apply_filters( 'wpmu_blogs_columns', $sites_columns );
return $sites_columns;
}
function get_sortable_columns() {
return array(
'blogname' => 'blogname',
'lastupdated' => 'lastupdated',
'registered' => 'blog_id',
);
}
function display_rows() {
global $current_site, $mode;
$status_list = array(
'archived' => array( 'site-archived', __( 'Archived' ) ),
'spam' => array( 'site-spammed', _x( 'Spam', 'site' ) ),
'deleted' => array( 'site-deleted', __( 'Deleted' ) ),
'mature' => array( 'site-mature', __( 'Mature' ) )
);
$class = '';
foreach ( $this->items as $blog ) {
$class = ( 'alternate' == $class ) ? '' : 'alternate';
reset( $status_list );
$blog_states = array();
foreach ( $status_list as $status => $col ) {
if ( get_blog_status( $blog['blog_id'], $status ) == 1 ) {
$class = $col[0];
$blog_states[] = $col[1];
}
}
$blog_state = '';
if ( ! empty( $blog_states ) ) {
$state_count = count( $blog_states );
$i = 0;
$blog_state .= ' - ';
foreach ( $blog_states as $state ) {
++$i;
( $i == $state_count ) ? $sep = '' : $sep = ', ';
$blog_state .= "<span class='post-state'>$state$sep</span>";
}
}
echo "<tr class='$class'>";
$blogname = ( is_subdomain_install() ) ? str_replace( '.'.$current_site->domain, '', $blog['domain'] ) : $blog['path'];
list( $columns, $hidden ) = $this->get_column_info();
foreach ( $columns as $column_name => $column_display_name ) {
$style = '';
if ( in_array( $column_name, $hidden ) )
$style = ' style="display:none;"';
switch ( $column_name ) {
case 'cb': ?>
<th scope="row" class="check-column">
<input type="checkbox" id="blog_<?php echo $blog['blog_id'] ?>" name="allblogs[]" value="<?php echo esc_attr( $blog['blog_id'] ) ?>" />
</th>
<?php
break;
case 'id':?>
<th valign="top" scope="row">
<?php echo $blog['blog_id'] ?>
</th>
<?php
break;
case 'blogname':
echo "<td class='column-$column_name $column_name'$style>"; ?>
<a href="<?php echo esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ); ?>" class="edit"><?php echo $blogname . $blog_state; ?></a>
<?php
if ( 'list' != $mode )
echo '<p>' . sprintf( _x( '%1$s – <em>%2$s</em>', '%1$s: site name. %2$s: site tagline.' ), get_blog_option( $blog['blog_id'], 'blogname' ), get_blog_option( $blog['blog_id'], 'blogdescription ' ) ) . '</p>';
// Preordered.
$actions = array(
'edit' => '', 'backend' => '',
'activate' => '', 'deactivate' => '',
'archive' => '', 'unarchive' => '',
'spam' => '', 'unspam' => '',
'delete' => '',
'visit' => '',
);
$actions['edit'] = '<span class="edit"><a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ) . '">' . __( 'Edit' ) . '</a></span>';
$actions['backend'] = "<span class='backend'><a href='" . esc_url( get_admin_url( $blog['blog_id'] ) ) . "' class='edit'>" . __( 'Dashboard' ) . '</a></span>';
if ( $current_site->blog_id != $blog['blog_id'] ) {
if ( get_blog_status( $blog['blog_id'], 'deleted' ) == '1' )
$actions['activate'] = '<span class="activate"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=activateblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to activate the site %s' ), $blogname ) ) ), 'confirm' ) ) . '">' . __( 'Activate' ) . '</a></span>';
else
$actions['deactivate'] = '<span class="activate"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=deactivateblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to deactivate the site %s' ), $blogname ) ) ), 'confirm') ) . '">' . __( 'Deactivate' ) . '</a></span>';
if ( get_blog_status( $blog['blog_id'], 'archived' ) == '1' )
$actions['unarchive'] = '<span class="archive"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=unarchiveblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to unarchive the site %s.' ), $blogname ) ) ), 'confirm') ) . '">' . __( 'Unarchive' ) . '</a></span>';
else
$actions['archive'] = '<span class="archive"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=archiveblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to archive the site %s.' ), $blogname ) ) ), 'confirm') ) . '">' . _x( 'Archive', 'verb; site' ) . '</a></span>';
if ( get_blog_status( $blog['blog_id'], 'spam' ) == '1' )
$actions['unspam'] = '<span class="spam"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=unspamblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to unspam the site %s.' ), $blogname ) ) ), 'confirm') ) . '">' . _x( 'Not Spam', 'site' ) . '</a></span>';
else
$actions['spam'] = '<span class="spam"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=spamblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to mark the site %s as spam.' ), $blogname ) ) ), 'confirm') ) . '">' . _x( 'Spam', 'site' ) . '</a></span>';
if ( current_user_can( 'delete_site', $blog['blog_id'] ) )
$actions['delete'] = '<span class="delete"><a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=deleteblog&id=' . $blog['blog_id'] . '&msg=' . urlencode( sprintf( __( 'You are about to delete the site %s.' ), $blogname ) ) ), 'confirm') ) . '">' . __( 'Delete' ) . '</a></span>';
}
$actions['visit'] = "<span class='view'><a href='" . esc_url( get_home_url( $blog['blog_id'] ) ) . "' rel='permalink'>" . __( 'Visit' ) . '</a></span>';
$actions = apply_filters( 'manage_sites_action_links', array_filter( $actions ), $blog['blog_id'], $blogname );
echo $this->row_actions( $actions );
?>
</td>
<?php
break;
case 'lastupdated':
echo "<td valign='top' class='$column_name column-$column_name'$style>";
if ( 'list' == $mode )
$date = 'Y/m/d';
else
$date = 'Y/m/d \<\b\r \/\> g:i:s a';
echo ( $blog['last_updated'] == '0000-00-00 00:00:00' ) ? __( 'Never' ) : mysql2date( $date, $blog['last_updated'] ); ?>
</td>
<?php
break;
case 'registered':
echo "<td valign='top' class='$column_name column-$column_name'$style>";
if ( $blog['registered'] == '0000-00-00 00:00:00' )
echo '—';
else
echo mysql2date( $date, $blog['registered'] );
?>
</td>
<?php
break;
case 'users':
echo "<td valign='top' class='$column_name column-$column_name'$style>";
$blogusers = get_users( array( 'blog_id' => $blog['blog_id'], 'number' => 6) );
if ( is_array( $blogusers ) ) {
$blogusers_warning = '';
if ( count( $blogusers ) > 5 ) {
$blogusers = array_slice( $blogusers, 0, 5 );
$blogusers_warning = __( 'Only showing first 5 users.' ) . ' <a href="' . esc_url( network_admin_url( 'site-users.php?id=' . $blog['blog_id'] ) ) . '">' . __( 'More' ) . '</a>';
}
foreach ( $blogusers as $user_object ) {
echo '<a href="' . esc_url( network_admin_url( 'user-edit.php?user_id=' . $user_object->ID ) ) . '">' . esc_html( $user_object->user_login ) . '</a> ';
if ( 'list' != $mode )
echo '( ' . $user_object->user_email . ' )';
echo '<br />';
}
if ( $blogusers_warning != '' )
echo '<strong>' . $blogusers_warning . '</strong><br />';
}
?>
</td>
<?php
break;
case 'plugins': ?>
<?php if ( has_filter( 'wpmublogsaction' ) ) {
echo "<td valign='top' class='$column_name column-$column_name'$style>";
do_action( 'wpmublogsaction', $blog['blog_id'] ); ?>
</td>
<?php }
break;
default:
echo "<td class='$column_name column-$column_name'$style>";
do_action( 'manage_sites_custom_column', $column_name, $blog['blog_id'] );
echo "</td>";
break;
}
}
?>
</tr>
<?php
}
}
}
| 01happy-blog | trunk/myblog/wp-admin/includes/class-wp-ms-sites-list-table.php | PHP | oos | 13,137 |
<?php
/**
* Action handler for Multisite administration panels.
*
* @package WordPress
* @subpackage Multisite
* @since 3.0.0
*/
require_once( './admin.php' );
wp_redirect( network_admin_url() );
exit;
| 01happy-blog | trunk/myblog/wp-admin/ms-edit.php | PHP | oos | 210 |
<?php
/**
* Database Repair and Optimization Script.
*
* @package WordPress
* @subpackage Database
*/
define('WP_REPAIRING', true);
require_once('../../wp-load.php');
header( 'Content-Type: text/html; charset=utf-8' );
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php _e( 'WordPress › Database Repair' ); ?></title>
<?php wp_admin_css( 'install', true ); ?>
</head>
<body>
<h1 id="logo"><img alt="WordPress" src="../images/wordpress-logo.png?ver=20120216" /></h1>
<?php
if ( ! defined( 'WP_ALLOW_REPAIR' ) ) {
echo '<p>' . __( 'To allow use of this page to automatically repair database problems, please add the following line to your <code>wp-config.php</code> file. Once this line is added to your config, reload this page.' ) . "</p><code>define('WP_ALLOW_REPAIR', true);</code>";
} elseif ( isset( $_GET['repair'] ) ) {
$optimize = 2 == $_GET['repair'];
$okay = true;
$problems = array();
$tables = $wpdb->tables();
// Sitecategories may not exist if global terms are disabled.
if ( is_multisite() && ! $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->sitecategories'" ) )
unset( $tables['sitecategories'] );
$tables = array_merge( $tables, (array) apply_filters( 'tables_to_repair', array() ) ); // Return tables with table prefixes.
// Loop over the tables, checking and repairing as needed.
foreach ( $tables as $table ) {
$check = $wpdb->get_row( "CHECK TABLE $table" );
echo '<p>';
if ( 'OK' == $check->Msg_text ) {
/* translators: %s: table name */
printf( __( 'The %s table is okay.' ), "<code>$table</code>" );
} else {
/* translators: 1: table name, 2: error message, */
printf( __( 'The %1$s table is not okay. It is reporting the following error: %2$s. WordPress will attempt to repair this table…' ) , "<code>$table</code>", "<code>$check->Msg_text</code>" );
$repair = $wpdb->get_row( "REPAIR TABLE $table" );
echo '<br /> ';
if ( 'OK' == $check->Msg_text ) {
/* translators: %s: table name */
printf( __( 'Successfully repaired the %s table.' ), "<code>$table</code>" );
} else {
/* translators: 1: table name, 2: error message, */
echo sprintf( __( 'Failed to repair the %1$s table. Error: %2$s' ), "<code>$table</code>", "<code>$check->Msg_text</code>" ) . '<br />';
$problems[$table] = $check->Msg_text;
$okay = false;
}
}
if ( $okay && $optimize ) {
$check = $wpdb->get_row( "ANALYZE TABLE $table" );
echo '<br /> ';
if ( 'Table is already up to date' == $check->Msg_text ) {
/* translators: %s: table name */
printf( __( 'The %s table is already optimized.' ), "<code>$table</code>" );
} else {
$check = $wpdb->get_row( "OPTIMIZE TABLE $table" );
echo '<br /> ';
if ( 'OK' == $check->Msg_text || 'Table is already up to date' == $check->Msg_text ) {
/* translators: %s: table name */
printf( __( 'Successfully optimized the %s table.' ), "<code>$table</code>" );
} else {
/* translators: 1: table name, 2: error message, */
printf( __( 'Failed to optimize the %1$s table. Error: %2$s' ), "<code>$table</code>", "<code>$check->Msg_text</code>" );
}
}
}
echo '</p>';
}
if ( $problems ) {
printf( '<p>' . __('Some database problems could not be repaired. Please copy-and-paste the following list of errors to the <a href="%s">WordPress support forums</a> to get additional assistance.') . '</p>', __( 'http://wordpress.org/support/forum/how-to-and-troubleshooting' ) );
$problem_output = '';
foreach ( $problems as $table => $problem )
$problem_output .= "$table: $problem\n";
echo '<p><textarea name="errors" id="errors" rows="20" cols="60">' . esc_textarea( $problem_output ) . '</textarea></p>';
} else {
echo '<p>' . __( 'Repairs complete. Please remove the following line from wp-config.php to prevent this page from being used by unauthorized users.' ) . "</p><code>define('WP_ALLOW_REPAIR', true);</code>";
}
} else {
if ( isset( $_GET['referrer'] ) && 'is_blog_installed' == $_GET['referrer'] )
echo '<p>' . __( 'One or more database tables are unavailable. To allow WordPress to attempt to repair these tables, press the “Repair Database” button. Repairing can take a while, so please be patient.' ) . '</p>';
else
echo '<p>' . __( 'WordPress can automatically look for some common database problems and repair them. Repairing can take a while, so please be patient.' ) . '</p>';
?>
<p class="step"><a class="button" href="repair.php?repair=1"><?php _e( 'Repair Database' ); ?></a></p>
<p><?php _e( 'WordPress can also attempt to optimize the database. This improves performance in some situations. Repairing and optimizing the database can take a long time and the database will be locked while optimizing.' ); ?></p>
<p class="step"><a class="button" href="repair.php?repair=2"><?php _e( 'Repair and Optimize Database' ); ?></a></p>
<?php
}
?>
</body>
</html>
| 01happy-blog | trunk/myblog/wp-admin/maint/repair.php | PHP | oos | 5,107 |
<?php
/**
* Parse OPML XML files and store in globals.
*
* @package WordPress
* @subpackage Administration
*/
if ( ! defined('ABSPATH') )
die();
global $opml, $map;
// columns we wish to find are: link_url, link_name, link_target, link_description
// we need to map XML attribute names to our columns
$opml_map = array('URL' => 'link_url',
'HTMLURL' => 'link_url',
'TEXT' => 'link_name',
'TITLE' => 'link_name',
'TARGET' => 'link_target',
'DESCRIPTION' => 'link_description',
'XMLURL' => 'link_rss'
);
$map = $opml_map;
/**
* XML callback function for the start of a new XML tag.
*
* @since 0.71
* @access private
*
* @uses $updated_timestamp Not used inside function.
* @uses $all_links Not used inside function.
* @uses $map Stores names of attributes to use.
* @global array $names
* @global array $urls
* @global array $targets
* @global array $descriptions
* @global array $feeds
*
* @param mixed $parser XML Parser resource.
* @param string $tagName XML element name.
* @param array $attrs XML element attributes.
*/
function startElement($parser, $tagName, $attrs) {
global $updated_timestamp, $all_links, $map;
global $names, $urls, $targets, $descriptions, $feeds;
if ($tagName == 'OUTLINE') {
foreach (array_keys($map) as $key) {
if (isset($attrs[$key])) {
$$map[$key] = $attrs[$key];
}
}
//echo("got data: link_url = [$link_url], link_name = [$link_name], link_target = [$link_target], link_description = [$link_description]<br />\n");
// save the data away.
$names[] = $link_name;
$urls[] = $link_url;
$targets[] = $link_target;
$feeds[] = $link_rss;
$descriptions[] = $link_description;
} // end if outline
}
/**
* XML callback function that is called at the end of a XML tag.
*
* @since 0.71
* @access private
* @package WordPress
* @subpackage Dummy
*
* @param mixed $parser XML Parser resource.
* @param string $tagName XML tag name.
*/
function endElement($parser, $tagName) {
// nothing to do.
}
// Create an XML parser
$xml_parser = xml_parser_create();
// Set the functions to handle opening and closing tags
xml_set_element_handler($xml_parser, "startElement", "endElement");
if (!xml_parse($xml_parser, $opml, true)) {
echo(sprintf(__('XML error: %1$s at line %2$s'),
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
}
// Free up memory used by the XML parser
xml_parser_free($xml_parser);
| 01happy-blog | trunk/myblog/wp-admin/link-parse-opml.php | PHP | oos | 2,482 |
<?php
/**
* WordPress Administration Template Footer
*
* @package WordPress
* @subpackage Administration
*/
// don't load directly
if ( !defined('ABSPATH') )
die('-1');
?>
<div class="clear"></div></div><!-- wpbody-content -->
<div class="clear"></div></div><!-- wpbody -->
<div class="clear"></div></div><!-- wpcontent -->
<div id="footer">
<?php do_action( 'in_admin_footer' ); ?>
<p id="footer-left" class="alignleft"><?php
$upgrade = apply_filters( 'update_footer', '' );
$footer_text = array(
'<span id="footer-thankyou">' . __( 'Thank you for creating with <a href="http://wordpress.org/">WordPress</a>.' ) . '</span>',
);
echo apply_filters( 'admin_footer_text', implode( ' • ', $footer_text ) );
unset( $footer_text );
?></p>
<p id="footer-upgrade" class="alignright"><?php echo $upgrade; ?></p>
<div class="clear"></div>
</div>
<?php
do_action('admin_footer', '');
do_action('admin_print_footer_scripts');
do_action("admin_footer-" . $GLOBALS['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') )
compression_test();
}
?>
<div class="clear"></div></div><!-- wpwrap -->
<script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script>
</body>
</html>
| 01happy-blog | trunk/myblog/wp-admin/admin-footer.php | PHP | oos | 1,327 |
<?php
/**
* Multisite upgrade administration panel.
*
* @package WordPress
* @subpackage Multisite
* @since 3.0.0
*/
require_once('admin.php');
wp_redirect( network_admin_url('upgrade.php') );
exit;
| 01happy-blog | trunk/myblog/wp-admin/ms-upgrade-network.php | PHP | oos | 207 |
<?php
/**
* Displays Administration Menu.
*
* @package WordPress
* @subpackage Administration
*/
/**
* The current page.
*
* @global string $self
* @name $self
* @var string
*/
$self = preg_replace('|^.*/wp-admin/network/|i', '', $_SERVER['PHP_SELF']);
$self = preg_replace('|^.*/wp-admin/|i', '', $self);
$self = preg_replace('|^.*/plugins/|i', '', $self);
$self = preg_replace('|^.*/mu-plugins/|i', '', $self);
global $menu, $submenu, $parent_file; //For when admin-header is included from within a function.
$parent_file = apply_filters("parent_file", $parent_file); // For plugins to move submenu tabs around.
get_admin_page_parent();
/**
* Display menu.
*
* @access private
* @since 2.7.0
*
* @param array $menu
* @param array $submenu
* @param bool $submenu_as_parent
*/
function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) {
global $self, $parent_file, $submenu_file, $plugin_page, $pagenow, $typenow;
$first = true;
// 0 = name, 1 = capability, 2 = file, 3 = class, 4 = id, 5 = icon src
foreach ( $menu as $key => $item ) {
$admin_is_parent = false;
$class = array();
$aria_attributes = 'tabindex="1"';
if ( $first ) {
$class[] = 'wp-first-item';
$first = false;
}
$submenu_items = false;
if ( ! empty( $submenu[$item[2]] ) ) {
$class[] = 'wp-has-submenu';
$submenu_items = $submenu[$item[2]];
}
if ( ( $parent_file && $item[2] == $parent_file ) || ( empty($typenow) && $self == $item[2] ) ) {
$class[] = ! empty( $submenu_items ) ? 'wp-has-current-submenu wp-menu-open' : 'current';
} else {
$class[] = 'wp-not-current-submenu';
if ( ! empty( $submenu_items ) )
$aria_attributes .= ' aria-haspopup="true"';
}
if ( ! empty( $item[4] ) )
$class[] = $item[4];
$class = $class ? ' class="' . join( ' ', $class ) . '"' : '';
$id = ! empty( $item[5] ) ? ' id="' . preg_replace( '|[^a-zA-Z0-9_:.]|', '-', $item[5] ) . '"' : '';
$img = '';
if ( ! empty( $item[6] ) )
$img = ( 'div' === $item[6] ) ? '<br />' : '<img src="' . $item[6] . '" alt="" />';
$arrow = '<div class="wp-menu-arrow"><div></div></div>';
$title = wptexturize( $item[0] );
$aria_label = esc_attr( strip_tags( $item[0] ) ); // strip the comment/plugins/updates bubbles spans but keep the pending number if any
echo "\n\t<li$class$id>";
if ( false !== strpos( $class, 'wp-menu-separator' ) ) {
echo '<div class="separator"></div>';
} elseif ( $submenu_as_parent && ! empty( $submenu_items ) ) {
$submenu_items = array_values( $submenu_items ); // Re-index.
$menu_hook = get_plugin_page_hook( $submenu_items[0][2], $item[2] );
$menu_file = $submenu_items[0][2];
if ( false !== ( $pos = strpos( $menu_file, '?' ) ) )
$menu_file = substr( $menu_file, 0, $pos );
if ( ! empty( $menu_hook ) || ( ('index.php' != $submenu_items[0][2]) && file_exists( WP_PLUGIN_DIR . "/$menu_file" ) ) ) {
$admin_is_parent = true;
echo "<div class='wp-menu-image'><a href='admin.php?page={$submenu_items[0][2]}' aria-label='$aria_label'>$img</a></div>$arrow<a href='admin.php?page={$submenu_items[0][2]}'$class $aria_attributes>$title</a>";
} else {
echo "\n\t<div class='wp-menu-image'><a href='{$submenu_items[0][2]}' aria-label='$aria_label'>$img</a></div>$arrow<a href='{$submenu_items[0][2]}'$class $aria_attributes>$title</a>";
}
} elseif ( ! empty( $item[2] ) && current_user_can( $item[1] ) ) {
$menu_hook = get_plugin_page_hook( $item[2], 'admin.php' );
$menu_file = $item[2];
if ( false !== ( $pos = strpos( $menu_file, '?' ) ) )
$menu_file = substr( $menu_file, 0, $pos );
if ( ! empty( $menu_hook ) || ( ('index.php' != $item[2]) && file_exists( WP_PLUGIN_DIR . "/$menu_file" ) ) ) {
$admin_is_parent = true;
echo "\n\t<div class='wp-menu-image'><a href='admin.php?page={$item[2]}' aria-label='$aria_label'>$img</a></div>$arrow<a href='admin.php?page={$item[2]}'$class $aria_attributes>{$item[0]}</a>";
} else {
echo "\n\t<div class='wp-menu-image'><a href='{$item[2]}' aria-label='$aria_label'>$img</a></div>$arrow<a href='{$item[2]}'$class $aria_attributes>{$item[0]}</a>";
}
}
if ( ! empty( $submenu_items ) ) {
echo "\n\t<div class='wp-submenu'><div class='wp-submenu-wrap'>";
echo "<div class='wp-submenu-head'>{$item[0]}</div><ul>";
$first = true;
foreach ( $submenu_items as $sub_key => $sub_item ) {
if ( ! current_user_can( $sub_item[1] ) )
continue;
$aria_attributes = 'tabindex="1"';
$class = array();
if ( $first ) {
$class[] = 'wp-first-item';
$first = false;
}
$menu_file = $item[2];
if ( false !== ( $pos = strpos( $menu_file, '?' ) ) )
$menu_file = substr( $menu_file, 0, $pos );
// Handle current for post_type=post|page|foo pages, which won't match $self.
$self_type = ! empty( $typenow ) ? $self . '?post_type=' . $typenow : 'nothing';
if ( isset( $submenu_file ) ) {
if ( $submenu_file == $sub_item[2] )
$class[] = 'current';
// If plugin_page is set the parent must either match the current page or not physically exist.
// This allows plugin pages with the same hook to exist under different parents.
} else if (
( ! isset( $plugin_page ) && $self == $sub_item[2] ) ||
( isset( $plugin_page ) && $plugin_page == $sub_item[2] && ( $item[2] == $self_type || $item[2] == $self || file_exists($menu_file) === false ) )
) {
$class[] = 'current';
}
$class = $class ? ' class="' . join( ' ', $class ) . '"' : '';
$menu_hook = get_plugin_page_hook($sub_item[2], $item[2]);
$sub_file = $sub_item[2];
if ( false !== ( $pos = strpos( $sub_file, '?' ) ) )
$sub_file = substr($sub_file, 0, $pos);
$title = wptexturize($sub_item[0]);
if ( ! empty( $menu_hook ) || ( ('index.php' != $sub_item[2]) && file_exists( WP_PLUGIN_DIR . "/$sub_file" ) ) ) {
// If admin.php is the current page or if the parent exists as a file in the plugins or admin dir
if ( (!$admin_is_parent && file_exists(WP_PLUGIN_DIR . "/$menu_file") && !is_dir(WP_PLUGIN_DIR . "/{$item[2]}")) || file_exists($menu_file) )
$sub_item_url = add_query_arg( array('page' => $sub_item[2]), $item[2] );
else
$sub_item_url = add_query_arg( array('page' => $sub_item[2]), 'admin.php' );
$sub_item_url = esc_url( $sub_item_url );
echo "<li$class><a href='$sub_item_url'$class $aria_attributes>$title</a></li>";
} else {
echo "<li$class><a href='{$sub_item[2]}'$class $aria_attributes>$title</a></li>";
}
}
echo "</ul></div></div>";
}
echo "</li>";
}
echo '<li id="collapse-menu" class="hide-if-no-js"><div id="collapse-button"><div></div></div>';
echo '<span>' . esc_html__( 'Collapse menu' ) . '</span>';
echo '</li>';
}
?>
<div id="adminmenuback"></div>
<div id="adminmenuwrap">
<div id="adminmenushadow"></div>
<ul id="adminmenu" role="navigation">
<?php
_wp_menu_output( $menu, $submenu );
do_action( 'adminmenu' );
?>
</ul>
</div>
| 01happy-blog | trunk/myblog/wp-admin/menu-header.php | PHP | oos | 6,997 |
<?php
/**
* WordPress Upgrade Functions. Old file, must not be used. Include
* wp-admin/includes/upgrade.php instead.
*
* @deprecated 2.5
* @package WordPress
* @subpackage Administration
*/
_deprecated_file( basename(__FILE__), '2.5', 'wp-admin/includes/upgrade.php' );
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
| 01happy-blog | trunk/myblog/wp-admin/upgrade-functions.php | PHP | oos | 336 |
<?php
/**
* Media settings administration panel.
*
* @package WordPress
* @subpackage Administration
*/
/** WordPress Administration Bootstrap */
require_once('./admin.php');
if ( ! current_user_can( 'manage_options' ) )
wp_die( __( 'You do not have sufficient permissions to manage options for this site.' ) );
$title = __('Media Settings');
$parent_file = 'options-general.php';
$media_options_help = '<p>' . __('You can set maximum sizes for images inserted into your written content; you can also insert an image as Full Size.') . '</p>' .
'<p>' . __('The Embed option allows you embed a video, image, or other media content into your content automatically by typing the URL (of the web page where the file lives) on its own line when you create your content.');
if ( ! empty( $content_width ) )
$media_options_help .= ' ' . __( 'If you do not set the maximum embed size, it will be automatically sized to fit into your content area.' );
$media_options_help .= '</p>';
if ( ! is_multisite() ) {
$media_options_help .= '<p>' . __('Uploading Files allows you to choose the folder and path for storing your uploaded files.') . '</p>';
}
$media_options_help .= '<p>' . __('You must click the Save Changes button at the bottom of the screen for new settings to take effect.') . '</p>';
get_current_screen()->add_help_tab( array(
'id' => 'overview',
'title' => __('Overview'),
'content' => $media_options_help,
) );
get_current_screen()->set_help_sidebar(
'<p><strong>' . __('For more information:') . '</strong></p>' .
'<p>' . __('<a href="http://codex.wordpress.org/Settings_Media_Screen" target="_blank">Documentation on Media Settings</a>') . '</p>' .
'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
);
include('./admin-header.php');
?>
<div class="wrap">
<?php screen_icon(); ?>
<h2><?php echo esc_html( $title ); ?></h2>
<form action="options.php" method="post">
<?php settings_fields('media'); ?>
<h3><?php _e('Image sizes') ?></h3>
<p><?php _e('The sizes listed below determine the maximum dimensions in pixels to use when inserting an image into the body of a post.'); ?></p>
<table class="form-table">
<tr valign="top">
<th scope="row"><?php _e('Thumbnail size') ?></th>
<td>
<label for="thumbnail_size_w"><?php _e('Width'); ?></label>
<input name="thumbnail_size_w" type="number" step="1" min="0" id="thumbnail_size_w" value="<?php form_option('thumbnail_size_w'); ?>" class="small-text" />
<label for="thumbnail_size_h"><?php _e('Height'); ?></label>
<input name="thumbnail_size_h" type="number" step="1" min="0" id="thumbnail_size_h" value="<?php form_option('thumbnail_size_h'); ?>" class="small-text" /><br />
<input name="thumbnail_crop" type="checkbox" id="thumbnail_crop" value="1" <?php checked('1', get_option('thumbnail_crop')); ?>/>
<label for="thumbnail_crop"><?php _e('Crop thumbnail to exact dimensions (normally thumbnails are proportional)'); ?></label>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Medium size') ?></th>
<td><fieldset><legend class="screen-reader-text"><span><?php _e('Medium size'); ?></span></legend>
<label for="medium_size_w"><?php _e('Max Width'); ?></label>
<input name="medium_size_w" type="number" step="1" min="0" id="medium_size_w" value="<?php form_option('medium_size_w'); ?>" class="small-text" />
<label for="medium_size_h"><?php _e('Max Height'); ?></label>
<input name="medium_size_h" type="number" step="1" min="0" id="medium_size_h" value="<?php form_option('medium_size_h'); ?>" class="small-text" />
</fieldset></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Large size') ?></th>
<td><fieldset><legend class="screen-reader-text"><span><?php _e('Large size'); ?></span></legend>
<label for="large_size_w"><?php _e('Max Width'); ?></label>
<input name="large_size_w" type="number" step="1" min="0" id="large_size_w" value="<?php form_option('large_size_w'); ?>" class="small-text" />
<label for="large_size_h"><?php _e('Max Height'); ?></label>
<input name="large_size_h" type="number" step="1" min="0" id="large_size_h" value="<?php form_option('large_size_h'); ?>" class="small-text" />
</fieldset></td>
</tr>
<?php do_settings_fields('media', 'default'); ?>
</table>
<h3><?php _e('Embeds') ?></h3>
<table class="form-table">
<tr valign="top">
<th scope="row"><?php _e('Auto-embeds'); ?></th>
<td><fieldset><legend class="screen-reader-text"><span><?php _e('When possible, embed the media content from a URL directly onto the page. For example: links to Flickr and YouTube.'); ?></span></legend>
<label for="embed_autourls"><input name="embed_autourls" type="checkbox" id="embed_autourls" value="1" <?php checked( '1', get_option('embed_autourls') ); ?>/> <?php _e('When possible, embed the media content from a URL directly onto the page. For example: links to Flickr and YouTube.'); ?></label>
</fieldset></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Maximum embed size') ?></th>
<td>
<label for="embed_size_w"><?php _e('Width'); ?></label>
<input name="embed_size_w" type="number" step="1" min="0" id="embed_size_w" value="<?php form_option('embed_size_w'); ?>" class="small-text" />
<label for="embed_size_h"><?php _e('Height'); ?></label>
<input name="embed_size_h" type="number" step="1" min="0" id="embed_size_h" value="<?php form_option('embed_size_h'); ?>" class="small-text" />
<?php if ( ! empty( $content_width ) )
echo '<p class="description">' . __( 'If the width value is left blank, embeds will default to the max width of your theme.' ) . '</p>';
?>
</td>
</tr>
<?php do_settings_fields('media', 'embeds'); ?>
</table>
<?php if ( !is_multisite() ) : ?>
<h3><?php _e('Uploading Files'); ?></h3>
<table class="form-table">
<tr valign="top">
<th scope="row"><label for="upload_path"><?php _e('Store uploads in this folder'); ?></label></th>
<td><input name="upload_path" type="text" id="upload_path" value="<?php echo esc_attr(get_option('upload_path')); ?>" class="regular-text code" />
<p class="description"><?php _e('Default is <code>wp-content/uploads</code>'); ?></p>
</td>
</tr>
<tr valign="top">
<th scope="row"><label for="upload_url_path"><?php _e('Full URL path to files'); ?></label></th>
<td><input name="upload_url_path" type="text" id="upload_url_path" value="<?php echo esc_attr( get_option('upload_url_path')); ?>" class="regular-text code" />
<p class="description"><?php _e('Configuring this is optional. By default, it should be blank.'); ?></p>
</td>
</tr>
<tr>
<th scope="row" colspan="2" class="th-full">
<label for="uploads_use_yearmonth_folders">
<input name="uploads_use_yearmonth_folders" type="checkbox" id="uploads_use_yearmonth_folders" value="1"<?php checked('1', get_option('uploads_use_yearmonth_folders')); ?> />
<?php _e('Organize my uploads into month- and year-based folders'); ?>
</label>
</th>
</tr>
<?php do_settings_fields('media', 'uploads'); ?>
</table>
<?php endif; ?>
<?php do_settings_sections('media'); ?>
<?php submit_button(); ?>
</form>
</div>
<?php include('./admin-footer.php'); ?>
| 01happy-blog | trunk/myblog/wp-admin/options-media.php | PHP | oos | 7,045 |
<?php
/**
* Edit Tags Administration Screen.
*
* @package WordPress
* @subpackage Administration
*/
/** WordPress Administration Bootstrap */
require_once('./admin.php');
if ( ! $taxnow )
wp_die( __( 'Invalid taxonomy' ) );
$tax = get_taxonomy( $taxnow );
if ( ! $tax )
wp_die( __( 'Invalid taxonomy' ) );
if ( ! current_user_can( $tax->cap->manage_terms ) )
wp_die( __( 'Cheatin’ uh?' ) );
$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 = "edit.php?post_type=$post_type";
$submenu_file = "edit-tags.php?taxonomy=$taxonomy&post_type=$post_type";
} else if ( 'link_category' == $tax->name ) {
$parent_file = 'link-manager.php';
$submenu_file = 'edit-tags.php?taxonomy=link_category';
} else {
$parent_file = 'edit.php';
$submenu_file = "edit-tags.php?taxonomy=$taxonomy";
}
add_screen_option( 'per_page', array('label' => $title, 'default' => 20, 'option' => 'edit_' . $tax->name . '_per_page') );
switch ( $wp_list_table->current_action() ) {
case 'add-tag':
check_admin_referer( 'add-tag', '_wpnonce_add-tag' );
if ( !current_user_can( $tax->cap->edit_terms ) )
wp_die( __( 'Cheatin’ uh?' ) );
$ret = wp_insert_term( $_POST['tag-name'], $taxonomy, $_POST );
$location = 'edit-tags.php?taxonomy=' . $taxonomy;
if ( 'post' != $post_type )
$location .= '&post_type=' . $post_type;
if ( $referer = wp_get_original_referer() ) {
if ( false !== strpos( $referer, 'edit-tags.php' ) )
$location = $referer;
}
if ( $ret && !is_wp_error( $ret ) )
$location = add_query_arg( 'message', 1, $location );
else
$location = add_query_arg( 'message', 4, $location );
wp_redirect( $location );
exit;
break;
case 'delete':
$location = 'edit-tags.php?taxonomy=' . $taxonomy;
if ( 'post' != $post_type )
$location .= '&post_type=' . $post_type;
if ( $referer = wp_get_referer() ) {
if ( false !== strpos( $referer, 'edit-tags.php' ) )
$location = $referer;
}
if ( !isset( $_REQUEST['tag_ID'] ) ) {
wp_redirect( $location );
exit;
}
$tag_ID = (int) $_REQUEST['tag_ID'];
check_admin_referer( 'delete-tag_' . $tag_ID );
if ( !current_user_can( $tax->cap->delete_terms ) )
wp_die( __( 'Cheatin’ uh?' ) );
wp_delete_term( $tag_ID, $taxonomy );
$location = add_query_arg( 'message', 2, $location );
wp_redirect( $location );
exit;
break;
case 'bulk-delete':
check_admin_referer( 'bulk-tags' );
if ( !current_user_can( $tax->cap->delete_terms ) )
wp_die( __( 'Cheatin’ uh?' ) );
$tags = (array) $_REQUEST['delete_tags'];
foreach ( $tags as $tag_ID ) {
wp_delete_term( $tag_ID, $taxonomy );
}
$location = 'edit-tags.php?taxonomy=' . $taxonomy;
if ( 'post' != $post_type )
$location .= '&post_type=' . $post_type;
if ( $referer = wp_get_referer() ) {
if ( false !== strpos( $referer, 'edit-tags.php' ) )
$location = $referer;
}
$location = add_query_arg( 'message', 6, $location );
wp_redirect( $location );
exit;
break;
case 'edit':
$title = $tax->labels->edit_item;
$tag_ID = (int) $_REQUEST['tag_ID'];
$tag = get_term( $tag_ID, $taxonomy, OBJECT, 'edit' );
if ( ! $tag )
wp_die( __( 'You attempted to edit an item that doesn’t exist. Perhaps it was deleted?' ) );
require_once ( 'admin-header.php' );
include( './edit-tag-form.php' );
break;
case 'editedtag':
$tag_ID = (int) $_POST['tag_ID'];
check_admin_referer( 'update-tag_' . $tag_ID );
if ( !current_user_can( $tax->cap->edit_terms ) )
wp_die( __( 'Cheatin’ uh?' ) );
$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 );
$location = 'edit-tags.php?taxonomy=' . $taxonomy;
if ( 'post' != $post_type )
$location .= '&post_type=' . $post_type;
if ( $referer = wp_get_original_referer() ) {
if ( false !== strpos( $referer, 'edit-tags.php' ) )
$location = $referer;
}
if ( $ret && !is_wp_error( $ret ) )
$location = add_query_arg( 'message', 3, $location );
else
$location = add_query_arg( 'message', 5, $location );
wp_redirect( $location );
exit;
break;
default:
if ( ! empty($_REQUEST['_wp_http_referer']) ) {
$location = remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) );
if ( ! empty( $_REQUEST['paged'] ) )
$location = add_query_arg( 'paged', (int) $_REQUEST['paged'] );
wp_redirect( $location );
exit;
}
$wp_list_table->prepare_items();
$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
if ( $pagenum > $total_pages && $total_pages > 0 ) {
wp_redirect( add_query_arg( 'paged', $total_pages ) );
exit;
}
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 )
$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
$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 )
$help .= '<p>' . __( 'You can delete Link Categories in the Bulk Action pulldown, 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>';
get_current_screen()->add_help_tab( array(
'id' => 'overview',
'title' => __('Overview'),
'content' => $help,
) );
if ( 'category' == $taxonomy || 'post_tag' == $taxonomy ) {
if ( 'category' == $taxonomy )
$help = '<p>' . __( 'When adding a new category on this screen, you’ll fill in the following fields:' ) . '</p>';
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() )
$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 )
$help .= '<li>' . __( '<strong>Parent</strong> - 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. 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,
) );
}
$help = '<p><strong>' . __( 'For more information:' ) . '</strong></p>';
if ( 'category' == $taxonomy )
$help .= '<p>' . __( '<a href="http://codex.wordpress.org/Posts_Categories_Screen" target="_blank">Documentation on Categories</a>' ) . '</p>';
elseif ( 'link_category' == $taxonomy )
$help .= '<p>' . __( '<a href="http://codex.wordpress.org/Links_Link_Categories_Screen" target="_blank">Documentation on Link Categories</a>' ) . '</p>';
else
$help .= '<p>' . __( '<a href="http://codex.wordpress.org/Posts_Tags_Screen" target="_blank">Documentation on Tags</a>' ) . '</p>';
$help .= '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>';
get_current_screen()->set_help_sidebar( $help );
unset( $help );
}
require_once ('admin-header.php');
if ( !current_user_can($tax->cap->edit_terms) )
wp_die( __('You are not allowed to edit this item.') );
$messages[1] = __('Item added.');
$messages[2] = __('Item deleted.');
$messages[3] = __('Item updated.');
$messages[4] = __('Item not added.');
$messages[5] = __('Item not updated.');
$messages[6] = __('Items deleted.');
?>
<div class="wrap nosubsub">
<?php screen_icon(); ?>
<h2><?php echo esc_html( $title );
if ( !empty($_REQUEST['s']) )
printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( stripslashes($_REQUEST['s']) ) ); ?>
</h2>
<?php if ( isset($_REQUEST['message']) && ( $msg = (int) $_REQUEST['message'] ) ) : ?>
<div id="message" class="updated"><p><?php echo $messages[$msg]; ?></p></div>
<?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']);
endif; ?>
<div id="ajax-response"></div>
<form class="search-form" action="" 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); ?>" />
<?php $wp_list_table->search_box( $tax->labels->search_items, 'tag' ); ?>
</form>
<br class="clear" />
<div id="col-container">
<div id="col-right">
<div class="col-wrap">
<form id="posts-filter" action="" method="post">
<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->display(); ?>
<br class="clear" />
</form>
<?php if ( 'category' == $taxonomy ) : ?>
<div class="form-wrap">
<p><?php printf(__('<strong>Note:</strong><br />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 <strong>%s</strong>.'), apply_filters('the_category', get_cat_name(get_option('default_category')))) ?></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>.'), 'import.php') ?></p>
<?php endif; ?>
</div>
<?php elseif ( 'post_tag' == $taxonomy && current_user_can( 'import' ) ) : ?>
<div class="form-wrap">
<p><?php printf(__('Tags can be selectively converted to categories using the <a href="%s">tag to category converter</a>'), 'import.php') ;?>.</p>
</div>
<?php endif;
do_action('after-' . $taxonomy . '-table', $taxonomy);
?>
</div>
</div><!-- /col-right -->
<div id="col-left">
<div class="col-wrap">
<?php
if ( !is_null( $tax->labels->popular_items ) ) {
if ( current_user_can( $tax->cap->edit_terms ) )
$tag_cloud = wp_tag_cloud( array( 'taxonomy' => $taxonomy, 'echo' => false, 'link' => 'edit' ) );
else
$tag_cloud = wp_tag_cloud( array( 'taxonomy' => $taxonomy, 'echo' => false ) );
if ( $tag_cloud ) :
?>
<div class="tagcloud">
<h3><?php echo $tax->labels->popular_items; ?></h3>
<?php echo $tag_cloud; unset( $tag_cloud ); ?>
</div>
<?php
endif;
}
if ( current_user_can($tax->cap->edit_terms) ) {
// Back compat hooks. Deprecated in preference to {$taxonomy}_pre_add_form
if ( 'category' == $taxonomy )
do_action('add_category_form_pre', (object)array('parent' => 0) );
elseif ( 'link_category' == $taxonomy )
do_action('add_link_category_form_pre', (object)array('parent' => 0) );
else
do_action('add_tag_form_pre', $taxonomy);
do_action($taxonomy . '_pre_add_form', $taxonomy);
?>
<div class="form-wrap">
<h3><?php echo $tax->labels->add_new_item; ?></h3>
<form id="addtag" method="post" action="edit-tags.php" class="validate">
<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'); ?>
<div class="form-field form-required">
<label for="tag-name"><?php _ex('Name', 'Taxonomy 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>
</div>
<?php if ( ! global_terms_enabled() ) : ?>
<div class="form-field">
<label for="tag-slug"><?php _ex('Slug', 'Taxonomy 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>
</div>
<?php endif; // global_terms_enabled() ?>
<?php if ( is_taxonomy_hierarchical($taxonomy) ) : ?>
<div class="form-field">
<label for="parent"><?php _ex('Parent', 'Taxonomy Parent'); ?></label>
<?php wp_dropdown_categories(array('hide_empty' => 0, 'hide_if_empty' => false, 'taxonomy' => $taxonomy, 'name' => 'parent', 'orderby' => 'name', 'hierarchical' => true, 'show_option_none' => __('None'))); ?>
<?php if ( 'category' == $taxonomy ) : // @todo: Generic text for hierarchical taxonomies ?>
<p><?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 endif; ?>
</div>
<?php endif; // is_taxonomy_hierarchical() ?>
<div class="form-field">
<label for="tag-description"><?php _ex('Description', 'Taxonomy 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>
</div>
<?php
if ( ! is_taxonomy_hierarchical($taxonomy) )
do_action('add_tag_form_fields', $taxonomy);
do_action($taxonomy . '_add_form_fields', $taxonomy);
submit_button( $tax->labels->add_new_item, 'button' );
// Back compat hooks. Deprecated in preference to {$taxonomy}_add_form
if ( 'category' == $taxonomy )
do_action('edit_category_form', (object)array('parent' => 0) );
elseif ( 'link_category' == $taxonomy )
do_action('edit_link_category_form', (object)array('parent' => 0) );
else
do_action('add_tag_form', $taxonomy);
do_action($taxonomy . '_add_form', $taxonomy);
?>
</form></div>
<?php } ?>
</div>
</div><!-- /col-left -->
</div><!-- /col-container -->
</div><!-- /wrap -->
<?php $wp_list_table->inline_edit(); ?>
<?php
break;
}
include('./admin-footer.php');
| 01happy-blog | trunk/myblog/wp-admin/edit-tags.php | PHP | oos | 15,479 |
<?php
/**
* Plugins administration panel.
*
* @package WordPress
* @subpackage Administration
*/
/** WordPress Administration Bootstrap */
require_once('./admin.php');
if ( is_multisite() ) {
$menu_perms = get_site_option( 'menu_items', array() );
if ( empty( $menu_perms['plugins'] ) && ! current_user_can( 'manage_network_plugins' ) )
wp_die( __( 'Cheatin’ uh?' ) );
}
if ( !current_user_can('activate_plugins') )
wp_die( __( 'You do not have sufficient permissions to manage plugins for this site.' ) );
$wp_list_table = _get_list_table('WP_Plugins_List_Table');
$pagenum = $wp_list_table->get_pagenum();
$action = $wp_list_table->current_action();
$plugin = isset($_REQUEST['plugin']) ? $_REQUEST['plugin'] : '';
$s = isset($_REQUEST['s']) ? urlencode($_REQUEST['s']) : '';
// Clean up request URI from temporary args for screen options/paging uri's to work as expected.
$_SERVER['REQUEST_URI'] = remove_query_arg(array('error', 'deleted', 'activate', 'activate-multi', 'deactivate', 'deactivate-multi', '_error_nonce'), $_SERVER['REQUEST_URI']);
if ( $action ) {
switch ( $action ) {
case 'activate':
if ( ! current_user_can('activate_plugins') )
wp_die(__('You do not have sufficient permissions to activate plugins for this site.'));
check_admin_referer('activate-plugin_' . $plugin);
$result = activate_plugin($plugin, self_admin_url('plugins.php?error=true&plugin=' . $plugin), is_network_admin() );
if ( is_wp_error( $result ) ) {
if ( 'unexpected_output' == $result->get_error_code() ) {
$redirect = self_admin_url('plugins.php?error=true&charsout=' . strlen($result->get_error_data()) . '&plugin=' . $plugin . "&plugin_status=$status&paged=$page&s=$s");
wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), $redirect));
exit;
} else {
wp_die($result);
}
}
if ( ! is_network_admin() ) {
$recent = (array) get_option( 'recently_activated' );
unset( $recent[ $plugin ] );
update_option( 'recently_activated', $recent );
}
if ( isset($_GET['from']) && 'import' == $_GET['from'] ) {
wp_redirect( self_admin_url("import.php?import=" . str_replace('-importer', '', dirname($plugin))) ); // overrides the ?error=true one above and redirects to the Imports page, stripping the -importer suffix
} else {
wp_redirect( self_admin_url("plugins.php?activate=true&plugin_status=$status&paged=$page&s=$s") ); // overrides the ?error=true one above
}
exit;
break;
case 'activate-selected':
if ( ! current_user_can('activate_plugins') )
wp_die(__('You do not have sufficient permissions to activate plugins for this site.'));
check_admin_referer('bulk-plugins');
$plugins = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
// Only activate plugins which are not already active.
$check = is_network_admin() ? 'is_plugin_active_for_network' : 'is_plugin_active';
foreach ( $plugins as $i => $plugin )
if ( $check( $plugin ) )
unset( $plugins[ $i ] );
if ( empty($plugins) ) {
wp_redirect( self_admin_url("plugins.php?plugin_status=$status&paged=$page&s=$s") );
exit;
}
activate_plugins($plugins, self_admin_url('plugins.php?error=true'), is_network_admin() );
if ( ! is_network_admin() ) {
$recent = (array) get_option('recently_activated' );
foreach ( $plugins as $plugin )
unset( $recent[ $plugin ] );
update_option( 'recently_activated', $recent );
}
wp_redirect( self_admin_url("plugins.php?activate-multi=true&plugin_status=$status&paged=$page&s=$s") );
exit;
break;
case 'update-selected' :
check_admin_referer( 'bulk-plugins' );
if ( isset( $_GET['plugins'] ) )
$plugins = explode( ',', $_GET['plugins'] );
elseif ( isset( $_POST['checked'] ) )
$plugins = (array) $_POST['checked'];
else
$plugins = array();
$title = __( 'Update Plugins' );
$parent_file = 'plugins.php';
require_once(ABSPATH . 'wp-admin/admin-header.php');
echo '<div class="wrap">';
screen_icon();
echo '<h2>' . esc_html( $title ) . '</h2>';
$url = self_admin_url('update.php?action=update-selected&plugins=' . urlencode( join(',', $plugins) ));
$url = wp_nonce_url($url, 'bulk-update-plugins');
echo "<iframe src='$url' style='width: 100%; height:100%; min-height:850px;'></iframe>";
echo '</div>';
require_once(ABSPATH . 'wp-admin/admin-footer.php');
exit;
break;
case 'error_scrape':
if ( ! current_user_can('activate_plugins') )
wp_die(__('You do not have sufficient permissions to activate plugins for this site.'));
check_admin_referer('plugin-activation-error_' . $plugin);
$valid = validate_plugin($plugin);
if ( is_wp_error($valid) )
wp_die($valid);
if ( ! WP_DEBUG ) {
error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR );
}
@ini_set('display_errors', true); //Ensure that Fatal errors are displayed.
// Go back to "sandbox" scope so we get the same errors as before
function plugin_sandbox_scrape( $plugin ) {
include( WP_PLUGIN_DIR . '/' . $plugin );
}
plugin_sandbox_scrape( $plugin );
do_action('activate_' . $plugin);
exit;
break;
case 'deactivate':
if ( ! current_user_can('activate_plugins') )
wp_die(__('You do not have sufficient permissions to deactivate plugins for this site.'));
check_admin_referer('deactivate-plugin_' . $plugin);
if ( ! is_network_admin() && is_plugin_active_for_network( $plugin ) ) {
wp_redirect( self_admin_url("plugins.php?plugin_status=$status&paged=$page&s=$s") );
exit;
}
deactivate_plugins( $plugin, false, is_network_admin() );
if ( ! is_network_admin() )
update_option( 'recently_activated', array( $plugin => time() ) + (array) get_option( 'recently_activated' ) );
if ( headers_sent() )
echo "<meta http-equiv='refresh' content='" . esc_attr( "0;url=plugins.php?deactivate=true&plugin_status=$status&paged=$page&s=$s" ) . "' />";
else
wp_redirect( self_admin_url("plugins.php?deactivate=true&plugin_status=$status&paged=$page&s=$s") );
exit;
break;
case 'deactivate-selected':
if ( ! current_user_can('activate_plugins') )
wp_die(__('You do not have sufficient permissions to deactivate plugins for this site.'));
check_admin_referer('bulk-plugins');
$plugins = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
// Do not deactivate plugins which are already deactivated.
if ( is_network_admin() ) {
$plugins = array_filter( $plugins, 'is_plugin_active_for_network' );
} else {
$plugins = array_filter( $plugins, 'is_plugin_active' );
$plugins = array_diff( $plugins, array_filter( $plugins, 'is_plugin_active_for_network' ) );
}
if ( empty($plugins) ) {
wp_redirect( self_admin_url("plugins.php?plugin_status=$status&paged=$page&s=$s") );
exit;
}
deactivate_plugins( $plugins, false, is_network_admin() );
if ( ! is_network_admin() ) {
$deactivated = array();
foreach ( $plugins as $plugin )
$deactivated[ $plugin ] = time();
update_option( 'recently_activated', $deactivated + (array) get_option( 'recently_activated' ) );
}
wp_redirect( self_admin_url("plugins.php?deactivate-multi=true&plugin_status=$status&paged=$page&s=$s") );
exit;
break;
case 'delete-selected':
if ( ! current_user_can('delete_plugins') )
wp_die(__('You do not have sufficient permissions to delete plugins for this site.'));
check_admin_referer('bulk-plugins');
//$_POST = from the plugin form; $_GET = from the FTP details screen.
$plugins = isset( $_REQUEST['checked'] ) ? (array) $_REQUEST['checked'] : array();
if ( empty( $plugins ) ) {
wp_redirect( self_admin_url("plugins.php?plugin_status=$status&paged=$page&s=$s") );
exit;
}
$plugins = array_filter($plugins, 'is_plugin_inactive'); // Do not allow to delete Activated plugins.
if ( empty( $plugins ) ) {
wp_redirect( self_admin_url( "plugins.php?error=true&main=true&plugin_status=$status&paged=$page&s=$s" ) );
exit;
}
include(ABSPATH . 'wp-admin/update.php');
$parent_file = 'plugins.php';
if ( ! isset($_REQUEST['verify-delete']) ) {
wp_enqueue_script('jquery');
require_once(ABSPATH . 'wp-admin/admin-header.php');
?>
<div class="wrap">
<?php
$files_to_delete = $plugin_info = array();
$have_non_network_plugins = false;
foreach ( (array) $plugins as $plugin ) {
if ( '.' == dirname($plugin) ) {
$files_to_delete[] = WP_PLUGIN_DIR . '/' . $plugin;
if( $data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin) ) {
$plugin_info[ $plugin ] = $data;
$plugin_info[ $plugin ]['is_uninstallable'] = is_uninstallable_plugin( $plugin );
if ( ! $plugin_info[ $plugin ]['Network'] )
$have_non_network_plugins = true;
}
} else {
// Locate all the files in that folder
$files = list_files( WP_PLUGIN_DIR . '/' . dirname($plugin) );
if ( $files ) {
$files_to_delete = array_merge($files_to_delete, $files);
}
// Get plugins list from that folder
if ( $folder_plugins = get_plugins( '/' . dirname($plugin)) ) {
foreach( $folder_plugins as $plugin_file => $data ) {
$plugin_info[ $plugin_file ] = _get_plugin_data_markup_translate( $plugin_file, $data );
$plugin_info[ $plugin_file ]['is_uninstallable'] = is_uninstallable_plugin( $plugin );
if ( ! $plugin_info[ $plugin_file ]['Network'] )
$have_non_network_plugins = true;
}
}
}
}
screen_icon();
$plugins_to_delete = count( $plugin_info );
echo '<h2>' . _n( 'Delete Plugin', 'Delete Plugins', $plugins_to_delete ) . '</h2>';
?>
<?php if ( $have_non_network_plugins && is_network_admin() ) : ?>
<div class="error"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php echo _n( 'This plugin may be active on other sites in the network.', 'These plugins may be active on other sites in the network.', $plugins_to_delete ); ?></p></div>
<?php endif; ?>
<p><?php echo _n( 'You are about to remove the following plugin:', 'You are about to remove the following plugins:', $plugins_to_delete ); ?></p>
<ul class="ul-disc">
<?php
$data_to_delete = false;
foreach ( $plugin_info as $plugin ) {
if ( $plugin['is_uninstallable'] ) {
/* translators: 1: plugin name, 2: plugin author */
echo '<li>', sprintf( __( '<strong>%1$s</strong> by <em>%2$s</em> (will also <strong>delete its data</strong>)' ), esc_html($plugin['Name']), esc_html($plugin['AuthorName']) ), '</li>';
$data_to_delete = true;
} else {
/* translators: 1: plugin name, 2: plugin author */
echo '<li>', sprintf( __('<strong>%1$s</strong> by <em>%2$s</em>' ), esc_html($plugin['Name']), esc_html($plugin['AuthorName']) ), '</li>';
}
}
?>
</ul>
<p><?php
if ( $data_to_delete )
_e('Are you sure you wish to delete these files and data?');
else
_e('Are you sure you wish to delete these files?');
?></p>
<form method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>" style="display:inline;">
<input type="hidden" name="verify-delete" value="1" />
<input type="hidden" name="action" value="delete-selected" />
<?php
foreach ( (array) $plugins as $plugin )
echo '<input type="hidden" name="checked[]" value="' . esc_attr($plugin) . '" />';
?>
<?php wp_nonce_field('bulk-plugins') ?>
<?php submit_button( $data_to_delete ? __( 'Yes, Delete these files and data' ) : __( 'Yes, Delete these files' ), 'button', 'submit', false ); ?>
</form>
<form method="post" action="<?php echo esc_url(wp_get_referer()); ?>" style="display:inline;">
<?php submit_button( __( 'No, Return me to the plugin list' ), 'button', 'submit', false ); ?>
</form>
<p><a href="#" onclick="jQuery('#files-list').toggle(); return false;"><?php _e('Click to view entire list of files which will be deleted'); ?></a></p>
<div id="files-list" style="display:none;">
<ul class="code">
<?php
foreach ( (array)$files_to_delete as $file )
echo '<li>' . esc_html(str_replace(WP_PLUGIN_DIR, '', $file)) . '</li>';
?>
</ul>
</div>
</div>
<?php
require_once(ABSPATH . 'wp-admin/admin-footer.php');
exit;
} //Endif verify-delete
$delete_result = delete_plugins($plugins);
set_transient('plugins_delete_result_' . $user_ID, $delete_result); //Store the result in a cache rather than a URL param due to object type & length
wp_redirect( self_admin_url("plugins.php?deleted=true&plugin_status=$status&paged=$page&s=$s") );
exit;
break;
case 'clear-recent-list':
if ( ! is_network_admin() )
update_option( 'recently_activated', array() );
break;
}
}
$wp_list_table->prepare_items();
wp_enqueue_script('plugin-install');
add_thickbox();
add_screen_option( 'per_page', array('label' => _x( 'Plugins', 'plugins per page (screen options)' ), 'default' => 999 ) );
get_current_screen()->add_help_tab( array(
'id' => 'overview',
'title' => __('Overview'),
'content' =>
'<p>' . __('Plugins extend and expand the functionality of WordPress. Once a plugin is installed, you may activate it or deactivate it here.') . '</p>' .
'<p>' . sprintf(__('You can find additional plugins for your site by using the <a href="%1$s">Plugin Browser/Installer</a> functionality or by browsing the <a href="%2$s" target="_blank">WordPress Plugin Directory</a> directly and installing new plugins manually. To manually install a plugin you generally just need to upload the plugin file into your <code>/wp-content/plugins</code> directory. Once a plugin has been installed, you can activate it here.'), 'plugin-install.php', 'http://wordpress.org/extend/plugins/') . '</p>'
) );
get_current_screen()->add_help_tab( array(
'id' => 'compatibility-problems',
'title' => __('Troubleshooting'),
'content' =>
'<p>' . __('Most of the time, plugins play nicely with the core of WordPress and with other plugins. Sometimes, though, a plugin’s code will get in the way of another plugin, causing compatibility issues. If your site starts doing strange things, this may be the problem. Try deactivating all your plugins and re-activating them in various combinations until you isolate which one(s) caused the issue.') . '</p>' .
'<p>' . sprintf( __('If something goes wrong with a plugin and you can’t use WordPress, delete or rename that file in the <code>%s</code> directory and it will be automatically deactivated.'), WP_PLUGIN_DIR) . '</p>'
) );
get_current_screen()->set_help_sidebar(
'<p><strong>' . __('For more information:') . '</strong></p>' .
'<p>' . __('<a href="http://codex.wordpress.org/Managing_Plugins#Plugin_Management" target="_blank">Documentation on Managing Plugins</a>') . '</p>' .
'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
);
$title = __('Plugins');
$parent_file = 'plugins.php';
require_once(ABSPATH . 'wp-admin/admin-header.php');
$invalid = validate_active_plugins();
if ( !empty($invalid) )
foreach ( $invalid as $plugin_file => $error )
echo '<div id="message" class="error"><p>' . sprintf(__('The plugin <code>%s</code> has been <strong>deactivated</strong> due to an error: %s'), esc_html($plugin_file), $error->get_error_message()) . '</p></div>';
?>
<?php if ( isset($_GET['error']) ) :
if ( isset( $_GET['main'] ) )
$errmsg = __( 'You cannot delete a plugin while it is active on the main site.' );
elseif ( isset($_GET['charsout']) )
$errmsg = sprintf(__('The plugin generated %d characters of <strong>unexpected output</strong> during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.'), $_GET['charsout']);
else
$errmsg = __('Plugin could not be activated because it triggered a <strong>fatal error</strong>.');
?>
<div id="message" class="updated"><p><?php echo $errmsg; ?></p>
<?php
if ( !isset( $_GET['main'] ) && !isset($_GET['charsout']) && wp_verify_nonce($_GET['_error_nonce'], 'plugin-activation-error_' . $plugin) ) { ?>
<iframe style="border:0" width="100%" height="70px" src="<?php echo 'plugins.php?action=error_scrape&plugin=' . esc_attr($plugin) . '&_wpnonce=' . esc_attr($_GET['_error_nonce']); ?>"></iframe>
<?php
}
?>
</div>
<?php elseif ( isset($_GET['deleted']) ) :
$delete_result = get_transient('plugins_delete_result_'.$user_ID);
delete_transient('plugins_delete_result'); //Delete it once we're done.
if ( is_wp_error($delete_result) ) : ?>
<div id="message" class="updated"><p><?php printf( __('Plugin could not be deleted due to an error: %s'), $delete_result->get_error_message() ); ?></p></div>
<?php else : ?>
<div id="message" class="updated"><p><?php _e('The selected plugins have been <strong>deleted</strong>.'); ?></p></div>
<?php endif; ?>
<?php elseif ( isset($_GET['activate']) ) : ?>
<div id="message" class="updated"><p><?php _e('Plugin <strong>activated</strong>.') ?></p></div>
<?php elseif (isset($_GET['activate-multi'])) : ?>
<div id="message" class="updated"><p><?php _e('Selected plugins <strong>activated</strong>.'); ?></p></div>
<?php elseif ( isset($_GET['deactivate']) ) : ?>
<div id="message" class="updated"><p><?php _e('Plugin <strong>deactivated</strong>.') ?></p></div>
<?php elseif (isset($_GET['deactivate-multi'])) : ?>
<div id="message" class="updated"><p><?php _e('Selected plugins <strong>deactivated</strong>.'); ?></p></div>
<?php elseif ( 'update-selected' == $action ) : ?>
<div id="message" class="updated"><p><?php _e('No out of date plugins were selected.'); ?></p></div>
<?php endif; ?>
<div class="wrap">
<?php screen_icon(); ?>
<h2><?php echo esc_html( $title );
if ( ( ! is_multisite() || is_network_admin() ) && current_user_can('install_plugins') ) { ?>
<a href="<?php echo self_admin_url( 'plugin-install.php' ); ?>" class="add-new-h2"><?php echo esc_html_x('Add New', 'plugin'); ?></a>
<?php }
if ( $s )
printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( $s ) ); ?>
</h2>
<?php do_action( 'pre_current_active_plugins', $plugins['all'] ) ?>
<?php $wp_list_table->views(); ?>
<form method="get" action="">
<?php $wp_list_table->search_box( __( 'Search Installed Plugins' ), 'plugin' ); ?>
</form>
<form method="post" action="">
<input type="hidden" name="plugin_status" value="<?php echo esc_attr($status) ?>" />
<input type="hidden" name="paged" value="<?php echo esc_attr($page) ?>" />
<?php $wp_list_table->display(); ?>
</form>
</div>
<?php
include(ABSPATH . 'wp-admin/admin-footer.php');
| 01happy-blog | trunk/myblog/wp-admin/plugins.php | PHP | oos | 18,979 |
<?php
/**
* WordPress AJAX Process Execution.
*
* @package WordPress
* @subpackage Administration
*
* @link http://codex.wordpress.org/AJAX_in_Plugins
*/
/**
* Executing AJAX process.
*
* @since 2.1.0
*/
define( 'DOING_AJAX', true );
define( 'WP_ADMIN', true );
// Require an action parameter
if ( empty( $_REQUEST['action'] ) )
die( '0' );
/** Load WordPress Bootstrap */
require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );
/** Load WordPress Administration APIs */
require_once( ABSPATH . 'wp-admin/includes/admin.php' );
/** Load Ajax Handlers for WordPress Core */
require_once( ABSPATH . 'wp-admin/includes/ajax-actions.php' );
@header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
@header( 'X-Robots-Tag: noindex' );
send_nosniff_header();
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',
);
$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', 'autosave', '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', 'set-post-thumbnail', 'date_format', 'time_format', 'wp-fullscreen-save-post',
'wp-remove-post-lock', 'dismiss-wp-pointer', 'upload-attachment',
);
// Register core Ajax calls.
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 ) )
add_action( 'wp_ajax_' . $_POST['action'], 'wp_ajax_' . str_replace( '-', '_', $_POST['action'] ), 1 );
add_action( 'wp_ajax_nopriv_autosave', 'wp_ajax_nopriv_autosave', 1 );
if ( is_user_logged_in() )
do_action( 'wp_ajax_' . $_REQUEST['action'] ); // Authenticated actions
else
do_action( 'wp_ajax_nopriv_' . $_REQUEST['action'] ); // Non-admin actions
// Default status
die( '0' );
| 01happy-blog | trunk/myblog/wp-admin/admin-ajax.php | PHP | oos | 2,489 |
<?php
/**
* Upload new media Administration Screen.
*
* @package WordPress
* @subpackage Administration
*/
$_GET['inline'] = 'true';
/** Administration bootstrap */
require_once('./admin.php');
require_once('./media-upload.php');
| 01happy-blog | trunk/myblog/wp-admin/media-new.php | PHP | oos | 236 |
<?php
/**
* Plugins may load this file to gain access to special helper functions for
* plugin installation. This file is not included by WordPress and it is
* recommended, to prevent fatal errors, that this file is included using
* require_once().
*
* These functions are not optimized for speed, but they should only be used
* once in a while, so speed shouldn't be a concern. If it is and you are
* needing to use these functions a lot, you might experience time outs. If you
* do, then it is advised to just write the SQL code yourself.
*
* <code>
* check_column('wp_links', 'link_description', 'mediumtext');
* if (check_column($wpdb->comments, 'comment_author', 'tinytext'))
* echo "ok\n";
*
* $error_count = 0;
* $tablename = $wpdb->links;
* // check the column
* if (!check_column($wpdb->links, 'link_description', 'varchar(255)')) {
* $ddl = "ALTER TABLE $wpdb->links MODIFY COLUMN link_description varchar(255) NOT NULL DEFAULT '' ";
* $q = $wpdb->query($ddl);
* }
*
* if (check_column($wpdb->links, 'link_description', 'varchar(255)')) {
* $res .= $tablename . ' - ok <br />';
* } else {
* $res .= 'There was a problem with ' . $tablename . '<br />';
* ++$error_count;
* }
* </code>
*
* @package WordPress
* @subpackage Plugin
*/
/** Load WordPress Bootstrap */
require_once(dirname(dirname(__FILE__)).'/wp-load.php');
if ( ! function_exists('maybe_create_table') ) :
/**
* Create database table, if it doesn't already exist.
*
* @since 1.0.0
* @package WordPress
* @subpackage Plugin
* @uses $wpdb
*
* @param string $table_name Database table name.
* @param string $create_ddl Create database table SQL.
* @return bool False on error, true if already exists or success.
*/
function maybe_create_table($table_name, $create_ddl) {
global $wpdb;
foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
if ($table == $table_name) {
return true;
}
}
//didn't find it try to create it.
$wpdb->query($create_ddl);
// we cannot directly tell that whether this succeeded!
foreach ($wpdb->get_col("SHOW TABLES",0) as $table ) {
if ($table == $table_name) {
return true;
}
}
return false;
}
endif;
if ( ! function_exists('maybe_add_column') ) :
/**
* Add column to database table, if column doesn't already exist in table.
*
* @since 1.0.0
* @package WordPress
* @subpackage Plugin
* @uses $wpdb
*
* @param string $table_name Database table name
* @param string $column_name Table column name
* @param string $create_ddl SQL to add column to table.
* @return bool False on failure. True, if already exists or was successful.
*/
function maybe_add_column($table_name, $column_name, $create_ddl) {
global $wpdb;
foreach ($wpdb->get_col("DESC $table_name",0) as $column ) {
if ($column == $column_name) {
return true;
}
}
//didn't find it try to create it.
$wpdb->query($create_ddl);
// we cannot directly tell that whether this succeeded!
foreach ($wpdb->get_col("DESC $table_name",0) as $column ) {
if ($column == $column_name) {
return true;
}
}
return false;
}
endif;
/**
* Drop column from database table, if it exists.
*
* @since 1.0.0
* @package WordPress
* @subpackage Plugin
* @uses $wpdb
*
* @param string $table_name Table name
* @param string $column_name Column name
* @param string $drop_ddl SQL statement to drop column.
* @return bool False on failure, true on success or doesn't exist.
*/
function maybe_drop_column($table_name, $column_name, $drop_ddl) {
global $wpdb;
foreach ($wpdb->get_col("DESC $table_name",0) as $column ) {
if ($column == $column_name) {
//found it try to drop it.
$wpdb->query($drop_ddl);
// we cannot directly tell that whether this succeeded!
foreach ($wpdb->get_col("DESC $table_name",0) as $column ) {
if ($column == $column_name) {
return false;
}
}
}
}
// else didn't find it
return true;
}
/**
* Check column matches criteria.
*
* Uses the SQL DESC for retrieving the table info for the column. It will help
* understand the parameters, if you do more research on what column information
* is returned by the SQL statement. Pass in null to skip checking that
* criteria.
*
* Column names returned from DESC table are case sensitive and are listed:
* Field
* Type
* Null
* Key
* Default
* Extra
*
* @since 1.0.0
* @package WordPress
* @subpackage Plugin
*
* @param string $table_name Table name
* @param string $col_name Column name
* @param string $col_type Column type
* @param bool $is_null Optional. Check is null.
* @param mixed $key Optional. Key info.
* @param mixed $default Optional. Default value.
* @param mixed $extra Optional. Extra value.
* @return bool True, if matches. False, if not matching.
*/
function check_column($table_name, $col_name, $col_type, $is_null = null, $key = null, $default = null, $extra = null) {
global $wpdb;
$diffs = 0;
$results = $wpdb->get_results("DESC $table_name");
foreach ($results as $row ) {
if ($row->Field == $col_name) {
// got our column, check the params
if (($col_type != null) && ($row->Type != $col_type)) {
++$diffs;
}
if (($is_null != null) && ($row->Null != $is_null)) {
++$diffs;
}
if (($key != null) && ($row->Key != $key)) {
++$diffs;
}
if (($default != null) && ($row->Default != $default)) {
++$diffs;
}
if (($extra != null) && ($row->Extra != $extra)) {
++$diffs;
}
if ($diffs > 0) {
return false;
}
return true;
} // end if found our column
}
return false;
}
| 01happy-blog | trunk/myblog/wp-admin/install-helper.php | PHP | oos | 5,590 |
<?php
/**
* Theme editor administration panel.
*
* @package WordPress
* @subpackage Administration
*/
/** WordPress Administration Bootstrap */
require_once('./admin.php');
if ( is_multisite() && ! is_network_admin() ) {
wp_redirect( network_admin_url( 'theme-editor.php' ) );
exit();
}
if ( !current_user_can('edit_themes') )
wp_die('<p>'.__('You do not have sufficient permissions to edit templates for this site.').'</p>');
$title = __("Edit Themes");
$parent_file = 'themes.php';
get_current_screen()->add_help_tab( array(
'id' => 'overview',
'title' => __('Overview'),
'content' =>
'<p>' . __('You can use the Theme Editor to edit the individual CSS and PHP files which make up your theme.') . '</p>
<p>' . __('Begin by choosing a theme to edit from the dropdown menu and clicking Select. A list then appears of all the template files. Clicking once on any file name causes the file to appear in the large Editor box.') . '</p>
<p>' . __('For PHP files, you can use the Documentation dropdown to select from functions recognized in that file. Lookup takes you to a web page with reference material about that particular function.') . '</p>
<p>' . __('After typing in your edits, click Update File.') . '</p>
<p>' . __('<strong>Advice:</strong> think very carefully about your site crashing if you are live-editing the theme currently in use.') . '</p>
<p>' . __('Upgrading to a newer version of the same theme will override changes made here. To avoid this, consider creating a <a href="http://codex.wordpress.org/Child_Themes" target="_blank">child theme</a> instead.') . '</p>' .
( is_network_admin() ? '<p>' . __('Any edits to files from this screen will be reflected on all sites in the network.') . '</p>' : '' )
) );
get_current_screen()->set_help_sidebar(
'<p><strong>' . __('For more information:') . '</strong></p>' .
'<p>' . __('<a href="http://codex.wordpress.org/Theme_Development" target="_blank">Documentation on Theme Development</a>') . '</p>' .
'<p>' . __('<a href="http://codex.wordpress.org/Using_Themes" target="_blank">Documentation on Using Themes</a>') . '</p>' .
'<p>' . __('<a href="http://codex.wordpress.org/Editing_Files" target="_blank">Documentation on Editing Files</a>') . '</p>' .
'<p>' . __('<a href="http://codex.wordpress.org/Template_Tags" target="_blank">Documentation on Template Tags</a>') . '</p>' .
'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
);
wp_reset_vars( array( 'action', 'error', 'file', 'theme' ) );
if ( $theme )
$stylesheet = urldecode( $theme );
else
$stylesheet = get_stylesheet();
$theme = wp_get_theme( $stylesheet );
if ( ! $theme->exists() )
wp_die( __( 'The requested theme does not exist.' ) );
if ( $theme->errors() && 'theme_no_stylesheet' == $theme->errors()->get_error_code() )
wp_die( __( 'The requested theme does not exist.' ) . ' ' . $theme->errors()->get_error_message() );
$allowed_files = $theme->get_files( 'php', 1 );
$has_templates = ! empty( $allowed_files );
$style_files = $theme->get_files( 'css' );
$allowed_files['style.css'] = $style_files['style.css'];
$allowed_files += $style_files;
if ( empty( $file ) ) {
$relative_file = 'style.css';
$file = $allowed_files['style.css'];
} else {
$relative_file = urldecode( stripslashes( $file ) );
$file = $theme->get_stylesheet_directory() . '/' . $relative_file;
}
validate_file_to_edit( $file, $allowed_files );
$scrollto = isset( $_REQUEST['scrollto'] ) ? (int) $_REQUEST['scrollto'] : 0;
switch( $action ) {
case 'update':
check_admin_referer( 'edit-theme_' . $file . $stylesheet );
$newcontent = stripslashes( $_POST['newcontent'] );
$location = 'theme-editor.php?file=' . urlencode( $relative_file ) . '&theme=' . urlencode( $stylesheet ) . '&scrollto=' . $scrollto;
if ( is_writeable( $file ) ) {
//is_writable() not always reliable, check return value. see comments @ http://uk.php.net/is_writable
$f = fopen( $file, 'w+' );
if ( $f !== false ) {
fwrite( $f, $newcontent );
fclose( $f );
$location .= '&updated=true';
$theme->cache_delete();
}
}
wp_redirect( $location );
exit;
break;
default:
require_once( ABSPATH . 'wp-admin/admin-header.php' );
update_recently_edited( $file );
if ( ! is_file( $file ) )
$error = true;
$content = '';
if ( ! $error && filesize( $file ) > 0 ) {
$f = fopen($file, 'r');
$content = fread($f, filesize($file));
if ( '.php' == substr( $file, strrpos( $file, '.' ) ) ) {
$functions = wp_doc_link_parse( $content );
$docs_select = '<select name="docs-list" id="docs-list">';
$docs_select .= '<option value="">' . esc_attr__( 'Function Name...' ) . '</option>';
foreach ( $functions as $function ) {
$docs_select .= '<option value="' . esc_attr( urlencode( $function ) ) . '">' . htmlspecialchars( $function ) . '()</option>';
}
$docs_select .= '</select>';
}
$content = esc_textarea( $content );
}
?>
<?php if ( isset( $_GET['updated'] ) ) : ?>
<div id="message" class="updated"><p><?php _e( 'File edited successfully.' ) ?></p></div>
<?php endif;
$description = get_file_description( $file );
$file_show = array_search( $file, array_filter( $allowed_files ) );
if ( $description != $file_show )
$description .= ' <span>(' . $file_show . ')</span>';
?>
<div class="wrap">
<?php screen_icon(); ?>
<h2><?php echo esc_html( $title ); ?></h2>
<div class="fileedit-sub">
<div class="alignleft">
<h3><?php echo $theme->display('Name'); if ( $description ) echo ': ' . $description; ?></h3>
</div>
<div class="alignright">
<form action="theme-editor.php" method="post">
<strong><label for="theme"><?php _e('Select theme to edit:'); ?> </label></strong>
<select name="theme" id="theme">
<?php
foreach ( wp_get_themes( array( 'errors' => null ) ) as $a_stylesheet => $a_theme ) {
if ( $a_theme->errors() && 'theme_no_stylesheet' == $a_theme->errors()->get_error_code() )
continue;
$selected = $a_stylesheet == $stylesheet ? ' selected="selected"' : '';
echo "\n\t" . '<option value="' . esc_attr( $a_stylesheet ) . '"' . $selected . '>' . $a_theme->display('Name') . '</option>';
}
?>
</select>
<?php submit_button( __( 'Select' ), 'button', 'Submit', false ); ?>
</form>
</div>
<br class="clear" />
</div>
<?php
if ( $theme->errors() )
echo '<div class="error"><p><strong>' . __( 'This theme is broken.' ) . '</strong> ' . $theme->errors()->get_error_message() . '</p></div>';
?>
<div id="templateside">
<?php
if ( $allowed_files ) :
if ( $has_templates || $theme->parent() ) :
?>
<h3><?php _e('Templates'); ?></h3>
<?php if ( $theme->parent() ) : ?>
<p class="howto"><?php printf( __( 'This child theme inherits templates from a parent theme, %s.' ), '<a href="' . self_admin_url('theme-editor.php?theme=' . urlencode( $theme->get_template() ) ) . '">' . $theme->parent()->display('Name') . '</a>' ); ?></p>
<?php endif; ?>
<ul>
<?php
endif;
foreach ( $allowed_files as $filename => $absolute_filename ) :
if ( 'style.css' == $filename )
echo "\t</ul>\n\t<h3>" . _x( 'Styles', 'Theme stylesheets in theme editor' ) . "</h3>\n\t<ul>\n";
$file_description = get_file_description( $absolute_filename );
if ( $file_description != basename( $filename ) )
$file_description .= '<br /><span class="nonessential">(' . $filename . ')</span>';
if ( $absolute_filename == $file )
$file_description = '<span class="highlight">' . $file_description . '</span>';
?>
<li><a href="theme-editor.php?file=<?php echo urlencode( $filename ) ?>&theme=<?php echo urlencode( $stylesheet ) ?>"><?php echo $file_description; ?></a></li>
<?php
endforeach;
?>
</ul>
<?php endif; ?>
</div>
<?php if ( $error ) :
echo '<div class="error"><p>' . __('Oops, no such file exists! Double check the name and try again, merci.') . '</p></div>';
else : ?>
<form name="template" id="template" action="theme-editor.php" method="post">
<?php wp_nonce_field( 'edit-theme_' . $file . $stylesheet ); ?>
<div><textarea cols="70" rows="30" name="newcontent" id="newcontent" tabindex="1"><?php echo $content ?></textarea>
<input type="hidden" name="action" value="update" />
<input type="hidden" name="file" value="<?php echo esc_attr( $relative_file ); ?>" />
<input type="hidden" name="theme" value="<?php echo esc_attr( $theme->get_stylesheet() ); ?>" />
<input type="hidden" name="scrollto" id="scrollto" value="<?php echo $scrollto; ?>" />
</div>
<?php if ( ! empty( $functions ) ) : ?>
<div id="documentation" class="hide-if-no-js">
<label for="docs-list"><?php _e('Documentation:') ?></label>
<?php echo $docs_select; ?>
<input type="button" class="button" value=" <?php esc_attr_e( 'Lookup' ); ?> " onclick="if ( '' != jQuery('#docs-list').val() ) { window.open( 'http://api.wordpress.org/core/handbook/1.0/?function=' + escape( jQuery( '#docs-list' ).val() ) + '&locale=<?php echo urlencode( get_locale() ) ?>&version=<?php echo urlencode( $wp_version ) ?>&redirect=true'); }" />
</div>
<?php endif; ?>
<div>
<?php if ( is_child_theme() && $theme->get_stylesheet() == get_template() ) : ?>
<p><?php if ( is_writeable( $file ) ) { ?><strong><?php _e( 'Caution:' ); ?></strong><?php } ?>
<?php _e( 'This is a file in your current parent theme.' ); ?></p>
<?php endif; ?>
<?php
if ( is_writeable( $file ) ) :
submit_button( __( 'Update File' ), 'primary', 'submit', true, array( 'tabindex' => '2' ) );
else : ?>
<p><em><?php _e('You need to make this file writable before you can save your changes. See <a href="http://codex.wordpress.org/Changing_File_Permissions">the Codex</a> for more information.'); ?></em></p>
<?php endif; ?>
</div>
</form>
<?php
endif; // $error
?>
<br class="clear" />
</div>
<script type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready(function($){
$('#template').submit(function(){ $('#scrollto').val( $('#newcontent').scrollTop() ); });
$('#newcontent').scrollTop( $('#scrollto').val() );
});
/* ]]> */
</script>
<?php
break;
}
include(ABSPATH . 'wp-admin/admin-footer.php' );
| 01happy-blog | trunk/myblog/wp-admin/theme-editor.php | PHP | oos | 10,037 |
<?php
/**
* Reading settings administration panel.
*
* @package WordPress
* @subpackage Administration
*/
/** WordPress Administration Bootstrap */
require_once( './admin.php' );
if ( ! current_user_can( 'manage_options' ) )
wp_die( __( 'You do not have sufficient permissions to manage options for this site.' ) );
$title = __( 'Reading Settings' );
$parent_file = 'options-general.php';
/**
* Display JavaScript on the page.
*
* @package WordPress
* @subpackage Reading_Settings_Screen
*/
function add_js() {
?>
<script type="text/javascript">
//<![CDATA[
jQuery(document).ready(function($){
var section = $('#front-static-pages'),
staticPage = section.find('input:radio[value="page"]'),
selects = section.find('select'),
check_disabled = function(){
selects.prop( 'disabled', ! staticPage.prop('checked') );
};
check_disabled();
section.find('input:radio').change(check_disabled);
});
//]]>
</script>
<?php
}
add_action('admin_head', 'add_js');
get_current_screen()->add_help_tab( array(
'id' => 'overview',
'title' => __('Overview'),
'content' => '<p>' . __('This screen contains the settings that affect the display of your content.') . '</p>' .
'<p>' . sprintf(__('You can choose what’s displayed on the front page of your site. It can be posts in reverse chronological order (classic blog), or a fixed/static page. To set a static home page, you first need to create two <a href="%s">Pages</a>. One will become the front page, and the other will be where your posts are displayed.'), 'post-new.php?post_type=page') . '</p>' .
'<p>' . __('You can also control the display of your content in RSS feeds, including the maximum numbers of posts to display, whether to show full text or a summary, and the character set encoding.') . '</p>' .
'<p>' . __('You must click the Save Changes button at the bottom of the screen for new settings to take effect.') . '</p>',
) );
get_current_screen()->set_help_sidebar(
'<p><strong>' . __('For more information:') . '</strong></p>' .
'<p>' . __('<a href="http://codex.wordpress.org/Settings_Reading_Screen" target="_blank">Documentation on Reading Settings</a>') . '</p>' .
'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
);
include( './admin-header.php' );
?>
<div class="wrap">
<?php screen_icon(); ?>
<h2><?php echo esc_html( $title ); ?></h2>
<form name="form1" method="post" action="options.php">
<?php settings_fields( 'reading' ); ?>
<?php if ( ! get_pages() ) : ?>
<input name="show_on_front" type="hidden" value="posts" />
<table class="form-table">
<?php
if ( 'posts' != get_option( 'show_on_front' ) ) :
update_option( 'show_on_front', 'posts' );
endif;
else :
if ( 'page' == get_option( 'show_on_front' ) && ! get_option( 'page_on_front' ) && ! get_option( 'page_for_posts' ) )
update_option( 'show_on_front', 'posts' );
?>
<table class="form-table">
<tr valign="top">
<th scope="row"><?php _e( 'Front page displays' ); ?></th>
<td id="front-static-pages"><fieldset><legend class="screen-reader-text"><span><?php _e( 'Front page displays' ); ?></span></legend>
<p><label>
<input name="show_on_front" type="radio" value="posts" class="tog" <?php checked( 'posts', get_option( 'show_on_front' ) ); ?> />
<?php _e( 'Your latest posts' ); ?>
</label>
</p>
<p><label>
<input name="show_on_front" type="radio" value="page" class="tog" <?php checked( 'page', get_option( 'show_on_front' ) ); ?> />
<?php printf( __( 'A <a href="%s">static page</a> (select below)' ), 'edit.php?post_type=page' ); ?>
</label>
</p>
<ul>
<li><label for="page_on_front"><?php printf( __( 'Front page: %s' ), wp_dropdown_pages( array( 'name' => 'page_on_front', 'echo' => 0, 'show_option_none' => __( '— Select —' ), 'option_none_value' => '0', 'selected' => get_option( 'page_on_front' ) ) ) ); ?></label></li>
<li><label for="page_for_posts"><?php printf( __( 'Posts page: %s' ), wp_dropdown_pages( array( 'name' => 'page_for_posts', 'echo' => 0, 'show_option_none' => __( '— Select —' ), 'option_none_value' => '0', 'selected' => get_option( 'page_for_posts' ) ) ) ); ?></label></li>
</ul>
<?php if ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) == get_option( 'page_on_front' ) ) : ?>
<div id="front-page-warning" class="error inline"><p><?php _e( '<strong>Warning:</strong> these pages should not be the same!' ); ?></p></div>
<?php endif; ?>
</fieldset></td>
</tr>
<?php endif; ?>
<tr valign="top">
<th scope="row"><label for="posts_per_page"><?php _e( 'Blog pages show at most' ); ?></label></th>
<td>
<input name="posts_per_page" type="number" step="1" min="1" id="posts_per_page" value="<?php form_option( 'posts_per_page' ); ?>" class="small-text" /> <?php _e( 'posts' ); ?>
</td>
</tr>
<tr valign="top">
<th scope="row"><label for="posts_per_rss"><?php _e( 'Syndication feeds show the most recent' ); ?></label></th>
<td><input name="posts_per_rss" type="number" step="1" min="1" id="posts_per_rss" value="<?php form_option( 'posts_per_rss' ); ?>" class="small-text" /> <?php _e( 'items' ); ?></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e( 'For each article in a feed, show' ); ?> </th>
<td><fieldset><legend class="screen-reader-text"><span><?php _e( 'For each article in a feed, show' ); ?> </span></legend>
<p><label><input name="rss_use_excerpt" type="radio" value="0" <?php checked( 0, get_option( 'rss_use_excerpt' ) ); ?> /> <?php _e( 'Full text' ); ?></label><br />
<label><input name="rss_use_excerpt" type="radio" value="1" <?php checked( 1, get_option( 'rss_use_excerpt' ) ); ?> /> <?php _e( 'Summary' ); ?></label></p>
</fieldset></td>
</tr>
<tr valign="top">
<th scope="row"><label for="blog_charset"><?php _e( 'Encoding for pages and feeds' ); ?></label></th>
<td><input name="blog_charset" type="text" id="blog_charset" value="<?php form_option( 'blog_charset' ); ?>" class="regular-text" />
<p class="description"><?php _e( 'The <a href="http://codex.wordpress.org/Glossary#Character_set">character encoding</a> of your site (UTF-8 is recommended, if you are adventurous there are some <a href="http://en.wikipedia.org/wiki/Character_set">other encodings</a>)' ); ?></p></td>
</tr>
<?php do_settings_fields( 'reading', 'default' ); ?>
</table>
<?php do_settings_sections( 'reading' ); ?>
<?php submit_button(); ?>
</form>
</div>
<?php include( './admin-footer.php' ); ?>
| 01happy-blog | trunk/myblog/wp-admin/options-reading.php | PHP | oos | 6,434 |
<?php
/**
* Update Core administration panel.
*
* @package WordPress
* @subpackage Administration
*/
/** WordPress Administration Bootstrap */
require_once('./admin.php');
wp_enqueue_style( 'plugin-install' );
wp_enqueue_script( 'plugin-install' );
add_thickbox();
if ( is_multisite() && ! is_network_admin() ) {
wp_redirect( network_admin_url( 'update-core.php' ) );
exit();
}
if ( ! current_user_can( 'update_core' ) )
wp_die( __( 'You do not have sufficient permissions to update this site.' ) );
function list_core_update( $update ) {
global $wp_local_package, $wpdb;
static $first_pass = true;
$version_string = ('en_US' == $update->locale && 'en_US' == get_locale() ) ?
$update->current : sprintf("%s–<strong>%s</strong>", $update->current, $update->locale);
$current = false;
if ( !isset($update->response) || 'latest' == $update->response )
$current = true;
$submit = __('Update Now');
$form_action = 'update-core.php?action=do-core-upgrade';
$php_version = phpversion();
$mysql_version = $wpdb->db_version();
$show_buttons = true;
if ( 'development' == $update->response ) {
$message = __('You are using a development version of WordPress. You can update to the latest nightly build automatically or download the nightly build and install it manually:');
$download = __('Download nightly build');
} else {
if ( $current ) {
$message = sprintf(__('You have the latest version of WordPress. You do not need to update. However, if you want to re-install version %s, you can do so automatically or download the package and re-install manually:'), $version_string);
$submit = __('Re-install Now');
$form_action = 'update-core.php?action=do-core-reinstall';
} else {
$php_compat = version_compare( $php_version, $update->php_version, '>=' );
if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) )
$mysql_compat = true;
else
$mysql_compat = version_compare( $mysql_version, $update->mysql_version, '>=' );
if ( !$mysql_compat && !$php_compat )
$message = sprintf( __('You cannot update because <a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires PHP version %2$s or higher and MySQL version %3$s or higher. You are running PHP version %4$s and MySQL version %5$s.'), $update->current, $update->php_version, $update->mysql_version, $php_version, $mysql_version );
elseif ( !$php_compat )
$message = sprintf( __('You cannot update because <a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires PHP version %2$s or higher. You are running version %3$s.'), $update->current, $update->php_version, $php_version );
elseif ( !$mysql_compat )
$message = sprintf( __('You cannot update because <a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires MySQL version %2$s or higher. You are running version %3$s.'), $update->current, $update->mysql_version, $mysql_version );
else
$message = sprintf(__('You can update to <a href="http://codex.wordpress.org/Version_%1$s">WordPress %2$s</a> automatically or download the package and install it manually:'), $update->current, $version_string);
if ( !$mysql_compat || !$php_compat )
$show_buttons = false;
}
$download = sprintf(__('Download %s'), $version_string);
}
echo '<p>';
echo $message;
echo '</p>';
echo '<form method="post" action="' . $form_action . '" name="upgrade" class="upgrade">';
wp_nonce_field('upgrade-core');
echo '<p>';
echo '<input name="version" value="'. esc_attr($update->current) .'" type="hidden"/>';
echo '<input name="locale" value="'. esc_attr($update->locale) .'" type="hidden"/>';
if ( $show_buttons ) {
if ( $first_pass ) {
submit_button( $submit, $current ? 'button' : 'primary', 'upgrade', false );
$first_pass = false;
} else {
submit_button( $submit, 'button', 'upgrade', false );
}
echo ' <a href="' . esc_url( $update->download ) . '" class="button">' . $download . '</a> ';
}
if ( 'en_US' != $update->locale )
if ( !isset( $update->dismissed ) || !$update->dismissed )
submit_button( __('Hide this update'), 'button', 'dismiss', false );
else
submit_button( __('Bring back this update'), 'button', 'undismiss', false );
echo '</p>';
if ( 'en_US' != $update->locale && ( !isset($wp_local_package) || $wp_local_package != $update->locale ) )
echo '<p class="hint">'.__('This localized version contains both the translation and various other localization fixes. You can skip upgrading if you want to keep your current translation.').'</p>';
else if ( 'en_US' == $update->locale && get_locale() != 'en_US' ) {
echo '<p class="hint">'.sprintf( __('You are about to install WordPress %s <strong>in English (US).</strong> There is a chance this update will break your translation. You may prefer to wait for the localized version to be released.'), $update->response != 'development' ? $update->current : '' ).'</p>';
}
echo '</form>';
}
function dismissed_updates() {
$dismissed = get_core_updates( array( 'dismissed' => true, 'available' => false ) );
if ( $dismissed ) {
$show_text = esc_js(__('Show hidden updates'));
$hide_text = esc_js(__('Hide hidden updates'));
?>
<script type="text/javascript">
jQuery(function($) {
$('dismissed-updates').show();
$('#show-dismissed').toggle(function(){$(this).text('<?php echo $hide_text; ?>');}, function() {$(this).text('<?php echo $show_text; ?>')});
$('#show-dismissed').click(function() { $('#dismissed-updates').toggle('slow');});
});
</script>
<?php
echo '<p class="hide-if-no-js"><a id="show-dismissed" href="#">'.__('Show hidden updates').'</a></p>';
echo '<ul id="dismissed-updates" class="core-updates dismissed">';
foreach( (array) $dismissed as $update) {
echo '<li>';
list_core_update( $update );
echo '</li>';
}
echo '</ul>';
}
}
/**
* Display upgrade WordPress for downloading latest or upgrading automatically form.
*
* @since 2.7
*
* @return null
*/
function core_upgrade_preamble() {
global $upgrade_error, $wp_version;
$updates = get_core_updates();
?>
<div class="wrap">
<?php screen_icon('tools'); ?>
<h2><?php _e('WordPress Updates'); ?></h2>
<?php
if ( $upgrade_error ) {
echo '<div class="error"><p>';
if ( $upgrade_error == 'themes' )
_e('Please select one or more themes to update.');
else
_e('Please select one or more plugins to update.');
echo '</p></div>';
}
echo '<p>';
/* translators: %1 date, %2 time. */
printf( __('Last checked on %1$s at %2$s.'), date_i18n( get_option( 'date_format' ) ), date_i18n( get_option( 'time_format' ) ) );
echo ' <a class="button" href="' . esc_url( self_admin_url('update-core.php') ) . '">' . __( 'Check Again' ) . '</a>';
echo '</p>';
if ( !isset($updates[0]->response) || 'latest' == $updates[0]->response ) {
echo '<h3>';
_e('You have the latest version of WordPress.');
echo '</h3>';
} else {
echo '<div class="updated inline"><p>';
_e('<strong>Important:</strong> before updating, please <a href="http://codex.wordpress.org/WordPress_Backups">back up your database and files</a>. For help with updates, visit the <a href="http://codex.wordpress.org/Updating_WordPress">Updating WordPress</a> Codex page.');
echo '</p></div>';
echo '<h3 class="response">';
_e( 'An updated version of WordPress is available.' );
echo '</h3>';
}
echo '<ul class="core-updates">';
$alternate = true;
foreach( (array) $updates as $update ) {
echo '<li>';
list_core_update( $update );
echo '</li>';
}
echo '</ul>';
if ( $updates ) {
echo '<p>' . __( 'While your site is being updated, it will be in maintenance mode. As soon as your updates are complete, your site will return to normal.' ) . '</p>';
} else {
list( $normalized_version ) = explode( '-', $wp_version );
echo '<p>' . sprintf( __( '<a href="%s">Learn more about WordPress %s</a>.' ), esc_url( self_admin_url( 'about.php' ) ), $normalized_version ) . '</p>';
}
dismissed_updates();
if ( current_user_can( 'update_plugins' ) )
list_plugin_updates();
if ( current_user_can( 'update_themes' ) )
list_theme_updates();
do_action('core_upgrade_preamble');
echo '</div>';
}
function list_plugin_updates() {
global $wp_version;
$cur_wp_version = preg_replace('/-.*$/', '', $wp_version);
require_once(ABSPATH . 'wp-admin/includes/plugin-install.php');
$plugins = get_plugin_updates();
if ( empty( $plugins ) ) {
echo '<h3>' . __( 'Plugins' ) . '</h3>';
echo '<p>' . __( 'Your plugins are all up to date.' ) . '</p>';
return;
}
$form_action = 'update-core.php?action=do-plugin-upgrade';
$core_updates = get_core_updates();
if ( !isset($core_updates[0]->response) || 'latest' == $core_updates[0]->response || 'development' == $core_updates[0]->response || version_compare( $core_updates[0]->current, $cur_wp_version, '=') )
$core_update_version = false;
else
$core_update_version = $core_updates[0]->current;
?>
<h3><?php _e( 'Plugins' ); ?></h3>
<p><?php _e( 'The following plugins have new versions available. Check the ones you want to update and then click “Update Plugins”.' ); ?></p>
<form method="post" action="<?php echo $form_action; ?>" name="upgrade-plugins" class="upgrade">
<?php wp_nonce_field('upgrade-core'); ?>
<p><input id="upgrade-plugins" class="button" type="submit" value="<?php esc_attr_e('Update Plugins'); ?>" name="upgrade" /></p>
<table class="widefat" cellspacing="0" id="update-plugins-table">
<thead>
<tr>
<th scope="col" class="manage-column check-column"><input type="checkbox" id="plugins-select-all" /></th>
<th scope="col" class="manage-column"><label for="plugins-select-all"><?php _e('Select All'); ?></label></th>
</tr>
</thead>
<tfoot>
<tr>
<th scope="col" class="manage-column check-column"><input type="checkbox" id="plugins-select-all-2" /></th>
<th scope="col" class="manage-column"><label for="plugins-select-all-2"><?php _e('Select All'); ?></label></th>
</tr>
</tfoot>
<tbody class="plugins">
<?php
foreach ( (array) $plugins as $plugin_file => $plugin_data) {
$info = plugins_api('plugin_information', array('slug' => $plugin_data->update->slug ));
// Get plugin compat for running version of WordPress.
if ( isset($info->tested) && version_compare($info->tested, $cur_wp_version, '>=') ) {
$compat = '<br />' . sprintf(__('Compatibility with WordPress %1$s: 100%% (according to its author)'), $cur_wp_version);
} elseif ( isset($info->compatibility[$cur_wp_version][$plugin_data->update->new_version]) ) {
$compat = $info->compatibility[$cur_wp_version][$plugin_data->update->new_version];
$compat = '<br />' . sprintf(__('Compatibility with WordPress %1$s: %2$d%% (%3$d "works" votes out of %4$d total)'), $cur_wp_version, $compat[0], $compat[2], $compat[1]);
} else {
$compat = '<br />' . sprintf(__('Compatibility with WordPress %1$s: Unknown'), $cur_wp_version);
}
// Get plugin compat for updated version of WordPress.
if ( $core_update_version ) {
if ( isset($info->compatibility[$core_update_version][$plugin_data->update->new_version]) ) {
$update_compat = $info->compatibility[$core_update_version][$plugin_data->update->new_version];
$compat .= '<br />' . sprintf(__('Compatibility with WordPress %1$s: %2$d%% (%3$d "works" votes out of %4$d total)'), $core_update_version, $update_compat[0], $update_compat[2], $update_compat[1]);
} else {
$compat .= '<br />' . sprintf(__('Compatibility with WordPress %1$s: Unknown'), $core_update_version);
}
}
// Get the upgrade notice for the new plugin version.
if ( isset($plugin_data->update->upgrade_notice) ) {
$upgrade_notice = '<br />' . strip_tags($plugin_data->update->upgrade_notice);
} else {
$upgrade_notice = '';
}
$details_url = self_admin_url('plugin-install.php?tab=plugin-information&plugin=' . $plugin_data->update->slug . '§ion=changelog&TB_iframe=true&width=640&height=662');
$details_text = sprintf(__('View version %1$s details'), $plugin_data->update->new_version);
$details = sprintf('<a href="%1$s" class="thickbox" title="%2$s">%3$s</a>.', esc_url($details_url), esc_attr($plugin_data->Name), $details_text);
echo "
<tr class='active'>
<th scope='row' class='check-column'><input type='checkbox' name='checked[]' value='" . esc_attr($plugin_file) . "' /></th>
<td><p><strong>{$plugin_data->Name}</strong><br />" . sprintf(__('You have version %1$s installed. Update to %2$s.'), $plugin_data->Version, $plugin_data->update->new_version) . ' ' . $details . $compat . $upgrade_notice . "</p></td>
</tr>";
}
?>
</tbody>
</table>
<p><input id="upgrade-plugins-2" class="button" type="submit" value="<?php esc_attr_e('Update Plugins'); ?>" name="upgrade" /></p>
</form>
<?php
}
function list_theme_updates() {
$themes = get_theme_updates();
if ( empty( $themes ) ) {
echo '<h3>' . __( 'Themes' ) . '</h3>';
echo '<p>' . __( 'Your themes are all up to date.' ) . '</p>';
return;
}
$form_action = 'update-core.php?action=do-theme-upgrade';
?>
<h3><?php _e( 'Themes' ); ?></h3>
<p><?php _e( 'The following themes have new versions available. Check the ones you want to update and then click “Update Themes”.' ); ?></p>
<p><?php printf( __('<strong>Please Note:</strong> Any customizations you have made to theme files will be lost. Please consider using <a href="%s">child themes</a> for modifications.'), _x('http://codex.wordpress.org/Child_Themes', 'Link used in suggestion to use child themes in GUU') ); ?></p>
<form method="post" action="<?php echo $form_action; ?>" name="upgrade-themes" class="upgrade">
<?php wp_nonce_field('upgrade-core'); ?>
<p><input id="upgrade-themes" class="button" type="submit" value="<?php esc_attr_e('Update Themes'); ?>" name="upgrade" /></p>
<table class="widefat" cellspacing="0" id="update-themes-table">
<thead>
<tr>
<th scope="col" class="manage-column check-column"><input type="checkbox" id="themes-select-all" /></th>
<th scope="col" class="manage-column"><label for="themes-select-all"><?php _e('Select All'); ?></label></th>
</tr>
</thead>
<tfoot>
<tr>
<th scope="col" class="manage-column check-column"><input type="checkbox" id="themes-select-all-2" /></th>
<th scope="col" class="manage-column"><label for="themes-select-all-2"><?php _e('Select All'); ?></label></th>
</tr>
</tfoot>
<tbody class="plugins">
<?php
foreach ( $themes as $stylesheet => $theme ) {
echo "
<tr class='active'>
<th scope='row' class='check-column'><input type='checkbox' name='checked[]' value='" . esc_attr( $stylesheet ) . "' /></th>
<td class='plugin-title'><img src='" . esc_url( $theme->get_screenshot() ) . "' width='64' height='64' style='float:left; padding: 0 5px 5px' /><strong>" . $theme->display('Name') . '</strong> ' . sprintf( __( 'You have version %1$s installed. Update to %2$s.' ), $theme->display('Version'), $theme->update['new_version'] ) . "</td>
</tr>";
}
?>
</tbody>
</table>
<p><input id="upgrade-themes-2" class="button" type="submit" value="<?php esc_attr_e('Update Themes'); ?>" name="upgrade" /></p>
</form>
<?php
}
/**
* Upgrade WordPress core display.
*
* @since 2.7
*
* @return null
*/
function do_core_upgrade( $reinstall = false ) {
global $wp_filesystem;
if ( $reinstall )
$url = 'update-core.php?action=do-core-reinstall';
else
$url = 'update-core.php?action=do-core-upgrade';
$url = wp_nonce_url($url, 'upgrade-core');
if ( false === ($credentials = request_filesystem_credentials($url, '', false, ABSPATH)) )
return;
$version = isset( $_POST['version'] )? $_POST['version'] : false;
$locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';
$update = find_core_update( $version, $locale );
if ( !$update )
return;
if ( ! WP_Filesystem($credentials, ABSPATH) ) {
request_filesystem_credentials($url, '', true, ABSPATH); //Failed to connect, Error and request again
return;
}
?>
<div class="wrap">
<?php screen_icon('tools'); ?>
<h2><?php _e('Update WordPress'); ?></h2>
<?php
if ( $wp_filesystem->errors->get_error_code() ) {
foreach ( $wp_filesystem->errors->get_error_messages() as $message )
show_message($message);
echo '</div>';
return;
}
if ( $reinstall )
$update->response = 'reinstall';
$result = wp_update_core($update, 'show_message');
if ( is_wp_error($result) ) {
show_message($result);
if ('up_to_date' != $result->get_error_code() )
show_message( __('Installation Failed') );
echo '</div>';
return;
}
show_message( __('WordPress updated successfully') );
show_message( '<span class="hide-if-no-js">' . sprintf( __( 'Welcome to WordPress %1$s. You will be redirected to the About WordPress screen. If not, click <a href="%s">here</a>.' ), $result, esc_url( self_admin_url( 'about.php?updated' ) ) ) . '</span>' );
show_message( '<span class="hide-if-js">' . sprintf( __( 'Welcome to WordPress %1$s. <a href="%2$s">Learn more</a>.' ), $result, esc_url( self_admin_url( 'about.php?updated' ) ) ) . '</span>' );
?>
</div>
<script type="text/javascript">
window.location = '<?php echo self_admin_url( 'about.php?updated' ); ?>';
</script>
<?php
}
function do_dismiss_core_update() {
$version = isset( $_POST['version'] )? $_POST['version'] : false;
$locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';
$update = find_core_update( $version, $locale );
if ( !$update )
return;
dismiss_core_update( $update );
wp_redirect( wp_nonce_url('update-core.php?action=upgrade-core', 'upgrade-core') );
exit;
}
function do_undismiss_core_update() {
$version = isset( $_POST['version'] )? $_POST['version'] : false;
$locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';
$update = find_core_update( $version, $locale );
if ( !$update )
return;
undismiss_core_update( $version, $locale );
wp_redirect( wp_nonce_url('update-core.php?action=upgrade-core', 'upgrade-core') );
exit;
}
function no_update_actions($actions) {
return '';
}
$action = isset($_GET['action']) ? $_GET['action'] : 'upgrade-core';
$upgrade_error = false;
if ( ( 'do-theme-upgrade' == $action || ( 'do-plugin-upgrade' == $action && ! isset( $_GET['plugins'] ) ) )
&& ! isset( $_POST['checked'] ) ) {
$upgrade_error = $action == 'do-theme-upgrade' ? 'themes' : 'plugins';
$action = 'upgrade-core';
}
$title = __('WordPress Updates');
$parent_file = 'tools.php';
get_current_screen()->add_help_tab( array(
'id' => 'overview',
'title' => __('Overview'),
'content' =>
'<p>' . __('This screen lets you update to the latest version of WordPress as well as update your themes and plugins from the WordPress.org repository. When updates are available, the number of available updates will appear in a bubble on the left hand menu as a notification.') . '</p>' .
'<p>' . __('It is very important to keep your WordPress installation up to date for security reasons, so when you see a number appear, make sure you take the time to update, which is an easy process.') . '</p>'
) );
get_current_screen()->add_help_tab( array(
'id' => 'how-to-update',
'title' => __('How to Update'),
'content' =>
'<p>' . __('Updating your WordPress installation is a simple one-click procedure; just click on the Update button when it says a new version is available.') . '</p>' .
'<p>' . __('To update themes or plugins from this screen, use the checkboxes to make your selection and click on the appropriate Update button. Check the box at the top of the Themes or Plugins section to select all and update them all at once.') . '</p>'
) );
get_current_screen()->set_help_sidebar(
'<p><strong>' . __('For more information:') . '</strong></p>' .
'<p>' . __('<a href="http://codex.wordpress.org/Dashboard_Updates_Screen" target="_blank">Documentation on Updating WordPress</a>') . '</p>' .
'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
);
if ( 'upgrade-core' == $action ) {
wp_version_check();
require_once(ABSPATH . 'wp-admin/admin-header.php');
core_upgrade_preamble();
include(ABSPATH . 'wp-admin/admin-footer.php');
} elseif ( 'do-core-upgrade' == $action || 'do-core-reinstall' == $action ) {
check_admin_referer('upgrade-core');
// do the (un)dismiss actions before headers,
// so that they can redirect
if ( isset( $_POST['dismiss'] ) )
do_dismiss_core_update();
elseif ( isset( $_POST['undismiss'] ) )
do_undismiss_core_update();
require_once(ABSPATH . 'wp-admin/admin-header.php');
if ( 'do-core-reinstall' == $action )
$reinstall = true;
else
$reinstall = false;
if ( isset( $_POST['upgrade'] ) )
do_core_upgrade($reinstall);
include(ABSPATH . 'wp-admin/admin-footer.php');
} elseif ( 'do-plugin-upgrade' == $action ) {
if ( ! current_user_can( 'update_plugins' ) )
wp_die( __( 'You do not have sufficient permissions to update this site.' ) );
check_admin_referer('upgrade-core');
if ( isset( $_GET['plugins'] ) ) {
$plugins = explode( ',', $_GET['plugins'] );
} elseif ( isset( $_POST['checked'] ) ) {
$plugins = (array) $_POST['checked'];
} else {
wp_redirect( admin_url('update-core.php') );
exit;
}
$url = 'update.php?action=update-selected&plugins=' . urlencode(implode(',', $plugins));
$url = wp_nonce_url($url, 'bulk-update-plugins');
$title = __('Update Plugins');
require_once(ABSPATH . 'wp-admin/admin-header.php');
echo '<div class="wrap">';
screen_icon('plugins');
echo '<h2>' . esc_html__('Update Plugins') . '</h2>';
echo "<iframe src='$url' style='width: 100%; height: 100%; min-height: 750px;' frameborder='0'></iframe>";
echo '</div>';
include(ABSPATH . 'wp-admin/admin-footer.php');
} elseif ( 'do-theme-upgrade' == $action ) {
if ( ! current_user_can( 'update_themes' ) )
wp_die( __( 'You do not have sufficient permissions to update this site.' ) );
check_admin_referer('upgrade-core');
if ( isset( $_GET['themes'] ) ) {
$themes = explode( ',', $_GET['themes'] );
} elseif ( isset( $_POST['checked'] ) ) {
$themes = (array) $_POST['checked'];
} else {
wp_redirect( admin_url('update-core.php') );
exit;
}
$url = 'update.php?action=update-selected-themes&themes=' . urlencode(implode(',', $themes));
$url = wp_nonce_url($url, 'bulk-update-themes');
$title = __('Update Themes');
require_once(ABSPATH . 'wp-admin/admin-header.php');
echo '<div class="wrap">';
screen_icon('themes');
echo '<h2>' . esc_html__('Update Themes') . '</h2>';
echo "<iframe src='$url' style='width: 100%; height: 100%; min-height: 750px;' frameborder='0'></iframe>";
echo '</div>';
include(ABSPATH . 'wp-admin/admin-footer.php');
} else {
do_action('update-core-custom_' . $action);
} | 01happy-blog | trunk/myblog/wp-admin/update-core.php | PHP | oos | 22,633 |
<?php
/**
* Comment Moderation Administration Screen.
*
* Redirects to edit-comments.php?comment_status=moderated.
*
* @package WordPress
* @subpackage Administration
*/
require_once('../wp-load.php');
wp_redirect( admin_url('edit-comments.php?comment_status=moderated') );
exit;
| 01happy-blog | trunk/myblog/wp-admin/moderation.php | PHP | oos | 287 |
<?php
/**
* Edit post administration panel.
*
* Manage Post actions: post, edit, delete, etc.
*
* @package WordPress
* @subpackage Administration
*/
/** WordPress Administration Bootstrap */
require_once('./admin.php');
$parent_file = 'edit.php';
$submenu_file = 'edit.php';
wp_reset_vars(array('action', 'safe_mode', 'withcomments', 'posts', 'content', 'edited_post_title', 'comment_error', 'profile', 'trackback_url', 'excerpt', 'showcomments', 'commentstart', 'commentend', 'commentorder'));
if ( isset( $_GET['post'] ) )
$post_id = $post_ID = (int) $_GET['post'];
elseif ( isset( $_POST['post_ID'] ) )
$post_id = $post_ID = (int) $_POST['post_ID'];
else
$post_id = $post_ID = 0;
$post = $post_type = $post_type_object = null;
if ( $post_id )
$post = get_post( $post_id );
if ( $post ) {
$post_type = $post->post_type;
$post_type_object = get_post_type_object( $post_type );
}
/**
* Redirect to previous page.
*
* @param int $post_id Optional. Post ID.
*/
function redirect_post($post_id = '') {
if ( isset($_POST['save']) || isset($_POST['publish']) ) {
$status = get_post_status( $post_id );
if ( isset( $_POST['publish'] ) ) {
switch ( $status ) {
case 'pending':
$message = 8;
break;
case 'future':
$message = 9;
break;
default:
$message = 6;
}
} else {
$message = 'draft' == $status ? 10 : 1;
}
$location = add_query_arg( 'message', $message, get_edit_post_link( $post_id, 'url' ) );
} elseif ( isset($_POST['addmeta']) && $_POST['addmeta'] ) {
$location = add_query_arg( 'message', 2, wp_get_referer() );
$location = explode('#', $location);
$location = $location[0] . '#postcustom';
} elseif ( isset($_POST['deletemeta']) && $_POST['deletemeta'] ) {
$location = add_query_arg( 'message', 3, wp_get_referer() );
$location = explode('#', $location);
$location = $location[0] . '#postcustom';
} elseif ( 'post-quickpress-save-cont' == $_POST['action'] ) {
$location = "post.php?action=edit&post=$post_id&message=7";
} else {
$location = add_query_arg( 'message', 4, get_edit_post_link( $post_id, 'url' ) );
}
wp_redirect( apply_filters( 'redirect_post_location', $location, $post_id ) );
exit;
}
if ( isset( $_POST['deletepost'] ) )
$action = 'delete';
elseif ( isset($_POST['wp-preview']) && 'dopreview' == $_POST['wp-preview'] )
$action = 'preview';
$sendback = wp_get_referer();
if ( ! $sendback ||
strpos( $sendback, 'post.php' ) !== false ||
strpos( $sendback, 'post-new.php' ) !== false ) {
$sendback = admin_url( 'edit.php' );
$sendback .= ( ! empty( $post_type ) ) ? '?post_type=' . $post_type : '';
} else {
$sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), $sendback );
}
switch($action) {
case 'postajaxpost':
case 'post':
case 'post-quickpress-publish':
case 'post-quickpress-save':
check_admin_referer('add-' . $post_type);
if ( 'post-quickpress-publish' == $action )
$_POST['publish'] = 'publish'; // tell write_post() to publish
if ( 'post-quickpress-publish' == $action || 'post-quickpress-save' == $action ) {
$_POST['comment_status'] = get_option('default_comment_status');
$_POST['ping_status'] = get_option('default_ping_status');
$post_id = edit_post();
} else {
$post_id = 'postajaxpost' == $action ? edit_post() : write_post();
}
if ( 0 === strpos( $action, 'post-quickpress' ) ) {
$_POST['post_ID'] = $post_id;
// output the quickpress dashboard widget
require_once(ABSPATH . 'wp-admin/includes/dashboard.php');
wp_dashboard_quick_press();
exit;
}
redirect_post($post_id);
exit();
break;
case 'edit':
$editing = true;
if ( empty( $post_id ) ) {
wp_redirect( admin_url('post.php') );
exit();
}
$p = $post_id;
if ( empty($post->ID) )
wp_die( __('You attempted to edit an item that doesn’t exist. Perhaps it was deleted?') );
if ( null == $post_type_object )
wp_die( __('Unknown post type.') );
if ( !current_user_can($post_type_object->cap->edit_post, $post_id) )
wp_die( __('You are not allowed to edit this item.') );
if ( 'trash' == $post->post_status )
wp_die( __('You can’t edit this item because it is in the Trash. Please restore it and try again.') );
$post_type = $post->post_type;
if ( 'post' == $post_type ) {
$parent_file = "edit.php";
$submenu_file = "edit.php";
$post_new_file = "post-new.php";
} else {
if ( isset( $post_type_object ) && $post_type_object->show_in_menu && $post_type_object->show_in_menu !== true )
$parent_file = $post_type_object->show_in_menu;
else
$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";
}
if ( $last = wp_check_post_lock( $post->ID ) ) {
add_action('admin_notices', '_admin_notice_post_locked' );
} else {
$active_post_lock = wp_set_post_lock( $post->ID );
wp_enqueue_script('autosave');
}
$title = $post_type_object->labels->edit_item;
$post = get_post_to_edit($post_id);
if ( post_type_supports($post_type, 'comments') ) {
wp_enqueue_script('admin-comments');
enqueue_comment_hotkeys_js();
}
include('./edit-form-advanced.php');
break;
case 'editattachment':
check_admin_referer('update-attachment_' . $post_id);
// Don't let these be changed
unset($_POST['guid']);
$_POST['post_type'] = 'attachment';
// Update the thumbnail filename
$newmeta = wp_get_attachment_metadata( $post_id, true );
$newmeta['thumb'] = $_POST['thumb'];
wp_update_attachment_metadata( $post_id, $newmeta );
case 'editpost':
check_admin_referer('update-' . $post_type . '_' . $post_id);
$post_id = edit_post();
redirect_post($post_id); // Send user on their way while we keep working
exit();
break;
case 'trash':
check_admin_referer('trash-' . $post_type . '_' . $post_id);
$post = & get_post($post_id);
if ( !current_user_can($post_type_object->cap->delete_post, $post_id) )
wp_die( __('You are not allowed to move this item to the Trash.') );
if ( ! wp_trash_post($post_id) )
wp_die( __('Error in moving to Trash.') );
wp_redirect( add_query_arg( array('trashed' => 1, 'ids' => $post_id), $sendback ) );
exit();
break;
case 'untrash':
check_admin_referer('untrash-' . $post_type . '_' . $post_id);
if ( !current_user_can($post_type_object->cap->delete_post, $post_id) )
wp_die( __('You are not allowed to move this item out of the Trash.') );
if ( ! wp_untrash_post($post_id) )
wp_die( __('Error in restoring from Trash.') );
wp_redirect( add_query_arg('untrashed', 1, $sendback) );
exit();
break;
case 'delete':
check_admin_referer('delete-' . $post_type . '_' . $post_id);
if ( !current_user_can($post_type_object->cap->delete_post, $post_id) )
wp_die( __('You are not allowed to delete this item.') );
$force = !EMPTY_TRASH_DAYS;
if ( $post->post_type == 'attachment' ) {
$force = ( $force || !MEDIA_TRASH );
if ( ! wp_delete_attachment($post_id, $force) )
wp_die( __('Error in deleting.') );
} else {
if ( !wp_delete_post($post_id, $force) )
wp_die( __('Error in deleting.') );
}
wp_redirect( add_query_arg('deleted', 1, $sendback) );
exit();
break;
case 'preview':
check_admin_referer( 'autosave', 'autosavenonce' );
$url = post_preview();
wp_redirect($url);
exit();
break;
default:
wp_redirect( admin_url('edit.php') );
exit();
break;
} // end switch
include('./admin-footer.php');
| 01happy-blog | trunk/myblog/wp-admin/post.php | PHP | oos | 7,414 |
<?php
/**
* Multisite administration panel.
*
* @package WordPress
* @subpackage Multisite
* @since 3.0.0
*/
require_once( './admin.php' );
wp_redirect( network_admin_url() );
exit;
| 01happy-blog | trunk/myblog/wp-admin/ms-admin.php | PHP | oos | 190 |
/*------------------------------------------------------------------------------
Howdy! This is the CSS file that controls the
Blue (classic) color style on the WordPress Dashboard.
This file contains both LTR and RTL styles.
TABLE OF CONTENTS:
------------------
1.0 - Left to Right Styles
2.0 - Right to Left Styles
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
1.0 - Left to Right Styles
------------------------------------------------------------------------------*/
html,
.wp-dialog {
background-color: #fff;
}
* html input,
* html .widget {
border-color: #dfdfdf;
}
textarea,
input[type="text"],
input[type="password"],
input[type="file"],
input[type="button"],
input[type="submit"],
input[type="reset"],
input[type="email"],
input[type="number"],
input[type="search"],
input[type="tel"],
input[type="url"],
select {
border-color: #dfdfdf;
background-color: #fff;
color: #333;
}
select {
color: #000;
}
textarea:focus,
input[type="text"]:focus,
input[type="password"]:focus,
input[type="file"]:focus,
input[type="button"]:focus,
input[type="submit"]:focus,
input[type="reset"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
input[type="search"]:focus,
input[type="tel"]:focus,
input[type="url"]:focus,
select:focus {
border-color: #d1e5ee;
}
kbd,
code {
background: #eaeaea;
}
input[readonly] {
background-color: #eee;
}
.find-box-search {
border-color: #dfdfdf;
background-color: #f1f1f1;
}
.find-box {
background-color: #f1f1f1;
}
.find-box-inside {
background-color: #fff;
}
a.page-numbers:hover {
border-color: #999;
}
body,
#wpbody,
.form-table .pre,
.ui-autocomplete li a {
color: #333;
}
body > #upload-menu {
border-bottom-color: #fff;
}
#postcustomstuff table,
#your-profile fieldset,
#rightnow,
div.dashboard-widget,
#dashboard-widgets p.dashboard-widget-links {
border-color: #D1E5EE
}
#poststuff .inside label.spam,
#poststuff .inside label.deleted {
color: red;
}
#poststuff .inside label.waiting {
color: orange;
}
#poststuff .inside label.approved {
color: green;
}
#postcustomstuff table {
border-color: #dfdfdf;
background-color: #F9F9F9;
}
#postcustomstuff thead th {
background-color: #F1F1F1;
}
#postcustomstuff table input,
#postcustomstuff table textarea {
border-color: #dfdfdf;
background-color: #fff;
}
.widefat {
border-color: #D1E5EE;
background-color: #fff;
}
div.dashboard-widget-error {
background-color: #c43;
}
div.dashboard-widget-notice {
background-color: #cfe1ef;
}
div.dashboard-widget-submit {
border-top-color: #ccc;
}
ul.category-tabs li {
border-color: transparent;
}
div.tabs-panel,
.wp-tab-panel,
ul.category-tabs li.tabs,
ul.add-menu-item-tabs li.tabs,
.wp-tab-active {
border-color: #dfdfdf;
background-color: #fff;
}
ul.category-tabs li.tabs,
ul.add-menu-item-tabs li.tabs,
.wp-tab-active {
background-color: #fff;
}
input.disabled,
textarea.disabled {
background-color: #ccc;
}
/* #upload-menu li a.upload-tab-link, */
#plugin-information .action-button a,
#plugin-information .action-button a:hover,
#plugin-information .action-button a:visited {
color: #fff;
}
.widget .widget-top,
.postbox h3,
.stuffbox h3,
.widefat thead tr th,
.widefat tfoot tr th,
h3.dashboard-widget-title,
h3.dashboard-widget-title span,
h3.dashboard-widget-title small,
.find-box-head,
.sidebar-name,
#nav-menu-header,
#nav-menu-footer,
.menu-item-handle,
#fullscreen-topbar {
background-color: #f5fafd; /* Fallback */
background-image: -ms-linear-gradient(top, #f7fcfe, #eff8ff); /* IE10 */
background-image: -moz-linear-gradient(top, #f7fcfe, #eff8ff); /* Firefox */
background-image: -o-linear-gradient(top, #f7fcfe, #eff8ff); /* Opera */
background-image: -webkit-gradient(linear, left top, left bottom, from(#f7fcfe), to(#eff8ff)); /* old Webkit */
background-image: -webkit-linear-gradient(top, #f7fcfe, #eff8ff); /* new Webkit */
background-image: linear-gradient(top, #f7fcfe, #eff8ff); /* proposed W3C Markup */
}
.widget .widget-top,
.postbox h3,
.stuffbox h3 {
border-bottom-color: #D1E5EE;
text-shadow: #fff 0 1px 0;
-moz-box-shadow: 0 1px 0 #fff;
-webkit-box-shadow: 0 1px 0 #fff;
box-shadow: 0 1px 0 #fff;
}
.form-table th,
.form-wrap label {
color: #222;
text-shadow: #fff 0 1px 0;
}
.description,
.form-wrap p {
color: #666;
}
strong .post-com-count span {
background-color: #21759b;
}
.sorthelper {
background-color: #ccf3fa;
}
.ac_match,
.subsubsub a.current {
color: #000;
}
.wrap h2 {
color: #174f69;
}
.wrap .add-new-h2 {
background: #f1f1f1;
}
.subtitle {
color: #777;
}
.ac_over {
background-color: #f0f0b8;
}
.ac_results {
background-color: #fff;
border-color: #808080;
}
.ac_results li {
color: #101010;
}
.alternate,
.alt {
background-color: #f7fcfe;
}
.available-theme a.screenshot {
background-color: #f1f1f1;
border-color: #ddd;
}
.bar {
background-color: #e8e8e8;
border-right-color: #99d;
}
#media-upload,
#media-upload .media-item .slidetoggle {
background: #fff;
}
#media-upload .slidetoggle {
border-top-color: #dfdfdf;
}
div.error,
.login #login_error {
background-color: #ffebe8;
border-color: #c00;
}
div.error a {
color: #c00;
}
.form-invalid {
background-color: #ffebe8 !important;
}
.form-invalid input,
.form-invalid select {
border-color: #c00 !important;
}
.submit,
#commentsdiv #add-new-comment {
border-color: #dfdfdf;
}
.highlight {
background-color: #e4f2fd;
color: #000;
}
.howto,
.nonessential,
#edit-slug-box,
.form-input-tip,
.subsubsub {
color: #666;
}
.media-upload-form label.form-help,
td.help {
color: #9a9a9a;
}
.ui-autocomplete {
background-color: #eff8ff;
border-color: #d1e5ee;
}
.ui-autocomplete li a.ui-state-hover {
background-color: #def1ff;
}
.post-com-count {
background-image: url(../images/bubble_bg.gif);
color: #fff;
}
.post-com-count span {
background-color: #bbb;
color: #fff;
}
.post-com-count:hover span {
background-color: #d54e21;
}
.quicktags, .search {
background-color: #ccc;
color: #000;
}
.side-info h5 {
border-bottom-color: #dadada;
}
.side-info ul {
color: #666;
}
.button,
.button-secondary,
.submit input,
input[type=button],
input[type=submit] {
border-color: #bbb;
color: #464646;
}
.button:hover,
.button-secondary:hover,
.submit input:hover,
input[type=button]:hover,
input[type=submit]:hover {
color: #000;
border-color: #666;
}
.button,
.submit input,
.button-secondary {
background: #f2f2f2 url(../images/white-grad.png) repeat-x scroll left top;
text-shadow: rgba(255,255,255,1) 0 1px 0;
}
.button:active,
.submit input:active,
.button-secondary:active {
background: #eee url(../images/white-grad-active.png) repeat-x scroll left top;
}
input.button-primary,
button.button-primary,
a.button-primary {
border-color: #298cba;
font-weight: bold;
color: #fff;
background: #21759B url(../images/button-grad.png) repeat-x scroll left top;
text-shadow: rgba(0,0,0,0.3) 0 -1px 0;
}
input.button-primary:active,
button.button-primary:active,
a.button-primary:active {
background: #21759b url(../images/button-grad-active.png) repeat-x scroll left top;
color: #eaf2fa;
}
input.button-primary:hover,
button.button-primary:hover,
a.button-primary:hover,
a.button-primary:focus,
a.button-primary:active {
border-color: #13455b;
color: #eaf2fa;
}
.button-disabled,
.button[disabled],
.button:disabled,
.button-secondary[disabled],
.button-secondary:disabled,
a.button.disabled {
color: #aaa !important;
border-color: #ddd !important;
}
.button-primary-disabled,
.button-primary[disabled],
.button-primary:disabled {
color: #9FD0D5 !important;
background: #298CBA !important;
}
a:hover,
a:active,
a:focus {
color: #d54e21;
}
#adminmenu a:hover,
#adminmenu li.menu-top > a:focus,
#adminmenu ul.wp-submenu a:hover,
#the-comment-list .comment a:hover,
#rightnow a:hover,
#media-upload a.del-link:hover,
div.dashboard-widget-submit input:hover,
.subsubsub a:hover,
.subsubsub a.current:hover,
.ui-tabs-nav a:hover,
.plugins .inactive a:hover,
#all-plugins-table .plugins .inactive a:hover,
#search-plugins-table .plugins .inactive a:hover {
color: #d54e21;
}
#the-comment-list .comment-item,
#dashboard-widgets #dashboard_quick_press form p.submit {
border-color: #dfdfdf;
}
#side-sortables .category-tabs .tabs a,
#side-sortables .add-menu-item-tabs .tabs a,
.wp-tab-bar .wp-tab-active a {
color: #333;
}
#rightnow .rbutton {
background-color: #ebebeb;
color: #264761;
}
.submitbox .submit {
background-color: #464646;
color: #ccc;
}
.plugins a.delete:hover,
#all-plugins-table .plugins a.delete:hover,
#search-plugins-table .plugins a.delete:hover,
.submitbox .submitdelete {
color: #f00;
border-bottom-color: #f00;
}
.submitbox .submitdelete:hover,
#media-items a.delete:hover {
color: #fff;
background-color: #f00;
border-bottom-color: #f00;
}
#normal-sortables .submitbox .submitdelete:hover {
color: #000;
background-color: #f00;
border-bottom-color: #f00;
}
.tablenav .dots {
border-color: transparent;
}
.tablenav .next,
.tablenav .prev {
border-color: transparent;
color: #21759b;
}
.tablenav .next:hover,
.tablenav .prev:hover {
border-color: transparent;
color: #d54e21;
}
div.updated,
.login .message {
background-color: #ffffe0;
border-color: #e6db55;
}
.update-message {
color: #000;
}
a.page-numbers {
border-bottom-color: #B8D3E2;
}
.commentlist li {
border-bottom-color: #ccc;
}
.widefat td,
.widefat th {
border-top-color: #fff;
border-bottom-color: #D0DFE9;
}
.widefat th {
text-shadow: rgba(255,255,255,0.8) 0 1px 0;
}
.widefat td {
color: #555;
}
.widefat p,
.widefat ol,
.widefat ul {
color: #333;
}
.widefat thead tr th,
.widefat tfoot tr th,
h3.dashboard-widget-title,
h3.dashboard-widget-title span,
h3.dashboard-widget-title small,
.find-box-head {
color: #333;
}
th.sortable a:hover, th.sortable a:active, th.sortable a:focus {
color: #333;
}
h3.dashboard-widget-title small a {
color: #d7d7d7;
}
h3.dashboard-widget-title small a:hover {
color: #fff;
}
a,
#adminmenu a,
#the-comment-list p.comment-author strong a,
#media-upload a.del-link,
#media-items a.delete,
.plugins a.delete,
.ui-tabs-nav a {
color: #21759b;
}
#adminmenu .awaiting-mod,
#adminmenu .update-plugins,
#sidemenu a .update-plugins,
#rightnow .reallynow {
background-color: #464646;
color: #fff;
-moz-box-shadow: rgba(255,255,255,0.5) 0 1px 0;
-webkit-box-shadow: rgba(255,255,255,0.5) 0 1px 0;
box-shadow: rgba(255,255,255,0.5) 0 1px 0;
}
#plugin-information .action-button {
background-color: #d54e21;
color: #fff;
}
#adminmenu li.current a .awaiting-mod,
#adminmenu li a.wp-has-current-submenu .update-plugins{
background-color: #464646;
color: #fff;
-moz-box-shadow: rgba(255,255,255,0.5) 0 1px 0;
-webkit-box-shadow: rgba(255,255,255,0.5) 0 1px 0;
box-shadow: rgba(255,255,255,0.5) 0 1px 0;
}
div#media-upload-header,
div#plugin-information-header {
background-color: #f9f9f9;
border-bottom-color: #dfdfdf;
}
#currenttheme img {
border-color: #666;
}
#dashboard_secondary div.dashboard-widget-content ul li a {
background-color: #f9f9f9;
}
input.readonly, textarea.readonly {
background-color: #ddd;
}
.quicktags-toolbar input {
background: #fff;
background-image: -ms-linear-gradient(bottom, #e5f0f8, #fff); /* IE10 */
background-image: -moz-linear-gradient(bottom, #e5f0f8, #fff); /* Firefox */
background-image: -o-linear-gradient(bottom, #e5f0f8, #fff); /* Opera */
background-image: -webkit-gradient(linear, left bottom, left top, from(#e5f0f8), to(#fff)); /* old Webkit */
background-image: -webkit-linear-gradient(bottom, #e5f0f8, #fff) !important; /* new Webkit */
background-image: linear-gradient(bottom, #e5f0f8, #fff); /* proposed W3C Markup */
}
#editable-post-name {
background-color: #fffbcc;
}
#edit-slug-box strong,
.tablenav .displaying-num,
#submitted-on,
.submitted-on {
color: #777;
}
.login #nav a,
.login #backtoblog a {
color: #21759b !important;
}
.login #nav a:hover,
.login #backtoblog a:hover {
color: #d54e21 !important;
}
#footer {
color: #777;
border-color: #b0c8d7;
}
#media-items .media-item,
.media-item .describe,
.imgedit-group {
border-color: #dfdfdf;
}
.checkbox,
.side-info,
.plugins tr,
#your-profile #rich_editing {
background-color: #fcfcfc;
}
.plugins .inactive,
.plugins .inactive th,
.plugins .inactive td,
tr.inactive + tr.plugin-update-tr .plugin-update {
background-color: #f4f4f4;
}
.plugin-update-tr .update-message {
background-color: #fffbe4;
border-color: #dfdfdf;
}
.plugins .active,
.plugins .active th,
.plugins .active td {
color: #000;
}
.plugins .inactive a {
color: #557799;
}
#the-comment-list tr.undo,
#the-comment-list div.undo {
background-color: #f4f4f4;
}
#the-comment-list .unapproved {
background-color: #ffffe0;
}
#the-comment-list .approve a {
color: #006505;
}
#the-comment-list .unapprove a {
color: #d98500;
}
table.widefat span.delete a,
table.widefat span.trash a,
table.widefat span.spam a,
#dashboard_recent_comments .delete a,
#dashboard_recent_comments .trash a,
#dashboard_recent_comments .spam a {
color: #bc0b0b;
}
.welcome-panel {
border-color: #d1e5ee;
}
.welcome-panel p {
color: #777;
}
.welcome-panel-column p {
color: #464646;
}
.welcome-panel h3 {
text-shadow: 1px 1px 1px white;
}
.widget,
#widget-list .widget-top,
.postbox,
#titlediv,
#poststuff .postarea,
.stuffbox {
border-color: #d1e5ee;
-moz-box-shadow: inset 0 1px 0 #fff;
-webkit-box-shadow: inset 0 1px 0 #fff;
box-shadow: inset 0 1px 0 #fff;
-webkit-border-radius: 3px;
border-radius: 3px;
}
.widget,
#widget-list .widget-top,
.postbox,
.menu-item-settings {
background-color: #f7fcfe;
}
.postbox h3 {
color: #174f69;
}
.widget .widget-top {
color: #174f69;
}
.sidebar-name:hover h3,
.postbox h3:hover {
color: #000;
}
.curtime #timestamp {
background-image: url(../images/date-button.gif);
}
#quicktags #ed_link {
color: #00f;
}
#rightnow .youhave {
background-color: #f0f6fb;
}
#rightnow a {
color: #448abd;
}
.tagchecklist span a,
#bulk-titles div a {
background: url(../images/xit.gif) no-repeat;
}
.tagchecklist span a:hover,
#bulk-titles div a:hover {
background: url(../images/xit.gif) no-repeat -10px 0;
}
#update-nag, .update-nag {
background-color: #fffbcc;
border-color: #e6db55;
color: #555;
}
.login #backtoblog a {
color: #464646;
}
#wphead {
border-bottom:#d0dfe9 1px solid;
}
#wphead h1 a {
color: #174f69;
}
#footer a:link,
#footer a:visited {
text-decoration: none;
}
#footer a:hover {
color: #000;
text-decoration: underline;
}
.file-error,
abbr.required,
.widget-control-remove:hover,
table.widefat .delete a:hover,
table.widefat .trash a:hover,
table.widefat .spam a:hover,
#dashboard_recent_comments .delete a:hover,
#dashboard_recent_comments .trash a:hover
#dashboard_recent_comments .spam a:hover {
color: #f00;
}
#pass-strength-result {
background-color: #eee;
border-color: #ddd !important;
}
#pass-strength-result.bad {
background-color: #ffb78c;
border-color: #ff853c !important;
}
#pass-strength-result.good {
background-color: #ffec8b;
border-color: #fc0 !important;
}
#pass-strength-result.short {
background-color: #ffa0a0;
border-color: #f04040 !important;
}
#pass-strength-result.strong {
background-color: #c3ff88;
border-color: #8dff1c !important;
}
/* editors */
#quicktags {
border-color: #cfdfe9;
background-color: #cfdfe9;
background-image: url("../images/ed-bg-vs.gif?ver=20101102");
}
.quicktags-toolbar input {
border-color: #b2c4c8;
}
.quicktags-toolbar input:hover {
border-color: #d0dfe9;
background: #f0f8fe;
}
#poststuff .wp-editor-wrap .wp_themeSkin .mceStatusbar {
border-color: #d0dfe9;
}
#poststuff .wp-editor-wrap .wp_themeSkin .mceStatusbar * {
color: #555;
}
#poststuff #editor-toolbar .active {
border-color: #d0dfe9 #d0dfe9 #eff8ff;
background-color: #eff8ff;
color: #333;
}
/* TinyMCE */
#post-status-info {
background-color: #eff8ff;
}
.wp-editor-wrap .wp_themeSkin *,
.wp-editor-wrap .wp_themeSkin a:hover,
.wp-editor-wrap .wp_themeSkin a:link,
.wp-editor-wrap .wp_themeSkin a:visited,
.wp-editor-wrap .wp_themeSkin a:active {
color: #000;
}
/* Containers */
.wp-editor-wrap .wp_themeSkin table.mceLayout {
border-color: #bed1dd #bed1dd #d0dfe9;
}
#editorcontainer #content,
#editorcontainer .wp-editor-wrap .wp_themeSkin .mceIframeContainer {
-moz-box-shadow: inset 1px 1px 2px rgba( 0, 0, 0, 0.1 );
-webkit-box-shadow: inset 1px 1px 2px rgba( 0, 0, 0, 0.1 );
box-shadow: inset 1px 1px 2px rgba( 0, 0, 0, 0.1 );
}
.wp-editor-wrap .wp_themeSkin iframe {
background: transparent;
}
/* Layout */
.wp-editor-wrap .wp_themeSkin .mceStatusbar {
color: #000;
background-color: #f5f5f5;
}
/* Button */
.wp-editor-wrap .wp_themeSkin .mceButton {
border-color: #B0C8D7;
background-color: #cfdfe9; /* Fallback */
background-image: -ms-linear-gradient(bottom, #cfdfe9, #fff); /* IE10 */
background-image: -moz-linear-gradient(bottom, #cfdfe9, #fff); /* Firefox */
background-image: -o-linear-gradient(bottom, #cfdfe9, #fff); /* Opera */
background-image: -webkit-gradient(linear, left bottom, left top, from(#cfdfe9), to(#fff)); /* old Webkit */
background-image: -webkit-linear-gradient(bottom, #cfdfe9, #fff) !important; /* new Webkit */
background-image: linear-gradient(bottom, #cfdfe9, #fff); /* proposed W3C Markup */
}
.wp-editor-wrap .wp_themeSkin a.mceButtonEnabled:hover {
border-color: #5589AA !important;
background-color: #c9c9c9; /* Fallback */
background-image: -ms-linear-gradient(bottom, #bdccd5, #fff); /* IE10 */
background-image: -moz-linear-gradient(bottom, #bdccd5, #fff); /* Firefox */
background-image: -o-linear-gradient(bottom, #bdccd5, #fff); /* Opera */
background-image: -webkit-gradient(linear, left bottom, left top, from(#bdccd5), to(#fff)); /* old Webkit */
background-image: -webkit-linear-gradient(bottom, #bdccd5, #fff) !important; /* new Webkit */
background-image: linear-gradient(bottom, #bdccd5, #fff); /* proposed W3C Markup */
}
.wp-editor-wrap .wp_themeSkin a.mceButton:active,
.wp-editor-wrap .wp_themeSkin a.mceButtonEnabled:active,
.wp-editor-wrap .wp_themeSkin a.mceButtonSelected:active,
.wp-editor-wrap .wp_themeSkin a.mceButtonActive,
.wp-editor-wrap .wp_themeSkin a.mceButtonActive:active,
.wp-editor-wrap .wp_themeSkin a.mceButtonActive:hover {
background: #B0C8D7 !important;
background-image: -ms-linear-gradient(bottom, #fff, #cfdfe9); /* IE10 */
background-image: -moz-linear-gradient(bottom, #fff, #cfdfe9); /* Firefox */
background-image: -o-linear-gradient(bottom, #fff, #cfdfe9); /* Opera */
background-image: -webkit-gradient(linear, left bottom, left top, from(#fff), to(#cfdfe9)); /* old Webkit */
background-image: -webkit-linear-gradient(bottom, #fff, #cfdfe9) !important; /* new Webkit */
background-image: linear-gradient(bottom, #fff, #cfdfe9); /* proposed W3C Markup */
border-color: #5589AA !important;
}
.wp-editor-wrap .wp_themeSkin .mceButtonDisabled {
border-color: #B0C8D7 !important;
}
/* ListBox */
.wp-editor-wrap .wp_themeSkin .mceListBox .mceText,
.wp-editor-wrap .wp_themeSkin .mceListBox .mceOpen {
border-color: #B0C8D7;
background-color: #cfdfe9; /* Fallback */
background-image: -ms-linear-gradient(bottom, #cfdfe9, #fff); /* IE10 */
background-image: -moz-linear-gradient(bottom, #cfdfe9, #fff); /* Firefox */
background-image: -o-linear-gradient(bottom, #cfdfe9, #fff); /* Opera */
background-image: -webkit-gradient(linear, left bottom, left top, from(#cfdfe9), to(#fff)); /* old Webkit */
background-image: -webkit-linear-gradient(bottom, #cfdfe9, #fff) !important; /* new Webkit */
background-image: linear-gradient(bottom, #cfdfe9, #fff); /* proposed W3C Markup */
}
.wp-editor-wrap .wp_themeSkin .mceListBox .mceOpen {
border-left: 0px !important;
}
.wp-editor-wrap .wp_themeSkin table.mceListBoxEnabled:hover .mceOpen,
.wp-editor-wrap .wp_themeSkin .mceListBoxHover .mceOpen,
.wp-editor-wrap .wp_themeSkin .mceListBoxHover:active .mceOpen,
.wp-editor-wrap .wp_themeSkin .mceListBoxSelected .mceOpen,
.wp-editor-wrap .wp_themeSkin .mceListBoxSelected .mceText,
.wp-editor-wrap .wp_themeSkin table.mceListBoxEnabled:active .mceText {
background: #B0C8D7;
border-color: #5589AA !important;
}
/* List Box Hover */
.wp-editor-wrap .wp_themeSkin table.mceListBoxEnabled:hover .mceText,
.wp-editor-wrap .wp_themeSkin .mceListBoxHover .mceText,
.wp-editor-wrap .wp_themeSkin table.mceListBoxEnabled:hover .mceOpen,
.wp-editor-wrap .wp_themeSkin .mceListBoxHover .mceOpen {
border-color: #5589AA !important;
background-color: #c9c9c9; /* Fallback */
background-image: -ms-linear-gradient(bottom, #cfdfe9, #fff); /* IE10 */
background-image: -moz-linear-gradient(bottom, #cfdfe9, #fff); /* Firefox */
background-image: -o-linear-gradient(bottom, #cfdfe9, #fff); /* Opera */
background-image: -webkit-gradient(linear, left bottom, left top, from(#cfdfe9), to(#fff)); /* old Webkit */
background-image: -webkit-linear-gradient(bottom, #cfdfe9, #fff) !important; /* new Webkit */
background-image: linear-gradient(bottom, #cfdfe9, #fff); /* proposed W3C Markup */
}
.wp-editor-wrap .wp_themeSkin select.mceListBox {
border-color: #B2B2B2;
background-color: #fff;
}
/* SplitButton */
.wp-editor-wrap .wp_themeSkin .mceSplitButton a.mceAction,
.wp-editor-wrap .wp_themeSkin .mceSplitButton a.mceOpen {
border-color: #B0C8D7;
}
.wp-editor-wrap .wp_themeSkin .mceSplitButton a.mceOpen:hover,
.wp-editor-wrap .wp_themeSkin .mceSplitButtonSelected a.mceOpen,
.wp-editor-wrap .wp_themeSkin table.mceSplitButtonEnabled:hover a.mceAction,
.wp-editor-wrap .wp_themeSkin .mceSplitButton a.mceAction:hover {
border-color: #5589AA !important;
}
.wp-editor-wrap .wp_themeSkin table.mceSplitButton td {
background-color: #cfdfe9; /* Fallback */
background-image: -ms-linear-gradient(bottom, #cfdfe9, #fff); /* IE10 */
background-image: -moz-linear-gradient(bottom, #cfdfe9, #fff); /* Firefox */
background-image: -o-linear-gradient(bottom, #cfdfe9, #fff); /* Opera */
background-image: -webkit-gradient(linear, left bottom, left top, from(#cfdfe9), to(#fff)); /* old Webkit */
background-image: -webkit-linear-gradient(bottom, #cfdfe9, #fff) !important; /* new Webkit */
background-image: linear-gradient(bottom, #cfdfe9, #fff); /* proposed W3C Markup */
}
.wp-editor-wrap .wp_themeSkin table.mceSplitButton:hover td {
background-image: -ms-linear-gradient(bottom, #cfdfe9, #fff); /* IE10 */
background-image: -moz-linear-gradient(bottom, #cfdfe9, #fff); /* Firefox */
background-image: -o-linear-gradient(bottom, #cfdfe9, #fff); /* Opera */
background-image: -webkit-gradient(linear, left bottom, left top, from(#cfdfe9), to(#fff)); /* old Webkit */
background-image: -webkit-linear-gradient(bottom, #cfdfe9, #fff) !important; /* new Webkit */
background-image: linear-gradient(bottom, #cfdfe9, #fff); /* proposed W3C Markup */
}
.wp-editor-wrap .wp_themeSkin .mceSplitButtonActive {
background-color: #B0C8D7;
}
/* ColorSplitButton */
.wp-editor-wrap .wp_themeSkin div.mceColorSplitMenu table {
background-color: #ebebeb;
border-color: #B2B2B2;
}
.wp-editor-wrap .wp_themeSkin .mceColorSplitMenu a {
border-color: #B2B2B2;
}
.wp-editor-wrap .wp_themeSkin .mceColorSplitMenu a.mceMoreColors {
border-color: #fff;
}
.wp-editor-wrap .wp_themeSkin .mceColorSplitMenu a.mceMoreColors:hover {
border-color: #0A246A;
background-color: #B6BDD2;
}
.wp-editor-wrap .wp_themeSkin a.mceMoreColors:hover {
border-color: #0A246A;
}
/* Menu */
.wp-editor-wrap .wp_themeSkin .mceMenu {
border-color: #ddd;
}
.wp-editor-wrap .wp_themeSkin .mceMenu table {
background-color: #ebeaeb;
}
.wp-editor-wrap .wp_themeSkin .mceMenu .mceText {
color: #000;
}
.wp-editor-wrap .wp_themeSkin .mceMenu .mceMenuItemEnabled a:hover,
.wp-editor-wrap .wp_themeSkin .mceMenu .mceMenuItemActive {
background-color: #f5f5f5;
}
.wp-editor-wrap .wp_themeSkin td.mceMenuItemSeparator {
background-color: #aaa;
}
.wp-editor-wrap .wp_themeSkin .mceMenuItemTitle a {
background-color: #ccc;
border-bottom-color: #aaa;
}
.wp-editor-wrap .wp_themeSkin .mceMenuItemTitle span.mceText {
color: #000;
}
.wp-editor-wrap .wp_themeSkin .mceMenuItemDisabled .mceText {
color: #888;
}
.wp-editor-wrap .wp_themeSkin tr.mceFirst td.mceToolbar {
background: #cfdfe9 url("../images/ed-bg-vs.gif?ver=20101102") repeat-x scroll left top;
border-color: #cfdfe9;
}
.wp-admin #mceModalBlocker {
background: #000;
}
.wp-admin .clearlooks2 .mceFocus .mceTop .mceLeft {
background: #444444;
border-left: 1px solid #999;
border-top: 1px solid #999;
-webkit-border-top-left-radius: 3px;
border-top-left-radius: 3px;
}
.wp-admin .clearlooks2 .mceFocus .mceTop .mceRight {
background: #444444;
border-right: 1px solid #999;
border-top: 1px solid #999;
-webkit-border-top-right-radius: 3px;
border-top-right-radius: 3px;
}
.wp-admin .clearlooks2 .mceMiddle .mceLeft {
background: #f1f1f1;
border-left: 1px solid #999;
}
.wp-admin .clearlooks2 .mceMiddle .mceRight {
background: #f1f1f1;
border-right: 1px solid #999;
}
.wp-admin .clearlooks2 .mceBottom {
background: #f1f1f1;
border-bottom: 1px solid #999;
}
.wp-admin .clearlooks2 .mceBottom .mceLeft {
background: #f1f1f1;
border-bottom: 1px solid #999;
border-left: 1px solid #999;
}
.wp-admin .clearlooks2 .mceBottom .mceCenter {
background: #f1f1f1;
border-bottom: 1px solid #999;
}
.wp-admin .clearlooks2 .mceBottom .mceRight {
background: #f1f1f1;
border-bottom: 1px solid #999;
border-right: 1px solid #999;
}
.wp-admin .clearlooks2 .mceFocus .mceTop span {
color: #e5e5e5;
}
.wp-editor-wrap .wp-switch-editor {
background-color: #f5fafd;
border-color: #d1e5ee #d1e5ee #d1e5ee;
color: #999
}
.wp-editor-wrap.tmce-active .switch-tmce,
.wp-editor-wrap.html-active .switch-html {
background-color: #eff8ff;
border-color: #d1e5ee #d1e5ee #eff8ff;
color: #333;
}
.wp-editor-wrap.quicktags-toolbar input {
color: #464646;
border-color: #d1e5ee;
background-color: #eff8ff;
background-image: -ms-linear-gradient(bottom, #eff8ff, #fff);
background-image: -moz-linear-gradient(bottom, #eff8ff, #fff);
background-image: -o-linear-gradient(bottom, #eff8ff, #fff);
background-image: -webkit-linear-gradient(bottom, #eff8ff, #fff);
background-image: linear-gradient(bottom, #eff8ff, #fff);
}
.wp-editor-wrap .quicktags-toolbar,
.wp-editor-wrap.wp_themeSkin tr.mceFirst td.mceToolbar {
border-bottom: 1px solid #ccc;
background-color: #eff8ff; /* Fallback */
background-image: -ms-linear-gradient(bottom, #cfdfe9, #eff8ff); /* IE10 */
background-image: -moz-linear-gradient(bottom, #cfdfe9, #eff8ff); /* Firefox */
background-image: -o-linear-gradient(bottom, #cfdfe9, #eff8ff); /* Opera */
background-image: -webkit-linear-gradient(bottom, #cfdfe9, #eff8ff); /* new Webkit */
background-image: linear-gradient(bottom, #cfdfe9, #eff8ff); /* proposed W3C Markup */
}
.wp-editor-wrap .quicktags-toolbar input:hover {
border-color: #aaa;
background: #ddd;
}
.wp-editor-wrap.wp_themeSkin .mceButton,
.wp-editor-wrap.wp_themeSkin .mceListBox .mceText,
.wp-editor-wrap.wp_themeSkin .mceListBox .mceOpen {
border-color: #ccc;
background-color: #eff8ff; /* Fallback */
background-image: -ms-linear-gradient(bottom, #eff8ff, #fff); /* IE10 */
background-image: -moz-linear-gradient(bottom, #eff8ff, #fff); /* Firefox */
background-image: -o-linear-gradient(bottom, #eff8ff, #fff); /* Opera */
background-image: -webkit-gradient(linear, left bottom, left top, from(#eff8ff), to(#fff)); /* old Webkit */
background-image: -webkit-linear-gradient(bottom, #eff8ff, #fff); /* new Webkit */
background-image: linear-gradient(bottom, #eff8ff, #fff); /* proposed W3C Markup */
}
.wp-editor-wrap.wp_themeSkin a.mceButtonEnabled:hover {
border-color: #a0a0a0;
background: #ddd; /* Fallback */
background-image: -ms-linear-gradient(bottom, #cfdfe9, #fff); /* IE10 */
background-image: -moz-linear-gradient(bottom, #cfdfe9, #fff); /* Firefox */
background-image: -o-linear-gradient(bottom, #cfdfe9, #fff); /* Opera */
background-image: -webkit-gradient(linear, left bottom, left top, from(#cfdfe9), to(#fff)); /* old Webkit */
background-image: -webkit-linear-gradient(bottom, #cfdfe9, #fff); /* new Webkit */
background-image: linear-gradient(bottom, #cfdfe9, #fff); /* proposed W3C Markup */
}
/* end TinyMCE */
#titlediv #title {
border-color: #bdccd5;
}
#editorcontainer {
border-color: #bdccd5 #bdccd5 #d0dfe9;
}
#post-status-info {
border-color: #d0dfe9 #bdccd5 #bdccd5;
}
.editwidget .widget-inside {
border-color: #d0dfe9;
}
#titlediv #title {
background-color: #fff;
}
#tTips p#tTips_inside {
background-color: #ddd;
color: #333;
}
#timestampdiv input,
#namediv input,
#poststuff .inside .the-tagcloud {
border-color: #ddd;
}
/* menu */
#adminmenuback,
#adminmenuwrap {
background-color: #EFF8FF;
border-color: #D1E5EE;
}
#adminmenushadow,
#adminmenuback {
background-image: url(../images/menu-shadow.png);
background-position: top right;
background-repeat: repeat-y;
}
#adminmenu li.wp-menu-separator {
background: #D1E5EE;
border-color: #bed1dd;
}
#adminmenu div.separator {
border-color: #D1E5EE;
}
#adminmenu li.wp-has-current-submenu.wp-menu-open .wp-menu-toggle,
#adminmenu li.wp-has-current-submenu:hover .wp-menu-toggle {
background: transparent url(../images/arrows-dark-vs.png) no-repeat -1px 6px;
}
#adminmenu .wp-has-submenu:hover .wp-menu-toggle,
#adminmenu .wp-menu-open .wp-menu-toggle {
background: transparent url(../images/arrows-vs.png) no-repeat -2px 6px;
}
#adminmenu a.menu-top,
.folded #adminmenu li.menu-top,
#adminmenu .wp-submenu .wp-submenu-head {
border-top-color: #ffffff;
border-bottom-color: #cae6ff;
}
#adminmenu li.wp-menu-open {
border-color: #d1e5ee;
}
#adminmenu li.menu-top:hover > a,
#adminmenu li.menu-top.focused > a,
#adminmenu li.menu-top > a:focus {
background-color: #e0f1ff;
text-shadow: 0 1px 0 rgba( 255, 255, 255, 0.4 );
}
#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu,
#adminmenu li.current a.menu-top,
.folded #adminmenu li.wp-has-current-submenu,
.folded #adminmenu li.current.menu-top,
#adminmenu .wp-menu-arrow,
#adminmenu .wp-has-current-submenu .wp-submenu .wp-submenu-head {
background-color: #5589AA; /* Fallback */
background-image: -ms-linear-gradient(bottom, #5589AA, #619bbb); /* IE10 */
background-image: -moz-linear-gradient(bottom, #5589AA, #619bbb); /* Firefox */
background-image: -o-linear-gradient(bottom, #5589AA, #619bbb); /* Opera */
background-image: -webkit-gradient(linear, left bottom, left top, from(#5589AA), to(#619bbb)); /* old Webkit */
background-image: -webkit-linear-gradient(bottom, #5589AA, #619bbb); /* new Webkit */
background-image: linear-gradient(bottom, #5589AA, #619bbb); /* proposed W3C Markup */
}
#adminmenu .wp-menu-arrow div {
background-color: #5589AA; /* Fallback */
background-image: -ms-linear-gradient(right bottom, #5589AA, #619bbb); /* IE10 */
background-image: -moz-linear-gradient(right bottom, #5589AA, #619bbb); /* Firefox */
background-image: -o-linear-gradient(right bottom, #5589AA, #619bbb); /* Opera */
background-image: -webkit-gradient(linear, right bottom, left top, from(#5589AA), to(#619bbb)); /* old Webkit */
background-image: -webkit-linear-gradient(right bottom, #5589AA, #619bbb); /* new Webkit */
background-image: linear-gradient(right bottom, #5589AA, #619bbb); /* proposed W3C Markup */
}
#adminmenu li.wp-not-current-submenu .wp-menu-arrow {
border-top-color: #fff;
border-bottom-color: #cae6ff;
background: #e0f1ff;
}
#adminmenu li.wp-not-current-submenu .wp-menu-arrow div {
background: #e0f1ff;
border-color: #cae6ff;
}
.folded #adminmenu li.menu-top li:hover a {
background-image: none;
}
#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu,
#adminmenu li.current a.menu-top,
#adminmenu .wp-has-current-submenu .wp-submenu .wp-submenu-head {
text-shadow: 0 -1px 0 #333;
color: #fff;
border-top-color: #5A8FAD;
border-bottom-color: #5589AA;
}
.folded #adminmenu li.wp-has-current-submenu,
.folded #adminmenu li.current.menu-top {
border-top-color: #5A8FAD;
border-bottom-color: #5589AA;
}
#adminmenu .wp-submenu a:hover,
#adminmenu .wp-submenu a:focus {
background-color: #EFF8FF;
color: #333;
}
#adminmenu .wp-submenu li.current,
#adminmenu .wp-submenu li.current a,
#adminmenu .wp-submenu li.current a:hover {
color: #333;
}
#adminmenu .wp-submenu ul {
background-color: #fff;
}
#adminmenu .wp-submenu-wrap,
#adminmenu .wp-submenu ul {
border-color: #d0dfe9;
}
#adminmenu .wp-submenu-wrap,
.folded #adminmenu .wp-has-current-submenu .wp-submenu-wrap {
-moz-box-shadow: 2px 2px 5px rgba( 0, 0, 0, 0.4 );
-webkit-box-shadow: 2px 2px 5px rgba( 0, 0, 0, 0.4 );
box-shadow: 2px 2px 5px rgba( 0, 0, 0, 0.4 );
}
#adminmenu .wp-submenu .wp-submenu-head {
border-right-color: #e8eff4;
background-color: #EFF8FF;
}
#adminmenu div.wp-submenu {
background-color: transparent;
}
/* collapse menu button */
#collapse-menu {
color: #A0C3D5;
}
#collapse-menu:hover {
color: #5A8FAD;
}
#collapse-button {
border-color: #d0dfe9;
background-color: #eff8ff; /* Fallback */
background-image: -ms-linear-gradient(bottom, #eff8ff, #fff); /* IE10 */
background-image: -moz-linear-gradient(bottom, #eff8ff, #fff); /* Firefox */
background-image: -o-linear-gradient(bottom, #eff8ff, #fff); /* Opera */
background-image: -webkit-gradient(linear, left bottom, left top, from(#eff8ff), to(#fff)); /* old Webkit */
background-image: -webkit-linear-gradient(bottom, #eff8ff, #fff); /* new Webkit */
background-image: linear-gradient(bottom, #eff8ff, #fff); /* proposed W3C Markup */
}
#collapse-menu:hover #collapse-button {
border-color: #A0C3D5;
}
#collapse-button div {
background: transparent url(../images/arrows-vs.png) no-repeat 0 -72px;
}
.folded #collapse-button div {
background-position: 0 -108px;
}
/* Auto-folding of the admin menu */
@media only screen and (max-width: 900px) {
#adminmenu li.menu-top {
border-top-color: #ffffff;
border-bottom-color: #cae6ff;
}
#adminmenu li.wp-has-current-submenu,
#adminmenu li.current.menu-top {
background-color: #5589AA; /* Fallback */
background-image: -ms-linear-gradient(bottom, #5589AA, #619bbb); /* IE10 */
background-image: -moz-linear-gradient(bottom, #5589AA, #619bbb); /* Firefox */
background-image: -o-linear-gradient(bottom, #5589AA, #619bbb); /* Opera */
background-image: -webkit-gradient(linear, left bottom, left top, from(#5589AA), to(#619bbb)); /* old Webkit */
background-image: -webkit-linear-gradient(bottom, #5589AA, #619bbb); /* new Webkit */
background-image: linear-gradient(bottom, #5589AA, #619bbb); /* proposed W3C Markup */
}
#adminmenu li.menu-top li:hover a {
background-image: none;
}
#adminmenu li.wp-has-current-submenu,
#adminmenu li.current.menu-top {
border-top-color: #5A8FAD;
border-bottom-color: #5589AA;
}
#adminmenu .wp-has-current-submenu .wp-submenu-wrap {
-moz-box-shadow: 2px 2px 5px rgba( 0, 0, 0, 0.4 );
-webkit-box-shadow: 2px 2px 5px rgba( 0, 0, 0, 0.4 );
box-shadow: 2px 2px 5px rgba( 0, 0, 0, 0.4 );
}
#collapse-button div {
background-position: 0 -108px;
}
}
/* menu and screen icons */
.icon16,
.icon32,
div.wp-menu-image {
background-color: transparent;
background-repeat: no-repeat;
}
.icon16.icon-dashboard,
.menu-icon-dashboard div.wp-menu-image,
.icon16.icon-post,
.menu-icon-post div.wp-menu-image,
.icon16.icon-media,
.menu-icon-media div.wp-menu-image,
.icon16.icon-links,
.menu-icon-links div.wp-menu-image,
.icon16.icon-page,
.menu-icon-page div.wp-menu-image,
.icon16.icon-comments,
.menu-icon-comments div.wp-menu-image,
.icon16.icon-appearance,
.menu-icon-appearance div.wp-menu-image,
.icon16.icon-plugins,
.menu-icon-plugins div.wp-menu-image,
.icon16.icon-users,
.menu-icon-users div.wp-menu-image,
.icon16.icon-tools,
.menu-icon-tools div.wp-menu-image,
.icon16.icon-settings,
.menu-icon-settings div.wp-menu-image,
.icon16.icon-site,
.menu-icon-site div.wp-menu-image {
background-image: url('../images/menu-vs.png?ver=20120201');
}
.icon16.icon-dashboard,
#adminmenu .menu-icon-dashboard div.wp-menu-image {
background-position: -59px -33px;
}
#adminmenu .menu-icon-dashboard:hover div.wp-menu-image,
#adminmenu .menu-icon-dashboard.wp-has-current-submenu div.wp-menu-image,
#adminmenu .menu-icon-dashboard.current div.wp-menu-image {
background-position: -59px -1px;
}
.icon16.icon-post,
#adminmenu .menu-icon-post div.wp-menu-image {
background-position: -269px -33px;
}
#adminmenu .menu-icon-post:hover div.wp-menu-image,
#adminmenu .menu-icon-post.wp-has-current-submenu div.wp-menu-image,
#adminmenu .menu-icon-post.current div.wp-menu-image {
background-position: -269px -1px;
}
.icon16.icon-media,
#adminmenu .menu-icon-media div.wp-menu-image {
background-position: -119px -33px;
}
#adminmenu .menu-icon-media:hover div.wp-menu-image,
#adminmenu .menu-icon-media.wp-has-current-submenu div.wp-menu-image,
#adminmenu .menu-icon-media.current div.wp-menu-image {
background-position: -119px -1px;
}
.icon16.icon-links,
#adminmenu .menu-icon-links div.wp-menu-image {
background-position: -89px -33px;
}
#adminmenu .menu-icon-links:hover div.wp-menu-image,
#adminmenu .menu-icon-links.wp-has-current-submenu div.wp-menu-image,
#adminmenu .menu-icon-links.current div.wp-menu-image {
background-position: -89px -1px;
}
.icon16.icon-page,
#adminmenu .menu-icon-page div.wp-menu-image {
background-position: -149px -33px;
}
#adminmenu .menu-icon-page:hover div.wp-menu-image,
#adminmenu .menu-icon-page.wp-has-current-submenu div.wp-menu-image,
#adminmenu .menu-icon-page.current div.wp-menu-image {
background-position: -149px -1px;
}
.icon16.icon-comments,
#adminmenu .menu-icon-comments div.wp-menu-image {
background-position: -29px -33px;
}
#adminmenu .menu-icon-comments:hover div.wp-menu-image,
#adminmenu .menu-icon-comments.wp-has-current-submenu div.wp-menu-image,
#adminmenu .menu-icon-comments.current div.wp-menu-image {
background-position: -29px -1px;
}
.icon16.icon-appearance,
#adminmenu .menu-icon-appearance div.wp-menu-image {
background-position: 1px -33px;
}
#adminmenu .menu-icon-appearance:hover div.wp-menu-image,
#adminmenu .menu-icon-appearance.wp-has-current-submenu div.wp-menu-image,
#adminmenu .menu-icon-appearance.current div.wp-menu-image {
background-position: 1px -1px;
}
.icon16.icon-plugins,
#adminmenu .menu-icon-plugins div.wp-menu-image {
background-position: -179px -33px;
}
#adminmenu .menu-icon-plugins:hover div.wp-menu-image,
#adminmenu .menu-icon-plugins.wp-has-current-submenu div.wp-menu-image,
#adminmenu .menu-icon-plugins.current div.wp-menu-image {
background-position: -179px -1px;
}
.icon16.icon-users,
#adminmenu .menu-icon-users div.wp-menu-image {
background-position: -300px -33px;
}
#adminmenu .menu-icon-users:hover div.wp-menu-image,
#adminmenu .menu-icon-users.wp-has-current-submenu div.wp-menu-image,
#adminmenu .menu-icon-users.current div.wp-menu-image {
background-position: -300px -1px;
}
.icon16.icon-tools,
#adminmenu .menu-icon-tools div.wp-menu-image {
background-position: -209px -33px;
}
#adminmenu .menu-icon-tools:hover div.wp-menu-image,
#adminmenu .menu-icon-tools.wp-has-current-submenu div.wp-menu-image,
#adminmenu .menu-icon-tools.current div.wp-menu-image {
background-position: -209px -1px;
}
.icon16.icon-settings,
#adminmenu .menu-icon-settings div.wp-menu-image {
background-position: -239px -33px;
}
#adminmenu .menu-icon-settings:hover div.wp-menu-image,
#adminmenu .menu-icon-settings.wp-has-current-submenu div.wp-menu-image,
#adminmenu .menu-icon-settings.current div.wp-menu-image {
background-position: -239px -1px;
}
.icon16.icon-site,
#adminmenu .menu-icon-site div.wp-menu-image {
background-position: -359px -33px;
}
#adminmenu .menu-icon-site:hover div.wp-menu-image,
#adminmenu .menu-icon-site.wp-has-current-submenu div.wp-menu-image,
#adminmenu .menu-icon-site.current div.wp-menu-image {
background-position: -359px -1px;
}
/* end menu and screen icons */
/* Screen Icons */
.icon32.icon-post,
#icon-edit,
#icon-post,
.icon32.icon-dashboard,
#icon-index,
.icon32.icon-media,
#icon-upload,
.icon32.icon-links,
#icon-link-manager,
#icon-link,
#icon-link-category,
.icon32.icon-page,
#icon-edit-pages,
#icon-page,
.icon32.icon-comments,
#icon-edit-comments,
.icon32.icon-appearance,
#icon-themes,
.icon32.icon-plugins,
#icon-plugins,
.icon32.icon-users,
#icon-users,
#icon-profile,
#icon-user-edit,
.icon32.icon-tools,
#icon-tools,
#icon-admin,
.icon32.icon-settings,
#icon-options-general,
.icon32.icon-site,
#icon-ms-admin {
background-image: url(../images/icons32-vs.png?ver=20111206);
}
.icon32.icon-post,
#icon-edit,
#icon-post {
background-position: -552px -5px;
}
.icon32.icon-dashboard,
#icon-index {
background-position: -137px -5px;
}
.icon32.icon-media,
#icon-upload {
background-position: -251px -5px;
}
.icon32.icon-links,
#icon-link-manager,
#icon-link,
#icon-link-category {
background-position: -190px -5px;
}
.icon32.icon-page,
#icon-edit-pages,
#icon-page {
background-position: -312px -5px;
}
.icon32.icon-comments,
#icon-edit-comments {
background-position: -72px -5px;
}
.icon32.icon-appearance,
#icon-themes {
background-position: -11px -5px;
}
.icon32.icon-plugins,
#icon-plugins {
background-position: -370px -5px;
}
.icon32.icon-users,
#icon-users,
#icon-profile,
#icon-user-edit {
background-position: -600px -5px;
}
.icon32.icon-tools,
#icon-tools,
#icon-admin {
background-position: -432px -5px;
}
.icon32.icon-settings,
#icon-options-general {
background-position: -492px -5px;
}
.icon32.icon-site,
#icon-ms-admin {
background-position: -659px -5px;
}
@media only screen and (-webkit-min-device-pixel-ratio: 1.5) {
.icon32.icon-post,
#icon-edit,
#icon-post,
.icon32.icon-dashboard,
#icon-index,
.icon32.icon-media,
#icon-upload,
.icon32.icon-links,
#icon-link-manager,
#icon-link,
#icon-link-category,
.icon32.icon-page,
#icon-edit-pages,
#icon-page,
.icon32.icon-comments,
#icon-edit-comments,
.icon32.icon-appearance,
#icon-themes,
.icon32.icon-plugins,
#icon-plugins,
.icon32.icon-users,
#icon-users,
#icon-profile,
#icon-user-edit,
.icon32.icon-tools,
#icon-tools,
#icon-admin,
.icon32.icon-settings,
#icon-options-general,
.icon32.icon-site,
#icon-ms-admin {
background-image: url(../images/icons32-vs-2x.png?ver=20120412);
background-size: 708px 45px;
}
.icon16.icon-dashboard,
.menu-icon-dashboard div.wp-menu-image,
.icon16.icon-post,
.menu-icon-post div.wp-menu-image,
.icon16.icon-media,
.menu-icon-media div.wp-menu-image,
.icon16.icon-links,
.menu-icon-links div.wp-menu-image,
.icon16.icon-page,
.menu-icon-page div.wp-menu-image,
.icon16.icon-comments,
.menu-icon-comments div.wp-menu-image,
.icon16.icon-appearance,
.menu-icon-appearance div.wp-menu-image,
.icon16.icon-plugins,
.menu-icon-plugins div.wp-menu-image,
.icon16.icon-users,
.menu-icon-users div.wp-menu-image,
.icon16.icon-tools,
.menu-icon-tools div.wp-menu-image,
.icon16.icon-settings,
.menu-icon-settings div.wp-menu-image,
.icon16.icon-site,
.menu-icon-site div.wp-menu-image {
background-image: url('../images/menu-2x.png?ver=20120412');
background-size: 390px 64px;
}
}
/* end screen icons */
/* Diff */
table.diff .diff-deletedline {
background-color: #fdd;
}
table.diff .diff-deletedline del {
background-color: #f99;
}
table.diff .diff-addedline {
background-color: #dfd;
}
table.diff .diff-addedline ins {
background-color: #9f9;
}
#att-info {
background-color: #E4F2FD;
}
/* edit image */
#sidemenu a {
background-color: #f9f9f9;
border-color: #f9f9f9;
border-bottom-color: #dfdfdf;
}
#sidemenu a.current {
background-color: #fff;
border-color: #dfdfdf #dfdfdf #fff;
color: #D54E21;
}
#screen-meta {
background-color: #EFF8FF;
border-color: #D1E5EE;
-webkit-box-shadow: 0 1px 3px rgba( 0, 0, 0, 0.05 );
box-shadow: 0 1px 3px rgba( 0, 0, 0, 0.05 );
}
#contextual-help-back {
background: #fff;
}
.contextual-help-tabs a:hover {
background-color: #ceeaff;
color: #333;
}
#contextual-help-back,
.contextual-help-tabs .active {
border-color: #D1E5EE;
}
.contextual-help-tabs .active,
.contextual-help-tabs .active a,
.contextual-help-tabs .active a:hover {
background: #fff;
color: #000;
}
/* screen options and help tabs */
#screen-options-link-wrap,
#contextual-help-link-wrap {
background-color: #eff8ff; /* Fallback */
border-right: 1px solid #D1E5EE;
border-left: 1px solid #D1E5EE;
border-bottom: 1px solid #D1E5EE;
background-image: -ms-linear-gradient(bottom, #eff8ff, #eff8ff); /* IE10 */
background-image: -moz-linear-gradient(bottom, #def1ff, #eff8ff); /* Firefox */
background-image: -o-linear-gradient(bottom, #def1ff, #eff8ff); /* Opera */
background-image: -webkit-gradient(linear, left bottom, left top, from(#def1ff), to(#eff8ff)); /* old Webkit */
background-image: -webkit-linear-gradient(bottom, #def1ff, #eff8ff); /* new Webkit */
background-image: linear-gradient(bottom, #def1ff, #eff8ff); /* proposed W3C Markup */
}
#screen-meta-links a.show-settings {
color: #606060;
}
#screen-meta-links a.show-settings:hover {
color: #000;
}
#screen-meta-links a.show-settings {
background: transparent url(../images/arrows-vs.png) no-repeat right 4px;
}
#screen-meta-links a.show-settings.screen-meta-active {
background: transparent url(../images/arrows-vs.png) no-repeat right -31px;
}
/* end screen options and help tabs */
#replyerror {
border-color: #ddd;
background-color: #f9f9f9;
}
/* table vim shortcuts */
.vim-current,
.vim-current th,
.vim-current td {
background-color: #E4F2FD !important;
}
/* Install Plugins */
#plugin-information .fyi ul {
background-color: #eaf3fa;
}
#plugin-information .fyi h2.mainheader {
background-color: #cee1ef;
}
#plugin-information pre,
#plugin-information code {
background-color: #ededff;
}
#plugin-information pre {
border: 1px solid #ccc;
}
/* inline editor */
.inline-edit-row fieldset input[type="text"],
.inline-edit-row fieldset textarea,
#bulk-titles {
border-color: #ddd;
}
.inline-editor div.title {
background-color: #EAF3FA;
}
.inline-editor ul.cat-checklist {
background-color: #fff;
border-color: #ddd;
}
.inline-editor .categories .catshow,
.inline-editor .categories .cathide {
color: #21759b;
}
.inline-editor .quick-edit-save {
background-color: #f1f1f1;
}
fieldset.inline-edit-col-right .inline-edit-col {
border-color: #dfdfdf;
}
.attention {
color: #D54E21;
}
.meta-box-sortables .postbox:hover .handlediv {
background: transparent url(../images/arrows-vs.png) no-repeat 6px 7px;
}
.tablenav .tablenav-pages {
color: #555;
}
.tablenav .tablenav-pages a {
border-color: #d1e5ee;
background: #eee url('../images/menu-bits-vs.gif?ver=20101102') repeat-x scroll left -379px;
}
.tablenav .tablenav-pages a:hover,
.tablenav .tablenav-pages a:focus {
color: #d54e21;
}
.tablenav .tablenav-pages a.disabled,
.tablenav .tablenav-pages a.disabled:hover,
.tablenav .tablenav-pages a.disabled:focus {
color: #aaa;
}
.tablenav .tablenav-pages .current {
background: #dfdfdf;
border-color: #d3d3d3;
}
#availablethemes,
#availablethemes td {
border-color: #ddd;
}
#current-theme img {
border-color: #999;
}
#TB_window #TB_title a.tb-theme-preview-link,
#TB_window #TB_title a.tb-theme-preview-link:visited {
color: #999;
}
#TB_window #TB_title a.tb-theme-preview-link:hover,
#TB_window #TB_title a.tb-theme-preview-link:focus {
color: #ccc;
}
.misc-pub-section {
border-top-color: #fff;
border-bottom-color: #eee;
}
#minor-publishing {
border-bottom-color: #ddd;
}
#post-body .misc-pub-section {
border-left-color: #eee;
}
.post-com-count span {
background-color: #bbb;
}
.form-table .color-palette td {
border-color: #fff;
}
.sortable-placeholder {
border-color: #bbb;
background-color: #f5f5f5;
}
#post-body ul.category-tabs li.tabs a,
#post-body ul.add-menu-item-tabs li.tabs a,
body.press-this ul.category-tabs li.tabs a {
color: #333;
}
.view-switch #view-switch-list {
background: transparent url(../images/list.png) no-repeat 0 0;
}
.view-switch .current #view-switch-list {
background: transparent url(../images/list.png) no-repeat -40px 0;
}
.view-switch #view-switch-excerpt {
background: transparent url(../images/list.png) no-repeat -20px 0;
}
.view-switch .current #view-switch-excerpt {
background: transparent url(../images/list.png) no-repeat -60px 0;
}
#header-logo {
background: transparent url(../images/wp-logo-vs.png?ver=20101102) no-repeat scroll center center;
}
.popular-tags,
.feature-filter {
background-color: #fff;
border-color: #DFDFDF;
}
div.widgets-sortables,
#widgets-left .inactive {
background-color: #f7fcfe;
border-color: #d0dfe9;
}
#available-widgets .widget-holder {
background-color: #f7fcfe;
border-color: #d0dfe9;
}
#available-widgets .widget-description {
color: #555;
}
.sidebar-name {
color: #464646;
background-color: #f7fcfe; /* Fallback */
background-image: -ms-linear-gradient(top, #ECF8FE, #f7fcfe); /* IE10 */
background-image: -moz-linear-gradient(top, #ECF8FE, #f7fcfe); /* Firefox */
background-image: -o-linear-gradient(top, #ECF8FE, #f7fcfe); /* Opera */
background-image: -webkit-gradient(linear, left top, left bottom, from(#ECF8FE), to(#f7fcfe)); /* old Webkit */
background-image: -webkit-linear-gradient(top, #ECF8FE, #f7fcfe); /* new Webkit */
background-image: linear-gradient(top, #ECF8FE, #f7fcfe); /* proposed W3C Markup */
text-shadow: #fff 0 1px 0;
border-color: #d0dfe9;
-moz-box-shadow: inset 0 1px 0 #fff;
-webkit-box-shadow: inset 0 1px 0 #fff;
box-shadow: inset 0 1px 0 #fff;
}
.sidebar-name:hover,
#removing-widget {
color: #d54e21;
}
#removing-widget span {
color: black;
}
.sidebar-name-arrow {
background: transparent url(../images/arrows-vs.png) no-repeat 5px 9px;
}
.sidebar-name:hover .sidebar-name-arrow {
background: transparent url(../images/arrows-dark-vs.png) no-repeat 5px 9px;
}
.in-widget-title {
color: #606060;
}
.deleting .widget-title * {
color: #aaa;
}
.imgedit-menu div {
border-color: #d5d5d5;
background-color: #f1f1f1;
}
.imgedit-menu div:hover {
border-color: #c1c1c1;
background-color: #eaeaea;
}
.imgedit-menu div.disabled {
border-color: #ccc;
background-color: #ddd;
filter: alpha(opacity=50);
opacity: 0.5;
}
#dashboard_recent_comments div.undo {
border-top-color: #dfdfdf;
}
.comment-ays,
.comment-ays th {
border-color: #ddd;
}
.comment-ays th {
background-color: #f1f1f1;
}
/* added from nav-menu.css */
#menu-management .menu-edit {
border-color: #d0dfe9;
}
#post-body {
background: #ffffff;
border-top-color: #fff;
border-bottom-color: #d0dfe9;
}
#nav-menu-header {
border-bottom-color: #d0dfe9;
}
#nav-menu-footer {
border-top-color: #fff;
}
#menu-management .nav-tabs-arrow a {
color: #C1C1C1;
}
#menu-management .nav-tabs-arrow a:hover {
color: #D54E21;
}
#menu-management .nav-tabs-arrow a:active {
color: #464646;
}
#menu-management .nav-tab-active {
border-color: #dfdfdf;
}
#menu-management .nav-tab {
background: #f7fcfe;
border-color: #d0dfe9;
}
.js .input-with-default-title {
color: #aaa;
}
#cancel-save {
color: #ff0000;
}
#cancel-save:hover {
background-color: #FF0000;
color: #fff;
}
.list-container {
border-color: #dfdfdf;
}
.menu-item-handle {
border-color: #d0dfe9;
}
.menu li.deleting .menu-item-handle {
background-color: #f66;
text-shadow: #ccc;
}
.item-type { /* Menu item controls */
color: #999999;
}
.item-controls .menu-item-delete:hover {
color: #ff0000;
}
.nav-menus-php .item-edit {
background: transparent url(../images/arrows-vs.png) no-repeat 8px 10px;
border-bottom-color: #eff8ff;
}
.item-edit:hover {
background: transparent url(../images/arrows-dark-vs.png) no-repeat 8px 10px;
}
.menu-item-settings { /* Menu editing */
border-color: #d0dfe9;
}
.link-to-original {
color: #777;
border-color: #d0dfe9;
}
#cancel-save:hover {
color: #fff !important;
}
#update-menu-item {
color: #fff !important;
}
#update-menu-item:hover,
#update-menu-item:active,
#update-menu-item:focus {
color: #eaf2fa !important;
border-color: #13455b !important;
}
.submitbox .submitcancel {
color: #21759B;
border-bottom-color: #21759B;
}
.submitbox .submitcancel:hover {
background: #21759B;
color: #fff;
}
/* end added from nav-menu.css */
#menu-management .nav-tab-active,
.menu-item-handle,
.menu-item-settings {
-moz-box-shadow: inset 0 1px 0 #fff;
-webkit-box-shadow: inset 0 1px 0 #fff;
box-shadow: inset 0 1px 0 #fff;
}
#menu-management .nav-tab-active {
background: #eff8ff;
border-bottom-color: #eff8ff;
}
#upload-form label {
color: #777;
}
/* custom header & background pages */
/* full screen */
.fullscreen-overlay {
background: #fff;
}
.wp-fullscreen-focus #wp-fullscreen-title,
.wp-fullscreen-focus #wp-fullscreen-container {
border-color: #BED1DD;
}
#fullscreen-topbar {
border-bottom-color: #D1E5EE;
}
/* Begin About Pages */
.about-wrap h1 {
color: #333;
text-shadow: 1px 1px 1px white;
}
.about-text {
color: #777;
}
.wp-badge {
color: #fff;
text-shadow: 0 -1px 0 rgba(22, 57, 81, 0.3);
}
.about-wrap h2 .nav-tab {
color: #21759B;
}
.about-wrap h2 .nav-tab:hover {
color: #d54e21;
}
.about-wrap h2 .nav-tab-active,
.about-wrap h2 .nav-tab-active:hover {
color: #333;
}
.about-wrap h2 .nav-tab-active {
text-shadow: 1px 1px 1px white;
color: #464646;
}
.about-wrap h3 {
color: #333;
text-shadow: 1px 1px 1px white;
}
.about-wrap .feature-section h4 {
color: #464646;
}
.about-wrap .feature-section img {
background: #fff;
border: 1px #ccc solid;
-moz-box-shadow: 0 1px 3px rgba( 0, 0, 0, 0.3 );
-webkit-box-shadow: 0 1px 3px rgba( 0, 0, 0, 0.3 );
box-shadow: 0 1px 3px rgba( 0, 0, 0, 0.3 );
}
.about-wrap .point-releases {
border-bottom: 1px solid #dfdfdf;
}
.about-wrap .point-releases h3 {
border-top: 1px solid #dfdfdf;
}
.about-wrap .point-releases h3:first-child {
border: 0;
}
.about-wrap h4.wp-people-group {
text-shadow: 1px 1px 1px white;
}
.about-wrap li.wp-person img.gravatar {
-moz-box-shadow: 0 0 4px rgba( 0, 0, 0, 0.4 );
-webkit-box-shadow: 0 0 4px rgba( 0, 0, 0, 0.4 );
box-shadow: 0 0 4px rgba( 0, 0, 0, 0.4 );
}
.about-wrap li.wp-person .title {
color: #464646;
text-shadow: 1px 1px 1px white;
}
.freedoms-php .about-wrap ol li {
color: #999;
}
.freedoms-php .about-wrap ol p {
color: #464646;
}
/* End About Pages */
/*------------------------------------------------------------------------------
2.0 - Right to Left Styles
------------------------------------------------------------------------------*/
.rtl .bar {
border-right-color: none;
border-left-color: #99d;
}
.rtl .post-com-count {
background-image: url(../images/bubble_bg-rtl.gif);
}
.rtl #screen-meta-links a.show-settings {
background-position: left 3px;
}
.rtl #screen-meta-links a.show-settings.screen-meta-active {
background-position: left -33px;
}
/* Menu */
.rtl #adminmenushadow,
.rtl #adminmenuback {
background-image: url(../images/menu-shadow-rtl.png);
background-position: top left;
}
.rtl #adminmenu li.wp-has-current-submenu.wp-menu-open .wp-menu-toggle,
.rtl #adminmenu li.wp-has-current-submenu:hover .wp-menu-toggle {
background: transparent url(../images/arrows-dark-vs.png) no-repeat 8px 6px;
}
.rtl #adminmenu .wp-has-submenu:hover .wp-menu-toggle,
.rtl #adminmenu .wp-menu-open .wp-menu-toggle {
background: transparent url(../images/arrows-vs.png) no-repeat 8px 6px;
}
.rtl #adminmenu .wp-submenu .wp-submenu-head {
border-right-color: none;
border-left-color: #d1e5ee;
}
.rtl #adminmenu .wp-submenu-wrap,
.rtl.folded #adminmenu .wp-has-current-submenu .wp-submenu-wrap{
-moz-box-shadow: -2px 2px 5px rgba( 0, 0, 0, 0.4 );
-webkit-box-shadow: -2px 2px 5px rgba( 0, 0, 0, 0.4 );
box-shadow: -2px 2px 5px rgba( 0, 0, 0, 0.4 );
}
/* Collapse Menu Button */
.rtl #collapse-button div {
background-position: 0 -108px;
}
.rtl.folded #collapse-button div {
background-position: 0 -72px;
}
/* Auto-folding of the admin menu for RTL */
@media only screen and (max-width: 900px) {
.rtl #adminmenu .wp-has-current-submenu .wp-submenu-wrap{
-moz-box-shadow: -2px 2px 5px rgba( 0, 0, 0, 0.4 );
-webkit-box-shadow: -2px 2px 5px rgba( 0, 0, 0, 0.4 );
box-shadow: -2px 2px 5px rgba( 0, 0, 0, 0.4 );
}
.rtl #collapse-button div {
background-position: 0 -72px;
}
}
/* edit image */
.rtl .meta-box-sortables .postbox:hover .handlediv {
background: transparent url(../images/arrows-vs.png) no-repeat 6px 7px;
}
.rtl .tablenav .tablenav-pages a {
border-color: #d1e5ee;
background: #eee url('../images/menu-bits-rtl-vs.gif?ver=20100610') repeat-x scroll right -379px;
}
.rtl #post-body .misc-pub-section {
border-right-color: none;
border-left-color: #d1e5ee;
}
.rtl .sidebar-name-arrow {
background: transparent url(../images/arrows-vs.png) no-repeat 5px 9px;
}
.rtl .sidebar-name:hover .sidebar-name-arrow {
background: transparent url(../images/arrows-dark-vs.png) no-repeat 5px 9px;
}
| 01happy-blog | trunk/myblog/wp-admin/css/colors-classic.dev.css | CSS | oos | 57,100 |
.control-section .customize-section-title {
font-family: Tahoma, Arial, sans-serif;
}
.customize-section-title:after {
right: auto;
left: 20px;
}
#customize-header-actions .button-primary {
float: left;
}
#customize-header-actions img {
float: left;
margin-right: 0;
margin-left: 4px;
}
.customize-control {
float: right;
}
.customize-control-radio input,
.customize-control-checkbox input {
margin-right: 0;
margin-left: 5px;
}
/*
* Dropdowns
*/
.customize-section .dropdown {
float: right;
}
.customize-section .dropdown-content {
float: right;
margin-right: 0px;
margin-left: 16px;
-webkit-border-radius: 0 3px 3px 0;
border-radius: 0 3px 3px 0;
}
.customize-control .dropdown-arrow {
right: auto;
left: 0;
border-color: #ccc;
border-style: solid;
border-width: 1px 0 1px 1px;
-webkit-border-radius: 3px 0 0 3px;
border-radius: 3px 0 0 3px;
}
.customize-control .dropdown-arrow:after {
right: auto;
left: 4px;
}
/*
* Color Picker
*/
.customize-control-color .dropdown {
margin-right: 0;
margin-left: 5px;
}
.customize-section input[type="text"].color-picker-hex,
.customize-control-color .farbtastic-placeholder {
float: right;
}
/*
* Image Picker
*/
.customize-section .customize-control-image .actions {
text-align: left;
}
.customize-control-image .library,
.customize-control-image .actions,
.customize-section .customize-control-image .library ul,
.customize-section .customize-control-image .library li,
.customize-section .customize-control-image .library-content {
float: right;
}
| 01happy-blog | trunk/myblog/wp-admin/css/customize-controls-rtl.dev.css | CSS | oos | 1,541 |
html {
background: #f9f9f9;
}
body {
background: #fff;
color: #333;
font-family: sans-serif;
margin: 2em auto;
padding: 1em 2em;
-webkit-border-radius: 3px;
border-radius: 3px;
border: 1px solid #dfdfdf;
max-width: 700px;
}
a {
color: #21759B;
text-decoration: none;
}
a:hover {
color: #D54E21;
}
h1 {
border-bottom: 1px solid #dadada;
clear: both;
color: #666;
font: 24px Georgia, "Times New Roman", Times, serif;
margin: 30px 0 0 0;
padding: 0;
padding-bottom: 7px;
}
h2 {
font-size: 16px;
}
p, li, dd, dt {
padding-bottom: 2px;
font-size: 14px;
line-height: 1.5;
}
code, .code {
font-size: 14px;
}
ul, ol, dl {
padding: 5px 5px 5px 22px;
}
a img {
border:0
}
abbr {
border: 0;
font-variant: normal;
}
#logo {
margin: 6px 0 14px 0;
border-bottom: none;
text-align:center
}
.step {
margin: 20px 0 15px;
}
.step, th {
text-align: left;
padding: 0;
}
.submit input, .button, .button-secondary {
font-family: sans-serif;
text-decoration: none;
font-size: 14px !important;
line-height: 16px;
padding: 6px 12px;
cursor: pointer;
border: 1px solid #bbb;
color: #464646;
-webkit-border-radius: 15px;
border-radius: 15px;
-moz-box-sizing: content-box;
-webkit-box-sizing: content-box;
box-sizing: content-box;
}
.button:hover, .button-secondary:hover, .submit input:hover {
color: #000;
border-color: #666;
}
.button, .submit input, .button-secondary {
background: #f2f2f2 url(../images/white-grad.png) repeat-x scroll left top;
}
.button:active, .submit input:active, .button-secondary:active {
background: #eee url(../images/white-grad-active.png) repeat-x scroll left top;
}
textarea {
border: 1px solid #dfdfdf;
-webkit-border-radius: 3px;
border-radius: 3px;
font-family: sans-serif;
width: 695px;
}
.form-table {
border-collapse: collapse;
margin-top: 1em;
width: 100%;
}
.form-table td {
margin-bottom: 9px;
padding: 10px 20px 10px 0;
border-bottom: 8px solid #fff;
font-size: 14px;
vertical-align: top
}
.form-table th {
font-size: 14px;
text-align: left;
padding: 16px 20px 10px 0;
border-bottom: 8px solid #fff;
width: 140px;
vertical-align: top;
}
.form-table code {
line-height: 18px;
font-size: 14px;
}
.form-table p {
margin: 4px 0 0 0;
font-size: 11px;
}
.form-table input {
line-height: 20px;
font-size: 15px;
padding: 2px;
border: 1px #DFDFDF solid;
-webkit-border-radius: 3px;
border-radius: 3px;
font-family: sans-serif;
}
.form-table input[type=text],
.form-table input[type=password] {
width: 206px;
}
.form-table th p {
font-weight: normal;
}
.form-table.install-success td {
vertical-align: middle;
padding: 16px 20px 10px 0;
}
.form-table.install-success td p {
margin: 0;
font-size: 14px;
}
.form-table.install-success td code {
margin: 0;
font-size: 18px;
}
#error-page {
margin-top: 50px;
}
#error-page p {
font-size: 14px;
line-height: 18px;
margin: 25px 0 20px;
}
#error-page code, .code {
font-family: Consolas, Monaco, monospace;
}
#pass-strength-result {
background-color: #eee;
border-color: #ddd !important;
border-style: solid;
border-width: 1px;
margin: 5px 5px 5px 0;
padding: 5px;
text-align: center;
width: 200px;
display: none;
}
#pass-strength-result.bad {
background-color: #ffb78c;
border-color: #ff853c !important;
}
#pass-strength-result.good {
background-color: #ffec8b;
border-color: #ffcc00 !important;
}
#pass-strength-result.short {
background-color: #ffa0a0;
border-color: #f04040 !important;
}
#pass-strength-result.strong {
background-color: #c3ff88;
border-color: #8dff1c !important;
}
.message {
border: 1px solid #e6db55;
padding: 0.3em 0.6em;
margin: 5px 0 15px;
background-color: #ffffe0;
}
/* install-rtl */
body.rtl {
font-family: Tahoma, arial;
}
.rtl h1 {
font-family: arial;
margin: 5px -4px 0 0;
}
.rtl ul,
.rtl ol {
padding: 5px 22px 5px 5px;
}
.rtl .step,
.rtl th,
.rtl .form-table th {
text-align: right;
}
.rtl .submit input,
.rtl .button,
.rtl .button-secondary {
margin-right: 0;
}
.rtl #dbname,
.rtl #uname,
.rtl #pwd,
.rtl #dbhost,
.rtl #prefix,
.rtl #user_login,
.rtl #admin_email,
.rtl #pass1,
.rtl #pass2 {
direction: ltr;
}
| 01happy-blog | trunk/myblog/wp-admin/css/install.dev.css | CSS | oos | 4,157 |
body {
direction: rtl;
width: 99.5%;
}
.rtl #adminmenuback {
left: auto;
right: 0;
background-image: none;
}
.rtl #adminmenuback,
.rtl #adminmenuwrap {
border-width: 0 0 0 1px;
}
#plupload-upload-ui {
zoom: 1;
}
.post-com-count-wrapper a.post-com-count {
float: none;
}
#adminmenu .wp-submenu ul {
width: 99%;
}
#adminmenu .wp-submenu .wp-submenu .wp-submenu-wrap,
#adminmenu .wp-menu-open .wp-submenu .wp-submenu-wrap {
border: 1px solid #dfdfdf;
}
.folded #adminmenu .wp-submenu {
right: 30px;
top: -4px;
}
#adminmenu .wp-submenu .wp-submenu-head {
padding: 6px 10px 6px 4px;
}
#adminmenu .wp-menu-arrow {
display: none !important;
}
#wpcontent #adminmenu .wp-submenu li.wp-submenu-head {
padding: 3px 10px 4px 4px;
}
div.quicktags-toolbar input {
min-width: 0;
}
.inline-edit-row fieldset label span.title {
float: right;
}
.inline-edit-row fieldset label span.input-text-wrap {
margin-right: 0;
}
p.search-box {
float: left;
}
#bh {
margin: 7px 10px 0 0;
float: left;
}
.postbox div.inside,
.wp-editor-wrap .wp-editor-container .wp-editor-area,
#nav-menu-theme-locations .howto select {
width: 97.5%;
}
/* without this dashboard widgets appear in one column for some screen widths */
div#dashboard-widgets {
padding-right: 0;
padding-left: 1px;
}
#dashboard_quick_press h4 {
text-align: right;
}
.tagchecklist span a {
margin: 4px -9px 0 0;
}
.widefat th input {
margin: 0 5px 0 0;
}
/* ---------- add by navid */
#TB_window {
width: 670px;
position: absolute;
top: 50%;
left: 50%;
margin-right: 335px !important;
}
#dashboard_plugins {
direction: ltr;
}
#dashboard_plugins h3.hndle {
direction: rtl;
}
#dashboard_incoming_links ul li,
#dashboard_secondary ul li,
#dashboard_primary ul li,
p.row-actions {
width: 100%;
}
#post-status-info {
height: 25px;
}
p.submit { /* quick edit and reply in edit-comments.php */
height:22px;
}
form#widgets-filter { /* fix widget page */
position: static;
}
/* nav menus
.menu-max-depth-0 #menu-management { width: 460px; }
.menu-max-depth-1 #menu-management { width: 490px; }
.menu-max-depth-2 #menu-management { width: 520px; }
.menu-max-depth-3 #menu-management { width: 550px; }
.menu-max-depth-4 #menu-management { width: 580px; }
.menu-max-depth-5 #menu-management { width: 610px; }
.menu-max-depth-6 #menu-management { width: 640px; }
.menu-max-depth-7 #menu-management { width: 670px; }
.menu-max-depth-8 #menu-management { width: 700px; }
.menu-max-depth-9 #menu-management { width: 730px; }
.menu-max-depth-10 #menu-management { width: 760px; }
.menu-max-depth-11 #menu-management { width: 790px; }
*/
.menu-item-depth-0 { margin-left: 0px; }
.menu-item-depth-1 { margin-left: -30px; }
.menu-item-depth-2 { margin-left: -60px; }
.menu-item-depth-3 { margin-left: -90px; }
.menu-item-depth-4 { margin-left: -120px; }
.menu-item-depth-5 { margin-left: -150px; }
.menu-item-depth-6 { margin-left: -180px; }
.menu-item-depth-7 { margin-left: -210px; }
.menu-item-depth-8 { margin-left: -240px; }
.menu-item-depth-9 { margin-left: -270px; }
.menu-item-depth-10 { margin-left: -300px; }
.menu-item-depth-11 { margin-left: -330px; }
/*
#menu-to-edit li dl {
padding: 0 !important;
margin: 0 !important;
}
.ui-sortable-helper .menu-item-transport {
margin-top: 13px;
}
.ui-sortable-helper .menu-item-transport .menu-item-transport {
margin-top: 0;
}
*/
#menu-management,
.nav-menus-php .menu-edit,
#nav-menu-header .submitbox {
zoom: 1;
}
.nav-menus-php label {
max-width: 90% !important;
}
p.button-controls,
.nav-menus-php .tabs-panel {
max-width: 90%;
}
.nav-menus-php .major-publishing-actions .publishing-action {
float: none;
}
#wpbody #nav-menu-header label {
float: none;
}
#nav-menu-header {
margin-top: -10px;
}
#nav-menu-footer {
margin-bottom: -20px;
}
#update-nav-menu .publishing-action {
max-width: 200px;
}
#nav-menus-frame #update-nav-menu .delete-action {
margin-top: -25px;
float: left;
}
#menu-to-edit li {
margin-top: -10px;
margin-bottom: -10px;
}
.sortable-placeholder {
margin-top: 0 !important;
margin-left: 0 !important;
margin-bottom: 13px !important;
padding: 0 !important;
}
.auto-add-pages {
clear: both;
float: none;
}
#nav-menus-frame .open-label span {
float: none;
display: inline-block;
}
#nav-menus-frame .delete-action {
float: none;
}
| 01happy-blog | trunk/myblog/wp-admin/css/ie-rtl.dev.css | CSS | oos | 4,325 |
body {
overflow: hidden;
}
#customize-controls a {
text-decoration: none;
}
.customize-section {
border-top: 1px solid #fff;
border-bottom: 1px solid #dfdfdf;
margin: 0;
}
.control-section.customize-section:hover,
.control-section.customize-section.open {
border-top-color: #808080;
}
.control-section.customize-section:hover {
border-bottom-color: #6d6d6d;
}
.customize-section.open:hover {
border-bottom-color: #dfdfdf;
}
.customize-section:last-child {
box-shadow: 0 1px 0 0px #fff;
}
.customize-section-title {
margin: 0;
padding: 15px 20px;
position: relative;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
}
.cannot-expand .customize-section-title {
cursor: auto;
}
.customize-section-content {
display: none;
padding: 10px 20px 15px;
overflow: hidden;
}
.control-section .customize-section-title {
padding: 10px 20px;
font-size: 15px;
font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
font-weight: normal;
text-shadow: 0 1px 0 #fff;
background-color: #f5f5f5;
background-image: -webkit-linear-gradient( top, #f5f5f5, #eee );
background-image: -moz-linear-gradient( top, #f5f5f5, #eee );
background-image: -ms-linear-gradient( top, #f5f5f5, #eee );
background-image: -o-linear-gradient( top, #f5f5f5, #eee );
background-image: linear-gradient( top, #f5f5f5, #eee );
}
.control-section:hover .customize-section-title,
.control-section .customize-section-title:hover,
.control-section.open .customize-section-title {
color: #fff;
text-shadow: 0 -1px 0 #333;
background-color: #808080;
background-image: -webkit-linear-gradient( top, #808080, #6d6d6d );
background-image: -moz-linear-gradient( top, #808080, #6d6d6d );
background-image: -ms-linear-gradient( top, #808080, #6d6d6d );
background-image: -o-linear-gradient( top, #808080, #6d6d6d );
background-image: linear-gradient( top, #808080, #6d6d6d );
}
.control-section.open .customize-section-title {
border-bottom: 1px solid #6d6d6d;
}
.customize-section.open .customize-section-content {
display: block;
background: #fdfdfd;
}
.customize-section-title:after {
content: '';
width: 0;
height: 0;
border-color: #ccc transparent;
border-style: solid;
border-width: 6px 6px 0;
position: absolute;
top: 25px;
right: 20px;
z-index: 1;
}
.cannot-expand .customize-section-title:after {
display: none;
}
.customize-section-title:hover:after {
border-color: #aaa transparent;
}
.control-section .customize-section-title:hover:after {
border-color: #eee transparent;
}
.control-section .customize-section-title:after {
top: 15px;
}
#customize-info .customize-section-content {
background: transparent;
}
#customize-info .preview-notice {
font-size: 13px;
line-height: 24px;
color: #999;
}
#customize-info .theme-name {
font-size: 20px;
font-weight: 200;
line-height: 24px;
color: #333;
display: block;
text-shadow: 0 1px 0 #fff;
}
#customize-info .theme-screenshot {
width: 258px;
border: 1px solid #ccc;
}
#customize-info .theme-description {
margin-top: 1em;
color: #777;
line-height: 20px;
}
#customize-controls .submit {
text-align: center;
}
#customize-theme-controls > ul,
#customize-theme-controls .customize-section-content {
margin: 0;
}
#customize-header-actions .button-primary {
float: right;
margin-top: 11px;
}
#customize-header-actions img {
display: none;
float: right;
margin-top: 13px;
margin-right: 4px;
}
.saving #customize-header-actions img {
display: block;
}
.customize-control {
width: 100%;
float: left;
clear: both;
margin-bottom: 8px;
}
.customize-control-title {
display: block;
line-height: 24px;
font-weight: bold;
}
.customize-control select,
.customize-control input[type="text"],
.customize-control input[type="radio"],
.customize-control input[type="checkbox"],
.customize-control-color .color-picker,
.customize-control-checkbox label,
.customize-control-upload div {
line-height: 28px;
}
.customize-control input[type="text"] {
width: 98%;
line-height: 18px;
margin: 0;
}
.customize-control select {
min-width: 50%;
max-width: 100%;
height: 28px;
line-height: 28px;
}
.customize-control-checkbox input {
margin-right: 5px;
}
.customize-control-radio {
padding: 5px 0 10px;
}
.customize-control-radio .customize-control-title {
margin-bottom: 0;
line-height: 22px;
}
.customize-control-radio label {
line-height: 20px;
}
.customize-control-radio input {
margin-right: 5px;
}
#customize-preview iframe {
width: 100%;
height: 100%;
}
/*
* Style for custom settings
*/
/*
* Dropdowns
*/
.customize-section .dropdown {
float: left;
display: block;
position: relative;
cursor: pointer;
-webkit-border-radius: 3px;
border-radius: 3px;
}
.customize-section .dropdown-content {
overflow: hidden;
float: left;
min-width: 30px;
height: 16px;
line-height: 16px;
margin-right: 16px;
padding: 4px 5px;
background-color: #eee;
border: 1px solid #ccc;
-webkit-border-radius: 3px 0 0 3px;
border-radius: 3px 0 0 3px;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
}
.customize-control .dropdown-arrow {
position: absolute;
top: 0;
bottom: 0;
right: 0;
width: 15px;
border-color: #ccc;
border-style: solid;
border-width: 1px 1px 1px 0;
-webkit-border-radius: 0 3px 3px 0;
border-radius: 0 3px 3px 0;
}
.customize-control .dropdown-arrow:after {
content: '';
width: 0;
height: 0;
border-color: #ccc transparent;
border-style: solid;
border-width: 4px 4px 0 4px;
position: absolute;
top: 50%;
margin-top: -1px;
right: 4px;
z-index: 1;
}
.customize-section .dropdown:hover .dropdown-content,
.customize-control .dropdown:hover .dropdown-arrow {
border-color: #aaa;
}
.customize-section .dropdown:hover .dropdown-arrow:after {
border-color: #aaa transparent;
}
.customize-control .dropdown-status {
display: none;
max-width: 112px;
color: #777;
}
/*
* Color Picker
*/
.customize-control-color .color-picker-hex,
.customize-control-color .farbtastic-placeholder {
display: none;
}
.customize-control-color.open .color-picker-hex,
.customize-control-color.open .farbtastic-placeholder {
display: block;
}
.customize-control-color .dropdown {
margin-right: 5px;
margin-bottom: 5px;
}
.customize-control-color .dropdown .dropdown-content {
background-color: #fff;
border: 1px solid rgba( 0, 0, 0, 0.15 );
}
.customize-control-color .dropdown:hover .dropdown-content {
border-color: rgba( 0, 0, 0, 0.25 );
}
.customize-section input[type="text"].color-picker-hex {
float: left;
width: 85px;
font-family: monospace;
text-align: center;
}
/* The centered cursor overlaps the placeholder in webkit. Hide it when selected. */
.customize-section input[type="text"].color-picker-hex:focus::-webkit-input-placeholder {
color: transparent;
}
.customize-section input[type="text"].color-picker-hex:-moz-placeholder {
color: #999;
}
.customize-control-color .farbtastic-placeholder {
width: 100%;
margin: 5px 0 10px;
float: left;
}
.customize-control-color .farbtastic {
margin: 0 auto;
}
/*
* Image Picker
*/
.customize-control-image .library,
.customize-control-image .actions {
display: none;
float: left;
width: 100%;
}
.customize-control-image.open .library,
.customize-control-image.open .actions {
display: block;
}
.customize-section .customize-control-image .dropdown-content {
height: auto;
min-height: 24px;
min-width: 40px;
padding: 0;
}
.customize-section .customize-control-image .dropdown-status {
padding: 4px 5px;
}
.customize-section .customize-control-image .preview-thumbnail img {
display: block;
width: 100%;
max-width: 122px;
max-height: 98px;
margin: 0 auto;
}
.customize-section .customize-control-image .actions {
text-align: right;
}
.customize-section .customize-control-image .library ul {
border-bottom: 1px solid #dfdfdf;
float: left;
width: 100%;
margin: 10px 0 0;
}
.customize-section .customize-control-image .library li {
color: #999;
float: left;
padding: 3px 5px;
margin: 0;
border-style: solid;
border-color: transparent;
border-width: 1px 1px 0 1px;
}
.customize-section .customize-control-image .library li.library-selected {
margin-bottom: -1px;
padding-bottom: 4px;
color: #777;
background: #fdfdfd;
border-color: #dfdfdf;
-webkit-border-radius: 3px 3px 0 0;
border-radius: 3px 3px 0 0 ;
}
.customize-section .customize-control-image .library-content {
display: none;
width: 100%;
float: left;
padding: 10px 0;
}
.customize-section .customize-control-image .library-content.library-selected {
display: block;
}
.customize-section .customize-control-image .library .thumbnail {
display: block;
width: 100%;
}
.customize-section .customize-control-image .library .thumbnail:hover img {
border-color: #21759b;
}
.customize-section .customize-control-image .library .thumbnail img {
display: block;
max-width: 90%;
max-height: 80px;
margin: 5px auto;
padding: 4px;
background: #fff;
border: 1px solid #dfdfdf;
}
.customize-section .customize-control-upload .upload-fallback,
.customize-section .customize-control-image .upload-fallback {
display: none;
}
.customize-section .customize-control-upload .upload-dropzone,
.customize-section .customize-control-image .upload-dropzone {
display: none;
padding: 15px 10px;
border: 3px dashed #dfdfdf;
margin: 5px auto;
text-align: center;
color: #777;
position: relative;
cursor: default;
}
.customize-section .customize-control-upload .upload-dropzone.supports-drag-drop,
.customize-section .customize-control-image .upload-dropzone.supports-drag-drop {
display: block;
-webkit-transition: border-color 0.1s;
-moz-transition: border-color 0.1s;
-ms-transition: border-color 0.1s;
-o-transition: border-color 0.1s;
transition: border-color 0.1s;
}
.customize-section .customize-control-upload .library ul li,
.customize-section .customize-control-image .library ul li {
cursor: pointer;
}
.customize-section .customize-control-upload .upload-dropzone.supports-drag-drop.drag-over,
.customize-section .customize-control-image .upload-dropzone.supports-drag-drop.drag-over {
border-color: #83b4d8;
}
/**
* iOS can't scroll iframes,
* instead it expands the iframe size to match the size of the content
*/
.ios .wp-full-overlay {
position: relative;
}
.ios #customize-preview {
position: relative;
}
.ios #customize-controls .wp-full-overlay-sidebar-content {
-webkit-overflow-scrolling: touch;
}
/**
* Handle cheaters.
*/
body.cheatin {
min-width: 0;
background: #f9f9f9;
padding: 50px;
}
body.cheatin p {
max-width: 700px;
margin: 0 auto;
padding: 2em;
font-size: 14px;
background: #fff;
border: 1px solid #dfdfdf;
-webkit-border-radius: 3px;
border-radius: 3px;
} | 01happy-blog | trunk/myblog/wp-admin/css/customize-controls.dev.css | CSS | oos | 10,800 |
/*------------------------------------------------------------------------------
Hello, this is the main WordPress admin CSS file.
All the important stuff is in here.
TABLE OF CONTENTS:
------------------
1.0 - Text Elements
2.0 - Forms
3.0 - Actions
4.0 - Notifications
5.0 - TinyMCE
6.0 - Admin Header
6.1 - Screen Options Tabs
6.2 - Help Menu
7.0 - Main Navigation
8.0 - Layout Blocks
9.0 - Dashboard
10.0 - List Posts
10.1 - Inline Editing
11.0 - Write/Edit Post Screen
11.1 - Custom Fields
11.2 - Post Revisions
12.0 - Categories
13.0 - Tags
14.0 - Media Screen
14.1 - Media Library
14.2 - Image Editor
15.0 - Comments Screen
16.0 - Themes
16.1 - Custom Header
16.2 - Custom Background
16.3 - Tabbed Admin Screen Interface
17.0 - Plugins
18.0 - Users
19.0 - Tools
20.0 - Settings
21.0 - Admin Footer
22.0 - About Pages
23.0 - Full Overlay w/ Sidebar
24.0 - Customize Loader
25.0 - Misc
------------------------------------------------------------------------*/
/* 2 column liquid layout */
#wpwrap {
height: auto;
min-height: 100%;
width: 100%;
position: relative;
}
#wpcontent {
height: 100%;
}
#wpcontent,
#footer {
margin-left: 165px;
}
.folded #wpcontent,
.folded #footer {
margin-left: 52px;
}
#wpbody-content {
padding-bottom: 65px;
float: left;
width: 100%;
}
#adminmenuback,
#adminmenuwrap,
#adminmenu,
#adminmenu .wp-submenu,
#adminmenu .wp-submenu-wrap,
.folded #adminmenu .wp-has-current-submenu .wp-submenu {
width: 145px;
}
#adminmenuback {
position: absolute;
top: 0;
bottom: 0;
z-index: -1;
}
#adminmenu {
clear: left;
margin: 0;
padding: 0;
list-style: none;
}
.folded #adminmenuback,
.folded #adminmenuwrap,
.folded #adminmenu,
.folded #adminmenu li.menu-top {
width: 32px;
}
/* inner 2 column liquid layout */
.inner-sidebar {
float: right;
clear: right;
display: none;
width: 281px;
position: relative;
}
.columns-2 .inner-sidebar {
margin-right: auto;
width: 286px;
display: block;
}
.inner-sidebar #side-sortables,
.columns-2 .inner-sidebar #side-sortables {
min-height: 300px;
width: 280px;
padding: 0;
}
.has-right-sidebar .inner-sidebar {
display: block;
}
.has-right-sidebar #post-body {
float: left;
clear: left;
width: 100%;
margin-right: -2000px;
}
.has-right-sidebar #post-body-content {
margin-right: 300px;
float: none;
width: auto;
}
/* 2 columns main area */
#col-container,
#col-left,
#col-right {
overflow: hidden;
padding: 0;
margin: 0;
}
#col-left {
width: 35%;
}
#col-right {
float: right;
clear: right;
width: 65%;
}
.col-wrap {
padding: 0 7px;
}
/* utility classes */
.alignleft {
float: left;
}
.alignright {
float: right;
}
.textleft {
text-align: left;
}
.textright {
text-align: right;
}
.clear {
clear: both;
}
/* Hide visually but not from screen readers */
.screen-reader-text,
.screen-reader-text span {
position: absolute;
left: -1000em;
height: 1px;
width: 1px;
overflow: hidden;
}
.hidden,
.js .closed .inside,
.js .hide-if-js,
.no-js .hide-if-no-js {
display: none;
}
/* include margin and padding in the width calculation of input and textarea */
input[type="text"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="email"],
input[type="url"],
textarea {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
-ms-box-sizing: border-box; /* ie8 only */
box-sizing: border-box;
}
input[type="checkbox"],
input[type="radio"] {
vertical-align: text-top;
padding: 0;
margin: 1px 0 0;
}
input[type="search"] {
-webkit-appearance: textfield;
}
input[type="search"]::-webkit-search-decoration {
display: none;
}
/* general */
html,
body {
height: 100%;
margin: 0;
padding: 0;
}
body {
font-family: sans-serif;
font-size: 12px;
line-height: 1.4em;
min-width: 600px;
}
body.iframe {
min-width: 0;
}
body.login {
background: #fbfbfb;
min-width: 0;
}
iframe,
img {
border: 0;
}
td,
textarea,
input,
select {
font-family: inherit;
font-size: inherit;
font-weight: inherit;
}
td,
textarea {
line-height: inherit;
}
input,
select {
line-height: 15px;
}
a,
input,
select {
outline: 0;
}
blockquote,
q {
quotes: none;
}
blockquote:before,
blockquote:after,
q:before,
q:after {
content: '';
content: none;
}
p {
margin: 1em 0;
}
blockquote {
margin: 1em;
}
label {
cursor: pointer;
}
li,
dd {
margin-bottom: 6px;
}
textarea,
input,
select {
margin: 1px;
padding: 3px;
}
h1,
h2,
h3,
h4,
h5,
h6 {
display: block;
font-weight: bold;
}
h1 {
font-size: 2em;
margin: .67em 0;
}
h2 {
font-size: 1.5em;
margin: .83em 0;
}
h3 {
font-size: 1.17em;
margin: 1em 0;
}
h4 {
font-size: 1em;
margin: 1.33em 0;
}
h5 {
font-size: 0.83em;
margin: 1.67em 0;
}
h6 {
font-size: 0.67em;
margin: 2.33em 0;
}
ul,
ol {
padding: 0;
}
ul {
list-style: none;
}
ol {
list-style-type: decimal;
margin-left: 2em;
}
ul.ul-disc {
list-style: disc outside;
}
ul.ul-square {
list-style: square outside;
}
ol.ol-decimal {
list-style: decimal outside;
}
ul.ul-disc,
ul.ul-square,
ol.ol-decimal {
margin-left: 1.8em;
}
ul.ul-disc > li,
ul.ul-square > li,
ol.ol-decimal > li {
margin: 0 0 0.5em;
}
.code,
code {
font-family: Consolas, Monaco, monospace;
}
kbd,
code {
padding: 1px 3px;
margin: 0 1px;
font-size: 11px;
}
.subsubsub {
list-style: none;
margin: 8px 0 5px;
padding: 0;
white-space: nowrap;
font-size: 12px;
float: left;
}
.subsubsub a {
line-height: 2;
padding: .2em;
text-decoration: none;
}
.subsubsub a .count,
.subsubsub a.current .count {
color: #999;
font-weight: normal;
}
.subsubsub a.current {
font-weight: bold;
background: none;
border: none;
}
.subsubsub li {
display: inline;
margin: 0;
padding: 0;
}
.widefat,
div.updated,
div.error,
.wrap .add-new-h2,
textarea,
input[type="text"],
input[type="password"],
input[type="file"],
input[type="button"],
input[type="submit"],
input[type="reset"],
input[type="email"],
input[type="number"],
input[type="search"],
input[type="tel"],
input[type="url"],
select,
.tablenav .tablenav-pages a,
.tablenav-pages span.current,
#titlediv #title,
.postbox,
#postcustomstuff table,
#postcustomstuff input,
#postcustomstuff textarea,
.imgedit-menu div,
.plugin-update-tr .update-message,
#poststuff .inside .the-tagcloud,
.login form,
#login_error,
.login .message,
#menu-management .menu-edit,
.nav-menus-php .list-container,
.menu-item-handle,
.link-to-original,
.nav-menus-php .major-publishing-actions .form-invalid,
.press-this #message,
#TB_window,
.tbtitle,
.highlight,
.feature-filter,
#widget-list .widget-top,
.editwidget .widget-inside {
-webkit-border-radius: 3px;
border-radius: 3px;
border-width: 1px;
border-style: solid;
}
/* .widefat - main style for tables */
.widefat {
border-spacing: 0;
width: 100%;
clear: both;
margin: 0;
}
.widefat * {
word-wrap: break-word;
}
.widefat a {
text-decoration: none;
}
.widefat thead th:first-of-type {
-webkit-border-top-left-radius: 3px;
border-top-left-radius: 3px;
}
.widefat thead th:last-of-type {
-webkit-border-top-right-radius: 3px;
border-top-right-radius: 3px;
}
.widefat tfoot th:first-of-type {
-webkit-border-bottom-left-radius: 3px;
border-bottom-left-radius: 3px;
}
.widefat tfoot th:last-of-type {
-webkit-border-bottom-right-radius: 3px;
border-bottom-right-radius: 3px;
}
.widefat td,
.widefat th {
border-width: 1px 0;
border-style: solid;
}
.widefat tfoot th {
border-bottom: none;
}
.widefat .no-items td {
border-bottom-width: 0;
}
.widefat td {
font-size: 12px;
padding: 4px 7px 2px;
vertical-align: top;
}
.widefat td p,
.widefat td ol,
.widefat td ul {
font-size: 12px;
}
.widefat th {
padding: 7px 7px 8px;
text-align: left;
line-height: 1.3em;
font-size: 14px;
}
.widefat th input {
margin: 0 0 0 8px;
padding: 0;
vertical-align: text-top;
}
.widefat .check-column {
width: 2.2em;
padding: 11px 0 0;
vertical-align: top;
}
.widefat tbody th.check-column {
padding: 9px 0 22px;
}
.widefat .num,
.column-comments,
.column-links,
.column-posts {
text-align: center;
}
.widefat th#comments {
vertical-align: middle;
}
.wrap {
margin: 4px 15px 0 0;
}
div.updated,
div.error {
padding: 0 0.6em;
margin: 5px 15px 2px;
}
div.updated p,
div.error p {
margin: 0.5em 0;
padding: 2px;
}
.wrap div.updated,
.wrap div.error,
.media-upload-form div.error {
margin: 5px 0 15px;
}
.wrap h2,
.subtitle {
font-weight: normal;
margin: 0;
text-shadow: #fff 0 1px 0;
}
.wrap h2 {
font-size: 23px;
padding: 9px 15px 4px 0;
line-height: 29px;
}
.subtitle {
font-size: 14px;
padding-left: 25px;
}
.wrap .add-new-h2 {
font-family: sans-serif;
margin-left: 4px;
padding: 3px 8px;
position: relative;
top: -3px;
text-decoration: none;
font-size: 12px;
border: 0 none;
}
.wrap h2.long-header {
padding-right: 0;
}
/*------------------------------------------------------------------------------
1.0 - Text Styles
------------------------------------------------------------------------------*/
div.sidebar-name h3,
#menu-management .nav-tab,
#dashboard_plugins h5,
a.rsswidget,
#dashboard_right_now td.b,
#dashboard-widgets h4,
.tool-box .title,
#poststuff h3,
.metabox-holder h3,
.pressthis a,
#your-profile legend,
.inline-edit-row fieldset span.title,
.inline-edit-row fieldset span.checkbox-title,
.tablenav .displaying-num,
.widefat th,
.quicktags,
.search {
font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
}
h2 .nav-tab,
.wrap h2,
.subtitle,
.login form .input {
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", sans-serif;
}
.quicktags,
.search {
font-size: 12px;
}
.icon32 {
float: left;
height: 34px;
margin: 7px 8px 0 0;
width: 36px;
}
.icon16 {
height: 18px;
width: 18px;
padding: 6px 6px;
margin: -6px 0 0 -8px;
float: left;
}
.key-labels label {
line-height: 24px;
}
.pre {
/* http://www.longren.org/2006/09/27/wrapping-text-inside-pre-tags/ */
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
}
.howto {
font-style: italic;
display: block;
font-family: sans-serif;
}
p.install-help {
margin: 8px 0;
font-style: italic;
}
.no-break {
white-space: nowrap;
}
/*------------------------------------------------------------------------------
2.0 - Forms
------------------------------------------------------------------------------*/
.wp-admin select {
padding: 2px;
height: 2em;
}
.wp-admin select[multiple] {
height: auto;
}
select option {
padding: 2px;
}
.submit {
padding: 1.5em 0;
margin: 5px 0;
-webkit-border-bottom-left-radius: 3px;
-webkit-border-bottom-right-radius: 3px;
border-bottom-left-radius: 3px;
border-bottom-right-radius: 3px;
}
form p.submit a.cancel:hover {
text-decoration: none;
}
.submit input,
.button,
input.button,
.button-primary,
input.button-primary,
.button-secondary,
input.button-secondary,
.button-highlighted,
input.button-highlighted,
#postcustomstuff .submit input {
text-decoration: none;
font-size: 12px !important;
line-height: 13px;
padding: 3px 8px;
cursor: pointer;
border-width: 1px;
border-style: solid;
-webkit-border-radius: 11px;
border-radius: 11px;
-moz-box-sizing: content-box;
-webkit-box-sizing: content-box;
box-sizing: content-box;
}
#minor-publishing-actions input,
#major-publishing-actions input,
#minor-publishing-actions .preview {
min-width: 80px;
text-align: center;
}
textarea.all-options,
input.all-options {
width: 250px;
}
input.large-text,
textarea.large-text {
width: 99%;
}
input.regular-text,
#adduser .form-field input {
width: 25em;
}
input.small-text {
width: 50px;
}
input[type="number"].small-text {
width: 60px;
}
#doaction,
#doaction2,
#post-query-submit {
margin-right: 8px;
}
.tablenav select[name="action"],
.tablenav select[name="action2"] {
width: 130px;
}
.tablenav select[name="m"] {
width: 155px;
}
.tablenav select#cat {
width: 170px;
}
#wpcontent option {
padding: 2px;
}
#timezone_string option {
margin-left: 1em;
}
label,
#your-profile label + a {
vertical-align: middle;
}
#misc-publishing-actions label {
vertical-align: baseline;
}
#pass-strength-result {
border-style: solid;
border-width: 1px;
float: left;
margin: 13px 5px 5px 1px;
padding: 3px 5px;
text-align: center;
width: 200px;
display: none;
}
.indicator-hint {
padding-top: 8px;
}
p.search-box {
float: right;
margin: 0;
}
input[type="text"].ui-autocomplete-loading {
background: transparent url('../images/loading.gif') no-repeat right center;
visibility: visible;
}
ul#add-to-blog-users {
margin: 0 0 0 14px;
}
.ui-autocomplete-input.open {
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
}
.ui-autocomplete {
padding: 0;
margin: 0;
list-style: none;
position: absolute;
z-index: 10000;
border-bottom-right-radius: 3px;
border-bottom-left-radius: 3px;
border-width: 1px;
border-style: solid;
}
.ui-autocomplete li {
margin-bottom: 0;
white-space: nowrap;
text-align: left;
}
.ui-autocomplete li a {
display: block;
height: 100%;
padding: 4px 10px;
}
.ui-autocomplete li a.ui-state-hover {
cursor: pointer;
}
/*------------------------------------------------------------------------------
3.0 - Actions
------------------------------------------------------------------------------*/
#major-publishing-actions {
padding: 10px 10px 8px;
clear: both;
border-top: 1px solid #f5f5f5;
margin-top: -2px;
}
#delete-action {
line-height: 25px;
vertical-align: middle;
text-align: left;
float: left;
}
#publishing-action {
text-align: right;
float: right;
line-height: 23px;
}
#misc-publishing-actions {
padding: 6px 0 0;
}
.misc-pub-section {
padding: 6px 10px 8px;
border-width: 1px 0;
border-style: solid;
}
.misc-pub-section:first-child {
border-top-width: 0;
}
.misc-pub-section-last {
border-bottom-width: 0;
}
#minor-publishing-actions {
padding: 10px 10px 2px 8px;
text-align: right;
}
#minor-publishing {
border-bottom-width: 1px;
border-bottom-style: solid;
-webkit-box-shadow: 0 1px 0 #fff;
-moz-box-shadow: 0 1px 0 #fff;
box-shadow: 0 1px 0 #fff;
}
#save-post {
float: left;
}
#minor-publishing .ajax-loading {
padding: 3px 0 0 4px;
float: left;
}
.preview {
float: right;
}
#sticky-span {
margin-left: 18px;
}
.side-info {
margin: 0;
padding: 4px;
font-size: 11px;
}
.side-info h5 {
padding-bottom: 7px;
font-size: 14px;
margin: 12px 2px 5px;
border-bottom-width: 1px;
border-bottom-style: solid;
}
.side-info ul {
margin: 0;
padding-left: 18px;
list-style: square;
}
a.button,
a.button-primary,
a.button-secondary {
line-height: 15px;
padding: 3px 10px;
white-space: nowrap;
-webkit-border-radius: 10px;
}
.approve,
.unapproved .unapprove {
display: none;
}
.unapproved .approve,
.spam .approve,
.trash .approve {
display: inline;
}
td.action-links,
th.action-links {
text-align: right;
}
.describe .del-link {
padding-left: 5px;
}
/*------------------------------------------------------------------------------
4.0 - Notifications
------------------------------------------------------------------------------*/
#update-nag,
.update-nag {
line-height: 19px;
padding: 5px 0;
font-size: 12px;
text-align: center;
margin: -1px 15px 0 5px;
border-width: 1px;
border-style: solid;
-webkit-border-bottom-right-radius: 3px;
-webkit-border-bottom-left-radius: 3px;
border-bottom-right-radius: 3px;
border-bottom-left-radius: 3px;
}
.plugins .plugin-update {
padding: 0;
}
.plugin-update .update-message {
margin: 0 10px 8px 31px;
font-weight: bold;
}
ul#dismissed-updates {
display: none;
}
form.upgrade {
margin-top: 8px;
}
form.upgrade .hint {
font-style: italic;
font-size: 85%;
margin: -0.5em 0 2em 0;
}
.ajax-feedback {
visibility: hidden;
vertical-align: bottom;
}
#ajax-response.alignleft {
margin-left: 2em;
}
/*------------------------------------------------------------------------------
6.0 - Admin Header
------------------------------------------------------------------------------*/
#adminmenu a,
#sidemenu a,
#taglist a,
#catlist a {
text-decoration: none;
}
/*------------------------------------------------------------------------------
6.1 - Screen Options Tabs
------------------------------------------------------------------------------*/
#screen-options-wrap,
#contextual-help-wrap {
margin: 0;
padding: 8px 20px 12px;
position: relative;
overflow: auto;
}
#screen-meta .screen-reader-text {
visibility: hidden;
}
#screen-meta-links {
margin: 0 24px 0 0;
}
/* screen options and help tabs revert */
#screen-meta {
display: none;
position: relative;
margin: 0 15px 0 5px;
border-width: 0 1px 1px;
border-style: none solid solid;
}
#screen-options-link-wrap,
#contextual-help-link-wrap {
float: right;
height: 23px;
padding: 0;
margin: 0 0 0 6px;
font-family: sans-serif;
}
#screen-options-link-wrap,
#contextual-help-link-wrap,
#screen-meta {
-webkit-border-bottom-left-radius: 3px;
-webkit-border-bottom-right-radius: 3px;
border-bottom-left-radius: 3px;
border-bottom-right-radius: 3px;
}
#screen-meta-links .screen-meta-toggle {
position: relative;
top: -1px;
}
#screen-meta-links a.show-settings {
text-decoration: none;
z-index: 1;
padding: 1px 16px 0 6px;
height: 22px;
line-height: 22px;
font-size: 12px;
display: block;
text-shadow: rgba(255,255,255,0.7) 0 1px 0;
}
#screen-meta-links a.show-settings:hover {
text-decoration: none;
}
/* end screen options and help tabs */
.toggle-arrow {
background-repeat: no-repeat;
background-position: top left;
background-color: transparent;
height: 22px;
line-height: 22px;
display: block;
}
.toggle-arrow-active {
background-position: bottom left;
}
#screen-options-wrap h5,
#contextual-help-wrap h5 {
margin: 8px 0;
font-size: 13px;
}
.metabox-prefs label {
display: inline-block;
padding-right: 15px;
white-space: nowrap;
line-height: 30px;
}
.metabox-prefs label input {
margin: 0 5px 0 2px;
}
.metabox-prefs .columns-prefs label input {
margin: 0 2px;
}
.metabox-prefs label a {
display: none;
}
/*------------------------------------------------------------------------------
6.2 - Help Menu
------------------------------------------------------------------------------*/
#contextual-help-wrap {
padding: 0;
margin-left: -4px;
}
#contextual-help-columns {
position: relative;
}
#contextual-help-back {
position: absolute;
top: 0;
bottom: 0;
left: 150px;
right: 170px;
border-width: 0 1px;
border-style: solid;
}
#contextual-help-wrap.no-sidebar #contextual-help-back {
right: 0;
border-right-width: 0;
-webkit-border-bottom-right-radius: 2px;
border-bottom-right-radius: 2px;
}
.contextual-help-tabs {
float: left;
width: 150px;
margin: 0;
}
.contextual-help-tabs ul {
margin: 1em 0;
}
.contextual-help-tabs li {
margin-bottom: 0;
list-style-type: none;
border-style: solid;
border-width: 1px 0;
border-color: transparent;
}
.contextual-help-tabs a {
display: block;
padding: 5px 5px 5px 12px;
line-height: 18px;
text-decoration: none;
}
.contextual-help-tabs .active {
padding: 0;
margin: 0 -1px 0 0;
border-width: 1px 0 1px 1px;
border-style: solid;
}
.contextual-help-tabs-wrap {
padding: 0 20px;
overflow: auto;
}
.help-tab-content {
display: none;
margin: 0 22px 12px 0;
line-height: 1.6em;
}
.help-tab-content.active {
display: block;
}
.help-tab-content li {
list-style-type: disc;
margin-left: 18px;
}
.contextual-help-sidebar {
width: 150px;
float: right;
padding: 0 8px 0 12px;
overflow: auto;
}
/*------------------------------------------------------------------------------
7.0 - Main Navigation (Left Menu)
------------------------------------------------------------------------------*/
#adminmenuback,
#adminmenuwrap {
border-width: 0 1px 0 0;
border-style: solid;
}
#adminmenuwrap {
position: relative;
float: left;
}
#adminmenushadow {
position: absolute;
top: 0;
right: 0;
bottom: 0;
width: 6px;
z-index: 20;
}
/* side admin menu */
#adminmenu * {
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
}
#adminmenu .wp-submenu {
list-style: none;
padding: 0;
margin: 0;
overflow: hidden;
}
#adminmenu li .wp-submenu,
.folded #adminmenu .wp-has-current-submenu .wp-submenu {
display: none;
position: absolute;
top: -1px;
left: 146px;
z-index: 999;
overflow: hidden;
}
.js #adminmenu .wp-submenu.sub-open,
.folded #adminmenu .wp-has-current-submenu .wp-submenu.sub-open,
.no-js #adminmenu .wp-has-submenu:hover .wp-submenu,
#adminmenu .wp-has-current-submenu .wp-submenu,
#adminmenu li.focused .wp-submenu {
display: block;
}
#adminmenu .wp-has-current-submenu .wp-submenu {
position: relative;
z-index: 2;
top: auto;
left: auto;
right: auto;
bottom: auto;
padding: 0;
}
#adminmenu .wp-has-current-submenu .wp-submenu-wrap {
-moz-box-shadow: none;
-webkit-box-shadow: none;
box-shadow: none;
}
.folded #adminmenu .wp-submenu,
.folded #adminmenu .wp-has-current-submenu .wp-submenu {
top: -5px;
left: 26px;
}
#adminmenu .wp-submenu.sub-open,
#adminmenu li.focused.wp-not-current-submenu .wp-submenu,
.folded #adminmenu li.focused.wp-has-current-submenu .wp-submenu,
.folded #adminmenu .wp-has-current-submenu .wp-submenu.sub-open,
.no-js #adminmenu .wp-has-submenu:hover .wp-submenu,
.no-js.folded #adminmenu .wp-has-current-submenu:hover .wp-submenu {
padding: 0 8px 8px 0;
}
.no-js #adminmenu .wp-has-current-submenu:hover .wp-submenu,
#adminmenu .wp-has-current-submenu .wp-submenu {
padding: 0;
}
#adminmenu .wp-submenu a {
font-size: 12px;
line-height: 18px;
}
#adminmenu a.menu-top,
#adminmenu .wp-submenu-head {
font-size: 13px;
line-height: 18px;
}
#adminmenu div.wp-submenu-head {
display: none;
}
.folded #adminmenu div.wp-submenu-head {
display: block;
}
.folded #adminmenu a.menu-top,
body.no-js #adminmenu .wp-menu-toggle,
.folded #adminmenu div.wp-menu-toggle {
display: none;
}
#adminmenu div.wp-menu-image {
float: left;
width: 28px;
height: 28px;
}
.folded #adminmenu div.wp-menu-image {
width: 30px;
}
#adminmenu li {
margin: 0;
padding: 0;
cursor: pointer;
}
#adminmenu a {
display: block;
line-height: 18px;
padding: 2px 5px;
}
#adminmenu li.menu-top {
min-height: 29px;
position: relative;
}
#adminmenu a.menu-top {
font-weight: bold;
line-height: 18px;
min-width: 10em;
padding: 5px 5px;
border-width: 1px 0 1px;
border-style: solid;
}
#adminmenu li.wp-menu-open {
border-width: 0 0 1px;
border-style: solid;
}
#adminmenu .wp-submenu ul {
padding: 4px 0;
}
#adminmenu .wp-submenu a {
margin: 0;
}
#adminmenu li li {
margin-left: 8px;
}
#adminmenu .wp-submenu a,
#adminmenu li li a,
.folded #adminmenu .wp-not-current-submenu li a {
padding-left: 12px;
}
#adminmenu .wp-not-current-submenu li a {
padding-left: 18px;
}
.folded #adminmenu li li {
margin-left: 0;
}
.folded #adminmenu li li a {
padding-left: 0;
}
.wp-menu-arrow {
display: none;
cursor: auto;
z-index: 25;
position: absolute;
right: 100%;
margin: 0;
height: 30px;
width: 6px;
-moz-transform: translate( 146px );
-webkit-transform: translate( 146px );
-o-transform: translate( 146px );
-ms-transform: translate( 146px );
transform: translate( 146px );
}
#adminmenu li.wp-has-current-submenu .wp-menu-arrow,
#adminmenu li.menu-top:hover .wp-menu-arrow,
#adminmenu li.current .wp-menu-arrow,
#adminmenu li.focused .wp-menu-arrow,
#adminmenu li.menu-top.wp-has-submenu:hover .wp-menu-arrow div {
display: block;
}
#adminmenu li.wp-not-current-submenu:hover .wp-menu-arrow div {
display: none;
}
#adminmenu li.menu-top:hover .wp-menu-arrow,
#adminmenu li.menu-top.focused .wp-menu-arrow {
z-index: 1001;
}
.ie8 #adminmenu li.menu-top:hover .wp-menu-arrow {
display: none;
}
#adminmenu .wp-menu-arrow div {
position: absolute;
top: 7px;
left: -1px;
width: 14px;
height: 15px;
-moz-transform: matrix( -0.6, 1, 0.6, 1, 0, 0 );
-webkit-transform: matrix( -0.6, 1, 0.6, 1, 0, 0 );
-o-transform: matrix( -0.6, 1, 0.6, 1, 0, 0 );
-ms-transform: matrix( -0.6, 1, 0.6, 1, 0, 0 );
transform: matrix( -0.6, 1, 0.6, 1, 0, 0 );
}
#adminmenu li.wp-not-current-submenu .wp-menu-arrow {
-moz-transform: translate( 145px );
-webkit-transform: translate( 145px );
-o-transform: translate( 145px );
-ms-transform: translate( 145px );
transform: translate( 145px );
height: 28px;
border-width: 1px 0;
border-style: solid;
}
.folded .wp-menu-arrow {
-moz-transform: translate( 33px );
-webkit-transform: translate( 33px );
-o-transform: translate( 33px );
-ms-transform: translate( 33px );
transform: translate( 33px );
}
#adminmenu .wp-not-current-submenu .wp-menu-arrow div {
width: 15px;
top: 6px;
border-width: 0 0 1px 1px;
border-style: solid;
}
.wp-menu-arrow,
.folded #adminmenu li.menu-top:hover .wp-menu-arrow {
display: none;
}
.folded #adminmenu li.current:hover .wp-menu-arrow,
.folded #adminmenu li.menu-top.wp-menu-open:hover .wp-menu-arrow {
display: block;
z-index: 125;
}
#adminmenu .wp-submenu li {
padding: 0;
margin: 0;
}
.folded #adminmenu li.menu-top {
border-width: 1px 0;
border-style: solid none;
}
#adminmenu .wp-menu-image img {
float: left;
padding: 5px 0 0 2px;
opacity: 0.6;
filter: alpha(opacity=60);
}
#adminmenu li.menu-top:hover .wp-menu-image img,
#adminmenu li.wp-has-current-submenu .wp-menu-image img {
opacity: 1;
filter: alpha(opacity=100);
}
#adminmenu li.wp-menu-separator {
height: 3px;
padding: 0;
margin: 0;
border-width: 1px 0;
border-style: solid;
cursor: inherit;
}
#adminmenu div.separator {
height: 1px;
padding: 0;
border-width: 1px 0 0 0;
border-style: solid;
}
#adminmenu .wp-submenu .wp-submenu-head {
padding: 6px 4px 5px 10px;
cursor: default;
border-width: 1px 0;
border-style: solid;
}
#adminmenu li .wp-submenu-wrap {
border-width: 1px 1px 1px 0;
border-style: solid solid solid none;
position: relative;
-webkit-border-bottom-right-radius: 3px;
-webkit-border-top-right-radius: 3px;
border-bottom-right-radius: 3px;
border-top-right-radius: 3px;
}
#adminmenu li.wp-menu-open .wp-submenu-wrap {
border: 0 none;
}
.folded #adminmenu .wp-submenu .wp-submenu-wrap {
margin-top: 3px;
}
.folded #adminmenu .wp-has-current-submenu {
margin-bottom: 1px;
}
.folded #adminmenu .wp-has-current-submenu.menu-top-last {
margin-bottom: 0;
}
.folded #adminmenu .wp-has-current-submenu .wp-submenu-wrap {
margin-top: 4px;
}
.folded #adminmenu .wp-submenu ul {
border-width: 0 0 0 1px;
border-style: solid;
}
.folded #adminmenu .wp-submenu a {
padding-left: 10px;
}
.folded #adminmenu a.wp-has-submenu {
margin-left: 40px;
}
#adminmenu .wp-menu-toggle {
width: 18px;
clear: right;
float: right;
margin: 1px 0 0;
height: 27px;
padding: 1px 2px 0 0;
cursor: pointer;
}
#adminmenu .wp-menu-image a {
height: 24px;
}
#adminmenu .awaiting-mod,
#adminmenu span.update-plugins,
#sidemenu li a span.update-plugins {
position: absolute;
font-family: sans-serif;
font-size: 9px;
line-height: 17px;
font-weight: bold;
margin-top: 1px;
margin-left: 7px;
-webkit-border-radius: 10px;
border-radius: 10px;
}
#adminmenu li .awaiting-mod span,
#adminmenu li span.update-plugins span,
#sidemenu li a span.update-plugins span {
display: block;
padding: 0 6px;
}
#adminmenu li span.count-0,
#sidemenu li a .count-0 {
display: none;
}
#collapse-menu {
font-size: 12px;
line-height: 34px;
}
.folded #collapse-menu span {
display: none;
}
#collapse-button,
#collapse-button div {
width: 15px;
height: 15px;
}
#collapse-button {
float: left;
margin: 8px 6px;
border-width: 1px;
border-style: solid;
-webkit-border-radius: 10px;
border-radius: 10px;
}
/* Auto-folding of the admin menu */
@media only screen and (max-width: 900px) {
#wpcontent,
#footer {
margin-left: 52px;
}
#adminmenuback,
#adminmenuwrap,
#adminmenu,
#adminmenu li.menu-top {
width: 32px;
}
#adminmenu .wp-has-current-submenu .wp-submenu {
display: none;
position: absolute;
width: 145px;
z-index: 999;
overflow: hidden;
}
#adminmenu .wp-has-current-submenu .wp-submenu.sub-open {
display: block;
}
#adminmenu li .wp-submenu,
#adminmenu .wp-has-current-submenu .wp-submenu {
top: -5px;
left: 26px;
}
#adminmenu li.focused.wp-has-current-submenu .wp-submenu,
#adminmenu .wp-has-current-submenu .wp-submenu.sub-open {
padding: 0 8px 8px 0;
}
#adminmenu div.wp-submenu-head {
display: block;
}
#adminmenu a.menu-top,
#adminmenu div.wp-menu-toggle {
display: none;
}
#adminmenu div.wp-menu-image {
width: 30px;
}
#adminmenu .wp-not-current-submenu li a {
padding-left: 12px;
}
#adminmenu li li {
margin-left: 0;
}
#adminmenu li li a {
padding-left: 0;
}
.wp-menu-arrow {
-moz-transform: translate( 33px );
-webkit-transform: translate( 33px );
-o-transform: translate( 33px );
-ms-transform: translate( 33px );
transform: translate( 33px );
}
#adminmenu li.menu-top:hover .wp-menu-arrow {
display: none;
}
#adminmenu li.current:hover .wp-menu-arrow,
#adminmenu li.menu-top.wp-menu-open:hover .wp-menu-arrow {
display: block;
z-index: 125;
}
#adminmenu li.menu-top {
border-width: 1px 0;
border-style: solid none;
}
#adminmenu .wp-submenu .wp-submenu-wrap {
margin-top: 3px;
}
#adminmenu .wp-has-current-submenu {
margin-bottom: 1px;
}
#adminmenu .wp-has-current-submenu.menu-top-last {
margin-bottom: 0;
}
#adminmenu .wp-has-current-submenu .wp-submenu-wrap {
margin-top: 4px;
}
#adminmenu .wp-submenu ul {
border-width: 0 0 0 1px;
border-style: solid;
}
#adminmenu .wp-submenu a {
padding-left: 10px;
}
#adminmenu a.wp-has-submenu {
margin-left: 40px;
}
#collapse-menu {
display: none;
}
}
/* List table styles */
.post-com-count-wrapper {
min-width: 22px;
font-family: sans-serif;
}
.post-com-count {
height: 1.3em;
line-height: 1.1em;
display: block;
text-decoration: none;
padding: 0 0 6px;
cursor: pointer;
background-position: center -80px;
background-repeat: no-repeat;
}
.post-com-count span {
font-size: 11px;
font-weight: bold;
height: 1.4em;
line-height: 1.4em;
min-width: 0.7em;
padding: 0 6px;
display: inline-block;
-webkit-border-radius: 5px;
border-radius: 5px;
}
strong .post-com-count {
background-position: center -55px;
}
.post-com-count:hover {
background-position: center -3px;
}
.column-response .post-com-count {
float: left;
margin-right: 5px;
text-align: center;
}
.response-links {
float: left;
}
#the-comment-list .attachment-80x60 {
padding: 4px 8px;
}
/*------------------------------------------------------------------------------
8.0 - Layout Blocks
------------------------------------------------------------------------------*/
html.wp-toolbar {
padding-top: 28px;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.narrow {
width: 70%;
margin-bottom: 40px;
}
.narrow p {
line-height: 150%;
}
.widefat th,
.widefat td {
overflow: hidden;
}
.widefat th {
font-weight: normal;
}
.widefat td p {
margin: 2px 0 0.8em;
}
.widefat .column-comment p {
margin: 0.6em 0;
}
/* Screens with postboxes */
.postbox-container {
float: left;
}
#dashboard-widgets.columns-1 .postbox-container {
width: 100%;
}
#dashboard-widgets.columns-2 .postbox-container {
width: 49.5%;
}
#dashboard-widgets.columns-2 #postbox-container-2,
#dashboard-widgets.columns-2 #postbox-container-3,
#dashboard-widgets.columns-2 #postbox-container-4 {
float: right;
width: 50.5%;
}
#dashboard-widgets.columns-3 .postbox-container {
width: 33.5%;
}
#dashboard-widgets.columns-3 #postbox-container-1 {
width: 33%;
}
#dashboard-widgets.columns-3 #postbox-container-3,
#dashboard-widgets.columns-3 #postbox-container-4 {
float: right;
}
#dashboard-widgets.columns-4 .postbox-container {
width: 25%;
}
.postbox-container .meta-box-sortables {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
}
.metabox-holder .postbox-container .empty-container {
border: 3px dashed #CCCCCC;
height: 250px;
}
.metabox-holder.columns-1 .postbox-container .empty-container,
.columns-2 #postbox-container-3 .empty-container,
.columns-2 #postbox-container-4 .empty-container,
.columns-3 #postbox-container-4 .empty-container {
border: 0 none;
height: 0;
min-height: 0;
}
#poststuff {
padding-top: 10px;
}
#poststuff #post-body {
padding: 0;
}
#post-body-content {
width: 100%;
float: left;
}
#poststuff .postbox-container {
width: 100%;
}
#poststuff #post-body.columns-2 {
margin-right: 300px;
}
#post-body.columns-2 #postbox-container-1 {
float: right;
margin-right: -300px;
width: 280px;
}
#post-body.columns-2 #side-sortables {
min-height: 250px;
}
/* one column on the dash */
@media only screen and (max-width: 799px) {
#wpbody-content #dashboard-widgets .postbox-container {
width: 100%;
}
#wpbody-content .metabox-holder .postbox-container .empty-container {
border: 0 none;
height: 0;
min-height: 0;
}
}
/* two columns on the dash, but keep the setting if one is selected */
@media only screen and (min-width: 800px) and (max-width: 1200px) {
#wpbody-content #dashboard-widgets .postbox-container {
width: 49.5%;
}
#wpbody-content #dashboard-widgets #postbox-container-2,
#wpbody-content #dashboard-widgets #postbox-container-3,
#wpbody-content #dashboard-widgets #postbox-container-4 {
float: right;
width: 50.5%;
}
#dashboard-widgets #postbox-container-3 .empty-container,
#dashboard-widgets #postbox-container-4 .empty-container {
border: 0 none;
height: 0;
min-height: 0;
}
#wpbody #wpbody-content #dashboard-widgets.columns-1 .postbox-container {
width: 100%;
}
#wpbody #wpbody-content .metabox-holder.columns-1 .postbox-container .empty-container {
border: 0 none;
height: 0;
min-height: 0;
}
/* show the radio buttons for column prefs only for one or two columns */
.index-php .screen-layout,
.index-php .columns-prefs {
display: block;
}
.columns-prefs .columns-prefs-3,
.columns-prefs .columns-prefs-4 {
display: none;
}
}
/* one column on the post write/edit screen */
@media only screen and (max-width: 850px) {
#wpbody-content #poststuff #post-body {
margin: 0;
}
#wpbody-content #post-body.columns-2 #postbox-container-1 {
margin-right: 0;
width: 100%;
}
#poststuff #postbox-container-1 .empty-container,
#poststuff #postbox-container-1 #side-sortables:empty {
border: 0 none;
height: 0;
min-height: 0;
}
#poststuff #post-body.columns-2 #side-sortables {
min-height: 0;
}
/* hide the radio buttons for column prefs */
.screen-layout,
.columns-prefs {
display: none;
}
}
.postbox .hndle {
cursor: move;
-webkit-border-top-left-radius: 3px;
-webkit-border-top-right-radius: 3px;
border-top-left-radius: 3px;
border-top-right-radius: 3px;
}
.postbox.closed .hndle {
-webkit-border-radius: 3px;
border-radius: 3px;
}
.hndle a {
font-size: 11px;
font-weight: normal;
}
.postbox .handlediv {
float: right;
width: 27px;
height: 30px;
cursor: pointer;
}
.sortable-placeholder {
border-width: 1px;
border-style: dashed;
margin-bottom: 20px;
}
.widget,
.postbox,
.stuffbox {
margin-bottom: 20px;
padding: 0;
border-width: 1px;
border-style: solid;
line-height: 1;
}
.widget .widget-top,
.postbox h3,
.stuffbox h3 {
margin-top: 1px;
border-bottom-width: 1px;
border-bottom-style: solid;
cursor: move;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
}
.stuffbox h3 {
cursor: auto;
}
.postbox .inside,
.stuffbox .inside {
padding: 0 10px;
line-height: 1.4em;
}
.postbox .inside {
margin: 10px 0;
position: relative;
}
.postbox.closed h3 {
border: none;
-moz-box-shadow: none;
-webkit-box-shadow: none;
box-shadow: none;
}
.postbox table.form-table {
margin-bottom: 0;
}
.temp-border {
border: 1px dotted #ccc;
}
.columns-prefs label {
padding: 0 5px;
}
/*------------------------------------------------------------------------------
9.0 - Dashboard
------------------------------------------------------------------------------*/
#dashboard-widgets-wrap {
margin: 0 -8px;
}
#wpbody-content .metabox-holder {
padding-top: 10px;
}
#dashboard-widgets .meta-box-sortables {
margin: 0 8px;
}
#dashboard_recent_comments div.undo {
border-top-style: solid;
border-top-width: 1px;
margin: 0 -10px;
padding: 3px 8px;
font-size: 11px;
}
#the-comment-list td.comment p.comment-author {
margin-top: 0;
margin-left: 0;
}
#the-comment-list p.comment-author img {
float: left;
margin-right: 8px;
}
#the-comment-list p.comment-author strong a {
border: none;
}
#the-comment-list td {
vertical-align: top;
}
#the-comment-list td.comment {
word-wrap: break-word;
}
/* Welcome Panel */
.welcome-panel {
margin: 20px 8px;
padding: 30px 10px 20px;
border-width: 1px 0;
border-style: solid;
position: relative;
line-height: 1.6em;
overflow: auto;
}
.welcome-panel h3 {
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", sans-serif;
font-size: 32px;
font-weight: normal;
line-height: 1.2;
margin: 0.1em 0 0.8em;
}
.welcome-panel h4 {
font-size: 14px;
}
.welcome-panel .welcome-panel-close {
position: absolute;
top: 0;
right: 10px;
padding: 8px 3px;
font-size: 13px;
text-decoration: none;
}
.welcome-panel .welcome-panel-close:before {
background: url('../images/xit.gif') 0 17% no-repeat;
content: ' ';
height: 100%;
width: 10px;
left: -12px;
position: absolute;
}
.welcome-panel .welcome-panel-close:hover:before {
background-position: 100% 17%;
}
.welcome-panel .wp-badge {
float: left;
margin-bottom: 20px;
}
.welcome-panel-content {
max-width: 1500px;
}
.welcome-panel-content .about-description,
.welcome-panel h3 {
margin-left: 190px;
}
.welcome-panel p.welcome-panel-dismiss {
clear: both;
padding: 1em 0 0 0;
}
.welcome-panel .welcome-panel-column-container {
clear: both;
overflow: hidden;
position: relative;
padding-left: 26px;
}
.welcome-panel .welcome-panel-column {
margin: 0 5% 0 -25px;
padding-left: 25px;
width: 30%;
min-width: 200px;
float: left;
}
.welcome-panel .welcome-panel-column.welcome-panel-last {
margin-right: 0;
}
.welcome-panel h4 .icon16 {
margin-left: -32px;
}
.welcome-panel .welcome-panel-column ul {
margin: 1.6em 1em 1em 1.3em;
}
.welcome-panel .welcome-panel-column li {
list-style-type: disc;
padding-left: 2px;
}
/*------------------------------------------------------------------------------
10.0 - List Posts (/Pages/etc)
------------------------------------------------------------------------------*/
table.fixed {
table-layout: fixed;
}
.fixed .column-rating,
.fixed .column-visible {
width: 8%;
}
.fixed .column-date,
.fixed .column-parent,
.fixed .column-links {
width: 10%;
}
.fixed .column-response,
.fixed .column-author,
.fixed .column-categories,
.fixed .column-tags,
.fixed .column-rel,
.fixed .column-role {
width: 15%;
}
.fixed .column-comments {
width: 4em;
padding: 8px 0;
text-align: left;
}
.fixed .column-comments .vers {
padding-left: 3px;
}
.fixed .column-comments a {
float: left;
}
.fixed .column-slug {
width: 25%;
}
.fixed .column-posts {
width: 10%;
}
.fixed .column-icon {
width: 80px;
}
#comments-form .fixed .column-author {
width: 20%;
}
#commentsdiv.postbox .inside {
margin: 0;
padding: 0;
}
#commentsdiv .inside .row-actions {
line-height:18px;
}
#commentsdiv .inside .column-author {
width: 25%;
}
#commentsdiv .column-comment p {
margin: 0.6em 0;
padding: 0;
}
#commentsdiv #replyrow td {
padding: 0;
}
#commentsdiv p {
padding: 8px 10px;
margin: 0;
}
#commentsdiv #add-new-comment {
border-width: 0 0 1px;
border-style: none none solid;
}
#commentsdiv .comments-box {
border: 0 none;
}
#commentsdiv .comments-box thead th {
background: transparent;
padding: 0 7px 4px;
font-style: italic;
}
#commentsdiv .comments-box tr:last-child td {
border-bottom: 0 none;
}
#commentsdiv img.waiting {
padding-left: 5px;
}
.sorting-indicator {
display: none;
width: 7px;
height: 4px;
margin-top: 8px;
margin-left: 7px;
background-image: url(../images/sort.gif);
background-repeat: no-repeat;
}
.fixed .column-comments .sorting-indicator {
margin-top: 3px;
}
.widefat th.sortable,
.widefat th.sorted {
padding: 0;
}
th.sortable a,
th.sorted a {
display: block;
overflow: hidden;
padding: 7px 7px 8px;
}
.fixed .column-comments.sortable a,
.fixed .column-comments.sorted a {
padding: 8px 0;
}
th.sortable a span,
th.sorted a span {
float: left;
cursor: pointer;
}
th.sorted.asc .sorting-indicator,
th.desc:hover span.sorting-indicator {
display: block;
background-position: 0 0;
}
th.sorted.desc .sorting-indicator,
th.asc:hover span.sorting-indicator {
display: block;
background-position: -7px 0;
}
/* Bulk Actions */
.tablenav-pages a {
border-bottom-style: solid;
border-bottom-width: 2px;
font-weight: bold;
margin-right: 1px;
padding: 0 2px;
}
.tablenav-pages .current-page {
text-align: center;
}
.tablenav-pages .next-page {
margin-left: 2px;
}
.tablenav a.button-secondary {
display: block;
margin: 3px 8px 0 0;
}
.tablenav {
clear: both;
height: 30px;
margin: 6px 0 4px;
vertical-align: middle;
}
.tablenav.themes {
max-width: 98%;
}
.tablenav .tablenav-pages {
float: right;
display: block;
cursor: default;
height: 30px;
line-height: 30px;
font-size: 12px;
}
.tablenav .no-pages,
.tablenav .one-page .pagination-links {
display: none;
}
.tablenav .tablenav-pages a,
.tablenav-pages span.current {
text-decoration: none;
padding: 3px 6px;
}
.tablenav .tablenav-pages a.disabled:hover ,
.tablenav .tablenav-pages a.disabled:active {
cursor: default;
}
.tablenav .displaying-num {
margin-right: 10px;
font-size: 12px;
font-style: italic;
}
.tablenav .actions {
padding: 2px 8px 0 0;
}
.tablenav .delete {
margin-right: 20px;
}
.view-switch {
float: right;
margin: 6px 8px 0;
}
.view-switch a {
text-decoration: none;
}
.filter {
float: left;
margin: -5px 0 0 10px;
}
.filter .subsubsub {
margin-left: -10px;
margin-top: 13px;
}
.screen-per-page {
width: 4em;
}
#posts-filter fieldset {
float: left;
margin: 0 1.5ex 1em 0;
padding: 0;
}
#posts-filter fieldset legend {
padding: 0 0 .2em 1px;
}
span.post-state-format {
font-weight: normal;
}
/*------------------------------------------------------------------------------
10.1 - Inline Editing
------------------------------------------------------------------------------*/
/*
.quick-edit* is for Quick Edit
.bulk-edit* is for Bulk Edit
.inline-edit* is for everything
*/
/* Layout */
#wpbody-content .inline-edit-row fieldset {
font-size: 12px;
float: left;
margin: 0;
padding: 0;
width: 100%;
}
tr.inline-edit-row td,
#wpbody-content .inline-edit-row fieldset .inline-edit-col {
padding: 0 0.5em;
}
#wpbody-content .quick-edit-row-page fieldset.inline-edit-col-right .inline-edit-col {
border-width: 0 0 0 1px;
border-style: none none none solid;
}
#wpbody-content .quick-edit-row-post .inline-edit-col-left {
width: 40%;
}
#wpbody-content .quick-edit-row-post .inline-edit-col-right {
width: 39%;
}
#wpbody-content .inline-edit-row-post .inline-edit-col-center {
width: 20%;
}
#wpbody-content .quick-edit-row-page .inline-edit-col-left {
width: 50%;
}
#wpbody-content .quick-edit-row-page .inline-edit-col-right,
#wpbody-content .bulk-edit-row-post .inline-edit-col-right {
width: 49%;
}
#wpbody-content .bulk-edit-row .inline-edit-col-left {
width: 30%;
}
#wpbody-content .bulk-edit-row-page .inline-edit-col-right {
width: 69%;
}
#wpbody-content .bulk-edit-row .inline-edit-col-bottom {
float: right;
width: 69%;
}
#wpbody-content .inline-edit-row-page .inline-edit-col-right {
margin-top: 27px;
}
.inline-edit-row fieldset .inline-edit-group {
clear: both;
}
.inline-edit-row fieldset .inline-edit-group:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}
.inline-edit-row p.submit {
clear: both;
padding: 0.5em;
margin: 0.5em 0 0;
}
.inline-edit-row span.error {
line-height: 22px;
margin: 0 15px;
padding: 3px 5px;
}
/* Positioning */
.inline-edit-row h4 {
margin: .2em 0;
padding: 0;
line-height: 23px;
}
.inline-edit-row fieldset span.title,
.inline-edit-row fieldset span.checkbox-title {
margin: 0;
padding: 0;
line-height: 27px;
}
.inline-edit-row fieldset label,
.inline-edit-row fieldset span.inline-edit-categories-label {
display: block;
margin: .2em 0;
}
.inline-edit-row fieldset label.inline-edit-tags {
margin-top: 0;
}
.inline-edit-row fieldset label.inline-edit-tags span.title {
margin: .2em 0;
}
.inline-edit-row fieldset label span.title {
display: block;
float: left;
width: 5em;
}
.inline-edit-row fieldset label span.input-text-wrap {
display: block;
margin-left: 5em;
}
.quick-edit-row-post fieldset.inline-edit-col-right label span.title {
width: auto;
padding-right: 0.5em;
}
.inline-edit-row .input-text-wrap input[type=text] {
width: 100%;
}
.inline-edit-row fieldset label input[type=checkbox] {
vertical-align: text-bottom;
}
.inline-edit-row fieldset label textarea {
width: 100%;
height: 4em;
}
#wpbody-content .bulk-edit-row fieldset .inline-edit-group label {
max-width: 50%;
}
#wpbody-content .quick-edit-row fieldset .inline-edit-group label.alignleft:first-child {
margin-right: 0.5em
}
.inline-edit-col-right .input-text-wrap input.inline-edit-menu-order-input {
width: 6em;
}
/* Styling */
.inline-edit-row h4 {
text-transform: uppercase;
}
.inline-edit-row fieldset span.title,
.inline-edit-row fieldset span.checkbox-title {
font-style: italic;
line-height: 1.8em;
}
/* Specific Elements */
.inline-edit-row fieldset input[type="text"],
.inline-edit-row fieldset textarea {
border-style: solid;
border-width: 1px;
}
.inline-edit-row fieldset .inline-edit-date {
float: left;
}
.inline-edit-row fieldset input[name=jj],
.inline-edit-row fieldset input[name=hh],
.inline-edit-row fieldset input[name=mn] {
font-size: 12px;
width: 2.1em;
}
.inline-edit-row fieldset input[name=aa] {
font-size: 12px;
width: 3.5em;
}
.inline-edit-row fieldset label input.inline-edit-password-input {
width: 8em;
}
.inline-edit-row .catshow,
.inline-edit-row .cathide {
cursor: pointer;
}
ul.cat-checklist {
height: 12em;
border-style: solid;
border-width: 1px;
overflow-y: scroll;
padding: 0 5px;
margin: 0;
}
#bulk-titles {
display: block;
height: 12em;
border-style: solid;
border-width: 1px;
overflow-y: scroll;
padding: 0 5px;
margin: 0 0 5px;
}
.inline-edit-row fieldset ul.cat-checklist li,
.inline-edit-row fieldset ul.cat-checklist input {
margin: 0;
}
.inline-edit-row fieldset ul.cat-checklist label,
.inline-edit-row .catshow,
.inline-edit-row .cathide,
.inline-edit-row #bulk-titles div {
font-family: sans-serif;
font-style: normal;
font-size: 11px;
}
table .inline-edit-row fieldset ul.cat-hover {
height: auto;
max-height: 30em;
overflow-y: auto;
position: absolute;
}
.inline-edit-row fieldset label input.inline-edit-menu-order-input {
width: 3em;
}
.inline-edit-row fieldset label input.inline-edit-slug-input {
width: 75%;
}
.quick-edit-row-post fieldset label.inline-edit-status {
float: left;
}
#bulk-titles {
line-height: 140%;
}
#bulk-titles div {
margin: 0.2em 0.3em;
}
#bulk-titles div a {
cursor: pointer;
display: block;
float: left;
height: 10px;
margin: 3px 3px 0 -2px;
overflow: hidden;
position: relative;
text-indent: -9999px;
width: 10px;
}
/*------------------------------------------------------------------------------
11.0 - Write/Edit Post Screen
------------------------------------------------------------------------------*/
#titlediv {
position: relative;
margin-bottom: 20px;
}
#titlediv label { cursor: text; }
#titlediv div.inside {
margin: 0;
}
#poststuff #titlewrap {
border: 0;
padding: 0;
}
#titlediv #title {
padding: 3px 8px;
font-size: 1.7em;
line-height: 100%;
width: 100%;
outline: none;
}
#titlediv #title-prompt-text,
#wp-fullscreen-title-prompt-text {
color: #bbb;
position: absolute;
font-size: 1.7em;
padding: 8px 10px;
}
#wp-fullscreen-title-prompt-text {
left: 0;
padding: 11px;
}
#poststuff .inside-submitbox,
#side-sortables .inside-submitbox {
margin: 0 3px;
font-size: 11px;
}
input#link_description,
input#link_url {
width: 98%;
}
#pending {
background: 0 none;
border: 0 none;
padding: 0;
font-size: 11px;
margin-top: -1px;
}
#edit-slug-box {
height: 1em;
margin-top: 8px;
padding: 0 10px;
}
#editable-post-name-full {
display: none;
}
#editable-post-name input {
width: 16em;
}
.postarea h3 label {
float: left;
}
#submitpost #ajax-loading,
#submitpost .ajax-loading {
vertical-align: middle;
}
#wpcontent .ajax-loading {
visibility: hidden;
}
.submitbox .submit {
text-align: left;
padding: 12px 10px 10px;
font-size: 11px;
}
.submitbox .submitdelete {
text-decoration: none;
padding: 1px 2px;
}
.submitbox .submitdelete,
.submitbox .submit a:hover {
border-bottom-width: 1px;
border-bottom-style: solid;
}
.submitbox .submit input {
margin-bottom: 8px;
margin-right: 4px;
padding: 6px;
}
.inside-submitbox #post_status {
margin: 2px 0 2px -2px;
}
#post-status-select, #post-format {
line-height: 2.5em;
margin-top: 3px;
}
/* Post Screen */
#post-body #normal-sortables {
min-height: 50px;
}
.postbox {
position: relative;
min-width: 255px;
}
#trackback_url {
width: 99%;
}
#normal-sortables .postbox .submit {
background: transparent none;
border: 0 none;
float: right;
padding: 0 12px;
margin:0;
}
.category-add input[type="text"],
.category-add select {
width: 100%;
max-width: 260px;
}
.press-this #side-sortables .category-tabs li,
ul.category-tabs li,
#side-sortables .add-menu-item-tabs li,
.wp-tab-bar li {
display: inline;
line-height: 1.35em;
}
.no-js .category-tabs li.hide-if-no-js {
display: none;
}
.category-tabs a,
#side-sortables .add-menu-item-tabs a,
.wp-tab-bar a {
text-decoration: none;
}
.category-tabs {
margin: 8px 0 3px;
}
#category-adder h4 {
margin: 10px 0;
}
#side-sortables .add-menu-item-tabs,
.wp-tab-bar {
margin-bottom: 3px;
}
#normal-sortables .postbox #replyrow .submit {
float: none;
margin: 0;
padding: 0 7px 5px;
}
#side-sortables .submitbox .submit input,
#side-sortables .submitbox .submit .preview,
#side-sortables .submitbox .submit a.preview:hover {
border: 0 none;
}
#side-sortables .inside-submitbox .insidebox,
.stuffbox .insidebox {
margin: 11px 0;
}
ul.category-tabs,
ul.add-menu-item-tabs,
ul.wp-tab-bar {
margin-top: 12px;
}
ul.category-tabs li,
ul.add-menu-item-tabs li.tabs,
.wp-tab-active {
border-style: solid solid none;
border-width: 1px 1px 0;
}
#post-body .add-menu-item-tabs li.tabs {
border-style: solid none solid solid;
border-width: 1px 0 1px 1px;
margin-right: -1px;
}
ul.category-tabs li,
ul.add-menu-item-tabs li,
ul.wp-tab-bar li {
padding: 3px 5px 5px;
-webkit-border-top-left-radius: 3px;
-webkit-border-top-right-radius: 3px;
border-top-left-radius: 3px;
border-top-right-radius: 3px;
}
/* positioning etc. */
form#tags-filter {
position: relative;
}
/* Edit posts */
td.post-title strong,
td.plugin-title strong {
display: block;
margin-bottom: .2em;
}
td.post-title p,
td.plugin-title p {
margin: 6px 0;
}
/* Global classes */
.wp-hidden-children .wp-hidden-child,
.ui-tabs-hide {
display: none;
}
.commentlist .avatar {
vertical-align: text-top;
}
#post-body .tagsdiv #newtag {
margin-right: 5px;
width: 16em;
}
#side-sortables input#post_password {
width: 94%
}
#side-sortables .tagsdiv #newtag {
width: 68%;
}
#post-status-info {
border-width: 0 1px 1px;
border-style: none solid solid;
width: 100%;
-webkit-border-bottom-left-radius: 3px;
-webkit-border-bottom-right-radius: 3px;
border-bottom-left-radius: 3px;
border-bottom-right-radius: 3px;
}
#post-status-info td {
font-size: 12px;
}
.autosave-info {
padding: 2px 15px;
text-align: right;
}
#editorcontent #post-status-info {
border: none;
}
#post-body .wp_themeSkin .mceStatusbar a.mceResize {
display: block;
background: transparent url(../images/resize.gif) no-repeat scroll right bottom;
width: 12px;
cursor: se-resize;
margin: 0 2px;
position: relative;
top: -2px;
}
#post-body .postarea .wp_themeSkin .mceStatusbar a.mceResize {
top: 20px;
}
#wp-word-count {
display: block;
padding: 2px 10px;
}
#timestampdiv select {
height: 20px;
line-height: 14px;
padding: 0;
vertical-align: top;
}
#aa, #jj, #hh, #mn {
padding: 1px;
font-size: 12px;
}
#jj, #hh, #mn {
width: 2em;
}
#aa {
width: 3.4em;
}
.curtime #timestamp {
background-repeat: no-repeat;
background-position: left top;
padding-left: 18px;
}
#timestampdiv {
padding-top: 5px;
line-height: 23px;
}
#timestampdiv p {
margin: 8px 0 6px;
}
#timestampdiv input {
border-width: 1px;
border-style: solid;
}
/*------------------------------------------------------------------------------
11.1 - Custom Fields
------------------------------------------------------------------------------*/
#postcustomstuff .updatemeta,
#postcustomstuff .deletemeta {
margin: auto;
}
#postcustomstuff thead th {
padding: 5px 8px 8px;
}
#postcustom #postcustomstuff .submit {
border: 0 none;
float: none;
padding: 5px 8px;
}
#side-sortables #postcustom #postcustomstuff .submit {
padding: 0 5px;
}
#side-sortables #postcustom #postcustomstuff td.left input {
margin: 3px 3px 0;
}
#side-sortables #postcustom #postcustomstuff #the-list textarea {
height: 85px;
margin: 3px;
}
#postcustomstuff table {
margin: 0;
width: 100%;
border-width: 1px;
border-style: solid;
border-spacing: 0;
}
#postcustomstuff table input,
#postcustomstuff table select,
#postcustomstuff table textarea {
width: 95%;
margin: 8px 0 8px 8px;
}
#postcustomstuff th.left,
#postcustomstuff td.left {
width: 38%;
}
#postcustomstuff #newmeta .submit {
padding: 0 8px;
}
#postcustomstuff .submit input,
#postcustomstuff table #addmetasub {
width: auto;
}
#postcustomstuff #newmetaleft {
vertical-align: top;
}
#postcustomstuff #newmetaleft a {
padding: 0 10px;
text-decoration: none;
}
/*------------------------------------------------------------------------------
11.2 - Post Revisions
------------------------------------------------------------------------------*/
table.diff {
width: 100%;
}
table.diff col.content {
width: 50%;
}
table.diff tr {
background-color: transparent;
}
table.diff td, table.diff th {
padding: .5em;
font-family: Consolas, Monaco, monospace;
border: none;
}
table.diff .diff-deletedline del, table.diff .diff-addedline ins {
text-decoration: none;
}
/*------------------------------------------------------------------------------
12.0 - Categories
------------------------------------------------------------------------------*/
.category-adder {
margin-left: 120px;
padding: 4px 0;
}
.category-adder h4 {
margin: 0 0 8px;
}
#side-sortables .category-adder {
margin: 0;
}
#post-body ul.add-menu-item-tabs {
float: left;
width: 120px;
text-align: right;
/* Negative margin for the sake of those without JS: all tabs display */
margin: 0 -120px 0 5px;
padding: 0;
}
#post-body ul.add-menu-item-tabs li {
padding: 8px;
}
#post-body ul.add-menu-item-tabs li.tabs {
-webkit-border-top-left-radius: 3px;
-webkit-border-bottom-left-radius: 3px;
border-top-left-radius: 3px;
border-bottom-left-radius: 3px;
}
.wp-tab-panel,
.categorydiv div.tabs-panel,
.customlinkdiv div.tabs-panel,
.posttypediv div.tabs-panel,
.taxonomydiv div.tabs-panel {
height: 200px;
overflow: auto;
padding: 0.5em 0.9em;
border-style: solid;
border-width: 1px;
}
.nav-menus-php .customlinkdiv div.tabs-panel,
.nav-menus-php .posttypediv div.tabs-panel,
.nav-menus-php .taxonomydiv div.tabs-panel {
height: auto;
max-height: 205px;
}
div.tabs-panel-active {
display:block;
}
div.tabs-panel-inactive {
display:none;
}
.colunms-1 .categorydiv div.tabs-panel,
.taxonomy div.tabs-panel {
margin: 0 5px 0 125px;
}
.customlinkdiv ul,
.posttypediv ul,
.taxonomydiv ul {
list-style: none;
padding: 0;
margin: 0;
}
#front-page-warning,
#front-static-pages ul,
ul.export-filters,
.inline-editor ul.cat-checklist ul,
.categorydiv ul.categorychecklist ul,
.customlinkdiv ul.categorychecklist ul,
.posttypediv ul.categorychecklist ul,
.taxonomydiv ul.categorychecklist ul {
margin-left: 18px;
}
ul.categorychecklist li {
margin: 0;
padding: 0;
line-height: 19px;
word-wrap: break-word;
}
.categorydiv .tabs-panel,
.customlinkdiv .tabs-panel,
.posttypediv .tabs-panel,
.taxonomydiv .tabs-panel {
border-width: 3px;
border-style: solid;
}
.form-wrap p,
.form-wrap label {
font-size: 11px;
}
.form-wrap label {
display: block;
padding: 2px;
font-size: 12px;
}
.form-field input,
.form-field textarea {
border-style: solid;
border-width: 1px;
width: 95%;
}
p.description,
.form-wrap p {
margin: 2px 0 5px;
}
p.help,
p.description,
span.description,
.form-wrap p {
font-size: 12px;
font-style: italic;
font-family: sans-serif;
}
.form-wrap .form-field {
margin: 0 0 10px;
padding: 8px;
}
.col-wrap h3 {
margin: 12px 0;
font-size: 1.1em;
}
.col-wrap p.submit {
margin-top: -10px;
}
/*------------------------------------------------------------------------------
13.0 - Tags
------------------------------------------------------------------------------*/
#poststuff .taghint {
color: #aaa;
margin: 15px 0 -24px 12px;
}
#poststuff .tagsdiv .howto {
margin: 0 0 6px 8px;
}
.ajaxtag .newtag {
position: relative;
}
.tagsdiv .newtag {
width: 180px;
}
.tagsdiv .the-tags {
display: block;
height: 60px;
margin: 0 auto;
overflow: auto;
width: 260px;
}
#post-body-content .tagsdiv .the-tags {
margin: 0 5px;
}
p.popular-tags {
-webkit-border-radius: 8px;
border-radius: 8px;
border-width: 1px;
border-style: solid;
line-height: 2em;
max-width: 1000px;
padding: 8px 12px 12px;
text-align: justify;
}
p.popular-tags a {
padding: 0 3px;
}
.tagcloud {
width: 97%;
margin: 0 0 40px;
text-align: justify;
}
.tagcloud h3 {
margin: 2px 0 12px;
}
.ac_results {
padding: 0;
margin: 0;
list-style: none;
position: absolute;
z-index: 10000;
display: none;
border-width: 1px;
border-style: solid;
}
.ac_results li {
padding: 2px 5px;
white-space: nowrap;
text-align: left;
}
.ac_over {
cursor: pointer;
}
.ac_match {
text-decoration: underline;
}
/* links tables */
table.links-table {
width: 100%;
}
.links-table th {
font-weight: normal;
text-align: left;
vertical-align: top;
min-width: 80px;
width: 20%;
word-wrap: break-word;
}
.links-table th,
.links-table td {
padding: 5px 0;
}
.links-table td label {
margin-right: 8px;
}
.links-table td input[type="text"],
.links-table td textarea {
width: 100%;
}
.links-table #link_rel {
max-width: 280px;
}
/*------------------------------------------------------------------------------
14.0 - Media Screen
------------------------------------------------------------------------------*/
.media-item .describe {
border-collapse: collapse;
width: 100%;
border-top-style: solid;
border-top-width: 1px;
clear: both;
cursor: default;
}
.media-item.media-blank .describe {
border: 0;
}
.media-item .describe th {
vertical-align: top;
text-align: left;
padding: 5px 10px 10px;
width: 140px;
}
.media-item .describe .align th {
padding-top: 0;
}
.media-item .media-item-info tr {
background-color: transparent;
}
.media-item .describe td {
padding: 0 8px 8px 0;
vertical-align: top;
}
.media-item thead.media-item-info td {
padding: 4px 10px 0;
}
.media-item .media-item-info .A1B1 {
padding: 0 0 0 10px;
}
.media-item td.savesend {
padding-bottom: 15px;
}
.media-item .thumbnail {
max-height: 128px;
max-width: 128px;
}
#wpbody-content #async-upload-wrap a {
display: none;
}
.media-upload-form {
margin-top: 20px;
}
.media-upload-form td label {
margin-right: 6px;
margin-left: 2px;
}
.media-upload-form .align .field label {
display: inline;
padding: 0 0 0 23px;
margin: 0 1em 0 3px;
font-weight: bold;
}
.media-upload-form tr.image-size label {
margin: 0 0 0 5px;
font-weight: bold;
}
.media-upload-form th.label label {
font-weight: bold;
margin: 0.5em;
font-size: 13px;
}
.media-upload-form th.label label span {
padding: 0 5px;
}
abbr.required {
border: medium none;
text-decoration: none;
}
.media-item .describe input[type="text"],
.media-item .describe textarea {
width: 460px;
}
.media-item .describe p.help {
margin: 0;
padding: 0 0 0 5px;
}
.describe-toggle-on,
.describe-toggle-off {
display: block;
line-height: 36px;
float: right;
margin-right: 15px;
}
.media-item .describe-toggle-off,
.media-item.open .describe-toggle-on,
.media-item.open img.pinkynail {
display: none;
}
.media-item.open .describe-toggle-off {
display: block;
}
#media-items .media-item {
border-style: solid;
border-width: 1px;
min-height: 36px;
position: relative;
margin-top: -1px;
width: 100%;
}
#media-items {
width: 623px;
}
#media-items:empty {
border: 0 none;
}
.media-item .filename {
line-height: 36px;
overflow: hidden;
padding: 0 10px;
}
.media-item .error-div {
padding-left: 10px;
}
.media-item .pinkynail {
float: left;
margin: 2px 2px 0;
max-width: 40px;
max-height: 32px;
}
.media-item .startopen,
.media-item .startclosed {
display: none;
}
.media-item .original {
position: relative;
height: 34px;
}
.media-item .progress {
float: right;
height: 22px;
margin: 6px 10px 0 0;
width: 200px;
line-height: 2em;
padding: 0;
overflow: hidden;
margin-bottom: 2px;
border: 1px solid #d1d1d1;
background: #fff;
background-image: linear-gradient(bottom, rgb(255,255,255) 0%, rgb(247,247,247) 100%);
background-image: -o-linear-gradient(bottom, rgb(255,255,255) 0%, rgb(247,247,247) 100%);
background-image: -moz-linear-gradient(bottom, rgb(255,255,255) 0%, rgb(247,247,247) 100%);
background-image: -webkit-linear-gradient(bottom, rgb(255,255,255) 0%, rgb(247,247,247) 100%);
background-image: -ms-linear-gradient(bottom, rgb(255,255,255) 0%, rgb(247,247,247) 100%);
-webkit-border-radius: 3px;
border-radius: 3px;
-webkit-box-shadow: inset 0 0 3px rgba(0,0,0,0.1);
box-shadow: inset 0 0 3px rgba(0,0,0,0.1);
}
.media-item .bar {
z-index: 9;
width: 0;
height: 100%;
margin-top: -24px;
background-color: #83B4D8;
background-image: linear-gradient(bottom, rgb(114,167,207) 0%, rgb(144,197,238) 100%);
background-image: -o-linear-gradient(bottom, rgb(114,167,207) 0%, rgb(144,197,238) 100%);
background-image: -moz-linear-gradient(bottom, rgb(114,167,207) 0%, rgb(144,197,238) 100%);
background-image: -webkit-linear-gradient(bottom, rgb(114,167,207) 0%, rgb(144,197,238) 100%);
background-image: -ms-linear-gradient(bottom, rgb(114,167,207) 0%, rgb(144,197,238) 100%);
-webkit-border-radius: 3px;
border-radius: 3px;
-webkit-box-shadow: 0 0 3px rgba(0,0,0,0.3);
box-shadow: 0 0 3px rgba(0,0,0,0.3);
}
.media-item .progress .percent {
z-index: 10;
position: relative;
width: 200px;
padding: 0 8px;
text-shadow: 0 1px 0 rgba(255,255,255,0.4);
color: rgba(0,0,0,0.6);
}
.upload-php .fixed .column-parent {
width: 25%;
}
.js .html-uploader #plupload-upload-ui {
display: none;
}
.js .html-uploader #html-upload-ui {
display: block;
}
.media-upload-form .media-item.error {
margin: 0;
padding: 0;
}
.media-upload-form .media-item.error p,
.media-item .error-div {
line-height: 16px;
margin: 5px 10px;
padding: 0;
}
.media-item .error-div a.dismiss {
display: block;
float: right;
margin: 5px 4px 0 15px;
}
/*------------------------------------------------------------------------------
14.1 - Media Library
------------------------------------------------------------------------------*/
.find-box {
width: 500px;
height: 300px;
overflow: hidden;
padding: 33px 5px 40px;
position: absolute;
z-index: 1000;
}
.find-box-head {
cursor: move;
font-weight: bold;
height: 2em;
line-height: 2em;
padding: 1px 12px;
position: absolute;
top: 5px;
width: 100%;
}
.find-box-inside {
overflow: auto;
width: 100%;
height: 100%;
}
.find-box-search {
padding: 12px;
border-width: 1px;
border-style: none none solid;
}
#find-posts-response {
margin: 8px 0;
padding: 0 1px;
}
#find-posts-response table {
width: 100%;
}
#find-posts-response .found-radio {
padding: 5px 0 0 8px;
width: 15px;
}
.find-box-buttons {
width: 480px;
margin: 8px;
}
.find-box-search label {
padding-right: 6px;
}
.find-box #resize-se {
position: absolute;
right: 1px;
bottom: 1px;
}
ul#dismissed-updates {
display: none;
}
form.upgrade {
margin-top: 8px;
}
form.upgrade .hint {
font-style: italic;
font-size: 85%;
margin: -0.5em 0 2em 0;
}
#poststuff .inside .the-tagcloud {
margin: 5px 0 10px;
padding: 8px;
border-width: 1px;
border-style: solid;
line-height: 1.8em;
word-spacing: 3px;
-webkit-border-radius: 6px;
border-radius: 6px;
}
.drag-drop #drag-drop-area {
border: 4px dashed #DDDDDD;
height: 200px;
}
.drag-drop .drag-drop-inside {
margin: 70px auto 0;
width: 250px;
}
.drag-drop-inside p {
color: #aaa;
font-size: 14px;
margin: 5px 0;
display: none;
}
.drag-drop .drag-drop-inside p {
text-align: center;
}
.drag-drop-inside p.drag-drop-info {
font-size: 20px;
}
.drag-drop .drag-drop-inside p,
.drag-drop-inside p.drag-drop-buttons {
display: block;
}
/*
#drag-drop-area:-moz-drag-over {
border-color: #83b4d8;
}
borger color while dragging a file over the uploader drop area */
.drag-drop.drag-over #drag-drop-area {
border-color: #83b4d8;
}
#plupload-upload-ui {
position: relative;
}
/*------------------------------------------------------------------------------
14.2 - Image Editor
------------------------------------------------------------------------------*/
.describe .image-editor {
vertical-align: top;
}
.imgedit-wrap {
position: relative;
}
.imgedit-settings p {
margin: 8px 0;
}
.describe .imgedit-wrap table td {
vertical-align: top;
padding-top: 0;
}
.imgedit-wrap p,
.describe .imgedit-wrap table td {
font-size: 11px;
line-height: 18px;
}
.describe .imgedit-wrap table td.imgedit-settings {
padding: 0 5px;
}
td.imgedit-settings input {
vertical-align: middle;
}
.imgedit-wait {
position: absolute;
top: 0;
background: #FFFFFF url(../images/wpspin_light.gif) no-repeat scroll 22px 10px;
opacity: 0.7;
filter: alpha(opacity=70);
width: 100%;
height: 500px;
display: none;
}
.media-disabled,
.imgedit-settings .disabled {
color: grey;
}
.imgedit-wait-spin {
padding: 0 4px 4px;
vertical-align: bottom;
visibility: hidden;
}
.imgedit-menu {
margin: 0 0 12px;
min-width: 300px;
}
.imgedit-menu div {
float: left;
width: 32px;
height: 32px;
}
.imgedit-crop-wrap {
position: relative;
}
.imgedit-crop {
background: transparent url(../images/imgedit-icons.png) no-repeat scroll -9px -31px;
margin: 0 8px 0 0;
}
.imgedit-crop.disabled:hover {
background-position: -9px -31px;
}
.imgedit-crop:hover {
background-position: -9px -1px;
}
.imgedit-rleft {
background: transparent url(../images/imgedit-icons.png) no-repeat scroll -46px -31px;
margin: 0 3px;
}
.imgedit-rleft.disabled:hover {
background-position: -46px -31px;
}
.imgedit-rleft:hover {
background-position: -46px -1px;
}
.imgedit-rright {
background: transparent url(../images/imgedit-icons.png) no-repeat scroll -77px -31px;
margin: 0 8px 0 3px;
}
.imgedit-rright.disabled:hover {
background-position: -77px -31px;
}
.imgedit-rright:hover {
background-position: -77px -1px;
}
.imgedit-flipv {
background: transparent url(../images/imgedit-icons.png) no-repeat scroll -115px -31px;
margin: 0 3px;
}
.imgedit-flipv.disabled:hover {
background-position: -115px -31px;
}
.imgedit-flipv:hover {
background-position: -115px -1px;
}
.imgedit-fliph {
background: transparent url(../images/imgedit-icons.png) no-repeat scroll -147px -31px;
margin: 0 8px 0 3px;
}
.imgedit-fliph.disabled:hover {
background-position: -147px -31px;
}
.imgedit-fliph:hover {
background-position: -147px -1px;
}
.imgedit-undo {
background: transparent url(../images/imgedit-icons.png) no-repeat scroll -184px -31px;
margin: 0 3px;
}
.imgedit-undo.disabled:hover {
background-position: -184px -31px;
}
.imgedit-undo:hover {
background-position: -184px -1px;
}
.imgedit-redo {
background: transparent url(../images/imgedit-icons.png) no-repeat scroll -215px -31px;
margin: 0 8px 0 3px;
}
.imgedit-redo.disabled:hover {
background-position: -215px -31px;
}
.imgedit-redo:hover {
background-position: -215px -1px;
}
.imgedit-applyto img {
margin: 0 8px 0 0;
}
.imgedit-group-top {
margin: 5px 0;
}
.imgedit-applyto .imgedit-label {
padding: 2px 0 0;
display: block;
}
.imgedit-help {
display: none;
font-style: italic;
margin-bottom: 8px;
}
.imgedit-help ul li {
font-size: 11px;
}
a.imgedit-help-toggle {
text-decoration: none;
}
#wpbody-content .imgedit-response div {
width: 600px;
margin: 8px;
}
.form-table td.imgedit-response {
padding: 0;
}
.imgedit-submit {
margin: 8px 0;
}
.imgedit-submit-btn {
margin-left: 20px;
}
.imgedit-wrap .nowrap {
white-space: nowrap;
}
span.imgedit-scale-warn {
color: red;
font-size: 20px;
font-style: normal;
visibility: hidden;
vertical-align: middle;
}
.imgedit-group {
border-width: 1px;
border-style: solid;
-webkit-border-radius: 8px;
border-radius: 8px;
margin-bottom: 8px;
padding: 2px 10px;
}
/*------------------------------------------------------------------------------
15.0 - Comments Screen
------------------------------------------------------------------------------*/
.form-table {
border-collapse: collapse;
margin-top: 0.5em;
width: 100%;
margin-bottom: -8px;
clear: both;
}
.form-table td {
margin-bottom: 9px;
padding: 8px 10px;
line-height: 20px;
font-size: 12px;
}
.form-table th,
.form-wrap label {
font-weight: normal;
text-shadow: #fff 0 1px 0;
}
.form-table th {
vertical-align: top;
text-align: left;
padding: 10px;
width: 200px;
}
.form-table th.th-full {
width: auto;
}
.form-table div.color-option {
display: block;
clear: both;
margin-top: 12px;
}
.form-table input.tog {
margin-top: 2px;
margin-right: 2px;
float: left;
}
.form-table td p {
margin-top: 4px;
}
.form-table table.color-palette {
vertical-align: bottom;
float: left;
margin: -12px 3px 11px;
}
.form-table .color-palette td {
border-width: 1px 1px 0;
border-style: solid solid none;
height: 10px;
line-height: 20px;
width: 10px;
}
.commentlist li {
padding: 1em 1em .2em;
margin: 0;
border-bottom-width: 1px;
border-bottom-style: solid;
}
.commentlist li li {
border-bottom: 0;
padding: 0;
}
.commentlist p {
padding: 0;
margin: 0 0 .8em;
}
/* reply to comments */
#replyrow input {
border-width: 1px;
border-style: solid;
}
#replyrow td {
padding: 2px;
}
#replysubmit {
margin: 0;
padding: 0 7px 3px;
text-align: center;
}
#replysubmit img.waiting,
.inline-edit-save img.waiting {
padding: 4px 10px 0;
vertical-align: top;
float: right;
}
#replysubmit .button {
margin-right: 5px;
}
#replysubmit .error {
color: red;
line-height: 21px;
text-align: center;
vertical-align: center;
}
#replyrow h5 {
margin: .2em 0 0;
padding: 0 5px;
line-height: 1.4em;
font-size: 1em;
}
#edithead .inside {
float: left;
padding: 3px 0 2px 5px;
margin: 0;
text-align: center;
}
#edithead .inside input {
width: 180px;
}
#edithead label {
padding: 2px 0;
}
#replycontainer {
padding: 5px;
}
#replycontent {
height: 120px;
}
.comment-ays {
margin-bottom: 0;
border-style: solid;
border-width: 1px;
}
.comment-ays th {
border-right-style: solid;
border-right-width: 1px;
}
.trash-undo-inside,
.spam-undo-inside {
margin: 1px 8px 1px 0;
line-height: 16px;
}
.spam-undo-inside .avatar,
.trash-undo-inside .avatar {
height: 20px;
width: 20px;
margin-right: 8px;
vertical-align: middle;
}
.stuffbox .editcomment {
clear: none;
}
#comment-status-radio p {
margin: 3px 0 5px;
}
#comment-status-radio input {
margin: 2px 3px 5px 0;
vertical-align: middle;
}
#comment-status-radio label {
padding: 5px 0;
}
.commentlist .avatar {
vertical-align: text-top;
}
/*------------------------------------------------------------------------------
16.0 - Themes
------------------------------------------------------------------------------*/
.theme-install-php .tablenav {
height: auto;
}
h3.available-themes {
margin: 0 0 1em;
float: left;
}
.available-theme {
display: inline-block;
margin-right: 10px;
overflow: hidden;
padding: 20px 20px 20px 0;
vertical-align: top;
width: 300px;
}
.available-theme .screenshot {
width: 300px;
height: 225px;
display: block;
border-width: 1px;
border-style: solid;
margin-bottom: 10px;
overflow: hidden;
}
.available-theme img {
width: 300px;
}
.available-theme h3 {
margin: 15px 0 0;
}
.available-theme .theme-author {
line-height: 18px;
}
.available-theme .action-links {
margin-top: 10px;
overflow: hidden;
}
#current-theme .theme-info li,
.theme-options li,
.available-theme .action-links li {
float: left;
padding-right: 10px;
margin-right: 10px;
border-right: 1px solid #dfdfdf;
}
.available-theme .action-links li {
padding-right: 8px;
margin-right: 8px;
}
#current-theme .theme-info li:last-child,
.theme-options li:last-child,
.available-theme .action-links li:last-child {
padding-right: 0;
margin-right: 0;
border-right: 0;
}
.available-theme .action-links .delete-theme {
float: right;
margin-left: 8px;
margin-right: 0;
}
.available-theme .action-links .delete-theme a {
color: red;
padding: 2px;
}
.available-theme .action-links .delete-theme a:hover {
background: red;
color: #fff;
text-decoration: none;
}
.available-theme .action-links p {
float: left;
}
#current-theme {
margin: 20px 0 10px;
padding: 0 0 20px;
border-bottom: 1px solid #dfdfdf;
overflow: hidden;
}
#current-theme.has-screenshot {
padding-left: 330px;
}
#current-theme h3 {
margin: 0;
font-size: 12px;
font-weight: normal;
color: #999;
}
#current-theme h4 {
margin: 3px 0 16px;
font-size: 20px;
}
#current-theme h4 span {
margin-left: 20px;
font-size: 12px;
font-weight: normal;
}
#current-theme a {
border-bottom: none;
}
#current-theme .theme-info {
margin: 1em 0;
overflow: hidden;
}
#current-theme .theme-description {
margin-top: 5px;
max-width: 600px;
line-height: 1.6em;
}
#current-theme img {
float: left;
width: 300px;
margin-left: -330px;
border-width: 1px;
border-style: solid;
}
.theme-options {
overflow: hidden;
font-size: 14px;
padding-bottom: 10px;
}
.theme-options .load-customize {
margin-right: 30px;
float: left;
}
.theme-options span {
float: left;
margin-right: 10px;
text-transform: uppercase;
font-size: 11px;
line-height: 18px;
color: #999;
}
.theme-options ul {
float: left;
margin: 0;
}
/* Allow for three-up on 1024px wide screens, e.g. tablets */
@media only screen and (max-width: 1200px) {
.available-theme,
.available-theme .screenshot,
#current-theme img {
width: 240px;
}
.available-theme .screenshot {
height: 180px;
}
.available-theme img {
width: 100%;
}
#current-theme.has-screenshot {
padding-left: 270px;
}
#current-theme img {
margin-left: -270px;
}
}
#post-body ul.add-menu-item-tabs li.tabs a,
#TB_window #TB_title a.tb-theme-preview-link,
#TB_window #TB_title a.tb-theme-preview-link:visited {
font-weight: bold;
text-decoration: none;
}
#TB_window #TB_title {
background-color: #222;
color: #cfcfcf;
}
#broken-themes {
text-align: left;
width: 50%;
border-spacing: 3px;
padding: 3px;
}
.theme-install-php h4 {
margin: 2.5em 0 8px;
}
/*------------------------------------------------------------------------------
16.1 - Custom Header Screen
------------------------------------------------------------------------------*/
.appearance_page_custom-header #headimg {
border: 1px solid #DFDFDF;
width: 100%;
}
.appearance_page_custom-header #upload-form p label {
font-size: 12px;
}
.appearance_page_custom-header .available-headers .default-header {
float: left;
margin: 0 20px 20px 0;
}
.appearance_page_custom-header .random-header {
clear: both;
margin: 0 20px 20px 0;
vertical-align: middle;
}
.appearance_page_custom-header .available-headers label input,
.appearance_page_custom-header .random-header label input {
margin-right: 10px;
}
.appearance_page_custom-header .available-headers label img {
vertical-align: middle;
}
/*------------------------------------------------------------------------------
16.2 - Custom Background Screen
------------------------------------------------------------------------------*/
div#custom-background-image {
min-height: 100px;
border: 1px solid #dfdfdf;
}
div#custom-background-image img {
max-width: 400px;
max-height: 300px;
}
/*------------------------------------------------------------------------------
16.3 - Tabbed Admin Screen Interface (Experimental)
------------------------------------------------------------------------------*/
.nav-tab {
border-style: solid;
border-color: #dfdfdf #dfdfdf #fff;
border-width: 1px 1px 0;
color: #aaa;
text-shadow: #fff 0 1px 0;
font-size: 12px;
line-height: 16px;
display: inline-block;
padding: 4px 14px 6px;
text-decoration: none;
margin: 0 6px -1px 0;
-webkit-border-top-left-radius: 3px;
-webkit-border-top-right-radius: 3px;
border-top-left-radius: 3px;
border-top-right-radius: 3px;
}
.nav-tab-active {
border-width: 1px;
color: #464646;
}
.nav-tab:hover,
.nav-tab-active {
border-color: #ccc #ccc #fff;
}
h2.nav-tab-wrapper, h3.nav-tab-wrapper {
border-bottom: 1px solid #ccc;
padding-bottom: 0;
}
h2 .nav-tab {
padding: 4px 10px 6px;
font-weight: 200;
font-size: 20px;
line-height: 24px;
}
/*------------------------------------------------------------------------------
17.0 - Plugins
------------------------------------------------------------------------------*/
#dashboard_right_now .versions .b,
#post-status-display,
#post-visibility-display,
#adminmenu .wp-submenu li.current,
#adminmenu .wp-submenu li.current a,
#adminmenu .wp-submenu li.current a:hover,
.media-item .percent,
.plugins .name,
#pass-strength-result.strong,
#pass-strength-result.short,
.button-highlighted,
input.button-highlighted,
#quicktags #ed_strong,
#ed_reply_toolbar #ed_reply_strong,
.item-controls .item-order a,
.feature-filter .feature-name {
font-weight: bold;
}
.plugins p {
margin: 0 4px;
padding: 0;
}
.plugins .desc p {
margin: 0 0 8px;
}
.plugins td.desc {
line-height: 1.5em;
}
.plugins .desc ul,
.plugins .desc ol {
margin: 0 0 0 2em;
}
.plugins .desc ul {
list-style-type: disc;
}
.plugins .row-actions-visible {
padding: 0;
}
.plugins tbody th.check-column {
padding: 7px 0;
}
.plugins .inactive td,
.plugins .inactive th,
.plugins .active td,
.plugins .active th {
border-top-style: solid;
border-top-width: 1px;
padding: 5px 7px 0;
}
.plugins .update th,
.plugins .update td {
border-bottom: 0;
}
.plugin-update-tr td {
border-top: 0;
}
#wpbody-content .plugins .plugin-title,
#wpbody-content .plugins .theme-title {
padding-right: 12px;
white-space:nowrap;
}
.plugins .second,
.plugins .row-actions-visible {
padding: 0 0 5px;
}
.plugins .update .second,
.plugins .update .row-actions-visible {
padding-bottom: 0;
}
.plugins-php .widefat tfoot th,
.plugins-php .widefat tfoot td {
border-top-style: solid;
border-top-width: 1px;
}
.plugin-update-tr .update-message {
margin: 5px;
padding: 3px 5px;
}
.plugin-install-php h4 {
margin: 2.5em 0 8px;
}
/*------------------------------------------------------------------------------
18.0 - Users
------------------------------------------------------------------------------*/
#profile-page .form-table textarea {
width: 500px;
margin-bottom: 6px;
}
#profile-page .form-table #rich_editing {
margin-right: 5px
}
#your-profile legend {
font-size: 22px;
}
#your-profile #rich_editing {
border: none;
}
#display_name {
width: 15em;
}
#createuser .form-field input {
width: 25em;
}
/*------------------------------------------------------------------------------
19.0 - Tools
------------------------------------------------------------------------------*/
.pressthis {
margin: 20px 0;
}
.pressthis a {
display: inline-block;
position: relative;
cursor: move;
color: #333;
background: #dfdfdf;
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0.07, #e6e6e6), color-stop(0.77, #d8d8d8));
background-image: -webkit-linear-gradient(bottom, #e6e6e6 7%, #d8d8d8 77%);
background-image: -moz-linear-gradient(bottom, #e6e6e6 7%, #d8d8d8 77%);
background-image: -ms-linear-gradient(bottom, #e6e6e6 7%, #d8d8d8 77%);
background-image: -o-linear-gradient(bottom, #e6e6e6 7%, #d8d8d8 77%);
background-image: linear-gradient(bottom, #e6e6e6 7%, #d8d8d8 77%);
-webkit-border-radius: 5px;
border-radius: 5px;
border: 1px solid #b4b4b4;
font-style: normal;
line-height: 16px;
font-size: 14px;
text-decoration: none;
text-shadow: 0 1px 0px #fff;
}
.pressthis a:hover,
.pressthis a:active {
color: #333
}
.pressthis a:hover:after {
transform: skew(20deg) rotate(9deg);
-webkit-transform: skew(20deg) rotate(9deg);
-moz-transform: skew(20deg) rotate(9deg);
box-shadow: 0 10px 8px rgba(0, 0, 0, 0.7);
-webkit-box-shadow: 0 10px 8px rgba(0, 0, 0, 0.7);
-moz-box-shadow: 0 10px 8px rgba(0, 0, 0, 0.7);
}
.pressthis a span {
background: url(../images/press-this.png?v=20120502) no-repeat 0px 5px;
padding: 8px 11px 8px 27px;
margin: 0 5px;
display: inline-block;
}
.pressthis a:after {
content: '';
width: 70%;
height: 55%;
z-index: -1;
position: absolute;
right: 10px;
bottom: 9px;
background: transparent;
transform: skew(20deg) rotate(6deg);
-webkit-transform: skew(20deg) rotate(6deg);
-moz-transform: skew(20deg) rotate(6deg);
box-shadow: 0 10px 8px rgba(0, 0, 0, 0.6);
-webkit-box-shadow: 0 10px 8px rgba(0, 0, 0, 0.6);
-moz-box-shadow: 0 10px 8px rgba(0, 0, 0, 0.6);
}
/*------------------------------------------------------------------------------
20.0 - Settings
------------------------------------------------------------------------------*/
#utc-time, #local-time {
padding-left: 25px;
font-style: italic;
font-family: sans-serif;
}
.defaultavatarpicker .avatar {
margin: 2px 0;
vertical-align: middle;
}
/*------------------------------------------------------------------------------
21.0 - Admin Footer
------------------------------------------------------------------------------*/
#footer {
position: absolute;
bottom: 0;
left: 0;
right: 0;
padding: 10px 0;
margin-right: 20px;
border-top-width: 1px;
border-top-style: solid;
}
#footer p {
margin: 0;
line-height: 20px;
}
#footer a {
text-decoration: none;
}
#footer a:hover {
text-decoration: underline;
}
/*------------------------------------------------------------------------------
22.0 - About Pages
------------------------------------------------------------------------------*/
.about-wrap {
position: relative;
margin: 25px 40px 0 20px;
max-width: 1050px; /* readability */
font-size: 15px;
}
.about-wrap div.updated,
.about-wrap div.error {
display: none !important;
}
/* Typography */
.about-wrap p {
line-height: 1.6em;
}
.about-wrap h1 {
margin: 0.2em 200px 0 0;
line-height: 1.2em;
font-size: 2.8em;
font-weight: 200;
}
.about-text,
.about-description,
.about-wrap li.wp-person a.web {
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", sans-serif;
font-weight: normal;
line-height: 1.6em;
font-size: 20px;
}
.about-description {
margin-top: 1.4em;
}
.about-text {
margin: 1em 200px 1.4em 0;
min-height: 60px;
font-size: 24px;
}
.about-wrap h3 {
font-size: 24px;
margin-bottom: 1em;
padding-top: 20px;
}
.about-wrap .changelog {
overflow: hidden;
}
.about-wrap .changelog li {
list-style-type: disc;
margin-left: 3em;
}
.about-wrap .feature-section {
padding-bottom: 20px;
}
.about-wrap .feature-section h4 {
margin-bottom: 0.6em;
}
.about-wrap .feature-section p {
margin-top: 0.6em;
}
.about-wrap code {
font-size: 14px;
}
/* Point Releases */
.about-wrap .point-releases {
margin-top: 5px;
}
.about-wrap .changelog.point-releases h3 {
padding-top: 35px;
}
.about-wrap .changelog.point-releases h3:first-child {
padding-top: 7px;
}
/* WordPress Version Badge */
.wp-badge {
padding-top: 142px;
height: 50px;
width: 173px;
font-weight: bold;
font-size: 14px;
text-align: center;
margin: 0 -5px;
background: url('../images/wp-badge.png?ver=20111120') no-repeat;
}
.about-wrap .wp-badge {
position: absolute;
top: 0;
right: 0;
}
/* Tabs */
.about-wrap h2.nav-tab-wrapper {
padding-left: 6px;
}
.about-wrap h2 .nav-tab {
padding: 4px 10px 6px;
margin: 0 3px -1px 0;
font-size: 18px;
vertical-align: top;
}
.about-wrap h2 .nav-tab-active {
font-weight: bold;
padding-top: 3px;
}
/* Changelog / Update screen */
.about-wrap .feature-section img {
border: none;
margin: 0 1.94% 10px 0;
-webkit-border-radius: 3px;
border-radius: 3px;
}
.about-wrap .feature-section img.image-50 {
max-width: 50%;
}
.about-wrap .feature-section img.image-30 {
max-width: 31.2381%;
}
.ie8 .about-wrap .feature-section img {
border-width: 1px;
border-style: solid;
}
.about-wrap .feature-section.three-col {
padding-top: 15px;
margin-bottom: 0;
}
.about-wrap .feature-section.three-col div {
width: 30%;
margin-right: 4.999999999%;
float: left;
}
.about-wrap .feature-section.three-col h4 {
margin: 0 0 0.6em 0;
}
.about-wrap .feature-section.three-col img {
margin: 0.5em 0 0.5em 5px;
max-width: 100%;
float: none;
}
.ie8 .about-wrap .feature-section.three-col img {
margin-left: 0;
}
.about-wrap .feature-section.three-col .last-feature {
margin-right: 0;
}
.about-wrap .three-col-images {
text-align: center;
}
.about-wrap .three-col-images img {
margin: 0 0 10px;
}
.about-wrap .three-col-images .last-feature {
float: right;
}
.about-wrap .three-col-images .first-feature {
float: left;
}
.about-wrap .feature-section.images-stagger-right img {
float: right;
margin: 0 5px 12px 12px;
}
.about-wrap .feature-section.images-stagger-left img {
float: left;
margin: 0 12px 12px 5px;
}
@media only screen and (max-width: 900px) {
.about-wrap .feature-section.images-stagger-left img,
.about-wrap .feature-section.images-stagger-right img {
clear: both;
}
}
/* Return to Dashboard Home link */
.about-wrap .return-to-dashboard {
margin: 30px 0 0 -5px;
font-size: 14px;
font-weight: bold;
}
.about-wrap .return-to-dashboard a {
text-decoration: none;
padding: 0 5px;
}
/* Credits */
.about-wrap h4.wp-people-group {
margin-top: 2.6em;
font-size: 16px;
}
.about-wrap ul.wp-people-group {
overflow: hidden;
padding: 5px;
margin: 0 -15px 0 -5px;
}
.about-wrap ul.compact {
margin-bottom: 0
}
.about-wrap li.wp-person {
float: left;
margin-right: 10px;
}
.about-wrap li.wp-person img.gravatar {
float: left;
margin: 0 10px 10px 0;
padding: 2px;
width: 60px;
height: 60px;
}
.about-wrap ul.compact li.wp-person img.gravatar {
width: 30px;
height: 30px;
}
.about-wrap li.wp-person {
height: 70px;
width: 280px;
padding-bottom: 15px;
}
.about-wrap ul.compact li.wp-person {
height: auto;
width: 180px;
padding-bottom: 0;
margin-bottom: 0;
}
.about-wrap #wp-people-group-validators + p.wp-credits-list {
margin-top: 0;
}
.about-wrap li.wp-person a.web {
display: block;
margin: 6px 0 2px;
font-size: 16px;
text-decoration: none;
}
.about-wrap p.wp-credits-list a {
white-space: nowrap;
}
/* Freedoms */
.freedoms-php .about-wrap ol {
margin: 40px 60px;
}
.freedoms-php .about-wrap ol li {
list-style-type: decimal;
font-weight: bold;
}
.freedoms-php .about-wrap ol p {
font-weight: normal;
margin: 0.6em 0;
}
/*------------------------------------------------------------------------------
23.0 - Full Overlay w/ Sidebar
------------------------------------------------------------------------------*/
body.full-overlay-active {
overflow: hidden;
}
.wp-full-overlay {
background: #fff;
z-index: 500000;
position: fixed;
overflow: visible;
top: 0;
bottom: 0;
left: 0;
right: 0;
height: 100%;
min-width: 0;
}
.wp-full-overlay-sidebar {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
position: fixed;
width: 300px;
height: 100%;
top: 0;
bottom: 0;
left: 0;
padding: 0;
margin: 0;
z-index: 10;
overflow: auto;
background: #f5f5f5;
border-right: 1px solid rgba( 0, 0, 0, 0.2 );
}
.wp-full-overlay.collapsed .wp-full-overlay-sidebar {
overflow: visible;
}
.wp-full-overlay.collapsed,
.wp-full-overlay.expanded .wp-full-overlay-sidebar {
margin-left: 0 !important;
}
.wp-full-overlay.expanded {
margin-left: 300px;
}
.wp-full-overlay.collapsed .wp-full-overlay-sidebar {
margin-left: -300px;
}
.wp-full-overlay-sidebar:after {
content: '';
display: block;
position: absolute;
top: 0;
bottom: 0;
right: 0;
width: 3px;
box-shadow: -5px 0 4px -4px rgba(0, 0, 0, 0.1) inset;
z-index: 1000;
}
.wp-full-overlay-main {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
height: 100%;
}
.wp-full-overlay-sidebar .wp-full-overlay-header,
.wp-full-overlay-sidebar .wp-full-overlay-footer {
position: absolute;
left: 0;
right: 0;
height: 45px;
padding: 0 20px;
line-height: 45px;
z-index: 10;
margin: 0;
}
.wp-full-overlay-sidebar .wp-full-overlay-header {
top: 0;
border-top: 0;
border-bottom: 1px solid #fff;
box-shadow: inset 0 -1px 0 0px #dfdfdf;
}
.wp-full-overlay-sidebar .wp-full-overlay-footer {
bottom: 0;
border-bottom: 0;
border-top: 1px solid #dfdfdf;
box-shadow: inset 0 1px 0 0px #fff;
}
.wp-full-overlay-sidebar .wp-full-overlay-sidebar-content {
position: absolute;
top: 45px;
bottom: 45px;
left: 0;
right: 0;
overflow: auto;
}
/* Close Link */
.wp-full-overlay .close-full-overlay {
text-decoration: none;
}
/* Collapse Button */
.wp-full-overlay .collapse-sidebar {
position: absolute;
bottom: 12px;
left: 0;
z-index: 50;
display: block;
width: 19px;
height: 19px;
margin-left: 15px;
padding: 0;
border-radius: 50%;
text-decoration: none;
}
.wp-full-overlay.collapsed .collapse-sidebar {
position: absolute;
left: 100%;
}
.wp-full-overlay .collapse-sidebar-arrow {
position: absolute;
margin-top: 2px;
margin-left: 2px;
display: block;
width: 15px;
height: 15px;
background: transparent url('../images/arrows.png') no-repeat 0 -72px;
}
.wp-full-overlay.collapsed .collapse-sidebar-arrow {
background-position: 0 -108px;
}
.wp-full-overlay .collapse-sidebar-label {
position: absolute;
left: 100%;
color: #808080;
line-height: 20px;
margin-left: 10px;
}
.wp-full-overlay.collapsed .collapse-sidebar-label {
display: none;
}
.wp-full-overlay .collapse-sidebar:hover .collapse-sidebar-label {
color: #666;
}
/* Animations */
.wp-full-overlay,
.wp-full-overlay-sidebar,
.wp-full-overlay .collapse-sidebar,
.wp-full-overlay-main {
-webkit-transition-property: left, right, top, bottom, width, margin;
-moz-transition-property: left, right, top, bottom, width, margin;
-ms-transition-property: left, right, top, bottom, width, margin;
-o-transition-property: left, right, top, bottom, width, margin;
transition-property: left, right, top, bottom, width, margin;
-webkit-transition-duration: 0.2s;
-moz-transition-duration: 0.2s;
-ms-transition-duration: 0.2s;
-o-transition-duration: 0.2s;
transition-duration: 0.2s;
}
/*------------------------------------------------------------------------------
24.0 - Customize Loader
------------------------------------------------------------------------------*/
.no-customize-support .hide-if-no-customize,
.customize-support .hide-if-customize {
display: none;
}
#customize-container {
display: none;
background: #fff;
z-index: 500000;
position: fixed;
overflow: visible;
top: 0;
bottom: 0;
left: 0;
right: 0;
height: 100%;
}
.customize-active #customize-container {
display: block;
}
.customize-loading #customize-container iframe {
opacity: 0;
}
.customize-loading #customize-container {
background: #fff url("../images/wpspin_light.gif") no-repeat fixed center center;
}
#customize-container iframe,
#theme-installer iframe {
height: 100%;
width: 100%;
z-index: 20;
-webkit-transition: opacity 0.3s;
-moz-transition: opacity 0.3s;
-ms-transition: opacity 0.3s;
-o-transition: opacity 0.3s;
transition: opacity 0.3s;
}
#customize-container .collapse-sidebar {
bottom: 16px;
}
#theme-installer {
display: none;
}
#theme-installer.single-theme {
display: block;
}
.install-theme-info {
display: none;
padding: 10px 20px 20px;
}
.single-theme .install-theme-info {
padding-top: 15px;
}
#theme-installer .install-theme-info {
display: block;
}
.install-theme-info .theme-install {
float: right;
margin-top: 18px;
}
.install-theme-info .theme-name {
font-size: 16px;
line-height: 24px;
margin-bottom: 0;
}
.install-theme-info .theme-screenshot {
margin-top: 15px;
width: 258px;
border: 1px solid #ccc;
}
.install-theme-info .theme-details {
overflow: hidden;
}
.theme-details .theme-version {
margin: 15px 0;
float: left;
}
.theme-details .star-holder {
margin: 14px 0;
float: right;
}
.theme-details .theme-description {
float: left;
color: #777;
line-height: 20px;
}
/*------------------------------------------------------------------------------
25.0 - Misc
------------------------------------------------------------------------------*/
#excerpt,
.attachmentlinks {
margin: 0;
height: 4em;
width: 98%;
}
#template div {
margin-right: 190px;
}
p.pagenav {
margin: 0;
display: inline;
}
.pagenav span {
font-weight: bold;
margin: 0 6px;
}
.row-title {
font-size: 13px !important;
font-weight: bold;
}
.column-author img, .column-username img {
float: left;
margin-right: 10px;
margin-top: 1px;
}
.row-actions {
visibility: hidden;
padding: 2px 0 0;
}
.mobile .row-actions {
visibility: visible;
}
tr:hover .row-actions,
div.comment-item:hover .row-actions {
visibility: visible;
}
.row-actions-visible {
padding: 2px 0 0;
}
.form-table .pre {
padding: 8px;
margin: 0;
}
table.form-table td .updated {
font-size: 13px;
}
.tagchecklist {
margin-left: 14px;
font-size: 12px;
overflow: auto;
}
.tagchecklist strong {
margin-left: -8px;
position: absolute;
}
.tagchecklist span {
margin-right: 25px;
display: block;
float: left;
font-size: 11px;
line-height: 1.8em;
white-space: nowrap;
cursor: default;
}
.tagchecklist span a {
margin: 6px 0pt 0pt -9px;
cursor: pointer;
width: 10px;
height: 10px;
display: block;
float: left;
text-indent: -9999px;
overflow: hidden;
position: absolute;
}
#poststuff h2 {
margin-top: 20px;
font-size: 1.5em;
margin-bottom: 15px;
padding: 0 0 3px;
clear: left;
}
#poststuff h3,
.metabox-holder h3 {
font-size: 15px;
font-weight: normal;
padding: 7px 10px;
margin: 0;
line-height: 1;
}
#poststuff .inside {
margin: 6px 0 8px;
}
#poststuff .inside #parent_id,
.inline-edit-row #post_parent {
max-width: 100%;
}
#post-visibility-select,
#post-formats-select {
line-height: 1.5em;
margin-top: 3px;
}
#poststuff #submitdiv .inside {
margin: 0;
padding: 0;
}
#titlediv,
#poststuff .postarea {
margin-bottom: 20px;
}
#templateside ul li a {
text-decoration: none;
}
.tool-box .title {
margin: 8px 0;
font-size: 18px;
font-weight: normal;
line-height: 24px;
}
#sidemenu {
margin: -30px 15px 0 315px;
list-style: none;
position: relative;
float: right;
padding-left: 10px;
font-size: 12px;
}
#sidemenu a {
padding: 0 7px;
display: block;
float: left;
line-height: 28px;
border-top-width: 1px;
border-top-style: solid;
border-bottom-width: 1px;
border-bottom-style: solid;
}
#sidemenu li {
display: inline;
line-height: 200%;
list-style: none;
text-align: center;
white-space: nowrap;
margin: 0;
padding: 0;
}
#sidemenu a.current {
font-weight: normal;
padding-left: 6px;
padding-right: 6px;
-webkit-border-top-left-radius: 3px;
-webkit-border-top-right-radius: 3px;
border-top-left-radius: 3px;
border-top-right-radius: 3px;
border-width: 1px;
border-style: solid;
}
#sidemenu li a .count-0 {
display: none;
}
.plugin-install #description,
.plugin-install-network #description {
width: 60%;
}
table .vers,
table .column-visible,
table .column-rating {
text-align: left;
}
.error-message {
color: red;
font-weight: bold;
}
/* Scrollbar fix for bulk upgrade iframe */
body.iframe {
height: 98%;
}
/* - Only used once or twice in all of WP - deprecate for global style
------------------------------------------------------------------------------*/
td.media-icon {
text-align: center;
width: 80px;
padding-top: 8px;
padding-bottom: 8px;
}
td.media-icon img {
max-width: 80px;
max-height: 60px;
}
.list-ajax-loading {
float: right;
margin-right: 9px;
margin-top: -1px;
}
.tablenav .list-ajax-loading {
margin-top: 7px;
}
#howto {
font-size: 11px;
margin: 0 5px;
display: block;
}
.importers td {
padding-right: 14px;
}
.importers {
font-size: 16px;
width: auto;
}
#namediv table {
width: 100%;
}
#namediv td.first {
width: 10px;
white-space: nowrap;
}
#namediv input {
width: 98%;
}
#namediv p {
margin: 10px 0;
}
#submitdiv h3 {
margin-bottom: 0 !important;
}
/* - Used - but could/should be deprecated with a CSS reset
------------------------------------------------------------------------------*/
.zerosize {
height: 0;
width: 0;
margin: 0;
border: 0;
padding: 0;
overflow: hidden;
position: absolute;
}
br.clear {
height: 2px;
line-height: 2px;
}
.checkbox {
border: none;
margin: 0;
padding: 0;
}
fieldset {
border: 0;
padding: 0;
margin: 0;
}
.post-categories {
display: inline;
margin: 0;
padding: 0;
}
.post-categories li {
display: inline;
}
/*-----------------------------------------------------------------------------
MERGED
-------------------------------------------------------------------------------*/
/* dashboard */
.edit-box {
display: none;
}
h3:hover .edit-box {
display: inline;
}
.index-php form .input-text-wrap {
background: #fff;
border-style: solid;
border-width: 1px;
padding: 2px 3px;
border-color: #ccc;
}
#dashboard-widgets form .input-text-wrap input {
border: 0 none;
outline: none;
margin: 0;
padding: 0;
width: 99%;
color: #333;
}
form .textarea-wrap {
background: #fff;
border-style: solid;
border-width: 1px;
padding: 2px;
border-color: #ccc;
}
#dashboard-widgets form .textarea-wrap textarea {
border: 0 none;
padding: 0;
outline: none;
width: 99%;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
#dashboard-widgets .postbox form .submit {
float: none;
margin: .5em 0 0;
padding: 0;
border: none;
}
#dashboard-widgets-wrap #dashboard-widgets .postbox form .submit input {
margin: 0;
}
#dashboard-widgets-wrap #dashboard-widgets .postbox form .submit #publish {
min-width: 0;
}
#dashboard-widgets a {
text-decoration: none;
}
#dashboard-widgets h3 a {
text-decoration: underline;
}
#dashboard-widgets h3 .postbox-title-action {
position: absolute;
right: 30px;
padding: 0;
top: 5px;
}
#dashboard-widgets h4 {
font-weight: normal;
font-size: 13px;
margin: 0 0 .2em;
padding: 0;
}
/* Right Now */
#dashboard_right_now p.sub,
#dashboard_right_now .table, #dashboard_right_now .versions {
margin: -12px;
}
#dashboard_right_now .inside {
font-size: 12px;
padding-top: 20px;
}
#dashboard_right_now p.sub {
padding: 5px 0 15px;
color: #8f8f8f;
font-size: 14px;
position: absolute;
top: -17px;
left: 15px;
}
#dashboard_right_now .table {
margin: 0;
padding: 0;
position: relative;
}
#dashboard_right_now .table_content {
float: left;
border-top: #ececec 1px solid;
width: 45%;
}
#dashboard_right_now .table_discussion {
float: right;
border-top: #ececec 1px solid;
width: 45%;
}
#dashboard_right_now table td {
padding: 3px 0;
white-space: nowrap;
}
#dashboard_right_now table tr.first td {
border-top: none;
}
#dashboard_right_now td.b {
padding-right: 6px;
text-align: right;
font-size: 14px;
width: 1%;
}
#dashboard_right_now td.b a {
font-size: 18px;
}
#dashboard_right_now td.b a:hover {
color: #d54e21;
}
#dashboard_right_now .t {
font-size: 12px;
padding-right: 12px;
padding-top: 6px;
color: #777;
}
#dashboard_right_now .t a {
white-space: nowrap;
}
#dashboard_right_now .spam {
color: red;
}
#dashboard_right_now .waiting {
color: #e66f00;
}
#dashboard_right_now .approved {
color: green;
}
#dashboard_right_now .versions {
padding: 6px 10px 12px;
clear: both;
}
#dashboard_right_now a.button {
float: right;
clear: right;
position: relative;
top: -5px;
}
/* Recent Comments */
#dashboard_recent_comments h3 {
margin-bottom: 0;
}
#dashboard_recent_comments .inside {
margin-top: 0;
}
#dashboard_recent_comments .comment-meta .approve {
font-style: italic;
font-family: sans-serif;
font-size: 10px;
}
#dashboard_recent_comments .subsubsub {
float: none;
white-space: normal;
}
#the-comment-list {
position: relative;
}
#the-comment-list .comment-item {
padding: 1em 10px;
border-top: 1px solid;
}
#the-comment-list .pingback {
padding-left: 9px !important;
}
#the-comment-list .comment-item,
#the-comment-list #replyrow {
margin: 0 -10px;
}
#the-comment-list .comment-item:first-child {
border-top: none;
}
#the-comment-list .comment-item .avatar {
float: left;
margin: 0 10px 5px 0;
}
#the-comment-list .comment-item h4 {
line-height: 1.7em;
margin-top: -0.4em;
color: #777;
}
#the-comment-list .comment-item h4 cite {
font-style: normal;
font-weight: normal;
}
#the-comment-list .comment-item blockquote,
#the-comment-list .comment-item blockquote p {
margin: 0;
padding: 0;
display: inline;
}
#dashboard_recent_comments #the-comment-list .trackback blockquote,
#dashboard_recent_comments #the-comment-list .pingback blockquote {
display: block;
}
#the-comment-list .comment-item p.row-actions {
margin: 3px 0 0;
padding: 0;
font-size: 12px;
}
/* QuickPress */
#dashboard_quick_press h4 {
font-family: sans-serif;
float: left;
width: 5em;
clear: both;
font-weight: normal;
text-align: right;
font-size: 12px;
}
#dashboard_quick_press h4 label {
margin-right: 10px;
}
#dashboard_quick_press .input-text-wrap,
#dashboard_quick_press .textarea-wrap {
margin: 0 0 1em 5em;
}
#dashboard_quick_press .wp-media-buttons {
margin: 0 0 .5em 5em;
padding: 0;
}
#dashboard_quick_press .wp-media-buttons a {
color: #777;
}
#dashboard-widgets #dashboard_quick_press form p.submit {
margin-left: 4.6em;
}
#dashboard-widgets #dashboard_quick_press form p.submit input {
float: left;
}
#dashboard-widgets #dashboard_quick_press form p.submit #save-post {
margin: 0 1em 0 10px;
}
#dashboard-widgets #dashboard_quick_press form p.submit #publish {
float: right;
}
#dashboard-widgets #dashboard_quick_press form p.submit img.waiting {
vertical-align: middle;
visibility: hidden;
margin: 4px 6px 0 0;
}
/* Recent Drafts */
#dashboard_recent_drafts ul,
#dashboard_recent_drafts p {
margin: 0;
padding: 0;
word-wrap: break-word;
}
#dashboard_recent_drafts ul {
list-style: none;
}
#dashboard_recent_drafts ul li {
margin-bottom: 1em;
}
#dashboard_recent_drafts h4 {
line-height: 1.7em;
word-wrap: break-word;
}
#dashboard_recent_drafts h4 abbr {
font-weight: normal;
font-family: sans-serif;
font-size: 12px;
color: #999;
margin-left: 3px;
}
/* Feeds */
.rss-widget ul {
margin: 0;
padding: 0;
list-style: none;
}
a.rsswidget {
font-size: 13px;
line-height: 1.7em;
}
.rss-widget ul li {
line-height: 1.5em;
margin-bottom: 12px;
}
.rss-widget span.rss-date {
color: #999;
font-size: 12px;
margin-left: 3px;
}
.rss-widget cite {
display: block;
text-align: right;
margin: 0 0 1em;
padding: 0;
}
.rss-widget cite:before {
content: '\2014';
}
/* Plugins */
#dashboard_plugins h4 {
line-height: 1.7em;
}
#dashboard_plugins h5 {
font-weight: normal;
font-size: 13px;
margin: 0;
display: inline;
line-height: 1.4em;
}
#dashboard_plugins h5 a {
line-height: 1.4em;
}
#dashboard_plugins .inside span {
font-size: 12px;
padding-left: 5px;
}
#dashboard_plugins p {
margin: 0.3em 0 1.4em;
line-height: 1.4em;
}
.dashboard-comment-wrap {
overflow: hidden;
word-wrap: break-word;
}
/* Browser Nag */
#dashboard_browser_nag a.update-browser-link {
font-size: 1.2em;
font-weight: bold;
}
#dashboard_browser_nag a {
text-decoration: underline;
}
#dashboard_browser_nag p.browser-update-nag.has-browser-icon {
padding-right: 125px;
}
#dashboard_browser_nag .browser-icon {
margin-top: -35px;
}
#dashboard_browser_nag.postbox.browser-insecure {
background-color: #ac1b1b;
border-color: #ac1b1b;
}
#dashboard_browser_nag.postbox {
background-color: #e29808;
background-image: none;
border-color: #edc048;
-moz-box-shadow: none;
-webkit-box-shadow: none;
box-shadow: none;
color: #fff;
}
#dashboard_browser_nag.postbox.browser-insecure h3 {
border-bottom-color: #cd5a5a;
color: #fff;
}
#dashboard_browser_nag.postbox h3 {
border-bottom-color: #f6e2ac;
text-shadow: none;
-moz-box-shadow: none;
-webkit-box-shadow: none;
box-shadow: none;
background: transparent none;
color: #fff;
}
#dashboard_browser_nag a {
color: #fff;
}
#dashboard_browser_nag.browser-insecure a.browse-happy-link,
#dashboard_browser_nag.browser-insecure a.update-browser-link {
text-shadow: #871b15 0 1px 0;
}
#dashboard_browser_nag a.browse-happy-link,
#dashboard_browser_nag a.update-browser-link {
text-shadow: #d29a04 0 1px 0;
}
/* login */
.login * {
margin: 0;
padding: 0;
}
.login form {
margin-left: 8px;
padding: 26px 24px 46px;
font-weight: normal;
background: #fff;
border: 1px solid #e5e5e5;
-moz-box-shadow: rgba(200, 200, 200, 0.7) 0px 4px 10px -1px;
-webkit-box-shadow: rgba(200, 200, 200, 0.7) 0px 4px 10px -1px;
box-shadow: rgba(200, 200, 200, 0.7) 0px 4px 10px -1px;
}
.login form .forgetmenot {
font-weight: normal;
float: left;
margin-bottom: 0;
}
.login .button-primary {
font-size: 13px !important;
line-height: 16px;
padding: 3px 10px;
float: right;
}
#login form p {
margin-bottom: 0;
}
#login form p.submit {
padding: 0;
}
.login label {
color: #777;
font-size: 14px;
}
.login form .forgetmenot label {
font-size: 12px;
line-height: 19px;
}
.login form p {
margin-bottom: 24px;
}
.login h1 a {
background-image: url('../images/wordpress-logo.png?ver=20120216');
background-size: 274px 63px;
background-position: top center;
background-repeat: no-repeat;
width: 326px;
height: 67px;
text-indent: -9999px;
overflow: hidden;
padding-bottom: 15px;
display: block;
}
@media only screen and (-webkit-min-device-pixel-ratio: 1.5) {
.login h1 a {
background-image: url('../images/wordpress-logo-2x.png?ver=20120412');
background-size: 274px 63px;
}
.wp-badge {
background-image: url('../images/wp-badge-2x.png?ver=20120516');
background-size: 173px 194px;
}
}
#login {
width: 320px;
padding: 114px 0 0;
margin: auto;
}
#login_error,
.login .message {
margin: 0 0 16px 8px;
padding: 12px;
}
.login #nav,
.login #backtoblog {
text-shadow: #fff 0 1px 0;
margin: 0 0 0 16px;
padding: 16px 16px 0;
}
#backtoblog {
padding: 12px 16px 0;
}
.login form .input,
.login input[type="text"] {
color: #555;
font-weight: 200;
font-size: 24px;
line-height: 1;
width: 100%;
padding: 3px;
margin-top: 2px;
margin-right: 6px;
margin-bottom: 16px;
border: 1px solid #e5e5e5;
background: #fbfbfb;
outline: none;
-moz-box-shadow: inset 1px 1px 2px rgba(200, 200, 200, 0.2);
-webkit-box-shadow: inset 1px 1px 2px rgba(200, 200, 200, 0.2);
box-shadow: inset 1px 1px 2px rgba(200, 200, 200, 0.2);
}
.login #pass-strength-result {
width: 250px;
font-weight: bold;
border-style: solid;
border-width: 1px;
margin: 12px 0 6px;
padding: 6px 5px;
text-align: center;
}
.mobile #login {
padding: 20px 0;
}
.mobile #login form,
.mobile #login .message,
.mobile #login_error {
margin-left: 0;
}
.mobile #login #nav,
.mobile #login #backtoblog {
margin-left: 8px;
}
.mobile #login h1 a {
width: auto;
}
/* ms */
/* Dashboard: MS Specific Data */
#dashboard_right_now p.musub {
margin-top: 12px;
border-top: 1px solid #ececec;
padding-left: 16px;
position: static;
}
.rtl #dashboard_right_now p.musub {
padding-left: 0;
padding-right: 16px;
}
#dashboard_right_now td.b a.musublink {
font-size: 16px;
}
#dashboard_right_now div.musubtable {
border-top: none;
}
#dashboard_right_now div.musubtable .t {
white-space: normal;
}
/* Background Color for Site Status */
.wp-list-table .site-deleted {
background: #ff8573;
}
.wp-list-table .site-spammed {
background: #faafaa;
}
.wp-list-table .site-archived {
background: #ffebe8;
}
.wp-list-table .site-mature {
background: #fecac2;
}
/* nav-menu */
#nav-menus-frame {
margin-left: 300px;
}
#wpbody-content #menu-settings-column {
display:inline;
width:281px;
margin-left: -300px;
clear: both;
float: left;
padding-top: 24px;
}
.no-js #wpbody-content #menu-settings-column {
padding-top: 31px;
}
#menu-settings-column .inside {
clear: both;
}
.metabox-holder-disabled .postbox {
opacity: 0.5;
filter: alpha(opacity=50);
}
.metabox-holder-disabled .button-controls .select-all {
display: none;
}
#wpbody {
position: relative;
}
/* Menu Container */
#menu-management-liquid {
float: left;
min-width: 100%;
}
#menu-management {
position: relative;
margin-right: 20px;
margin-top: -3px;
width: 100%;
}
#menu-management .menu-edit {
margin-bottom: 20px;
}
.nav-menus-php #post-body {
padding: 10px;
border-width: 1px 0;
border-style: solid;
}
#nav-menu-header,
#nav-menu-footer {
padding: 0 10px;
}
#nav-menu-header {
border-bottom: 1px solid;
}
#nav-menu-footer {
border-top: 1px solid;
}
.nav-menus-php #post-body div.updated,
.nav-menus-php #post-body div.error {
margin: 0;
}
.nav-menus-php #post-body-content {
position: relative;
float: none;
}
#menu-management .menu-add-new abbr {
font-weight:bold;
}
/* Menu Tabs */
#menu-management .nav-tabs-nav {
margin: 0 20px;
}
#menu-management .nav-tabs-arrow {
width: 10px;
padding: 0 5px 4px;
cursor: pointer;
position: absolute;
top: 0;
line-height: 22px;
font-size: 18px;
text-shadow: 0 1px 0 #fff;
}
#menu-management .nav-tabs-arrow-left {
left: 0;
}
#menu-management .nav-tabs-arrow-right {
right: 0;
text-align: right;
}
#menu-management .nav-tabs-wrapper {
width: 100%;
height: 28px;
margin-bottom: -1px;
overflow: hidden;
}
#menu-management .nav-tabs {
padding-left: 20px;
padding-right: 10px;
}
.js #menu-management .nav-tabs {
float: left;
margin-left: 0px;
margin-right: -400px;
}
#menu-management .nav-tab {
margin-bottom: 0;
font-size: 14px;
}
#select-nav-menu-container {
text-align: right;
padding: 0 10px 3px 10px;
margin-bottom: 5px;
}
#select-nav-menu {
width: 100px;
display: inline;
}
#menu-name-label {
margin-top: -2px;
}
#wpbody .open-label {
display: block;
float:left;
}
#wpbody .open-label span {
padding-right: 10px;
}
.js .input-with-default-title {
font-style: italic;
}
#menu-management .inside {
padding: 0 10px;
}
/* Add Menu Item Boxes */
.postbox .howto input {
width: 180px;
float: right;
}
.customlinkdiv .howto input {
width: 200px;
}
#nav-menu-theme-locations .howto select {
width: 100%;
}
#nav-menu-theme-locations .button-controls {
text-align: right;
}
.add-menu-item-view-all {
height: 400px;
}
/* Button Primary Actions */
#menu-container .submit {
margin: 0px 0px 10px;
padding: 0px;
}
.nav-menus-php .meta-sep,
.nav-menus-php .submitdelete,
.nav-menus-php .submitcancel {
display: block;
float: left;
margin: 4px 0;
line-height: 15px;
}
.meta-sep {
padding: 0 2px;
}
#cancel-save {
text-decoration: underline;
font-size: 12px;
margin-left: 20px;
margin-top: 5px;
}
/* Button Secondary Actions */
.list-controls {
float: left;
margin-top: 5px;
}
.add-to-menu {
float: right;
}
.postbox img.waiting {
display: none;
vertical-align: middle;
}
.button-controls {
clear:both;
margin: 10px 0;
}
.show-all,
.hide-all {
cursor: pointer;
}
.hide-all {
display: none;
}
/* Create Menu */
#menu-name {
width: 270px;
}
#manage-menu .inside {
padding: 0px 0px;
}
/* Custom Links */
#available-links dt {
display: block;
}
#add-custom-link .howto {
font-size: 12px;
}
#add-custom-link label span {
display: block;
float: left;
margin-top: 5px;
padding-right: 5px;
}
.menu-item-textbox {
width: 180px;
}
.nav-menus-php .howto span {
margin-top: 4px;
display: block;
float: left;
}
/* Menu item types */
.quick-search {
width: 190px;
}
.nav-menus-php .list-wrap {
display: none;
clear: both;
margin-bottom: 10px;
}
.nav-menus-php .list-container {
max-height: 200px;
overflow-y: auto;
padding: 10px 10px 5px;
}
.nav-menus-php .postbox p.submit {
margin-bottom: 0;
}
/* Listings */
.nav-menus-php .list li {
display: none;
margin: 0;
margin-bottom: 5px;
}
.nav-menus-php .list li .menu-item-title {
cursor: pointer;
display: block;
}
.nav-menus-php .list li .menu-item-title input {
margin-right: 3px;
margin-top: -3px;
}
/* Nav Menu */
#menu-container .inside {
padding-bottom: 10px;
}
.menu {
padding-top:1em;
}
#menu-to-edit {
padding: 1em 0;
}
.menu ul {
width: 100%;
}
.menu li {
margin-bottom: 0;
position:relative;
}
.menu-item-bar {
clear:both;
line-height:1.5em;
position:relative;
margin: 13px 0 0 0;
}
.menu-item-handle {
border: 1px solid #dfdfdf;
position: relative;
padding-left: 10px;
height: auto;
width: 400px;
line-height: 35px;
text-shadow: 0 1px 0 #FFFFFF;
overflow: hidden;
word-wrap: break-word;
}
#menu-to-edit .menu-item-invalid .menu-item-handle {
background-color: #f6c9cc; /* Fallback */
background-image: -ms-linear-gradient(bottom, #f6c9cc, #fdf8ff); /* IE10 */
background-image: -moz-linear-gradient(bottom, #f6c9cc, #fdf8ff); /* Firefox */
background-image: -o-linear-gradient(bottom, #f6c9cc, #fdf8ff); /* Opera */
background-image: -webkit-gradient(linear, left bottom, left top, from(#f6c9cc), to(#fdf8ff)); /* old Webkit */
background-image: -webkit-linear-gradient(bottom, #f6c9cc, #fdf8ff); /* new Webkit */
background-image: linear-gradient(bottom, #f6c9cc, #fdf8ff); /* proposed W3C Markup */
}
.menu-item-edit-active .menu-item-handle {
-webkit-border-bottom-right-radius: 0;
-webkit-border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
}
.no-js .menu-item-edit-active .item-edit {
display: none;
}
.js .menu-item-handle {
cursor: move;
}
.menu li.deleting .menu-item-handle {
background-image: none;
text-shadow: 0 0 0;
}
.menu-item-handle .item-title {
font-size: 12px;
font-weight: bold;
padding: 7px 0;
line-height: 20px;
display:block;
margin-right:13em;
}
/* Sortables */
li.menu-item.ui-sortable-helper dl {
margin-top: 0;
}
li.menu-item.ui-sortable-helper .menu-item-transport dl {
margin-top: 13px;
}
.menu .sortable-placeholder {
height: 35px;
width: 410px;
margin-top: 13px;
}
/* WARNING: The factor of 30px is hardcoded into the nav-menus javascript. */
.menu-item-depth-0 { margin-left: 0px; }
.menu-item-depth-1 { margin-left: 30px; }
.menu-item-depth-2 { margin-left: 60px; }
.menu-item-depth-3 { margin-left: 90px; }
.menu-item-depth-4 { margin-left: 120px; }
.menu-item-depth-5 { margin-left: 150px; }
.menu-item-depth-6 { margin-left: 180px; }
.menu-item-depth-7 { margin-left: 210px; }
.menu-item-depth-8 { margin-left: 240px; }
.menu-item-depth-9 { margin-left: 270px; }
.menu-item-depth-10 { margin-left: 300px; }
.menu-item-depth-11 { margin-left: 330px; }
.menu-item-depth-0 .menu-item-transport { margin-left: 0px; }
.menu-item-depth-1 .menu-item-transport { margin-left: -30px; }
.menu-item-depth-2 .menu-item-transport { margin-left: -60px; }
.menu-item-depth-3 .menu-item-transport { margin-left: -90px; }
.menu-item-depth-4 .menu-item-transport { margin-left: -120px; }
.menu-item-depth-5 .menu-item-transport { margin-left: -150px; }
.menu-item-depth-6 .menu-item-transport { margin-left: -180px; }
.menu-item-depth-7 .menu-item-transport { margin-left: -210px; }
.menu-item-depth-8 .menu-item-transport { margin-left: -240px; }
.menu-item-depth-9 .menu-item-transport { margin-left: -270px; }
.menu-item-depth-10 .menu-item-transport { margin-left: -300px; }
.menu-item-depth-11 .menu-item-transport { margin-left: -330px; }
body.menu-max-depth-0 { min-width: 950px !important; }
body.menu-max-depth-1 { min-width: 980px !important; }
body.menu-max-depth-2 { min-width: 1010px !important; }
body.menu-max-depth-3 { min-width: 1040px !important; }
body.menu-max-depth-4 { min-width: 1070px !important; }
body.menu-max-depth-5 { min-width: 1100px !important; }
body.menu-max-depth-6 { min-width: 1130px !important; }
body.menu-max-depth-7 { min-width: 1160px !important; }
body.menu-max-depth-8 { min-width: 1190px !important; }
body.menu-max-depth-9 { min-width: 1220px !important; }
body.menu-max-depth-10 { min-width: 1250px !important; }
body.menu-max-depth-11 { min-width: 1280px !important; }
/* Menu item controls */
.item-type {
font-size: 12px;
padding-right: 10px;
}
.item-controls {
font-size: 12px;
position: absolute;
right: 20px;
top: -1px;
}
.item-controls a {
text-decoration: none;
}
.item-controls a:hover {
cursor: pointer;
}
.item-controls .item-order {
padding-right: 10px;
}
.nav-menus-php .item-edit {
position: absolute;
right: -20px;
top: 0;
display: block;
width: 30px;
height: 36px;
overflow: hidden;
text-indent:-999em;
border-bottom: 1px solid;
-webkit-border-bottom-left-radius: 3px;
border-bottom-left-radius: 3px;
}
/* Menu editing */
.menu-instructions-inactive {
display: none;
}
.menu-item-settings {
display: block;
width: 400px;
padding: 10px 0 10px 10px;
border: solid;
border-width: 0 1px 1px 1px;
-webkit-border-bottom-right-radius: 3px;
-webkit-border-bottom-left-radius: 3px;
border-bottom-left-radius: 3px;
border-bottom-right-radius: 3px;
}
.menu-item-edit-active .menu-item-settings {
display: block;
}
.menu-item-edit-inactive .menu-item-settings {
display: none;
}
.add-menu-item-pagelinks {
margin: .5em auto;
text-align: center;
}
.link-to-original {
display: block;
margin: 0 0 10px;
padding: 3px 5px 5px;
font-size: 12px;
font-style: italic;
}
.link-to-original a {
padding-left: 4px;
font-style: normal;
}
.hidden-field {
display: none;
}
.menu-item-settings .description-thin,
.menu-item-settings .description-wide {
margin-right: 10px;
float: left;
}
.description-thin {
width: 190px;
height: 40px;
}
.description-wide {
width: 390px;
}
.menu-item-actions {
padding-top: 15px;
}
#cancel-save {
cursor: pointer;
}
/* Major/minor publishing actions (classes) */
.nav-menus-php .major-publishing-actions {
clear: both;
padding: 3px 0 5px;
}
.nav-menus-php .major-publishing-actions .publishing-action {
text-align: right;
float: right;
line-height: 23px;
margin: 5px 0 1px;
}
.nav-menus-php .major-publishing-actions .delete-action {
vertical-align: middle;
text-align: left;
float: left;
padding-right: 15px;
margin-top: 5px;
}
.menu-name-label span,
.auto-add-pages label {
font-size: 12px;
font-style: normal;
}
.menu-name-label {
margin-right: 15px;
}
.auto-add-pages input {
margin-top: 0;
}
.auto-add-pages {
margin-top: 4px;
float: left;
}
.nav-menus-php .submitbox .submitcancel {
border-bottom: 1px solid;
padding: 1px 2px;
text-decoration: none;
}
.nav-menus-php .major-publishing-actions .form-invalid {
padding-left: 4px;
margin-left: -4px;
border: 0 none;
}
/* Clearfix */
#menu-item-name-wrap:after,
#menu-item-url-wrap:after,
#menu-name-label:after,
#menu-settings-column .inside:after,
#nav-menus-frame:after,
.nav-menus-php #post-body-content:after,
.nav-menus-php .button-controls:after,
.nav-menus-php .major-publishing-actions:after,
.nav-menus-php .menu-item-settings:after {
clear: both;
content: ".";
display: block;
height: 0;
visibility: hidden;
}
#nav-menus-frame,
.button-controls,
#menu-item-url-wrap,
#menu-item-name-wrap {
display: block;
}
/* Star ratings */
div.star-holder {
position: relative;
height: 17px;
width: 100px;
background: url('../images/stars.png?ver=20120307') repeat-x bottom left;
}
div.star-holder .star-rating {
background: url('../images/stars.png?ver=20120307') repeat-x top left;
height: 17px;
float: left;
}
div.action-links {
font-weight: normal;
margin: 6px 0 0;
}
/* Header on thickbox */
#plugin-information-header {
margin: 0;
padding: 0 5px;
font-weight: bold;
position: relative;
border-bottom-width: 1px;
border-bottom-style: solid;
height: 2.5em;
}
#plugin-information ul#sidemenu {
font-weight: normal;
margin: 0 5px;
position: absolute;
left: 0;
bottom: -1px;
}
/* Install sidemenu */
#plugin-information p.action-button {
width: 100%;
padding-bottom: 0;
margin-bottom: 0;
margin-top: 10px;
-webkit-border-top-left-radius: 3px;
-webkit-border-bottom-left-radius: 3px;
border-top-left-radius: 3px;
border-bottom-left-radius: 3px;
}
#plugin-information .action-button a {
text-align: center;
font-weight: bold;
text-decoration: none;
display: block;
line-height: 2em;
}
#plugin-information h2 {
clear: none !important;
margin-right: 200px;
}
#plugin-information .fyi {
margin: 0 10px 50px;
width: 210px;
}
#plugin-information .fyi h2 {
font-size: 0.9em;
margin-bottom: 0;
margin-right: 0;
}
#plugin-information .fyi h2.mainheader {
padding: 5px;
-webkit-border-top-left-radius: 3px;
border-top-left-radius: 3px;
}
#plugin-information .fyi ul {
padding: 10px 5px 10px 7px;
margin: 0;
list-style: none;
-webkit-border-bottom-left-radius: 3px;
border-bottom-left-radius: 3px;
}
#plugin-information .fyi li {
margin-right: 0;
}
#plugin-information #section-holder {
padding: 10px;
}
#plugin-information .section ul,
#plugin-information .section ol {
margin-left: 16px;
list-style-type: square;
list-style-image: none;
}
#plugin-information #section-screenshots ol {
list-style: none;
margin: 0;
}
#plugin-information #section-screenshots li img {
vertical-align: text-top;
max-width: 100%;
width: auto;
height: auto;
}
#plugin-information #section-screenshots li p {
font-style: italic;
padding-left: 20px;
padding-bottom: 2em;
}
#plugin-information #section-screenshots ol,
#plugin-information .updated,
#plugin-information pre {
margin-right: 215px;
}
#plugin-information pre {
padding: 7px;
overflow: auto;
}
/* press-this */
body.press-this {
color: #333;
margin: 0;
padding: 0;
min-width: 675px;
min-height: 400px;
}
img {
border: none;
}
/* Header */
.press-this #wphead {
height: 32px;
margin-left: 0;
margin-right: 0;
margin-bottom: 5px;
}
.press-this #header-logo {
float: left;
margin: 7px 7px 0;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
}
.press-this #wphead h1 {
font-weight: normal;
font-size: 16px;
line-height: 32px;
margin: 0;
float: left;
}
.press-this #wphead h1 a {
text-decoration: none;
}
.press-this #wphead h1 a:hover {
text-decoration: underline;
}
.press-this #message {
margin: 10px 0;
}
.press-this-sidebar {
float: right;
width: 200px;
padding-top: 10px;
}
.press-this #title {
margin-left: 0;
margin-right: 0;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
}
.press-this .tagchecklist span a {
background: transparent url(../images/xit.gif) no-repeat 0 0;
}
.press-this #titlediv {
margin: 0;
}
.press-this .wp-media-buttons {
cursor: default;
padding: 8px 8px 0;
}
.press-this .howto {
margin-top: 2px;
margin-bottom: 3px;
font-size: 12px;
font-style: italic;
display: block;
}
/* Editor/Main Column */
.press-this #poststuff {
margin: 0 10px 10px;
}
#poststuff #editor-toolbar {
height: 30px;
}
div.zerosize {
border: 0 none;
height: 0;
margin: 0;
overflow: hidden;
padding: 0;
width: 0;
}
.posting {
margin-right: 212px;
position: relative;
}
.press-this .inner-sidebar {
width: 200px;
}
.press-this .inner-sidebar .sleeve {
padding-top: 5px;
}
.press-this #submitdiv p {
margin: 0;
padding: 6px;
}
.press-this #submitdiv #publishing-actions {
border-bottom: 1px solid #dfdfdf;
}
.press-this #publish {
float: right;
}
.press-this #poststuff h2,
.press-this #poststuff h3 {
font-size: 14px;
line-height: 1;
}
.press-this #tagsdiv-post_tag h3,
.press-this #categorydiv h3 {
cursor: pointer;
}
.press-this #submitdiv h3 {
cursor: default;
}
h3.tb {
text-shadow: 0 1px 0 #fff;
font-weight: bold;
font-size: 12px;
margin-left: 5px;
}
#TB_window {
border: 1px solid #333;
}
.press-this .postbox,
.press-this .stuffbox {
margin-bottom: 10px;
min-width: 0;
}
.postbox:hover .handlediv,
.stuffbox:hover .handlediv {
background: transparent url(../images/arrows.png) no-repeat 6px 7px;
}
.press-this #submitdiv:hover .handlediv {
background: none;
}
.tbtitle {
font-size: 1.7em;
outline: none;
padding: 3px 4px;
border-color: #dfdfdf;
}
.press-this .actions {
float: right;
margin: -19px 0 0;
}
.press-this #extra-fields .actions {
margin: -25px -7px 0 0;
}
.press-this .actions li {
float: left;
list-style: none;
margin-right: 10px;
}
#extra-fields .button {
margin-right: 5px;
}
/* Photo Styles */
#photo_saving {
margin: 0 8px 8px;
vertical-align: middle;
}
#img_container_container {
overflow: auto;
}
#extra-fields {
margin-top: 10px;
position: relative;
}
#extra-fields h2 {
margin: 12px;
}
#waiting {
margin-top: 10px;
}
#extra-fields .postbox {
margin-bottom: 5px;
}
#extra-fields .titlewrap {
padding: 0;
overflow: auto;
height: 100px;
}
#img_container a {
display: block;
float: left;
overflow: hidden;
vertical-align: center;
}
#img_container img,
#img_container a {
width: 68px;
height: 68px;
}
#img_container img {
border: none;
background-color: #f4f4f4;
cursor: pointer;
}
#img_container a,
#img_container a:link,
#img_container a:visited {
border: 1px solid #ccc;
display: block;
position: relative;
}
#img_container a:hover,
#img_container a:active {
border-color: #000;
z-index: 1000;
border-width: 2px;
margin: -1px;
}
/* Video */
#embed-code {
width: 100%;
height: 98px;
}
/* Categories */
.press-this .categorydiv div.tabs-panel {
height: 100px;
}
/* Tags */
.press-this .tagsdiv .newtag {
width: 130px;
}
.press-this #content {
margin: 5px 0;
padding: 0 5px;
border: 0 none;
height: 357px;
font-family: Consolas, Monaco, monospace;
font-size: 13px;
line-height: 19px;
background: transparent;
}
/* Submit */
#saving {
display: inline;
vertical-align: middle;
}
#TB_ajaxContent #options {
position: absolute;
top: 20px;
right: 25px;
padding: 5px;
}
#TB_ajaxContent h3 {
margin-bottom: .25em;
}
.error a {
text-decoration: underline;
}
.updated a {
text-decoration: none;
padding-bottom: 2px;
}
/* tag hints */
.taghint {
color: #aaa;
margin: -17px 0 0 7px;
visibility: hidden;
}
input.newtag ~ div.taghint {
visibility: visible;
}
input.newtag:focus ~ div.taghint {
visibility: hidden;
}
/* TinyMCE */
#mce_fullscreen_container {
background: #fff;
}
#photo-add-url-div input[type="text"] {
width: 300px;
}
/* theme-editor */
.alignleft h3 {
margin: 0;
}
h3 span {
font-weight: normal;
}
#template textarea {
font-family: Consolas, Monaco, monospace;
font-size: 12px;
width: 97%;
background: #f9f9f9;
outline: none;
}
#template p {
width: 97%;
}
#templateside {
float: right;
width: 190px;
word-wrap: break-word;
}
#templateside h3,
#postcustomstuff p.submit {
margin: 0;
}
#templateside h4 {
margin: 1em 0 0;
}
#templateside ol,
#templateside ul {
margin: .5em;
padding: 0;
}
#templateside li {
margin: 4px 0;
}
#templateside ul li a span.highlight {
display:block;
}
.nonessential {
font-size: 11px;
font-style: italic;
padding-left: 12px;
}
.highlight {
padding: 3px 3px 3px 12px;
margin-left: -12px;
font-weight: bold;
border: 0 none;
}
#documentation {
margin-top: 10px;
}
#documentation label {
line-height: 22px;
vertical-align: top;
font-weight: bold;
}
.fileedit-sub {
padding: 10px 0 8px;
line-height: 180%;
}
#filter-box {
clear: both;
}
.feature-filter {
padding: 8px 12px 0;
}
.feature-filter .feature-group {
float: left;
margin: 5px 10px 10px;
}
.feature-filter .feature-group li {
display: inline;
float: left;
list-style-type: none;
padding-right: 25px;
width: 150px;
}
.feature-container {
width: 100%;
overflow: auto;
margin-bottom: 10px;
}
/* widgets */
/* 2 column liquid layout */
div.widget-liquid-left {
float: left;
clear: left;
width: 100%;
margin-right: -325px;
}
div#widgets-left {
margin-left: 5px;
margin-right: 325px;
}
div#widgets-right {
width: 285px;
margin: 0 auto;
}
div.widget-liquid-right {
float: right;
clear: right;
width: 300px;
}
.widget-liquid-right .widget,
.inactive-sidebar .widget,
.widget-liquid-right .sidebar-description {
width: 250px;
margin: 0 auto 20px;
overflow: hidden;
}
.widget-liquid-right .sidebar-description {
margin-bottom: 10px;
}
.inactive-sidebar .widget {
margin: 0 10px 20px;
float: left;
}
div.sidebar-name h3 {
font-weight: normal;
font-size: 15px;
margin: 0;
padding: 8px 10px;
overflow: hidden;
white-space: nowrap;
}
div.sidebar-name {
cursor: pointer;
font-size: 13px;
border-width: 1px;
border-style: solid;
-webkit-border-top-right-radius: 3px;
-webkit-border-top-left-radius: 3px;
border-top-right-radius: 3px;
border-top-left-radius: 3px;
}
.js .closed .sidebar-name {
-webkit-border-bottom-right-radius: 3px;
-webkit-border-bottom-left-radius: 3px;
border-bottom-right-radius: 3px;
border-bottom-left-radius: 3px;
}
.widget-liquid-right .widgets-sortables,
#widgets-left .widget-holder {
border-width: 0 1px 1px;
border-style: none solid solid;
-webkit-border-bottom-right-radius: 3px;
-webkit-border-bottom-left-radius: 3px;
border-bottom-right-radius: 3px;
border-bottom-left-radius: 3px;
}
.js .closed .widgets-sortables,
.js .closed .widget-holder {
display: none;
}
.widget-liquid-right .widgets-sortables {
padding: 15px 0 0;
}
#available-widgets .widget-holder {
padding: 7px 5px 0;
}
#available-widgets .widget {
-moz-box-shadow: none;
-webkit-box-shadow: none;
box-shadow: none;
}
.inactive-sidebar {
padding: 5px 5px 0;
}
#widget-list .widget {
width: 250px;
margin: 0 10px 15px;
border: 0 none;
background: transparent;
float: left;
}
#widget-list .widget-description {
padding: 5px 8px;
}
.widget-placeholder {
border-width: 1px;
border-style: dashed;
margin: 0 auto 20px;
height: 26px;
width: 250px;
}
.inactive-sidebar .widget-placeholder {
margin: 0 10px 20px;
float: left;
}
div.widgets-holder-wrap {
padding: 0;
margin: 10px 0 20px;
}
#widgets-left #available-widgets {
background-color: transparent;
border: 0 none;
}
ul#widget-list {
list-style: none;
margin: 0;
padding: 0;
min-height: 100px;
}
.widget .widget-top {
margin-bottom: -1px;
font-size: 12px;
font-weight: bold;
height: 26px;
overflow: hidden;
}
.widget-top .widget-title {
padding: 7px 9px;
}
.widget-top .widget-title-action {
float: right;
}
a.widget-action {
display: block;
width: 24px;
height: 26px;
}
#available-widgets a.widget-action {
display: none;
}
.widget-top a.widget-action {
background: transparent url(../images/arrows.png) no-repeat 4px 6px;
}
.widget-top a.widget-action:hover {
background: transparent url(../images/arrows-dark.png) no-repeat 4px 6px;
}
.widget .widget-inside,
.widget .widget-description {
padding: 12px 12px 10px;
font-size: 12px;
line-height: 16px;
}
.widget-inside,
.widget-description {
display: none;
}
#available-widgets .widget-description {
display: block;
}
.widget .widget-inside p {
margin: 0 0 1em;
padding: 0;
}
.widget-title h4 {
margin: 0;
line-height: 1;
overflow: hidden;
white-space: nowrap;
}
.widgets-sortables {
min-height: 90px;
}
.widget-control-actions {
margin-top: 8px;
}
.widget-control-actions a {
text-decoration: none;
}
.widget-control-actions a:hover {
text-decoration: underline;
}
.widget-control-actions .ajax-feedback {
padding-bottom: 3px;
}
.widget-control-actions div.alignleft {
margin-top: 6px;
}
div#sidebar-info {
padding: 0 1em;
margin-bottom: 1em;
font-size: 12px;
}
.widget-title a,
.widget-title a:hover {
text-decoration: none;
border-bottom: none;
}
.widget-control-edit {
display: block;
font-size: 12px;
font-weight: normal;
line-height: 26px;
padding: 0 8px 0 0;
}
a.widget-control-edit {
text-decoration: none;
}
.widget-control-edit .add,
.widget-control-edit .edit {
display: none;
}
#available-widgets .widget-control-edit .add,
#widgets-right .widget-control-edit .edit,
.inactive-sidebar .widget-control-edit .edit {
display: inline;
}
.editwidget {
margin: 0 auto 15px;
}
.editwidget .widget-inside {
display: block;
padding: 10px;
}
.inactive p.description {
margin: 5px 15px 10px;
}
#available-widgets p.description {
margin: 0 12px 12px;
}
.widget-position {
margin-top: 8px;
}
.inactive {
padding-top: 2px;
}
.sidebar-name-arrow {
float: right;
height: 29px;
width: 26px;
}
.widget-title .in-widget-title {
font-size: 12px;
white-space: nowrap;
}
#removing-widget {
display: none;
font-weight: normal;
padding-left: 15px;
font-size: 12px;
line-height: 1;
}
.widget-control-noform,
#access-off,
.widgets_access .widget-action,
.widgets_access .sidebar-name-arrow,
.widgets_access #access-on,
.widgets_access .widget-holder .description {
display: none;
}
.widgets_access .widget-holder,
.widgets_access #widget-list {
padding-top: 10px;
}
.widgets_access #access-off {
display: inline;
}
.widgets_access #wpbody-content .widget-title-action,
.widgets_access #wpbody-content .widget-control-edit,
.widgets_access .closed .widgets-sortables,
.widgets_access .closed .widget-holder {
display: block;
}
.widgets_access .closed .sidebar-name {
-webkit-border-bottom-right-radius: 0;
-webkit-border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
}
.widgets_access .sidebar-name,
.widgets_access .widget .widget-top {
cursor: default;
}
/* =Media Queries
-------------------------------------------------------------- */
@media only screen and (max-width: 768px) {
/* categories */
#col-left {
width: 100%;
}
#col-right {
width: 100%;
}
}
@media only screen and (min-width: 769px) {
/* categories */
#col-left {
width: 35%;
}
#col-right {
width: 65%;
}
}
@media only screen and (max-width: 860px) {
/* categories */
#col-left {
width: 35%;
}
#col-right {
width: 65%;
}
}
@media only screen and (min-width: 980px) {
/* categories */
#col-left {
width: 35%;
}
#col-right {
width: 65%;
}
}
@media only screen and (max-width: 768px) {
/* categories */
#col-left {
width: 100%;
}
#col-right {
width: 100%;
}
.form-field input,
.form-field textarea {
width: 99%;
}
.form-wrap .form-field {
padding:0;
}
/* users */
#profile-page .form-table textarea {
max-width: 400px;
width: auto;
}
}
/* =Localized CSS
-------------------------------------------------------------- */
/* zh_CN: Remove italic properties. */
.locale-zh-cn .howto,
.locale-zh-cn .tablenav .displaying-num,
.locale-zh-cn .js .input-with-default-title,
.locale-zh-cn .link-to-original,
.locale-zh-cn .inline-edit-row fieldset span.title,
.locale-zh-cn .inline-edit-row fieldset span.checkbox-title,
.locale-zh-cn #utc-time,
.locale-zh-cn #local-time,
.locale-zh-cn p.install-help,
.locale-zh-cn p.help,
.locale-zh-cn p.description,
.locale-zh-cn span.description,
.locale-zh-cn .form-wrap p {
font-style: normal;
}
/* zh_CN: Enlarge dashboard widget 'Configure' link */
.locale-zh-cn .hdnle a { font-size: 12px; }
/* zn_CH: Enlarge font size, set font-size: normal */
.locale-zh-cn form.upgrade .hint { font-style: normal; font-size: 100%; }
/* Zn_CH: Distraction free writing.
* More beautiful font for "Just write."
* Larger text for HTML/Visual mode.
*/
.locale-zh-cn #wp-fullscreen-tagline { font-family: KaiTi, "楷体", sans-serif; }
.locale-zh-cn #wp-fullscreen-modes a { font-size: 12px; }
/* zh_CN: Enlarge font-size. */
.locale-zh-cn #sort-buttons { font-size: 1em !important; }
/* ru_RU: Text needs more room to breathe. */
.locale-ru-ru #dashboard_quick_press .input-text-wrap,
.locale-ru-ru #dashboard_quick_press .textarea-wrap,
.locale-ru-ru #dashboard_quick_press .wp-media-buttons {
margin-left: 5.7em; /* default 5em + 0.7em */
}
.locale-ru-ru #dashboard_quick_press h4 {
width: 5.7em; /* default 5.5em + 0.2em */
}
.locale-ru-ru #dashboard-widgets #dashboard_quick_press form p.submit {
margin-left: 5.3em; /* default 4.6em + 0.7em */
}
.locale-ru-ru .inline-edit-row fieldset label span.title {
width: auto; /* default 5em */
min-width: 5em;
}
.locale-ru-ru.press-this .posting {
margin-right: 257px; /* default 212px + 45px */
}
.locale-ru-ru.press-this #photo-add-url-div input[type="text"] {
width: 255px; /* default 300px - 45px */
}
.locale-ru-ru.press-this #side-sortables {
width: 245px; /* default 200px + 45px */
}
/* lt_LT: QuickPress + QuickEdit */
.locale-lt-lt #dashboard_quick_press .input-text-wrap,
.locale-lt-lt #dashboard_quick_press .textarea-wrap,
.locale-lt-lt #dashboard_quick_press .wp-media-buttons {
margin-left: 7em;
}
.locale-lt-lt #dashboard_quick_press h4 {
width: 7em;
}
.locale-lt-lt .inline-edit-row fieldset label span.title {
width: 8em;
}
.locale-lt-lt .inline-edit-row fieldset label span.input-text-wrap {
margin-left: 8em;
}
| 01happy-blog | trunk/myblog/wp-admin/css/wp-admin.dev.css | CSS | oos | 138,084 |
/* Fixes for IE 7 bugs */
.wp-editor-wrap .wp-editor-container textarea.wp-editor-area {
width: 97%;
}
#post-body.columns-2 #postbox-container-1 {
padding-left: 19px;
}
.welcome-panel .wp-badge {
position: absolute;
}
.welcome-panel .welcome-panel-column {
margin: 0 -25px 0 4%;
}
#wp-fullscreen-title {
width: 97%;
}
#wp_mce_fullscreen_ifr {
background-color: #f9f9f9;
}
#wp-fullscreen-tagline {
color: #888;
font-size: 14px;
}
#adminmenushadow {
display: none;
}
#adminmenuback {
left: 0;
background-image: none;
}
#adminmenuwrap {
position: static;
}
#adminmenu {
position: relative;
}
#adminmenu li.wp-menu-separator,
#adminmenu li.wp-menu-separator-last {
font-size: 1px;
line-height: 1;
}
#adminmenu a.menu-top {
border-bottom: 0 none;
border-top: 1px solid #ddd;
}
#adminmenu .separator {
font-size: 1px;
line-height: 1px;
}
#adminmenu .wp-submenu ul {
margin: 0;
}
.folded #adminmenu .wp-submenu ul {
margin-left: 5px;
}
#adminmenu li.menu-top {
margin-bottom: -2px;
}
#adminmenu li.wp-not-current-submenu:hover .wp-menu-arrow {
display: none;
}
#wpcontent #adminmenu .wp-submenu li.wp-submenu-head {
padding: 3px 4px 4px 10px;
zoom: 100%;
}
.js.folded #adminmenu .menu-top {
height: 30px;
}
.js.folded #adminmenu .wp-submenu {
margin: -1px 0 0 0;
}
.js.folded #adminmenu li.menu-top {
display: block;
zoom: 100%;
}
ul#adminmenu {
z-index: 99;
}
#adminmenu li.menu-top a.menu-top {
min-width: auto;
width: auto;
}
#wpcontent #adminmenu li.wp-has-current-submenu a.wp-has-submenu {
font-style: normal;
}
#wpcontent #adminmenu .wp-submenu li {
padding: 0;
}
#collapse-menu {
line-height: 23px;
}
#wpadminbar .ab-comments-icon {
padding-top: 7px;
}
table.fixed th,
table.fixed td {
border-top: 1px solid #ddd;
}
#wpbody-content input.button,
#wpbody-content input.button-primary,
#wpbody-content input.button-secondary,
#wpbody-content input.button-highlighted {
overflow: visible;
}
#dashboard-widgets #dashboard_quick_press form p.submit #publish {
float: none;
}
#dashboard-widgets h3 a {
height: 14px;
line-height: 14px;
}
#dashboard_browser_nag {
color: #fff;
}
#dashboard_browser_nag .browser-icon {
position: relative;
}
.tablenav-pages .current-page {
vertical-align: middle;
}
#wpbody-content .postbox {
border: 1px solid #dfdfdf;
}
#wpbody-content .postbox h3 {
margin-bottom: -1px;
}
.major-publishing-actions,
.wp-submenu,
.wp-submenu li,
.wp-menu-toggle,
#template,
#template div,
#editcat,
#addcat {
zoom: 100%;
}
.wp-menu-arrow {
height: 28px;
}
.submitbox {
margin-top: 10px;
}
/* Inline Editor */
#wpbody-content .quick-edit-row-post .inline-edit-col-left {
width: 39%;
}
#wpbody-content .inline-edit-row-post .inline-edit-col-center {
width: 19%;
}
#wpbody-content .quick-edit-row-page .inline-edit-col-left {
width: 49%;
}
#wpbody-content .bulk-edit-row .inline-edit-col-left {
width: 29%;
}
.inline-edit-row p.submit {
zoom: 100%;
}
.inline-edit-row fieldset label span.title {
display: block;
float: left;
width: 5em;
}
.inline-edit-row fieldset label span.input-text-wrap {
margin-left: 0;
zoom: 100%;
}
#wpbody-content .inline-edit-row fieldset label span.input-text-wrap input {
line-height: 130%;
}
#wpbody-content .inline-edit-row .input-text-wrap input {
width: 95%;
}
#wpbody-content .inline-edit-row .input-text-wrap input.inline-edit-password-input {
width: 8em;
}
/* end Inline Editor */
#titlediv #title {
width: 98%;
}
a.button {
line-height: 1.4em;
margin: 1px;
padding: 2px 6px;
}
#screen-options-wrap {
overflow: hidden;
}
#the-comment-list .comment-item,
#post-status-info,
#wpwrap,
#wrap,
#postdivrich,
#postdiv,
#poststuff,
.metabox-holder,
#titlediv,
#post-body,
#editorcontainer,
.tablenav,
.widget-liquid-left,
.widget-liquid-right,
#widgets-left,
.widgets-sortables,
#dragHelper,
.widget .widget-top,
.widget,
.widget-control-actions,
.tagchecklist,
#col-container,
#col-left,
#col-right,
.fileedit-sub {
display: block;
zoom: 100%;
}
p.search-box {
position: static;
float: right;
margin: -3px 0 4px;
}
#editorcontainer #content {
overflow: auto;
margin: auto;
width: 98%;
}
form#template div {
width: 100%;
}
.wp-editor-container .quicktags-toolbar input {
overflow: visible;
padding: 0 4px;
}
#poststuff h2 {
font-size: 1.6em;
}
#bh {
margin: 7px 10px 0 0;
float: right;
}
/* without this dashboard widgets appear in one column for some screen widths */
div#dashboard-widgets {
padding-right: 1px;
}
.tagchecklist span, .tagchecklist span a {
display: inline-block;
display: block;
}
.tagchecklist span a {
margin: 4px 0 0 -9px;
}
.tablenav .button-secondary,
.nav .button-secondary {
padding-top: 2px;
padding-bottom: 2px;
}
.tablenav select {
font-size: 13px;
display: inline-block;
vertical-align: top;
margin-top: 2px;
}
.tablenav .actions select {
width: 155px;
}
table.ie-fixed {
table-layout: fixed;
}
.widefat tr, .widefat th {
margin-bottom: 0;
border-spacing: 0;
}
.widefat th input {
margin: 0 0 0 5px;
}
.widefat .check-column {
padding: 6px 0 2px;
}
.widefat tbody th.check-column {
padding: 4px 0 22px;
}
.widefat {
empty-cells: show;
border-collapse: collapse;
}
.tablenav a.button-secondary {
display: inline-block;
padding: 2px 5px;
}
.inactive-sidebar .widgets-sortables {
padding-bottom: 8px;
}
#available-widgets .widget-holder {
padding-bottom: 65px;
}
#widgets-left .inactive {
padding-bottom: 10px;
}
.widget-liquid-right .widget,
.inactive-sidebar .widget {
position: relative;
}
#wpcontent .button-primary-disabled {
color: #9FD0D5;
background: #298CBA;
}
#wpcontent #ajax-loading,
#wpcontent .ajax-loading {
vertical-align: baseline;
}
#the-comment-list .unapproved tr,
#the-comment-list .unapproved td {
background-color: #ffffe0;
}
.imgedit-submit {
width: 300px;
}
#nav-menus-frame,
#wpbody,
.menu li {
zoom: 100%;
}
#update-nav-menu #post-body {
overflow:hidden;
}
.menu li {
min-width: 100%;
}
.menu li.sortable-placeholder {
min-width: 400px;
}
.about-wrap img.element-screenshot {
padding: 2px;
}
.about-wrap .feature-section img,
.about-wrap .feature-section .image-mask {
border-width: 1px;
border-style: solid;
}
.about-wrap .feature-section.three-col img {
margin-left: 0;
}
.available-theme {
display: inline;
}
.available-theme ul {
margin: 0;
}
.about-wrap .three-col-images img {
margin: 0 0.6% 10px;
}
.about-wrap .three-col-images .last-feature,
.about-wrap .three-col-images .first-feature {
float: none;
}
/* IE6 leftovers */
* html .row-actions {
visibility: visible;
}
* html div.widget-liquid-left,
* html div.widget-liquid-right {
display: block;
position: relative;
}
* html #editorcontainer {
padding: 0;
}
* html #poststuff h2 {
margin-left: 0;
}
* html .stuffbox,
* html .stuffbox input,
* html .stuffbox textarea {
border: 1px solid #DFDFDF;
}
* html .feature-filter .feature-group li {
width: 145px;
}
* html .widget-top .widget-title-action a {
background: url("../images/menu-bits.gif?ver=20100610") no-repeat scroll 0 -110px;
}
* html div.widget-liquid-left {
width: 99%;
}
* html .widgets-sortables {
height: 50px;
}
* html a#content_resize {
right: -2px;
}
* html .widget-title h4 {
width: 205px;
}
* html #removing-widget .in-widget-title {
display: none;
}
* html .media-item .pinkynail {
height: 32px;
width: 40px;
}
* html .describe .field input.text,
* html .describe .field textarea {
width: 440px;
}
* html input {
border: 1px solid #dfdfdf;
}
* html .meta-box-sortables .postbox .handlediv {
background: transparent url(../images/menu-bits-vs.gif) no-repeat scroll left -111px;
}
* html .edit-box {
display: inline;
}
* html .postbox-container .meta-box-sortables {
height: 300px;
}
* html #wpbody-content #screen-options-link-wrap {
display: inline-block;
width: 150px;
text-align: center;
}
* html #wpbody-content #contextual-help-link-wrap {
display: inline-block;
width: 100px;
text-align: center;
}
* html #adminmenu {
margin-left: -80px;
}
* html .folded #adminmenu {
margin-left: -22px;
}
* html #wpcontent #adminmenu li.menu-top {
display: inline;
padding: 0;
margin: 0;
}
* html #footer {
margin: 0;
}
* html #wpcontent #adminmenu .wp-menu-open .wp-menu-toggle {
background: none;
}
* html #wpcontent #adminmenu .wp-has-submenu .wp-menu-toggle {
background: url(../images/menu-bits.gif?ver=20100610) no-repeat scroll left -109px;
}
* html #wpcontent #adminmenu li.wp-has-current-submenu .wp-menu-toggle {
background: url(../images/menu-bits.gif?ver=20100610) no-repeat scroll left -206px;
}
* html #adminmenu div.wp-menu-image {
height: 29px;
}
| 01happy-blog | trunk/myblog/wp-admin/css/ie.dev.css | CSS | oos | 8,653 |
.farbtastic {
position: relative;
}
.farbtastic * {
position: absolute;
cursor: crosshair;
}
.farbtastic,
.farbtastic .wheel {
width: 195px;
height: 195px;
}
.farbtastic .color,
.farbtastic .overlay {
top: 47px;
left: 47px;
width: 101px;
height: 101px;
}
.farbtastic .wheel {
background: url(../images/wheel.png) no-repeat;
width: 195px;
height: 195px;
}
.farbtastic .overlay {
background: url(../images/mask.png) no-repeat;
}
.farbtastic .marker {
width: 17px;
height: 17px;
margin: -8px 0 0 -8px;
overflow: hidden;
background: url(../images/marker.png) no-repeat;
}
/* farbtastic-rtl */
.rtl .farbtastic .color,
.rtl .farbtastic .overlay {
left: 0;
right: 47px;
}
.rtl .farbtastic .marker {
margin: -8px -8px 0 0;
}
| 01happy-blog | trunk/myblog/wp-admin/css/farbtastic.css | CSS | oos | 766 |
/* Styles for the media library iframe (not used on the Library screen) */
div#media-upload-header {
margin: 0;
padding: 5px 5px 0;
font-weight: bold;
position: relative;
border-bottom-width: 1px;
border-bottom-style: solid;
}
body#media-upload ul#sidemenu {
font-weight: normal;
margin: 0 5px;
left: 0;
bottom: -1px;
float: none;
overflow: hidden;
}
form {
margin: 1em;
}
#search-filter {
text-align: right;
}
th {
position: relative;
}
.media-upload-form label.form-help, td.help {
font-family: sans-serif;
font-style: italic;
font-weight: normal;
}
.media-upload-form p.help {
margin: 0;
padding: 0;
}
.media-upload-form fieldset {
width: 100%;
border: none;
text-align: justify;
margin: 0 0 1em 0;
padding: 0;
}
/* specific to the image upload form */
.image-align-none-label {
background: url(../images/align-none.png) no-repeat center left;
}
.image-align-left-label {
background: url(../images/align-left.png) no-repeat center left;
}
.image-align-center-label {
background: url(../images/align-center.png) no-repeat center left;
}
.image-align-right-label {
background: url(../images/align-right.png) no-repeat center left;
}
tr.image-size td {
width: 460px;
}
tr.image-size div.image-size-item {
margin: 0 0 5px;
}
#library-form .progress,
#gallery-form .progress,
.insert-gallery,
.describe.startopen,
.describe.startclosed {
display: none;
}
.media-item .thumbnail {
max-width: 128px;
max-height: 128px;
}
thead.media-item-info tr {
background-color: transparent;
}
.form-table thead.media-item-info {
border: 8px solid #fff;
}
abbr.required {
text-decoration: none;
border: none;
}
.describe label {
display: inline;
}
.describe td.error {
padding: 2px 8px;
}
.describe td.A1 {
width: 132px;
}
.describe input[type="text"],
.describe textarea {
width: 460px;
border-width: 1px;
border-style: solid;
}
/* Specific to Uploader */
#media-upload p.ml-submit {
padding: 1em 0;
}
#media-upload p.help,
#media-upload label.help {
font-family: sans-serif;
font-style: italic;
font-weight: normal;
}
#media-upload .ui-sortable .media-item {
cursor: move;
}
#media-upload tr.image-size {
margin-bottom: 1em;
height: 3em;
}
#media-upload #filter {
width: 623px;
}
#media-upload #filter .subsubsub {
margin: 8px 0;
}
#filter .tablenav select {
border-style: solid;
border-width: 1px;
padding: 2px;
vertical-align: top;
width: auto;
}
#media-upload .del-attachment {
display: none;
margin: 5px 0;
}
.menu_order {
float: right;
font-size: 11px;
margin: 10px 10px 0;
}
.menu_order_input {
border: 1px solid #ddd;
font-size: 10px;
padding: 1px;
width: 23px;
}
.ui-sortable-helper {
background-color: #fff;
border: 1px solid #aaa;
opacity: 0.6;
filter: alpha(opacity=60);
}
#media-upload th.order-head {
width: 20%;
text-align: center;
}
#media-upload th.actions-head {
width: 25%;
text-align: center;
}
#media-upload a.wp-post-thumbnail {
margin: 0 20px;
}
#media-items a.delete {
display: block;
float: right;
}
#media-upload .widefat {
width: 626px;
border-style: solid solid none;
}
.sorthelper {
height: 37px;
width: 623px;
display: block;
}
#gallery-settings th.label {
width: 160px;
}
#gallery-settings #basic th.label {
padding: 5px 5px 5px 0;
}
#gallery-settings .title {
clear: both;
padding: 0 0 3px;
font-size: 1.6em;
border-bottom: 1px solid #DADADA;
}
h3.media-title {
font-size: 1.6em;
}
h4.media-sub-title {
border-bottom: 1px solid #DADADA;
font-size: 1.3em;
margin: 12px;
padding: 0 0 3px;
}
#gallery-settings .title,
h3.media-title,
h4.media-sub-title {
font-family: Georgia,"Times New Roman",Times,serif;
font-weight: normal;
color: #5A5A5A;
}
#gallery-settings .describe td {
vertical-align: middle;
height: 3em;
}
#gallery-settings .describe th.label {
padding-top: .5em;
text-align: left;
}
#gallery-settings .describe {
padding: 5px;
width: 615px;
clear: both;
cursor: default;
}
#gallery-settings .describe select {
width: 15em;
}
#gallery-settings .describe select option,
#gallery-settings .describe td {
padding: 0;
}
#gallery-settings label,
#gallery-settings legend {
font-size: 13px;
color: #464646;
margin-right: 15px;
}
#gallery-settings .align .field label {
margin: 0 1em 0 3px;
}
#gallery-settings p.ml-submit {
border-top: 1px solid #dfdfdf;
}
#gallery-settings select#columns {
width: 6em;
}
#sort-buttons {
font-size: 0.8em;
margin: 3px 25px -8px 0;
text-align: right;
max-width: 625px;
}
#sort-buttons a {
text-decoration: none;
}
#sort-buttons #asc,
#sort-buttons #showall {
padding-left: 5px;
}
#sort-buttons span {
margin-right: 25px;
}
p.media-types {
margin: 1em;
}
tr.not-image {
display: none;
}
table.not-image tr.not-image {
display: table-row;
}
table.not-image tr.image-only {
display: none;
}
| 01happy-blog | trunk/myblog/wp-admin/css/media.dev.css | CSS | oos | 4,831 |
/*------------------------------------------------------------------------------
Hello, this is the RTL version of the main WordPress admin CSS file.
All the important stuff is in here.
TABLE OF CONTENTS:
------------------
1.0 - Text Elements
2.0 - Forms
3.0 - Actions
4.0 - Notifications
5.0 - TinyMCE
6.0 - Admin Header
6.1 - Screen Options Tabs
7.0 - Main Navigation
8.0 - Layout Blocks
9.0 - Dashboard
10.0 - List Posts
10.1 - Inline Editing
11.0 - Write/Edit Post Screen
11.1 - Custom Fields
11.2 - Post Revisions
12.0 - Categories
13.0 - Tags
14.0 - Media Screen
14.1 - Media Uploader
14.2 - Image Editor
15.0 - Comments Screen
16.0 - Themes
16.1 - Custom Header
16.2 - Custom Background
16.3 - Tabbed Admin Screen Interface
17.0 - Plugins
18.0 - Users
19.0 - Tools
20.0 - Settings
21.0 - Admin Footer
22.0 - About Pages
23.0 - Misc
24.0 - Dead
25.0 - TinyMCE tweaks
26.0 - Full Overlay w/ Sidebar
27.0 - Customize Loader
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
1.0 - Text Styles
------------------------------------------------------------------------------*/
ol {
margin-left: 0;
margin-right: 2em;
}
.code, code {
font-family: monospace;
direction: ltr;
}
.quicktags, .search {
font: 12px Tahoma, Arial, sans-serif;
}
.icon32 {
float: right;
margin-right: 0;
margin-left: 8px;
}
.icon16 {
float: right;
margin-right: -8px;
margin-left: 0;
}
.howto {
font-style: normal;
font-family: Tahoma, Arial, sans-serif;
}
p.install-help {
font-style: normal;
}
/*------------------------------------------------------------------------------
2.0 - Forms
------------------------------------------------------------------------------*/
#doaction,
#doaction2,
#post-query-submit {
margin-right: 0;
margin-left: 8px;
}
#timezone_string option {
margin-left: 0;
margin-right: 1em;
}
#pass-strength-result {
float: right;
margin: 13px 1px 5px 5px;
}
p.search-box {
float: left;
}
input[type=password] {
direction: ltr;
}
input[type="text"].ui-autocomplete-loading {
background: transparent url('../images/loading.gif') no-repeat left center;
}
ul#add-to-blog-users {
margin: 0 14px 0 0;
}
.ui-autocomplete li {
text-align: right;
}
/*------------------------------------------------------------------------------
3.0 - Actions
------------------------------------------------------------------------------*/
#delete-action {
float: right;
}
#publishing-action {
float: left;
}
#post-body .misc-pub-section {
border-right:0;
border-left-width: 1px;
border-left-style: solid;
}
#post-body .misc-pub-section-last {
border-left: 0;
}
#minor-publishing-actions {
padding: 10px 8px 2px 10px;
text-align: left;
}
#save-post {
float: right;
}
#minor-publishing .ajax-loading {
padding: 3px 4px 0 0;
float: right;
}
.preview {
float: left;
}
#sticky-span {
margin-left: 0;
margin-right: 18px;
}
.side-info ul {
padding-left: 0;
padding-right: 18px;
}
td.action-links,
th.action-links {
text-align: left;
}
.describe .del-link {
padding-left: 0;
padding-right: 5px;
}
/*------------------------------------------------------------------------------
4.0 - Notifications
------------------------------------------------------------------------------*/
form.upgrade .hint {
font-style: normal;
}
#ajax-response.alignleft {
margin-left: 0;
margin-right: 2em;
}
/*------------------------------------------------------------------------------
5.0 - TinyMCE
------------------------------------------------------------------------------*/
#quicktags {
background-position: right top;
}
#ed_reply_toolbar input {
margin: 1px 1px 1px 2px;
}
/*------------------------------------------------------------------------------
6.0 - Admin Header
------------------------------------------------------------------------------*/
#wphead {
height: 32px;
margin-left: 15px;
margin-right: 2px;
}
#header-logo {
float: right;
}
#wphead h1 {
float: right;
}
/*------------------------------------------------------------------------------
6.1 - Screen Options Tabs
------------------------------------------------------------------------------*/
#screen-meta-links {
margin-right: 0;
margin-left: 24px;
}
#screen-meta {
margin-right: 5px;
margin-left: 15px;
}
#screen-options-link-wrap,
#contextual-help-link-wrap {
float: left;
margin-left: 0;
margin-right: 6px;
}
#screen-meta-links a.show-settings {
padding-right: 6px;
padding-left: 16px;
}
.toggle-arrow {
background-position: top right;
}
.toggle-arrow-active {
background-position: bottom right;
}
.metabox-prefs label {
padding-right: 0;
padding-left: 15px;
}
.metabox-prefs label input {
margin-right: 2px;
margin-left: 5px;
}
/*------------------------------------------------------------------------------
6.2 - Help Menu
------------------------------------------------------------------------------*/
#contextual-help-wrap {
margin-left: 0;
margin-right: -4px;
}
#contextual-help-back {
left: 170px;
right: 150px;
}
#contextual-help-wrap.no-sidebar #contextual-help-back {
left: 0;
right: 150px;
border-right-width: 1px;
border-left-width: 0;
-webkit-border-bottom-right-radius: 0;
border-bottom-right-radius: 0;
-webkit-border-bottom-left-radius: 2px;
border-bottom-left-radius: 2px;
}
.contextual-help-tabs {
float: right;
}
.contextual-help-tabs a {
padding-left: 5px;
padding-right: 12px;
}
.contextual-help-tabs .active {
margin-right: 0;
margin-left: -1px;
}
.contextual-help-tabs .active,
.contextual-help-tabs-wrap {
border-left: 0;
border-right-width: 1px;
}
.help-tab-content {
margin-right: 0;
margin-left: 22px;
}
.help-tab-content li {
margin-left: 0;
margin-right: 18px;
}
.contextual-help-sidebar {
float: left;
padding-right: 12px;
padding-left: 8px;
}
/*------------------------------------------------------------------------------
7.0 - Main Navigation (Right Menu) (RTL: Left Menu)
------------------------------------------------------------------------------*/
#adminmenuback,
#adminmenuwrap {
border-width: 0 0 0 1px;
}
#adminmenushadow {
right: auto;
left: 0;
}
#adminmenu li .wp-submenu {
left: auto;
right: 146px;
}
.folded #adminmenu .wp-submenu,
.folded #adminmenu .wp-has-current-submenu .wp-submenu {
left: auto;
right: 26px;
}
#adminmenu .wp-submenu.sub-open,
#adminmenu li.focused.wp-not-current-submenu .wp-submenu,
.folded #adminmenu li.focused.wp-has-current-submenu .wp-submenu,
.folded #adminmenu .wp-has-current-submenu .wp-submenu.sub-open,
.no-js #adminmenu .wp-has-submenu:hover .wp-submenu,
.no-js.folded #adminmenu .wp-has-current-submenu:hover .wp-submenu {
padding: 0 0 8px 8px;
}
#adminmenu div.wp-menu-image {
float: right;
}
#adminmenu li li {
margin-left: 0;
margin-right: 8px
}
#adminmenu .wp-submenu a,
#adminmenu li li a,
.folded #adminmenu .wp-not-current-submenu li a {
padding-left: 0;
padding-right: 12px;
}
#adminmenu .wp-not-current-submenu li a {
padding-left: 0;
padding-right: 18px;
}
.folded #adminmenu li li {
margin-left: inherit;
margin-right: 0
}
.folded #adminmenu li li a {
padding-left: inherit;
padding-right: 0
}
.wp-menu-arrow {
right: 0;
-moz-transform: translate( -139px );
-webkit-transform: translate( -139px );
-o-transform: translate( -139px );
-ms-transform: translate( -139px );
transform: translate( -139px );
}
.ie8 .wp-menu-arrow {
right: -20px;
}
#adminmenu .wp-menu-arrow div {
left: -8px;
width: 16px;
}
#adminmenu li.wp-not-current-submenu .wp-menu-arrow {
-moz-transform: translate( -138px );
-webkit-transform: translate( -138px );
-o-transform: translate( -138px );
-ms-transform: translate( -138px );
transform: translate( -138px );
}
.folded .wp-menu-arrow {
-moz-transform: translate( -27px );
-webkit-transform: translate( -27px );
-o-transform: translate( -27px );
-ms-transform: translate( -27px );
transform: translate( -27px );
}
#adminmenu .wp-not-current-submenu .wp-menu-arrow div {
border-style: solid solid none none;
border-width: 1px 1px 0 0;
}
#adminmenu .wp-menu-image img {
float: right;
padding: 5px 2px 0 0;
}
#adminmenu .wp-submenu .wp-submenu-head {
padding: 6px 10px 5px 4px;
}
#adminmenu li .wp-submenu-wrap {
border-width: 1px 0 1px 1px;
border-style: solid none solid solid;
-webkit-border-bottom-right-radius: 0;
-webkit-border-bottom-left-radius: 3px;
-webkit-border-top-right-radius: 0;
-webkit-border-top-left-radius: 3px;
border-bottom-right-radius: 0;
border-bottom-left-radius: 3px;
border-top-right-radius: 0;
border-top-left-radius: 3px;
}
.folded #adminmenu .wp-submenu ul {
border-width: 0 1px 0 0;
}
.folded #adminmenu .wp-submenu a {
padding-left: 0;
padding-right: 10px;
}
.folded #adminmenu a.wp-has-submenu {
margin-left: 0;
margin-right: 40px;
}
#adminmenu .wp-menu-toggle {
clear: left;
float: left;
padding: 1px 0 0 2px;
}
#adminmenu .awaiting-mod,
#adminmenu span.update-plugins,
#sidemenu li a span.update-plugins {
font-family: Tahoma, Arial, sans-serif;
margin-left: 0;
margin-right: 7px;
}
#collapse-button {
float: right;
}
/* Auto-folding of the admin menu */
@media only screen and (max-width: 900px) {
#adminmenu li .wp-submenu,
#adminmenu .wp-has-current-submenu .wp-submenu {
left: auto;
right: 26px;
}
#adminmenu li.focused.wp-has-current-submenu .wp-submenu,
#adminmenu .wp-has-current-submenu .wp-submenu.sub-open {
padding: 0 0 8px 8px;
}
.folded #adminmenu .wp-not-current-submenu li a {
padding-left: 0;
padding-right: 12px;
}
#adminmenu li li,
#adminmenu li li a {
padding-left: inherit;
padding-right: 0
}
.wp-menu-arrow {
-moz-transform: translate( -27px );
-webkit-transform: translate( -27px );
-o-transform: translate( -27px );
-ms-transform: translate( -27px );
transform: translate( -27px );
}
#adminmenu .wp-submenu ul {
border-width: 0 1px 0 0;
}
#adminmenu .wp-submenu a {
padding-left: 0;
padding-right: 10px;
}
#adminmenu a.wp-has-submenu {
margin-left: 0;
margin-right: 40px;
}
body #wpcontent {
margin-left: 0;
margin-right: 52px;
}
body .wp-admin #footer {
margin-left: 15px;
margin-right: 52px;
}
}
/* List table styles */
.post-com-count-wrapper {
font-family: Tahoma, Arial, sans-serif;
}
.column-response .post-com-count {
float: right;
margin-right: 0;
margin-left: 5px;
}
.response-links {
float: right;
}
/*------------------------------------------------------------------------------
8.0 - Layout Blocks
------------------------------------------------------------------------------*/
.widefat th {
font-family: Tahoma, Arial, sans-serif;
}
.widefat td p {
margin: 2px 0 0.8em;
}
.postbox-container {
float: right;
}
.postbox .handlediv {
float: left;
}
/*------------------------------------------------------------------------------
9.0 - Dashboard
------------------------------------------------------------------------------*/
#the-comment-list p.comment-author img {
float: right;
margin-right: 0;
margin-left: 8px;
}
/* Browser Nag */
#dashboard_browser_nag p.browser-update-nag.has-browser-icon {
padding-right: 0;
padding-left: 125px;
}
.welcome-panel .welcome-panel-close {
right: auto;
left: 10px;
}
.welcome-panel .welcome-panel-close:before {
left: auto;
right: -12px;
}
.welcome-panel .wp-badge {
float: right;
}
.welcome-panel-content .about-description, .welcome-panel h3 {
margin-left: 0;
margin-right: 190px;
}
.welcome-panel .welcome-panel-column {
margin: 0 -25px 0 5%;
padding-left: 0;
padding-right: 25px;
float: right;
}
.welcome-panel .welcome-panel-column.welcome-panel-last {
margin-right: auto;
padding-right: 0;
margin-left: 0;
}
.welcome-panel h4 .icon16 {
margin-left: 0;
margin-right: -32px;
}
.welcome-panel .welcome-panel-column-container {
padding: 0 25px 0 0;
}
.welcome-panel .welcome-panel-column ul {
margin: 1.6em 1.3em 1em 1em;
}
.welcome-panel .welcome-panel-column li {
padding-left: 0;
padding-right: 2px;
}
/*------------------------------------------------------------------------------
10.0 - List Posts (/Pages/etc)
------------------------------------------------------------------------------*/
.fixed .column-comments {
text-align: right;
}
.fixed .column-comments .vers {
padding-left: 0;
padding-right: 3px;
}
.fixed .column-comments a {
float: right;
}
.sorting-indicator {
margin-left: 0;
margin-right: 7px;
}
th.sortable a span,
th.sorted a span {
float: right;
}
/* Bulk Actions */
.tablenav-pages a {
margin-right: 0;
margin-left: 1px;
}
.tablenav-pages .next-page {
margin-left: 0;
margin-right: 2px;
}
.tablenav a.button-secondary {
margin: 3px 0 0 8px;
}
.tablenav .tablenav-pages {
float: left;
}
.tablenav .displaying-num {
margin-right: 0;
margin-left: 10px;
font-family: Tahoma, Arial, sans-serif;
font-style: normal;
}
.tablenav .actions {
padding: 2px 0 0 8px;
}
.tablenav .delete {
margin-right: 0;
margin-left: 20px;
}
.view-switch {
float: left;
}
.filter {
float: right;
margin: -5px 10px 0 0;
}
.filter .subsubsub {
margin-left: 0;
margin-right: -10px;
}
#posts-filter fieldset {
float: right;
margin: 0 0 1em 1.5ex;
}
#posts-filter fieldset legend {
padding: 0 1px .2em 0;
}
/*------------------------------------------------------------------------------
10.1 - Inline Editing
------------------------------------------------------------------------------*/
#wpbody-content .inline-edit-row fieldset {
float: right;
}
#wpbody-content .quick-edit-row-page fieldset.inline-edit-col-right .inline-edit-col {
border-width: 0 1px 0 0;
}
#wpbody-content .bulk-edit-row .inline-edit-col-bottom {
float: left;
}
.inline-edit-row fieldset label span.title {
float: right;
}
.inline-edit-row fieldset label span.input-text-wrap {
margin-left: 0;
margin-right: 5em;
}
.quick-edit-row-post fieldset.inline-edit-col-right label span.title {
padding-right: 0;
padding-left: 0.5em;
}
#wpbody-content .quick-edit-row fieldset .inline-edit-group label.alignleft:first-child {
margin-right: 0;
margin-left: 0.5em
}
/* Styling */
.inline-edit-row fieldset span.title,
.inline-edit-row fieldset span.checkbox-title {
font-family: Tahoma, Arial, sans-serif;
font-style: normal;
}
.inline-edit-row fieldset .inline-edit-date {
float: right;
}
.inline-edit-row fieldset ul.cat-checklist label,
.inline-edit-row .catshow,
.inline-edit-row .cathide,
.inline-edit-row #bulk-titles div {
font-family: Tahoma, Arial, sans-serif;
}
.quick-edit-row-post fieldset label.inline-edit-status {
float: right;
}
#bulk-titles div a {
float: right;
margin: 3px -2px 0 3px;
overflow: hidden;
text-indent: -9999px;
}
/*------------------------------------------------------------------------------
11.0 - Write/Edit Post Screen
------------------------------------------------------------------------------*/
/* structural/layout */
#post-body-content {
float: right;
}
#poststuff #post-body.columns-2 {
margin-left: 300px;
margin-right: 0;
}
#post-body.columns-2 #postbox-container-1 {
float: left;
margin-left: -300px;
margin-right: 0;
}
@media only screen and (max-width: 850px) {
#wpbody-content #post-body.columns-2 #postbox-container-1 {
margin-left: 0;
}
}
#titlediv #title-prompt-text,
#wp-fullscreen-title-prompt-text {
right:0;
}
#sample-permalink {
direction:ltr;
}
#sample-permalink #editable-post-name {
unicode-bidi:embed;
}
#wp-fullscreen-title-prompt-text {
left: auto;
right: 0;
}
.postarea h3 label {
float: right;
}
.submitbox .submit {
text-align: right;
}
.inside-submitbox #post_status {
margin: 2px -2px 2px 0;
}
.submitbox .submit input {
margin-right: 0;
margin-left: 4px;
}
#normal-sortables .postbox .submit {
float: left;
}
.taxonomy div.tabs-panel {
margin: 0 125px 0 5px;
}
#side-sortables .comments-box thead th,
#normal-sortables .comments-box thead th {
font-style: normal;
}
#commentsdiv img.waiting {
padding-left: 0;
padding-right: 5px;
}
#post-body .add-menu-item-tabs li.tabs {
border-width: 1px 1px 1px 0;
margin-right: 0;
margin-left: -1px;
}
/* Global classes */
#post-body .tagsdiv #newtag {
margin-right: 0;
margin-left: 5px;
}
.autosave-info {
padding: 2px 2px 2px 15px;
text-align: left;
}
#post-body .wp_themeSkin .mceStatusbar a.mceResize {
background: transparent url(../images/resize-rtl.gif) no-repeat scroll left bottom;
cursor: sw-resize;
}
.curtime #timestamp {
background-position: right top;
padding-left: 0;
padding-right: 18px;
}
/*------------------------------------------------------------------------------
11.1 - Custom Fields
------------------------------------------------------------------------------*/
#postcustomstuff table input,
#postcustomstuff table select,
#postcustomstuff table textarea {
margin: 8px 8px 8px 0;
}
/*------------------------------------------------------------------------------
11.2 - Post Revisions
------------------------------------------------------------------------------*/
table.diff td, table.diff th {
font-family: Consolas, Monaco, monospace;
}
/*------------------------------------------------------------------------------
12.0 - Categories
------------------------------------------------------------------------------*/
.category-adder {
margin-left: 0;
margin-right: 120px;
}
#post-body ul.add-menu-item-tabs {
float: right;
text-align: left;
/* Negative margin for the sake of those without JS: all tabs display */
margin: 0 5px 0 -120px;
}
#post-body ul.add-menu-item-tabs li.tabs {
-webkit-border-top-left-radius: 0;
-webkit-border-top-right-radius: 3px;
-webkit-border-bottom-left-radius: 0;
-webkit-border-bottom-right-radius: 3px;
border-top-left-radius: 0;
border-top-right-radius: 3px;
border-bottom-left-radius: 0;
border-bottom-right-radius: 3px;
}
#front-page-warning,
#front-static-pages ul,
ul.export-filters,
.inline-editor ul.cat-checklist ul,
.categorydiv ul.categorychecklist ul,
.customlinkdiv ul.categorychecklist ul,
.posttypediv ul.categorychecklist ul,
.taxonomydiv ul.categorychecklist ul {
margin-left: 0;
margin-right: 18px;
}
#post-body .add-menu-item-tabs li.tabs {
border-style: solid solid solid none;
border-width: 1px 1px 1px 0;
margin-right: 0;
margin-left: -1px;
}
p.help,
p.description,
span.description,
.form-wrap p {
font-style: normal;
font-family: Tahoma, Arial, sans-serif;
}
/*------------------------------------------------------------------------------
13.0 - Tags
------------------------------------------------------------------------------*/
.taghint {
margin: 15px 12px -24px 0;
}
#poststuff .tagsdiv .howto {
margin: 0 8px 6px 0;
}
.ac_results li {
text-align: right;
}
.links-table th {
text-align: right;
}
/*------------------------------------------------------------------------------
14.0 - Media Screen
------------------------------------------------------------------------------*/
#wpbody-content .describe th {
text-align: right;
}
.describe .media-item-info .A1B1 {
padding: 0 10px 0 0;
}
.media-upload-form td label {
margin-left: 6px;
margin-right: 2px;
}
.media-upload-form .align .field label {
padding: 0 23px 0 0;
margin: 0 3px 0 1em;
}
.media-upload-form tr.image-size label {
margin: 0 5px 0 0;
}
#wpbody-content .describe p.help {
padding: 0 5px 0 0;
}
.media-item .error-div a.dismiss,
.describe-toggle-on,
.describe-toggle-off {
float: left;
margin-right: 0;
margin-left: 15px;
}
.media-item .error-div a.dismiss {
padding: 0 15px 0 0;
}
.media-item .error-div {
padding-left: 0;
padding-right: 10px;
}
.media-item .pinkynail {
float: right;
}
.media-item .describe td {
padding: 0 0 8px 8px;
}
.media-item .progress {
float: left;
margin: 6px 0 0 10px;
}
/*------------------------------------------------------------------------------
14.1 - Media Uploader
------------------------------------------------------------------------------*/
#find-posts-response .found-radio {
padding: 5px 8px 0 0;
}
.find-box-search label {
padding-right: 0;
padding-left: 6px;
}
.find-box #resize-se {
right: auto;
left: 1px;
}
form.upgrade .hint {
font-style: normal;
}
/*------------------------------------------------------------------------------
14.2 - Image Editor
------------------------------------------------------------------------------*/
.imgedit-menu div {
float: right;
}
.imgedit-help {
font-style: normal;
}
.imgedit-submit-btn {
margin-left: 0;
margin-right: 20px;
}
/*------------------------------------------------------------------------------
15.0 - Comments Screen
------------------------------------------------------------------------------*/
.form-table th {
text-align: right;
}
.form-table input.tog {
margin-right: 0;
margin-left: 2px;
float: right;
}
.form-table table.color-palette {
float: right;
}
/* reply to comments */
#replysubmit img.waiting,
.inline-edit-save img.waiting {
float: left;
}
#replysubmit .button {
margin-right: 0;
margin-left: 5px;
}
#edithead .inside {
float: right;
padding: 3px 5px 2px 0;
}
.comment-ays th {
border-right-style: none;
border-left-style: solid;
border-right-width: 0;
border-left-width: 1px;
}
.spam-undo-inside .avatar,
.trash-undo-inside .avatar {
margin-left: 8px;
}
#comment-status-radio input {
margin: 2px 0 5px 3px;
}
/*------------------------------------------------------------------------------
16.0 - Themes
------------------------------------------------------------------------------*/
h3.available-themes {
float: right;
}
.available-theme {
margin-right: 0;
margin-left: 10px;
padding: 20px 0 20px 20px;
}
#current-theme .theme-info li,
.theme-options li,
.available-theme .action-links li {
float: right;
padding-right: 0;
padding-left: 10px;
margin-right: 0;
margin-left: 10px;
border-right: none;
border-left: 1px solid #dfdfdf;
}
.available-theme .action-links li {
padding-left: 8px;
margin-left: 8px;
}
#current-theme .theme-info li:last-child,
.theme-options li:last-child,
.available-theme .action-links li:last-child {
padding-left: 0;
margin-right: 0;
border-left: 0;
}
.available-theme .action-links .delete-theme {
float: left;
margin-left: 0;
margin-right: 8px;
}
.available-theme .action-links p {
float: right;
}
#current-theme.has-screenshot {
padding-left: 0;
padding-right: 330px;
}
#current-theme h4 span {
margin-left: 0;
margin-right: 20px;
}
#current-theme img {
float: right;
width: 300px;
margin-left: 0;
margin-right: -330px;
}
.theme-options .load-customize {
margin-right: 0;
margin-left: 30px;
float: right;
}
.theme-options span {
float: right;
margin-right: 0;
margin-left: 10px;
}
.theme-options ul {
float: right;
}
/* Allow for three-up on 1024px wide screens, e.g. tablets */
@media only screen and (max-width: 1200px) {
#current-theme.has-screenshot {
padding-right: 270px;
}
#current-theme img {
margin-right: -270px;
width: 240px;
}
}
#broken-themes {
text-align: right;
}
/*------------------------------------------------------------------------------
16.1 - Custom Header Screen
------------------------------------------------------------------------------*/
.appearance_page_custom-header .available-headers .default-header {
float: right;
margin: 0 0 20px 20px;
}
.appearance_page_custom-header .random-header {
margin: 0 0 20px 20px;
}
.appearance_page_custom-header .available-headers label input,
.appearance_page_custom-header .random-header label input {
margin-right: 0;
margin-left: 10px;
}
/*------------------------------------------------------------------------------
16.2 - Custom Background Screen
------------------------------------------------------------------------------*/
/* No RTL for now, this space intentionally left blank */
/*------------------------------------------------------------------------------
16.3 - Tabbed Admin Screen Interface (Experimental)
------------------------------------------------------------------------------*/
.nav-tab {
margin: 0 0 -1px 6px;
}
h2 .nav-tab {
font-family: Tahoma, Arial, sans-serif;
}
/*------------------------------------------------------------------------------
17.0 - Plugins
------------------------------------------------------------------------------*/
.plugins .desc ul,
.plugins .desc ol {
margin: 0 2em 0 0;
}
#wpbody-content .plugins .plugin-title, #wpbody-content .plugins .theme-title {
padding-right: 0;
padding-left: 12px;
}
/*------------------------------------------------------------------------------
18.0 - Users
------------------------------------------------------------------------------*/
#profile-page .form-table #rich_editing {
margin-right: 0;
margin-left: 5px
}
#profile-page #pass1,
#profile-page #pass2,
#profile-page #user_login {
direction: ltr;
}
#your-profile legend {
font-family: Tahoma, Arial, sans-serif;
}
/*------------------------------------------------------------------------------
19.0 - Tools
------------------------------------------------------------------------------*/
.pressthis a span {
background-position: right 5px;
padding: 8px 27px 8px 11px;
}
.pressthis a:after {
right: auto;
left: 10px;
background: transparent;
transform: skew(-20deg) rotate(-6deg);
-webkit-transform: skew(-20deg) rotate(-6deg);
-moz-transform: skew(-20deg) rotate(-6deg);
}
.pressthis a:hover:after {
transform: skew(-20deg) rotate(-9deg);
-webkit-transform: skew(-20deg) rotate(-9deg);
-moz-transform: skew(-20deg) rotate(-9deg);
}
/*------------------------------------------------------------------------------
20.0 - Settings
------------------------------------------------------------------------------*/
#utc-time, #local-time {
padding-left: 0;
padding-right: 25px;
font-style: normal;
font-family: Tahoma, Arial, sans-serif;
}
/*------------------------------------------------------------------------------
21.0 - Admin Footer
------------------------------------------------------------------------------*/
#footer {
margin-left: 20px;
}
#wpcontent,
#footer {
margin-right: 165px;
}
/*------------------------------------------------------------------------------
22.0 - About Pages
------------------------------------------------------------------------------*/
.wrap.about-wrap {
margin-left: 40px;
margin-right: 20px;
}
.about-wrap h1,
.about-text {
margin-right: 0;
margin-left: 200px;
}
.about-wrap h2.nav-tab-wrapper {
padding-left: 0px;
padding-right: 6px;
}
.about-wrap .wp-badge {
right: auto;
left: 0;
}
.about-wrap h2 .nav-tab {
margin-right: 0;
margin-left: 3px;
}
.about-wrap .changelog li {
margin-left: 0;
margin-right: 3em;
}
.about-wrap .three-col-images .last-feature {
float: left;
}
.about-wrap .three-col-images .first-feature {
float: right;
}
.about-wrap .feature-section.three-col div {
margin-right: 0;
margin-left: 4.999999999%;
float: right;
}
.about-wrap .feature-section.three-col h4 {
text-align: right;
}
.about-wrap .feature-section.three-col img {
margin-right: 5px;
margin-left: 0;
}
.about-wrap .feature-section.three-col .last-feature {
margin-left: 0;
}
.about-wrap .feature-section img {
margin: 0 0 10px 0.7%;
}
.about-wrap .feature-section.images-stagger-right img {
float: left;
margin: 0 12px 12px 5px;
}
.about-wrap .feature-section.images-stagger-left img {
float: right;
margin: 0 5px 12px 12px;
}
.about-wrap li.wp-person,
.about-wrap li.wp-person img.gravatar {
float: right;
margin-right: 0;
margin-left: 10px;
}
/*------------------------------------------------------------------------------
23.0 - Misc
------------------------------------------------------------------------------*/
#template div {
margin-right: 0;
margin-left: 190px;
}
.column-author img, .column-username img {
float: right;
margin-right: 0;
margin-left: 10px;
}
.tagchecklist {
margin-left: 0;
margin-right: 14px;
}
.tagchecklist strong {
margin-left: 0;
margin-right: -8px;
}
.tagchecklist span {
margin-right: 0;
margin-left: 25px;
float: right;
}
.tagchecklist span a {
margin: 6px -9px 0pt 0pt;
float: right;
}
#poststuff h2 {
clear: right;
}
#poststuff h3,
.metabox-holder h3 {
font-family: Tahoma, Arial, sans-serif;
}
.tool-box .title {
font-family: Tahoma, Arial, sans-serif;
}
#sidemenu {
margin: -30px 315px 0 15px;
float: left;
padding-left: 0;
padding-right: 10px;
}
#sidemenu a {
float: right;
}
table .vers,
table .column-visible,
table .column-rating {
text-align: right;
}
.screen-meta-toggle {
right: auto;
left: 15px;
}
/*------------------------------------------------------------------------------
24.0 - Dead
------------------------------------------------------------------------------*/
/* - Not used anywhere in WordPress - verify and then deprecate
------------------------------------------------------------------------------*/
/* No RTL for now, this space intentionally left blank */
/* - Only used once or twice in all of WP - deprecate for global style
------------------------------------------------------------------------------*/
* html #template div {margin-left: 0;}
.list-ajax-loading {
float: left;
margin-right: 0;
margin-left: 9px;
}
/* - Used - but could/should be deprecated with a CSS reset
------------------------------------------------------------------------------*/
/* No RTL for now, this space intentionally left blank */
/*------------------------------------------------------------------------------
25.0 - TinyMCE tweaks
Small tweaks for until tinymce css files are proprely RTLized
------------------------------------------------------------------------------*/
#editorcontainer .wp_themeSkin .mceStatusbar {
padding-left: 0;
padding-right: 5px;
}
#editorcontainer .wp_themeSkin .mceStatusbar div {
float: right;
}
#editorcontainer .wp_themeSkin .mceStatusbar a.mceResize {
float: left;
}
/*------------------------------------------------------------------------------
26.0 - Full Overlay w/ Sidebar
------------------------------------------------------------------------------*/
.wp-full-overlay .wp-full-overlay-sidebar {
margin: 0;
left: auto;
right: 0;
border-right: 0;
border-left: 1px solid rgba( 0, 0, 0, 0.2 );
}
.wp-full-overlay-sidebar:after {
right: auto;
left: 0;
box-shadow: inset 5px 0 4px -4px rgba(0, 0, 0, 0.1);
}
.wp-full-overlay.collapsed,
.wp-full-overlay.expanded .wp-full-overlay-sidebar {
margin-right: 0 !important;
}
.wp-full-overlay.expanded {
margin-right: 300px;
margin-left: 0;
}
.wp-full-overlay.collapsed .wp-full-overlay-sidebar {
margin-right: -300px;
margin-left: 0;
}
/* Collapse Button */
.wp-full-overlay .collapse-sidebar {
right: 0;
left: auto;
margin-right: 15px;
}
.wp-full-overlay.collapsed .collapse-sidebar {
right: 100%;
}
.wp-full-overlay .collapse-sidebar-arrow {
margin-right: 2px;
margin-left: 0;
background: transparent url('../../wp-admin/images/arrows.png') no-repeat 0 -108px;
}
.wp-full-overlay.collapsed .collapse-sidebar-arrow {
background-position: 0 -72px;
}
.wp-full-overlay .collapse-sidebar-label {
right: 100%;
left: auto;
margin-right: 10px;
margin-left: 0;
}
/*------------------------------------------------------------------------------
27.0 - Customize Loader
------------------------------------------------------------------------------*/
.install-theme-info .theme-install {
float: left;
}
/* MERGED */
/* global */
/* 2 column liquid layout */
#wpcontent {
margin-left: 0;
margin-right: 165px;
}
.folded #wpcontent {
margin-left: 0;
margin-right: 52px;
}
.folded.wp-admin #footer {
margin-left: 15px;
margin-right: 52px;
}
#wpbody-content {
float: right;
}
#adminmenuwrap {
float: right;
}
#adminmenu {
clear: right;
}
/* inner 2 column liquid layout */
.inner-sidebar {
float: left;
clear: left;
}
.has-right-sidebar #post-body {
float: right;
clear: right;
margin-right: 0;
margin-left: -340px;
}
.has-right-sidebar #post-body-content {
margin-right: 0;
margin-left: 300px;
}
/* 2 columns main area */
#col-right {
float: left;
clear: left;
}
/* utility classes*/
.alignleft {
float: right;
}
.alignright {
float: left;
}
.textleft {
text-align: right;
}
.textright {
text-align: left;
}
/* Hide visually but not from screen readers */
.screen-reader-text, .screen-reader-text span {
left: auto;
right: -1000em;
}
/* styles for use by people extending the WordPress interface */
body,
td,
textarea,
input,
select {
font-family: Tahoma, Arial, sans-serif;
}
ul.ul-disc,
ul.ul-square,
ol.ol-decimal {
margin-left: 0;
margin-right: 1.8em;
}
.subsubsub {
float: right;
}
.widefat thead th:first-of-type {
-webkit-border-top-left-radius: 0;
-webkit-border-top-right-radius: 3px;
border-top-left-radius: 0;
border-top-right-radius: 3px;
}
.widefat thead th:last-of-type {
-webkit-border-top-right-radius: 0;
-webkit-border-top-left-radius: 3px;
border-top-right-radius: 0;
border-top-left-radius: 3px;
}
.widefat tfoot th:first-of-type {
-webkit-border-bottom-left-radius: 0;
-webkit-border-bottom-right-radius: 3px;
border-bottom-left-radius: 0;
border-bottom-right-radius: 3px;
}
.widefat tfoot th:last-of-type {
-webkit-border-bottom-right-radius: 0;
-webkit-border-bottom-left-radius: 3px;
border-bottom-right-radius: 0;
border-bottom-left-radius: 3px;
}
.widefat th {
text-align: right;
}
.widefat th input {
margin: 0 8px 0 0;
}
.wrap {
margin-right: 0;
margin-left: 15px;
}
.wrap h2,
.subtitle {
font-family: Tahoma, Arial, sans-serif;
}
.wrap h2 {
padding-right: 0;
padding-left: 15px;
}
.subtitle {
padding-left: 0;
padding-right: 25px;
}
.wrap .add-new-h2 {
font-family: Tahoma, Arial, sans-serif;
margin-left: 0;
margin-right: 4px;
}
.wrap h2.long-header {
padding-left: 0;
}
/* dashboard */
#dashboard-widgets-wrap .has-sidebar {
margin-right: 0;
margin-left: -51%;
}
#dashboard-widgets-wrap .has-sidebar .has-sidebar-content {
margin-right: 0;
margin-left: 51%;
}
.view-all {
right: auto;
left: 0;
}
#dashboard_right_now p.sub,
#dashboard-widgets h4,
a.rsswidget,
#dashboard_plugins h4,
#dashboard_plugins h5,
#dashboard_recent_comments .comment-meta .approve,
#dashboard_right_now td.b,
#dashboard_right_now .versions a {
font-family: Tahoma, Arial, sans-serif;
}
#dashboard_right_now p.sub {
left:auto;
right:15px;
}
#dashboard_right_now td.b {
padding-right: 0;
padding-left: 6px;
text-align: left;
}
#dashboard_right_now .t {
padding-right: 0;
padding-left: 12px;
}
#dashboard_right_now .table_content {
float:right;
}
#dashboard_right_now .table_discussion {
float:left;
}
#dashboard_right_now a.button {
float: left;
clear: left;
}
#dashboard_plugins .inside span {
padding-left: 0;
padding-right: 5px;
}
#dashboard-widgets h3 .postbox-title-action {
right: auto;
left: 30px;
}
#the-comment-list .pingback {
padding-left: 0 !important;
padding-right: 9px !important;
}
/* Recent Comments */
#the-comment-list .comment-item {
padding: 1em 70px 1em 10px;
}
#the-comment-list .comment-item .avatar {
float: right;
margin-left: 0;
margin-right: -60px;
}
/* Feeds */
.rss-widget cite {
text-align: left;
}
.rss-widget span.rss-date {
font-family: Tahoma, Arial, sans-serif;
margin-left: 0;
margin-right: 3px;
}
/* QuickPress */
#dashboard_quick_press h4 {
float: right;
text-align: left;
}
#dashboard_quick_press .wp-media-buttons {
margin: 0 5em 0.5em 0;
}
#dashboard_quick_press h4 label {
margin-right: 0;
margin-left: 10px;
}
#dashboard_quick_press .input-text-wrap,
#dashboard_quick_press .textarea-wrap {
margin: 0 5em 1em 0;
}
#dashboard_quick_press #media-buttons {
margin: 0 5em .5em 0;
padding: 0;
}
#dashboard-widgets #dashboard_quick_press form p.submit {
margin-left: 0;
margin-right: 4.6em;
}
#dashboard-widgets #dashboard_quick_press form p.submit input {
float: right;
}
#dashboard-widgets #dashboard_quick_press form p.submit #save-post {
margin: 0 10px 0 1em;
}
#dashboard-widgets #dashboard_quick_press form p.submit #publish {
float: left;
}
#dashboard-widgets #dashboard_quick_press form p.submit img.waiting {
margin: 4px 0 0 6px;
}
/* Recent Drafts */
#dashboard_recent_drafts h4 abbr {
font-family: Tahoma, Arial, sans-serif;
margin-left:0;
margin-right: 3px;
}
/* login */
body.login {
font-family: Tahoma, Arial, sans-serif;
}
.login form {
margin-right: 8px;
margin-left: 0;
}
.login form .forgetmenot {
float: right;
}
.login form .submit {
float: left;
}
#login form .submit input {
font-family: Tahoma, Arial, sans-serif;
}
.login #nav,
.login #backtoblog {
margin: 0 16px 0 0;
}
#login_error,
.login .message {
margin: 0 8px 16px 0;
}
.login #user_pass,
.login #user_login,
.login #user_email {
margin-left: 6px;
margin-right: 0;
direction: ltr;
}
.login h1 a {
text-decoration: none;
}
.login .button-primary {
float: left;
}
/* nav-menu */
#nav-menus-frame {
margin-right: 300px;
margin-left: 0;
}
#wpbody-content #menu-settings-column {
margin-right: -300px;
margin-left: 0;
float: right;
}
/* Menu Container */
#menu-management-liquid {
float: right;
}
#menu-management {
margin-left: 20px;
margin-right: 0;
}
.post-body-plain {
padding: 10px 0 0 10px;
}
/* Menu Tabs */
#menu-management .nav-tabs-arrow-left {
right: 0;
left:auto;
}
#menu-management .nav-tabs-arrow-right {
left: 0;
right:auto;
text-align: left;
font-family: Tahoma, Arial, sans-serif;
}
#menu-management .nav-tabs {
padding-right: 20px;
padding-left: 10px;
}
.js #menu-management .nav-tabs {
float: right;
margin-right: 0px;
margin-left: -400px;
}
#select-nav-menu-container {
text-align: left;
}
#wpbody .open-label {
float:right;
}
#wpbody .open-label span {
padding-left: 10px;
padding-right:0;
}
.js .input-with-default-title {
font-style: normal;
font-weight: bold;
}
/* Add Menu Item Boxes */
.postbox .howto input {
float: left;
}
#nav-menu-theme-locations .button-controls {
text-align: left;
}
/* Button Primary Actions */
.meta-sep,
.submitcancel {
float: right;
}
#cancel-save {
margin-left: 0;
margin-right: 20px;
}
/* Button Secondary Actions */
.list-controls {
float: right;
}
.add-to-menu {
float: left;
}
/* Custom Links */
#add-custom-link label span {
float: right;
padding-left: 5px;
padding-right: 0;
}
.nav-menus-php .howto span {
float: right;
}
.list li .menu-item-title input {
margin-left: 3px;
margin-right: 0;
}
/* Nav Menu */
.menu-item-handle {
padding-right: 10px;
padding-left: 0;
}
.menu-item-edit-active .menu-item-handle {
-webkit-border-bottom-left-radius: 0;
-webkit-border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}
.menu-item-handle .item-title {
margin-left:13em;
margin-right:0;
}
.menu-item-handle .item-edit {
right: auto;
left: -20px;
}
/* WARNING: The factor of 30px is hardcoded into the nav-menus javascript. */
.menu-item-depth-0 { margin-right: 0px; margin-left:0;}
.menu-item-depth-1 { margin-right: 30px; margin-left:0;}
.menu-item-depth-2 { margin-right: 60px; margin-left:0;}
.menu-item-depth-3 { margin-right: 90px; margin-left:0;}
.menu-item-depth-4 { margin-right: 120px; margin-left:0;}
.menu-item-depth-5 { margin-right: 150px; margin-left:0;}
.menu-item-depth-6 { margin-right: 180px; margin-left:0;}
.menu-item-depth-7 { margin-right: 210px; margin-left:0;}
.menu-item-depth-8 { margin-right: 240px; margin-left:0;}
.menu-item-depth-9 { margin-right: 270px; margin-left:0;}
.menu-item-depth-10 { margin-right: 300px; margin-left:0;}
.menu-item-depth-11 { margin-right: 330px; margin-left:0;}
.menu-item-depth-0 .menu-item-transport { margin-right: 0px; margin-left:0;}
.menu-item-depth-1 .menu-item-transport { margin-right: -30px; margin-left:0;}
.menu-item-depth-2 .menu-item-transport { margin-right: -60px; margin-left:0;}
.menu-item-depth-3 .menu-item-transport { margin-right: -90px; margin-left:0;}
.menu-item-depth-4 .menu-item-transport { margin-right: -120px; margin-left:0;}
.menu-item-depth-5 .menu-item-transport { margin-right: -150px; margin-left:0;}
.menu-item-depth-6 .menu-item-transport { margin-right: -180px; margin-left:0;}
.menu-item-depth-7 .menu-item-transport { margin-right: -210px; margin-left:0;}
.menu-item-depth-8 .menu-item-transport { margin-right: -240px; margin-left:0;}
.menu-item-depth-9 .menu-item-transport { margin-right: -270px; margin-left:0;}
.menu-item-depth-10 .menu-item-transport { margin-right: -300px; margin-left:0;}
.menu-item-depth-11 .menu-item-transport { margin-right: -330px; margin-left:0;}
/* Menu item controls */
.item-type {
padding-left: 10px;
padding-right:0;
}
.item-controls {
left: 20px;
right: auto;
}
.item-controls .item-order {
padding-left: 10px;
padding-right: 0;
}
.item-edit {
left: -20px;
right:auto;
-webkit-border-bottom-right-radius: 3px;
-webkit-border-bottom-left-radius: 0;
border-bottom-right-radius: 3px;
border-bottom-left-radius: 0;
}
/* Menu editing */
.menu-item-settings {
padding: 10px 10px 10px 0;
border-width: 0 1px 1px 1px;
}
#custom-menu-item-url {
direction: ltr;
}
.link-to-original {
font-style: normal;
font-weight: bold;
}
.link-to-original a {
padding-right: 4px;
padding-left:0;
}
.menu-item-settings .description-thin,
.menu-item-settings .description-wide {
margin-left: 10px;
margin-right:0;
float: right;
}
/* Major/minor publishing actions (classes) */
.major-publishing-actions .publishing-action {
text-align: left;
float: left;
}
.major-publishing-actions .delete-action {
text-align: right;
float: right;
padding-left: 15px;
padding-right:0;
}
.menu-name-label {
margin-left: 15px;
margin-right:0;
}
.auto-add-pages {
float: right;
}
/* Star ratings */
div.star-holder {
background: url('../images/stars-rtl.png?ver=20120506.png') repeat-x bottom right;
}
div.star-holder .star-rating {
background: url('../images/stars-rtl.png?ver=20120506.png') repeat-x top right;
float: right;
}
#plugin-information ul#sidemenu {
left: auto;
right: 0;
}
#plugin-information h2 {
margin-right: 0;
margin-left: 200px;
}
#plugin-information .fyi {
margin-left: 5px;
margin-right: 20px;
}
#plugin-information .fyi h2 {
margin-left: 0;
}
#plugin-information .fyi ul {
padding: 10px 7px 10px 5px;
}
#plugin-information #section-screenshots li p {
padding-left: 0;
padding-right: 20px;
}
#plugin-information #section-screenshots ol,
#plugin-information .updated,
#plugin-information pre {
margin-right: 0;
margin-left: 215px;
}
#plugin-information .updated,
#plugin-information .error {
clear: none;
direction: rtl;
}
#plugin-information #section-holder .section {
direction: ltr;
}
/* Editor/Main Column */
.posting {
margin-left: 212px;
margin-right: 0;
position: relative;
}
h3.tb {
margin-left: 0;
margin-right: 5px;
}
#publish {
float: left;
}
.postbox .handlediv {
float: left;
}
.actions li {
float: right;
margin-right: 0;
margin-left: 10px;
}
#extra-fields .actions {
margin: -23px 0 0 -7px;
}
/* Photo Styles */
#img_container a {
float: right;
}
#category-add input,
#category-add select {
font-family: Tahoma, Arial, sans-serif;
}
/* Tags */
#tagsdiv #newtag {
margin-right: 0;
margin-left: 5px;
}
#tagadd {
margin-left: 0;
margin-right: 3px;
}
#tagchecklist span {
margin-left: .5em;
margin-right: 10px;
float: right;
}
#tagchecklist span a {
margin: 6px -9px 0 0;
float: right;
}
.submit input,
.button,
.button-primary,
.button-secondary,
.button-highlighted,
#postcustomstuff .submit input {
font-family: Tahoma, Arial, sans-serif;
}
.ac_results li {
text-align: right;
}
#TB_ajaxContent #options {
right: auto;
left: 25px;
}
#post_status {
margin-left: 0;
margin-right: 10px;
}
/* theme-editor, plugin-editor */
#templateside {
float: left;
}
#template textarea,
#docs-list {
direction: ltr;
}
/* theme-install */
.theme-details .theme-version {
float: right;
}
.theme-details .star-holder {
float: left;
}
.feature-filter .feature-group {
float: right;
}
.feature-filter .feature-name {
float: right;
text-align: left;
}
.feature-filter .feature-group li {
float: right;
padding-right: 0;
padding-left: 25px;
}
/* widgets */
/* 2 column liquid layout */
div.widget-liquid-left {
float: right;
clear: right;
margin-right: 0;
margin-left: -325px;
}
div#widgets-left {
margin-right: 5px;
margin-left: 325px;
}
div.widget-liquid-right {
float: left;
clear: left;
}
.inactive-sidebar .widget {
float: right;
}
div.sidebar-name h3 {
font-family: Tahoma, Arial, sans-serif;
}
#widget-list .widget {
float: right;
}
.inactive-sidebar .widget-placeholder {
float: right;
}
.widget-top .widget-title-action {
float: left;
}
.widget-control-edit {
padding: 0 0 0 8px;
}
.sidebar-name-arrow {
float: left;
}
/* Press This */
.press-this-sidebar {
float: left;
}
.press-this #header-logo,
.press-this #wphead h1 {
float: right;
}
/* RTL */
.ltr {
direction: ltr;
}
/* =Localized CSS
-------------------------------------------------------------- */
/* he_IL: Remove Tahoma from the font stack. Arial is best for Hebrew. */
body.locale-he-il,
.locale-he-il .quicktags, .locale-he-il .search,
.locale-he-il .howto,
.locale-he-il #adminmenu .awaiting-mod,
.locale-he-il #adminmenu span.update-plugins,
.locale-he-il #sidemenu li a span.update-plugins,
.locale-he-il .post-com-count-wrapper,
.locale-he-il .widefat th,
.locale-he-il .tablenav .displaying-num,
.locale-he-il .inline-edit-row fieldset span.title,
.locale-he-il .inline-edit-row fieldset span.checkbox-title,
.locale-he-il .inline-edit-row fieldset ul.cat-checklist label,
.locale-he-il .inline-edit-row .catshow,
.locale-he-il .inline-edit-row .cathide,
.locale-he-il .inline-edit-row #bulk-titles div,
.locale-he-il p.help,
.locale-he-il p.description,
.locale-he-il span.description,
.locale-he-il .form-wrap p,
.locale-he-il h2 .nav-tab,
.locale-he-il #your-profile legend,
.locale-he-il #utc-time, .locale-he-il #local-time,
.locale-he-il #poststuff h3,
.locale-he-il .metabox-holder h3,
.locale-he-il .tool-box .title,
.locale-he-il td,
.locale-he-il textarea,
.locale-he-il input,
.locale-he-il select,
.locale-he-il .wrap h2,
.locale-he-il .subtitle,
.locale-he-il .wrap .add-new-h2,
.locale-he-il #dashboard_right_now p.sub,
.locale-he-il #dashboard-widgets h4,
.locale-he-il a.rsswidget,
.locale-he-il #dashboard_plugins h4,
.locale-he-il #dashboard_plugins h5,
.locale-he-il #dashboard_recent_comments .comment-meta .approve,
.locale-he-il #dashboard_right_now td.b,
.locale-he-il #dashboard_right_now .versions a,
.locale-he-il .rss-widget span.rss-date,
.locale-he-il #dashboard_recent_drafts h4 abbr,
body.login.locale-he-il,
.locale-he-il #login form .submit input,
.locale-he-il #menu-management .nav-tabs-arrow-right,
.locale-he-il #category-add input,
.locale-he-il #category-add select,
.locale-he-il .submit input,
.locale-he-il .button,
.locale-he-il .button-primary,
.locale-he-il .button-secondary,
.locale-he-il .button-highlighted,
.locale-he-il #postcustomstuff .submit input,
.locale-he-il div.sidebar-name h3 {
font-family: Arial, sans-serif;
}
/* he_IL: Have <em> be bold rather than italic. */
.locale-he-il em {
font-style: normal;
font-weight: bold;
}
| 01happy-blog | trunk/myblog/wp-admin/css/wp-admin-rtl.dev.css | CSS | oos | 47,430 |
/*------------------------------------------------------------------------------
Howdy! This is the CSS file that controls the
Gray (fresh) color style on the WordPress Dashboard.
This file contains both LTR and RTL styles.
TABLE OF CONTENTS:
------------------
1.0 - Left to Right Styles
2.0 - Right to Left Styles
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
1.0 - Left to Right Styles
------------------------------------------------------------------------------*/
html,
.wp-dialog {
background-color: #fff;
}
textarea,
input[type="text"],
input[type="password"],
input[type="file"],
input[type="button"],
input[type="submit"],
input[type="reset"],
input[type="email"],
input[type="number"],
input[type="search"],
input[type="tel"],
input[type="url"],
select {
border-color: #dfdfdf;
background-color: #fff;
color: #333;
}
select {
color: #000;
}
textarea:focus,
input[type="text"]:focus,
input[type="password"]:focus,
input[type="file"]:focus,
input[type="button"]:focus,
input[type="submit"]:focus,
input[type="reset"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
input[type="search"]:focus,
input[type="tel"]:focus,
input[type="url"]:focus,
select:focus {
border-color: #bbb;
}
kbd,
code {
background: #eaeaea;
}
input[readonly] {
background-color: #eee;
}
.find-box-search {
border-color: #dfdfdf;
background-color: #f1f1f1;
}
.find-box {
background-color: #f1f1f1;
}
.find-box-inside {
background-color: #fff;
}
a.page-numbers:hover {
border-color: #999;
}
body,
#wpbody,
.form-table .pre,
.ui-autocomplete li a {
color: #333;
}
body > #upload-menu {
border-bottom-color: #fff;
}
#postcustomstuff table,
#your-profile fieldset,
#rightnow,
div.dashboard-widget,
#dashboard-widgets p.dashboard-widget-links {
border-color: #ccc;
}
#poststuff .inside label.spam,
#poststuff .inside label.deleted {
color: red;
}
#poststuff .inside label.waiting {
color: orange;
}
#poststuff .inside label.approved {
color: green;
}
#postcustomstuff table {
border-color: #dfdfdf;
background-color: #F9F9F9;
}
#postcustomstuff thead th {
background-color: #F1F1F1;
}
.widefat {
border-color: #dfdfdf;
background-color: #f9f9f9;
}
textarea.widefat {
background-color: #fff;
}
div.dashboard-widget-error {
background-color: #c43;
}
div.dashboard-widget-notice {
background-color: #cfe1ef;
}
div.dashboard-widget-submit {
border-top-color: #ccc;
}
ul.category-tabs li {
border-color: transparent;
}
div.tabs-panel,
.wp-tab-panel,
ul.category-tabs li.tabs,
ul.add-menu-item-tabs li.tabs,
.wp-tab-active {
border-color: #dfdfdf;
background-color: #fff;
}
ul.category-tabs li.tabs,
ul.add-menu-item-tabs li.tabs,
.wp-tab-active {
background-color: #fff;
}
input.disabled,
textarea.disabled {
background-color: #ccc;
}
/* #upload-menu li a.upload-tab-link, */
#plugin-information .action-button a,
#plugin-information .action-button a:hover,
#plugin-information .action-button a:visited {
color: #fff;
}
.widget .widget-top,
.postbox h3,
.stuffbox h3,
.widefat thead tr th,
.widefat tfoot tr th,
h3.dashboard-widget-title,
h3.dashboard-widget-title span,
h3.dashboard-widget-title small,
.find-box-head,
.sidebar-name,
#nav-menu-header,
#nav-menu-footer,
.menu-item-handle {
background-color: #f1f1f1; /* Fallback */
background-image: -ms-linear-gradient(top, #f9f9f9, #ececec); /* IE10 */
background-image: -moz-linear-gradient(top, #f9f9f9, #ececec); /* Firefox */
background-image: -o-linear-gradient(top, #f9f9f9, #ececec); /* Opera */
background-image: -webkit-gradient(linear, left top, left bottom, from(#f9f9f9), to(#ececec)); /* old Webkit */
background-image: -webkit-linear-gradient(top, #f9f9f9, #ececec); /* new Webkit */
background-image: linear-gradient(top, #f9f9f9, #ececec); /* proposed W3C Markup */
}
.widget .widget-top,
.postbox h3,
.stuffbox h3 {
border-bottom-color: #dfdfdf;
text-shadow: #fff 0 1px 0;
-moz-box-shadow: 0 1px 0 #fff;
-webkit-box-shadow: 0 1px 0 #fff;
box-shadow: 0 1px 0 #fff;
}
.form-table th,
.form-wrap label {
color: #222;
text-shadow: #fff 0 1px 0;
}
.description,
.form-wrap p {
color: #666;
}
strong .post-com-count span {
background-color: #21759b;
}
.sorthelper {
background-color: #ccf3fa;
}
.ac_match,
.subsubsub a.current {
color: #000;
}
.wrap h2 {
color: #464646;
}
.wrap .add-new-h2 {
background: #f1f1f1;
}
.subtitle {
color: #777;
}
.ac_over {
background-color: #f0f0b8;
}
.ac_results {
background-color: #fff;
border-color: #808080;
}
.ac_results li {
color: #101010;
}
.alternate,
.alt {
background-color: #fcfcfc;
}
.available-theme a.screenshot {
background-color: #f1f1f1;
border-color: #ddd;
}
.bar {
background-color: #e8e8e8;
border-right-color: #99d;
}
#media-upload,
#media-upload .media-item .slidetoggle {
background: #fff;
}
#media-upload .slidetoggle {
border-top-color: #dfdfdf;
}
div.error,
.login #login_error {
background-color: #ffebe8;
border-color: #c00;
}
div.error a {
color: #c00;
}
.form-invalid {
background-color: #ffebe8 !important;
}
.form-invalid input,
.form-invalid select {
border-color: #c00 !important;
}
.submit,
#commentsdiv #add-new-comment {
border-color: #dfdfdf;
}
.highlight {
background-color: #e4f2fd;
color: #000;
}
.howto,
.nonessential,
#edit-slug-box,
.form-input-tip,
.subsubsub {
color: #666;
}
.media-upload-form label.form-help,
td.help {
color: #9a9a9a;
}
.ui-autocomplete {
background-color: #efefef;
border-color: #bbb;
}
.ui-autocomplete li a.ui-state-hover {
background-color: #ddd;
}
.post-com-count {
background-image: url(../images/bubble_bg.gif);
color: #fff;
}
.post-com-count span {
background-color: #bbb;
color: #fff;
}
.post-com-count:hover span {
background-color: #d54e21;
}
.quicktags, .search {
background-color: #ccc;
color: #000;
}
.side-info h5 {
border-bottom-color: #dadada;
}
.side-info ul {
color: #666;
}
.button,
.button-secondary,
.submit input,
input[type=button],
input[type=submit] {
border-color: #bbb;
color: #464646;
}
.button:hover,
.button-secondary:hover,
.submit input:hover,
input[type=button]:hover,
input[type=submit]:hover {
color: #000;
border-color: #666;
}
.button,
.submit input,
.button-secondary {
background: #f2f2f2 url(../images/white-grad.png) repeat-x scroll left top;
text-shadow: rgba(255,255,255,1) 0 1px 0;
}
.button:active,
.submit input:active,
.button-secondary:active {
background: #eee url(../images/white-grad-active.png) repeat-x scroll left top;
}
input.button-primary,
button.button-primary,
a.button-primary {
border-color: #298cba;
font-weight: bold;
color: #fff;
background: #21759B url(../images/button-grad.png) repeat-x scroll left top;
text-shadow: rgba(0,0,0,0.3) 0 -1px 0;
}
input.button-primary:active,
button.button-primary:active,
a.button-primary:active {
background: #21759b url(../images/button-grad-active.png) repeat-x scroll left top;
color: #eaf2fa;
}
input.button-primary:hover,
button.button-primary:hover,
a.button-primary:hover,
a.button-primary:focus,
a.button-primary:active {
border-color: #13455b;
color: #eaf2fa;
}
.button-disabled,
.button[disabled],
.button:disabled,
.button-secondary[disabled],
.button-secondary:disabled,
a.button.disabled {
color: #aaa !important;
border-color: #ddd !important;
}
.button-primary-disabled,
.button-primary[disabled],
.button-primary:disabled {
color: #9FD0D5 !important;
background: #298CBA !important;
}
a:hover,
a:active,
a:focus {
color: #d54e21;
}
#adminmenu a:hover,
#adminmenu li.menu-top > a:focus,
#adminmenu ul.wp-submenu a:hover,
#the-comment-list .comment a:hover,
#rightnow a:hover,
#media-upload a.del-link:hover,
div.dashboard-widget-submit input:hover,
.subsubsub a:hover,
.subsubsub a.current:hover,
.ui-tabs-nav a:hover,
.plugins .inactive a:hover,
#all-plugins-table .plugins .inactive a:hover,
#search-plugins-table .plugins .inactive a:hover {
color: #d54e21;
}
#the-comment-list .comment-item,
#dashboard-widgets #dashboard_quick_press form p.submit {
border-color: #dfdfdf;
}
#side-sortables .category-tabs .tabs a,
#side-sortables .add-menu-item-tabs .tabs a,
.wp-tab-bar .wp-tab-active a {
color: #333;
}
#rightnow .rbutton {
background-color: #ebebeb;
color: #264761;
}
.submitbox .submit {
background-color: #464646;
color: #ccc;
}
.plugins a.delete:hover,
#all-plugins-table .plugins a.delete:hover,
#search-plugins-table .plugins a.delete:hover,
.submitbox .submitdelete {
color: #f00;
border-bottom-color: #f00;
}
.submitbox .submitdelete:hover,
#media-items a.delete:hover {
color: #fff;
background-color: #f00;
border-bottom-color: #f00;
}
#normal-sortables .submitbox .submitdelete:hover {
color: #000;
background-color: #f00;
border-bottom-color: #f00;
}
.tablenav .dots {
border-color: transparent;
}
.tablenav .next,
.tablenav .prev {
border-color: transparent;
color: #21759b;
}
.tablenav .next:hover,
.tablenav .prev:hover {
border-color: transparent;
color: #d54e21;
}
div.updated,
.login .message {
background-color: #ffffe0;
border-color: #e6db55;
}
.update-message {
color: #000;
}
a.page-numbers {
border-bottom-color: #B8D3E2;
}
.commentlist li {
border-bottom-color: #ccc;
}
.widefat td,
.widefat th {
border-top-color: #fff;
border-bottom-color: #dfdfdf;
}
.widefat th {
text-shadow: rgba(255,255,255,0.8) 0 1px 0;
}
.widefat td {
color: #555;
}
.widefat p,
.widefat ol,
.widefat ul {
color: #333;
}
.widefat thead tr th,
.widefat tfoot tr th,
h3.dashboard-widget-title,
h3.dashboard-widget-title span,
h3.dashboard-widget-title small,
.find-box-head {
color: #333;
}
th.sortable a:hover, th.sortable a:active, th.sortable a:focus {
color: #333;
}
h3.dashboard-widget-title small a {
color: #d7d7d7;
}
h3.dashboard-widget-title small a:hover {
color: #fff;
}
a,
#adminmenu a,
#the-comment-list p.comment-author strong a,
#media-upload a.del-link,
#media-items a.delete,
.plugins a.delete,
.ui-tabs-nav a {
color: #21759b;
}
#adminmenu .awaiting-mod,
#adminmenu .update-plugins,
#sidemenu a .update-plugins,
#rightnow .reallynow {
background-color: #464646;
color: #fff;
-moz-box-shadow: rgba(255,255,255,0.5) 0 1px 0;
-webkit-box-shadow: rgba(255,255,255,0.5) 0 1px 0;
box-shadow: rgba(255,255,255,0.5) 0 1px 0;
}
#plugin-information .action-button {
background-color: #d54e21;
color: #fff;
}
#adminmenu li.current a .awaiting-mod,
#adminmenu li a.wp-has-current-submenu .update-plugins{
background-color: #464646;
color: #fff;
-moz-box-shadow: rgba(255,255,255,0.5) 0 1px 0;
-webkit-box-shadow: rgba(255,255,255,0.5) 0 1px 0;
box-shadow: rgba(255,255,255,0.5) 0 1px 0;
}
div#media-upload-header,
div#plugin-information-header {
background-color: #f9f9f9;
border-bottom-color: #dfdfdf;
}
#currenttheme img {
border-color: #666;
}
#dashboard_secondary div.dashboard-widget-content ul li a {
background-color: #f9f9f9;
}
input.readonly, textarea.readonly {
background-color: #ddd;
}
#editable-post-name {
background-color: #fffbcc;
}
#edit-slug-box strong,
.tablenav .displaying-num,
#submitted-on,
.submitted-on {
color: #777;
}
.login #nav a,
.login #backtoblog a {
color: #21759b !important;
}
.login #nav a:hover,
.login #backtoblog a:hover {
color: #d54e21 !important;
}
#footer {
color: #777;
border-color: #dfdfdf;
}
.imgedit-group,
#media-items .media-item,
.media-item .describe {
border-color: #dfdfdf;
}
.checkbox,
.side-info,
.plugins tr,
#your-profile #rich_editing {
background-color: #fcfcfc;
}
.plugins .inactive,
.plugins .inactive th,
.plugins .inactive td,
tr.inactive + tr.plugin-update-tr .plugin-update {
background-color: #f4f4f4;
}
.plugin-update-tr .update-message {
background-color: #fffbe4;
border-color: #dfdfdf;
}
.plugins .active,
.plugins .active th,
.plugins .active td {
color: #000;
}
.plugins .inactive a {
color: #557799;
}
#the-comment-list tr.undo,
#the-comment-list div.undo {
background-color: #f4f4f4;
}
#the-comment-list .unapproved {
background-color: #ffffe0;
}
#the-comment-list .approve a {
color: #006505;
}
#the-comment-list .unapprove a {
color: #d98500;
}
table.widefat span.delete a,
table.widefat span.trash a,
table.widefat span.spam a,
#dashboard_recent_comments .delete a,
#dashboard_recent_comments .trash a,
#dashboard_recent_comments .spam a {
color: #bc0b0b;
}
.welcome-panel {
border-color: #dfdfdf;
}
.welcome-panel p {
color: #777;
}
.welcome-panel-column p {
color: #464646;
}
.welcome-panel h3 {
text-shadow: 1px 1px 1px white;
}
.widget,
#widget-list .widget-top,
.postbox,
#titlediv,
#poststuff .postarea,
.stuffbox {
border-color: #dfdfdf;
-moz-box-shadow: inset 0 1px 0 #fff;
-webkit-box-shadow: inset 0 1px 0 #fff;
box-shadow: inset 0 1px 0 #fff;
-webkit-border-radius: 3px;
border-radius: 3px;
}
.widget,
#widget-list .widget-top,
.postbox,
.menu-item-settings {
background-color: #f5f5f5; /* Fallback */
background-image: -ms-linear-gradient(top, #f9f9f9, #f5f5f5); /* IE10 */
background-image: -moz-linear-gradient(top, #f9f9f9, #f5f5f5); /* Firefox */
background-image: -o-linear-gradient(top, #f9f9f9, #f5f5f5); /* Opera */
background-image: -webkit-gradient(linear, left top, left bottom, from(#f9f9f9), to(#f5f5f5)); /* old Webkit */
background-image: -webkit-linear-gradient(top, #f9f9f9, #f5f5f5); /* new Webkit */
background-image: linear-gradient(top, #f9f9f9, #f5f5f5); /* proposed W3C Markup */
}
.postbox h3 {
color: #464646;
}
.widget .widget-top {
color: #222;
}
.sidebar-name:hover h3,
.postbox h3:hover {
color: #000;
}
.curtime #timestamp {
background-image: url(../images/date-button.gif);
}
#quicktags #ed_link {
color: #00f;
}
#rightnow .youhave {
background-color: #f0f6fb;
}
#rightnow a {
color: #448abd;
}
.tagchecklist span a,
#bulk-titles div a {
background: url(../images/xit.gif) no-repeat;
}
.tagchecklist span a:hover,
#bulk-titles div a:hover {
background: url(../images/xit.gif) no-repeat -10px 0;
}
#update-nag, .update-nag {
background-color: #FFFBCC;
border-color: #E6DB55;
color: #555;
}
#screen-meta {
background-color: #f1f1f1;
border-color: #ccc;
-webkit-box-shadow: 0 1px 3px rgba( 0, 0, 0, 0.05 );
box-shadow: 0 1px 3px rgba( 0, 0, 0, 0.05 );
}
#contextual-help-back {
background: #fff;
}
.contextual-help-tabs a:hover {
color: #333;
}
#contextual-help-back,
.contextual-help-tabs .active {
border-color: #ccc;
}
.contextual-help-tabs .active,
.contextual-help-tabs .active a,
.contextual-help-tabs .active a:hover {
background: #fff;
color: #333;
}
/* screen options and help tabs */
#screen-options-link-wrap,
#contextual-help-link-wrap {
background-color: #e3e3e3; /* Fallback */
border-right: 1px solid #ccc;
border-left: 1px solid #ccc;
border-bottom: 1px solid #ccc;
background-image: -ms-linear-gradient(bottom, #dfdfdf, #f1f1f1); /* IE10 */
background-image: -moz-linear-gradient(bottom, #dfdfdf, #f1f1f1); /* Firefox */
background-image: -o-linear-gradient(bottom, #dfdfdf, #f1f1f1); /* Opera */
background-image: -webkit-gradient(linear, left bottom, left top, from(#dfdfdf), to(#f1f1f1)); /* old Webkit */
background-image: -webkit-linear-gradient(bottom, #dfdfdf, #f1f1f1); /* new Webkit */
background-image: linear-gradient(bottom, #dfdfdf, #f1f1f1); /* proposed W3C Markup */
}
#screen-meta-links a.show-settings {
color: #777;
}
#screen-meta-links a.show-settings:hover {
color: #333;
}
#screen-meta-links a.show-settings {
background: transparent url(../images/arrows.png) no-repeat right 4px;
}
#screen-meta-links a.show-settings.screen-meta-active {
background: transparent url(../images/arrows.png) no-repeat right -31px;
}
/* end screen options and help tabs */
.login #backtoblog a {
color: #464646;
}
#wphead {
border-bottom:#dfdfdf 1px solid;
}
#wphead h1 a {
color: #464646;
}
#footer a:link,
#footer a:visited {
text-decoration: none;
}
#footer a:hover {
text-decoration: underline;
}
.file-error,
abbr.required,
.widget-control-remove:hover,
table.widefat .delete a:hover,
table.widefat .trash a:hover,
table.widefat .spam a:hover,
#dashboard_recent_comments .delete a:hover,
#dashboard_recent_comments .trash a:hover
#dashboard_recent_comments .spam a:hover {
color: #f00;
}
#pass-strength-result {
background-color: #eee;
border-color: #ddd !important;
}
#pass-strength-result.bad {
background-color: #ffb78c;
border-color: #ff853c !important;
}
#pass-strength-result.good {
background-color: #ffec8b;
border-color: #fc0 !important;
}
#pass-strength-result.short {
background-color: #ffa0a0;
border-color: #f04040 !important;
}
#pass-strength-result.strong {
background-color: #c3ff88;
border-color: #8dff1c !important;
}
#titlediv #title {
border-color: #ccc;
}
#post-status-info {
border-color: #dfdfdf #ccc #ccc;
background-color: #eaeaea;
}
.editwidget .widget-inside {
border-color: #dfdfdf;
}
#titlediv #title {
background-color: #fff;
}
#tTips p#tTips_inside {
background-color: #ddd;
color: #333;
}
#timestampdiv input,
#namediv input,
#poststuff .inside .the-tagcloud {
border-color: #ddd;
}
/* menu */
#adminmenuback,
#adminmenuwrap {
background-color: #ececec;
border-color: #ccc;
}
#adminmenushadow,
#adminmenuback {
background-image: url(../images/menu-shadow.png);
background-position: top right;
background-repeat: repeat-y;
}
#adminmenu li.wp-menu-separator {
background: #dfdfdf;
border-color: #cfcfcf;
}
#adminmenu div.separator {
border-color: #e1e1e1;
}
#adminmenu li.wp-has-current-submenu.wp-menu-open .wp-menu-toggle,
#adminmenu li.wp-has-current-submenu:hover .wp-menu-toggle {
background: transparent url(../images/arrows-dark.png) no-repeat -1px 6px;
}
#adminmenu .wp-has-submenu:hover .wp-menu-toggle,
#adminmenu .wp-menu-open .wp-menu-toggle {
background: transparent url(../images/arrows.png) no-repeat -2px 6px;
}
#adminmenu a.menu-top,
.folded #adminmenu li.menu-top,
#adminmenu .wp-submenu .wp-submenu-head {
border-top-color: #f9f9f9;
border-bottom-color: #dfdfdf;
}
#adminmenu li.wp-menu-open {
border-color: #dfdfdf;
}
#adminmenu li.menu-top:hover > a,
#adminmenu li.menu-top.focused > a,
#adminmenu li.menu-top > a:focus {
background-color: #e4e4e4;
text-shadow: 0 1px 0 rgba( 255, 255, 255, 0.4 );
}
#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu,
#adminmenu li.current a.menu-top,
.folded #adminmenu li.wp-has-current-submenu,
.folded #adminmenu li.current.menu-top,
#adminmenu .wp-menu-arrow,
#adminmenu .wp-has-current-submenu .wp-submenu .wp-submenu-head {
background-color: #777; /* Fallback */
background-image: -ms-linear-gradient(bottom, #6d6d6d, #808080); /* IE10 */
background-image: -moz-linear-gradient(bottom, #6d6d6d, #808080); /* Firefox */
background-image: -o-linear-gradient(bottom, #6d6d6d, #808080); /* Opera */
background-image: -webkit-gradient(linear, left bottom, left top, from(#6d6d6d), to(#808080)); /* old Webkit */
background-image: -webkit-linear-gradient(bottom, #6d6d6d, #808080); /* new Webkit */
background-image: linear-gradient(bottom, #6d6d6d, #808080); /* proposed W3C Markup */
}
#adminmenu .wp-menu-arrow div {
background-color: #777; /* Fallback */
background-image: -ms-linear-gradient(right bottom, #6d6d6d, #808080); /* IE10 */
background-image: -moz-linear-gradient(right bottom, #6d6d6d, #808080); /* Firefox */
background-image: -o-linear-gradient(right bottom, #6d6d6d, #808080); /* Opera */
background-image: -webkit-gradient(linear, right bottom, left top, from(#6d6d6d), to(#808080)); /* old Webkit */
background-image: -webkit-linear-gradient(right bottom, #6d6d6d, #808080); /* new Webkit */
background-image: linear-gradient(right bottom, #6d6d6d, #808080); /* proposed W3C Markup */
}
#adminmenu li.wp-not-current-submenu .wp-menu-arrow {
border-top-color: #f9f9f9;
border-bottom-color: #dfdfdf;
background: #E4E4E4;
}
#adminmenu li.wp-not-current-submenu .wp-menu-arrow div {
background: #E4E4E4;
border-color: #ccc;
}
.folded #adminmenu li.menu-top li:hover a {
background-image: none;
}
#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu,
#adminmenu li.current a.menu-top,
#adminmenu .wp-has-current-submenu .wp-submenu .wp-submenu-head {
text-shadow: 0 -1px 0 #333;
color: #fff;
border-top-color: #808080;
border-bottom-color: #6d6d6d;
}
.folded #adminmenu li.wp-has-current-submenu,
.folded #adminmenu li.current.menu-top {
border-top-color: #808080;
border-bottom-color: #6d6d6d;
}
#adminmenu .wp-submenu a:hover,
#adminmenu .wp-submenu a:focus {
background-color: #EAF2FA;
color: #333;
}
#adminmenu .wp-submenu li.current,
#adminmenu .wp-submenu li.current a,
#adminmenu .wp-submenu li.current a:hover {
color: #333;
}
#adminmenu .wp-submenu ul {
background-color: #fff;
}
#adminmenu .wp-submenu-wrap,
#adminmenu .wp-submenu ul {
border-color: #dfdfdf;
}
#adminmenu .wp-submenu-wrap,
.folded #adminmenu .wp-has-current-submenu .wp-submenu-wrap {
-moz-box-shadow: 2px 2px 5px rgba( 0, 0, 0, 0.4 );
-webkit-box-shadow: 2px 2px 5px rgba( 0, 0, 0, 0.4 );
box-shadow: 2px 2px 5px rgba( 0, 0, 0, 0.4 );
}
#adminmenu .wp-submenu .wp-submenu-head {
border-right-color: #dfdfdf;
background-color: #ececec;
}
#adminmenu div.wp-submenu {
background-color: transparent;
}
/* collapse menu button */
#collapse-menu {
color: #aaa;
}
#collapse-menu:hover {
color: #999;
}
#collapse-button {
border-color: #ccc;
background-color: #f4f4f4; /* Fallback */
background-image: -ms-linear-gradient(bottom, #dfdfdf, #fff); /* IE10 */
background-image: -moz-linear-gradient(bottom, #dfdfdf, #fff); /* Firefox */
background-image: -o-linear-gradient(bottom, #dfdfdf, #fff); /* Opera */
background-image: -webkit-gradient(linear, left bottom, left top, from(#dfdfdf), to(#fff)); /* old Webkit */
background-image: -webkit-linear-gradient(bottom, #dfdfdf, #fff); /* new Webkit */
background-image: linear-gradient(bottom, #dfdfdf, #fff); /* proposed W3C Markup */
}
#collapse-menu:hover #collapse-button {
border-color: #aaa;
}
#collapse-button div {
background: transparent url(../images/arrows.png) no-repeat 0 -72px;
}
.folded #collapse-button div {
background-position: 0 -108px;
}
/* Auto-folding of the admin menu */
@media only screen and (max-width: 900px) {
#adminmenu li.menu-top {
border-top-color: #f9f9f9;
border-bottom-color: #dfdfdf;
}
#adminmenu li.wp-has-current-submenu,
#adminmenu li.current.menu-top {
background-color: #777; /* Fallback */
background-image: -ms-linear-gradient(bottom, #6d6d6d, #808080); /* IE10 */
background-image: -moz-linear-gradient(bottom, #6d6d6d, #808080); /* Firefox */
background-image: -o-linear-gradient(bottom, #6d6d6d, #808080); /* Opera */
background-image: -webkit-gradient(linear, left bottom, left top, from(#6d6d6d), to(#808080)); /* old Webkit */
background-image: -webkit-linear-gradient(bottom, #6d6d6d, #808080); /* new Webkit */
background-image: linear-gradient(bottom, #6d6d6d, #808080); /* proposed W3C Markup */
}
#adminmenu li.menu-top li:hover a {
background-image: none;
}
#adminmenu li.wp-has-current-submenu,
#adminmenu li.current.menu-top {
border-top-color: #808080;
border-bottom-color: #6d6d6d;
}
#adminmenu .wp-has-current-submenu .wp-submenu-wrap {
-moz-box-shadow: 2px 2px 5px rgba( 0, 0, 0, 0.4 );
-webkit-box-shadow: 2px 2px 5px rgba( 0, 0, 0, 0.4 );
box-shadow: 2px 2px 5px rgba( 0, 0, 0, 0.4 );
}
#collapse-button div {
background-position: 0 -108px;
}
}
/* menu and screen icons */
.icon16,
.icon32,
div.wp-menu-image {
background-color: transparent;
background-repeat: no-repeat;
}
.icon16.icon-dashboard,
.menu-icon-dashboard div.wp-menu-image,
.icon16.icon-post,
.menu-icon-post div.wp-menu-image,
.icon16.icon-media,
.menu-icon-media div.wp-menu-image,
.icon16.icon-links,
.menu-icon-links div.wp-menu-image,
.icon16.icon-page,
.menu-icon-page div.wp-menu-image,
.icon16.icon-comments,
.menu-icon-comments div.wp-menu-image,
.icon16.icon-appearance,
.menu-icon-appearance div.wp-menu-image,
.icon16.icon-plugins,
.menu-icon-plugins div.wp-menu-image,
.icon16.icon-users,
.menu-icon-users div.wp-menu-image,
.icon16.icon-tools,
.menu-icon-tools div.wp-menu-image,
.icon16.icon-settings,
.menu-icon-settings div.wp-menu-image,
.icon16.icon-site,
.menu-icon-site div.wp-menu-image {
background-image: url('../images/menu.png?ver=20120201');
}
.icon16.icon-dashboard,
#adminmenu .menu-icon-dashboard div.wp-menu-image {
background-position: -59px -33px;
}
#adminmenu .menu-icon-dashboard:hover div.wp-menu-image,
#adminmenu .menu-icon-dashboard.wp-has-current-submenu div.wp-menu-image,
#adminmenu .menu-icon-dashboard.current div.wp-menu-image {
background-position: -59px -1px;
}
.icon16.icon-post,
#adminmenu .menu-icon-post div.wp-menu-image {
background-position: -269px -33px;
}
#adminmenu .menu-icon-post:hover div.wp-menu-image,
#adminmenu .menu-icon-post.wp-has-current-submenu div.wp-menu-image,
#adminmenu .menu-icon-post.current div.wp-menu-image {
background-position: -269px -1px;
}
.icon16.icon-media,
#adminmenu .menu-icon-media div.wp-menu-image {
background-position: -119px -33px;
}
#adminmenu .menu-icon-media:hover div.wp-menu-image,
#adminmenu .menu-icon-media.wp-has-current-submenu div.wp-menu-image,
#adminmenu .menu-icon-media.current div.wp-menu-image {
background-position: -119px -1px;
}
.icon16.icon-links,
#adminmenu .menu-icon-links div.wp-menu-image {
background-position: -89px -33px;
}
#adminmenu .menu-icon-links:hover div.wp-menu-image,
#adminmenu .menu-icon-links.wp-has-current-submenu div.wp-menu-image,
#adminmenu .menu-icon-links.current div.wp-menu-image {
background-position: -89px -1px;
}
.icon16.icon-page,
#adminmenu .menu-icon-page div.wp-menu-image {
background-position: -149px -33px;
}
#adminmenu .menu-icon-page:hover div.wp-menu-image,
#adminmenu .menu-icon-page.wp-has-current-submenu div.wp-menu-image,
#adminmenu .menu-icon-page.current div.wp-menu-image {
background-position: -149px -1px;
}
.icon16.icon-comments,
#adminmenu .menu-icon-comments div.wp-menu-image {
background-position: -29px -33px;
}
#adminmenu .menu-icon-comments:hover div.wp-menu-image,
#adminmenu .menu-icon-comments.wp-has-current-submenu div.wp-menu-image,
#adminmenu .menu-icon-comments.current div.wp-menu-image {
background-position: -29px -1px;
}
.icon16.icon-appearance,
#adminmenu .menu-icon-appearance div.wp-menu-image {
background-position: 1px -33px;
}
#adminmenu .menu-icon-appearance:hover div.wp-menu-image,
#adminmenu .menu-icon-appearance.wp-has-current-submenu div.wp-menu-image,
#adminmenu .menu-icon-appearance.current div.wp-menu-image {
background-position: 1px -1px;
}
.icon16.icon-plugins,
#adminmenu .menu-icon-plugins div.wp-menu-image {
background-position: -179px -33px;
}
#adminmenu .menu-icon-plugins:hover div.wp-menu-image,
#adminmenu .menu-icon-plugins.wp-has-current-submenu div.wp-menu-image,
#adminmenu .menu-icon-plugins.current div.wp-menu-image {
background-position: -179px -1px;
}
.icon16.icon-users,
#adminmenu .menu-icon-users div.wp-menu-image {
background-position: -300px -33px;
}
#adminmenu .menu-icon-users:hover div.wp-menu-image,
#adminmenu .menu-icon-users.wp-has-current-submenu div.wp-menu-image,
#adminmenu .menu-icon-users.current div.wp-menu-image {
background-position: -300px -1px;
}
.icon16.icon-tools,
#adminmenu .menu-icon-tools div.wp-menu-image {
background-position: -209px -33px;
}
#adminmenu .menu-icon-tools:hover div.wp-menu-image,
#adminmenu .menu-icon-tools.wp-has-current-submenu div.wp-menu-image,
#adminmenu .menu-icon-tools.current div.wp-menu-image {
background-position: -209px -1px;
}
.icon16.icon-settings,
#adminmenu .menu-icon-settings div.wp-menu-image {
background-position: -239px -33px;
}
#adminmenu .menu-icon-settings:hover div.wp-menu-image,
#adminmenu .menu-icon-settings.wp-has-current-submenu div.wp-menu-image,
#adminmenu .menu-icon-settings.current div.wp-menu-image {
background-position: -239px -1px;
}
.icon16.icon-site,
#adminmenu .menu-icon-site div.wp-menu-image {
background-position: -359px -33px;
}
#adminmenu .menu-icon-site:hover div.wp-menu-image,
#adminmenu .menu-icon-site.wp-has-current-submenu div.wp-menu-image,
#adminmenu .menu-icon-site.current div.wp-menu-image {
background-position: -359px -1px;
}
/* end menu and screen icons */
/* Screen Icons */
.icon32.icon-post,
#icon-edit,
#icon-post,
.icon32.icon-dashboard,
#icon-index,
.icon32.icon-media,
#icon-upload,
.icon32.icon-links,
#icon-link-manager,
#icon-link,
#icon-link-category,
.icon32.icon-page,
#icon-edit-pages,
#icon-page,
.icon32.icon-comments,
#icon-edit-comments,
.icon32.icon-appearance,
#icon-themes,
.icon32.icon-plugins,
#icon-plugins,
.icon32.icon-users,
#icon-users,
#icon-profile,
#icon-user-edit,
.icon32.icon-tools,
#icon-tools,
#icon-admin,
.icon32.icon-settings,
#icon-options-general,
.icon32.icon-site,
#icon-ms-admin {
background-image: url(../images/icons32.png?ver=20111206);
}
.icon32.icon-post,
#icon-edit,
#icon-post {
background-position: -552px -5px;
}
.icon32.icon-dashboard,
#icon-index {
background-position: -137px -5px;
}
.icon32.icon-media,
#icon-upload {
background-position: -251px -5px;
}
.icon32.icon-links,
#icon-link-manager,
#icon-link,
#icon-link-category {
background-position: -190px -5px;
}
.icon32.icon-page,
#icon-edit-pages,
#icon-page {
background-position: -312px -5px;
}
.icon32.icon-comments,
#icon-edit-comments {
background-position: -72px -5px;
}
.icon32.icon-appearance,
#icon-themes {
background-position: -11px -5px;
}
.icon32.icon-plugins,
#icon-plugins {
background-position: -370px -5px;
}
.icon32.icon-users,
#icon-users,
#icon-profile,
#icon-user-edit {
background-position: -600px -5px;
}
.icon32.icon-tools,
#icon-tools,
#icon-admin {
background-position: -432px -5px;
}
.icon32.icon-settings,
#icon-options-general {
background-position: -492px -5px;
}
.icon32.icon-site,
#icon-ms-admin {
background-position: -659px -5px;
}
@media only screen and (-webkit-min-device-pixel-ratio: 1.5) {
.icon32.icon-post,
#icon-edit,
#icon-post,
.icon32.icon-dashboard,
#icon-index,
.icon32.icon-media,
#icon-upload,
.icon32.icon-links,
#icon-link-manager,
#icon-link,
#icon-link-category,
.icon32.icon-page,
#icon-edit-pages,
#icon-page,
.icon32.icon-comments,
#icon-edit-comments,
.icon32.icon-appearance,
#icon-themes,
.icon32.icon-plugins,
#icon-plugins,
.icon32.icon-users,
#icon-users,
#icon-profile,
#icon-user-edit,
.icon32.icon-tools,
#icon-tools,
#icon-admin,
.icon32.icon-settings,
#icon-options-general,
.icon32.icon-site,
#icon-ms-admin {
background-image: url(../images/icons32-2x.png?ver=20120412);
background-size: 708px 45px;
}
.icon16.icon-dashboard,
.menu-icon-dashboard div.wp-menu-image,
.icon16.icon-post,
.menu-icon-post div.wp-menu-image,
.icon16.icon-media,
.menu-icon-media div.wp-menu-image,
.icon16.icon-links,
.menu-icon-links div.wp-menu-image,
.icon16.icon-page,
.menu-icon-page div.wp-menu-image,
.icon16.icon-comments,
.menu-icon-comments div.wp-menu-image,
.icon16.icon-appearance,
.menu-icon-appearance div.wp-menu-image,
.icon16.icon-plugins,
.menu-icon-plugins div.wp-menu-image,
.icon16.icon-users,
.menu-icon-users div.wp-menu-image,
.icon16.icon-tools,
.menu-icon-tools div.wp-menu-image,
.icon16.icon-settings,
.menu-icon-settings div.wp-menu-image,
.icon16.icon-site,
.menu-icon-site div.wp-menu-image {
background-image: url('../images/menu-2x.png?ver=20120412');
background-size: 390px 64px;
}
}
/* end screen icons */
/* Diff */
table.diff .diff-deletedline {
background-color: #fdd;
}
table.diff .diff-deletedline del {
background-color: #f99;
}
table.diff .diff-addedline {
background-color: #dfd;
}
table.diff .diff-addedline ins {
background-color: #9f9;
}
#att-info {
background-color: #E4F2FD;
}
/* edit image */
#sidemenu a {
background-color: #f9f9f9;
border-color: #f9f9f9;
border-bottom-color: #dfdfdf;
}
#sidemenu a.current {
background-color: #fff;
border-color: #dfdfdf #dfdfdf #fff;
color: #D54E21;
}
#replyerror {
border-color: #ddd;
background-color: #f9f9f9;
}
/* table vim shortcuts */
.vim-current,
.vim-current th,
.vim-current td {
background-color: #E4F2FD !important;
}
/* Install Plugins */
#plugin-information .fyi ul {
background-color: #eaf3fa;
}
#plugin-information .fyi h2.mainheader {
background-color: #cee1ef;
}
#plugin-information pre,
#plugin-information code {
background-color: #ededff;
}
#plugin-information pre {
border: 1px solid #ccc;
}
/* inline editor */
.inline-edit-row fieldset input[type="text"],
.inline-edit-row fieldset textarea,
#bulk-titles {
border-color: #ddd;
}
.inline-editor div.title {
background-color: #EAF3FA;
}
.inline-editor ul.cat-checklist {
background-color: #fff;
border-color: #ddd;
}
.inline-editor .categories .catshow,
.inline-editor .categories .cathide {
color: #21759b;
}
.inline-editor .quick-edit-save {
background-color: #f1f1f1;
}
fieldset.inline-edit-col-right .inline-edit-col {
border-color: #dfdfdf;
}
.attention {
color: #D54E21;
}
.meta-box-sortables .postbox:hover .handlediv {
background: transparent url(../images/arrows.png) no-repeat 6px 7px;
}
.tablenav .tablenav-pages {
color: #555;
}
.tablenav .tablenav-pages a {
border-color: #e3e3e3;
background: #eee url('../images/menu-bits.gif?ver=20100610') repeat-x scroll left -379px;
}
.tablenav .tablenav-pages a:hover,
.tablenav .tablenav-pages a:focus {
color: #d54e21;
}
.tablenav .tablenav-pages a.disabled,
.tablenav .tablenav-pages a.disabled:hover,
.tablenav .tablenav-pages a.disabled:focus {
color: #aaa;
}
.tablenav .tablenav-pages .current {
background: #dfdfdf;
border-color: #d3d3d3;
}
#availablethemes,
#availablethemes td {
border-color: #ddd;
}
#current-theme img {
border-color: #999;
}
#TB_window #TB_title a.tb-theme-preview-link,
#TB_window #TB_title a.tb-theme-preview-link:visited {
color: #999;
}
#TB_window #TB_title a.tb-theme-preview-link:hover,
#TB_window #TB_title a.tb-theme-preview-link:focus {
color: #ccc;
}
.misc-pub-section {
border-top-color: #fff;
border-bottom-color: #dfdfdf;
}
#minor-publishing {
border-bottom-color: #dfdfdf;
}
#post-body .misc-pub-section {
border-left-color: #eee;
}
.post-com-count span {
background-color: #bbb;
}
.form-table .color-palette td {
border-color: #fff;
}
.sortable-placeholder {
border-color: #bbb;
background-color: #f5f5f5;
}
#post-body ul.category-tabs li.tabs a,
#post-body ul.add-menu-item-tabs li.tabs a,
body.press-this ul.category-tabs li.tabs a {
color: #333;
}
.view-switch #view-switch-list {
background: transparent url(../images/list.png) no-repeat 0 0;
}
.view-switch .current #view-switch-list {
background: transparent url(../images/list.png) no-repeat -40px 0;
}
.view-switch #view-switch-excerpt {
background: transparent url(../images/list.png) no-repeat -20px 0;
}
.view-switch .current #view-switch-excerpt {
background: transparent url(../images/list.png) no-repeat -60px 0;
}
#header-logo {
background: transparent url(../images/wp-logo.png?ver=20110504) no-repeat scroll center center;
}
.popular-tags,
.feature-filter {
background-color: #fff;
border-color: #DFDFDF;
}
div.widgets-sortables,
#widgets-left .inactive,
#available-widgets .widget-holder {
background-color: #fcfcfc;
border-color: #dfdfdf;
}
#available-widgets .widget-description {
color: #555;
}
.sidebar-name {
color: #464646;
text-shadow: #fff 0 1px 0;
border-color: #dfdfdf;
-moz-box-shadow: inset 0 1px 0 #fff;
-webkit-box-shadow: inset 0 1px 0 #fff;
box-shadow: inset 0 1px 0 #fff;
}
.sidebar-name:hover,
#removing-widget {
color: #d54e21;
}
#removing-widget span {
color: black;
}
.sidebar-name-arrow {
background: transparent url(../images/arrows.png) no-repeat 5px 9px;
}
.sidebar-name:hover .sidebar-name-arrow {
background: transparent url(../images/arrows-dark.png) no-repeat 5px 9px;
}
.in-widget-title {
color: #606060;
}
.deleting .widget-title * {
color: #aaa;
}
.imgedit-menu div {
border-color: #d5d5d5;
background-color: #f1f1f1;
}
.imgedit-menu div:hover {
border-color: #c1c1c1;
background-color: #eaeaea;
}
.imgedit-menu div.disabled {
border-color: #ccc;
background-color: #ddd;
filter: alpha(opacity=50);
opacity: 0.5;
}
#dashboard_recent_comments div.undo {
border-top-color: #dfdfdf;
}
.comment-ays,
.comment-ays th {
border-color: #ddd;
}
.comment-ays th {
background-color: #f1f1f1;
}
/* added from nav-menu.css */
#menu-management .menu-edit {
border-color: #dfdfdf;
}
#post-body {
background: #fff;
border-top-color: #fff;
border-bottom-color: #dfdfdf;
}
#nav-menu-header {
border-bottom-color: #dfdfdf;
}
#nav-menu-footer {
border-top-color: #fff;
}
#menu-management .nav-tabs-arrow a {
color: #C1C1C1;
}
#menu-management .nav-tabs-arrow a:hover {
color: #D54E21;
}
#menu-management .nav-tabs-arrow a:active {
color: #464646;
}
#menu-management .nav-tab-active {
border-color: #dfdfdf;
}
#menu-management .nav-tab {
background: #fbfbfb;
border-color: #dfdfdf;
}
.js .input-with-default-title {
color: #aaa;
}
#cancel-save {
color: #ff0000;
}
#cancel-save:hover {
background-color: #FF0000;
color: #fff;
}
.list-container,
.menu-item-handle {
border-color: #dfdfdf;
}
.menu li.deleting .menu-item-handle {
background-color: #f66;
text-shadow: #ccc;
}
.item-type { /* Menu item controls */
color: #999999;
}
.item-controls .menu-item-delete:hover {
color: #ff0000;
}
.nav-menus-php .item-edit {
background: transparent url(../images/arrows.png) no-repeat 8px 10px;
border-bottom-color: #eee;
}
.item-edit:hover {
background: transparent url(../images/arrows-dark.png) no-repeat 8px 10px;
}
.menu-item-settings { /* Menu editing */
border-color: #dfdfdf;
}
.link-to-original {
color: #777;
border-color: #dfdfdf;
}
#cancel-save:hover {
color: #fff !important;
}
#update-menu-item {
color: #fff !important;
}
#update-menu-item:hover,
#update-menu-item:active,
#update-menu-item:focus {
color: #eaf2fa !important;
border-color: #13455b !important;
}
.submitbox .submitcancel {
color: #21759B;
border-bottom-color: #21759B;
}
.submitbox .submitcancel:hover {
background: #21759B;
color: #fff;
}
/* end added from nav-menu.css */
#menu-management .nav-tab-active,
.menu-item-handle,
.menu-item-settings {
-moz-box-shadow: inset 0 1px 0 #fff;
-webkit-box-shadow: inset 0 1px 0 #fff;
box-shadow: inset 0 1px 0 #fff;
}
#menu-management .nav-tab-active {
background: #f9f9f9;
border-bottom-color: #f9f9f9;
}
#upload-form label {
color: #777;
}
/* Begin About Pages */
.about-wrap h1 {
color: #333;
text-shadow: 1px 1px 1px white;
}
.about-text {
color: #777;
}
.wp-badge {
color: #fff;
text-shadow: 0 -1px 0 rgba(22, 57, 81, 0.3);
}
.about-wrap h2 .nav-tab {
color: #21759B;
}
.about-wrap h2 .nav-tab:hover {
color: #d54e21;
}
.about-wrap h2 .nav-tab-active,
.about-wrap h2 .nav-tab-active:hover {
color: #333;
}
.about-wrap h2 .nav-tab-active {
text-shadow: 1px 1px 1px white;
color: #464646;
}
.about-wrap h3 {
color: #333;
text-shadow: 1px 1px 1px white;
}
.about-wrap .feature-section h4 {
color: #464646;
}
.about-wrap .feature-section img {
background: #fff;
border: 1px #ccc solid;
-moz-box-shadow: 0 1px 3px rgba( 0, 0, 0, 0.3 );
-webkit-box-shadow: 0 1px 3px rgba( 0, 0, 0, 0.3 );
box-shadow: 0 1px 3px rgba( 0, 0, 0, 0.3 );
}
.about-wrap h4.wp-people-group {
text-shadow: 1px 1px 1px white;
}
.about-wrap .point-releases {
border-bottom: 1px solid #dfdfdf;
}
.about-wrap .point-releases h3 {
border-top: 1px solid #dfdfdf;
}
.about-wrap .point-releases h3:first-child {
border: 0;
}
.about-wrap li.wp-person img.gravatar {
-moz-box-shadow: 0 0 4px rgba( 0, 0, 0, 0.4 );
-webkit-box-shadow: 0 0 4px rgba( 0, 0, 0, 0.4 );
box-shadow: 0 0 4px rgba( 0, 0, 0, 0.4 );
}
.about-wrap li.wp-person .title {
color: #464646;
text-shadow: 1px 1px 1px white;
}
.freedoms-php .about-wrap ol li {
color: #999;
}
.freedoms-php .about-wrap ol p {
color: #464646;
}
/* End About Pages */
/*------------------------------------------------------------------------------
2.0 - Right to Left Styles
------------------------------------------------------------------------------*/
.rtl .bar {
border-right-color: none;
border-left-color: #99d;
}
.rtl .post-com-count {
background-image: url(../images/bubble_bg-rtl.gif);
}
.rtl #screen-meta-links a.show-settings {
background-position: left 3px;
}
.rtl #screen-meta-links a.show-settings.screen-meta-active {
background-position: left -33px;
}
/* Menu */
.rtl #adminmenushadow,
.rtl #adminmenuback {
background-image: url(../images/menu-shadow-rtl.png);
background-position: top left;
}
.rtl #adminmenu li.wp-has-current-submenu.wp-menu-open .wp-menu-toggle,
.rtl #adminmenu li.wp-has-current-submenu:hover .wp-menu-toggle {
background: transparent url(../images/arrows-dark.png) no-repeat 8px 6px;
}
.rtl #adminmenu .wp-has-submenu:hover .wp-menu-toggle,
.rtl #adminmenu .wp-menu-open .wp-menu-toggle {
background: transparent url(../images/arrows.png) no-repeat 8px 6px;
}
.rtl #adminmenu .wp-submenu .wp-submenu-head {
border-right-color: none;
border-left-color: #dfdfdf;
}
.rtl #adminmenu .wp-submenu-wrap,
.rtl.folded #adminmenu .wp-has-current-submenu .wp-submenu-wrap{
-moz-box-shadow: -2px 2px 5px rgba( 0, 0, 0, 0.4 );
-webkit-box-shadow: -2px 2px 5px rgba( 0, 0, 0, 0.4 );
box-shadow: -2px 2px 5px rgba( 0, 0, 0, 0.4 );
}
/* Collapse Menu Button */
.rtl #collapse-button div {
background-position: 0 -108px;
}
.rtl.folded #collapse-button div {
background-position: 0 -72px;
}
/* Auto-folding of the admin menu for RTL */
@media only screen and (max-width: 900px) {
.rtl #adminmenu .wp-has-current-submenu .wp-submenu-wrap{
-moz-box-shadow: -2px 2px 5px rgba( 0, 0, 0, 0.4 );
-webkit-box-shadow: -2px 2px 5px rgba( 0, 0, 0, 0.4 );
box-shadow: -2px 2px 5px rgba( 0, 0, 0, 0.4 );
}
.rtl #collapse-button div {
background-position: 0 -72px;
}
}
/* Edit Image */
.rtl .meta-box-sortables .postbox:hover .handlediv {
background: transparent url(../images/arrows.png) no-repeat 6px 7px;
}
.rtl .tablenav .tablenav-pages a {
border-color: #e3e3e3;
background: #eee url('../images/menu-bits-rtl.gif?ver=20100610') repeat-x scroll right -379px;
}
.rtl #post-body .misc-pub-section {
border-right-color: none;
border-left-color: #eee;
}
.rtl .sidebar-name-arrow {
background: transparent url(../images/arrows.png) no-repeat 5px 9px;
}
.rtl .sidebar-name:hover .sidebar-name-arrow {
background: transparent url(../images/arrows-dark.png) no-repeat 5px 9px;
}
| 01happy-blog | trunk/myblog/wp-admin/css/colors-fresh.dev.css | CSS | oos | 42,774 |
body#media-upload ul#sidemenu {
left: auto;
right: 0;
}
#search-filter {
text-align: left;
}
/* specific to the image upload form */
.align .field label {
padding: 0 23px 0 0;
margin: 0 3px 0 1em;
}
.image-align-none-label, .image-align-left-label, .image-align-center-label, .image-align-right-label {
background-position: center right;
}
tr.image-size label {
margin: 0 5px 0 0;
}
.file-error {
margin: 0 50px 5px 0;
}
.progress {
left: auto;
right: 0;
}
.describe td {
padding: 0 0 0 5px;
}
/* Specific to Uploader */
#media-upload .describe th.label {
text-align: right;
}
.menu_order {
float: left;
}
.media-upload-form label.form-help, td.help, #media-upload p.help, #media-upload label.help {
font-family: Tahoma, Arial;
}
#gallery-settings #basic th.label {
padding: 5px 0 5px 5px;
}
#gallery-settings .title, h3.media-title {
font-family: Tahoma, Arial;
}
#gallery-settings .describe th.label {
text-align: right;
}
#gallery-settings label,
#gallery-settings legend {
margin-right: 0;
margin-left: 15px;
}
#gallery-settings .align .field label {
margin: 0 3px 0 1em;
}
#sort-buttons {
margin: 3px 0 -8px 25px;
text-align: left;
}
#sort-buttons #asc,
#sort-buttons #showall {
padding-left: 0;
padding-right: 5px;
}
#sort-buttons span {
margin-right: 0;
margin-left: 25px;
}
| 01happy-blog | trunk/myblog/wp-admin/css/media-rtl.dev.css | CSS | oos | 1,311 |
<?php
/**
* Discussion settings administration panel.
*
* @package WordPress
* @subpackage Administration
*/
/** WordPress Administration Bootstrap */
require_once('./admin.php');
if ( ! current_user_can( 'manage_options' ) )
wp_die( __( 'You do not have sufficient permissions to manage options for this site.' ) );
$title = __('Discussion Settings');
$parent_file = 'options-general.php';
get_current_screen()->add_help_tab( array(
'id' => 'overview',
'title' => __('Overview'),
'content' => '<p>' . __('This screen provides many options for controlling the management and display of comments and links to your posts/pages. So many, in fact, they won’t all fit here! :) Use the documentation links to get information on what each discussion setting does.') . '</p>' .
'<p>' . __('You must click the Save Changes button at the bottom of the screen for new settings to take effect.') . '</p>',
) );
get_current_screen()->set_help_sidebar(
'<p><strong>' . __('For more information:') . '</strong></p>' .
'<p>' . __('<a href="http://codex.wordpress.org/Settings_Discussion_Screen" target="_blank">Documentation on Discussion Settings</a>') . '</p>' .
'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
);
include('./admin-header.php');
?>
<div class="wrap">
<?php screen_icon(); ?>
<h2><?php echo esc_html( $title ); ?></h2>
<form method="post" action="options.php">
<?php settings_fields('discussion'); ?>
<table class="form-table">
<tr valign="top">
<th scope="row"><?php _e('Default article settings'); ?></th>
<td><fieldset><legend class="screen-reader-text"><span><?php _e('Default article settings'); ?></span></legend>
<label for="default_pingback_flag">
<input name="default_pingback_flag" type="checkbox" id="default_pingback_flag" value="1" <?php checked('1', get_option('default_pingback_flag')); ?> />
<?php _e('Attempt to notify any blogs linked to from the article'); ?></label>
<br />
<label for="default_ping_status">
<input name="default_ping_status" type="checkbox" id="default_ping_status" value="open" <?php checked('open', get_option('default_ping_status')); ?> />
<?php _e('Allow link notifications from other blogs (pingbacks and trackbacks)'); ?></label>
<br />
<label for="default_comment_status">
<input name="default_comment_status" type="checkbox" id="default_comment_status" value="open" <?php checked('open', get_option('default_comment_status')); ?> />
<?php _e('Allow people to post comments on new articles'); ?></label>
<br />
<small><em><?php echo '(' . __('These settings may be overridden for individual articles.') . ')'; ?></em></small>
</fieldset></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Other comment settings'); ?></th>
<td><fieldset><legend class="screen-reader-text"><span><?php _e('Other comment settings'); ?></span></legend>
<label for="require_name_email"><input type="checkbox" name="require_name_email" id="require_name_email" value="1" <?php checked('1', get_option('require_name_email')); ?> /> <?php _e('Comment author must fill out name and e-mail'); ?></label>
<br />
<label for="comment_registration">
<input name="comment_registration" type="checkbox" id="comment_registration" value="1" <?php checked('1', get_option('comment_registration')); ?> />
<?php _e('Users must be registered and logged in to comment'); ?>
<?php if ( !get_option( 'users_can_register' ) && is_multisite() ) echo ' ' . __( '(Signup has been disabled. Only members of this site can comment.)' ); ?>
</label>
<br />
<label for="close_comments_for_old_posts">
<input name="close_comments_for_old_posts" type="checkbox" id="close_comments_for_old_posts" value="1" <?php checked('1', get_option('close_comments_for_old_posts')); ?> />
<?php printf( __('Automatically close comments on articles older than %s days'), '</label><input name="close_comments_days_old" type="number" min="0" step="1" id="close_comments_days_old" value="' . esc_attr(get_option('close_comments_days_old')) . '" class="small-text" />'); ?>
<br />
<label for="thread_comments">
<input name="thread_comments" type="checkbox" id="thread_comments" value="1" <?php checked('1', get_option('thread_comments')); ?> />
<?php
$maxdeep = (int) apply_filters( 'thread_comments_depth_max', 10 );
$thread_comments_depth = '</label><select name="thread_comments_depth" id="thread_comments_depth">';
for ( $i = 2; $i <= $maxdeep; $i++ ) {
$thread_comments_depth .= "<option value='" . esc_attr($i) . "'";
if ( get_option('thread_comments_depth') == $i ) $thread_comments_depth .= " selected='selected'";
$thread_comments_depth .= ">$i</option>";
}
$thread_comments_depth .= '</select>';
printf( __('Enable threaded (nested) comments %s levels deep'), $thread_comments_depth );
?><br />
<label for="page_comments">
<input name="page_comments" type="checkbox" id="page_comments" value="1" <?php checked('1', get_option('page_comments')); ?> />
<?php
$default_comments_page = '</label><label for="default_comments_page"><select name="default_comments_page" id="default_comments_page"><option value="newest"';
if ( 'newest' == get_option('default_comments_page') ) $default_comments_page .= ' selected="selected"';
$default_comments_page .= '>' . __('last') . '</option><option value="oldest"';
if ( 'oldest' == get_option('default_comments_page') ) $default_comments_page .= ' selected="selected"';
$default_comments_page .= '>' . __('first') . '</option></select>';
printf( __('Break comments into pages with %1$s top level comments per page and the %2$s page displayed by default'), '</label><label for="comments_per_page"><input name="comments_per_page" type="number" step="1" min="0" id="comments_per_page" value="' . esc_attr(get_option('comments_per_page')) . '" class="small-text" />', $default_comments_page );
?></label>
<br />
<label for="comment_order"><?php
$comment_order = '<select name="comment_order" id="comment_order"><option value="asc"';
if ( 'asc' == get_option('comment_order') ) $comment_order .= ' selected="selected"';
$comment_order .= '>' . __('older') . '</option><option value="desc"';
if ( 'desc' == get_option('comment_order') ) $comment_order .= ' selected="selected"';
$comment_order .= '>' . __('newer') . '</option></select>';
printf( __('Comments should be displayed with the %s comments at the top of each page'), $comment_order );
?></label>
</fieldset></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('E-mail me whenever'); ?></th>
<td><fieldset><legend class="screen-reader-text"><span><?php _e('E-mail me whenever'); ?></span></legend>
<label for="comments_notify">
<input name="comments_notify" type="checkbox" id="comments_notify" value="1" <?php checked('1', get_option('comments_notify')); ?> />
<?php _e('Anyone posts a comment'); ?> </label>
<br />
<label for="moderation_notify">
<input name="moderation_notify" type="checkbox" id="moderation_notify" value="1" <?php checked('1', get_option('moderation_notify')); ?> />
<?php _e('A comment is held for moderation'); ?> </label>
</fieldset></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Before a comment appears'); ?></th>
<td><fieldset><legend class="screen-reader-text"><span><?php _e('Before a comment appears'); ?></span></legend>
<label for="comment_moderation">
<input name="comment_moderation" type="checkbox" id="comment_moderation" value="1" <?php checked('1', get_option('comment_moderation')); ?> />
<?php _e('An administrator must always approve the comment'); ?> </label>
<br />
<label for="comment_whitelist"><input type="checkbox" name="comment_whitelist" id="comment_whitelist" value="1" <?php checked('1', get_option('comment_whitelist')); ?> /> <?php _e('Comment author must have a previously approved comment'); ?></label>
</fieldset></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Comment Moderation'); ?></th>
<td><fieldset><legend class="screen-reader-text"><span><?php _e('Comment Moderation'); ?></span></legend>
<p><label for="comment_max_links"><?php printf(__('Hold a comment in the queue if it contains %s or more links. (A common characteristic of comment spam is a large number of hyperlinks.)'), '<input name="comment_max_links" type="number" step="1" min="0" id="comment_max_links" value="' . esc_attr(get_option('comment_max_links')) . '" class="small-text" />' ); ?></label></p>
<p><label for="moderation_keys"><?php _e('When a comment contains any of these words in its content, name, URL, e-mail, or IP, it will be held in the <a href="edit-comments.php?comment_status=moderated">moderation queue</a>. One word or IP per line. It will match inside words, so “press” will match “WordPress”.'); ?></label></p>
<p>
<textarea name="moderation_keys" rows="10" cols="50" id="moderation_keys" class="large-text code"><?php echo esc_textarea( get_option( 'moderation_keys' ) ); ?></textarea>
</p>
</fieldset></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Comment Blacklist'); ?></th>
<td><fieldset><legend class="screen-reader-text"><span><?php _e('Comment Blacklist'); ?></span></legend>
<p><label for="blacklist_keys"><?php _e('When a comment contains any of these words in its content, name, URL, e-mail, or IP, it will be marked as spam. One word or IP per line. It will match inside words, so “press” will match “WordPress”.'); ?></label></p>
<p>
<textarea name="blacklist_keys" rows="10" cols="50" id="blacklist_keys" class="large-text code"><?php echo esc_textarea( get_option( 'blacklist_keys' ) ); ?></textarea>
</p>
</fieldset></td>
</tr>
<?php do_settings_fields('discussion', 'default'); ?>
</table>
<h3><?php _e('Avatars'); ?></h3>
<p><?php _e('An avatar is an image that follows you from weblog to weblog appearing beside your name when you comment on avatar enabled sites. Here you can enable the display of avatars for people who comment on your site.'); ?></p>
<?php // the above would be a good place to link to codex documentation on the gravatar functions, for putting it in themes. anything like that? ?>
<table class="form-table">
<tr valign="top">
<th scope="row"><?php _e('Avatar Display'); ?></th>
<td><fieldset><legend class="screen-reader-text"><span><?php _e('Avatar Display'); ?></span></legend>
<?php
$yesorno = array( 0 => __( 'Don’t show Avatars' ), 1 => __( 'Show Avatars' ) );
foreach ( $yesorno as $key => $value) {
$selected = (get_option('show_avatars') == $key) ? 'checked="checked"' : '';
echo "\n\t<label><input type='radio' name='show_avatars' value='" . esc_attr($key) . "' $selected/> $value</label><br />";
}
?>
</fieldset></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Maximum Rating'); ?></th>
<td><fieldset><legend class="screen-reader-text"><span><?php _e('Maximum Rating'); ?></span></legend>
<?php
$ratings = array(
/* translators: Content suitability rating: http://bit.ly/89QxZA */
'G' => __('G — Suitable for all audiences'),
/* translators: Content suitability rating: http://bit.ly/89QxZA */
'PG' => __('PG — Possibly offensive, usually for audiences 13 and above'),
/* translators: Content suitability rating: http://bit.ly/89QxZA */
'R' => __('R — Intended for adult audiences above 17'),
/* translators: Content suitability rating: http://bit.ly/89QxZA */
'X' => __('X — Even more mature than above')
);
foreach ($ratings as $key => $rating) :
$selected = (get_option('avatar_rating') == $key) ? 'checked="checked"' : '';
echo "\n\t<label><input type='radio' name='avatar_rating' value='" . esc_attr($key) . "' $selected/> $rating</label><br />";
endforeach;
?>
</fieldset></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Default Avatar'); ?></th>
<td class="defaultavatarpicker"><fieldset><legend class="screen-reader-text"><span><?php _e('Default Avatar'); ?></span></legend>
<?php _e('For users without a custom avatar of their own, you can either display a generic logo or a generated one based on their e-mail address.'); ?><br />
<?php
$avatar_defaults = array(
'mystery' => __('Mystery Man'),
'blank' => __('Blank'),
'gravatar_default' => __('Gravatar Logo'),
'identicon' => __('Identicon (Generated)'),
'wavatar' => __('Wavatar (Generated)'),
'monsterid' => __('MonsterID (Generated)'),
'retro' => __('Retro (Generated)')
);
$avatar_defaults = apply_filters('avatar_defaults', $avatar_defaults);
$default = get_option('avatar_default');
if ( empty($default) )
$default = 'mystery';
$size = 32;
$avatar_list = '';
foreach ( $avatar_defaults as $default_key => $default_name ) {
$selected = ($default == $default_key) ? 'checked="checked" ' : '';
$avatar_list .= "\n\t<label><input type='radio' name='avatar_default' id='avatar_{$default_key}' value='" . esc_attr($default_key) . "' {$selected}/> ";
$avatar = get_avatar( $user_email, $size, $default_key );
$avatar_list .= preg_replace("/src='(.+?)'/", "src='\$1&forcedefault=1'", $avatar);
$avatar_list .= ' ' . $default_name . '</label>';
$avatar_list .= '<br />';
}
echo apply_filters('default_avatar_select', $avatar_list);
?>
</fieldset></td>
</tr>
<?php do_settings_fields('discussion', 'avatars'); ?>
</table>
<?php do_settings_sections('discussion'); ?>
<?php submit_button(); ?>
</form>
</div>
<?php include('./admin-footer.php'); ?>
| 01happy-blog | trunk/myblog/wp-admin/options-discussion.php | PHP | oos | 13,253 |
<?php
/**
* Manage media uploaded file.
*
* There are many filters in here for media. Plugins can extend functionality
* by hooking into the filters.
*
* @package WordPress
* @subpackage Administration
*/
if ( ! isset( $_GET['inline'] ) )
define( 'IFRAME_REQUEST' , true );
/** Load WordPress Administration Bootstrap */
require_once('./admin.php');
if (!current_user_can('upload_files'))
wp_die(__('You do not have permission to upload files.'));
wp_enqueue_script('plupload-handlers');
wp_enqueue_script('image-edit');
wp_enqueue_script('set-post-thumbnail' );
wp_enqueue_style('imgareaselect');
wp_enqueue_script( 'media-gallery' );
@header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
// IDs should be integers
$ID = isset($ID) ? (int) $ID : 0;
$post_id = isset($post_id)? (int) $post_id : 0;
// Require an ID for the edit screen
if ( isset($action) && $action == 'edit' && !$ID )
wp_die( __( 'Cheatin’ uh?' ) );
if ( isset($_GET['inline']) ) {
$errors = array();
if ( ! empty( $_REQUEST['post_id'] ) && ! current_user_can( 'edit_post' , $_REQUEST['post_id'] ) )
wp_die( __( 'Cheatin’ uh?' ) );
if ( isset($_POST['html-upload']) && !empty($_FILES) ) {
check_admin_referer('media-form');
// Upload File button was clicked
$id = media_handle_upload('async-upload', $_REQUEST['post_id']);
unset($_FILES);
if ( is_wp_error($id) ) {
$errors['upload_error'] = $id;
$id = false;
}
}
if ( isset($_GET['upload-page-form']) ) {
$errors = array_merge($errors, (array) media_upload_form_handler());
$location = 'upload.php';
if ( $errors )
$location .= '?message=3';
wp_redirect( admin_url($location) );
exit;
}
if ( isset( $_REQUEST['post_id'] ) )
wp_die( __( 'Cheatin’ uh?' ) );
$title = __('Upload New Media');
$parent_file = 'upload.php';
get_current_screen()->add_help_tab( array(
'id' => 'overview',
'title' => __('Overview'),
'content' =>
'<p>' . __('You can upload media files here without creating a post first. This allows you to upload files to use with posts and pages later and/or to get a web link for a particular file that you can share. There are three options for uploading files:') . '</p>' .
'<ul>' .
'<li>' . __('<strong>Drag and drop</strong> your files into the area below. Multiple files are allowed.') . '</li>' .
'<li>' . __('Clicking <strong>Select Files</strong> opens a navigation window showing you files in your operating system. Selecting <strong>Open</strong> after clicking on the file you want activates a progress bar on the uploader screen.') . '</li>' .
'<li>' . __('Revert to the <strong>Browser Uploader</strong> by clicking the link below the drag and drop box.') . '</li>' .
'</ul>' .
'<p>' . __('Basic image editing is available after upload is complete. Make sure you click Save before leaving this screen.') . '</p>'
) );
get_current_screen()->set_help_sidebar(
'<p><strong>' . __('For more information:') . '</strong></p>' .
'<p>' . __('<a href="http://codex.wordpress.org/Media_Add_New_Screen" target="_blank">Documentation on Uploading Media Files</a>') . '</p>' .
'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
);
require_once('./admin-header.php');
$form_class = 'media-upload-form type-form validate';
if ( get_user_setting('uploader') )
$form_class .= ' html-uploader';
?>
<div class="wrap">
<?php screen_icon(); ?>
<h2><?php echo esc_html( $title ); ?></h2>
<form enctype="multipart/form-data" method="post" action="<?php echo admin_url('media-upload.php?inline=&upload-page-form='); ?>" class="<?php echo $form_class; ?>" id="file-form">
<?php media_upload_form(); ?>
<script type="text/javascript">
jQuery(function($){
var preloaded = $(".media-item.preloaded");
if ( preloaded.length > 0 ) {
preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');});
}
updateMediaForm();
post_id = 0;
shortform = 1;
});
</script>
<input type="hidden" name="post_id" id="post_id" value="0" />
<?php wp_nonce_field('media-form'); ?>
<div id="media-items" class="hide-if-no-js"></div>
<?php submit_button( __( 'Save all changes' ), 'button savebutton hidden', 'save' ); ?>
</form>
</div>
<?php
include('./admin-footer.php');
} else {
if ( ! empty( $_REQUEST['post_id'] ) && ! current_user_can( 'edit_post' , $_REQUEST['post_id'] ) )
wp_die( __( 'Cheatin’ uh?' ) );
// upload type: image, video, file, ..?
if ( isset($_GET['type']) )
$type = strval($_GET['type']);
else
$type = apply_filters('media_upload_default_type', 'file');
// tab: gallery, library, or type-specific
if ( isset($_GET['tab']) )
$tab = strval($_GET['tab']);
else
$tab = apply_filters('media_upload_default_tab', 'type');
$body_id = 'media-upload';
// let the action code decide how to handle the request
if ( $tab == 'type' || $tab == 'type_url' || ! array_key_exists( $tab , media_upload_tabs() ) )
do_action("media_upload_$type");
else
do_action("media_upload_$tab");
}
| 01happy-blog | trunk/myblog/wp-admin/media-upload.php | PHP | oos | 5,099 |
<?php
/**
* Multisite sites administration panel.
*
* @package WordPress
* @subpackage Multisite
* @since 3.0.0
*/
require_once( './admin.php' );
wp_redirect( network_admin_url('sites.php') );
exit;
| 01happy-blog | trunk/myblog/wp-admin/ms-sites.php | PHP | oos | 207 |
<?php
/**
* Edit tag form for inclusion in administration panels.
*
* @package WordPress
* @subpackage Administration
*/
// don't load directly
if ( !defined('ABSPATH') )
die('-1');
if ( empty($tag_ID) ) { ?>
<div id="message" class="updated"><p><strong><?php _e( 'You did not select an item for editing.' ); ?></strong></p></div>
<?php
return;
}
// Back compat hooks
if ( 'category' == $taxonomy )
do_action('edit_category_form_pre', $tag );
elseif ( 'link_category' == $taxonomy )
do_action('edit_link_category_form_pre', $tag );
else
do_action('edit_tag_form_pre', $tag);
do_action($taxonomy . '_pre_edit_form', $tag, $taxonomy); ?>
<div class="wrap">
<?php screen_icon(); ?>
<h2><?php echo $tax->labels->edit_item; ?></h2>
<div id="ajax-response"></div>
<form name="edittag" id="edittag" method="post" action="edit-tags.php" class="validate">
<input type="hidden" name="action" value="editedtag" />
<input type="hidden" name="tag_ID" value="<?php echo esc_attr($tag->term_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); ?>
<table class="form-table">
<tr class="form-field form-required">
<th scope="row" valign="top"><label for="name"><?php _ex('Name', 'Taxonomy Name'); ?></label></th>
<td><input name="name" id="name" type="text" value="<?php if ( isset( $tag->name ) ) echo esc_attr($tag->name); ?>" size="40" aria-required="true" />
<p class="description"><?php _e('The name is how it appears on your site.'); ?></p></td>
</tr>
<?php if ( !global_terms_enabled() ) { ?>
<tr class="form-field">
<th scope="row" valign="top"><label for="slug"><?php _ex('Slug', 'Taxonomy Slug'); ?></label></th>
<td><input name="slug" id="slug" type="text" value="<?php if ( isset( $tag->slug ) ) echo esc_attr(apply_filters('editable_slug', $tag->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>
</tr>
<?php } ?>
<?php if ( is_taxonomy_hierarchical($taxonomy) ) : ?>
<tr class="form-field">
<th scope="row" valign="top"><label for="parent"><?php _ex('Parent', 'Taxonomy Parent'); ?></label></th>
<td>
<?php wp_dropdown_categories(array('hide_empty' => 0, 'hide_if_empty' => false, 'name' => 'parent', 'orderby' => 'name', 'taxonomy' => $taxonomy, 'selected' => $tag->parent, 'exclude_tree' => $tag->term_id, 'hierarchical' => true, 'show_option_none' => __('None'))); ?>
<?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 endif; ?>
</td>
</tr>
<?php endif; // is_taxonomy_hierarchical() ?>
<tr class="form-field">
<th scope="row" valign="top"><label for="description"><?php _ex('Description', 'Taxonomy Description'); ?></label></th>
<td><textarea name="description" id="description" rows="5" cols="50" class="large-text"><?php echo $tag->description; // textarea_escaped ?></textarea><br />
<span class="description"><?php _e('The description is not prominent by default, however some themes may show it.'); ?></span></td>
</tr>
<?php
// Back compat hooks
if ( 'category' == $taxonomy )
do_action('edit_category_form_fields', $tag);
elseif ( 'link_category' == $taxonomy )
do_action('edit_link_category_form_fields', $tag);
else
do_action('edit_tag_form_fields', $tag);
do_action($taxonomy . '_edit_form_fields', $tag, $taxonomy);
?>
</table>
<?php
// Back compat hooks
if ( 'category' == $taxonomy )
do_action('edit_category_form', $tag);
elseif ( 'link_category' == $taxonomy )
do_action('edit_link_category_form', $tag);
else
do_action('edit_tag_form', $tag);
do_action($taxonomy . '_edit_form', $tag, $taxonomy);
submit_button( __('Update') );
?>
</form>
</div>
| 01happy-blog | trunk/myblog/wp-admin/edit-tag-form.php | PHP | oos | 4,075 |
<?php
/**
* Permalink Settings Administration Screen.
*
* @package WordPress
* @subpackage Administration
*/
/** WordPress Administration Bootstrap */
require_once('./admin.php');
if ( ! current_user_can( 'manage_options' ) )
wp_die( __( 'You do not have sufficient permissions to manage options for this site.' ) );
$title = __('Permalink Settings');
$parent_file = 'options-general.php';
get_current_screen()->add_help_tab( array(
'id' => 'overview',
'title' => __('Overview'),
'content' => '<p>' . __('Permalinks are the permanent URLs to your individual pages and blog posts, as well as your category and tag archives. A permalink is the web address used to link to your content. The URL to each post should be permanent, and never change — hence the name permalink.') . '</p>' .
'<p>' . __('This screen allows you to choose your default permalink structure. You can choose from common settings or create custom URL structures.') . '</p>' .
'<p>' . __('You must click the Save Changes button at the bottom of the screen for new settings to take effect.') . '</p>',
) );
get_current_screen()->add_help_tab( array(
'id' => 'common-settings',
'title' => __('Common Settings'),
'content' => '<p>' . __('Many people choose to use “pretty permalinks,” URLs that contain useful information such as the post title rather than generic post ID numbers. You can choose from any of the permalink formats under Common Settings, or can craft your own if you select Custom Structure.') . '</p>' .
'<p>' . __('If you pick an option other than Default, your general URL path with structure tags, terms surrounded by <code>%</code>, will also appear in the custom structure field and your path can be further modified there.') . '</p>' .
'<p>' . __('When you assign multiple categories or tags to a post, only one can show up in the permalink: the lowest numbered category. This applies if your custom structure includes <code>%category%</code> or <code>%tag%</code>.') . '</p>' .
'<p>' . __('You must click the Save Changes button at the bottom of the screen for new settings to take effect.') . '</p>',
) );
get_current_screen()->add_help_tab( array(
'id' => 'custom-structures',
'title' => __('Custom Structures'),
'content' => '<p>' . __('The Optional fields let you customize the “category” and “tag” base names that will appear in archive URLs. For example, the page listing all posts in the “Uncategorized” category could be <code>/topics/uncategorized</code> instead of <code>/category/uncategorized</code>.') . '</p>' .
'<p>' . __('You must click the Save Changes button at the bottom of the screen for new settings to take effect.') . '</p>',
) );
get_current_screen()->set_help_sidebar(
'<p><strong>' . __('For more information:') . '</strong></p>' .
'<p>' . __('<a href="http://codex.wordpress.org/Settings_Permalinks_Screen" target="_blank">Documentation on Permalinks Settings</a>') . '</p>' .
'<p>' . __('<a href="http://codex.wordpress.org/Using_Permalinks" target="_blank">Documentation on Using Permalinks</a>') . '</p>' .
'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
);
/**
* Display JavaScript on the page.
*
* @package WordPress
* @subpackage Permalink_Settings_Screen
*/
function add_js() {
?>
<script type="text/javascript">
//<![CDATA[
jQuery(document).ready(function() {
jQuery('input:radio.tog').change(function() {
if ( 'custom' == this.value )
return;
jQuery('#permalink_structure').val( this.value );
});
jQuery('#permalink_structure').focus(function() {
jQuery("#custom_selection").attr('checked', 'checked');
});
});
//]]>
</script>
<?php
}
add_filter('admin_head', 'add_js');
include('./admin-header.php');
$home_path = get_home_path();
$iis7_permalinks = iis7_supports_permalinks();
$prefix = $blog_prefix = '';
if ( ! got_mod_rewrite() && ! $iis7_permalinks )
$prefix = '/index.php';
if ( is_multisite() && !is_subdomain_install() && is_main_site() )
$blog_prefix = '/blog';
if ( isset($_POST['permalink_structure']) || isset($_POST['category_base']) ) {
check_admin_referer('update-permalink');
if ( isset( $_POST['permalink_structure'] ) ) {
if ( isset( $_POST['selection'] ) && 'custom' != $_POST['selection'] )
$permalink_structure = $_POST['selection'];
else
$permalink_structure = $_POST['permalink_structure'];
if ( ! empty( $permalink_structure ) ) {
$permalink_structure = preg_replace( '#/+#', '/', '/' . str_replace( '#', '', $permalink_structure ) );
if ( $prefix && $blog_prefix )
$permalink_structure = $prefix . preg_replace( '#^/?index\.php#', '', $permalink_structure );
else
$permalink_structure = $blog_prefix . $permalink_structure;
}
$wp_rewrite->set_permalink_structure( $permalink_structure );
}
if ( isset( $_POST['category_base'] ) ) {
$category_base = $_POST['category_base'];
if ( ! empty( $category_base ) )
$category_base = $blog_prefix . preg_replace('#/+#', '/', '/' . str_replace( '#', '', $category_base ) );
$wp_rewrite->set_category_base( $category_base );
}
if ( isset( $_POST['tag_base'] ) ) {
$tag_base = $_POST['tag_base'];
if ( ! empty( $tag_base ) )
$tag_base = $blog_prefix . preg_replace('#/+#', '/', '/' . str_replace( '#', '', $tag_base ) );
$wp_rewrite->set_tag_base( $tag_base );
}
create_initial_taxonomies();
}
$permalink_structure = get_option('permalink_structure');
$category_base = get_option('category_base');
$tag_base = get_option( 'tag_base' );
if ( $iis7_permalinks ) {
if ( ( ! file_exists($home_path . 'web.config') && win_is_writable($home_path) ) || win_is_writable($home_path . 'web.config') )
$writable = true;
else
$writable = false;
} else {
if ( ( ! file_exists($home_path . '.htaccess') && is_writable($home_path) ) || is_writable($home_path . '.htaccess') )
$writable = true;
else
$writable = false;
}
if ( $wp_rewrite->using_index_permalinks() )
$usingpi = true;
else
$usingpi = false;
flush_rewrite_rules();
if (isset($_POST['submit'])) : ?>
<div id="message" class="updated"><p><?php
if ( ! is_multisite() ) {
if ( $iis7_permalinks ) {
if ( $permalink_structure && ! $usingpi && ! $writable )
_e('You should update your web.config now.');
else if ( $permalink_structure && ! $usingpi && $writable )
_e('Permalink structure updated. Remove write access on web.config file now!');
else
_e('Permalink structure updated.');
} else {
if ( $permalink_structure && ! $usingpi && ! $writable )
_e('You should update your .htaccess now.');
else
_e('Permalink structure updated.');
}
} else {
_e('Permalink structure updated.');
}
?>
</p></div>
<?php endif; ?>
<div class="wrap">
<?php screen_icon(); ?>
<h2><?php echo esc_html( $title ); ?></h2>
<form name="form" action="options-permalink.php" method="post">
<?php wp_nonce_field('update-permalink') ?>
<p><?php _e('By default WordPress uses web <abbr title="Universal Resource Locator">URL</abbr>s which have question marks and lots of numbers in them, however WordPress offers you the ability to create a custom URL structure for your permalinks and archives. This can improve the aesthetics, usability, and forward-compatibility of your links. A <a href="http://codex.wordpress.org/Using_Permalinks">number of tags are available</a>, and here are some examples to get you started.'); ?></p>
<?php
if ( is_multisite() && !is_subdomain_install() && is_main_site() ) {
$permalink_structure = preg_replace( '|^/?blog|', '', $permalink_structure );
$category_base = preg_replace( '|^/?blog|', '', $category_base );
$tag_base = preg_replace( '|^/?blog|', '', $tag_base );
}
$structures = array(
0 => '',
1 => $prefix . '/%year%/%monthnum%/%day%/%postname%/',
2 => $prefix . '/%year%/%monthnum%/%postname%/',
3 => $prefix . '/' . _x( 'archives', 'sample permalink base' ) . '/%post_id%',
4 => $prefix . '/%postname%/',
);
?>
<h3><?php _e('Common Settings'); ?></h3>
<table class="form-table">
<tr>
<th><label><input name="selection" type="radio" value="" class="tog" <?php checked('', $permalink_structure); ?> /> <?php _e('Default'); ?></label></th>
<td><code><?php echo get_option('home'); ?>/?p=123</code></td>
</tr>
<tr>
<th><label><input name="selection" type="radio" value="<?php echo esc_attr($structures[1]); ?>" class="tog" <?php checked($structures[1], $permalink_structure); ?> /> <?php _e('Day and name'); ?></label></th>
<td><code><?php echo get_option('home') . $blog_prefix . $prefix . '/' . date('Y') . '/' . date('m') . '/' . date('d') . '/' . _x( 'sample-post', 'sample permalink structure' ) . '/'; ?></code></td>
</tr>
<tr>
<th><label><input name="selection" type="radio" value="<?php echo esc_attr($structures[2]); ?>" class="tog" <?php checked($structures[2], $permalink_structure); ?> /> <?php _e('Month and name'); ?></label></th>
<td><code><?php echo get_option('home') . $blog_prefix . $prefix . '/' . date('Y') . '/' . date('m') . '/' . _x( 'sample-post', 'sample permalink structure' ) . '/'; ?></code></td>
</tr>
<tr>
<th><label><input name="selection" type="radio" value="<?php echo esc_attr($structures[3]); ?>" class="tog" <?php checked($structures[3], $permalink_structure); ?> /> <?php _e('Numeric'); ?></label></th>
<td><code><?php echo get_option('home') . $blog_prefix . $prefix . '/' . _x( 'archives', 'sample permalink base' ) . '/123'; ?></code></td>
</tr>
<tr>
<th><label><input name="selection" type="radio" value="<?php echo esc_attr($structures[4]); ?>" class="tog" <?php checked($structures[4], $permalink_structure); ?> /> <?php _e('Post name'); ?></label></th>
<td><code><?php echo get_option('home') . $blog_prefix . $prefix . '/' . _x( 'sample-post', 'sample permalink structure' ) . '/'; ?></code></td>
</tr>
<tr>
<th>
<label><input name="selection" id="custom_selection" type="radio" value="custom" class="tog" <?php checked( !in_array($permalink_structure, $structures) ); ?> />
<?php _e('Custom Structure'); ?>
</label>
</th>
<td>
<?php echo $blog_prefix; ?>
<input name="permalink_structure" id="permalink_structure" type="text" value="<?php echo esc_attr($permalink_structure); ?>" class="regular-text code" />
</td>
</tr>
</table>
<h3><?php _e('Optional'); ?></h3>
<?php
$suffix = '';
if ( ! $is_apache && ! $iis7_permalinks )
$suffix = 'index.php/';
?>
<p><?php
/* translators: %s is a placeholder that must come at the start of the URL path. */
printf( __('If you like, you may enter custom structures for your category and tag <abbr title="Universal Resource Locator">URL</abbr>s here. For example, using <code>topics</code> as your category base would make your category links like <code>http://example.org/%stopics/uncategorized/</code>. If you leave these blank the defaults will be used.'), $suffix ); ?></p>
<table class="form-table">
<tr>
<th><label for="category_base"><?php /* translators: prefix for category permalinks */ _e('Category base'); ?></label></th>
<td><?php echo $blog_prefix; ?> <input name="category_base" id="category_base" type="text" value="<?php echo esc_attr( $category_base ); ?>" class="regular-text code" /></td>
</tr>
<tr>
<th><label for="tag_base"><?php _e('Tag base'); ?></label></th>
<td><?php echo $blog_prefix; ?> <input name="tag_base" id="tag_base" type="text" value="<?php echo esc_attr($tag_base); ?>" class="regular-text code" /></td>
</tr>
<?php do_settings_fields('permalink', 'optional'); ?>
</table>
<?php do_settings_sections('permalink'); ?>
<?php submit_button(); ?>
</form>
<?php if ( !is_multisite() ) { ?>
<?php if ( $iis7_permalinks ) :
if ( isset($_POST['submit']) && $permalink_structure && ! $usingpi && ! $writable ) :
if ( file_exists($home_path . 'web.config') ) : ?>
<p><?php _e('If your <code>web.config</code> file were <a href="http://codex.wordpress.org/Changing_File_Permissions">writable</a>, we could do this automatically, but it isn’t so this is the url rewrite rule you should have in your <code>web.config</code> file. Click in the field and press <kbd>CTRL + a</kbd> to select all. Then insert this rule inside of the <code>/<configuration>/<system.webServer>/<rewrite>/<rules></code> element in <code>web.config</code> file.') ?></p>
<form action="options-permalink.php" method="post">
<?php wp_nonce_field('update-permalink') ?>
<p><textarea rows="9" class="large-text readonly" name="rules" id="rules" readonly="readonly"><?php echo esc_textarea( $wp_rewrite->iis7_url_rewrite_rules() ); ?></textarea></p>
</form>
<p><?php _e('If you temporarily make your <code>web.config</code> file writable for us to generate rewrite rules automatically, do not forget to revert the permissions after rule has been saved.') ?></p>
<?php else : ?>
<p><?php _e('If the root directory of your site were <a href="http://codex.wordpress.org/Changing_File_Permissions">writable</a>, we could do this automatically, but it isn’t so this is the url rewrite rule you should have in your <code>web.config</code> file. Create a new file, called <code>web.config</code> in the root directory of your site. Click in the field and press <kbd>CTRL + a</kbd> to select all. Then insert this code into the <code>web.config</code> file.') ?></p>
<form action="options-permalink.php" method="post">
<?php wp_nonce_field('update-permalink') ?>
<p><textarea rows="18" class="large-text readonly" name="rules" id="rules" readonly="readonly"><?php echo esc_textarea( $wp_rewrite->iis7_url_rewrite_rules(true) ); ?></textarea></p>
</form>
<p><?php _e('If you temporarily make your site’s root directory writable for us to generate the <code>web.config</code> file automatically, do not forget to revert the permissions after the file has been created.') ?></p>
<?php endif; ?>
<?php endif; ?>
<?php else :
if ( $permalink_structure && ! $usingpi && ! $writable ) : ?>
<p><?php _e('If your <code>.htaccess</code> file were <a href="http://codex.wordpress.org/Changing_File_Permissions">writable</a>, we could do this automatically, but it isn’t so these are the mod_rewrite rules you should have in your <code>.htaccess</code> file. Click in the field and press <kbd>CTRL + a</kbd> to select all.') ?></p>
<form action="options-permalink.php" method="post">
<?php wp_nonce_field('update-permalink') ?>
<p><textarea rows="6" class="large-text readonly" name="rules" id="rules" readonly="readonly"><?php echo esc_textarea( $wp_rewrite->mod_rewrite_rules() ); ?></textarea></p>
</form>
<?php endif; ?>
<?php endif; ?>
<?php } // multisite ?>
</div>
<?php require('./admin-footer.php'); ?>
| 01happy-blog | trunk/myblog/wp-admin/options-permalink.php | PHP | oos | 14,669 |
<?php
/**
* Upgrade WordPress Page.
*
* @package WordPress
* @subpackage Administration
*/
/**
* We are upgrading WordPress.
*
* @since 1.5.1
* @var bool
*/
define( 'WP_INSTALLING', true );
/** Load WordPress Bootstrap */
require( '../wp-load.php' );
timer_start();
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
delete_site_transient('update_core');
if ( isset( $_GET['step'] ) )
$step = $_GET['step'];
else
$step = 0;
// Do it. No output.
if ( 'upgrade_db' === $step ) {
wp_upgrade();
die( '0' );
}
$step = (int) $step;
$php_version = phpversion();
$mysql_version = $wpdb->db_version();
$php_compat = version_compare( $php_version, $required_php_version, '>=' );
if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) )
$mysql_compat = true;
else
$mysql_compat = version_compare( $mysql_version, $required_mysql_version, '>=' );
@header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
<head>
<meta http-equiv="Content-Type" content="<?php bloginfo( 'html_type' ); ?>; charset=<?php echo get_option( 'blog_charset' ); ?>" />
<title><?php _e( 'WordPress › Update' ); ?></title>
<?php
wp_admin_css( 'install', true );
wp_admin_css( 'ie', true );
?>
</head>
<body>
<h1 id="logo"><img alt="WordPress" src="images/wordpress-logo.png?ver=20120216" /></h1>
<?php if ( get_option( 'db_version' ) == $wp_db_version || !is_blog_installed() ) : ?>
<h2><?php _e( 'No Update Required' ); ?></h2>
<p><?php _e( 'Your WordPress database is already up-to-date!' ); ?></p>
<p class="step"><a class="button" href="<?php echo get_option( 'home' ); ?>/"><?php _e( 'Continue' ); ?></a></p>
<?php elseif ( !$php_compat || !$mysql_compat ) :
if ( !$mysql_compat && !$php_compat )
printf( __('You cannot update because <a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires PHP version %2$s or higher and MySQL version %3$s or higher. You are running PHP version %4$s and MySQL version %5$s.'), $wp_version, $required_php_version, $required_mysql_version, $php_version, $mysql_version );
elseif ( !$php_compat )
printf( __('You cannot update because <a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires PHP version %2$s or higher. You are running version %3$s.'), $wp_version, $required_php_version, $php_version );
elseif ( !$mysql_compat )
printf( __('You cannot update because <a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires MySQL version %2$s or higher. You are running version %3$s.'), $wp_version, $required_mysql_version, $mysql_version );
?>
<?php else :
switch ( $step ) :
case 0:
$goback = stripslashes( wp_get_referer() );
$goback = esc_url_raw( $goback );
$goback = urlencode( $goback );
?>
<h2><?php _e( 'Database Update Required' ); ?></h2>
<p><?php _e( 'WordPress has been updated! Before we send you on your way, we have to update your database to the newest version.' ); ?></p>
<p><?php _e( 'The update process may take a little while, so please be patient.' ); ?></p>
<p class="step"><a class="button" href="upgrade.php?step=1&backto=<?php echo $goback; ?>"><?php _e( 'Update WordPress Database' ); ?></a></p>
<?php
break;
case 1:
wp_upgrade();
$backto = !empty($_GET['backto']) ? stripslashes( urldecode( $_GET['backto'] ) ) : __get_option( 'home' ) . '/';
$backto = esc_url( $backto );
$backto = wp_validate_redirect($backto, __get_option( 'home' ) . '/');
?>
<h2><?php _e( 'Update Complete' ); ?></h2>
<p><?php _e( 'Your WordPress database has been successfully updated!' ); ?></p>
<p class="step"><a class="button" href="<?php echo $backto; ?>"><?php _e( 'Continue' ); ?></a></p>
<!--
<pre>
<?php printf( __( '%s queries' ), $wpdb->num_queries ); ?>
<?php printf( __( '%s seconds' ), timer_stop( 0 ) ); ?>
</pre>
-->
<?php
break;
endswitch;
endif;
?>
</body>
</html>
| 01happy-blog | trunk/myblog/wp-admin/upgrade.php | PHP | oos | 4,008 |
<?php
/**
* New Post Administration Screen.
*
* @package WordPress
* @subpackage Administration
*/
/** Load WordPress Administration Bootstrap */
require_once('./admin.php');
if ( !isset($_GET['post_type']) )
$post_type = 'post';
elseif ( in_array( $_GET['post_type'], get_post_types( array('show_ui' => true ) ) ) )
$post_type = $_GET['post_type'];
else
wp_die( __('Invalid post type') );
$post_type_object = get_post_type_object( $post_type );
if ( 'post' == $post_type ) {
$parent_file = 'edit.php';
$submenu_file = 'post-new.php';
} else {
$submenu_file = "post-new.php?post_type=$post_type";
if ( isset( $post_type_object ) && $post_type_object->show_in_menu && $post_type_object->show_in_menu !== true ) {
$parent_file = $post_type_object->show_in_menu;
if ( ! isset( $_registered_pages[ get_plugin_page_hookname( "post-new.php?post_type=$post_type", $post_type_object->show_in_menu ) ] ) )
$submenu_file = $parent_file;
} else {
$parent_file = "edit.php?post_type=$post_type";
}
}
$title = $post_type_object->labels->add_new_item;
$editing = true;
if ( ! current_user_can( $post_type_object->cap->edit_posts ) )
wp_die( __( 'Cheatin’ uh?' ) );
// Schedule auto-draft cleanup
if ( ! wp_next_scheduled( 'wp_scheduled_auto_draft_delete' ) )
wp_schedule_event( time(), 'daily', 'wp_scheduled_auto_draft_delete' );
wp_enqueue_script('autosave');
// Show post form.
$post = get_default_post_to_edit( $post_type, true );
$post_ID = $post->ID;
include('edit-form-advanced.php');
include('./admin-footer.php');
| 01happy-blog | trunk/myblog/wp-admin/post-new.php | PHP | oos | 1,550 |
<?php
/**
* Users administration panel.
*
* @package WordPress
* @subpackage Administration
*/
/** WordPress Administration Bootstrap */
require_once( './admin.php' );
if ( ! current_user_can( 'list_users' ) )
wp_die( __( 'Cheatin’ uh?' ) );
$wp_list_table = _get_list_table('WP_Users_List_Table');
$pagenum = $wp_list_table->get_pagenum();
$title = __('Users');
$parent_file = 'users.php';
add_screen_option( 'per_page', array('label' => _x( 'Users', 'users per page (screen options)' )) );
// contextual help - choose Help on the top right of admin panel to preview this.
get_current_screen()->add_help_tab( array(
'id' => 'overview',
'title' => __('Overview'),
'content' => '<p>' . __('This screen lists all the existing users for your site. Each user has one of five defined roles as set by the site admin: Site Administrator, Editor, Author, Contributor, or Subscriber. Users with roles other than Administrator will see fewer options in the dashboard navigation when they are logged in, based on their role.') . '</p>' .
'<p>' . __('To add a new user for your site, click the Add New button at the top of the screen or Add New in the Users menu section.') . '</p>'
) ) ;
get_current_screen()->add_help_tab( array(
'id' => 'screen-display',
'title' => __('Screen Display'),
'content' => '<p>' . __('You can customize the display of this screen in a number of ways:') . '</p>' .
'<ul>' .
'<li>' . __('You can hide/display columns based on your needs and decide how many users to list per screen using the Screen Options tab.') . '</li>' .
'<li>' . __('You can filter the list of users by User Role using the text links in the upper left to show All, Administrator, Editor, Author, Contributor, or Subscriber. The default view is to show all users. Unused User Roles are not listed.') . '</li>' .
'<li>' . __('You can view all posts made by a user by clicking on the number under the Posts column.') . '</li>' .
'</ul>'
) );
$help = '<p>' . __('Hovering over a row in the users list will display action links that allow you to manage users. You can perform the following actions:') . '</p>' .
'<ul>' .
'<li>' . __('Edit takes you to the editable profile screen for that user. You can also reach that screen by clicking on the username.') . '</li>';
if ( is_multisite() )
$help .= '<li>' . __( 'Remove allows you to remove a user from your site. It does not delete their posts. You can also remove multiple users at once by using Bulk Actions.' ) . '</li>';
else
$help .= '<li>' . __( 'Delete brings you to the Delete Users screen for confirmation, where you can permanently remove a user from your site and delete their posts. You can also delete multiple users at once by using Bulk Actions.' ) . '</li>';
$help .= '</ul>';
get_current_screen()->add_help_tab( array(
'id' => 'actions',
'title' => __('Actions'),
'content' => $help,
) );
unset( $help );
get_current_screen()->set_help_sidebar(
'<p><strong>' . __('For more information:') . '</strong></p>' .
'<p>' . __('<a href="http://codex.wordpress.org/Users_Screen" target="_blank">Documentation on Managing Users</a>') . '</p>' .
'<p>' . __('<a href="http://codex.wordpress.org/Roles_and_Capabilities" target="_blank">Descriptions of Roles and Capabilities</a>') . '</p>' .
'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
);
if ( empty($_REQUEST) ) {
$referer = '<input type="hidden" name="wp_http_referer" value="'. esc_attr(stripslashes($_SERVER['REQUEST_URI'])) . '" />';
} elseif ( isset($_REQUEST['wp_http_referer']) ) {
$redirect = remove_query_arg(array('wp_http_referer', 'updated', 'delete_count'), stripslashes($_REQUEST['wp_http_referer']));
$referer = '<input type="hidden" name="wp_http_referer" value="' . esc_attr($redirect) . '" />';
} else {
$redirect = 'users.php';
$referer = '';
}
$update = '';
switch ( $wp_list_table->current_action() ) {
/* Bulk Dropdown menu Role changes */
case 'promote':
check_admin_referer('bulk-users');
if ( ! current_user_can( 'promote_users' ) )
wp_die( __( 'You can’t edit that user.' ) );
if ( empty($_REQUEST['users']) ) {
wp_redirect($redirect);
exit();
}
$editable_roles = get_editable_roles();
if ( empty( $editable_roles[$_REQUEST['new_role']] ) )
wp_die(__('You can’t give users that role.'));
$userids = $_REQUEST['users'];
$update = 'promote';
foreach ( $userids as $id ) {
$id = (int) $id;
if ( ! current_user_can('promote_user', $id) )
wp_die(__('You can’t edit that user.'));
// The new role of the current user must also have the promote_users cap or be a multisite super admin
if ( $id == $current_user->ID && ! $wp_roles->role_objects[ $_REQUEST['new_role'] ]->has_cap('promote_users')
&& ! ( is_multisite() && is_super_admin() ) ) {
$update = 'err_admin_role';
continue;
}
// If the user doesn't already belong to the blog, bail.
if ( is_multisite() && !is_user_member_of_blog( $id ) )
wp_die(__('Cheatin’ uh?'));
$user = new WP_User($id);
$user->set_role($_REQUEST['new_role']);
}
wp_redirect(add_query_arg('update', $update, $redirect));
exit();
break;
case 'dodelete':
if ( is_multisite() )
wp_die( __('User deletion is not allowed from this screen.') );
check_admin_referer('delete-users');
if ( empty($_REQUEST['users']) ) {
wp_redirect($redirect);
exit();
}
if ( ! current_user_can( 'delete_users' ) )
wp_die(__('You can’t delete users.'));
$userids = $_REQUEST['users'];
$update = 'del';
$delete_count = 0;
foreach ( (array) $userids as $id) {
$id = (int) $id;
if ( ! current_user_can( 'delete_user', $id ) )
wp_die(__( 'You can’t delete that user.' ) );
if ( $id == $current_user->ID ) {
$update = 'err_admin_del';
continue;
}
switch ( $_REQUEST['delete_option'] ) {
case 'delete':
if ( current_user_can('delete_user', $id) )
wp_delete_user($id);
break;
case 'reassign':
if ( current_user_can('delete_user', $id) )
wp_delete_user($id, $_REQUEST['reassign_user']);
break;
}
++$delete_count;
}
$redirect = add_query_arg( array('delete_count' => $delete_count, 'update' => $update), $redirect);
wp_redirect($redirect);
exit();
break;
case 'delete':
if ( is_multisite() )
wp_die( __('User deletion is not allowed from this screen.') );
check_admin_referer('bulk-users');
if ( empty($_REQUEST['users']) && empty($_REQUEST['user']) ) {
wp_redirect($redirect);
exit();
}
if ( ! current_user_can( 'delete_users' ) )
$errors = new WP_Error( 'edit_users', __( 'You can’t delete users.' ) );
if ( empty($_REQUEST['users']) )
$userids = array(intval($_REQUEST['user']));
else
$userids = (array) $_REQUEST['users'];
include ('admin-header.php');
?>
<form action="" method="post" name="updateusers" id="updateusers">
<?php wp_nonce_field('delete-users') ?>
<?php echo $referer; ?>
<div class="wrap">
<?php screen_icon(); ?>
<h2><?php _e('Delete Users'); ?></h2>
<p><?php echo _n( 'You have specified this user for deletion:', 'You have specified these users for deletion:', count( $userids ) ); ?></p>
<ul>
<?php
$go_delete = 0;
foreach ( $userids as $id ) {
$id = (int) $id;
$user = new WP_User($id);
if ( $id == $current_user->ID ) {
echo "<li>" . sprintf(__('ID #%1s: %2s <strong>The current user will not be deleted.</strong>'), $id, $user->user_login) . "</li>\n";
} else {
echo "<li><input type=\"hidden\" name=\"users[]\" value=\"" . esc_attr($id) . "\" />" . sprintf(__('ID #%1s: %2s'), $id, $user->user_login) . "</li>\n";
$go_delete++;
}
}
?>
</ul>
<?php if ( $go_delete ) : ?>
<fieldset><p><legend><?php echo _n( 'What should be done with posts and links owned by this user?', 'What should be done with posts and links owned by these users?', $go_delete ); ?></legend></p>
<ul style="list-style:none;">
<li><label><input type="radio" id="delete_option0" name="delete_option" value="delete" checked="checked" />
<?php _e('Delete all posts and links.'); ?></label></li>
<li><input type="radio" id="delete_option1" name="delete_option" value="reassign" />
<?php echo '<label for="delete_option1">'.__('Attribute all posts and links to:').'</label>';
wp_dropdown_users( array( 'name' => 'reassign_user', 'exclude' => array_diff( $userids, array($current_user->ID) ) ) ); ?></li>
</ul></fieldset>
<input type="hidden" name="action" value="dodelete" />
<?php submit_button( __('Confirm Deletion'), 'secondary' ); ?>
<?php else : ?>
<p><?php _e('There are no valid users selected for deletion.'); ?></p>
<?php endif; ?>
</div>
</form>
<?php
break;
case 'doremove':
check_admin_referer('remove-users');
if ( ! is_multisite() )
wp_die( __( 'You can’t remove users.' ) );
if ( empty($_REQUEST['users']) ) {
wp_redirect($redirect);
exit;
}
if ( ! current_user_can( 'remove_users' ) )
wp_die( __( 'You can’t remove users.' ) );
$userids = $_REQUEST['users'];
$update = 'remove';
foreach ( $userids as $id ) {
$id = (int) $id;
if ( $id == $current_user->ID && !is_super_admin() ) {
$update = 'err_admin_remove';
continue;
}
if ( !current_user_can('remove_user', $id) ) {
$update = 'err_admin_remove';
continue;
}
remove_user_from_blog($id, $blog_id);
}
$redirect = add_query_arg( array('update' => $update), $redirect);
wp_redirect($redirect);
exit;
break;
case 'remove':
check_admin_referer('bulk-users');
if ( ! is_multisite() )
wp_die( __( 'You can’t remove users.' ) );
if ( empty($_REQUEST['users']) && empty($_REQUEST['user']) ) {
wp_redirect($redirect);
exit();
}
if ( !current_user_can('remove_users') )
$error = new WP_Error('edit_users', __('You can’t remove users.'));
if ( empty($_REQUEST['users']) )
$userids = array(intval($_REQUEST['user']));
else
$userids = $_REQUEST['users'];
include ('admin-header.php');
?>
<form action="" method="post" name="updateusers" id="updateusers">
<?php wp_nonce_field('remove-users') ?>
<?php echo $referer; ?>
<div class="wrap">
<?php screen_icon(); ?>
<h2><?php _e('Remove Users from Site'); ?></h2>
<p><?php _e('You have specified these users for removal:'); ?></p>
<ul>
<?php
$go_remove = false;
foreach ( $userids as $id ) {
$id = (int) $id;
$user = new WP_User($id);
if ( $id == $current_user->ID && !is_super_admin() ) {
echo "<li>" . sprintf(__('ID #%1s: %2s <strong>The current user will not be removed.</strong>'), $id, $user->user_login) . "</li>\n";
} elseif ( !current_user_can('remove_user', $id) ) {
echo "<li>" . sprintf(__('ID #%1s: %2s <strong>You don\'t have permission to remove this user.</strong>'), $id, $user->user_login) . "</li>\n";
} else {
echo "<li><input type=\"hidden\" name=\"users[]\" value=\"{$id}\" />" . sprintf(__('ID #%1s: %2s'), $id, $user->user_login) . "</li>\n";
$go_remove = true;
}
}
?>
<?php if ( $go_remove ) : ?>
<input type="hidden" name="action" value="doremove" />
<?php submit_button( __('Confirm Removal'), 'secondary' ); ?>
<?php else : ?>
<p><?php _e('There are no valid users selected for removal.'); ?></p>
<?php endif; ?>
</div>
</form>
<?php
break;
default:
if ( !empty($_GET['_wp_http_referer']) ) {
wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI'])));
exit;
}
$wp_list_table->prepare_items();
$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
if ( $pagenum > $total_pages && $total_pages > 0 ) {
wp_redirect( add_query_arg( 'paged', $total_pages ) );
exit;
}
include('./admin-header.php');
$messages = array();
if ( isset($_GET['update']) ) :
switch($_GET['update']) {
case 'del':
case 'del_many':
$delete_count = isset($_GET['delete_count']) ? (int) $_GET['delete_count'] : 0;
$messages[] = '<div id="message" class="updated"><p>' . sprintf( _n( 'User deleted.', '%s users deleted.', $delete_count ), number_format_i18n( $delete_count ) ) . '</p></div>';
break;
case 'add':
if ( isset( $_GET['id'] ) && ( $user_id = $_GET['id'] ) && current_user_can( 'edit_user', $user_id ) ) {
$messages[] = '<div id="message" class="updated"><p>' . sprintf( __( 'New user created. <a href="%s">Edit user</a>' ),
esc_url( add_query_arg( 'wp_http_referer', urlencode( stripslashes( $_SERVER['REQUEST_URI'] ) ),
self_admin_url( 'user-edit.php?user_id=' . $user_id ) ) ) ) . '</p></div>';
} else {
$messages[] = '<div id="message" class="updated"><p>' . __( 'New user created.' ) . '</p></div>';
}
break;
case 'promote':
$messages[] = '<div id="message" class="updated"><p>' . __('Changed roles.') . '</p></div>';
break;
case 'err_admin_role':
$messages[] = '<div id="message" class="error"><p>' . __('The current user’s role must have user editing capabilities.') . '</p></div>';
$messages[] = '<div id="message" class="updated"><p>' . __('Other user roles have been changed.') . '</p></div>';
break;
case 'err_admin_del':
$messages[] = '<div id="message" class="error"><p>' . __('You can’t delete the current user.') . '</p></div>';
$messages[] = '<div id="message" class="updated"><p>' . __('Other users have been deleted.') . '</p></div>';
break;
case 'remove':
$messages[] = '<div id="message" class="updated fade"><p>' . __('User removed from this site.') . '</p></div>';
break;
case 'err_admin_remove':
$messages[] = '<div id="message" class="error"><p>' . __("You can't remove the current user.") . '</p></div>';
$messages[] = '<div id="message" class="updated fade"><p>' . __('Other users have been removed.') . '</p></div>';
break;
}
endif; ?>
<?php if ( isset($errors) && is_wp_error( $errors ) ) : ?>
<div class="error">
<ul>
<?php
foreach ( $errors->get_error_messages() as $err )
echo "<li>$err</li>\n";
?>
</ul>
</div>
<?php endif;
if ( ! empty($messages) ) {
foreach ( $messages as $msg )
echo $msg;
} ?>
<div class="wrap">
<?php screen_icon(); ?>
<h2>
<?php
echo esc_html( $title );
if ( current_user_can( 'create_users' ) ) { ?>
<a href="user-new.php" class="add-new-h2"><?php echo esc_html_x( 'Add New', 'user' ); ?></a>
<?php } elseif ( is_multisite() && current_user_can( 'promote_users' ) ) { ?>
<a href="user-new.php" class="add-new-h2"><?php echo esc_html_x( 'Add Existing', 'user' ); ?></a>
<?php }
if ( $usersearch )
printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( $usersearch ) ); ?>
</h2>
<?php $wp_list_table->views(); ?>
<form action="" method="get">
<?php $wp_list_table->search_box( __( 'Search Users' ), 'user' ); ?>
<?php $wp_list_table->display(); ?>
</form>
<br class="clear" />
</div>
<?php
break;
} // end of the $doaction switch
include('./admin-footer.php');
| 01happy-blog | trunk/myblog/wp-admin/users.php | PHP | oos | 14,857 |
<?php
/**
* Press This Display and Handler.
*
* @package WordPress
* @subpackage Press_This
*/
define('IFRAME_REQUEST' , true);
/** WordPress Administration Bootstrap */
require_once('./admin.php');
header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
if ( ! current_user_can('edit_posts') )
wp_die( __( 'Cheatin’ uh?' ) );
/**
* Press It form handler.
*
* @package WordPress
* @subpackage Press_This
* @since 2.6.0
*
* @return int Post ID
*/
function press_it() {
$post = get_default_post_to_edit();
$post = get_object_vars($post);
$post_ID = $post['ID'] = (int) $_POST['post_id'];
if ( !current_user_can('edit_post', $post_ID) )
wp_die(__('You are not allowed to edit this post.'));
$post['post_category'] = isset($_POST['post_category']) ? $_POST['post_category'] : '';
$post['tax_input'] = isset($_POST['tax_input']) ? $_POST['tax_input'] : '';
$post['post_title'] = isset($_POST['title']) ? $_POST['title'] : '';
$content = isset($_POST['content']) ? $_POST['content'] : '';
$upload = false;
if ( !empty($_POST['photo_src']) && current_user_can('upload_files') ) {
foreach( (array) $_POST['photo_src'] as $key => $image) {
// see if files exist in content - we don't want to upload non-used selected files.
if ( strpos($_POST['content'], htmlspecialchars($image)) !== false ) {
$desc = isset($_POST['photo_description'][$key]) ? $_POST['photo_description'][$key] : '';
$upload = media_sideload_image($image, $post_ID, $desc);
// Replace the POSTED content <img> with correct uploaded ones. Regex contains fix for Magic Quotes
if ( !is_wp_error($upload) )
$content = preg_replace('/<img ([^>]*)src=\\\?(\"|\')'.preg_quote(htmlspecialchars($image), '/').'\\\?(\2)([^>\/]*)\/*>/is', $upload, $content);
}
}
}
// set the post_content and status
$post['post_content'] = $content;
if ( isset( $_POST['publish'] ) && current_user_can( 'publish_posts' ) )
$post['post_status'] = 'publish';
elseif ( isset( $_POST['review'] ) )
$post['post_status'] = 'pending';
else
$post['post_status'] = 'draft';
// error handling for media_sideload
if ( is_wp_error($upload) ) {
wp_delete_post($post_ID);
wp_die($upload);
} else {
// Post formats
if ( isset( $_POST['post_format'] ) ) {
if ( current_theme_supports( 'post-formats', $_POST['post_format'] ) )
set_post_format( $post_ID, $_POST['post_format'] );
elseif ( '0' == $_POST['post_format'] )
set_post_format( $post_ID, false );
}
$post_ID = wp_update_post($post);
}
return $post_ID;
}
// For submitted posts.
if ( isset($_REQUEST['action']) && 'post' == $_REQUEST['action'] ) {
check_admin_referer('press-this');
$posted = $post_ID = press_it();
} else {
$post = get_default_post_to_edit('post', true);
$post_ID = $post->ID;
}
// Set Variables
$title = isset( $_GET['t'] ) ? trim( strip_tags( html_entity_decode( stripslashes( $_GET['t'] ) , ENT_QUOTES) ) ) : '';
$selection = '';
if ( !empty($_GET['s']) ) {
$selection = str_replace(''', "'", stripslashes($_GET['s']));
$selection = trim( htmlspecialchars( html_entity_decode($selection, ENT_QUOTES) ) );
}
if ( ! empty($selection) ) {
$selection = preg_replace('/(\r?\n|\r)/', '</p><p>', $selection);
$selection = '<p>' . str_replace('<p></p>', '', $selection) . '</p>';
}
$url = isset($_GET['u']) ? esc_url($_GET['u']) : '';
$image = isset($_GET['i']) ? $_GET['i'] : '';
if ( !empty($_REQUEST['ajax']) ) {
switch ($_REQUEST['ajax']) {
case 'video': ?>
<script type="text/javascript" charset="utf-8">
/* <![CDATA[ */
jQuery('.select').click(function() {
append_editor(jQuery('#embed-code').val());
jQuery('#extra-fields').hide();
jQuery('#extra-fields').html('');
});
jQuery('.close').click(function() {
jQuery('#extra-fields').hide();
jQuery('#extra-fields').html('');
});
/* ]]> */
</script>
<div class="postbox">
<h2><label for="embed-code"><?php _e('Embed Code') ?></label></h2>
<div class="inside">
<textarea name="embed-code" id="embed-code" rows="8" cols="40"><?php echo esc_textarea( $selection ); ?></textarea>
<p id="options"><a href="#" class="select button"><?php _e('Insert Video'); ?></a> <a href="#" class="close button"><?php _e('Cancel'); ?></a></p>
</div>
</div>
<?php break;
case 'photo_thickbox': ?>
<script type="text/javascript" charset="utf-8">
/* <![CDATA[ */
jQuery('.cancel').click(function() {
tb_remove();
});
jQuery('.select').click(function() {
image_selector(this);
});
/* ]]> */
</script>
<h3 class="tb"><label for="tb_this_photo_description"><?php _e('Description') ?></label></h3>
<div class="titlediv">
<div class="titlewrap">
<input id="tb_this_photo_description" name="photo_description" class="tb_this_photo_description tbtitle text" onkeypress="if(event.keyCode==13) image_selector(this);" value="<?php echo esc_attr($title);?>"/>
</div>
</div>
<p class="centered">
<input type="hidden" name="this_photo" value="<?php echo esc_attr($image); ?>" id="tb_this_photo" class="tb_this_photo" />
<a href="#" class="select">
<img src="<?php echo esc_url($image); ?>" alt="<?php echo esc_attr(__('Click to insert.')); ?>" title="<?php echo esc_attr(__('Click to insert.')); ?>" />
</a>
</p>
<p id="options"><a href="#" class="select button"><?php _e('Insert Image'); ?></a> <a href="#" class="cancel button"><?php _e('Cancel'); ?></a></p>
<?php break;
case 'photo_images':
/**
* Retrieve all image URLs from given URI.
*
* @package WordPress
* @subpackage Press_This
* @since 2.6.0
*
* @param string $uri
* @return string
*/
function get_images_from_uri($uri) {
$uri = preg_replace('/\/#.+?$/','', $uri);
if ( preg_match('/\.(jpg|jpe|jpeg|png|gif)$/', $uri) && !strpos($uri,'blogger.com') )
return "'" . esc_attr( html_entity_decode($uri) ) . "'";
$content = wp_remote_fopen($uri);
if ( false === $content )
return '';
$host = parse_url($uri);
$pattern = '/<img ([^>]*)src=(\"|\')([^<>\'\"]+)(\2)([^>]*)\/*>/i';
$content = str_replace(array("\n","\t","\r"), '', $content);
preg_match_all($pattern, $content, $matches);
if ( empty($matches[0]) )
return '';
$sources = array();
foreach ($matches[3] as $src) {
// if no http in url
if (strpos($src, 'http') === false)
// if it doesn't have a relative uri
if ( strpos($src, '../') === false && strpos($src, './') === false && strpos($src, '/') === 0)
$src = 'http://'.str_replace('//','/', $host['host'].'/'.$src);
else
$src = 'http://'.str_replace('//','/', $host['host'].'/'.dirname($host['path']).'/'.$src);
$sources[] = esc_url($src);
}
return "'" . implode("','", $sources) . "'";
}
$url = wp_kses(urldecode($url), null);
echo 'new Array('.get_images_from_uri($url).')';
break;
case 'photo_js': ?>
// gather images and load some default JS
var last = null
var img, img_tag, aspect, w, h, skip, i, strtoappend = "";
if(photostorage == false) {
var my_src = eval(
jQuery.ajax({
type: "GET",
url: "<?php echo esc_url($_SERVER['PHP_SELF']); ?>",
cache : false,
async : false,
data: "ajax=photo_images&u=<?php echo urlencode($url); ?>",
dataType : "script"
}).responseText
);
if(my_src.length == 0) {
var my_src = eval(
jQuery.ajax({
type: "GET",
url: "<?php echo esc_url($_SERVER['PHP_SELF']); ?>",
cache : false,
async : false,
data: "ajax=photo_images&u=<?php echo urlencode($url); ?>",
dataType : "script"
}).responseText
);
if(my_src.length == 0) {
strtoappend = '<?php _e('Unable to retrieve images or no images on page.'); ?>';
}
}
}
for (i = 0; i < my_src.length; i++) {
img = new Image();
img.src = my_src[i];
img_attr = 'id="img' + i + '"';
skip = false;
maybeappend = '<a href="?ajax=photo_thickbox&i=' + encodeURIComponent(img.src) + '&u=<?php echo urlencode($url); ?>&height=400&width=500" title="" class="thickbox"><img src="' + img.src + '" ' + img_attr + '/></a>';
if (img.width && img.height) {
if (img.width >= 30 && img.height >= 30) {
aspect = img.width / img.height;
scale = (aspect > 1) ? (71 / img.width) : (71 / img.height);
w = img.width;
h = img.height;
if (scale < 1) {
w = parseInt(img.width * scale);
h = parseInt(img.height * scale);
}
img_attr += ' style="width: ' + w + 'px; height: ' + h + 'px;"';
strtoappend += maybeappend;
}
} else {
strtoappend += maybeappend;
}
}
function pick(img, desc) {
if (img) {
if('object' == typeof jQuery('.photolist input') && jQuery('.photolist input').length != 0) length = jQuery('.photolist input').length;
if(length == 0) length = 1;
jQuery('.photolist').append('<input name="photo_src[' + length + ']" value="' + img +'" type="hidden"/>');
jQuery('.photolist').append('<input name="photo_description[' + length + ']" value="' + desc +'" type="hidden"/>');
insert_editor( "\n\n" + encodeURI('<p style="text-align: center;"><a href="<?php echo $url; ?>"><img src="' + img +'" alt="' + desc + '" /></a></p>'));
}
return false;
}
function image_selector(el) {
var desc, src, parent = jQuery(el).closest('#photo-add-url-div');
if ( parent.length ) {
desc = parent.find('input.tb_this_photo_description').val() || '';
src = parent.find('input.tb_this_photo').val() || ''
} else {
desc = jQuery('#tb_this_photo_description').val() || '';
src = jQuery('#tb_this_photo').val() || ''
}
tb_remove();
pick(src, desc);
jQuery('#extra-fields').hide();
jQuery('#extra-fields').html('');
return false;
}
jQuery('#extra-fields').html('<div class="postbox"><h2><?php _e( 'Add Photos' ); ?> <small id="photo_directions">(<?php _e("click images to select") ?>)</small></h2><ul class="actions"><li><a href="#" id="photo-add-url" class="button"><?php _e("Add from URL") ?> +</a></li></ul><div class="inside"><div class="titlewrap"><div id="img_container"></div></div><p id="options"><a href="#" class="close button"><?php _e('Cancel'); ?></a><a href="#" class="refresh button"><?php _e('Refresh'); ?></a></p></div>');
jQuery('#img_container').html(strtoappend);
<?php break;
}
die;
}
wp_enqueue_style( 'colors' );
wp_enqueue_script( 'post' );
_wp_admin_html_begin();
?>
<title><?php _e('Press This') ?></title>
<script type="text/javascript">
//<![CDATA[
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();}}};
var userSettings = {'url':'<?php echo SITECOOKIEPATH; ?>','uid':'<?php if ( ! isset($current_user) ) $current_user = wp_get_current_user(); echo $current_user->ID; ?>','time':'<?php echo time() ?>'};
var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>', pagenow = 'press-this', isRtl = <?php echo (int) is_rtl(); ?>;
var photostorage = false;
//]]>
</script>
<?php
do_action('admin_print_styles');
do_action('admin_print_scripts');
do_action('admin_head');
?>
<script type="text/javascript">
var wpActiveEditor = 'content';
function insert_plain_editor(text) {
if ( typeof(QTags) != 'undefined' )
QTags.insertContent(text);
}
function set_editor(text) {
if ( '' == text || '<p></p>' == text )
text = '<p><br /></p>';
if ( tinyMCE.activeEditor )
tinyMCE.execCommand('mceSetContent', false, text);
}
function insert_editor(text) {
if ( '' != text && tinyMCE.activeEditor && ! tinyMCE.activeEditor.isHidden()) {
tinyMCE.execCommand('mceInsertContent', false, '<p>' + decodeURI(tinymce.DOM.decode(text)) + '</p>', {format : 'raw'});
} else {
insert_plain_editor(decodeURI(text));
}
}
function append_editor(text) {
if ( '' != text && tinyMCE.activeEditor && ! tinyMCE.activeEditor.isHidden()) {
tinyMCE.execCommand('mceSetContent', false, tinyMCE.activeEditor.getContent({format : 'raw'}) + '<p>' + text + '</p>');
} else {
insert_plain_editor(text);
}
}
function show(tab_name) {
jQuery('#extra-fields').html('');
switch(tab_name) {
case 'video' :
jQuery('#extra-fields').load('<?php echo esc_url($_SERVER['PHP_SELF']); ?>', { ajax: 'video', s: '<?php echo esc_attr($selection); ?>'}, function() {
<?php
$content = '';
if ( preg_match("/youtube\.com\/watch/i", $url) ) {
list($domain, $video_id) = explode("v=", $url);
$video_id = esc_attr($video_id);
$content = '<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/' . $video_id . '"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/' . $video_id . '" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>';
} elseif ( preg_match("/vimeo\.com\/[0-9]+/i", $url) ) {
list($domain, $video_id) = explode(".com/", $url);
$video_id = esc_attr($video_id);
$content = '<object width="400" height="225"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://www.vimeo.com/moogaloop.swf?clip_id=' . $video_id . '&server=www.vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1" /> <embed src="http://www.vimeo.com/moogaloop.swf?clip_id=' . $video_id . '&server=www.vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="225"></embed></object>';
if ( trim($selection) == '' )
$selection = '<p><a href="http://www.vimeo.com/' . $video_id . '?pg=embed&sec=' . $video_id . '">' . $title . '</a> on <a href="http://vimeo.com?pg=embed&sec=' . $video_id . '">Vimeo</a></p>';
} elseif ( strpos( $selection, '<object' ) !== false ) {
$content = $selection;
}
?>
jQuery('#embed-code').prepend('<?php echo htmlentities($content); ?>');
});
jQuery('#extra-fields').show();
return false;
break;
case 'photo' :
function setup_photo_actions() {
jQuery('.close').click(function() {
jQuery('#extra-fields').hide();
jQuery('#extra-fields').html('');
});
jQuery('.refresh').click(function() {
photostorage = false;
show('photo');
});
jQuery('#photo-add-url').click(function(){
var form = jQuery('#photo-add-url-div').clone();
jQuery('#img_container').empty().append( form.show() );
});
jQuery('#waiting').hide();
jQuery('#extra-fields').show();
}
jQuery('#waiting').show();
if(photostorage == false) {
jQuery.ajax({
type: "GET",
cache : false,
url: "<?php echo esc_url($_SERVER['PHP_SELF']); ?>",
data: "ajax=photo_js&u=<?php echo urlencode($url)?>",
dataType : "script",
success : function(data) {
eval(data);
photostorage = jQuery('#extra-fields').html();
setup_photo_actions();
}
});
} else {
jQuery('#extra-fields').html(photostorage);
setup_photo_actions();
}
return false;
break;
}
}
jQuery(document).ready(function($) {
//resize screen
window.resizeTo(720,580);
// set button actions
jQuery('#photo_button').click(function() { show('photo'); return false; });
jQuery('#video_button').click(function() { show('video'); return false; });
// auto select
<?php if ( preg_match("/youtube\.com\/watch/i", $url) ) { ?>
show('video');
<?php } elseif ( preg_match("/vimeo\.com\/[0-9]+/i", $url) ) { ?>
show('video');
<?php } elseif ( preg_match("/flickr\.com/i", $url) ) { ?>
show('photo');
<?php } ?>
jQuery('#title').unbind();
jQuery('#publish, #save').click(function() { jQuery('#saving').css('display', 'inline'); });
$('#tagsdiv-post_tag, #categorydiv').children('h3, .handlediv').click(function(){
$(this).siblings('.inside').toggle();
});
});
</script>
</head>
<?php
$admin_body_class = ( is_rtl() ) ? 'rtl' : '';
$admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) );
?>
<body class="press-this wp-admin <?php echo $admin_body_class; ?>">
<form action="press-this.php?action=post" method="post">
<div id="poststuff" class="metabox-holder">
<div id="side-sortables" class="press-this-sidebar">
<div class="sleeve">
<?php wp_nonce_field('press-this') ?>
<input type="hidden" name="post_type" id="post_type" value="text"/>
<input type="hidden" name="autosave" id="autosave" />
<input type="hidden" id="original_post_status" name="original_post_status" value="draft" />
<input type="hidden" id="prev_status" name="prev_status" value="draft" />
<input type="hidden" id="post_id" name="post_id" value="<?php echo (int) $post_ID; ?>" />
<!-- This div holds the photo metadata -->
<div class="photolist"></div>
<div id="submitdiv" class="postbox">
<div class="handlediv" title="<?php esc_attr_e( 'Click to toggle' ); ?>"><br /></div>
<h3 class="hndle"><?php _e('Press This') ?></h3>
<div class="inside">
<p id="publishing-actions">
<?php
submit_button( __( 'Save Draft' ), 'button', 'draft', false, array( 'id' => 'save' ) );
if ( current_user_can('publish_posts') ) {
submit_button( __( 'Publish' ), 'primary', 'publish', false );
} else {
echo '<br /><br />';
submit_button( __( 'Submit for Review' ), 'primary', 'review', false );
} ?>
<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" id="saving" style="display:none;" />
</p>
<?php if ( current_theme_supports( 'post-formats' ) && post_type_supports( 'post', 'post-formats' ) ) :
$post_formats = get_theme_support( 'post-formats' );
if ( is_array( $post_formats[0] ) ) :
$default_format = get_option( 'default_post_format', '0' );
?>
<p>
<label for="post_format"><?php _e( 'Post Format:' ); ?>
<select name="post_format" id="post_format">
<option value="0"><?php _ex( 'Standard', 'Post format' ); ?></option>
<?php foreach ( $post_formats[0] as $format ): ?>
<option<?php selected( $default_format, $format ); ?> value="<?php echo esc_attr( $format ); ?>"> <?php echo esc_html( get_post_format_string( $format ) ); ?></option>
<?php endforeach; ?>
</select></label>
</p>
<?php endif; endif; ?>
</div>
</div>
<?php $tax = get_taxonomy( 'category' ); ?>
<div id="categorydiv" class="postbox">
<div class="handlediv" title="<?php esc_attr_e( 'Click to toggle' ); ?>"><br /></div>
<h3 class="hndle"><?php _e('Categories') ?></h3>
<div class="inside">
<div id="taxonomy-category" class="categorydiv">
<ul id="category-tabs" class="category-tabs">
<li class="tabs"><a href="#category-all" tabindex="3"><?php echo $tax->labels->all_items; ?></a></li>
<li class="hide-if-no-js"><a href="#category-pop" tabindex="3"><?php _e( 'Most Used' ); ?></a></li>
</ul>
<div id="category-pop" class="tabs-panel" style="display: none;">
<ul id="categorychecklist-pop" class="categorychecklist form-no-clear" >
<?php $popular_ids = wp_popular_terms_checklist( 'category' ); ?>
</ul>
</div>
<div id="category-all" class="tabs-panel">
<ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
<?php wp_terms_checklist($post_ID, array( 'taxonomy' => 'category', 'popular_cats' => $popular_ids ) ) ?>
</ul>
</div>
<?php if ( !current_user_can($tax->cap->assign_terms) ) : ?>
<p><em><?php _e('You cannot modify this Taxonomy.'); ?></em></p>
<?php endif; ?>
<?php if ( current_user_can($tax->cap->edit_terms) ) : ?>
<div id="category-adder" class="wp-hidden-children">
<h4>
<a id="category-add-toggle" href="#category-add" class="hide-if-no-js" tabindex="3">
<?php printf( __( '+ %s' ), $tax->labels->add_new_item ); ?>
</a>
</h4>
<p id="category-add" class="category-add wp-hidden-child">
<label class="screen-reader-text" for="newcategory"><?php echo $tax->labels->add_new_item; ?></label>
<input type="text" name="newcategory" id="newcategory" class="form-required form-input-tip" value="<?php echo esc_attr( $tax->labels->new_item_name ); ?>" tabindex="3" aria-required="true"/>
<label class="screen-reader-text" for="newcategory_parent">
<?php echo $tax->labels->parent_item_colon; ?>
</label>
<?php wp_dropdown_categories( array( 'taxonomy' => 'category', 'hide_empty' => 0, 'name' => 'newcategory_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => '— ' . $tax->labels->parent_item . ' —', 'tab_index' => 3 ) ); ?>
<input type="button" id="category-add-submit" class="add:categorychecklist:category-add button category-add-submit" value="<?php echo esc_attr( $tax->labels->add_new_item ); ?>" tabindex="3" />
<?php wp_nonce_field( 'add-category', '_ajax_nonce-add-category', false ); ?>
<span id="category-ajax-response"></span>
</p>
</div>
<?php endif; ?>
</div>
</div>
</div>
<div id="tagsdiv-post_tag" class="postbox">
<div class="handlediv" title="<?php esc_attr_e( 'Click to toggle' ); ?>"><br /></div>
<h3><span><?php _e('Tags'); ?></span></h3>
<div class="inside">
<div class="tagsdiv" id="post_tag">
<div class="jaxtag">
<label class="screen-reader-text" for="newtag"><?php _e('Tags'); ?></label>
<input type="hidden" name="tax_input[post_tag]" class="the-tags" id="tax-input[post_tag]" value="" />
<div class="ajaxtag">
<input type="text" name="newtag[post_tag]" class="newtag form-input-tip" size="16" autocomplete="off" value="" />
<input type="button" class="button tagadd" value="<?php esc_attr_e('Add'); ?>" tabindex="3" />
</div>
</div>
<div class="tagchecklist"></div>
</div>
<p class="tagcloud-link"><a href="#titlediv" class="tagcloud-link" id="link-post_tag"><?php _e('Choose from the most used tags'); ?></a></p>
</div>
</div>
</div>
</div>
<div class="posting">
<div id="wphead">
<img id="header-logo" src="<?php echo esc_url( includes_url( 'images/blank.gif' ) ); ?>" alt="" width="16" height="16" />
<h1 id="site-heading">
<a href="<?php echo get_option('home'); ?>/" target="_blank">
<span id="site-title"><?php bloginfo('name'); ?></span>
</a>
</h1>
</div>
<?php
if ( isset($posted) && intval($posted) ) {
$post_ID = intval($posted); ?>
<div id="message" class="updated">
<p><strong><?php _e('Your post has been saved.'); ?></strong>
<a onclick="window.opener.location.replace(this.href); window.close();" href="<?php echo get_permalink($post_ID); ?>"><?php _e('View post'); ?></a>
| <a href="<?php echo get_edit_post_link( $post_ID ); ?>" onclick="window.opener.location.replace(this.href); window.close();"><?php _e('Edit Post'); ?></a>
| <a href="#" onclick="window.close();"><?php _e('Close Window'); ?></a></p>
</div>
<?php } ?>
<div id="titlediv">
<div class="titlewrap">
<input name="title" id="title" class="text" value="<?php echo esc_attr($title);?>"/>
</div>
</div>
<div id="waiting" style="display: none"><img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" /> <?php esc_html_e( 'Loading...' ); ?></div>
<div id="extra-fields" style="display: none"></div>
<div class="postdivrich">
<?php
$editor_settings = array(
'teeny' => true,
'textarea_rows' => '15'
);
$content = '';
if ( $selection )
$content .= $selection;
if ( $url ) {
$content .= '<p>';
if ( $selection )
$content .= __('via ');
$content .= sprintf( "<a href='%s'>%s</a>.</p>", esc_url( $url ), esc_html( $title ) );
}
remove_action( 'media_buttons', 'media_buttons' );
add_action( 'media_buttons', 'press_this_media_buttons' );
function press_this_media_buttons() {
_e( 'Add:' );
if ( current_user_can('upload_files') ) {
?>
<a id="photo_button" title="<?php esc_attr_e('Insert an Image'); ?>" href="#">
<img alt="<?php esc_attr_e('Insert an Image'); ?>" src="<?php echo esc_url( admin_url( 'images/media-button-image.gif?ver=20100531' ) ); ?>"/></a>
<?php
}
?>
<a id="video_button" title="<?php esc_attr_e('Embed a Video'); ?>" href="#"><img alt="<?php esc_attr_e('Embed a Video'); ?>" src="<?php echo esc_url( admin_url( 'images/media-button-video.gif?ver=20100531' ) ); ?>"/></a>
<?php
}
wp_editor( $content, 'content', $editor_settings );
?>
</div>
</div>
</div>
</form>
<div id="photo-add-url-div" style="display:none;">
<table><tr>
<td><label for="this_photo"><?php _e('URL') ?></label></td>
<td><input type="text" id="this_photo" name="this_photo" class="tb_this_photo text" onkeypress="if(event.keyCode==13) image_selector(this);" /></td>
</tr><tr>
<td><label for="this_photo_description"><?php _e('Description') ?></label></td>
<td><input type="text" id="this_photo_description" name="photo_description" class="tb_this_photo_description text" onkeypress="if(event.keyCode==13) image_selector(this);" value="<?php echo esc_attr($title);?>"/></td>
</tr><tr>
<td><input type="button" class="button" onclick="image_selector(this)" value="<?php esc_attr_e('Insert Image'); ?>" /></td>
</tr></table>
</div>
<?php
do_action('admin_footer');
do_action('admin_print_footer_scripts');
?>
<script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script>
</body>
</html>
| 01happy-blog | trunk/myblog/wp-admin/press-this.php | PHP | oos | 25,914 |
<?php
/**
* Media Library administration panel.
*
* @package WordPress
* @subpackage Administration
*/
/** WordPress Administration Bootstrap */
require_once( './admin.php' );
if ( !current_user_can('upload_files') )
wp_die( __( 'You do not have permission to upload files.' ) );
$wp_list_table = _get_list_table('WP_Media_List_Table');
$pagenum = $wp_list_table->get_pagenum();
// Handle bulk actions
$doaction = $wp_list_table->current_action();
if ( $doaction ) {
check_admin_referer('bulk-media');
if ( 'delete_all' == $doaction ) {
$post_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type='attachment' AND post_status = 'trash'" );
$doaction = 'delete';
} elseif ( isset( $_REQUEST['media'] ) ) {
$post_ids = $_REQUEST['media'];
} elseif ( isset( $_REQUEST['ids'] ) ) {
$post_ids = explode( ',', $_REQUEST['ids'] );
}
$location = 'upload.php';
if ( $referer = wp_get_referer() ) {
if ( false !== strpos( $referer, 'upload.php' ) )
$location = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'message', 'ids', 'posted' ), $referer );
}
switch ( $doaction ) {
case 'find_detached':
if ( !current_user_can('edit_posts') )
wp_die( __('You are not allowed to scan for lost attachments.') );
$lost = $wpdb->get_col( "
SELECT ID FROM $wpdb->posts
WHERE post_type = 'attachment' AND post_parent > '0'
AND post_parent NOT IN (
SELECT ID FROM $wpdb->posts
WHERE post_type NOT IN ( 'attachment', '" . join( "', '", get_post_types( array( 'public' => false ) ) ) . "' )
)
" );
$_REQUEST['detached'] = 1;
break;
case 'attach':
$parent_id = (int) $_REQUEST['found_post_id'];
if ( !$parent_id )
return;
$parent = &get_post( $parent_id );
if ( !current_user_can( 'edit_post', $parent_id ) )
wp_die( __( 'You are not allowed to edit this post.' ) );
$attach = array();
foreach ( (array) $_REQUEST['media'] as $att_id ) {
$att_id = (int) $att_id;
if ( !current_user_can( 'edit_post', $att_id ) )
continue;
$attach[] = $att_id;
clean_attachment_cache( $att_id );
}
if ( ! empty( $attach ) ) {
$attach = implode( ',', $attach );
$attached = $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET post_parent = %d WHERE post_type = 'attachment' AND ID IN ( $attach )", $parent_id ) );
}
if ( isset( $attached ) ) {
$location = 'upload.php';
if ( $referer = wp_get_referer() ) {
if ( false !== strpos( $referer, 'upload.php' ) )
$location = $referer;
}
$location = add_query_arg( array( 'attached' => $attached ) , $location );
wp_redirect( $location );
exit;
}
break;
case 'trash':
if ( !isset( $post_ids ) )
break;
foreach ( (array) $post_ids as $post_id ) {
if ( !current_user_can( 'delete_post', $post_id ) )
wp_die( __( 'You are not allowed to move this post to the trash.' ) );
if ( !wp_trash_post( $post_id ) )
wp_die( __( 'Error in moving to trash...' ) );
}
$location = add_query_arg( array( 'trashed' => count( $post_ids ), 'ids' => join( ',', $post_ids ) ), $location );
break;
case 'untrash':
if ( !isset( $post_ids ) )
break;
foreach ( (array) $post_ids as $post_id ) {
if ( !current_user_can( 'delete_post', $post_id ) )
wp_die( __( 'You are not allowed to move this post out of the trash.' ) );
if ( !wp_untrash_post( $post_id ) )
wp_die( __( 'Error in restoring from trash...' ) );
}
$location = add_query_arg( 'untrashed', count( $post_ids ), $location );
break;
case 'delete':
if ( !isset( $post_ids ) )
break;
foreach ( (array) $post_ids as $post_id_del ) {
if ( !current_user_can( 'delete_post', $post_id_del ) )
wp_die( __( 'You are not allowed to delete this post.' ) );
if ( !wp_delete_attachment( $post_id_del ) )
wp_die( __( 'Error in deleting...' ) );
}
$location = add_query_arg( 'deleted', count( $post_ids ), $location );
break;
}
wp_redirect( $location );
exit;
} elseif ( ! empty( $_GET['_wp_http_referer'] ) ) {
wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), stripslashes( $_SERVER['REQUEST_URI'] ) ) );
exit;
}
$wp_list_table->prepare_items();
$title = __('Media Library');
$parent_file = 'upload.php';
wp_enqueue_script( 'wp-ajax-response' );
wp_enqueue_script( 'jquery-ui-draggable' );
wp_enqueue_script( 'media' );
add_screen_option( 'per_page', array('label' => _x( 'Media items', 'items per page (screen options)' )) );
get_current_screen()->add_help_tab( array(
'id' => 'overview',
'title' => __('Overview'),
'content' =>
'<p>' . __( 'All the files you’ve uploaded are listed in the Media Library, with the most recent uploads listed first. You can use the Screen Options tab to customize the display of this screen.' ) . '</p>' .
'<p>' . __( 'You can narrow the list by file type/status using the text link filters at the top of the screen. You also can refine the list by date using the dropdown menu above the media table.' ) . '</p>'
) );
get_current_screen()->add_help_tab( array(
'id' => 'actions-links',
'title' => __('Available Actions'),
'content' =>
'<p>' . __( 'Hovering over a row reveals action links: Edit, Delete Permanently, and View. Clicking Edit or on the media file’s name displays a simple screen to edit that individual file’s metadata. Clicking Delete Permanently will delete the file from the media library (as well as from any posts to which it is currently attached). View will take you to the display page for that file.' ) . '</p>'
) );
get_current_screen()->add_help_tab( array(
'id' => 'attaching-files',
'title' => __('Attaching Files'),
'content' =>
'<p>' . __( 'If a media file has not been attached to any post, you will see that in the Attached To column, and can click on Attach File to launch a small popup that will allow you to search for a post and attach the file.' ) . '</p>'
) );
get_current_screen()->set_help_sidebar(
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
'<p>' . __( '<a href="http://codex.wordpress.org/Media_Library_Screen" target="_blank">Documentation on Media Library</a>' ) . '</p>' .
'<p>' . __( '<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>' ) . '</p>'
);
require_once('./admin-header.php');
?>
<div class="wrap">
<?php screen_icon(); ?>
<h2>
<?php
echo esc_html( $title );
if ( current_user_can( 'upload_files' ) ) { ?>
<a href="media-new.php" class="add-new-h2"><?php echo esc_html_x('Add New', 'file'); ?></a><?php
}
if ( ! empty( $_REQUEST['s'] ) )
printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', get_search_query() ); ?>
</h2>
<?php
$message = '';
if ( ! empty( $_GET['posted'] ) ) {
$message = __('Media attachment updated.');
$_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']);
}
if ( ! empty( $_GET['attached'] ) && $attached = absint( $_GET['attached'] ) ) {
$message = sprintf( _n('Reattached %d attachment.', 'Reattached %d attachments.', $attached), $attached );
$_SERVER['REQUEST_URI'] = remove_query_arg(array('attached'), $_SERVER['REQUEST_URI']);
}
if ( ! empty( $_GET['deleted'] ) && $deleted = absint( $_GET['deleted'] ) ) {
$message = sprintf( _n( 'Media attachment permanently deleted.', '%d media attachments permanently deleted.', $deleted ), number_format_i18n( $_GET['deleted'] ) );
$_SERVER['REQUEST_URI'] = remove_query_arg(array('deleted'), $_SERVER['REQUEST_URI']);
}
if ( ! empty( $_GET['trashed'] ) && $trashed = absint( $_GET['trashed'] ) ) {
$message = sprintf( _n( 'Media attachment moved to the trash.', '%d media attachments moved to the trash.', $trashed ), number_format_i18n( $_GET['trashed'] ) );
$message .= ' <a href="' . esc_url( wp_nonce_url( 'upload.php?doaction=undo&action=untrash&ids='.(isset($_GET['ids']) ? $_GET['ids'] : ''), "bulk-media" ) ) . '">' . __('Undo') . '</a>';
$_SERVER['REQUEST_URI'] = remove_query_arg(array('trashed'), $_SERVER['REQUEST_URI']);
}
if ( ! empty( $_GET['untrashed'] ) && $untrashed = absint( $_GET['untrashed'] ) ) {
$message = sprintf( _n( 'Media attachment restored from the trash.', '%d media attachments restored from the trash.', $untrashed ), number_format_i18n( $_GET['untrashed'] ) );
$_SERVER['REQUEST_URI'] = remove_query_arg(array('untrashed'), $_SERVER['REQUEST_URI']);
}
$messages[1] = __('Media attachment updated.');
$messages[2] = __('Media permanently deleted.');
$messages[3] = __('Error saving media attachment.');
$messages[4] = __('Media moved to the trash.') . ' <a href="' . esc_url( wp_nonce_url( 'upload.php?doaction=undo&action=untrash&ids='.(isset($_GET['ids']) ? $_GET['ids'] : ''), "bulk-media" ) ) . '">' . __('Undo') . '</a>';
$messages[5] = __('Media restored from the trash.');
if ( ! empty( $_GET['message'] ) && isset( $messages[ $_GET['message'] ] ) ) {
$message = $messages[ $_GET['message'] ];
$_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']);
}
if ( !empty($message) ) { ?>
<div id="message" class="updated"><p><?php echo $message; ?></p></div>
<?php } ?>
<?php $wp_list_table->views(); ?>
<form id="posts-filter" action="" method="get">
<?php $wp_list_table->search_box( __( 'Search Media' ), 'media' ); ?>
<?php $wp_list_table->display(); ?>
<div id="ajax-response"></div>
<?php find_posts_div(); ?>
<br class="clear" />
</form>
</div>
<?php
include('./admin-footer.php');
| 01happy-blog | trunk/myblog/wp-admin/upload.php | PHP | oos | 9,493 |
<?php
/**
* Defines the Gears manifest file for Google Gears offline storage.
*
* @package WordPress
* @subpackage Administration
*/
/**
* Disable error reporting
*
* Set this to error_reporting( E_ALL ) or error_reporting( E_ALL | E_STRICT ) for debugging
*/
error_reporting(0);
/** Set ABSPATH for execution */
define( 'ABSPATH', dirname(dirname(__FILE__)) . '/' );
require(ABSPATH . '/wp-admin/includes/manifest.php');
$files = get_manifest();
header( 'Expires: Wed, 11 Jan 1984 05:00:00 GMT' );
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
header( 'Cache-Control: no-cache, must-revalidate, max-age=0' );
header( 'Pragma: no-cache' );
header( 'Content-Type: application/x-javascript; charset=UTF-8' );
?>
{
"betaManifestVersion" : 1,
"version" : "<?php echo $man_version; ?>",
"entries" : [
<?php
$entries = '';
foreach ( $files as $file ) {
// Set ignoreQuery, defaulting to true
$ignore_query = ( isset($file[2]) && !$file[2] ) ? '' : ', "ignoreQuery" : true ';
// If version is not set, just output the file
if ( !isset($file[1]) )
$entries .= '{ "url" : "' . $file[0] . '"' . $ignore_query . ' }' . "\n";
// Output url and src
else
$entries .= '{ "url" : "' . $file[0] . '", "src" : "' . $file[0] . '?' . $file[1] . '"' . $ignore_query . ' },' . "\n";
}
echo trim( trim($entries), ',' );
?>
]}
| 01happy-blog | trunk/myblog/wp-admin/gears-manifest.php | PHP | oos | 1,352 |
<?php
define( 'WP_INSTALLING', true );
/** Sets up the WordPress Environment. */
require( dirname(__FILE__) . '/wp-load.php' );
require( './wp-blog-header.php' );
if ( !is_multisite() ) {
wp_redirect( site_url( '/wp-login.php?action=register' ) );
die();
}
if ( is_object( $wp_object_cache ) )
$wp_object_cache->cache_enabled = false;
do_action( 'activate_header' );
function do_activate_header() {
do_action( 'activate_wp_head' );
}
add_action( 'wp_head', 'do_activate_header' );
function wpmu_activate_stylesheet() {
?>
<style type="text/css">
form { margin-top: 2em; }
#submit, #key { width: 90%; font-size: 24px; }
#language { margin-top: .5em; }
.error { background: #f66; }
span.h3 { padding: 0 8px; font-size: 1.3em; font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif; font-weight: bold; color: #333; }
</style>
<?php
}
add_action( 'wp_head', 'wpmu_activate_stylesheet' );
get_header();
?>
<div id="content" class="widecolumn">
<?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'); ?>">
<p>
<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') ?>" />
</p>
</form>
<?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>
<?php
echo '<p class="lead-in">';
if ( $signup->domain . $signup->path == '' ) {
printf( __('Your account has been activated. You may now <a href="%1$s">log in</a> to the site using your chosen username of “%2$s”. Please check your email inbox at %3$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%4$s">reset your password</a>.'), network_site_url( 'wp-login.php', 'login' ), $signup->user_login, $signup->user_email, wp_lostpassword_url() );
} else {
printf( __('Your site at <a href="%1$s">%2$s</a> is active. You may now log in to your site using your chosen username of “%3$s”. Please check your email inbox at %4$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%5$s">reset your password</a>.'), 'http://' . $signup->domain, $signup->domain, $signup->user_login, $signup->user_email, wp_lostpassword_url() );
}
echo '</p>';
} else {
?>
<h2><?php _e('An error occurred during the activation'); ?></h2>
<?php
echo '<p>'.$result->get_error_message().'</p>';
}
} else {
extract($result);
$url = get_blogaddress_by_id( (int) $blog_id);
$user = new WP_User( (int) $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 $password; ?></p>
</div>
<?php if ( $url != network_home_url('', 'http') ) : ?>
<p class="view"><?php printf( __('Your account is now activated. <a href="%1$s">View your site</a> or <a href="%2$s">Log in</a>'), $url, $url . 'wp-login.php' ); ?></p>
<?php else: ?>
<p class="view"><?php 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;
}
}
?>
</div>
<script type="text/javascript">
var key_input = document.getElementById('key');
key_input && key_input.focus();
</script>
<?php get_footer(); ?> | 01happy-blog | trunk/myblog/wp-activate.php | PHP | oos | 4,264 |