wp/wp-admin/includes/template.php
author ymh <ymh.work@gmail.com>
Wed, 06 Nov 2013 03:21:17 +0000
changeset 0 d970ebf37754
child 5 5e2f62d02dcd
permissions -rw-r--r--
first import
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
 * Template WordPress Administration API.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
 * A Big Mess. Also some neat functions that are nicely written.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
 * @package WordPress
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
 * @subpackage Administration
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
//
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
// Category Checklists
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
//
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
 * Walker to output an unordered list of category checkbox <input> elements.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
 * @see Walker
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
 * @see wp_category_checklist()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
 * @see wp_terms_checklist()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
 * @since 2.5.1
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
class Walker_Category_Checklist extends Walker {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
	var $tree_type = 'category';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
	var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
	 * Starts the list before the elements are added.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
	 * @see Walker:start_lvl()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
	 * @since 2.5.1
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
	 * @param string $output Passed by reference. Used to append additional content.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
	 * @param int    $depth  Depth of category. Used for tab indentation.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
	 * @param array  $args   An array of arguments. @see wp_terms_checklist()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
	function start_lvl( &$output, $depth = 0, $args = array() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
		$indent = str_repeat("\t", $depth);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
		$output .= "$indent<ul class='children'>\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
	 * Ends the list of after the elements are added.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    45
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
	 * @see Walker::end_lvl()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
	 * @since 2.5.1
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
	 * @param string $output Passed by reference. Used to append additional content.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    51
	 * @param int    $depth  Depth of category. Used for tab indentation.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    52
	 * @param array  $args   An array of arguments. @see wp_terms_checklist()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    53
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
	function end_lvl( &$output, $depth = 0, $args = array() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
		$indent = str_repeat("\t", $depth);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    56
		$output .= "$indent</ul>\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    59
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    60
	 * Start the element output.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    61
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    62
	 * @see Walker::start_el()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
	 * @since 2.5.1
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    65
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    66
	 * @param string $output   Passed by reference. Used to append additional content.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
	 * @param object $category The current term object.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
	 * @param int    $depth    Depth of the term in reference to parents. Default 0.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
	 * @param array  $args     An array of arguments. @see wp_terms_checklist()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
	 * @param int    $id       ID of the current term.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    71
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
	function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
		extract($args);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
		if ( empty($taxonomy) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
			$taxonomy = 'category';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    76
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
		if ( $taxonomy == 'category' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
			$name = 'post_category';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
		else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
			$name = 'tax_input['.$taxonomy.']';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
		$class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category"' : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
		$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>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    84
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    85
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    86
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    87
	 * Ends the element output, if needed.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
	 * @see Walker::end_el()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    91
	 * @since 2.5.1
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    92
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    93
	 * @param string $output   Passed by reference. Used to append additional content.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    94
	 * @param object $category The current term object.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    95
	 * @param int    $depth    Depth of the term in reference to parents. Default 0.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    96
	 * @param array  $args     An array of arguments. @see wp_terms_checklist()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    97
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    98
	function end_el( &$output, $category, $depth = 0, $args = array() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    99
		$output .= "</li>\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   100
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   101
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   102
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   103
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   104
 * Output an unordered list of checkbox <input> elements labelled
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   105
 * with category names.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   106
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   107
 * @see wp_terms_checklist()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   108
 * @since 2.5.1
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   109
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   110
 * @param int $post_id Mark categories associated with this post as checked. $selected_cats must not be an array.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   111
 * @param int $descendants_and_self ID of the category to output along with its descendents.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   112
 * @param bool|array $selected_cats List of categories to mark as checked.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   113
 * @param bool|array $popular_cats Override the list of categories that receive the "popular-category" class.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   114
 * @param object $walker Walker object to use to build the output.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   115
 * @param bool $checked_ontop Move checked items out of the hierarchy and to the top of the list.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   116
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   117
function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null, $checked_ontop = true ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   118
	wp_terms_checklist( $post_id, array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   119
		'taxonomy' => 'category',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   120
		'descendants_and_self' => $descendants_and_self,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   121
		'selected_cats' => $selected_cats,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   122
		'popular_cats' => $popular_cats,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   123
		'walker' => $walker,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   124
		'checked_ontop' => $checked_ontop
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   125
	) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   126
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   127
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   128
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   129
 * Output an unordered list of checkbox <input> elements labelled
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   130
 * with term names. Taxonomy independent version of wp_category_checklist().
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   131
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   132
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   133
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   134
 * @param int $post_id
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   135
 * @param array $args
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   136
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   137
function wp_terms_checklist($post_id = 0, $args = array()) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   138
 	$defaults = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   139
		'descendants_and_self' => 0,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   140
		'selected_cats' => false,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   141
		'popular_cats' => false,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   142
		'walker' => null,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   143
		'taxonomy' => 'category',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   144
		'checked_ontop' => true
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   145
	);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   146
	$args = apply_filters( 'wp_terms_checklist_args', $args, $post_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   147
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   148
	extract( wp_parse_args($args, $defaults), EXTR_SKIP );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   149
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   150
	if ( empty($walker) || !is_a($walker, 'Walker') )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   151
		$walker = new Walker_Category_Checklist;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   152
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   153
	$descendants_and_self = (int) $descendants_and_self;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   154
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   155
	$args = array('taxonomy' => $taxonomy);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   156
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   157
	$tax = get_taxonomy($taxonomy);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   158
	$args['disabled'] = !current_user_can($tax->cap->assign_terms);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   159
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   160
	if ( is_array( $selected_cats ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   161
		$args['selected_cats'] = $selected_cats;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   162
	elseif ( $post_id )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   163
		$args['selected_cats'] = wp_get_object_terms($post_id, $taxonomy, array_merge($args, array('fields' => 'ids')));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   164
	else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   165
		$args['selected_cats'] = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   166
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   167
	if ( is_array( $popular_cats ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   168
		$args['popular_cats'] = $popular_cats;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   169
	else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   170
		$args['popular_cats'] = get_terms( $taxonomy, array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   171
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   172
	if ( $descendants_and_self ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   173
		$categories = (array) get_terms($taxonomy, array( 'child_of' => $descendants_and_self, 'hierarchical' => 0, 'hide_empty' => 0 ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   174
		$self = get_term( $descendants_and_self, $taxonomy );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   175
		array_unshift( $categories, $self );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   176
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   177
		$categories = (array) get_terms($taxonomy, array('get' => 'all'));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   178
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   179
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   180
	if ( $checked_ontop ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   181
		// 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)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   182
		$checked_categories = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   183
		$keys = array_keys( $categories );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   184
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   185
		foreach( $keys as $k ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   186
			if ( in_array( $categories[$k]->term_id, $args['selected_cats'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   187
				$checked_categories[] = $categories[$k];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   188
				unset( $categories[$k] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   189
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   190
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   191
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   192
		// Put checked cats on top
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   193
		echo call_user_func_array(array(&$walker, 'walk'), array($checked_categories, 0, $args));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   194
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   195
	// Then the rest of them
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   196
	echo call_user_func_array(array(&$walker, 'walk'), array($categories, 0, $args));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   197
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   198
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   199
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   200
 * Retrieve a list of the most popular terms from the specified taxonomy.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   201
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   202
 * If the $echo argument is true then the elements for a list of checkbox
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   203
 * <input> elements labelled with the names of the selected terms is output.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   204
 * If the $post_ID global isn't empty then the terms associated with that
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   205
 * post will be marked as checked.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   206
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   207
 * @since 2.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   208
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   209
 * @param string $taxonomy Taxonomy to retrieve terms from.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   210
 * @param int $default Unused.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   211
 * @param int $number Number of terms to retrieve. Defaults to 10.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   212
 * @param bool $echo Optionally output the list as well. Defaults to true.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   213
 * @return array List of popular term IDs.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   214
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   215
function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   216
	$post = get_post();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   217
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   218
	if ( $post && $post->ID )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   219
		$checked_terms = wp_get_object_terms($post->ID, $taxonomy, array('fields'=>'ids'));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   220
	else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   221
		$checked_terms = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   222
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   223
	$terms = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number, 'hierarchical' => false ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   224
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   225
	$tax = get_taxonomy($taxonomy);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   226
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   227
	$popular_ids = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   228
	foreach ( (array) $terms as $term ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   229
		$popular_ids[] = $term->term_id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   230
		if ( !$echo ) // hack for AJAX use
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   231
			continue;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   232
		$id = "popular-$taxonomy-$term->term_id";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   233
		$checked = in_array( $term->term_id, $checked_terms ) ? 'checked="checked"' : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   234
		?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   235
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   236
		<li id="<?php echo $id; ?>" class="popular-category">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   237
			<label class="selectit">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   238
			<input id="in-<?php echo $id; ?>" type="checkbox" <?php echo $checked; ?> value="<?php echo (int) $term->term_id; ?>" <?php disabled( ! current_user_can( $tax->cap->assign_terms ) ); ?> />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   239
				<?php echo esc_html( apply_filters( 'the_category', $term->name ) ); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   240
			</label>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   241
		</li>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   242
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   243
		<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   244
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   245
	return $popular_ids;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   246
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   247
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   248
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   249
 * {@internal Missing Short Description}}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   250
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   251
 * @since 2.5.1
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   252
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   253
 * @param unknown_type $link_id
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   254
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   255
function wp_link_category_checklist( $link_id = 0 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   256
	$default = 1;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   257
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   258
	if ( $link_id ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   259
		$checked_categories = wp_get_link_cats( $link_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   260
		// No selected categories, strange
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   261
		if ( ! count( $checked_categories ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   262
			$checked_categories[] = $default;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   263
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   264
		$checked_categories[] = $default;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   265
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   266
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   267
	$categories = get_terms( 'link_category', array( 'orderby' => 'name', 'hide_empty' => 0 ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   268
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   269
	if ( empty( $categories ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   270
		return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   271
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   272
	foreach ( $categories as $category ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   273
		$cat_id = $category->term_id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   274
		$name = esc_html( apply_filters( 'the_category', $category->name ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   275
		$checked = in_array( $cat_id, $checked_categories ) ? ' checked="checked"' : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   276
		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>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   277
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   278
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   279
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   280
// adds hidden fields with the data for use in the inline editor for posts and pages
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   281
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   282
 * {@internal Missing Short Description}}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   283
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   284
 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   285
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   286
 * @param unknown_type $post
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   287
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   288
function get_inline_data($post) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   289
	$post_type_object = get_post_type_object($post->post_type);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   290
	if ( ! current_user_can( 'edit_post', $post->ID ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   291
		return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   292
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   293
	$title = esc_textarea( trim( $post->post_title ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   294
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   295
	echo '
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   296
<div class="hidden" id="inline_' . $post->ID . '">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   297
	<div class="post_title">' . $title . '</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   298
	<div class="post_name">' . apply_filters('editable_slug', $post->post_name) . '</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   299
	<div class="post_author">' . $post->post_author . '</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   300
	<div class="comment_status">' . esc_html( $post->comment_status ) . '</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   301
	<div class="ping_status">' . esc_html( $post->ping_status ) . '</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   302
	<div class="_status">' . esc_html( $post->post_status ) . '</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   303
	<div class="jj">' . mysql2date( 'd', $post->post_date, false ) . '</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   304
	<div class="mm">' . mysql2date( 'm', $post->post_date, false ) . '</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   305
	<div class="aa">' . mysql2date( 'Y', $post->post_date, false ) . '</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   306
	<div class="hh">' . mysql2date( 'H', $post->post_date, false ) . '</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   307
	<div class="mn">' . mysql2date( 'i', $post->post_date, false ) . '</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   308
	<div class="ss">' . mysql2date( 's', $post->post_date, false ) . '</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   309
	<div class="post_password">' . esc_html( $post->post_password ) . '</div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   310
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   311
	if ( $post_type_object->hierarchical )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   312
		echo '<div class="post_parent">' . $post->post_parent . '</div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   313
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   314
	if ( $post->post_type == 'page' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   315
		echo '<div class="page_template">' . esc_html( get_post_meta( $post->ID, '_wp_page_template', true ) ) . '</div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   316
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   317
	if ( post_type_supports( $post->post_type, 'page-attributes' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   318
		echo '<div class="menu_order">' . $post->menu_order . '</div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   319
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   320
	$taxonomy_names = get_object_taxonomies( $post->post_type );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   321
	foreach ( $taxonomy_names as $taxonomy_name) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   322
		$taxonomy = get_taxonomy( $taxonomy_name );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   323
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   324
		if ( $taxonomy->hierarchical && $taxonomy->show_ui ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   325
				echo '<div class="post_category" id="' . $taxonomy_name . '_' . $post->ID . '">'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   326
					. implode( ',', wp_get_object_terms( $post->ID, $taxonomy_name, array( 'fields' => 'ids' ) ) ) . '</div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   327
		} elseif ( $taxonomy->show_ui ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   328
			echo '<div class="tags_input" id="'.$taxonomy_name.'_'.$post->ID.'">'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   329
				. esc_html( str_replace( ',', ', ', get_terms_to_edit( $post->ID, $taxonomy_name ) ) ) . '</div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   330
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   331
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   332
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   333
	if ( !$post_type_object->hierarchical )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   334
		echo '<div class="sticky">' . (is_sticky($post->ID) ? 'sticky' : '') . '</div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   335
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   336
	if ( post_type_supports( $post->post_type, 'post-formats' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   337
		echo '<div class="post_format">' . esc_html( get_post_format( $post->ID ) ) . '</div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   338
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   339
	echo '</div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   340
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   341
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   342
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   343
 * {@internal Missing Short Description}}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   344
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   345
 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   346
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   347
 * @param unknown_type $position
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   348
 * @param unknown_type $checkbox
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   349
 * @param unknown_type $mode
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   350
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   351
function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single', $table_row = true) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   352
	// allow plugin to replace the popup content
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   353
	$content = apply_filters( 'wp_comment_reply', '', array('position' => $position, 'checkbox' => $checkbox, 'mode' => $mode) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   354
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   355
	if ( ! empty($content) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   356
		echo $content;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   357
		return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   358
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   359
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   360
	if ( $mode == 'single' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   361
		$wp_list_table = _get_list_table('WP_Post_Comments_List_Table');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   362
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   363
		$wp_list_table = _get_list_table('WP_Comments_List_Table');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   364
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   365
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   366
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   367
<form method="get" action="">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   368
<?php if ( $table_row ) : ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   369
<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">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   370
<?php else : ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   371
<div id="com-reply" style="display:none;"><div id="replyrow" style="display:none;">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   372
<?php endif; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   373
	<div id="replyhead" style="display:none;"><h5><?php _e( 'Reply to Comment' ); ?></h5></div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   374
	<div id="addhead" style="display:none;"><h5><?php _e('Add new Comment'); ?></h5></div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   375
	<div id="edithead" style="display:none;">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   376
		<div class="inside">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   377
		<label for="author"><?php _e('Name') ?></label>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   378
		<input type="text" name="newcomment_author" size="50" value="" id="author" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   379
		</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   380
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   381
		<div class="inside">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   382
		<label for="author-email"><?php _e('E-mail') ?></label>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   383
		<input type="text" name="newcomment_author_email" size="50" value="" id="author-email" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   384
		</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   385
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   386
		<div class="inside">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   387
		<label for="author-url"><?php _e('URL') ?></label>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   388
		<input type="text" id="author-url" name="newcomment_author_url" size="103" value="" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   389
		</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   390
		<div style="clear:both;"></div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   391
	</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   392
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   393
	<div id="replycontainer">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   394
	<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   395
	$quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   396
	wp_editor( '', 'replycontent', array( 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   397
	?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   398
	</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   399
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   400
	<p id="replysubmit" class="submit">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   401
	<a href="#comments-form" class="save button-primary alignright">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   402
	<span id="addbtn" style="display:none;"><?php _e('Add Comment'); ?></span>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   403
	<span id="savebtn" style="display:none;"><?php _e('Update Comment'); ?></span>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   404
	<span id="replybtn" style="display:none;"><?php _e('Submit Reply'); ?></span></a>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   405
	<a href="#comments-form" class="cancel button-secondary alignleft"><?php _e('Cancel'); ?></a>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   406
	<span class="waiting spinner"></span>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   407
	<span class="error" style="display:none;"></span>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   408
	<br class="clear" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   409
	</p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   410
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   411
	<input type="hidden" name="user_ID" id="user_ID" value="<?php echo get_current_user_id(); ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   412
	<input type="hidden" name="action" id="action" value="" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   413
	<input type="hidden" name="comment_ID" id="comment_ID" value="" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   414
	<input type="hidden" name="comment_post_ID" id="comment_post_ID" value="" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   415
	<input type="hidden" name="status" id="status" value="" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   416
	<input type="hidden" name="position" id="position" value="<?php echo $position; ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   417
	<input type="hidden" name="checkbox" id="checkbox" value="<?php echo $checkbox ? 1 : 0; ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   418
	<input type="hidden" name="mode" id="mode" value="<?php echo esc_attr($mode); ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   419
	<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   420
		wp_nonce_field( 'replyto-comment', '_ajax_nonce-replyto-comment', false );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   421
		if ( current_user_can( 'unfiltered_html' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   422
			wp_nonce_field( 'unfiltered-html-comment', '_wp_unfiltered_html_comment', false );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   423
	?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   424
<?php if ( $table_row ) : ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   425
</td></tr></tbody></table>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   426
<?php else : ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   427
</div></div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   428
<?php endif; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   429
</form>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   430
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   431
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   432
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   433
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   434
 * Output 'undo move to trash' text for comments
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   435
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   436
 * @since 2.9.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   437
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   438
function wp_comment_trashnotice() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   439
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   440
<div class="hidden" id="trash-undo-holder">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   441
	<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>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   442
</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   443
<div class="hidden" id="spam-undo-holder">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   444
	<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>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   445
</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   446
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   447
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   448
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   449
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   450
 * {@internal Missing Short Description}}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   451
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   452
 * @since 1.2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   453
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   454
 * @param unknown_type $meta
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   455
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   456
function list_meta( $meta ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   457
	// Exit if no meta
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   458
	if ( ! $meta ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   459
		echo '
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   460
<table id="list-table" style="display: none;">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   461
	<thead>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   462
	<tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   463
		<th class="left">' . _x( 'Name', 'meta name' ) . '</th>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   464
		<th>' . __( 'Value' ) . '</th>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   465
	</tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   466
	</thead>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   467
	<tbody id="the-list" data-wp-lists="list:meta">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   468
	<tr><td></td></tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   469
	</tbody>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   470
</table>'; //TBODY needed for list-manipulation JS
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   471
		return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   472
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   473
	$count = 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   474
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   475
<table id="list-table">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   476
	<thead>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   477
	<tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   478
		<th class="left"><?php _ex( 'Name', 'meta name' ) ?></th>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   479
		<th><?php _e( 'Value' ) ?></th>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   480
	</tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   481
	</thead>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   482
	<tbody id='the-list' data-wp-lists='list:meta'>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   483
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   484
	foreach ( $meta as $entry )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   485
		echo _list_meta_row( $entry, $count );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   486
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   487
	</tbody>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   488
</table>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   489
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   490
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   491
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   492
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   493
 * {@internal Missing Short Description}}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   494
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   495
 * @since 2.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   496
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   497
 * @param unknown_type $entry
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   498
 * @param unknown_type $count
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   499
 * @return unknown
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   500
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   501
function _list_meta_row( $entry, &$count ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   502
	static $update_nonce = false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   503
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   504
	if ( is_protected_meta( $entry['meta_key'], 'post' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   505
		return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   506
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   507
	if ( !$update_nonce )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   508
		$update_nonce = wp_create_nonce( 'add-meta' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   509
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   510
	$r = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   511
	++ $count;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   512
	if ( $count % 2 )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   513
		$style = 'alternate';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   514
	else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   515
		$style = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   516
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   517
	if ( is_serialized( $entry['meta_value'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   518
		if ( is_serialized_string( $entry['meta_value'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   519
			// this is a serialized string, so we should display it
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   520
			$entry['meta_value'] = maybe_unserialize( $entry['meta_value'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   521
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   522
			// this is a serialized array/object so we should NOT display it
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   523
			--$count;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   524
			return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   525
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   526
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   527
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   528
	$entry['meta_key'] = esc_attr($entry['meta_key']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   529
	$entry['meta_value'] = esc_textarea( $entry['meta_value'] ); // using a <textarea />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   530
	$entry['meta_id'] = (int) $entry['meta_id'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   531
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   532
	$delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   533
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   534
	$r .= "\n\t<tr id='meta-{$entry['meta_id']}' class='$style'>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   535
	$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]' type='text' size='20' value='{$entry['meta_key']}' />";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   536
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   537
	$r .= "\n\t\t<div class='submit'>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   538
	$r .= get_submit_button( __( 'Delete' ), 'deletemeta small', "deletemeta[{$entry['meta_id']}]", false, array( 'data-wp-lists' => "delete:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$delete_nonce" ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   539
	$r .= "\n\t\t";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   540
	$r .= get_submit_button( __( 'Update' ), 'updatemeta small', "meta-{$entry['meta_id']}-submit", false, array( 'data-wp-lists' => "add:the-list:meta-{$entry['meta_id']}::_ajax_nonce-add-meta=$update_nonce" ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   541
	$r .= "</div>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   542
	$r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   543
	$r .= "</td>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   544
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   545
	$r .= "\n\t\t<td><label class='screen-reader-text' for='meta[{$entry['meta_id']}][value]'>" . __( 'Value' ) . "</label><textarea name='meta[{$entry['meta_id']}][value]' id='meta[{$entry['meta_id']}][value]' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>\n\t</tr>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   546
	return $r;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   547
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   548
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   549
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   550
 * Prints the form in the Custom Fields meta box.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   551
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   552
 * @since 1.2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   553
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   554
 * @param WP_Post $post Optional. The post being edited.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   555
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   556
function meta_form( $post = null ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   557
	global $wpdb;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   558
	$post = get_post( $post );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   559
	$limit = (int) apply_filters( 'postmeta_form_limit', 30 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   560
	$keys = $wpdb->get_col( "
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   561
		SELECT meta_key
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   562
		FROM $wpdb->postmeta
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   563
		GROUP BY meta_key
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   564
		HAVING meta_key NOT LIKE '\_%'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   565
		ORDER BY meta_key
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   566
		LIMIT $limit" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   567
	if ( $keys )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   568
		natcasesort($keys);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   569
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   570
<p><strong><?php _e( 'Add New Custom Field:' ) ?></strong></p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   571
<table id="newmeta">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   572
<thead>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   573
<tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   574
<th class="left"><label for="metakeyselect"><?php _ex( 'Name', 'meta name' ) ?></label></th>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   575
<th><label for="metavalue"><?php _e( 'Value' ) ?></label></th>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   576
</tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   577
</thead>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   578
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   579
<tbody>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   580
<tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   581
<td id="newmetaleft" class="left">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   582
<?php if ( $keys ) { ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   583
<select id="metakeyselect" name="metakeyselect">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   584
<option value="#NONE#"><?php _e( '&mdash; Select &mdash;' ); ?></option>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   585
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   586
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   587
	foreach ( $keys as $key ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   588
		if ( is_protected_meta( $key, 'post' ) || ! current_user_can( 'add_post_meta', $post->ID, $key ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   589
			continue;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   590
		echo "\n<option value='" . esc_attr($key) . "'>" . esc_html($key) . "</option>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   591
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   592
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   593
</select>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   594
<input class="hide-if-js" type="text" id="metakeyinput" name="metakeyinput" value="" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   595
<a href="#postcustomstuff" class="hide-if-no-js" onclick="jQuery('#metakeyinput, #metakeyselect, #enternew, #cancelnew').toggle();return false;">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   596
<span id="enternew"><?php _e('Enter new'); ?></span>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   597
<span id="cancelnew" class="hidden"><?php _e('Cancel'); ?></span></a>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   598
<?php } else { ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   599
<input type="text" id="metakeyinput" name="metakeyinput" value="" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   600
<?php } ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   601
</td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   602
<td><textarea id="metavalue" name="metavalue" rows="2" cols="25"></textarea></td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   603
</tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   604
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   605
<tr><td colspan="2">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   606
<div class="submit">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   607
<?php submit_button( __( 'Add Custom Field' ), 'secondary', 'addmeta', false, array( 'id' => 'newmeta-submit', 'data-wp-lists' => 'add:the-list:newmeta' ) ); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   608
</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   609
<?php wp_nonce_field( 'add-meta', '_ajax_nonce-add-meta', false ); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   610
</td></tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   611
</tbody>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   612
</table>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   613
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   614
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   615
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   616
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   617
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   618
 * {@internal Missing Short Description}}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   619
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   620
 * @since 0.71
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   621
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   622
 * @param unknown_type $edit
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   623
 * @param unknown_type $for_post
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   624
 * @param unknown_type $tab_index
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   625
 * @param unknown_type $multi
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   626
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   627
function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   628
	global $wp_locale, $comment;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   629
	$post = get_post();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   630
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   631
	if ( $for_post )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   632
		$edit = ! ( in_array($post->post_status, array('draft', 'pending') ) && (!$post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   633
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   634
	$tab_index_attribute = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   635
	if ( (int) $tab_index > 0 )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   636
		$tab_index_attribute = " tabindex=\"$tab_index\"";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   637
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   638
	// 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 />';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   639
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   640
	$time_adj = current_time('timestamp');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   641
	$post_date = ($for_post) ? $post->post_date : $comment->comment_date;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   642
	$jj = ($edit) ? mysql2date( 'd', $post_date, false ) : gmdate( 'd', $time_adj );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   643
	$mm = ($edit) ? mysql2date( 'm', $post_date, false ) : gmdate( 'm', $time_adj );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   644
	$aa = ($edit) ? mysql2date( 'Y', $post_date, false ) : gmdate( 'Y', $time_adj );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   645
	$hh = ($edit) ? mysql2date( 'H', $post_date, false ) : gmdate( 'H', $time_adj );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   646
	$mn = ($edit) ? mysql2date( 'i', $post_date, false ) : gmdate( 'i', $time_adj );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   647
	$ss = ($edit) ? mysql2date( 's', $post_date, false ) : gmdate( 's', $time_adj );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   648
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   649
	$cur_jj = gmdate( 'd', $time_adj );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   650
	$cur_mm = gmdate( 'm', $time_adj );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   651
	$cur_aa = gmdate( 'Y', $time_adj );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   652
	$cur_hh = gmdate( 'H', $time_adj );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   653
	$cur_mn = gmdate( 'i', $time_adj );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   654
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   655
	$month = "<select " . ( $multi ? '' : 'id="mm" ' ) . "name=\"mm\"$tab_index_attribute>\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   656
	for ( $i = 1; $i < 13; $i = $i +1 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   657
		$monthnum = zeroise($i, 2);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   658
		$month .= "\t\t\t" . '<option value="' . $monthnum . '"';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   659
		if ( $i == $mm )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   660
			$month .= ' selected="selected"';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   661
		/* translators: 1: month number (01, 02, etc.), 2: month abbreviation */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   662
		$month .= '>' . sprintf( __( '%1$s-%2$s' ), $monthnum, $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ) ) . "</option>\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   663
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   664
	$month .= '</select>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   665
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   666
	$day = '<input type="text" ' . ( $multi ? '' : 'id="jj" ' ) . 'name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   667
	$year = '<input type="text" ' . ( $multi ? '' : 'id="aa" ' ) . 'name="aa" value="' . $aa . '" size="4" maxlength="4"' . $tab_index_attribute . ' autocomplete="off" />';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   668
	$hour = '<input type="text" ' . ( $multi ? '' : 'id="hh" ' ) . 'name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   669
	$minute = '<input type="text" ' . ( $multi ? '' : 'id="mn" ' ) . 'name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   670
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   671
	echo '<div class="timestamp-wrap">';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   672
	/* translators: 1: month, 2: day, 3: year, 4: hour, 5: minute */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   673
	printf( __( '%1$s %2$s, %3$s @ %4$s : %5$s' ), $month, $day, $year, $hour, $minute );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   674
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   675
	echo '</div><input type="hidden" id="ss" name="ss" value="' . $ss . '" />';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   676
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   677
	if ( $multi ) return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   678
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   679
	echo "\n\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   680
	foreach ( array('mm', 'jj', 'aa', 'hh', 'mn') as $timeunit ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   681
		echo '<input type="hidden" id="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . $$timeunit . '" />' . "\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   682
		$cur_timeunit = 'cur_' . $timeunit;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   683
		echo '<input type="hidden" id="'. $cur_timeunit . '" name="'. $cur_timeunit . '" value="' . $$cur_timeunit . '" />' . "\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   684
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   685
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   686
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   687
<p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   688
<a href="#edit_timestamp" class="save-timestamp hide-if-no-js button"><?php _e('OK'); ?></a>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   689
<a href="#edit_timestamp" class="cancel-timestamp hide-if-no-js"><?php _e('Cancel'); ?></a>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   690
</p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   691
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   692
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   693
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   694
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   695
 * {@internal Missing Short Description}}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   696
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   697
 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   698
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   699
 * @param unknown_type $default
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   700
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   701
function page_template_dropdown( $default = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   702
	$templates = get_page_templates();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   703
	ksort( $templates );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   704
	foreach (array_keys( $templates ) as $template )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   705
		: if ( $default == $templates[$template] )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   706
			$selected = " selected='selected'";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   707
		else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   708
			$selected = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   709
	echo "\n\t<option value='".$templates[$template]."' $selected>$template</option>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   710
	endforeach;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   711
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   712
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   713
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   714
 * {@internal Missing Short Description}}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   715
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   716
 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   717
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   718
 * @param unknown_type $default
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   719
 * @param unknown_type $parent
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   720
 * @param unknown_type $level
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   721
 * @return unknown
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   722
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   723
function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   724
	global $wpdb;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   725
	$post = get_post();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   726
	$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) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   727
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   728
	if ( $items ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   729
		foreach ( $items as $item ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   730
			// A page cannot be its own parent.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   731
			if ( $post && $post->ID && $item->ID == $post->ID )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   732
				continue;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   733
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   734
			$pad = str_repeat( '&nbsp;', $level * 3 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   735
			if ( $item->ID == $default)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   736
				$current = ' selected="selected"';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   737
			else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   738
				$current = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   739
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   740
			echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad " . esc_html($item->post_title) . "</option>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   741
			parent_dropdown( $default, $item->ID, $level +1 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   742
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   743
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   744
		return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   745
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   746
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   747
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   748
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   749
 * Print out <option> html elements for role selectors
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   750
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   751
 * @since 2.1.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   752
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   753
 * @param string $selected slug for the role that should be already selected
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   754
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   755
function wp_dropdown_roles( $selected = false ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   756
	$p = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   757
	$r = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   758
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   759
	$editable_roles = array_reverse( get_editable_roles() );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   760
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   761
	foreach ( $editable_roles as $role => $details ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   762
		$name = translate_user_role($details['name'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   763
		if ( $selected == $role ) // preselect specified role
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   764
			$p = "\n\t<option selected='selected' value='" . esc_attr($role) . "'>$name</option>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   765
		else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   766
			$r .= "\n\t<option value='" . esc_attr($role) . "'>$name</option>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   767
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   768
	echo $p . $r;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   769
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   770
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   771
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   772
 * Outputs the form used by the importers to accept the data to be imported
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   773
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   774
 * @since 2.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   775
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   776
 * @param string $action The action attribute for the form.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   777
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   778
function wp_import_upload_form( $action ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   779
	$bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   780
	$size = size_format( $bytes );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   781
	$upload_dir = wp_upload_dir();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   782
	if ( ! empty( $upload_dir['error'] ) ) :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   783
		?><div class="error"><p><?php _e('Before you can upload your import file, you will need to fix the following error:'); ?></p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   784
		<p><strong><?php echo $upload_dir['error']; ?></strong></p></div><?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   785
	else :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   786
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   787
<form enctype="multipart/form-data" id="import-upload-form" method="post" class="wp-upload-form" action="<?php echo esc_url( wp_nonce_url( $action, 'import-upload' ) ); ?>">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   788
<p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   789
<label for="upload"><?php _e( 'Choose a file from your computer:' ); ?></label> (<?php printf( __('Maximum size: %s' ), $size ); ?>)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   790
<input type="file" id="upload" name="import" size="25" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   791
<input type="hidden" name="action" value="save" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   792
<input type="hidden" name="max_file_size" value="<?php echo $bytes; ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   793
</p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   794
<?php submit_button( __('Upload file and import'), 'button' ); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   795
</form>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   796
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   797
	endif;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   798
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   799
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   800
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   801
 * Add a meta box to an edit form.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   802
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   803
 * @since 2.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   804
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   805
 * @param string $id String for use in the 'id' attribute of tags.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   806
 * @param string $title Title of the meta box.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   807
 * @param string $callback Function that fills the box with the desired content. The function should echo its output.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   808
 * @param string|object $screen Optional. The screen on which to show the box (post, page, link). Defaults to current screen.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   809
 * @param string $context Optional. The context within the page where the boxes should show ('normal', 'advanced').
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   810
 * @param string $priority Optional. The priority within the context where the boxes should show ('high', 'low').
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   811
 * @param array $callback_args Optional. Data that should be set as the "args" property of the box array (which is the second parameter passed to your callback).
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   812
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   813
function add_meta_box( $id, $title, $callback, $screen = null, $context = 'advanced', $priority = 'default', $callback_args = null ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   814
	global $wp_meta_boxes;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   815
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   816
	if ( empty( $screen ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   817
		$screen = get_current_screen();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   818
	elseif ( is_string( $screen ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   819
		$screen = convert_to_screen( $screen );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   820
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   821
	$page = $screen->id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   822
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   823
	if ( !isset($wp_meta_boxes) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   824
		$wp_meta_boxes = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   825
	if ( !isset($wp_meta_boxes[$page]) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   826
		$wp_meta_boxes[$page] = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   827
	if ( !isset($wp_meta_boxes[$page][$context]) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   828
		$wp_meta_boxes[$page][$context] = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   829
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   830
	foreach ( array_keys($wp_meta_boxes[$page]) as $a_context ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   831
		foreach ( array('high', 'core', 'default', 'low') as $a_priority ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   832
			if ( !isset($wp_meta_boxes[$page][$a_context][$a_priority][$id]) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   833
				continue;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   834
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   835
			// If a core box was previously added or removed by a plugin, don't add.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   836
			if ( 'core' == $priority ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   837
				// If core box previously deleted, don't add
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   838
				if ( false === $wp_meta_boxes[$page][$a_context][$a_priority][$id] )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   839
					return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   840
				// If box was added with default priority, give it core priority to maintain sort order
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   841
				if ( 'default' == $a_priority ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   842
					$wp_meta_boxes[$page][$a_context]['core'][$id] = $wp_meta_boxes[$page][$a_context]['default'][$id];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   843
					unset($wp_meta_boxes[$page][$a_context]['default'][$id]);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   844
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   845
				return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   846
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   847
			// If no priority given and id already present, use existing priority
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   848
			if ( empty($priority) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   849
				$priority = $a_priority;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   850
			// 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.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   851
			} elseif ( 'sorted' == $priority ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   852
				$title = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['title'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   853
				$callback = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['callback'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   854
				$callback_args = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['args'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   855
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   856
			// An id can be in only one priority and one context
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   857
			if ( $priority != $a_priority || $context != $a_context )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   858
				unset($wp_meta_boxes[$page][$a_context][$a_priority][$id]);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   859
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   860
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   861
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   862
	if ( empty($priority) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   863
		$priority = 'low';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   864
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   865
	if ( !isset($wp_meta_boxes[$page][$context][$priority]) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   866
		$wp_meta_boxes[$page][$context][$priority] = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   867
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   868
	$wp_meta_boxes[$page][$context][$priority][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $callback_args);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   869
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   870
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   871
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   872
 * Meta-Box template function
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   873
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   874
 * @since 2.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   875
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   876
 * @param string|object $screen Screen identifier
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   877
 * @param string $context box context
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   878
 * @param mixed $object gets passed to the box callback function as first parameter
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   879
 * @return int number of meta_boxes
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   880
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   881
function do_meta_boxes( $screen, $context, $object ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   882
	global $wp_meta_boxes;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   883
	static $already_sorted = false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   884
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   885
	if ( empty( $screen ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   886
		$screen = get_current_screen();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   887
	elseif ( is_string( $screen ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   888
		$screen = convert_to_screen( $screen );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   889
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   890
	$page = $screen->id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   891
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   892
	$hidden = get_hidden_meta_boxes( $screen );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   893
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   894
	printf('<div id="%s-sortables" class="meta-box-sortables">', htmlspecialchars($context));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   895
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   896
	$i = 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   897
	do {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   898
		// Grab the ones the user has manually sorted. Pull them out of their previous context/priority and into the one the user chose
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   899
		if ( !$already_sorted && $sorted = get_user_option( "meta-box-order_$page" ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   900
			foreach ( $sorted as $box_context => $ids ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   901
				foreach ( explode(',', $ids ) as $id ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   902
					if ( $id && 'dashboard_browser_nag' !== $id )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   903
						add_meta_box( $id, null, null, $screen, $box_context, 'sorted' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   904
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   905
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   906
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   907
		$already_sorted = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   908
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   909
		if ( !isset($wp_meta_boxes) || !isset($wp_meta_boxes[$page]) || !isset($wp_meta_boxes[$page][$context]) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   910
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   911
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   912
		foreach ( array('high', 'sorted', 'core', 'default', 'low') as $priority ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   913
			if ( isset($wp_meta_boxes[$page][$context][$priority]) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   914
				foreach ( (array) $wp_meta_boxes[$page][$context][$priority] as $box ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   915
					if ( false == $box || ! $box['title'] )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   916
						continue;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   917
					$i++;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   918
					$hidden_class = in_array($box['id'], $hidden) ? ' hide-if-js' : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   919
					echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id'], $page) . $hidden_class . '" ' . '>' . "\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   920
					if ( 'dashboard_browser_nag' != $box['id'] )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   921
						echo '<div class="handlediv" title="' . esc_attr__('Click to toggle') . '"><br /></div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   922
					echo "<h3 class='hndle'><span>{$box['title']}</span></h3>\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   923
					echo '<div class="inside">' . "\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   924
					call_user_func($box['callback'], $object, $box);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   925
					echo "</div>\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   926
					echo "</div>\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   927
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   928
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   929
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   930
	} while(0);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   931
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   932
	echo "</div>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   933
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   934
	return $i;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   935
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   936
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   937
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   938
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   939
 * Remove a meta box from an edit form.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   940
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   941
 * @since 2.6.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   942
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   943
 * @param string $id String for use in the 'id' attribute of tags.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   944
 * @param string|object $screen The screen on which to show the box (post, page, link).
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   945
 * @param string $context The context within the page where the boxes should show ('normal', 'advanced').
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   946
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   947
function remove_meta_box($id, $screen, $context) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   948
	global $wp_meta_boxes;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   949
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   950
	if ( empty( $screen ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   951
		$screen = get_current_screen();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   952
	elseif ( is_string( $screen ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   953
		$screen = convert_to_screen( $screen );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   954
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   955
	$page = $screen->id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   956
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   957
	if ( !isset($wp_meta_boxes) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   958
		$wp_meta_boxes = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   959
	if ( !isset($wp_meta_boxes[$page]) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   960
		$wp_meta_boxes[$page] = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   961
	if ( !isset($wp_meta_boxes[$page][$context]) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   962
		$wp_meta_boxes[$page][$context] = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   963
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   964
	foreach ( array('high', 'core', 'default', 'low') as $priority )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   965
		$wp_meta_boxes[$page][$context][$priority][$id] = false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   966
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   967
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   968
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   969
 * Meta Box Accordion Template Function
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   970
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   971
 * Largely made up of abstracted code from {@link do_meta_boxes()}, this
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   972
 * function serves to build meta boxes as list items for display as
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   973
 * a collapsible accordion.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   974
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   975
 * @since 3.6.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   976
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   977
 * @uses global $wp_meta_boxes Used to retrieve registered meta boxes.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   978
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   979
 * @param string|object $screen The screen identifier.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   980
 * @param string $context The meta box context.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   981
 * @param mixed $object gets passed to the section callback function as first parameter.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   982
 * @return int number of meta boxes as accordion sections.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   983
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   984
function do_accordion_sections( $screen, $context, $object ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   985
	global $wp_meta_boxes;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   986
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   987
	wp_enqueue_script( 'accordion' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   988
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   989
	if ( empty( $screen ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   990
		$screen = get_current_screen();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   991
	elseif ( is_string( $screen ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   992
		$screen = convert_to_screen( $screen );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   993
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   994
	$page = $screen->id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   995
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   996
	$hidden = get_hidden_meta_boxes( $screen );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   997
	?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   998
	<div id="side-sortables" class="accordion-container">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   999
		<ul class="outer-border">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1000
	<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1001
	$i = 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1002
	$first_open = false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1003
	do {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1004
		if ( ! isset( $wp_meta_boxes ) || ! isset( $wp_meta_boxes[$page] ) || ! isset( $wp_meta_boxes[$page][$context] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1005
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1006
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1007
		foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1008
			if ( isset( $wp_meta_boxes[$page][$context][$priority] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1009
				foreach ( $wp_meta_boxes[$page][$context][$priority] as $box ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1010
					if ( false == $box || ! $box['title'] )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1011
						continue;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1012
					$i++;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1013
					$hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1014
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1015
					$open_class = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1016
					if ( ! $first_open && empty( $hidden_class ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1017
						$first_open = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1018
						$open_class = 'open';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1019
					}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1020
					?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1021
					<li class="control-section accordion-section <?php echo $hidden_class; ?> <?php echo $open_class; ?> <?php echo esc_attr( $box['id'] ); ?>" id="<?php echo esc_attr( $box['id'] ); ?>">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1022
						<h3 class="accordion-section-title hndle" tabindex="0" title="<?php echo esc_attr( $box['title'] ); ?>"><?php echo esc_html( $box['title'] ); ?></h3>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1023
						<div class="accordion-section-content <?php postbox_classes( $box['id'], $page ); ?>">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1024
							<div class="inside">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1025
								<?php call_user_func( $box['callback'], $object, $box ); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1026
							</div><!-- .inside -->
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1027
						</div><!-- .accordion-section-content -->
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1028
					</li><!-- .accordion-section -->
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1029
					<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1030
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1031
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1032
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1033
	} while(0);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1034
	?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1035
		</ul><!-- .outer-border -->
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1036
	</div><!-- .accordion-container -->
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1037
	<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1038
	return $i;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1039
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1040
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1041
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1042
 * Add a new section to a settings page.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1043
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1044
 * Part of the Settings API. Use this to define new settings sections for an admin page.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1045
 * Show settings sections in your admin page callback function with do_settings_sections().
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1046
 * Add settings fields to your section with add_settings_field()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1047
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1048
 * The $callback argument should be the name of a function that echoes out any
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1049
 * content you want to show at the top of the settings section before the actual
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1050
 * fields. It can output nothing if you want.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1051
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1052
 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1053
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1054
 * @global $wp_settings_sections Storage array of all settings sections added to admin pages
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1055
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1056
 * @param string $id Slug-name to identify the section. Used in the 'id' attribute of tags.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1057
 * @param string $title Formatted title of the section. Shown as the heading for the section.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1058
 * @param string $callback Function that echos out any content at the top of the section (between heading and fields).
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1059
 * @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();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1060
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1061
function add_settings_section($id, $title, $callback, $page) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1062
	global $wp_settings_sections;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1063
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1064
	if ( 'misc' == $page ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1065
		_deprecated_argument( __FUNCTION__, '3.0', sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'misc' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1066
		$page = 'general';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1067
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1068
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1069
	if ( 'privacy' == $page ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1070
		_deprecated_argument( __FUNCTION__, '3.5', sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'privacy' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1071
		$page = 'reading';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1072
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1073
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1074
	$wp_settings_sections[$page][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1075
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1076
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1077
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1078
 * Add a new field to a section of a settings page
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1079
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1080
 * Part of the Settings API. Use this to define a settings field that will show
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1081
 * as part of a settings section inside a settings page. The fields are shown using
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1082
 * do_settings_fields() in do_settings-sections()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1083
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1084
 * The $callback argument should be the name of a function that echoes out the
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1085
 * html input tags for this setting field. Use get_option() to retrieve existing
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1086
 * values to show.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1087
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1088
 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1089
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1090
 * @global $wp_settings_fields Storage array of settings fields and info about their pages/sections
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1091
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1092
 * @param string $id Slug-name to identify the field. Used in the 'id' attribute of tags.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1093
 * @param string $title Formatted title of the field. Shown as the label for the field during output.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1094
 * @param string $callback Function that fills the field with the desired form inputs. The function should echo its output.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1095
 * @param string $page The slug-name of the settings page on which to show the section (general, reading, writing, ...).
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1096
 * @param string $section The slug-name of the section of the settings page in which to show the box (default, ...).
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1097
 * @param array $args Additional arguments
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1098
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1099
function add_settings_field($id, $title, $callback, $page, $section = 'default', $args = array()) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1100
	global $wp_settings_fields;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1101
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1102
	if ( 'misc' == $page ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1103
		_deprecated_argument( __FUNCTION__, '3.0', __( 'The miscellaneous options group has been removed. Use another settings group.' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1104
		$page = 'general';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1105
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1106
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1107
	if ( 'privacy' == $page ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1108
		_deprecated_argument( __FUNCTION__, '3.5', __( 'The privacy options group has been removed. Use another settings group.' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1109
		$page = 'reading';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1110
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1111
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1112
	$wp_settings_fields[$page][$section][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $args);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1113
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1114
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1115
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1116
 * Prints out all settings sections added to a particular settings page
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1117
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1118
 * Part of the Settings API. Use this in a settings page callback function
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1119
 * to output all the sections and fields that were added to that $page with
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1120
 * add_settings_section() and add_settings_field()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1121
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1122
 * @global $wp_settings_sections Storage array of all settings sections added to admin pages
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1123
 * @global $wp_settings_fields Storage array of settings fields and info about their pages/sections
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1124
 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1125
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1126
 * @param string $page The slug name of the page whos settings sections you want to output
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1127
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1128
function do_settings_sections( $page ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1129
	global $wp_settings_sections, $wp_settings_fields;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1130
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1131
	if ( ! isset( $wp_settings_sections[$page] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1132
		return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1133
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1134
	foreach ( (array) $wp_settings_sections[$page] as $section ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1135
		if ( $section['title'] )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1136
			echo "<h3>{$section['title']}</h3>\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1137
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1138
		if ( $section['callback'] )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1139
			call_user_func( $section['callback'], $section );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1140
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1141
		if ( ! isset( $wp_settings_fields ) || !isset( $wp_settings_fields[$page] ) || !isset( $wp_settings_fields[$page][$section['id']] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1142
			continue;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1143
		echo '<table class="form-table">';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1144
		do_settings_fields( $page, $section['id'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1145
		echo '</table>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1146
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1147
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1148
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1149
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1150
 * Print out the settings fields for a particular settings section
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1151
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1152
 * Part of the Settings API. Use this in a settings page to output
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1153
 * a specific section. Should normally be called by do_settings_sections()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1154
 * rather than directly.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1155
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1156
 * @global $wp_settings_fields Storage array of settings fields and their pages/sections
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1157
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1158
 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1159
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1160
 * @param string $page Slug title of the admin page who's settings fields you want to show.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1161
 * @param section $section Slug title of the settings section who's fields you want to show.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1162
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1163
function do_settings_fields($page, $section) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1164
	global $wp_settings_fields;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1165
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1166
	if ( ! isset( $wp_settings_fields[$page][$section] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1167
		return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1168
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1169
	foreach ( (array) $wp_settings_fields[$page][$section] as $field ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1170
		echo '<tr valign="top">';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1171
		if ( !empty($field['args']['label_for']) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1172
			echo '<th scope="row"><label for="' . esc_attr( $field['args']['label_for'] ) . '">' . $field['title'] . '</label></th>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1173
		else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1174
			echo '<th scope="row">' . $field['title'] . '</th>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1175
		echo '<td>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1176
		call_user_func($field['callback'], $field['args']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1177
		echo '</td>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1178
		echo '</tr>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1179
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1180
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1181
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1182
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1183
 * Register a settings error to be displayed to the user
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1184
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1185
 * Part of the Settings API. Use this to show messages to users about settings validation
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1186
 * problems, missing settings or anything else.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1187
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1188
 * Settings errors should be added inside the $sanitize_callback function defined in
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1189
 * register_setting() for a given setting to give feedback about the submission.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1190
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1191
 * By default messages will show immediately after the submission that generated the error.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1192
 * Additional calls to settings_errors() can be used to show errors even when the settings
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1193
 * page is first accessed.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1194
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1195
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1196
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1197
 * @global array $wp_settings_errors Storage array of errors registered during this pageload
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1198
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1199
 * @param string $setting Slug title of the setting to which this error applies
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1200
 * @param string $code Slug-name to identify the error. Used as part of 'id' attribute in HTML output.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1201
 * @param string $message The formatted message text to display to the user (will be shown inside styled <div> and <p>)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1202
 * @param string $type The type of message it is, controls HTML class. Use 'error' or 'updated'.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1203
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1204
function add_settings_error( $setting, $code, $message, $type = 'error' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1205
	global $wp_settings_errors;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1206
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1207
	$new_error = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1208
		'setting' => $setting,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1209
		'code' => $code,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1210
		'message' => $message,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1211
		'type' => $type
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1212
	);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1213
	$wp_settings_errors[] = $new_error;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1214
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1215
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1216
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1217
 * Fetch settings errors registered by add_settings_error()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1218
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1219
 * Checks the $wp_settings_errors array for any errors declared during the current
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1220
 * pageload and returns them.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1221
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1222
 * If changes were just submitted ($_GET['settings-updated']) and settings errors were saved
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1223
 * to the 'settings_errors' transient then those errors will be returned instead. This
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1224
 * is used to pass errors back across pageloads.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1225
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1226
 * Use the $sanitize argument to manually re-sanitize the option before returning errors.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1227
 * This is useful if you have errors or notices you want to show even when the user
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1228
 * hasn't submitted data (i.e. when they first load an options page, or in admin_notices action hook)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1229
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1230
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1231
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1232
 * @global array $wp_settings_errors Storage array of errors registered during this pageload
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1233
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1234
 * @param string $setting Optional slug title of a specific setting who's errors you want.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1235
 * @param boolean $sanitize Whether to re-sanitize the setting value before returning errors.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1236
 * @return array Array of settings errors
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1237
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1238
function get_settings_errors( $setting = '', $sanitize = false ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1239
	global $wp_settings_errors;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1240
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1241
	// If $sanitize is true, manually re-run the sanitization for this option
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1242
	// This allows the $sanitize_callback from register_setting() to run, adding
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1243
	// any settings errors you want to show by default.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1244
	if ( $sanitize )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1245
		sanitize_option( $setting, get_option( $setting ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1246
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1247
	// If settings were passed back from options.php then use them
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1248
	if ( isset( $_GET['settings-updated'] ) && $_GET['settings-updated'] && get_transient( 'settings_errors' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1249
		$wp_settings_errors = array_merge( (array) $wp_settings_errors, get_transient( 'settings_errors' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1250
		delete_transient( 'settings_errors' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1251
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1252
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1253
	// Check global in case errors have been added on this pageload
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1254
	if ( ! count( $wp_settings_errors ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1255
		return array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1256
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1257
	// Filter the results to those of a specific setting if one was set
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1258
	if ( $setting ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1259
		$setting_errors = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1260
		foreach ( (array) $wp_settings_errors as $key => $details ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1261
			if ( $setting == $details['setting'] )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1262
				$setting_errors[] = $wp_settings_errors[$key];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1263
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1264
		return $setting_errors;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1265
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1266
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1267
	return $wp_settings_errors;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1268
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1269
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1270
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1271
 * Display settings errors registered by add_settings_error()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1272
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1273
 * Part of the Settings API. Outputs a <div> for each error retrieved by get_settings_errors().
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1274
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1275
 * This is called automatically after a settings page based on the Settings API is submitted.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1276
 * Errors should be added during the validation callback function for a setting defined in register_setting()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1277
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1278
 * The $sanitize option is passed into get_settings_errors() and will re-run the setting sanitization
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1279
 * on its current value.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1280
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1281
 * The $hide_on_update option will cause errors to only show when the settings page is first loaded.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1282
 * if the user has already saved new values it will be hidden to avoid repeating messages already
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1283
 * shown in the default error reporting after submission. This is useful to show general errors like missing
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1284
 * settings when the user arrives at the settings page.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1285
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1286
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1287
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1288
 * @param string $setting Optional slug title of a specific setting who's errors you want.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1289
 * @param boolean $sanitize Whether to re-sanitize the setting value before returning errors.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1290
 * @param boolean $hide_on_update If set to true errors will not be shown if the settings page has already been submitted.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1291
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1292
function settings_errors( $setting = '', $sanitize = false, $hide_on_update = false ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1293
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1294
	if ( $hide_on_update && ! empty( $_GET['settings-updated'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1295
		return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1296
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1297
	$settings_errors = get_settings_errors( $setting, $sanitize );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1298
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1299
	if ( empty( $settings_errors ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1300
		return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1301
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1302
	$output = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1303
	foreach ( $settings_errors as $key => $details ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1304
		$css_id = 'setting-error-' . $details['code'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1305
		$css_class = $details['type'] . ' settings-error';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1306
		$output .= "<div id='$css_id' class='$css_class'> \n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1307
		$output .= "<p><strong>{$details['message']}</strong></p>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1308
		$output .= "</div> \n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1309
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1310
	echo $output;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1311
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1312
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1313
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1314
 * {@internal Missing Short Description}}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1315
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1316
 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1317
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1318
 * @param unknown_type $found_action
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1319
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1320
function find_posts_div($found_action = '') {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1321
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1322
	<div id="find-posts" class="find-box" style="display:none;">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1323
		<div id="find-posts-head" class="find-box-head"><?php _e('Find Posts or Pages'); ?></div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1324
		<div class="find-box-inside">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1325
			<div class="find-box-search">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1326
				<?php if ( $found_action ) { ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1327
					<input type="hidden" name="found_action" value="<?php echo esc_attr($found_action); ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1328
				<?php } ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1329
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1330
				<input type="hidden" name="affected" id="affected" value="" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1331
				<?php wp_nonce_field( 'find-posts', '_ajax_nonce', false ); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1332
				<label class="screen-reader-text" for="find-posts-input"><?php _e( 'Search' ); ?></label>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1333
				<input type="text" id="find-posts-input" name="ps" value="" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1334
				<span class="spinner"></span>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1335
				<input type="button" id="find-posts-search" value="<?php esc_attr_e( 'Search' ); ?>" class="button" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1336
			</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1337
			<div id="find-posts-response"></div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1338
		</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1339
		<div class="find-box-buttons">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1340
			<input id="find-posts-close" type="button" class="button alignleft" value="<?php esc_attr_e('Close'); ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1341
			<?php submit_button( __( 'Select' ), 'button-primary alignright', 'find-posts-submit', false ); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1342
		</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1343
	</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1344
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1345
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1346
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1347
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1348
 * Display the post password.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1349
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1350
 * The password is passed through {@link esc_attr()} to ensure that it
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1351
 * is safe for placing in an html attribute.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1352
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1353
 * @uses attr
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1354
 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1355
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1356
function the_post_password() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1357
	$post = get_post();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1358
	if ( isset( $post->post_password ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1359
		echo esc_attr( $post->post_password );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1360
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1361
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1362
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1363
 * Get the post title.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1364
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1365
 * The post title is fetched and if it is blank then a default string is
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1366
 * returned.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1367
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1368
 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1369
 * @param mixed $post Post id or object. If not supplied the global $post is used.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1370
 * @return string The post title if set
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1371
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1372
function _draft_or_post_title( $post = 0 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1373
	$title = get_the_title( $post );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1374
	if ( empty( $title ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1375
		$title = __( '(no title)' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1376
	return $title;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1377
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1378
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1379
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1380
 * Display the search query.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1381
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1382
 * A simple wrapper to display the "s" parameter in a GET URI. This function
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1383
 * should only be used when {@link the_search_query()} cannot.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1384
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1385
 * @uses attr
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1386
 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1387
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1388
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1389
function _admin_search_query() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1390
	echo isset($_REQUEST['s']) ? esc_attr( wp_unslash( $_REQUEST['s'] ) ) : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1391
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1392
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1393
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1394
 * Generic Iframe header for use with Thickbox
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1395
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1396
 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1397
 * @param string $title Title of the Iframe page.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1398
 * @param bool $limit_styles Limit styles to colour-related styles only (unless others are enqueued).
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1399
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1400
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1401
function iframe_header( $title = '', $limit_styles = false ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1402
	show_admin_bar( false );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1403
	global $hook_suffix, $current_user, $admin_body_class, $wp_locale;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1404
	$admin_body_class = preg_replace('/[^a-z0-9_-]+/i', '-', $hook_suffix);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1405
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1406
	$current_screen = get_current_screen();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1407
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1408
	@header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1409
	_wp_admin_html_begin();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1410
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1411
<title><?php bloginfo('name') ?> &rsaquo; <?php echo $title ?> &#8212; <?php _e('WordPress'); ?></title>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1412
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1413
wp_enqueue_style( 'colors' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1414
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1415
<script type="text/javascript">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1416
//<![CDATA[
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1417
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();}}};
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1418
function tb_close(){var win=window.dialogArguments||opener||parent||top;win.tb_remove();}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1419
var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1420
	pagenow = '<?php echo $current_screen->id; ?>',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1421
	typenow = '<?php echo $current_screen->post_type; ?>',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1422
	adminpage = '<?php echo $admin_body_class; ?>',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1423
	thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1424
	decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1425
	isRtl = <?php echo (int) is_rtl(); ?>;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1426
//]]>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1427
</script>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1428
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1429
do_action('admin_enqueue_scripts', $hook_suffix);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1430
do_action("admin_print_styles-$hook_suffix");
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1431
do_action('admin_print_styles');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1432
do_action("admin_print_scripts-$hook_suffix");
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1433
do_action('admin_print_scripts');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1434
do_action("admin_head-$hook_suffix");
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1435
do_action('admin_head');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1436
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1437
$admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1438
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1439
if ( is_rtl() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1440
	$admin_body_class .= ' rtl';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1441
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1442
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1443
</head>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1444
<body<?php if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?> class="wp-admin wp-core-ui no-js iframe <?php echo apply_filters( 'admin_body_class', '' ) . ' ' . $admin_body_class; ?>">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1445
<script type="text/javascript">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1446
//<![CDATA[
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1447
(function(){
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1448
var c = document.body.className;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1449
c = c.replace(/no-js/, 'js');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1450
document.body.className = c;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1451
})();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1452
//]]>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1453
</script>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1454
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1455
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1456
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1457
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1458
 * Generic Iframe footer for use with Thickbox
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1459
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1460
 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1461
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1462
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1463
function iframe_footer() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1464
	//We're going to hide any footer output on iframe pages, but run the hooks anyway since they output Javascript or other needed content. ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1465
	<div class="hidden">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1466
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1467
	do_action('admin_footer', '');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1468
	do_action('admin_print_footer_scripts'); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1469
	</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1470
<script type="text/javascript">if(typeof wpOnload=="function")wpOnload();</script>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1471
</body>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1472
</html>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1473
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1474
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1475
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1476
function _post_states($post) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1477
	$post_states = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1478
	if ( isset( $_REQUEST['post_status'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1479
		$post_status = $_REQUEST['post_status'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1480
	else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1481
		$post_status = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1482
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1483
	if ( !empty($post->post_password) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1484
		$post_states['protected'] = __('Password protected');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1485
	if ( 'private' == $post->post_status && 'private' != $post_status )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1486
		$post_states['private'] = __('Private');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1487
	if ( 'draft' == $post->post_status && 'draft' != $post_status )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1488
		$post_states['draft'] = __('Draft');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1489
	if ( 'pending' == $post->post_status && 'pending' != $post_status )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1490
		/* translators: post state */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1491
		$post_states['pending'] = _x('Pending', 'post state');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1492
	if ( is_sticky($post->ID) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1493
		$post_states['sticky'] = __('Sticky');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1494
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1495
	$post_states = apply_filters( 'display_post_states', $post_states, $post );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1496
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1497
	if ( ! empty($post_states) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1498
		$state_count = count($post_states);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1499
		$i = 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1500
		echo ' - ';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1501
		foreach ( $post_states as $state ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1502
			++$i;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1503
			( $i == $state_count ) ? $sep = '' : $sep = ', ';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1504
			echo "<span class='post-state'>$state$sep</span>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1505
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1506
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1507
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1508
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1509
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1510
function _media_states( $post ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1511
	$media_states = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1512
	$stylesheet = get_option('stylesheet');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1513
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1514
	if ( current_theme_supports( 'custom-header') ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1515
		$meta_header = get_post_meta($post->ID, '_wp_attachment_is_custom_header', true );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1516
		if ( ! empty( $meta_header ) && $meta_header == $stylesheet )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1517
			$media_states[] = __( 'Header Image' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1518
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1519
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1520
	if ( current_theme_supports( 'custom-background') ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1521
		$meta_background = get_post_meta($post->ID, '_wp_attachment_is_custom_background', true );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1522
		if ( ! empty( $meta_background ) && $meta_background == $stylesheet )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1523
			$media_states[] = __( 'Background Image' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1524
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1525
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1526
	$media_states = apply_filters( 'display_media_states', $media_states );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1527
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1528
	if ( ! empty( $media_states ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1529
		$state_count = count( $media_states );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1530
		$i = 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1531
		echo ' - ';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1532
		foreach ( $media_states as $state ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1533
			++$i;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1534
			( $i == $state_count ) ? $sep = '' : $sep = ', ';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1535
			echo "<span class='post-state'>$state$sep</span>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1536
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1537
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1538
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1539
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1540
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1541
 * Test support for compressing JavaScript from PHP
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1542
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1543
 * Outputs JavaScript that tests if compression from PHP works as expected
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1544
 * and sets an option with the result. Has no effect when the current user
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1545
 * is not an administrator. To run the test again the option 'can_compress_scripts'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1546
 * has to be deleted.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1547
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1548
 * @since 2.8.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1549
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1550
function compression_test() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1551
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1552
	<script type="text/javascript">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1553
	/* <![CDATA[ */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1554
	var testCompression = {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1555
		get : function(test) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1556
			var x;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1557
			if ( window.XMLHttpRequest ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1558
				x = new XMLHttpRequest();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1559
			} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1560
				try{x=new ActiveXObject('Msxml2.XMLHTTP');}catch(e){try{x=new ActiveXObject('Microsoft.XMLHTTP');}catch(e){};}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1561
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1562
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1563
			if (x) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1564
				x.onreadystatechange = function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1565
					var r, h;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1566
					if ( x.readyState == 4 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1567
						r = x.responseText.substr(0, 18);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1568
						h = x.getResponseHeader('Content-Encoding');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1569
						testCompression.check(r, h, test);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1570
					}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1571
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1572
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1573
				x.open('GET', ajaxurl + '?action=wp-compression-test&test='+test+'&'+(new Date()).getTime(), true);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1574
				x.send('');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1575
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1576
		},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1577
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1578
		check : function(r, h, test) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1579
			if ( ! r && ! test )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1580
				this.get(1);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1581
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1582
			if ( 1 == test ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1583
				if ( h && ( h.match(/deflate/i) || h.match(/gzip/i) ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1584
					this.get('no');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1585
				else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1586
					this.get(2);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1587
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1588
				return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1589
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1590
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1591
			if ( 2 == test ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1592
				if ( '"wpCompressionTest' == r )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1593
					this.get('yes');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1594
				else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1595
					this.get('no');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1596
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1597
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1598
	};
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1599
	testCompression.check();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1600
	/* ]]> */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1601
	</script>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1602
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1603
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1604
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1605
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1606
 * Echos a submit button, with provided text and appropriate class
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1607
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1608
 * @since 3.1.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1609
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1610
 * @param string $text The text of the button (defaults to 'Save Changes')
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1611
 * @param string $type The type of button. One of: primary, secondary, delete
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1612
 * @param string $name The HTML name of the submit button. Defaults to "submit". If no id attribute
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1613
 *               is given in $other_attributes below, $name will be used as the button's id.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1614
 * @param bool $wrap True if the output button should be wrapped in a paragraph tag,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1615
 * 			   false otherwise. Defaults to true
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1616
 * @param array|string $other_attributes Other attributes that should be output with the button,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1617
 *                     mapping attributes to their values, such as array( 'tabindex' => '1' ).
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1618
 *                     These attributes will be output as attribute="value", such as tabindex="1".
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1619
 *                     Defaults to no other attributes. Other attributes can also be provided as a
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1620
 *                     string such as 'tabindex="1"', though the array format is typically cleaner.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1621
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1622
function submit_button( $text = null, $type = 'primary', $name = 'submit', $wrap = true, $other_attributes = null ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1623
	echo get_submit_button( $text, $type, $name, $wrap, $other_attributes );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1624
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1625
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1626
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1627
 * Returns a submit button, with provided text and appropriate class
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1628
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1629
 * @since 3.1.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1630
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1631
 * @param string $text The text of the button (defaults to 'Save Changes')
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1632
 * @param string $type The type of button. One of: primary, secondary, delete
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1633
 * @param string $name The HTML name of the submit button. Defaults to "submit". If no id attribute
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1634
 *               is given in $other_attributes below, $name will be used as the button's id.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1635
 * @param bool $wrap True if the output button should be wrapped in a paragraph tag,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1636
 * 			   false otherwise. Defaults to true
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1637
 * @param array|string $other_attributes Other attributes that should be output with the button,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1638
 *                     mapping attributes to their values, such as array( 'tabindex' => '1' ).
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1639
 *                     These attributes will be output as attribute="value", such as tabindex="1".
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1640
 *                     Defaults to no other attributes. Other attributes can also be provided as a
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1641
 *                     string such as 'tabindex="1"', though the array format is typically cleaner.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1642
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1643
function get_submit_button( $text = null, $type = 'primary large', $name = 'submit', $wrap = true, $other_attributes = null ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1644
	if ( ! is_array( $type ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1645
		$type = explode( ' ', $type );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1646
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1647
	$button_shorthand = array( 'primary', 'small', 'large' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1648
	$classes = array( 'button' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1649
	foreach ( $type as $t ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1650
		if ( 'secondary' === $t || 'button-secondary' === $t )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1651
			continue;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1652
		$classes[] = in_array( $t, $button_shorthand ) ? 'button-' . $t : $t;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1653
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1654
	$class = implode( ' ', array_unique( $classes ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1655
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1656
	if ( 'delete' === $type )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1657
		$class = 'button-secondary delete';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1658
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1659
	$text = $text ? $text : __( 'Save Changes' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1660
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1661
	// Default the id attribute to $name unless an id was specifically provided in $other_attributes
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1662
	$id = $name;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1663
	if ( is_array( $other_attributes ) && isset( $other_attributes['id'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1664
		$id = $other_attributes['id'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1665
		unset( $other_attributes['id'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1666
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1667
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1668
	$attributes = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1669
	if ( is_array( $other_attributes ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1670
		foreach ( $other_attributes as $attribute => $value ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1671
			$attributes .= $attribute . '="' . esc_attr( $value ) . '" '; // Trailing space is important
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1672
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1673
	} else if ( !empty( $other_attributes ) ) { // Attributes provided as a string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1674
		$attributes = $other_attributes;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1675
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1676
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1677
	$button = '<input type="submit" name="' . esc_attr( $name ) . '" id="' . esc_attr( $id ) . '" class="' . esc_attr( $class );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1678
	$button	.= '" value="' . esc_attr( $text ) . '" ' . $attributes . ' />';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1679
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1680
	if ( $wrap ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1681
		$button = '<p class="submit">' . $button . '</p>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1682
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1683
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1684
	return $button;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1685
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1686
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1687
function _wp_admin_html_begin() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1688
	$admin_html_class = ( is_admin_bar_showing() ) ? 'wp-toolbar' : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1689
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1690
<!DOCTYPE html>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1691
<!--[if IE 8]>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1692
<html xmlns="http://www.w3.org/1999/xhtml" class="ie8 <?php echo $admin_html_class; ?>" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1693
<![endif]-->
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1694
<!--[if !(IE 8) ]><!-->
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1695
<html xmlns="http://www.w3.org/1999/xhtml" class="<?php echo $admin_html_class; ?>" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1696
<!--<![endif]-->
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1697
<head>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1698
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1699
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1700
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1701
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1702
final class WP_Internal_Pointers {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1703
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1704
	 * Initializes the new feature pointers.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1705
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1706
	 * @since 3.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1707
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1708
	 * All pointers can be disabled using the following:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1709
	 *     remove_action( 'admin_enqueue_scripts', array( 'WP_Internal_Pointers', 'enqueue_scripts' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1710
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1711
	 * Individual pointers (e.g. wp330_toolbar) can be disabled using the following:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1712
	 *     remove_action( 'admin_print_footer_scripts', array( 'WP_Internal_Pointers', 'pointer_wp330_toolbar' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1713
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1714
	public static function enqueue_scripts( $hook_suffix ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1715
		/*
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1716
		 * Register feature pointers
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1717
		 * Format: array( hook_suffix => pointer_id )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1718
		 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1719
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1720
		$registered_pointers = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1721
			'index.php'    => 'wp330_toolbar',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1722
			'post-new.php' => 'wp350_media',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1723
			'post.php'     => array( 'wp350_media', 'wp360_revisions' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1724
			'edit.php'     => 'wp360_locks',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1725
			'themes.php'   => array( 'wp330_saving_widgets', 'wp340_customize_current_theme_link' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1726
			'appearance_page_custom-header' => 'wp340_choose_image_from_library',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1727
			'appearance_page_custom-background' => 'wp340_choose_image_from_library',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1728
		);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1729
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1730
		// Check if screen related pointer is registered
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1731
		if ( empty( $registered_pointers[ $hook_suffix ] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1732
			return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1733
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1734
		$pointers = (array) $registered_pointers[ $hook_suffix ];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1735
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1736
		$caps_required = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1737
			'wp330_saving_widgets' => array( 'edit_theme_options', 'switch_themes' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1738
			'wp340_customize_current_theme_link' => array( 'edit_theme_options' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1739
			'wp340_choose_image_from_library' => array( 'edit_theme_options' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1740
			'wp350_media' => array( 'upload_files' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1741
		);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1742
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1743
		// Get dismissed pointers
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1744
		$dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1745
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1746
		$got_pointers = false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1747
		foreach ( array_diff( $pointers, $dismissed ) as $pointer ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1748
			if ( isset( $caps_required[ $pointer ] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1749
				foreach ( $caps_required[ $pointer ] as $cap ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1750
					if ( ! current_user_can( $cap ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1751
						continue 2;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1752
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1753
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1754
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1755
			// Bind pointer print function
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1756
			add_action( 'admin_print_footer_scripts', array( 'WP_Internal_Pointers', 'pointer_' . $pointer ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1757
			$got_pointers = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1758
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1759
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1760
		if ( ! $got_pointers )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1761
			return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1762
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1763
		// Add pointers script and style to queue
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1764
		wp_enqueue_style( 'wp-pointer' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1765
		wp_enqueue_script( 'wp-pointer' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1766
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1767
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1768
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1769
	 * Print the pointer javascript data.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1770
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1771
	 * @since 3.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1772
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1773
	 * @param string $pointer_id The pointer ID.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1774
	 * @param string $selector The HTML elements, on which the pointer should be attached.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1775
	 * @param array  $args Arguments to be passed to the pointer JS (see wp-pointer.js).
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1776
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1777
	private static function print_js( $pointer_id, $selector, $args ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1778
		if ( empty( $pointer_id ) || empty( $selector ) || empty( $args ) || empty( $args['content'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1779
			return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1780
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1781
		?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1782
		<script type="text/javascript">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1783
		//<![CDATA[
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1784
		(function($){
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1785
			var options = <?php echo json_encode( $args ); ?>, setup;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1786
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1787
			if ( ! options )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1788
				return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1789
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1790
			options = $.extend( options, {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1791
				close: function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1792
					$.post( ajaxurl, {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1793
						pointer: '<?php echo $pointer_id; ?>',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1794
						action: 'dismiss-wp-pointer'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1795
					});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1796
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1797
			});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1798
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1799
			setup = function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1800
				$('<?php echo $selector; ?>').first().pointer( options ).pointer('open');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1801
			};
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1802
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1803
			if ( options.position && options.position.defer_loading )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1804
				$(window).bind( 'load.wp-pointers', setup );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1805
			else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1806
				$(document).ready( setup );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1807
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1808
		})( jQuery );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1809
		//]]>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1810
		</script>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1811
		<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1812
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1813
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1814
	public static function pointer_wp330_toolbar() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1815
		$content  = '<h3>' . __( 'New Feature: Toolbar' ) . '</h3>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1816
		$content .= '<p>' .  __( 'We&#8217;ve combined the admin bar and the old Dashboard header into one persistent toolbar. Hover over the toolbar items to see what&#8217;s new.' ) . '</p>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1817
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1818
		if ( is_multisite() && is_super_admin() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1819
			$content .= '<p>' . __( 'Network Admin is now located in the My Sites menu.' ) . '</p>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1820
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1821
		WP_Internal_Pointers::print_js( 'wp330_toolbar', '#wpadminbar', array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1822
			'content'  => $content,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1823
			'position' => array( 'edge' => 'top', 'align' => 'center' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1824
		) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1825
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1826
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1827
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1828
	 * Print 'Updated Media Uploader' for 3.3.0.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1829
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1830
	 * @since 3.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1831
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1832
	public static function pointer_wp330_media_uploader() {}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1833
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1834
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1835
	 * Print 'New Feature: Saving Widgets' for 3.3.0.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1836
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1837
	 * @since 3.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1838
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1839
	public static function pointer_wp330_saving_widgets() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1840
		$content  = '<h3>' . __( 'New Feature: Saving Widgets' ) . '</h3>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1841
		$content .= '<p>' . __( 'If you change your mind and revert to your previous theme, we&#8217;ll put the widgets back the way you had them.' ) . '</p>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1842
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1843
		WP_Internal_Pointers::print_js( 'wp330_saving_widgets', '#message2', array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1844
			'content'  => $content,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1845
			'position' => array( 'edge' => 'top', 'align' => is_rtl() ? 'right' : 'left' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1846
		) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1847
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1848
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1849
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1850
	 * Print 'New Feature: Current Theme Customize Link' for 3.4.0.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1851
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1852
	 * @since 3.4.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1853
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1854
	public static function pointer_wp340_customize_current_theme_link() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1855
		$content  = '<h3>' . __( 'New Feature: Customizer' ) . '</h3>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1856
		$content .= '<p>' . __( 'Click Customize to change the header, background, title and menus of the current theme, all in one place.' ) . '</p>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1857
		$content .= '<p>' . __( 'Click the Live Preview links in the Available Themes list below to customize and preview another theme before activating it.' ) . '</p>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1858
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1859
		WP_Internal_Pointers::print_js( 'wp340_customize_current_theme_link', '#customize-current-theme-link', array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1860
			'content'  => $content,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1861
			'position' => array( 'edge' => 'top', 'align' => is_rtl() ? 'right' : 'left', 'offset' => is_rtl() ? '32 0' : '-32 0' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1862
		) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1863
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1864
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1865
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1866
	 * Print 'New Feature: Choose Image from Library' for 3.4.0.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1867
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1868
	 * @since 3.4.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1869
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1870
	public static function pointer_wp340_choose_image_from_library() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1871
		$content  = '<h3>' . __( 'New Feature: Choose Image from Library' ) . '</h3>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1872
		$content .= '<p>' . __( 'Want to use an image you uploaded earlier? Select it from your media library instead of uploading it again.' ) . '</p>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1873
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1874
		WP_Internal_Pointers::print_js( 'wp340_choose_image_from_library', '#choose-from-library-link', array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1875
			'content'  => $content,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1876
			'position' => array( 'edge' => 'top', 'align' => is_rtl() ? 'right' : 'left', 'defer_loading' => true ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1877
		) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1878
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1879
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1880
	public static function pointer_wp350_media() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1881
		$content  = '<h3>' . __( 'New Media Manager' ) . '</h3>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1882
		$content .= '<p>' . __( 'Uploading files and creating image galleries has a whole new look. Check it out!' ) . '</p>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1883
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1884
		self::print_js( 'wp350_media', '.insert-media', array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1885
			'content'  => $content,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1886
			'position' => array( 'edge' => is_rtl() ? 'right' : 'left', 'align' => 'center' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1887
		) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1888
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1889
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1890
	public static function pointer_wp360_revisions() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1891
		$content  = '<h3>' . __( 'Compare Revisions' ) . '</h3>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1892
		$content .= '<p>' . __( 'View, compare, and restore other versions of this content on the improved revisions screen.' ) . '</p>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1893
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1894
		self::print_js( 'wp360_revisions', '.misc-pub-section.misc-pub-revisions', array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1895
			'content' => $content,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1896
			'position' => array( 'edge' => is_rtl() ? 'left' : 'right', 'align' => 'center', 'my' => is_rtl() ? 'left' : 'right-14px' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1897
		) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1898
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1899
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1900
	public static function pointer_wp360_locks() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1901
		$content  = '<h3>' . __( 'Edit Lock' ) . '</h3>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1902
		$content .= '<p>' . __( 'Someone else is editing this. No need to refresh; the lock will disappear when they&#8217;re done.' ) . '</p>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1903
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1904
		if ( ! is_multi_author() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1905
			return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1906
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1907
		self::print_js( 'wp360_locks', 'tr.wp-locked .locked-indicator', array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1908
			'content' => $content,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1909
			'position' => array( 'edge' => 'left', 'align' => 'left' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1910
		) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1911
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1912
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1913
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1914
	 * Prevents new users from seeing existing 'new feature' pointers.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1915
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1916
	 * @since 3.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1917
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1918
	public static function dismiss_pointers_for_new_users( $user_id ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1919
		add_user_meta( $user_id, 'dismissed_wp_pointers', 'wp330_toolbar,wp330_saving_widgets,wp340_choose_image_from_library,wp340_customize_current_theme_link,wp350_media,wp360_revisions,wp360_locks' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1920
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1921
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1922
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1923
add_action( 'admin_enqueue_scripts', array( 'WP_Internal_Pointers', 'enqueue_scripts'                ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1924
add_action( 'user_register',         array( 'WP_Internal_Pointers', 'dismiss_pointers_for_new_users' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1925
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1926
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1927
 * Convert a screen string to a screen object
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1928
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1929
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1930
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1931
 * @param string $hook_name The hook name (also known as the hook suffix) used to determine the screen.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1932
 * @return WP_Screen Screen object.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1933
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1934
function convert_to_screen( $hook_name ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1935
	if ( ! class_exists( 'WP_Screen' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1936
		_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' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1937
		return (object) array( 'id' => '_invalid', 'base' => '_are_belong_to_us' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1938
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1939
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1940
	return WP_Screen::get( $hook_name );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1941
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1942
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1943
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1944
 * Output the HTML for restoring the post data from DOM storage
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1945
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1946
 * @since 3.6
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1947
 * @access private
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1948
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1949
function _local_storage_notice() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1950
	?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1951
	<div id="local-storage-notice" class="hidden">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1952
	<p class="local-restore">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1953
		<?php _e('The backup of this post in your browser is different from the version below.'); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1954
		<a class="restore-backup" href="#"><?php _e('Restore the backup.'); ?></a>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1955
	</p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1956
	<p class="undo-restore hidden">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1957
		<?php _e('Post restored successfully.'); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1958
		<a class="undo-restore-backup" href="#"><?php _e('Undo.'); ?></a>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1959
	</p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1960
	</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1961
	<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1962
}