wp/wp-admin/includes/template.php
changeset 5 5e2f62d02dcd
parent 0 d970ebf37754
child 7 cf61fcea0001
equal deleted inserted replaced
4:346c88efed21 5:5e2f62d02dcd
    11 //
    11 //
    12 // Category Checklists
    12 // Category Checklists
    13 //
    13 //
    14 
    14 
    15 /**
    15 /**
    16  * Walker to output an unordered list of category checkbox <input> elements.
    16  * Walker to output an unordered list of category checkbox input elements.
       
    17  *
       
    18  * @since 2.5.1
    17  *
    19  *
    18  * @see Walker
    20  * @see Walker
    19  * @see wp_category_checklist()
    21  * @see wp_category_checklist()
    20  * @see wp_terms_checklist()
    22  * @see wp_terms_checklist()
    21  * @since 2.5.1
       
    22  */
    23  */
    23 class Walker_Category_Checklist extends Walker {
    24 class Walker_Category_Checklist extends Walker {
    24 	var $tree_type = 'category';
    25 	public $tree_type = 'category';
    25 	var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this
    26 	public $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this
    26 
    27 
    27 	/**
    28 	/**
    28 	 * Starts the list before the elements are added.
    29 	 * Starts the list before the elements are added.
    29 	 *
    30 	 *
    30 	 * @see Walker:start_lvl()
    31 	 * @see Walker:start_lvl()
    33 	 *
    34 	 *
    34 	 * @param string $output Passed by reference. Used to append additional content.
    35 	 * @param string $output Passed by reference. Used to append additional content.
    35 	 * @param int    $depth  Depth of category. Used for tab indentation.
    36 	 * @param int    $depth  Depth of category. Used for tab indentation.
    36 	 * @param array  $args   An array of arguments. @see wp_terms_checklist()
    37 	 * @param array  $args   An array of arguments. @see wp_terms_checklist()
    37 	 */
    38 	 */
    38 	function start_lvl( &$output, $depth = 0, $args = array() ) {
    39 	public function start_lvl( &$output, $depth = 0, $args = array() ) {
    39 		$indent = str_repeat("\t", $depth);
    40 		$indent = str_repeat("\t", $depth);
    40 		$output .= "$indent<ul class='children'>\n";
    41 		$output .= "$indent<ul class='children'>\n";
    41 	}
    42 	}
    42 
    43 
    43 	/**
    44 	/**
    49 	 *
    50 	 *
    50 	 * @param string $output Passed by reference. Used to append additional content.
    51 	 * @param string $output Passed by reference. Used to append additional content.
    51 	 * @param int    $depth  Depth of category. Used for tab indentation.
    52 	 * @param int    $depth  Depth of category. Used for tab indentation.
    52 	 * @param array  $args   An array of arguments. @see wp_terms_checklist()
    53 	 * @param array  $args   An array of arguments. @see wp_terms_checklist()
    53 	 */
    54 	 */
    54 	function end_lvl( &$output, $depth = 0, $args = array() ) {
    55 	public function end_lvl( &$output, $depth = 0, $args = array() ) {
    55 		$indent = str_repeat("\t", $depth);
    56 		$indent = str_repeat("\t", $depth);
    56 		$output .= "$indent</ul>\n";
    57 		$output .= "$indent</ul>\n";
    57 	}
    58 	}
    58 
    59 
    59 	/**
    60 	/**
    67 	 * @param object $category The current term object.
    68 	 * @param object $category The current term object.
    68 	 * @param int    $depth    Depth of the term in reference to parents. Default 0.
    69 	 * @param int    $depth    Depth of the term in reference to parents. Default 0.
    69 	 * @param array  $args     An array of arguments. @see wp_terms_checklist()
    70 	 * @param array  $args     An array of arguments. @see wp_terms_checklist()
    70 	 * @param int    $id       ID of the current term.
    71 	 * @param int    $id       ID of the current term.
    71 	 */
    72 	 */
    72 	function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
    73 	public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
    73 		extract($args);
    74 		if ( empty( $args['taxonomy'] ) ) {
    74 		if ( empty($taxonomy) )
       
    75 			$taxonomy = 'category';
    75 			$taxonomy = 'category';
    76 
    76 		} else {
    77 		if ( $taxonomy == 'category' )
    77 			$taxonomy = $args['taxonomy'];
       
    78 		}
       
    79 
       
    80 		if ( $taxonomy == 'category' ) {
    78 			$name = 'post_category';
    81 			$name = 'post_category';
    79 		else
    82 		} else {
    80 			$name = 'tax_input['.$taxonomy.']';
    83 			$name = 'tax_input[' . $taxonomy . ']';
    81 
    84 		}
    82 		$class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category"' : '';
    85 
    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>';
    86 		$args['popular_cats'] = empty( $args['popular_cats'] ) ? array() : $args['popular_cats'];
       
    87 		$class = in_array( $category->term_id, $args['popular_cats'] ) ? ' class="popular-category"' : '';
       
    88 
       
    89 		$args['selected_cats'] = empty( $args['selected_cats'] ) ? array() : $args['selected_cats'];
       
    90 
       
    91 		/** This filter is documented in wp-includes/category-template.php */
       
    92 		if ( ! empty( $args['list_only'] ) ) {
       
    93 			$aria_cheched = 'false';
       
    94 			$inner_class = 'category';
       
    95 
       
    96 			if ( in_array( $category->term_id, $args['selected_cats'] ) ) {
       
    97 				$inner_class .= ' selected';
       
    98 				$aria_cheched = 'true';
       
    99 			}
       
   100 
       
   101 			$output .= "\n" . '<li' . $class . '>' .
       
   102 				'<div class="' . $inner_class . '" data-term-id=' . $category->term_id .
       
   103 				' tabindex="0" role="checkbox" aria-checked="' . $aria_cheched . '">' .
       
   104 				esc_html( apply_filters( 'the_category', $category->name ) ) . '</div>';
       
   105 		} else {
       
   106 			$output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>" .
       
   107 				'<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="'.$name.'[]" id="in-'.$taxonomy.'-' . $category->term_id . '"' .
       
   108 				checked( in_array( $category->term_id, $args['selected_cats'] ), true, false ) .
       
   109 				disabled( empty( $args['disabled'] ), false, false ) . ' /> ' .
       
   110 				esc_html( apply_filters( 'the_category', $category->name ) ) . '</label>';
       
   111 		}
    84 	}
   112 	}
    85 
   113 
    86 	/**
   114 	/**
    87 	 * Ends the element output, if needed.
   115 	 * Ends the element output, if needed.
    88 	 *
   116 	 *
    93 	 * @param string $output   Passed by reference. Used to append additional content.
   121 	 * @param string $output   Passed by reference. Used to append additional content.
    94 	 * @param object $category The current term object.
   122 	 * @param object $category The current term object.
    95 	 * @param int    $depth    Depth of the term in reference to parents. Default 0.
   123 	 * @param int    $depth    Depth of the term in reference to parents. Default 0.
    96 	 * @param array  $args     An array of arguments. @see wp_terms_checklist()
   124 	 * @param array  $args     An array of arguments. @see wp_terms_checklist()
    97 	 */
   125 	 */
    98 	function end_el( &$output, $category, $depth = 0, $args = array() ) {
   126 	public function end_el( &$output, $category, $depth = 0, $args = array() ) {
    99 		$output .= "</li>\n";
   127 		$output .= "</li>\n";
   100 	}
   128 	}
   101 }
   129 }
   102 
   130 
   103 /**
   131 /**
   104  * Output an unordered list of checkbox <input> elements labelled
   132  * Output an unordered list of checkbox input elements labeled with category names.
   105  * with category names.
   133  *
       
   134  * @since 2.5.1
   106  *
   135  *
   107  * @see wp_terms_checklist()
   136  * @see wp_terms_checklist()
   108  * @since 2.5.1
   137  *
   109  *
   138  * @param int    $post_id              Optional. Post to generate a categories checklist for. Default 0.
   110  * @param int $post_id Mark categories associated with this post as checked. $selected_cats must not be an array.
   139  *                                     $selected_cats must not be an array. Default 0.
   111  * @param int $descendants_and_self ID of the category to output along with its descendents.
   140  * @param int    $descendants_and_self Optional. ID of the category to output along with its descendants.
   112  * @param bool|array $selected_cats List of categories to mark as checked.
   141  *                                     Default 0.
   113  * @param bool|array $popular_cats Override the list of categories that receive the "popular-category" class.
   142  * @param array  $selected_cats        Optional. List of categories to mark as checked. Default false.
   114  * @param object $walker Walker object to use to build the output.
   143  * @param array  $popular_cats         Optional. List of categories to receive the "popular-category" class.
   115  * @param bool $checked_ontop Move checked items out of the hierarchy and to the top of the list.
   144  *                                     Default false.
       
   145  * @param object $walker               Optional. Walker object to use to build the output.
       
   146  *                                     Default is a Walker_Category_Checklist instance.
       
   147  * @param bool   $checked_ontop        Optional. Whether to move checked items out of the hierarchy and to
       
   148  *                                     the top of the list. Default true.
   116  */
   149  */
   117 function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null, $checked_ontop = true ) {
   150 function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null, $checked_ontop = true ) {
   118 	wp_terms_checklist( $post_id, array(
   151 	wp_terms_checklist( $post_id, array(
   119 		'taxonomy' => 'category',
   152 		'taxonomy' => 'category',
   120 		'descendants_and_self' => $descendants_and_self,
   153 		'descendants_and_self' => $descendants_and_self,
   124 		'checked_ontop' => $checked_ontop
   157 		'checked_ontop' => $checked_ontop
   125 	) );
   158 	) );
   126 }
   159 }
   127 
   160 
   128 /**
   161 /**
   129  * Output an unordered list of checkbox <input> elements labelled
   162  * Output an unordered list of checkbox input elements labelled with term names.
   130  * with term names. Taxonomy independent version of wp_category_checklist().
   163  *
       
   164  * Taxonomy-independent version of wp_category_checklist().
   131  *
   165  *
   132  * @since 3.0.0
   166  * @since 3.0.0
   133  *
   167  *
   134  * @param int $post_id
   168  * @param int          $post_id Optional. Post ID. Default 0.
   135  * @param array $args
   169  * @param array|string $args {
   136  */
   170  *     Optional. Array or string of arguments for generating a terms checklist. Default empty array.
   137 function wp_terms_checklist($post_id = 0, $args = array()) {
   171  *
       
   172  *     @type int    $descendants_and_self ID of the category to output along with its descendants.
       
   173  *                                        Default 0.
       
   174  *     @type array  $selected_cats        List of categories to mark as checked. Default false.
       
   175  *     @type array  $popular_cats         List of categories to receive the "popular-category" class.
       
   176  *                                        Default false.
       
   177  *     @type object $walker               Walker object to use to build the output.
       
   178  *                                        Default is a Walker_Category_Checklist instance.
       
   179  *     @type string $taxonomy             Taxonomy to generate the checklist for. Default 'category'.
       
   180  *     @type bool   $checked_ontop        Whether to move checked items out of the hierarchy and to
       
   181  *                                        the top of the list. Default true.
       
   182  * }
       
   183  */
       
   184 function wp_terms_checklist( $post_id = 0, $args = array() ) {
   138  	$defaults = array(
   185  	$defaults = array(
   139 		'descendants_and_self' => 0,
   186 		'descendants_and_self' => 0,
   140 		'selected_cats' => false,
   187 		'selected_cats' => false,
   141 		'popular_cats' => false,
   188 		'popular_cats' => false,
   142 		'walker' => null,
   189 		'walker' => null,
   143 		'taxonomy' => 'category',
   190 		'taxonomy' => 'category',
   144 		'checked_ontop' => true
   191 		'checked_ontop' => true
   145 	);
   192 	);
   146 	$args = apply_filters( 'wp_terms_checklist_args', $args, $post_id );
   193 
   147 
   194 	/**
   148 	extract( wp_parse_args($args, $defaults), EXTR_SKIP );
   195 	 * Filter the taxonomy terms checklist arguments.
   149 
   196 	 *
   150 	if ( empty($walker) || !is_a($walker, 'Walker') )
   197 	 * @since 3.4.0
       
   198 	 *
       
   199 	 * @see wp_terms_checklist()
       
   200 	 *
       
   201 	 * @param array $args    An array of arguments.
       
   202 	 * @param int   $post_id The post ID.
       
   203 	 */
       
   204 	$params = apply_filters( 'wp_terms_checklist_args', $args, $post_id );
       
   205 
       
   206 	$r = wp_parse_args( $params, $defaults );
       
   207 
       
   208 	if ( empty( $r['walker'] ) || ! ( $r['walker'] instanceof Walker ) ) {
   151 		$walker = new Walker_Category_Checklist;
   209 		$walker = new Walker_Category_Checklist;
   152 
   210 	} else {
   153 	$descendants_and_self = (int) $descendants_and_self;
   211 		$walker = $r['walker'];
   154 
   212 	}
   155 	$args = array('taxonomy' => $taxonomy);
   213 
   156 
   214 	$taxonomy = $r['taxonomy'];
   157 	$tax = get_taxonomy($taxonomy);
   215 	$descendants_and_self = (int) $r['descendants_and_self'];
   158 	$args['disabled'] = !current_user_can($tax->cap->assign_terms);
   216 
   159 
   217 	$args = array( 'taxonomy' => $taxonomy );
   160 	if ( is_array( $selected_cats ) )
   218 
   161 		$args['selected_cats'] = $selected_cats;
   219 	$tax = get_taxonomy( $taxonomy );
   162 	elseif ( $post_id )
   220 	$args['disabled'] = ! current_user_can( $tax->cap->assign_terms );
   163 		$args['selected_cats'] = wp_get_object_terms($post_id, $taxonomy, array_merge($args, array('fields' => 'ids')));
   221 
   164 	else
   222 	$args['list_only'] = ! empty( $r['list_only'] );
       
   223 
       
   224 	if ( is_array( $r['selected_cats'] ) ) {
       
   225 		$args['selected_cats'] = $r['selected_cats'];
       
   226 	} elseif ( $post_id ) {
       
   227 		$args['selected_cats'] = wp_get_object_terms( $post_id, $taxonomy, array_merge( $args, array( 'fields' => 'ids' ) ) );
       
   228 	} else {
   165 		$args['selected_cats'] = array();
   229 		$args['selected_cats'] = array();
   166 
   230 	}
   167 	if ( is_array( $popular_cats ) )
   231 	if ( is_array( $r['popular_cats'] ) ) {
   168 		$args['popular_cats'] = $popular_cats;
   232 		$args['popular_cats'] = $r['popular_cats'];
   169 	else
   233 	} else {
   170 		$args['popular_cats'] = get_terms( $taxonomy, array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) );
   234 		$args['popular_cats'] = get_terms( $taxonomy, array(
   171 
   235 			'fields' => 'ids',
       
   236 			'orderby' => 'count',
       
   237 			'order' => 'DESC',
       
   238 			'number' => 10,
       
   239 			'hierarchical' => false
       
   240 		) );
       
   241 	}
   172 	if ( $descendants_and_self ) {
   242 	if ( $descendants_and_self ) {
   173 		$categories = (array) get_terms($taxonomy, array( 'child_of' => $descendants_and_self, 'hierarchical' => 0, 'hide_empty' => 0 ) );
   243 		$categories = (array) get_terms( $taxonomy, array(
       
   244 			'child_of' => $descendants_and_self,
       
   245 			'hierarchical' => 0,
       
   246 			'hide_empty' => 0
       
   247 		) );
   174 		$self = get_term( $descendants_and_self, $taxonomy );
   248 		$self = get_term( $descendants_and_self, $taxonomy );
   175 		array_unshift( $categories, $self );
   249 		array_unshift( $categories, $self );
   176 	} else {
   250 	} else {
   177 		$categories = (array) get_terms($taxonomy, array('get' => 'all'));
   251 		$categories = (array) get_terms( $taxonomy, array( 'get' => 'all' ) );
   178 	}
   252 	}
   179 
   253 
   180 	if ( $checked_ontop ) {
   254 	if ( $r['checked_ontop'] ) {
   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)
   255 		// 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)
   182 		$checked_categories = array();
   256 		$checked_categories = array();
   183 		$keys = array_keys( $categories );
   257 		$keys = array_keys( $categories );
   184 
   258 
   185 		foreach( $keys as $k ) {
   259 		foreach( $keys as $k ) {
   188 				unset( $categories[$k] );
   262 				unset( $categories[$k] );
   189 			}
   263 			}
   190 		}
   264 		}
   191 
   265 
   192 		// Put checked cats on top
   266 		// Put checked cats on top
   193 		echo call_user_func_array(array(&$walker, 'walk'), array($checked_categories, 0, $args));
   267 		echo call_user_func_array( array( $walker, 'walk' ), array( $checked_categories, 0, $args ) );
   194 	}
   268 	}
   195 	// Then the rest of them
   269 	// Then the rest of them
   196 	echo call_user_func_array(array(&$walker, 'walk'), array($categories, 0, $args));
   270 	echo call_user_func_array( array( $walker, 'walk' ), array( $categories, 0, $args ) );
   197 }
   271 }
   198 
   272 
   199 /**
   273 /**
   200  * Retrieve a list of the most popular terms from the specified taxonomy.
   274  * Retrieve a list of the most popular terms from the specified taxonomy.
   201  *
   275  *
   202  * If the $echo argument is true then the elements for a list of checkbox
   276  * If the $echo argument is true then the elements for a list of checkbox
   203  * <input> elements labelled with the names of the selected terms is output.
   277  * `<input>` elements labelled with the names of the selected terms is output.
   204  * If the $post_ID global isn't empty then the terms associated with that
   278  * If the $post_ID global isn't empty then the terms associated with that
   205  * post will be marked as checked.
   279  * post will be marked as checked.
   206  *
   280  *
   207  * @since 2.5.0
   281  * @since 2.5.0
   208  *
   282  *
   209  * @param string $taxonomy Taxonomy to retrieve terms from.
   283  * @param string $taxonomy Taxonomy to retrieve terms from.
   210  * @param int $default Unused.
   284  * @param int $default Not used.
   211  * @param int $number Number of terms to retrieve. Defaults to 10.
   285  * @param int $number Number of terms to retrieve. Defaults to 10.
   212  * @param bool $echo Optionally output the list as well. Defaults to true.
   286  * @param bool $echo Optionally output the list as well. Defaults to true.
   213  * @return array List of popular term IDs.
   287  * @return array List of popular term IDs.
   214  */
   288  */
   215 function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) {
   289 function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) {
   233 		$checked = in_array( $term->term_id, $checked_terms ) ? 'checked="checked"' : '';
   307 		$checked = in_array( $term->term_id, $checked_terms ) ? 'checked="checked"' : '';
   234 		?>
   308 		?>
   235 
   309 
   236 		<li id="<?php echo $id; ?>" class="popular-category">
   310 		<li id="<?php echo $id; ?>" class="popular-category">
   237 			<label class="selectit">
   311 			<label class="selectit">
   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 ) ); ?> />
   312 				<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 ) ); ?> />
   239 				<?php echo esc_html( apply_filters( 'the_category', $term->name ) ); ?>
   313 				<?php
       
   314 				/** This filter is documented in wp-includes/category-template.php */
       
   315 				echo esc_html( apply_filters( 'the_category', $term->name ) );
       
   316 				?>
   240 			</label>
   317 			</label>
   241 		</li>
   318 		</li>
   242 
   319 
   243 		<?php
   320 		<?php
   244 	}
   321 	}
   248 /**
   325 /**
   249  * {@internal Missing Short Description}}
   326  * {@internal Missing Short Description}}
   250  *
   327  *
   251  * @since 2.5.1
   328  * @since 2.5.1
   252  *
   329  *
   253  * @param unknown_type $link_id
   330  * @param int $link_id
   254  */
   331  */
   255 function wp_link_category_checklist( $link_id = 0 ) {
   332 function wp_link_category_checklist( $link_id = 0 ) {
   256 	$default = 1;
   333 	$default = 1;
       
   334 
       
   335 	$checked_categories = array();
   257 
   336 
   258 	if ( $link_id ) {
   337 	if ( $link_id ) {
   259 		$checked_categories = wp_get_link_cats( $link_id );
   338 		$checked_categories = wp_get_link_cats( $link_id );
   260 		// No selected categories, strange
   339 		// No selected categories, strange
   261 		if ( ! count( $checked_categories ) )
   340 		if ( ! count( $checked_categories ) ) {
   262 			$checked_categories[] = $default;
   341 			$checked_categories[] = $default;
       
   342 		}
   263 	} else {
   343 	} else {
   264 		$checked_categories[] = $default;
   344 		$checked_categories[] = $default;
   265 	}
   345 	}
   266 
   346 
   267 	$categories = get_terms( 'link_category', array( 'orderby' => 'name', 'hide_empty' => 0 ) );
   347 	$categories = get_terms( 'link_category', array( 'orderby' => 'name', 'hide_empty' => 0 ) );
   269 	if ( empty( $categories ) )
   349 	if ( empty( $categories ) )
   270 		return;
   350 		return;
   271 
   351 
   272 	foreach ( $categories as $category ) {
   352 	foreach ( $categories as $category ) {
   273 		$cat_id = $category->term_id;
   353 		$cat_id = $category->term_id;
       
   354 
       
   355 		/** This filter is documented in wp-includes/category-template.php */
   274 		$name = esc_html( apply_filters( 'the_category', $category->name ) );
   356 		$name = esc_html( apply_filters( 'the_category', $category->name ) );
   275 		$checked = in_array( $cat_id, $checked_categories ) ? ' checked="checked"' : '';
   357 		$checked = in_array( $cat_id, $checked_categories ) ? ' checked="checked"' : '';
   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>";
   358 		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>";
   277 	}
   359 	}
   278 }
   360 }
   279 
   361 
   280 // adds hidden fields with the data for use in the inline editor for posts and pages
   362 /**
   281 /**
   363  * Adds hidden fields with the data for use in the inline editor for posts and pages.
   282  * {@internal Missing Short Description}}
       
   283  *
   364  *
   284  * @since 2.7.0
   365  * @since 2.7.0
   285  *
   366  *
   286  * @param unknown_type $post
   367  * @param WP_Post $post Post object.
   287  */
   368  */
   288 function get_inline_data($post) {
   369 function get_inline_data($post) {
   289 	$post_type_object = get_post_type_object($post->post_type);
   370 	$post_type_object = get_post_type_object($post->post_type);
   290 	if ( ! current_user_can( 'edit_post', $post->ID ) )
   371 	if ( ! current_user_can( 'edit_post', $post->ID ) )
   291 		return;
   372 		return;
   292 
   373 
   293 	$title = esc_textarea( trim( $post->post_title ) );
   374 	$title = esc_textarea( trim( $post->post_title ) );
   294 
   375 
       
   376 	/** This filter is documented in wp-admin/edit-tag-form.php */
   295 	echo '
   377 	echo '
   296 <div class="hidden" id="inline_' . $post->ID . '">
   378 <div class="hidden" id="inline_' . $post->ID . '">
   297 	<div class="post_title">' . $title . '</div>
   379 	<div class="post_title">' . $title . '</div>
   298 	<div class="post_name">' . apply_filters('editable_slug', $post->post_name) . '</div>
   380 	<div class="post_name">' . apply_filters( 'editable_slug', $post->post_name ) . '</div>
   299 	<div class="post_author">' . $post->post_author . '</div>
   381 	<div class="post_author">' . $post->post_author . '</div>
   300 	<div class="comment_status">' . esc_html( $post->comment_status ) . '</div>
   382 	<div class="comment_status">' . esc_html( $post->comment_status ) . '</div>
   301 	<div class="ping_status">' . esc_html( $post->ping_status ) . '</div>
   383 	<div class="ping_status">' . esc_html( $post->ping_status ) . '</div>
   302 	<div class="_status">' . esc_html( $post->post_status ) . '</div>
   384 	<div class="_status">' . esc_html( $post->post_status ) . '</div>
   303 	<div class="jj">' . mysql2date( 'd', $post->post_date, false ) . '</div>
   385 	<div class="jj">' . mysql2date( 'd', $post->post_date, false ) . '</div>
   320 	$taxonomy_names = get_object_taxonomies( $post->post_type );
   402 	$taxonomy_names = get_object_taxonomies( $post->post_type );
   321 	foreach ( $taxonomy_names as $taxonomy_name) {
   403 	foreach ( $taxonomy_names as $taxonomy_name) {
   322 		$taxonomy = get_taxonomy( $taxonomy_name );
   404 		$taxonomy = get_taxonomy( $taxonomy_name );
   323 
   405 
   324 		if ( $taxonomy->hierarchical && $taxonomy->show_ui ) {
   406 		if ( $taxonomy->hierarchical && $taxonomy->show_ui ) {
   325 				echo '<div class="post_category" id="' . $taxonomy_name . '_' . $post->ID . '">'
   407 
   326 					. implode( ',', wp_get_object_terms( $post->ID, $taxonomy_name, array( 'fields' => 'ids' ) ) ) . '</div>';
   408 			$terms = get_object_term_cache( $post->ID, $taxonomy_name );
       
   409 			if ( false === $terms ) {
       
   410 				$terms = wp_get_object_terms( $post->ID, $taxonomy_name );
       
   411 				wp_cache_add( $post->ID, $terms, $taxonomy_name . '_relationships' );
       
   412 			}
       
   413 			$term_ids = empty( $terms ) ? array() : wp_list_pluck( $terms, 'term_id' );
       
   414 
       
   415 			echo '<div class="post_category" id="' . $taxonomy_name . '_' . $post->ID . '">' . implode( ',', $term_ids ) . '</div>';
       
   416 
   327 		} elseif ( $taxonomy->show_ui ) {
   417 		} elseif ( $taxonomy->show_ui ) {
       
   418 
   328 			echo '<div class="tags_input" id="'.$taxonomy_name.'_'.$post->ID.'">'
   419 			echo '<div class="tags_input" id="'.$taxonomy_name.'_'.$post->ID.'">'
   329 				. esc_html( str_replace( ',', ', ', get_terms_to_edit( $post->ID, $taxonomy_name ) ) ) . '</div>';
   420 				. esc_html( str_replace( ',', ', ', get_terms_to_edit( $post->ID, $taxonomy_name ) ) ) . '</div>';
       
   421 
   330 		}
   422 		}
   331 	}
   423 	}
   332 
   424 
   333 	if ( !$post_type_object->hierarchical )
   425 	if ( !$post_type_object->hierarchical )
   334 		echo '<div class="sticky">' . (is_sticky($post->ID) ? 'sticky' : '') . '</div>';
   426 		echo '<div class="sticky">' . (is_sticky($post->ID) ? 'sticky' : '') . '</div>';
   342 /**
   434 /**
   343  * {@internal Missing Short Description}}
   435  * {@internal Missing Short Description}}
   344  *
   436  *
   345  * @since 2.7.0
   437  * @since 2.7.0
   346  *
   438  *
   347  * @param unknown_type $position
   439  * @param int $position
   348  * @param unknown_type $checkbox
   440  * @param bool $checkbox
   349  * @param unknown_type $mode
   441  * @param string $mode
   350  */
   442  * @param bool $table_row
   351 function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single', $table_row = true) {
   443  */
   352 	// allow plugin to replace the popup content
   444 function wp_comment_reply( $position = 1, $checkbox = false, $mode = 'single', $table_row = true ) {
   353 	$content = apply_filters( 'wp_comment_reply', '', array('position' => $position, 'checkbox' => $checkbox, 'mode' => $mode) );
   445 	global $wp_list_table;
       
   446 	/**
       
   447 	 * Filter the in-line comment reply-to form output in the Comments
       
   448 	 * list table.
       
   449 	 *
       
   450 	 * Returning a non-empty value here will short-circuit display
       
   451 	 * of the in-line comment-reply form in the Comments list table,
       
   452 	 * echoing the returned value instead.
       
   453 	 *
       
   454 	 * @since 2.7.0
       
   455 	 *
       
   456 	 * @see wp_comment_reply()
       
   457 	 *
       
   458 	 * @param string $content The reply-to form content.
       
   459 	 * @param array  $args    An array of default args.
       
   460 	 */
       
   461 	$content = apply_filters( 'wp_comment_reply', '', array( 'position' => $position, 'checkbox' => $checkbox, 'mode' => $mode ) );
   354 
   462 
   355 	if ( ! empty($content) ) {
   463 	if ( ! empty($content) ) {
   356 		echo $content;
   464 		echo $content;
   357 		return;
   465 		return;
   358 	}
   466 	}
   359 
   467 
   360 	if ( $mode == 'single' ) {
   468 	if ( ! $wp_list_table ) {
   361 		$wp_list_table = _get_list_table('WP_Post_Comments_List_Table');
   469 		if ( $mode == 'single' ) {
   362 	} else {
   470 			$wp_list_table = _get_list_table('WP_Post_Comments_List_Table');
   363 		$wp_list_table = _get_list_table('WP_Comments_List_Table');
   471 		} else {
       
   472 			$wp_list_table = _get_list_table('WP_Comments_List_Table');
       
   473 		}
   364 	}
   474 	}
   365 
   475 
   366 ?>
   476 ?>
   367 <form method="get" action="">
   477 <form method="get">
   368 <?php if ( $table_row ) : ?>
   478 <?php if ( $table_row ) : ?>
   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">
   479 <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">
   370 <?php else : ?>
   480 <?php else : ?>
   371 <div id="com-reply" style="display:none;"><div id="replyrow" style="display:none;">
   481 <div id="com-reply" style="display:none;"><div id="replyrow" style="display:none;">
   372 <?php endif; ?>
   482 <?php endif; ?>
   383 		<input type="text" name="newcomment_author_email" size="50" value="" id="author-email" />
   493 		<input type="text" name="newcomment_author_email" size="50" value="" id="author-email" />
   384 		</div>
   494 		</div>
   385 
   495 
   386 		<div class="inside">
   496 		<div class="inside">
   387 		<label for="author-url"><?php _e('URL') ?></label>
   497 		<label for="author-url"><?php _e('URL') ?></label>
   388 		<input type="text" id="author-url" name="newcomment_author_url" size="103" value="" />
   498 		<input type="text" id="author-url" name="newcomment_author_url" class="code" size="103" value="" />
   389 		</div>
   499 		</div>
   390 		<div style="clear:both;"></div>
   500 		<div style="clear:both;"></div>
   391 	</div>
   501 	</div>
   392 
   502 
   393 	<div id="replycontainer">
   503 	<div id="replycontainer">
   406 	<span class="waiting spinner"></span>
   516 	<span class="waiting spinner"></span>
   407 	<span class="error" style="display:none;"></span>
   517 	<span class="error" style="display:none;"></span>
   408 	<br class="clear" />
   518 	<br class="clear" />
   409 	</p>
   519 	</p>
   410 
   520 
   411 	<input type="hidden" name="user_ID" id="user_ID" value="<?php echo get_current_user_id(); ?>" />
       
   412 	<input type="hidden" name="action" id="action" value="" />
   521 	<input type="hidden" name="action" id="action" value="" />
   413 	<input type="hidden" name="comment_ID" id="comment_ID" value="" />
   522 	<input type="hidden" name="comment_ID" id="comment_ID" value="" />
   414 	<input type="hidden" name="comment_post_ID" id="comment_post_ID" value="" />
   523 	<input type="hidden" name="comment_post_ID" id="comment_post_ID" value="" />
   415 	<input type="hidden" name="status" id="status" value="" />
   524 	<input type="hidden" name="status" id="status" value="" />
   416 	<input type="hidden" name="position" id="position" value="<?php echo $position; ?>" />
   525 	<input type="hidden" name="position" id="position" value="<?php echo $position; ?>" />
   449 /**
   558 /**
   450  * {@internal Missing Short Description}}
   559  * {@internal Missing Short Description}}
   451  *
   560  *
   452  * @since 1.2.0
   561  * @since 1.2.0
   453  *
   562  *
   454  * @param unknown_type $meta
   563  * @param array $meta
   455  */
   564  */
   456 function list_meta( $meta ) {
   565 function list_meta( $meta ) {
   457 	// Exit if no meta
   566 	// Exit if no meta
   458 	if ( ! $meta ) {
   567 	if ( ! $meta ) {
   459 		echo '
   568 		echo '
   492 /**
   601 /**
   493  * {@internal Missing Short Description}}
   602  * {@internal Missing Short Description}}
   494  *
   603  *
   495  * @since 2.5.0
   604  * @since 2.5.0
   496  *
   605  *
   497  * @param unknown_type $entry
   606  * @param array $entry
   498  * @param unknown_type $count
   607  * @param int   $count
   499  * @return unknown
   608  * @return string
   500  */
   609  */
   501 function _list_meta_row( $entry, &$count ) {
   610 function _list_meta_row( $entry, &$count ) {
   502 	static $update_nonce = false;
   611 	static $update_nonce = false;
   503 
   612 
   504 	if ( is_protected_meta( $entry['meta_key'], 'post' ) )
   613 	if ( is_protected_meta( $entry['meta_key'], 'post' ) )
   505 		return;
   614 		return '';
   506 
   615 
   507 	if ( !$update_nonce )
   616 	if ( !$update_nonce )
   508 		$update_nonce = wp_create_nonce( 'add-meta' );
   617 		$update_nonce = wp_create_nonce( 'add-meta' );
   509 
   618 
   510 	$r = '';
   619 	$r = '';
   511 	++ $count;
   620 	++ $count;
   512 	if ( $count % 2 )
       
   513 		$style = 'alternate';
       
   514 	else
       
   515 		$style = '';
       
   516 
   621 
   517 	if ( is_serialized( $entry['meta_value'] ) ) {
   622 	if ( is_serialized( $entry['meta_value'] ) ) {
   518 		if ( is_serialized_string( $entry['meta_value'] ) ) {
   623 		if ( is_serialized_string( $entry['meta_value'] ) ) {
   519 			// this is a serialized string, so we should display it
   624 			// This is a serialized string, so we should display it.
   520 			$entry['meta_value'] = maybe_unserialize( $entry['meta_value'] );
   625 			$entry['meta_value'] = maybe_unserialize( $entry['meta_value'] );
   521 		} else {
   626 		} else {
   522 			// this is a serialized array/object so we should NOT display it
   627 			// This is a serialized array/object so we should NOT display it.
   523 			--$count;
   628 			--$count;
   524 			return;
   629 			return '';
   525 		}
   630 		}
   526 	}
   631 	}
   527 
   632 
   528 	$entry['meta_key'] = esc_attr($entry['meta_key']);
   633 	$entry['meta_key'] = esc_attr($entry['meta_key']);
   529 	$entry['meta_value'] = esc_textarea( $entry['meta_value'] ); // using a <textarea />
   634 	$entry['meta_value'] = esc_textarea( $entry['meta_value'] ); // using a <textarea />
   530 	$entry['meta_id'] = (int) $entry['meta_id'];
   635 	$entry['meta_id'] = (int) $entry['meta_id'];
   531 
   636 
   532 	$delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] );
   637 	$delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] );
   533 
   638 
   534 	$r .= "\n\t<tr id='meta-{$entry['meta_id']}' class='$style'>";
   639 	$r .= "\n\t<tr id='meta-{$entry['meta_id']}'>";
   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']}' />";
   640 	$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']}' />";
   536 
   641 
   537 	$r .= "\n\t\t<div class='submit'>";
   642 	$r .= "\n\t\t<div class='submit'>";
   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" ) );
   643 	$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" ) );
   539 	$r .= "\n\t\t";
   644 	$r .= "\n\t\t";
   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" ) );
   645 	$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" ) );
   541 	$r .= "</div>";
   646 	$r .= "</div>";
   542 	$r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false );
   647 	$r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false );
   543 	$r .= "</td>";
   648 	$r .= "</td>";
   544 
   649 
   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>";
   650 	$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>";
   546 	return $r;
   651 	return $r;
   547 }
   652 }
   548 
   653 
   549 /**
   654 /**
   550  * Prints the form in the Custom Fields meta box.
   655  * Prints the form in the Custom Fields meta box.
   554  * @param WP_Post $post Optional. The post being edited.
   659  * @param WP_Post $post Optional. The post being edited.
   555  */
   660  */
   556 function meta_form( $post = null ) {
   661 function meta_form( $post = null ) {
   557 	global $wpdb;
   662 	global $wpdb;
   558 	$post = get_post( $post );
   663 	$post = get_post( $post );
   559 	$limit = (int) apply_filters( 'postmeta_form_limit', 30 );
   664 
   560 	$keys = $wpdb->get_col( "
   665 	/**
   561 		SELECT meta_key
   666 	 * Filter the number of custom fields to retrieve for the drop-down
       
   667 	 * in the Custom Fields meta box.
       
   668 	 *
       
   669 	 * @since 2.1.0
       
   670 	 *
       
   671 	 * @param int $limit Number of custom fields to retrieve. Default 30.
       
   672 	 */
       
   673 	$limit = apply_filters( 'postmeta_form_limit', 30 );
       
   674 	$sql = "SELECT meta_key
   562 		FROM $wpdb->postmeta
   675 		FROM $wpdb->postmeta
   563 		GROUP BY meta_key
   676 		GROUP BY meta_key
   564 		HAVING meta_key NOT LIKE '\_%'
   677 		HAVING meta_key NOT LIKE %s
   565 		ORDER BY meta_key
   678 		ORDER BY meta_key
   566 		LIMIT $limit" );
   679 		LIMIT %d";
   567 	if ( $keys )
   680 	$keys = $wpdb->get_col( $wpdb->prepare( $sql, $wpdb->esc_like( '_' ) . '%', $limit ) );
   568 		natcasesort($keys);
   681 	if ( $keys ) {
       
   682 		natcasesort( $keys );
       
   683 		$meta_key_input_id = 'metakeyselect';
       
   684 	} else {
       
   685 		$meta_key_input_id = 'metakeyinput';
       
   686 	}
   569 ?>
   687 ?>
   570 <p><strong><?php _e( 'Add New Custom Field:' ) ?></strong></p>
   688 <p><strong><?php _e( 'Add New Custom Field:' ) ?></strong></p>
   571 <table id="newmeta">
   689 <table id="newmeta">
   572 <thead>
   690 <thead>
   573 <tr>
   691 <tr>
   574 <th class="left"><label for="metakeyselect"><?php _ex( 'Name', 'meta name' ) ?></label></th>
   692 <th class="left"><label for="<?php echo $meta_key_input_id; ?>"><?php _ex( 'Name', 'meta name' ) ?></label></th>
   575 <th><label for="metavalue"><?php _e( 'Value' ) ?></label></th>
   693 <th><label for="metavalue"><?php _e( 'Value' ) ?></label></th>
   576 </tr>
   694 </tr>
   577 </thead>
   695 </thead>
   578 
   696 
   579 <tbody>
   697 <tbody>
   613 <?php
   731 <?php
   614 
   732 
   615 }
   733 }
   616 
   734 
   617 /**
   735 /**
   618  * {@internal Missing Short Description}}
   736  * Print out HTML form date elements for editing post or comment publish date.
   619  *
   737  *
   620  * @since 0.71
   738  * @since 0.71
   621  *
   739  *
   622  * @param unknown_type $edit
   740  * @param int|bool $edit      Accepts 1|true for editing the date, 0|false for adding the date.
   623  * @param unknown_type $for_post
   741  * @param int|bool $for_post  Accepts 1|true for applying the date to a post, 0|false for a comment.
   624  * @param unknown_type $tab_index
   742  * @param int      $tab_index The tabindex attribute to add. Default 0.
   625  * @param unknown_type $multi
   743  * @param int|bool $multi     Optional. Whether the additional fields and buttons should be added.
       
   744  *                            Default 0|false.
   626  */
   745  */
   627 function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
   746 function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
   628 	global $wp_locale, $comment;
   747 	global $wp_locale, $comment;
   629 	$post = get_post();
   748 	$post = get_post();
   630 
   749 
   633 
   752 
   634 	$tab_index_attribute = '';
   753 	$tab_index_attribute = '';
   635 	if ( (int) $tab_index > 0 )
   754 	if ( (int) $tab_index > 0 )
   636 		$tab_index_attribute = " tabindex=\"$tab_index\"";
   755 		$tab_index_attribute = " tabindex=\"$tab_index\"";
   637 
   756 
       
   757 	// todo: Remove this?
   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 />';
   758 	// 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 />';
   639 
   759 
   640 	$time_adj = current_time('timestamp');
   760 	$time_adj = current_time('timestamp');
   641 	$post_date = ($for_post) ? $post->post_date : $comment->comment_date;
   761 	$post_date = ($for_post) ? $post->post_date : $comment->comment_date;
   642 	$jj = ($edit) ? mysql2date( 'd', $post_date, false ) : gmdate( 'd', $time_adj );
   762 	$jj = ($edit) ? mysql2date( 'd', $post_date, false ) : gmdate( 'd', $time_adj );
   650 	$cur_mm = gmdate( 'm', $time_adj );
   770 	$cur_mm = gmdate( 'm', $time_adj );
   651 	$cur_aa = gmdate( 'Y', $time_adj );
   771 	$cur_aa = gmdate( 'Y', $time_adj );
   652 	$cur_hh = gmdate( 'H', $time_adj );
   772 	$cur_hh = gmdate( 'H', $time_adj );
   653 	$cur_mn = gmdate( 'i', $time_adj );
   773 	$cur_mn = gmdate( 'i', $time_adj );
   654 
   774 
   655 	$month = "<select " . ( $multi ? '' : 'id="mm" ' ) . "name=\"mm\"$tab_index_attribute>\n";
   775 	$month = '<label for="mm" class="screen-reader-text">' . __( 'Month' ) . '</label><select ' . ( $multi ? '' : 'id="mm" ' ) . 'name="mm"' . $tab_index_attribute . ">\n";
   656 	for ( $i = 1; $i < 13; $i = $i +1 ) {
   776 	for ( $i = 1; $i < 13; $i = $i +1 ) {
   657 		$monthnum = zeroise($i, 2);
   777 		$monthnum = zeroise($i, 2);
   658 		$month .= "\t\t\t" . '<option value="' . $monthnum . '"';
   778 		$month .= "\t\t\t" . '<option value="' . $monthnum . '" ' . selected( $monthnum, $mm, false ) . '>';
   659 		if ( $i == $mm )
       
   660 			$month .= ' selected="selected"';
       
   661 		/* translators: 1: month number (01, 02, etc.), 2: month abbreviation */
   779 		/* translators: 1: month number (01, 02, etc.), 2: month abbreviation */
   662 		$month .= '>' . sprintf( __( '%1$s-%2$s' ), $monthnum, $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ) ) . "</option>\n";
   780 		$month .= sprintf( __( '%1$s-%2$s' ), $monthnum, $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ) ) . "</option>\n";
   663 	}
   781 	}
   664 	$month .= '</select>';
   782 	$month .= '</select>';
   665 
   783 
   666 	$day = '<input type="text" ' . ( $multi ? '' : 'id="jj" ' ) . 'name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
   784 	$day = '<label for="jj" class="screen-reader-text">' . __( 'Day' ) . '</label><input type="text" ' . ( $multi ? '' : 'id="jj" ' ) . 'name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
   667 	$year = '<input type="text" ' . ( $multi ? '' : 'id="aa" ' ) . 'name="aa" value="' . $aa . '" size="4" maxlength="4"' . $tab_index_attribute . ' autocomplete="off" />';
   785 	$year = '<label for="aa" class="screen-reader-text">' . __( 'Year' ) . '</label><input type="text" ' . ( $multi ? '' : 'id="aa" ' ) . 'name="aa" value="' . $aa . '" size="4" maxlength="4"' . $tab_index_attribute . ' autocomplete="off" />';
   668 	$hour = '<input type="text" ' . ( $multi ? '' : 'id="hh" ' ) . 'name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
   786 	$hour = '<label for="hh" class="screen-reader-text">' . __( 'Hour' ) . '</label><input type="text" ' . ( $multi ? '' : 'id="hh" ' ) . 'name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
   669 	$minute = '<input type="text" ' . ( $multi ? '' : 'id="mn" ' ) . 'name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
   787 	$minute = '<label for="mn" class="screen-reader-text">' . __( 'Minute' ) . '</label><input type="text" ' . ( $multi ? '' : 'id="mn" ' ) . 'name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
   670 
   788 
   671 	echo '<div class="timestamp-wrap">';
   789 	echo '<div class="timestamp-wrap">';
   672 	/* translators: 1: month, 2: day, 3: year, 4: hour, 5: minute */
   790 	/* translators: 1: month, 2: day, 3: year, 4: hour, 5: minute */
   673 	printf( __( '%1$s %2$s, %3$s @ %4$s : %5$s' ), $month, $day, $year, $hour, $minute );
   791 	printf( __( '%1$s %2$s, %3$s @ %4$s : %5$s' ), $month, $day, $year, $hour, $minute );
   674 
   792 
   675 	echo '</div><input type="hidden" id="ss" name="ss" value="' . $ss . '" />';
   793 	echo '</div><input type="hidden" id="ss" name="ss" value="' . $ss . '" />';
   676 
   794 
   677 	if ( $multi ) return;
   795 	if ( $multi ) return;
   678 
   796 
   679 	echo "\n\n";
   797 	echo "\n\n";
   680 	foreach ( array('mm', 'jj', 'aa', 'hh', 'mn') as $timeunit ) {
   798 	$map = array(
   681 		echo '<input type="hidden" id="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . $$timeunit . '" />' . "\n";
   799 		'mm' => array( $mm, $cur_mm ),
       
   800 		'jj' => array( $jj, $cur_jj ),
       
   801 		'aa' => array( $aa, $cur_aa ),
       
   802 		'hh' => array( $hh, $cur_hh ),
       
   803 		'mn' => array( $mn, $cur_mn ),
       
   804 	);
       
   805 	foreach ( $map as $timeunit => $value ) {
       
   806 		list( $unit, $curr ) = $value;
       
   807 
       
   808 		echo '<input type="hidden" id="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . $unit . '" />' . "\n";
   682 		$cur_timeunit = 'cur_' . $timeunit;
   809 		$cur_timeunit = 'cur_' . $timeunit;
   683 		echo '<input type="hidden" id="'. $cur_timeunit . '" name="'. $cur_timeunit . '" value="' . $$cur_timeunit . '" />' . "\n";
   810 		echo '<input type="hidden" id="' . $cur_timeunit . '" name="' . $cur_timeunit . '" value="' . $curr . '" />' . "\n";
   684 	}
   811 	}
   685 ?>
   812 ?>
   686 
   813 
   687 <p>
   814 <p>
   688 <a href="#edit_timestamp" class="save-timestamp hide-if-no-js button"><?php _e('OK'); ?></a>
   815 <a href="#edit_timestamp" class="save-timestamp hide-if-no-js button"><?php _e('OK'); ?></a>
   689 <a href="#edit_timestamp" class="cancel-timestamp hide-if-no-js"><?php _e('Cancel'); ?></a>
   816 <a href="#edit_timestamp" class="cancel-timestamp hide-if-no-js button-cancel"><?php _e('Cancel'); ?></a>
   690 </p>
   817 </p>
   691 <?php
   818 <?php
   692 }
   819 }
   693 
   820 
   694 /**
   821 /**
   695  * {@internal Missing Short Description}}
   822  * Print out option HTML elements for the page templates drop-down.
   696  *
   823  *
   697  * @since 1.5.0
   824  * @since 1.5.0
   698  *
   825  *
   699  * @param unknown_type $default
   826  * @param string $default Optional. The template file name. Default empty.
   700  */
   827  */
   701 function page_template_dropdown( $default = '' ) {
   828 function page_template_dropdown( $default = '' ) {
   702 	$templates = get_page_templates();
   829 	$templates = get_page_templates( get_post() );
   703 	ksort( $templates );
   830 	ksort( $templates );
   704 	foreach (array_keys( $templates ) as $template )
   831 	foreach ( array_keys( $templates ) as $template ) {
   705 		: if ( $default == $templates[$template] )
   832 		$selected = selected( $default, $templates[ $template ], false );
   706 			$selected = " selected='selected'";
   833 		echo "\n\t<option value='" . $templates[ $template ] . "' $selected>$template</option>";
   707 		else
   834 	}
   708 			$selected = '';
   835 }
   709 	echo "\n\t<option value='".$templates[$template]."' $selected>$template</option>";
   836 
   710 	endforeach;
   837 /**
   711 }
   838  * Print out option HTML elements for the page parents drop-down.
   712 
       
   713 /**
       
   714  * {@internal Missing Short Description}}
       
   715  *
   839  *
   716  * @since 1.5.0
   840  * @since 1.5.0
   717  *
   841  *
   718  * @param unknown_type $default
   842  * @param int $default Optional. The default page ID to be pre-selected. Default 0.
   719  * @param unknown_type $parent
   843  * @param int $parent  Optional. The parent page ID. Default 0.
   720  * @param unknown_type $level
   844  * @param int $level   Optional. Page depth level. Default 0.
   721  * @return unknown
   845  *
       
   846  * @return null|false Boolean False if page has no children, otherwise print out html elements
   722  */
   847  */
   723 function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) {
   848 function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) {
   724 	global $wpdb;
   849 	global $wpdb;
   725 	$post = get_post();
   850 	$post = get_post();
   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) );
   851 	$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) );
   730 			// A page cannot be its own parent.
   855 			// A page cannot be its own parent.
   731 			if ( $post && $post->ID && $item->ID == $post->ID )
   856 			if ( $post && $post->ID && $item->ID == $post->ID )
   732 				continue;
   857 				continue;
   733 
   858 
   734 			$pad = str_repeat( '&nbsp;', $level * 3 );
   859 			$pad = str_repeat( '&nbsp;', $level * 3 );
   735 			if ( $item->ID == $default)
   860 			$selected = selected( $default, $item->ID, false );
   736 				$current = ' selected="selected"';
   861 
   737 			else
   862 			echo "\n\t<option class='level-$level' value='$item->ID' $selected>$pad " . esc_html($item->post_title) . "</option>";
   738 				$current = '';
       
   739 
       
   740 			echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad " . esc_html($item->post_title) . "</option>";
       
   741 			parent_dropdown( $default, $item->ID, $level +1 );
   863 			parent_dropdown( $default, $item->ID, $level +1 );
   742 		}
   864 		}
   743 	} else {
   865 	} else {
   744 		return false;
   866 		return false;
   745 	}
   867 	}
   746 }
   868 }
   747 
   869 
   748 /**
   870 /**
   749  * Print out <option> html elements for role selectors
   871  * Print out option html elements for role selectors.
   750  *
   872  *
   751  * @since 2.1.0
   873  * @since 2.1.0
   752  *
   874  *
   753  * @param string $selected slug for the role that should be already selected
   875  * @param string $selected Slug for the role that should be already selected.
   754  */
   876  */
   755 function wp_dropdown_roles( $selected = false ) {
   877 function wp_dropdown_roles( $selected = '' ) {
   756 	$p = '';
   878 	$p = '';
   757 	$r = '';
   879 	$r = '';
   758 
   880 
   759 	$editable_roles = array_reverse( get_editable_roles() );
   881 	$editable_roles = array_reverse( get_editable_roles() );
   760 
   882 
   774  * @since 2.0.0
   896  * @since 2.0.0
   775  *
   897  *
   776  * @param string $action The action attribute for the form.
   898  * @param string $action The action attribute for the form.
   777  */
   899  */
   778 function wp_import_upload_form( $action ) {
   900 function wp_import_upload_form( $action ) {
       
   901 
       
   902 	/**
       
   903 	 * Filter the maximum allowed upload size for import files.
       
   904 	 *
       
   905 	 * @since 2.3.0
       
   906 	 *
       
   907 	 * @see wp_max_upload_size()
       
   908 	 *
       
   909 	 * @param int $max_upload_size Allowed upload size. Default 1 MB.
       
   910 	 */
   779 	$bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() );
   911 	$bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() );
   780 	$size = size_format( $bytes );
   912 	$size = size_format( $bytes );
   781 	$upload_dir = wp_upload_dir();
   913 	$upload_dir = wp_upload_dir();
   782 	if ( ! empty( $upload_dir['error'] ) ) :
   914 	if ( ! empty( $upload_dir['error'] ) ) :
   783 		?><div class="error"><p><?php _e('Before you can upload your import file, you will need to fix the following error:'); ?></p>
   915 		?><div class="error"><p><?php _e('Before you can upload your import file, you will need to fix the following error:'); ?></p>
   800 /**
   932 /**
   801  * Add a meta box to an edit form.
   933  * Add a meta box to an edit form.
   802  *
   934  *
   803  * @since 2.5.0
   935  * @since 2.5.0
   804  *
   936  *
   805  * @param string $id String for use in the 'id' attribute of tags.
   937  * @param string           $id            String for use in the 'id' attribute of tags.
   806  * @param string $title Title of the meta box.
   938  * @param string           $title         Title of the meta box.
   807  * @param string $callback Function that fills the box with the desired content. The function should echo its output.
   939  * @param callback         $callback      Function that fills the box with the desired content.
   808  * @param string|object $screen Optional. The screen on which to show the box (post, page, link). Defaults to current screen.
   940  *                                        The function should echo its output.
   809  * @param string $context Optional. The context within the page where the boxes should show ('normal', 'advanced').
   941  * @param string|WP_Screen $screen        Optional. The screen on which to show the box (like a post
   810  * @param string $priority Optional. The priority within the context where the boxes should show ('high', 'low').
   942  *                                        type, 'link', or 'comment'). Default is the current screen.
   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).
   943  * @param string           $context       Optional. The context within the screen where the boxes
       
   944  *                                        should display. Available contexts vary from screen to
       
   945  *                                        screen. Post edit screen contexts include 'normal', 'side',
       
   946  *                                        and 'advanced'. Comments screen contexts include 'normal'
       
   947  *                                        and 'side'. Menus meta boxes (accordion sections) all use
       
   948  *                                        the 'side' context. Global default is 'advanced'.
       
   949  * @param string           $priority      Optional. The priority within the context where the boxes
       
   950  *                                        should show ('high', 'low'). Default 'default'.
       
   951  * @param array            $callback_args Optional. Data that should be set as the $args property
       
   952  *                                        of the box array (which is the second parameter passed
       
   953  *                                        to your callback). Default null.
   812  */
   954  */
   813 function add_meta_box( $id, $title, $callback, $screen = null, $context = 'advanced', $priority = 'default', $callback_args = null ) {
   955 function add_meta_box( $id, $title, $callback, $screen = null, $context = 'advanced', $priority = 'default', $callback_args = null ) {
   814 	global $wp_meta_boxes;
   956 	global $wp_meta_boxes;
   815 
   957 
   816 	if ( empty( $screen ) )
   958 	if ( empty( $screen ) )
   835 			// If a core box was previously added or removed by a plugin, don't add.
   977 			// If a core box was previously added or removed by a plugin, don't add.
   836 			if ( 'core' == $priority ) {
   978 			if ( 'core' == $priority ) {
   837 				// If core box previously deleted, don't add
   979 				// If core box previously deleted, don't add
   838 				if ( false === $wp_meta_boxes[$page][$a_context][$a_priority][$id] )
   980 				if ( false === $wp_meta_boxes[$page][$a_context][$a_priority][$id] )
   839 					return;
   981 					return;
   840 				// If box was added with default priority, give it core priority to maintain sort order
   982 
       
   983 				/*
       
   984 				 * If box was added with default priority, give it core priority to
       
   985 				 * maintain sort order.
       
   986 				 */
   841 				if ( 'default' == $a_priority ) {
   987 				if ( 'default' == $a_priority ) {
   842 					$wp_meta_boxes[$page][$a_context]['core'][$id] = $wp_meta_boxes[$page][$a_context]['default'][$id];
   988 					$wp_meta_boxes[$page][$a_context]['core'][$id] = $wp_meta_boxes[$page][$a_context]['default'][$id];
   843 					unset($wp_meta_boxes[$page][$a_context]['default'][$id]);
   989 					unset($wp_meta_boxes[$page][$a_context]['default'][$id]);
   844 				}
   990 				}
   845 				return;
   991 				return;
   846 			}
   992 			}
   847 			// If no priority given and id already present, use existing priority
   993 			// If no priority given and id already present, use existing priority.
   848 			if ( empty($priority) ) {
   994 			if ( empty($priority) ) {
   849 				$priority = $a_priority;
   995 				$priority = $a_priority;
   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.
   996 			/*
       
   997 			 * Else, if we're adding to the sorted priority, we don't know the title
       
   998 			 * or callback. Grab them from the previously added context/priority.
       
   999 			 */
   851 			} elseif ( 'sorted' == $priority ) {
  1000 			} elseif ( 'sorted' == $priority ) {
   852 				$title = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['title'];
  1001 				$title = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['title'];
   853 				$callback = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['callback'];
  1002 				$callback = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['callback'];
   854 				$callback_args = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['args'];
  1003 				$callback_args = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['args'];
   855 			}
  1004 			}
   856 			// An id can be in only one priority and one context
  1005 			// An id can be in only one priority and one context.
   857 			if ( $priority != $a_priority || $context != $a_context )
  1006 			if ( $priority != $a_priority || $context != $a_context )
   858 				unset($wp_meta_boxes[$page][$a_context][$a_priority][$id]);
  1007 				unset($wp_meta_boxes[$page][$a_context][$a_priority][$id]);
   859 		}
  1008 		}
   860 	}
  1009 	}
   861 
  1010 
   871 /**
  1020 /**
   872  * Meta-Box template function
  1021  * Meta-Box template function
   873  *
  1022  *
   874  * @since 2.5.0
  1023  * @since 2.5.0
   875  *
  1024  *
   876  * @param string|object $screen Screen identifier
  1025  * @staticvar bool $already_sorted
       
  1026  * @param string|WP_Screen $screen Screen identifier
   877  * @param string $context box context
  1027  * @param string $context box context
   878  * @param mixed $object gets passed to the box callback function as first parameter
  1028  * @param mixed $object gets passed to the box callback function as first parameter
   879  * @return int number of meta_boxes
  1029  * @return int number of meta_boxes
   880  */
  1030  */
   881 function do_meta_boxes( $screen, $context, $object ) {
  1031 function do_meta_boxes( $screen, $context, $object ) {
   891 
  1041 
   892 	$hidden = get_hidden_meta_boxes( $screen );
  1042 	$hidden = get_hidden_meta_boxes( $screen );
   893 
  1043 
   894 	printf('<div id="%s-sortables" class="meta-box-sortables">', htmlspecialchars($context));
  1044 	printf('<div id="%s-sortables" class="meta-box-sortables">', htmlspecialchars($context));
   895 
  1045 
   896 	$i = 0;
  1046 	// Grab the ones the user has manually sorted. Pull them out of their previous context/priority and into the one the user chose
   897 	do {
  1047 	if ( ! $already_sorted && $sorted = get_user_option( "meta-box-order_$page" ) ) {
   898 		// Grab the ones the user has manually sorted. Pull them out of their previous context/priority and into the one the user chose
  1048 		foreach ( $sorted as $box_context => $ids ) {
   899 		if ( !$already_sorted && $sorted = get_user_option( "meta-box-order_$page" ) ) {
  1049 			foreach ( explode( ',', $ids ) as $id ) {
   900 			foreach ( $sorted as $box_context => $ids ) {
  1050 				if ( $id && 'dashboard_browser_nag' !== $id ) {
   901 				foreach ( explode(',', $ids ) as $id ) {
  1051 					add_meta_box( $id, null, null, $screen, $box_context, 'sorted' );
   902 					if ( $id && 'dashboard_browser_nag' !== $id )
       
   903 						add_meta_box( $id, null, null, $screen, $box_context, 'sorted' );
       
   904 				}
  1052 				}
   905 			}
  1053 			}
   906 		}
  1054 		}
   907 		$already_sorted = true;
  1055 	}
   908 
  1056 
   909 		if ( !isset($wp_meta_boxes) || !isset($wp_meta_boxes[$page]) || !isset($wp_meta_boxes[$page][$context]) )
  1057 	$already_sorted = true;
   910 			break;
  1058 
   911 
  1059 	$i = 0;
   912 		foreach ( array('high', 'sorted', 'core', 'default', 'low') as $priority ) {
  1060 
   913 			if ( isset($wp_meta_boxes[$page][$context][$priority]) ) {
  1061 	if ( isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
   914 				foreach ( (array) $wp_meta_boxes[$page][$context][$priority] as $box ) {
  1062 		foreach ( array( 'high', 'sorted', 'core', 'default', 'low' ) as $priority ) {
       
  1063 			if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ]) ) {
       
  1064 				foreach ( (array) $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) {
   915 					if ( false == $box || ! $box['title'] )
  1065 					if ( false == $box || ! $box['title'] )
   916 						continue;
  1066 						continue;
   917 					$i++;
  1067 					$i++;
   918 					$hidden_class = in_array($box['id'], $hidden) ? ' hide-if-js' : '';
  1068 					$hidden_class = in_array($box['id'], $hidden) ? ' hide-if-js' : '';
   919 					echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id'], $page) . $hidden_class . '" ' . '>' . "\n";
  1069 					echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes($box['id'], $page) . $hidden_class . '" ' . '>' . "\n";
   925 					echo "</div>\n";
  1075 					echo "</div>\n";
   926 					echo "</div>\n";
  1076 					echo "</div>\n";
   927 				}
  1077 				}
   928 			}
  1078 			}
   929 		}
  1079 		}
   930 	} while(0);
  1080 	}
   931 
  1081 
   932 	echo "</div>";
  1082 	echo "</div>";
   933 
  1083 
   934 	return $i;
  1084 	return $i;
   935 
  1085 
   998 	<div id="side-sortables" class="accordion-container">
  1148 	<div id="side-sortables" class="accordion-container">
   999 		<ul class="outer-border">
  1149 		<ul class="outer-border">
  1000 	<?php
  1150 	<?php
  1001 	$i = 0;
  1151 	$i = 0;
  1002 	$first_open = false;
  1152 	$first_open = false;
  1003 	do {
  1153 
  1004 		if ( ! isset( $wp_meta_boxes ) || ! isset( $wp_meta_boxes[$page] ) || ! isset( $wp_meta_boxes[$page][$context] ) )
  1154 	if ( isset( $wp_meta_boxes[ $page ][ $context ] ) ) {
  1005 			break;
       
  1006 
       
  1007 		foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) {
  1155 		foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) {
  1008 			if ( isset( $wp_meta_boxes[$page][$context][$priority] ) ) {
  1156 			if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) {
  1009 				foreach ( $wp_meta_boxes[$page][$context][$priority] as $box ) {
  1157 				foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) {
  1010 					if ( false == $box || ! $box['title'] )
  1158 					if ( false == $box || ! $box['title'] )
  1011 						continue;
  1159 						continue;
  1012 					$i++;
  1160 					$i++;
  1013 					$hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : '';
  1161 					$hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : '';
  1014 
  1162 
  1017 						$first_open = true;
  1165 						$first_open = true;
  1018 						$open_class = 'open';
  1166 						$open_class = 'open';
  1019 					}
  1167 					}
  1020 					?>
  1168 					?>
  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'] ); ?>">
  1169 					<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'] ); ?>">
  1022 						<h3 class="accordion-section-title hndle" tabindex="0" title="<?php echo esc_attr( $box['title'] ); ?>"><?php echo esc_html( $box['title'] ); ?></h3>
  1170 						<h3 class="accordion-section-title hndle" tabindex="0">
       
  1171 							<?php echo esc_html( $box['title'] ); ?>
       
  1172 							<span class="screen-reader-text"><?php _e( 'Press return or enter to expand' ); ?></span>
       
  1173 						</h3>
  1023 						<div class="accordion-section-content <?php postbox_classes( $box['id'], $page ); ?>">
  1174 						<div class="accordion-section-content <?php postbox_classes( $box['id'], $page ); ?>">
  1024 							<div class="inside">
  1175 							<div class="inside">
  1025 								<?php call_user_func( $box['callback'], $object, $box ); ?>
  1176 								<?php call_user_func( $box['callback'], $object, $box ); ?>
  1026 							</div><!-- .inside -->
  1177 							</div><!-- .inside -->
  1027 						</div><!-- .accordion-section-content -->
  1178 						</div><!-- .accordion-section-content -->
  1028 					</li><!-- .accordion-section -->
  1179 					</li><!-- .accordion-section -->
  1029 					<?php
  1180 					<?php
  1030 				}
  1181 				}
  1031 			}
  1182 			}
  1032 		}
  1183 		}
  1033 	} while(0);
  1184 	}
  1034 	?>
  1185 	?>
  1035 		</ul><!-- .outer-border -->
  1186 		</ul><!-- .outer-border -->
  1036 	</div><!-- .accordion-container -->
  1187 	</div><!-- .accordion-container -->
  1037 	<?php
  1188 	<?php
  1038 	return $i;
  1189 	return $i;
  1084  * The $callback argument should be the name of a function that echoes out the
  1235  * The $callback argument should be the name of a function that echoes out the
  1085  * html input tags for this setting field. Use get_option() to retrieve existing
  1236  * html input tags for this setting field. Use get_option() to retrieve existing
  1086  * values to show.
  1237  * values to show.
  1087  *
  1238  *
  1088  * @since 2.7.0
  1239  * @since 2.7.0
       
  1240  * @since 4.2.0 The `$class` argument was added.
  1089  *
  1241  *
  1090  * @global $wp_settings_fields Storage array of settings fields and info about their pages/sections
  1242  * @global $wp_settings_fields Storage array of settings fields and info about their pages/sections
  1091  *
  1243  *
  1092  * @param string $id Slug-name to identify the field. Used in the 'id' attribute of tags.
  1244  * @param string $id       Slug-name to identify the field. Used in the 'id' attribute of tags.
  1093  * @param string $title Formatted title of the field. Shown as the label for the field during output.
  1245  * @param string $title    Formatted title of the field. Shown as the label for the field
  1094  * @param string $callback Function that fills the field with the desired form inputs. The function should echo its output.
  1246  *                         during output.
  1095  * @param string $page The slug-name of the settings page on which to show the section (general, reading, writing, ...).
  1247  * @param string $callback Function that fills the field with the desired form inputs. The
  1096  * @param string $section The slug-name of the section of the settings page in which to show the box (default, ...).
  1248  *                         function should echo its output.
  1097  * @param array $args Additional arguments
  1249  * @param string $page     The slug-name of the settings page on which to show the section
       
  1250  *                         (general, reading, writing, ...).
       
  1251  * @param string $section  Optional. The slug-name of the section of the settings page
       
  1252  *                         in which to show the box. Default 'default'.
       
  1253  * @param array  $args {
       
  1254  *     Optional. Extra arguments used when outputting the field.
       
  1255  *
       
  1256  *     @type string $label_for When supplied, the setting title will be wrapped
       
  1257  *                             in a `<label>` element, its `for` attribute populated
       
  1258  *                             with this value.
       
  1259  *     @type string $class     CSS Class to be added to the `<tr>` element when the
       
  1260  *                             field is output.
       
  1261  * }
  1098  */
  1262  */
  1099 function add_settings_field($id, $title, $callback, $page, $section = 'default', $args = array()) {
  1263 function add_settings_field($id, $title, $callback, $page, $section = 'default', $args = array()) {
  1100 	global $wp_settings_fields;
  1264 	global $wp_settings_fields;
  1101 
  1265 
  1102 	if ( 'misc' == $page ) {
  1266 	if ( 'misc' == $page ) {
  1156  * @global $wp_settings_fields Storage array of settings fields and their pages/sections
  1320  * @global $wp_settings_fields Storage array of settings fields and their pages/sections
  1157  *
  1321  *
  1158  * @since 2.7.0
  1322  * @since 2.7.0
  1159  *
  1323  *
  1160  * @param string $page Slug title of the admin page who's settings fields you want to show.
  1324  * @param string $page Slug title of the admin page who's settings fields you want to show.
  1161  * @param section $section Slug title of the settings section who's fields you want to show.
  1325  * @param string $section Slug title of the settings section who's fields you want to show.
  1162  */
  1326  */
  1163 function do_settings_fields($page, $section) {
  1327 function do_settings_fields($page, $section) {
  1164 	global $wp_settings_fields;
  1328 	global $wp_settings_fields;
  1165 
  1329 
  1166 	if ( ! isset( $wp_settings_fields[$page][$section] ) )
  1330 	if ( ! isset( $wp_settings_fields[$page][$section] ) )
  1167 		return;
  1331 		return;
  1168 
  1332 
  1169 	foreach ( (array) $wp_settings_fields[$page][$section] as $field ) {
  1333 	foreach ( (array) $wp_settings_fields[$page][$section] as $field ) {
  1170 		echo '<tr valign="top">';
  1334 		$class = '';
  1171 		if ( !empty($field['args']['label_for']) )
  1335 
       
  1336 		if ( ! empty( $field['args']['class'] ) ) {
       
  1337 			$class = ' class="' . esc_attr( $field['args']['class'] ) . '"';
       
  1338 		}
       
  1339 
       
  1340 		echo "<tr{$class}>";
       
  1341 
       
  1342 		if ( ! empty( $field['args']['label_for'] ) ) {
  1172 			echo '<th scope="row"><label for="' . esc_attr( $field['args']['label_for'] ) . '">' . $field['title'] . '</label></th>';
  1343 			echo '<th scope="row"><label for="' . esc_attr( $field['args']['label_for'] ) . '">' . $field['title'] . '</label></th>';
  1173 		else
  1344 		} else {
  1174 			echo '<th scope="row">' . $field['title'] . '</th>';
  1345 			echo '<th scope="row">' . $field['title'] . '</th>';
       
  1346 		}
       
  1347 
  1175 		echo '<td>';
  1348 		echo '<td>';
  1176 		call_user_func($field['callback'], $field['args']);
  1349 		call_user_func($field['callback'], $field['args']);
  1177 		echo '</td>';
  1350 		echo '</td>';
  1178 		echo '</tr>';
  1351 		echo '</tr>';
  1179 	}
  1352 	}
  1195  * @since 3.0.0
  1368  * @since 3.0.0
  1196  *
  1369  *
  1197  * @global array $wp_settings_errors Storage array of errors registered during this pageload
  1370  * @global array $wp_settings_errors Storage array of errors registered during this pageload
  1198  *
  1371  *
  1199  * @param string $setting Slug title of the setting to which this error applies
  1372  * @param string $setting Slug title of the setting to which this error applies
  1200  * @param string $code Slug-name to identify the error. Used as part of 'id' attribute in HTML output.
  1373  * @param string $code    Slug-name to identify the error. Used as part of 'id' attribute in HTML output.
  1201  * @param string $message The formatted message text to display to the user (will be shown inside styled <div> and <p>)
  1374  * @param string $message The formatted message text to display to the user (will be shown inside styled
  1202  * @param string $type The type of message it is, controls HTML class. Use 'error' or 'updated'.
  1375  *                        `<div>` and `<p>` tags).
       
  1376  * @param string $type    Optional. Message type, controls HTML class. Accepts 'error' or 'updated'.
       
  1377  *                        Default 'error'.
  1203  */
  1378  */
  1204 function add_settings_error( $setting, $code, $message, $type = 'error' ) {
  1379 function add_settings_error( $setting, $code, $message, $type = 'error' ) {
  1205 	global $wp_settings_errors;
  1380 	global $wp_settings_errors;
  1206 
  1381 
  1207 	$new_error = array(
  1382 	$wp_settings_errors[] = array(
  1208 		'setting' => $setting,
  1383 		'setting' => $setting,
  1209 		'code' => $code,
  1384 		'code'    => $code,
  1210 		'message' => $message,
  1385 		'message' => $message,
  1211 		'type' => $type
  1386 		'type'    => $type
  1212 	);
  1387 	);
  1213 	$wp_settings_errors[] = $new_error;
       
  1214 }
  1388 }
  1215 
  1389 
  1216 /**
  1390 /**
  1217  * Fetch settings errors registered by add_settings_error()
  1391  * Fetch settings errors registered by add_settings_error()
  1218  *
  1392  *
  1236  * @return array Array of settings errors
  1410  * @return array Array of settings errors
  1237  */
  1411  */
  1238 function get_settings_errors( $setting = '', $sanitize = false ) {
  1412 function get_settings_errors( $setting = '', $sanitize = false ) {
  1239 	global $wp_settings_errors;
  1413 	global $wp_settings_errors;
  1240 
  1414 
  1241 	// If $sanitize is true, manually re-run the sanitization for this option
  1415 	/*
  1242 	// This allows the $sanitize_callback from register_setting() to run, adding
  1416 	 * If $sanitize is true, manually re-run the sanitization for this option
  1243 	// any settings errors you want to show by default.
  1417 	 * This allows the $sanitize_callback from register_setting() to run, adding
       
  1418 	 * any settings errors you want to show by default.
       
  1419 	 */
  1244 	if ( $sanitize )
  1420 	if ( $sanitize )
  1245 		sanitize_option( $setting, get_option( $setting ) );
  1421 		sanitize_option( $setting, get_option( $setting ) );
  1246 
  1422 
  1247 	// If settings were passed back from options.php then use them
  1423 	// If settings were passed back from options.php then use them.
  1248 	if ( isset( $_GET['settings-updated'] ) && $_GET['settings-updated'] && get_transient( 'settings_errors' ) ) {
  1424 	if ( isset( $_GET['settings-updated'] ) && $_GET['settings-updated'] && get_transient( 'settings_errors' ) ) {
  1249 		$wp_settings_errors = array_merge( (array) $wp_settings_errors, get_transient( 'settings_errors' ) );
  1425 		$wp_settings_errors = array_merge( (array) $wp_settings_errors, get_transient( 'settings_errors' ) );
  1250 		delete_transient( 'settings_errors' );
  1426 		delete_transient( 'settings_errors' );
  1251 	}
  1427 	}
  1252 
  1428 
  1253 	// Check global in case errors have been added on this pageload
  1429 	// Check global in case errors have been added on this pageload.
  1254 	if ( ! count( $wp_settings_errors ) )
  1430 	if ( ! count( $wp_settings_errors ) )
  1255 		return array();
  1431 		return array();
  1256 
  1432 
  1257 	// Filter the results to those of a specific setting if one was set
  1433 	// Filter the results to those of a specific setting if one was set.
  1258 	if ( $setting ) {
  1434 	if ( $setting ) {
  1259 		$setting_errors = array();
  1435 		$setting_errors = array();
  1260 		foreach ( (array) $wp_settings_errors as $key => $details ) {
  1436 		foreach ( (array) $wp_settings_errors as $key => $details ) {
  1261 			if ( $setting == $details['setting'] )
  1437 			if ( $setting == $details['setting'] )
  1262 				$setting_errors[] = $wp_settings_errors[$key];
  1438 				$setting_errors[] = $wp_settings_errors[$key];
  1266 
  1442 
  1267 	return $wp_settings_errors;
  1443 	return $wp_settings_errors;
  1268 }
  1444 }
  1269 
  1445 
  1270 /**
  1446 /**
  1271  * Display settings errors registered by add_settings_error()
  1447  * Display settings errors registered by {@see add_settings_error()}.
  1272  *
  1448  *
  1273  * Part of the Settings API. Outputs a <div> for each error retrieved by get_settings_errors().
  1449  * Part of the Settings API. Outputs a div for each error retrieved by
  1274  *
  1450  * {@see get_settings_errors()}.
  1275  * This is called automatically after a settings page based on the Settings API is submitted.
  1451  *
  1276  * Errors should be added during the validation callback function for a setting defined in register_setting()
  1452  * This is called automatically after a settings page based on the
  1277  *
  1453  * Settings API is submitted. Errors should be added during the validation
  1278  * The $sanitize option is passed into get_settings_errors() and will re-run the setting sanitization
  1454  * callback function for a setting defined in {@see register_setting()}
       
  1455  *
       
  1456  * The $sanitize option is passed into {@see get_settings_errors()} and will
       
  1457  * re-run the setting sanitization
  1279  * on its current value.
  1458  * on its current value.
  1280  *
  1459  *
  1281  * The $hide_on_update option will cause errors to only show when the settings page is first loaded.
  1460  * The $hide_on_update option will cause errors to only show when the settings
  1282  * if the user has already saved new values it will be hidden to avoid repeating messages already
  1461  * page is first loaded. if the user has already saved new values it will be
  1283  * shown in the default error reporting after submission. This is useful to show general errors like missing
  1462  * hidden to avoid repeating messages already shown in the default error
  1284  * settings when the user arrives at the settings page.
  1463  * reporting after submission. This is useful to show general errors like
       
  1464  * missing settings when the user arrives at the settings page.
  1285  *
  1465  *
  1286  * @since 3.0.0
  1466  * @since 3.0.0
  1287  *
  1467  *
  1288  * @param string $setting Optional slug title of a specific setting who's errors you want.
  1468  * @param string $setting Optional slug title of a specific setting who's errors you want.
  1289  * @param boolean $sanitize Whether to re-sanitize the setting value before returning errors.
  1469  * @param boolean $sanitize Whether to re-sanitize the setting value before returning errors.
  1300 		return;
  1480 		return;
  1301 
  1481 
  1302 	$output = '';
  1482 	$output = '';
  1303 	foreach ( $settings_errors as $key => $details ) {
  1483 	foreach ( $settings_errors as $key => $details ) {
  1304 		$css_id = 'setting-error-' . $details['code'];
  1484 		$css_id = 'setting-error-' . $details['code'];
  1305 		$css_class = $details['type'] . ' settings-error';
  1485 		$css_class = $details['type'] . ' settings-error notice is-dismissible';
  1306 		$output .= "<div id='$css_id' class='$css_class'> \n";
  1486 		$output .= "<div id='$css_id' class='$css_class'> \n";
  1307 		$output .= "<p><strong>{$details['message']}</strong></p>";
  1487 		$output .= "<p><strong>{$details['message']}</strong></p>";
  1308 		$output .= "</div> \n";
  1488 		$output .= "</div> \n";
  1309 	}
  1489 	}
  1310 	echo $output;
  1490 	echo $output;
  1313 /**
  1493 /**
  1314  * {@internal Missing Short Description}}
  1494  * {@internal Missing Short Description}}
  1315  *
  1495  *
  1316  * @since 2.7.0
  1496  * @since 2.7.0
  1317  *
  1497  *
  1318  * @param unknown_type $found_action
  1498  * @param string $found_action
  1319  */
  1499  */
  1320 function find_posts_div($found_action = '') {
  1500 function find_posts_div($found_action = '') {
  1321 ?>
  1501 ?>
  1322 	<div id="find-posts" class="find-box" style="display:none;">
  1502 	<div id="find-posts" class="find-box" style="display: none;">
  1323 		<div id="find-posts-head" class="find-box-head"><?php _e('Find Posts or Pages'); ?></div>
  1503 		<div id="find-posts-head" class="find-box-head">
       
  1504 			<?php _e( 'Find Posts or Pages' ); ?>
       
  1505 			<div id="find-posts-close"></div>
       
  1506 		</div>
  1324 		<div class="find-box-inside">
  1507 		<div class="find-box-inside">
  1325 			<div class="find-box-search">
  1508 			<div class="find-box-search">
  1326 				<?php if ( $found_action ) { ?>
  1509 				<?php if ( $found_action ) { ?>
  1327 					<input type="hidden" name="found_action" value="<?php echo esc_attr($found_action); ?>" />
  1510 					<input type="hidden" name="found_action" value="<?php echo esc_attr($found_action); ?>" />
  1328 				<?php } ?>
  1511 				<?php } ?>
  1329 
       
  1330 				<input type="hidden" name="affected" id="affected" value="" />
  1512 				<input type="hidden" name="affected" id="affected" value="" />
  1331 				<?php wp_nonce_field( 'find-posts', '_ajax_nonce', false ); ?>
  1513 				<?php wp_nonce_field( 'find-posts', '_ajax_nonce', false ); ?>
  1332 				<label class="screen-reader-text" for="find-posts-input"><?php _e( 'Search' ); ?></label>
  1514 				<label class="screen-reader-text" for="find-posts-input"><?php _e( 'Search' ); ?></label>
  1333 				<input type="text" id="find-posts-input" name="ps" value="" />
  1515 				<input type="text" id="find-posts-input" name="ps" value="" />
  1334 				<span class="spinner"></span>
  1516 				<span class="spinner"></span>
  1335 				<input type="button" id="find-posts-search" value="<?php esc_attr_e( 'Search' ); ?>" class="button" />
  1517 				<input type="button" id="find-posts-search" value="<?php esc_attr_e( 'Search' ); ?>" class="button" />
       
  1518 				<div class="clear"></div>
  1336 			</div>
  1519 			</div>
  1337 			<div id="find-posts-response"></div>
  1520 			<div id="find-posts-response"></div>
  1338 		</div>
  1521 		</div>
  1339 		<div class="find-box-buttons">
  1522 		<div class="find-box-buttons">
  1340 			<input id="find-posts-close" type="button" class="button alignleft" value="<?php esc_attr_e('Close'); ?>" />
       
  1341 			<?php submit_button( __( 'Select' ), 'button-primary alignright', 'find-posts-submit', false ); ?>
  1523 			<?php submit_button( __( 'Select' ), 'button-primary alignright', 'find-posts-submit', false ); ?>
       
  1524 			<div class="clear"></div>
  1342 		</div>
  1525 		</div>
  1343 	</div>
  1526 	</div>
  1344 <?php
  1527 <?php
  1345 }
  1528 }
  1346 
  1529 
  1348  * Display the post password.
  1531  * Display the post password.
  1349  *
  1532  *
  1350  * The password is passed through {@link esc_attr()} to ensure that it
  1533  * The password is passed through {@link esc_attr()} to ensure that it
  1351  * is safe for placing in an html attribute.
  1534  * is safe for placing in an html attribute.
  1352  *
  1535  *
  1353  * @uses attr
       
  1354  * @since 2.7.0
  1536  * @since 2.7.0
  1355  */
  1537  */
  1356 function the_post_password() {
  1538 function the_post_password() {
  1357 	$post = get_post();
  1539 	$post = get_post();
  1358 	if ( isset( $post->post_password ) )
  1540 	if ( isset( $post->post_password ) )
  1364  *
  1546  *
  1365  * The post title is fetched and if it is blank then a default string is
  1547  * The post title is fetched and if it is blank then a default string is
  1366  * returned.
  1548  * returned.
  1367  *
  1549  *
  1368  * @since 2.7.0
  1550  * @since 2.7.0
  1369  * @param mixed $post Post id or object. If not supplied the global $post is used.
  1551  *
  1370  * @return string The post title if set
  1552  * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
       
  1553  * @return string The post title if set.
  1371  */
  1554  */
  1372 function _draft_or_post_title( $post = 0 ) {
  1555 function _draft_or_post_title( $post = 0 ) {
  1373 	$title = get_the_title( $post );
  1556 	$title = get_the_title( $post );
  1374 	if ( empty( $title ) )
  1557 	if ( empty( $title ) )
  1375 		$title = __( '(no title)' );
  1558 		$title = __( '(no title)' );
  1376 	return $title;
  1559 	return esc_html( $title );
  1377 }
  1560 }
  1378 
  1561 
  1379 /**
  1562 /**
  1380  * Display the search query.
  1563  * Display the search query.
  1381  *
  1564  *
  1382  * A simple wrapper to display the "s" parameter in a GET URI. This function
  1565  * A simple wrapper to display the "s" parameter in a GET URI. This function
  1383  * should only be used when {@link the_search_query()} cannot.
  1566  * should only be used when {@link the_search_query()} cannot.
  1384  *
  1567  *
  1385  * @uses attr
       
  1386  * @since 2.7.0
  1568  * @since 2.7.0
  1387  *
       
  1388  */
  1569  */
  1389 function _admin_search_query() {
  1570 function _admin_search_query() {
  1390 	echo isset($_REQUEST['s']) ? esc_attr( wp_unslash( $_REQUEST['s'] ) ) : '';
  1571 	echo isset($_REQUEST['s']) ? esc_attr( wp_unslash( $_REQUEST['s'] ) ) : '';
  1391 }
  1572 }
  1392 
  1573 
  1393 /**
  1574 /**
  1394  * Generic Iframe header for use with Thickbox
  1575  * Generic Iframe header for use with Thickbox
  1395  *
  1576  *
  1396  * @since 2.7.0
  1577  * @since 2.7.0
  1397  * @param string $title Title of the Iframe page.
  1578  *
  1398  * @param bool $limit_styles Limit styles to colour-related styles only (unless others are enqueued).
  1579  * @param string $title      Optional. Title of the Iframe page. Default empty.
  1399  *
  1580  * @param bool   $deprecated Not used.
  1400  */
  1581  */
  1401 function iframe_header( $title = '', $limit_styles = false ) {
  1582 function iframe_header( $title = '', $deprecated = false ) {
  1402 	show_admin_bar( false );
  1583 	show_admin_bar( false );
  1403 	global $hook_suffix, $current_user, $admin_body_class, $wp_locale;
  1584 	global $hook_suffix, $admin_body_class, $wp_locale;
  1404 	$admin_body_class = preg_replace('/[^a-z0-9_-]+/i', '-', $hook_suffix);
  1585 	$admin_body_class = preg_replace('/[^a-z0-9_-]+/i', '-', $hook_suffix);
  1405 
  1586 
  1406 	$current_screen = get_current_screen();
  1587 	$current_screen = get_current_screen();
  1407 
  1588 
  1408 	@header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
  1589 	@header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
  1411 <title><?php bloginfo('name') ?> &rsaquo; <?php echo $title ?> &#8212; <?php _e('WordPress'); ?></title>
  1592 <title><?php bloginfo('name') ?> &rsaquo; <?php echo $title ?> &#8212; <?php _e('WordPress'); ?></title>
  1412 <?php
  1593 <?php
  1413 wp_enqueue_style( 'colors' );
  1594 wp_enqueue_style( 'colors' );
  1414 ?>
  1595 ?>
  1415 <script type="text/javascript">
  1596 <script type="text/javascript">
  1416 //<![CDATA[
       
  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();}}};
  1597 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();}}};
  1418 function tb_close(){var win=window.dialogArguments||opener||parent||top;win.tb_remove();}
  1598 function tb_close(){var win=window.dialogArguments||opener||parent||top;win.tb_remove();}
  1419 var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>',
  1599 var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>',
  1420 	pagenow = '<?php echo $current_screen->id; ?>',
  1600 	pagenow = '<?php echo $current_screen->id; ?>',
  1421 	typenow = '<?php echo $current_screen->post_type; ?>',
  1601 	typenow = '<?php echo $current_screen->post_type; ?>',
  1422 	adminpage = '<?php echo $admin_body_class; ?>',
  1602 	adminpage = '<?php echo $admin_body_class; ?>',
  1423 	thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>',
  1603 	thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>',
  1424 	decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>',
  1604 	decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>',
  1425 	isRtl = <?php echo (int) is_rtl(); ?>;
  1605 	isRtl = <?php echo (int) is_rtl(); ?>;
  1426 //]]>
       
  1427 </script>
  1606 </script>
  1428 <?php
  1607 <?php
  1429 do_action('admin_enqueue_scripts', $hook_suffix);
  1608 /** This action is documented in wp-admin/admin-header.php */
  1430 do_action("admin_print_styles-$hook_suffix");
  1609 do_action( 'admin_enqueue_scripts', $hook_suffix );
  1431 do_action('admin_print_styles');
  1610 
  1432 do_action("admin_print_scripts-$hook_suffix");
  1611 /** This action is documented in wp-admin/admin-header.php */
  1433 do_action('admin_print_scripts');
  1612 do_action( "admin_print_styles-$hook_suffix" );
  1434 do_action("admin_head-$hook_suffix");
  1613 
  1435 do_action('admin_head');
  1614 /** This action is documented in wp-admin/admin-header.php */
       
  1615 do_action( 'admin_print_styles' );
       
  1616 
       
  1617 /** This action is documented in wp-admin/admin-header.php */
       
  1618 do_action( "admin_print_scripts-$hook_suffix" );
       
  1619 
       
  1620 /** This action is documented in wp-admin/admin-header.php */
       
  1621 do_action( 'admin_print_scripts' );
       
  1622 
       
  1623 /** This action is documented in wp-admin/admin-header.php */
       
  1624 do_action( "admin_head-$hook_suffix" );
       
  1625 
       
  1626 /** This action is documented in wp-admin/admin-header.php */
       
  1627 do_action( 'admin_head' );
  1436 
  1628 
  1437 $admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) );
  1629 $admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) );
  1438 
  1630 
  1439 if ( is_rtl() )
  1631 if ( is_rtl() )
  1440 	$admin_body_class .= ' rtl';
  1632 	$admin_body_class .= ' rtl';
  1441 
  1633 
  1442 ?>
  1634 ?>
  1443 </head>
  1635 </head>
  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; ?>">
  1636 <?php
       
  1637 /** This filter is documented in wp-admin/admin-header.php */
       
  1638 $admin_body_classes = apply_filters( 'admin_body_class', '' );
       
  1639 ?>
       
  1640 <body<?php if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?> class="wp-admin wp-core-ui no-js iframe <?php echo $admin_body_classes . ' ' . $admin_body_class; ?>">
  1445 <script type="text/javascript">
  1641 <script type="text/javascript">
  1446 //<![CDATA[
       
  1447 (function(){
  1642 (function(){
  1448 var c = document.body.className;
  1643 var c = document.body.className;
  1449 c = c.replace(/no-js/, 'js');
  1644 c = c.replace(/no-js/, 'js');
  1450 document.body.className = c;
  1645 document.body.className = c;
  1451 })();
  1646 })();
  1452 //]]>
       
  1453 </script>
  1647 </script>
  1454 <?php
  1648 <?php
  1455 }
  1649 }
  1456 
  1650 
  1457 /**
  1651 /**
  1458  * Generic Iframe footer for use with Thickbox
  1652  * Generic Iframe footer for use with Thickbox
  1459  *
  1653  *
  1460  * @since 2.7.0
  1654  * @since 2.7.0
  1461  *
       
  1462  */
  1655  */
  1463 function iframe_footer() {
  1656 function iframe_footer() {
  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. ?>
  1657 	/*
       
  1658 	 * We're going to hide any footer output on iFrame pages,
       
  1659 	 * but run the hooks anyway since they output JavaScript
       
  1660 	 * or other needed content.
       
  1661 	 */
       
  1662 	 ?>
  1465 	<div class="hidden">
  1663 	<div class="hidden">
  1466 <?php
  1664 <?php
  1467 	do_action('admin_footer', '');
  1665 	/** This action is documented in wp-admin/admin-footer.php */
  1468 	do_action('admin_print_footer_scripts'); ?>
  1666 	do_action( 'admin_footer', '' );
       
  1667 
       
  1668 	/** This action is documented in wp-admin/admin-footer.php */
       
  1669 	do_action( 'admin_print_footer_scripts' );
       
  1670 ?>
  1469 	</div>
  1671 	</div>
  1470 <script type="text/javascript">if(typeof wpOnload=="function")wpOnload();</script>
  1672 <script type="text/javascript">if(typeof wpOnload=="function")wpOnload();</script>
  1471 </body>
  1673 </body>
  1472 </html>
  1674 </html>
  1473 <?php
  1675 <?php
  1490 		/* translators: post state */
  1692 		/* translators: post state */
  1491 		$post_states['pending'] = _x('Pending', 'post state');
  1693 		$post_states['pending'] = _x('Pending', 'post state');
  1492 	if ( is_sticky($post->ID) )
  1694 	if ( is_sticky($post->ID) )
  1493 		$post_states['sticky'] = __('Sticky');
  1695 		$post_states['sticky'] = __('Sticky');
  1494 
  1696 
       
  1697 	if ( get_option( 'page_on_front' ) == $post->ID ) {
       
  1698 		$post_states['page_on_front'] = __( 'Front Page' );
       
  1699 	}
       
  1700 
       
  1701 	if ( get_option( 'page_for_posts' ) == $post->ID ) {
       
  1702 		$post_states['page_for_posts'] = __( 'Posts Page' );
       
  1703 	}
       
  1704 
       
  1705 	/**
       
  1706 	 * Filter the default post display states used in the posts list table.
       
  1707 	 *
       
  1708 	 * @since 2.8.0
       
  1709 	 *
       
  1710 	 * @param array $post_states An array of post display states.
       
  1711 	 * @param int   $post        The post ID.
       
  1712 	 */
  1495 	$post_states = apply_filters( 'display_post_states', $post_states, $post );
  1713 	$post_states = apply_filters( 'display_post_states', $post_states, $post );
  1496 
  1714 
  1497 	if ( ! empty($post_states) ) {
  1715 	if ( ! empty($post_states) ) {
  1498 		$state_count = count($post_states);
  1716 		$state_count = count($post_states);
  1499 		$i = 0;
  1717 		$i = 0;
  1521 		$meta_background = get_post_meta($post->ID, '_wp_attachment_is_custom_background', true );
  1739 		$meta_background = get_post_meta($post->ID, '_wp_attachment_is_custom_background', true );
  1522 		if ( ! empty( $meta_background ) && $meta_background == $stylesheet )
  1740 		if ( ! empty( $meta_background ) && $meta_background == $stylesheet )
  1523 			$media_states[] = __( 'Background Image' );
  1741 			$media_states[] = __( 'Background Image' );
  1524 	}
  1742 	}
  1525 
  1743 
       
  1744 	/**
       
  1745 	 * Filter the default media display states for items in the Media list table.
       
  1746 	 *
       
  1747 	 * @since 3.2.0
       
  1748 	 *
       
  1749 	 * @param array $media_states An array of media states. Default 'Header Image',
       
  1750 	 *                            'Background Image'.
       
  1751 	 */
  1526 	$media_states = apply_filters( 'display_media_states', $media_states );
  1752 	$media_states = apply_filters( 'display_media_states', $media_states );
  1527 
  1753 
  1528 	if ( ! empty( $media_states ) ) {
  1754 	if ( ! empty( $media_states ) ) {
  1529 		$state_count = count( $media_states );
  1755 		$state_count = count( $media_states );
  1530 		$i = 0;
  1756 		$i = 0;
  1548  * @since 2.8.0
  1774  * @since 2.8.0
  1549  */
  1775  */
  1550 function compression_test() {
  1776 function compression_test() {
  1551 ?>
  1777 ?>
  1552 	<script type="text/javascript">
  1778 	<script type="text/javascript">
  1553 	/* <![CDATA[ */
       
  1554 	var testCompression = {
  1779 	var testCompression = {
  1555 		get : function(test) {
  1780 		get : function(test) {
  1556 			var x;
  1781 			var x;
  1557 			if ( window.XMLHttpRequest ) {
  1782 			if ( window.XMLHttpRequest ) {
  1558 				x = new XMLHttpRequest();
  1783 				x = new XMLHttpRequest();
  1566 					if ( x.readyState == 4 ) {
  1791 					if ( x.readyState == 4 ) {
  1567 						r = x.responseText.substr(0, 18);
  1792 						r = x.responseText.substr(0, 18);
  1568 						h = x.getResponseHeader('Content-Encoding');
  1793 						h = x.getResponseHeader('Content-Encoding');
  1569 						testCompression.check(r, h, test);
  1794 						testCompression.check(r, h, test);
  1570 					}
  1795 					}
  1571 				}
  1796 				};
  1572 
  1797 
  1573 				x.open('GET', ajaxurl + '?action=wp-compression-test&test='+test+'&'+(new Date()).getTime(), true);
  1798 				x.open('GET', ajaxurl + '?action=wp-compression-test&test='+test+'&'+(new Date()).getTime(), true);
  1574 				x.send('');
  1799 				x.send('');
  1575 			}
  1800 			}
  1576 		},
  1801 		},
  1595 					this.get('no');
  1820 					this.get('no');
  1596 			}
  1821 			}
  1597 		}
  1822 		}
  1598 	};
  1823 	};
  1599 	testCompression.check();
  1824 	testCompression.check();
  1600 	/* ]]> */
       
  1601 	</script>
  1825 	</script>
  1602 <?php
  1826 <?php
  1603 }
  1827 }
  1604 
  1828 
  1605 /**
  1829 /**
  1606  * Echos a submit button, with provided text and appropriate class
  1830  * Echoes a submit button, with provided text and appropriate class(es).
  1607  *
  1831  *
  1608  * @since 3.1.0
  1832  * @since 3.1.0
  1609  *
  1833  *
  1610  * @param string $text The text of the button (defaults to 'Save Changes')
  1834  * @see get_submit_button()
  1611  * @param string $type The type of button. One of: primary, secondary, delete
  1835  *
  1612  * @param string $name The HTML name of the submit button. Defaults to "submit". If no id attribute
  1836  * @param string       $text             The text of the button (defaults to 'Save Changes')
  1613  *               is given in $other_attributes below, $name will be used as the button's id.
  1837  * @param string       $type             Optional. The type and CSS class(es) of the button. Core values
  1614  * @param bool $wrap True if the output button should be wrapped in a paragraph tag,
  1838  *                                       include 'primary', 'secondary', 'delete'. Default 'primary'
  1615  * 			   false otherwise. Defaults to true
  1839  * @param string       $name             The HTML name of the submit button. Defaults to "submit". If no
  1616  * @param array|string $other_attributes Other attributes that should be output with the button,
  1840  *                                       id attribute is given in $other_attributes below, $name will be
  1617  *                     mapping attributes to their values, such as array( 'tabindex' => '1' ).
  1841  *                                       used as the button's id.
  1618  *                     These attributes will be output as attribute="value", such as tabindex="1".
  1842  * @param bool         $wrap             True if the output button should be wrapped in a paragraph tag,
  1619  *                     Defaults to no other attributes. Other attributes can also be provided as a
  1843  *                                       false otherwise. Defaults to true
  1620  *                     string such as 'tabindex="1"', though the array format is typically cleaner.
  1844  * @param array|string $other_attributes Other attributes that should be output with the button, mapping
       
  1845  *                                       attributes to their values, such as setting tabindex to 1, etc.
       
  1846  *                                       These key/value attribute pairs will be output as attribute="value",
       
  1847  *                                       where attribute is the key. Other attributes can also be provided
       
  1848  *                                       as a string such as 'tabindex="1"', though the array format is
       
  1849  *                                       preferred. Default null.
  1621  */
  1850  */
  1622 function submit_button( $text = null, $type = 'primary', $name = 'submit', $wrap = true, $other_attributes = null ) {
  1851 function submit_button( $text = null, $type = 'primary', $name = 'submit', $wrap = true, $other_attributes = null ) {
  1623 	echo get_submit_button( $text, $type, $name, $wrap, $other_attributes );
  1852 	echo get_submit_button( $text, $type, $name, $wrap, $other_attributes );
  1624 }
  1853 }
  1625 
  1854 
  1626 /**
  1855 /**
  1627  * Returns a submit button, with provided text and appropriate class
  1856  * Returns a submit button, with provided text and appropriate class
  1628  *
  1857  *
  1629  * @since 3.1.0
  1858  * @since 3.1.0
  1630  *
  1859  *
  1631  * @param string $text The text of the button (defaults to 'Save Changes')
  1860  * @param string       $text             Optional. The text of the button. Default 'Save Changes'.
  1632  * @param string $type The type of button. One of: primary, secondary, delete
  1861  * @param string       $type             Optional. The type of button. Accepts 'primary', 'secondary',
  1633  * @param string $name The HTML name of the submit button. Defaults to "submit". If no id attribute
  1862  *                                       or 'delete'. Default 'primary large'.
  1634  *               is given in $other_attributes below, $name will be used as the button's id.
  1863  * @param string       $name             Optional. The HTML name of the submit button. Defaults to "submit".
  1635  * @param bool $wrap True if the output button should be wrapped in a paragraph tag,
  1864  *                                       If no id attribute is given in $other_attributes below, `$name` will
  1636  * 			   false otherwise. Defaults to true
  1865  *                                       be used as the button's id. Default 'submit'.
  1637  * @param array|string $other_attributes Other attributes that should be output with the button,
  1866  * @param bool         $wrap             Optional. True if the output button should be wrapped in a paragraph
  1638  *                     mapping attributes to their values, such as array( 'tabindex' => '1' ).
  1867  *                                       tag, false otherwise. Default true.
  1639  *                     These attributes will be output as attribute="value", such as tabindex="1".
  1868  * @param array|string $other_attributes Optional. Other attributes that should be output with the button,
  1640  *                     Defaults to no other attributes. Other attributes can also be provided as a
  1869  *                                       mapping attributes to their values, such as `array( 'tabindex' => '1' )`.
  1641  *                     string such as 'tabindex="1"', though the array format is typically cleaner.
  1870  *                                       These attributes will be output as `attribute="value"`, such as
  1642  */
  1871  *                                       `tabindex="1"`. Other attributes can also be provided as a string such
  1643 function get_submit_button( $text = null, $type = 'primary large', $name = 'submit', $wrap = true, $other_attributes = null ) {
  1872  *                                       as `tabindex="1"`, though the array format is typically cleaner.
       
  1873  *                                       Default empty.
       
  1874  * @return string Submit button HTML.
       
  1875  */
       
  1876 function get_submit_button( $text = '', $type = 'primary large', $name = 'submit', $wrap = true, $other_attributes = '' ) {
  1644 	if ( ! is_array( $type ) )
  1877 	if ( ! is_array( $type ) )
  1645 		$type = explode( ' ', $type );
  1878 		$type = explode( ' ', $type );
  1646 
  1879 
  1647 	$button_shorthand = array( 'primary', 'small', 'large' );
  1880 	$button_shorthand = array( 'primary', 'small', 'large' );
  1648 	$classes = array( 'button' );
  1881 	$classes = array( 'button' );
  1668 	$attributes = '';
  1901 	$attributes = '';
  1669 	if ( is_array( $other_attributes ) ) {
  1902 	if ( is_array( $other_attributes ) ) {
  1670 		foreach ( $other_attributes as $attribute => $value ) {
  1903 		foreach ( $other_attributes as $attribute => $value ) {
  1671 			$attributes .= $attribute . '="' . esc_attr( $value ) . '" '; // Trailing space is important
  1904 			$attributes .= $attribute . '="' . esc_attr( $value ) . '" '; // Trailing space is important
  1672 		}
  1905 		}
  1673 	} else if ( !empty( $other_attributes ) ) { // Attributes provided as a string
  1906 	} elseif ( ! empty( $other_attributes ) ) { // Attributes provided as a string
  1674 		$attributes = $other_attributes;
  1907 		$attributes = $other_attributes;
  1675 	}
  1908 	}
  1676 
  1909 
  1677 	$button = '<input type="submit" name="' . esc_attr( $name ) . '" id="' . esc_attr( $id ) . '" class="' . esc_attr( $class );
  1910 	// Don't output empty name and id attributes.
       
  1911 	$name_attr = $name ? ' name="' . esc_attr( $name ) . '"' : '';
       
  1912 	$id_attr = $id ? ' id="' . esc_attr( $id ) . '"' : '';
       
  1913 
       
  1914 	$button = '<input type="submit"' . $name_attr . $id_attr . ' class="' . esc_attr( $class );
  1678 	$button	.= '" value="' . esc_attr( $text ) . '" ' . $attributes . ' />';
  1915 	$button	.= '" value="' . esc_attr( $text ) . '" ' . $attributes . ' />';
  1679 
  1916 
  1680 	if ( $wrap ) {
  1917 	if ( $wrap ) {
  1681 		$button = '<p class="submit">' . $button . '</p>';
  1918 		$button = '<p class="submit">' . $button . '</p>';
  1682 	}
  1919 	}
  1683 
  1920 
  1684 	return $button;
  1921 	return $button;
  1685 }
  1922 }
  1686 
  1923 
  1687 function _wp_admin_html_begin() {
  1924 function _wp_admin_html_begin() {
       
  1925 	global $is_IE;
       
  1926 
  1688 	$admin_html_class = ( is_admin_bar_showing() ) ? 'wp-toolbar' : '';
  1927 	$admin_html_class = ( is_admin_bar_showing() ) ? 'wp-toolbar' : '';
       
  1928 
       
  1929 	if ( $is_IE )
       
  1930 		@header('X-UA-Compatible: IE=edge');
       
  1931 
  1689 ?>
  1932 ?>
  1690 <!DOCTYPE html>
  1933 <!DOCTYPE html>
  1691 <!--[if IE 8]>
  1934 <!--[if IE 8]>
  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(); ?>>
  1935 <html xmlns="http://www.w3.org/1999/xhtml" class="ie8 <?php echo $admin_html_class; ?>" <?php
       
  1936 	/**
       
  1937 	 * Fires inside the HTML tag in the admin header.
       
  1938 	 *
       
  1939 	 * @since 2.2.0
       
  1940 	 */
       
  1941 	do_action( 'admin_xml_ns' );
       
  1942 ?> <?php language_attributes(); ?>>
  1693 <![endif]-->
  1943 <![endif]-->
  1694 <!--[if !(IE 8) ]><!-->
  1944 <!--[if !(IE 8) ]><!-->
  1695 <html xmlns="http://www.w3.org/1999/xhtml" class="<?php echo $admin_html_class; ?>" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>>
  1945 <html xmlns="http://www.w3.org/1999/xhtml" class="<?php echo $admin_html_class; ?>" <?php
       
  1946 	/** This action is documented in wp-admin/includes/template.php */
       
  1947 	do_action( 'admin_xml_ns' );
       
  1948 ?> <?php language_attributes(); ?>>
  1696 <!--<![endif]-->
  1949 <!--<![endif]-->
  1697 <head>
  1950 <head>
  1698 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
  1951 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
  1699 <?php
  1952 <?php
  1700 }
  1953 }
  1706 	 * @since 3.3.0
  1959 	 * @since 3.3.0
  1707 	 *
  1960 	 *
  1708 	 * All pointers can be disabled using the following:
  1961 	 * All pointers can be disabled using the following:
  1709 	 *     remove_action( 'admin_enqueue_scripts', array( 'WP_Internal_Pointers', 'enqueue_scripts' ) );
  1962 	 *     remove_action( 'admin_enqueue_scripts', array( 'WP_Internal_Pointers', 'enqueue_scripts' ) );
  1710 	 *
  1963 	 *
  1711 	 * Individual pointers (e.g. wp330_toolbar) can be disabled using the following:
  1964 	 * Individual pointers (e.g. wp390_widgets) can be disabled using the following:
  1712 	 *     remove_action( 'admin_print_footer_scripts', array( 'WP_Internal_Pointers', 'pointer_wp330_toolbar' ) );
  1965 	 *     remove_action( 'admin_print_footer_scripts', array( 'WP_Internal_Pointers', 'pointer_wp390_widgets' ) );
       
  1966 	 *
       
  1967 	 * @param string $hook_suffix The current admin page.
  1713 	 */
  1968 	 */
  1714 	public static function enqueue_scripts( $hook_suffix ) {
  1969 	public static function enqueue_scripts( $hook_suffix ) {
  1715 		/*
  1970 		/*
  1716 		 * Register feature pointers
  1971 		 * Register feature pointers
  1717 		 * Format: array( hook_suffix => pointer_id )
  1972 		 * Format: array( hook_suffix => pointer_id )
  1718 		 */
  1973 		 */
  1719 
  1974 
  1720 		$registered_pointers = array(
  1975 		$registered_pointers = array(
  1721 			'index.php'    => 'wp330_toolbar',
  1976 			'post-new.php' => 'wp410_dfw',
  1722 			'post-new.php' => 'wp350_media',
  1977 			'post.php'     => 'wp410_dfw',
  1723 			'post.php'     => array( 'wp350_media', 'wp360_revisions' ),
       
  1724 			'edit.php'     => 'wp360_locks',
  1978 			'edit.php'     => 'wp360_locks',
  1725 			'themes.php'   => array( 'wp330_saving_widgets', 'wp340_customize_current_theme_link' ),
  1979 			'widgets.php'  => 'wp390_widgets',
  1726 			'appearance_page_custom-header' => 'wp340_choose_image_from_library',
  1980 			'themes.php'   => 'wp390_widgets',
  1727 			'appearance_page_custom-background' => 'wp340_choose_image_from_library',
       
  1728 		);
  1981 		);
  1729 
  1982 
  1730 		// Check if screen related pointer is registered
  1983 		// Check if screen related pointer is registered
  1731 		if ( empty( $registered_pointers[ $hook_suffix ] ) )
  1984 		if ( empty( $registered_pointers[ $hook_suffix ] ) )
  1732 			return;
  1985 			return;
  1733 
  1986 
  1734 		$pointers = (array) $registered_pointers[ $hook_suffix ];
  1987 		$pointers = (array) $registered_pointers[ $hook_suffix ];
  1735 
  1988 
  1736 		$caps_required = array(
  1989 		$caps_required = array(
  1737 			'wp330_saving_widgets' => array( 'edit_theme_options', 'switch_themes' ),
  1990 			'wp390_widgets' => array( 'edit_theme_options' ),
  1738 			'wp340_customize_current_theme_link' => array( 'edit_theme_options' ),
       
  1739 			'wp340_choose_image_from_library' => array( 'edit_theme_options' ),
       
  1740 			'wp350_media' => array( 'upload_files' ),
       
  1741 		);
  1991 		);
  1742 
  1992 
  1743 		// Get dismissed pointers
  1993 		// Get dismissed pointers
  1744 		$dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
  1994 		$dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
  1745 
  1995 
  1764 		wp_enqueue_style( 'wp-pointer' );
  2014 		wp_enqueue_style( 'wp-pointer' );
  1765 		wp_enqueue_script( 'wp-pointer' );
  2015 		wp_enqueue_script( 'wp-pointer' );
  1766 	}
  2016 	}
  1767 
  2017 
  1768 	/**
  2018 	/**
  1769 	 * Print the pointer javascript data.
  2019 	 * Print the pointer JavaScript data.
  1770 	 *
  2020 	 *
  1771 	 * @since 3.3.0
  2021 	 * @since 3.3.0
  1772 	 *
  2022 	 *
  1773 	 * @param string $pointer_id The pointer ID.
  2023 	 * @param string $pointer_id The pointer ID.
  1774 	 * @param string $selector The HTML elements, on which the pointer should be attached.
  2024 	 * @param string $selector The HTML elements, on which the pointer should be attached.
  1778 		if ( empty( $pointer_id ) || empty( $selector ) || empty( $args ) || empty( $args['content'] ) )
  2028 		if ( empty( $pointer_id ) || empty( $selector ) || empty( $args ) || empty( $args['content'] ) )
  1779 			return;
  2029 			return;
  1780 
  2030 
  1781 		?>
  2031 		?>
  1782 		<script type="text/javascript">
  2032 		<script type="text/javascript">
  1783 		//<![CDATA[
       
  1784 		(function($){
  2033 		(function($){
  1785 			var options = <?php echo json_encode( $args ); ?>, setup;
  2034 			var options = <?php echo wp_json_encode( $args ); ?>, setup;
  1786 
  2035 
  1787 			if ( ! options )
  2036 			if ( ! options )
  1788 				return;
  2037 				return;
  1789 
  2038 
  1790 			options = $.extend( options, {
  2039 			options = $.extend( options, {
  1804 				$(window).bind( 'load.wp-pointers', setup );
  2053 				$(window).bind( 'load.wp-pointers', setup );
  1805 			else
  2054 			else
  1806 				$(document).ready( setup );
  2055 				$(document).ready( setup );
  1807 
  2056 
  1808 		})( jQuery );
  2057 		})( jQuery );
  1809 		//]]>
       
  1810 		</script>
  2058 		</script>
  1811 		<?php
  2059 		<?php
  1812 	}
  2060 	}
  1813 
  2061 
  1814 	public static function pointer_wp330_toolbar() {
  2062 	public static function pointer_wp330_toolbar() {}
  1815 		$content  = '<h3>' . __( 'New Feature: Toolbar' ) . '</h3>';
       
  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>';
       
  1817 
       
  1818 		if ( is_multisite() && is_super_admin() )
       
  1819 			$content .= '<p>' . __( 'Network Admin is now located in the My Sites menu.' ) . '</p>';
       
  1820 
       
  1821 		WP_Internal_Pointers::print_js( 'wp330_toolbar', '#wpadminbar', array(
       
  1822 			'content'  => $content,
       
  1823 			'position' => array( 'edge' => 'top', 'align' => 'center' ),
       
  1824 		) );
       
  1825 	}
       
  1826 
       
  1827 	/**
       
  1828 	 * Print 'Updated Media Uploader' for 3.3.0.
       
  1829 	 *
       
  1830 	 * @since 3.3.0
       
  1831 	 */
       
  1832 	public static function pointer_wp330_media_uploader() {}
  2063 	public static function pointer_wp330_media_uploader() {}
  1833 
  2064 	public static function pointer_wp330_saving_widgets() {}
  1834 	/**
  2065 	public static function pointer_wp340_customize_current_theme_link() {}
  1835 	 * Print 'New Feature: Saving Widgets' for 3.3.0.
  2066 	public static function pointer_wp340_choose_image_from_library() {}
  1836 	 *
  2067 	public static function pointer_wp350_media() {}
  1837 	 * @since 3.3.0
  2068 	public static function pointer_wp360_revisions() {}
  1838 	 */
       
  1839 	public static function pointer_wp330_saving_widgets() {
       
  1840 		$content  = '<h3>' . __( 'New Feature: Saving Widgets' ) . '</h3>';
       
  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>';
       
  1842 
       
  1843 		WP_Internal_Pointers::print_js( 'wp330_saving_widgets', '#message2', array(
       
  1844 			'content'  => $content,
       
  1845 			'position' => array( 'edge' => 'top', 'align' => is_rtl() ? 'right' : 'left' ),
       
  1846 		) );
       
  1847 	}
       
  1848 
       
  1849 	/**
       
  1850 	 * Print 'New Feature: Current Theme Customize Link' for 3.4.0.
       
  1851 	 *
       
  1852 	 * @since 3.4.0
       
  1853 	 */
       
  1854 	public static function pointer_wp340_customize_current_theme_link() {
       
  1855 		$content  = '<h3>' . __( 'New Feature: Customizer' ) . '</h3>';
       
  1856 		$content .= '<p>' . __( 'Click Customize to change the header, background, title and menus of the current theme, all in one place.' ) . '</p>';
       
  1857 		$content .= '<p>' . __( 'Click the Live Preview links in the Available Themes list below to customize and preview another theme before activating it.' ) . '</p>';
       
  1858 
       
  1859 		WP_Internal_Pointers::print_js( 'wp340_customize_current_theme_link', '#customize-current-theme-link', array(
       
  1860 			'content'  => $content,
       
  1861 			'position' => array( 'edge' => 'top', 'align' => is_rtl() ? 'right' : 'left', 'offset' => is_rtl() ? '32 0' : '-32 0' ),
       
  1862 		) );
       
  1863 	}
       
  1864 
       
  1865 	/**
       
  1866 	 * Print 'New Feature: Choose Image from Library' for 3.4.0.
       
  1867 	 *
       
  1868 	 * @since 3.4.0
       
  1869 	 */
       
  1870 	public static function pointer_wp340_choose_image_from_library() {
       
  1871 		$content  = '<h3>' . __( 'New Feature: Choose Image from Library' ) . '</h3>';
       
  1872 		$content .= '<p>' . __( 'Want to use an image you uploaded earlier? Select it from your media library instead of uploading it again.' ) . '</p>';
       
  1873 
       
  1874 		WP_Internal_Pointers::print_js( 'wp340_choose_image_from_library', '#choose-from-library-link', array(
       
  1875 			'content'  => $content,
       
  1876 			'position' => array( 'edge' => 'top', 'align' => is_rtl() ? 'right' : 'left', 'defer_loading' => true ),
       
  1877 		) );
       
  1878 	}
       
  1879 
       
  1880 	public static function pointer_wp350_media() {
       
  1881 		$content  = '<h3>' . __( 'New Media Manager' ) . '</h3>';
       
  1882 		$content .= '<p>' . __( 'Uploading files and creating image galleries has a whole new look. Check it out!' ) . '</p>';
       
  1883 
       
  1884 		self::print_js( 'wp350_media', '.insert-media', array(
       
  1885 			'content'  => $content,
       
  1886 			'position' => array( 'edge' => is_rtl() ? 'right' : 'left', 'align' => 'center' ),
       
  1887 		) );
       
  1888 	}
       
  1889 
       
  1890 	public static function pointer_wp360_revisions() {
       
  1891 		$content  = '<h3>' . __( 'Compare Revisions' ) . '</h3>';
       
  1892 		$content .= '<p>' . __( 'View, compare, and restore other versions of this content on the improved revisions screen.' ) . '</p>';
       
  1893 
       
  1894 		self::print_js( 'wp360_revisions', '.misc-pub-section.misc-pub-revisions', array(
       
  1895 			'content' => $content,
       
  1896 			'position' => array( 'edge' => is_rtl() ? 'left' : 'right', 'align' => 'center', 'my' => is_rtl() ? 'left' : 'right-14px' ),
       
  1897 		) );
       
  1898 	}
       
  1899 
  2069 
  1900 	public static function pointer_wp360_locks() {
  2070 	public static function pointer_wp360_locks() {
       
  2071 		if ( ! is_multi_author() ) {
       
  2072 			return;
       
  2073 		}
       
  2074 
  1901 		$content  = '<h3>' . __( 'Edit Lock' ) . '</h3>';
  2075 		$content  = '<h3>' . __( 'Edit Lock' ) . '</h3>';
  1902 		$content .= '<p>' . __( 'Someone else is editing this. No need to refresh; the lock will disappear when they&#8217;re done.' ) . '</p>';
  2076 		$content .= '<p>' . __( 'Someone else is editing this. No need to refresh; the lock will disappear when they&#8217;re done.' ) . '</p>';
  1903 
       
  1904 		if ( ! is_multi_author() )
       
  1905 			return;
       
  1906 
  2077 
  1907 		self::print_js( 'wp360_locks', 'tr.wp-locked .locked-indicator', array(
  2078 		self::print_js( 'wp360_locks', 'tr.wp-locked .locked-indicator', array(
  1908 			'content' => $content,
  2079 			'content' => $content,
  1909 			'position' => array( 'edge' => 'left', 'align' => 'left' ),
  2080 			'position' => array( 'edge' => 'left', 'align' => 'left' ),
  1910 		) );
  2081 		) );
  1911 	}
  2082 	}
  1912 
  2083 
       
  2084 	public static function pointer_wp390_widgets() {
       
  2085 		if ( ! current_theme_supports( 'widgets' ) ) {
       
  2086 			return;
       
  2087 		}
       
  2088 
       
  2089 		$content  = '<h3>' . __( 'New Feature: Live Widget Previews' ) . '</h3>';
       
  2090 		$content .= '<p>' . __( 'Add, edit, and play around with your widgets from the Customizer.' ) . ' ' . __( 'Preview your changes in real-time and only save them when you&#8217;re ready.' ) . '</p>';
       
  2091 
       
  2092 		if ( 'themes' === get_current_screen()->id ) {
       
  2093 			$selector = '.theme.active .customize';
       
  2094 			$position = array( 'edge' => is_rtl() ? 'right' : 'left', 'align' => 'center' );
       
  2095 		} else {
       
  2096 			$selector = 'a[href^="customize.php"]';
       
  2097 			if ( is_rtl() ) {
       
  2098 				$position = array( 'edge' => 'right', 'align' => 'center', 'my' => 'right-5px' );
       
  2099 			} else {
       
  2100 				$position = array( 'edge' => 'left', 'align' => 'center', 'my' => 'left-5px' );
       
  2101 			}
       
  2102 		}
       
  2103 
       
  2104 		self::print_js( 'wp390_widgets', $selector, array(
       
  2105 			'content' => $content,
       
  2106 			'position' => $position,
       
  2107 		) );
       
  2108 	}
       
  2109 
       
  2110 	public static function pointer_wp410_dfw() {
       
  2111 		// Don't show when editor-scrolling is not used.
       
  2112 		if ( empty( $GLOBALS['_wp_editor_expand'] ) ) {
       
  2113 			return;
       
  2114 		}
       
  2115 
       
  2116 		$content  = '<h3>' . __( 'Distraction-Free Writing' ) . '</h3>';
       
  2117 		$content .= '<p>' . __( 'Enable distraction-free writing mode, and everything surrounding the editor will fade away when you start typing. Move your mouse out of the editor to reveal everything again.' ) . '</p>';
       
  2118 
       
  2119 		if ( is_rtl() ) {
       
  2120 			$position = array( 'edge' => 'left', 'align' => 'center', 'my' => 'left+40 top-11', 'at' => 'left top' );
       
  2121 		} else {
       
  2122 			$position = array( 'edge' => 'right', 'align' => 'center', 'my' => 'right-40 top-11', 'at' => 'right top' );
       
  2123 		}
       
  2124 
       
  2125 		self::print_js( 'wp410_dfw', '#wp-content-wrap', array(
       
  2126 			'content' => $content,
       
  2127 			'position' => $position,
       
  2128 		) );
       
  2129 	}
       
  2130 
  1913 	/**
  2131 	/**
  1914 	 * Prevents new users from seeing existing 'new feature' pointers.
  2132 	 * Prevents new users from seeing existing 'new feature' pointers.
  1915 	 *
  2133 	 *
  1916 	 * @since 3.3.0
  2134 	 * @since 3.3.0
       
  2135 	 *
       
  2136 	 * @param int $user_id User ID.
  1917 	 */
  2137 	 */
  1918 	public static function dismiss_pointers_for_new_users( $user_id ) {
  2138 	public static function dismiss_pointers_for_new_users( $user_id ) {
  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' );
  2139 		add_user_meta( $user_id, 'dismissed_wp_pointers', 'wp360_locks,wp390_widgets' );
  1920 	}
  2140 	}
  1921 }
  2141 }
  1922 
  2142 
  1923 add_action( 'admin_enqueue_scripts', array( 'WP_Internal_Pointers', 'enqueue_scripts'                ) );
  2143 add_action( 'admin_enqueue_scripts', array( 'WP_Internal_Pointers', 'enqueue_scripts'                ) );
  1924 add_action( 'user_register',         array( 'WP_Internal_Pointers', 'dismiss_pointers_for_new_users' ) );
  2144 add_action( 'user_register',         array( 'WP_Internal_Pointers', 'dismiss_pointers_for_new_users' ) );
  1941 }
  2161 }
  1942 
  2162 
  1943 /**
  2163 /**
  1944  * Output the HTML for restoring the post data from DOM storage
  2164  * Output the HTML for restoring the post data from DOM storage
  1945  *
  2165  *
  1946  * @since 3.6
  2166  * @since 3.6.0
  1947  * @access private
  2167  * @access private
  1948  */
  2168  */
  1949 function _local_storage_notice() {
  2169 function _local_storage_notice() {
  1950 	?>
  2170 	?>
  1951 	<div id="local-storage-notice" class="hidden">
  2171 	<div id="local-storage-notice" class="hidden notice">
  1952 	<p class="local-restore">
  2172 	<p class="local-restore">
  1953 		<?php _e('The backup of this post in your browser is different from the version below.'); ?>
  2173 		<?php _e('The backup of this post in your browser is different from the version below.'); ?>
  1954 		<a class="restore-backup" href="#"><?php _e('Restore the backup.'); ?></a>
  2174 		<a class="restore-backup" href="#"><?php _e('Restore the backup.'); ?></a>
  1955 	</p>
  2175 	</p>
  1956 	<p class="undo-restore hidden">
  2176 	<p class="undo-restore hidden">
  1958 		<a class="undo-restore-backup" href="#"><?php _e('Undo.'); ?></a>
  2178 		<a class="undo-restore-backup" href="#"><?php _e('Undo.'); ?></a>
  1959 	</p>
  2179 	</p>
  1960 	</div>
  2180 	</div>
  1961 	<?php
  2181 	<?php
  1962 }
  2182 }
       
  2183 
       
  2184 /**
       
  2185  * Output a HTML element with a star rating for a given rating.
       
  2186  *
       
  2187  * Outputs a HTML element with the star rating exposed on a 0..5 scale in
       
  2188  * half star increments (ie. 1, 1.5, 2 stars). Optionally, if specified, the
       
  2189  * number of ratings may also be displayed by passing the $number parameter.
       
  2190  *
       
  2191  * @since 3.8.0
       
  2192  * @param array $args {
       
  2193  *     Optional. Array of star ratings arguments.
       
  2194  *
       
  2195  *     @type int    $rating The rating to display, expressed in either a 0.5 rating increment,
       
  2196  *                          or percentage. Default 0.
       
  2197  *     @type string $type   Format that the $rating is in. Valid values are 'rating' (default),
       
  2198  *                          or, 'percent'. Default 'rating'.
       
  2199  *     @type int    $number The number of ratings that makes up this rating. Default 0.
       
  2200  * }
       
  2201  */
       
  2202 function wp_star_rating( $args = array() ) {
       
  2203 	$defaults = array(
       
  2204 		'rating' => 0,
       
  2205 		'type' => 'rating',
       
  2206 		'number' => 0,
       
  2207 	);
       
  2208 	$r = wp_parse_args( $args, $defaults );
       
  2209 
       
  2210 	// Non-english decimal places when the $rating is coming from a string
       
  2211 	$rating = str_replace( ',', '.', $r['rating'] );
       
  2212 
       
  2213 	// Convert Percentage to star rating, 0..5 in .5 increments
       
  2214 	if ( 'percent' == $r['type'] ) {
       
  2215 		$rating = round( $rating / 10, 0 ) / 2;
       
  2216 	}
       
  2217 
       
  2218 	// Calculate the number of each type of star needed
       
  2219 	$full_stars = floor( $rating );
       
  2220 	$half_stars = ceil( $rating - $full_stars );
       
  2221 	$empty_stars = 5 - $full_stars - $half_stars;
       
  2222 
       
  2223 	if ( $r['number'] ) {
       
  2224 		/* translators: 1: The rating, 2: The number of ratings */
       
  2225 		$format = _n( '%1$s rating based on %2$s rating', '%1$s rating based on %2$s ratings', $r['number'] );
       
  2226 		$title = sprintf( $format, number_format_i18n( $rating, 1 ), number_format_i18n( $r['number'] ) );
       
  2227 	} else {
       
  2228 		/* translators: 1: The rating */
       
  2229 		$title = sprintf( __( '%s rating' ), number_format_i18n( $rating, 1 ) );
       
  2230 	}
       
  2231 
       
  2232 	echo '<div class="star-rating" title="' . esc_attr( $title ) . '">';
       
  2233 	echo '<span class="screen-reader-text">' . $title . '</span>';
       
  2234 	echo str_repeat( '<div class="star star-full"></div>', $full_stars );
       
  2235 	echo str_repeat( '<div class="star star-half"></div>', $half_stars );
       
  2236 	echo str_repeat( '<div class="star star-empty"></div>', $empty_stars);
       
  2237 	echo '</div>';
       
  2238 }
       
  2239 
       
  2240 /**
       
  2241  * Output a notice when editing the page for posts (internal use only).
       
  2242  *
       
  2243  * @ignore
       
  2244  * @since 4.2.0
       
  2245  */
       
  2246 function _wp_posts_page_notice() {
       
  2247 	echo '<div class="notice notice-warning inline"><p>' . __( 'You are currently editing the page that shows your latest posts.' ) . '</p></div>';
       
  2248 }