wp-admin/includes/template.php
is now a loader for 3 files made via svn cp
:
* `Walker_Category_Checklist` class * `WP_Internal_Pointers` class * `template-functions.php` This is BC for plugins that are loading `wp-admin/includes/template.php` for fun. See #33413. git-svn-id: https://develop.svn.wordpress.org/trunk@34241 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
d262ebca0a
commit
d2bb55ee92
124
src/wp-admin/includes/class-walker-category-checklist.php
Normal file
124
src/wp-admin/includes/class-walker-category-checklist.php
Normal file
@ -0,0 +1,124 @@
|
||||
<?php
|
||||
/**
|
||||
* WordPress Administration API: Walker_Category_Checklist class
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Administration
|
||||
* @since 4.4.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Walker to output an unordered list of category checkbox input elements.
|
||||
*
|
||||
* @since 2.5.1
|
||||
*
|
||||
* @see Walker
|
||||
* @see wp_category_checklist()
|
||||
* @see wp_terms_checklist()
|
||||
*/
|
||||
class Walker_Category_Checklist extends Walker {
|
||||
public $tree_type = 'category';
|
||||
public $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this
|
||||
|
||||
/**
|
||||
* Starts the list before the elements are added.
|
||||
*
|
||||
* @see Walker:start_lvl()
|
||||
*
|
||||
* @since 2.5.1
|
||||
*
|
||||
* @param string $output Passed by reference. Used to append additional content.
|
||||
* @param int $depth Depth of category. Used for tab indentation.
|
||||
* @param array $args An array of arguments. @see wp_terms_checklist()
|
||||
*/
|
||||
public function start_lvl( &$output, $depth = 0, $args = array() ) {
|
||||
$indent = str_repeat("\t", $depth);
|
||||
$output .= "$indent<ul class='children'>\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Ends the list of after the elements are added.
|
||||
*
|
||||
* @see Walker::end_lvl()
|
||||
*
|
||||
* @since 2.5.1
|
||||
*
|
||||
* @param string $output Passed by reference. Used to append additional content.
|
||||
* @param int $depth Depth of category. Used for tab indentation.
|
||||
* @param array $args An array of arguments. @see wp_terms_checklist()
|
||||
*/
|
||||
public function end_lvl( &$output, $depth = 0, $args = array() ) {
|
||||
$indent = str_repeat("\t", $depth);
|
||||
$output .= "$indent</ul>\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the element output.
|
||||
*
|
||||
* @see Walker::start_el()
|
||||
*
|
||||
* @since 2.5.1
|
||||
*
|
||||
* @param string $output Passed by reference. Used to append additional content.
|
||||
* @param object $category The current term object.
|
||||
* @param int $depth Depth of the term in reference to parents. Default 0.
|
||||
* @param array $args An array of arguments. @see wp_terms_checklist()
|
||||
* @param int $id ID of the current term.
|
||||
*/
|
||||
public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
|
||||
if ( empty( $args['taxonomy'] ) ) {
|
||||
$taxonomy = 'category';
|
||||
} else {
|
||||
$taxonomy = $args['taxonomy'];
|
||||
}
|
||||
|
||||
if ( $taxonomy == 'category' ) {
|
||||
$name = 'post_category';
|
||||
} else {
|
||||
$name = 'tax_input[' . $taxonomy . ']';
|
||||
}
|
||||
|
||||
$args['popular_cats'] = empty( $args['popular_cats'] ) ? array() : $args['popular_cats'];
|
||||
$class = in_array( $category->term_id, $args['popular_cats'] ) ? ' class="popular-category"' : '';
|
||||
|
||||
$args['selected_cats'] = empty( $args['selected_cats'] ) ? array() : $args['selected_cats'];
|
||||
|
||||
/** This filter is documented in wp-includes/category-template.php */
|
||||
if ( ! empty( $args['list_only'] ) ) {
|
||||
$aria_cheched = 'false';
|
||||
$inner_class = 'category';
|
||||
|
||||
if ( in_array( $category->term_id, $args['selected_cats'] ) ) {
|
||||
$inner_class .= ' selected';
|
||||
$aria_cheched = 'true';
|
||||
}
|
||||
|
||||
$output .= "\n" . '<li' . $class . '>' .
|
||||
'<div class="' . $inner_class . '" data-term-id=' . $category->term_id .
|
||||
' tabindex="0" role="checkbox" aria-checked="' . $aria_cheched . '">' .
|
||||
esc_html( apply_filters( 'the_category', $category->name ) ) . '</div>';
|
||||
} else {
|
||||
$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, $args['selected_cats'] ), true, false ) .
|
||||
disabled( empty( $args['disabled'] ), false, false ) . ' /> ' .
|
||||
esc_html( apply_filters( 'the_category', $category->name ) ) . '</label>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ends the element output, if needed.
|
||||
*
|
||||
* @see Walker::end_el()
|
||||
*
|
||||
* @since 2.5.1
|
||||
*
|
||||
* @param string $output Passed by reference. Used to append additional content.
|
||||
* @param object $category The current term object.
|
||||
* @param int $depth Depth of the term in reference to parents. Default 0.
|
||||
* @param array $args An array of arguments. @see wp_terms_checklist()
|
||||
*/
|
||||
public function end_el( &$output, $category, $depth = 0, $args = array() ) {
|
||||
$output .= "</li>\n";
|
||||
}
|
||||
}
|
161
src/wp-admin/includes/class-wp-internal-pointers.php
Normal file
161
src/wp-admin/includes/class-wp-internal-pointers.php
Normal file
@ -0,0 +1,161 @@
|
||||
<?php
|
||||
/**
|
||||
* WordPress Administration API: WP_Internal_Pointers class
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Administration
|
||||
* @since 4.4.0
|
||||
*/
|
||||
|
||||
final class WP_Internal_Pointers {
|
||||
/**
|
||||
* Initializes the new feature pointers.
|
||||
*
|
||||
* @since 3.3.0
|
||||
*
|
||||
* All pointers can be disabled using the following:
|
||||
* remove_action( 'admin_enqueue_scripts', array( 'WP_Internal_Pointers', 'enqueue_scripts' ) );
|
||||
*
|
||||
* Individual pointers (e.g. wp390_widgets) can be disabled using the following:
|
||||
* remove_action( 'admin_print_footer_scripts', array( 'WP_Internal_Pointers', 'pointer_wp390_widgets' ) );
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @param string $hook_suffix The current admin page.
|
||||
*/
|
||||
public static function enqueue_scripts( $hook_suffix ) {
|
||||
/*
|
||||
* Register feature pointers
|
||||
*
|
||||
* Format:
|
||||
* array(
|
||||
* hook_suffix => pointer callback
|
||||
* )
|
||||
*
|
||||
* Example:
|
||||
* array(
|
||||
* 'themes.php' => 'wp390_widgets'
|
||||
* )
|
||||
*/
|
||||
$registered_pointers = array(
|
||||
// None currently
|
||||
);
|
||||
|
||||
// Check if screen related pointer is registered
|
||||
if ( empty( $registered_pointers[ $hook_suffix ] ) )
|
||||
return;
|
||||
|
||||
$pointers = (array) $registered_pointers[ $hook_suffix ];
|
||||
|
||||
/*
|
||||
* Specify required capabilities for feature pointers
|
||||
*
|
||||
* Format:
|
||||
* array(
|
||||
* pointer callback => Array of required capabilities
|
||||
* )
|
||||
*
|
||||
* Example:
|
||||
* array(
|
||||
* 'wp390_widgets' => array( 'edit_theme_options' )
|
||||
* )
|
||||
*/
|
||||
$caps_required = array(
|
||||
// None currently
|
||||
);
|
||||
|
||||
// Get dismissed pointers
|
||||
$dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
|
||||
|
||||
$got_pointers = false;
|
||||
foreach ( array_diff( $pointers, $dismissed ) as $pointer ) {
|
||||
if ( isset( $caps_required[ $pointer ] ) ) {
|
||||
foreach ( $caps_required[ $pointer ] as $cap ) {
|
||||
if ( ! current_user_can( $cap ) )
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
|
||||
// Bind pointer print function
|
||||
add_action( 'admin_print_footer_scripts', array( 'WP_Internal_Pointers', 'pointer_' . $pointer ) );
|
||||
$got_pointers = true;
|
||||
}
|
||||
|
||||
if ( ! $got_pointers )
|
||||
return;
|
||||
|
||||
// Add pointers script and style to queue
|
||||
wp_enqueue_style( 'wp-pointer' );
|
||||
wp_enqueue_script( 'wp-pointer' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Print the pointer JavaScript data.
|
||||
*
|
||||
* @since 3.3.0
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @param string $pointer_id The pointer ID.
|
||||
* @param string $selector The HTML elements, on which the pointer should be attached.
|
||||
* @param array $args Arguments to be passed to the pointer JS (see wp-pointer.js).
|
||||
*/
|
||||
private static function print_js( $pointer_id, $selector, $args ) {
|
||||
if ( empty( $pointer_id ) || empty( $selector ) || empty( $args ) || empty( $args['content'] ) )
|
||||
return;
|
||||
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
(function($){
|
||||
var options = <?php echo wp_json_encode( $args ); ?>, setup;
|
||||
|
||||
if ( ! options )
|
||||
return;
|
||||
|
||||
options = $.extend( options, {
|
||||
close: function() {
|
||||
$.post( ajaxurl, {
|
||||
pointer: '<?php echo $pointer_id; ?>',
|
||||
action: 'dismiss-wp-pointer'
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
setup = function() {
|
||||
$('<?php echo $selector; ?>').first().pointer( options ).pointer('open');
|
||||
};
|
||||
|
||||
if ( options.position && options.position.defer_loading )
|
||||
$(window).bind( 'load.wp-pointers', setup );
|
||||
else
|
||||
$(document).ready( setup );
|
||||
|
||||
})( jQuery );
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
public static function pointer_wp330_toolbar() {}
|
||||
public static function pointer_wp330_media_uploader() {}
|
||||
public static function pointer_wp330_saving_widgets() {}
|
||||
public static function pointer_wp340_customize_current_theme_link() {}
|
||||
public static function pointer_wp340_choose_image_from_library() {}
|
||||
public static function pointer_wp350_media() {}
|
||||
public static function pointer_wp360_revisions() {}
|
||||
public static function pointer_wp360_locks() {}
|
||||
public static function pointer_wp390_widgets() {}
|
||||
public static function pointer_wp410_dfw() {}
|
||||
|
||||
/**
|
||||
* Prevents new users from seeing existing 'new feature' pointers.
|
||||
*
|
||||
* @since 3.3.0
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @param int $user_id User ID.
|
||||
*/
|
||||
public static function dismiss_pointers_for_new_users( $user_id ) {
|
||||
add_user_meta( $user_id, 'dismissed_wp_pointers', '' );
|
||||
}
|
||||
}
|
2005
src/wp-admin/includes/template-functions.php
Normal file
2005
src/wp-admin/includes/template-functions.php
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user