parent::__construct('pages', __('Pages'), $widget_ops);
}
+ /**
+ * @param array $args
+ * @param array $instance
+ */
public function widget( $args, $instance ) {
/**
}
}
+ /**
+ * @param array $new_instance
+ * @param array $old_instance
+ * @return array
+ */
public function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
return $instance;
}
+ /**
+ * @param array $instance
+ */
public function form( $instance ) {
//Defaults
$instance = wp_parse_args( (array) $instance, array( 'sortby' => 'post_title', 'title' => '', 'exclude' => '') );
parent::__construct('links', __('Links'), $widget_ops);
}
+ /**
+ * @param array $args
+ * @param array $instance
+ */
public function widget( $args, $instance ) {
-
$show_description = isset($instance['description']) ? $instance['description'] : false;
$show_name = isset($instance['name']) ? $instance['name'] : false;
$show_rating = isset($instance['rating']) ? $instance['rating'] : false;
) ) );
}
+ /**
+ * @param array $new_instance
+ * @param array $old_instance
+ * @return array
+ */
public function update( $new_instance, $old_instance ) {
$new_instance = (array) $new_instance;
$instance = array( 'images' => 0, 'name' => 0, 'description' => 0, 'rating' => 0 );
return $instance;
}
+ /**
+ * @param array $instance
+ */
public function form( $instance ) {
//Defaults
parent::__construct( 'search', _x( 'Search', 'Search widget' ), $widget_ops );
}
+ /**
+ * @param array $args
+ * @param array $instance
+ */
public function widget( $args, $instance ) {
-
/** This filter is documented in wp-includes/default-widgets.php */
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
echo $args['after_widget'];
}
+ /**
+ * @param array $instance
+ */
public function form( $instance ) {
$instance = wp_parse_args( (array) $instance, array( 'title' => '') );
$title = $instance['title'];
<?php
}
+ /**
+ * @param array $new_instance
+ * @param array $old_instance
+ * @return array
+ */
public function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$new_instance = wp_parse_args((array) $new_instance, array( 'title' => ''));
parent::__construct('archives', __('Archives'), $widget_ops);
}
+ /**
+ * @param array $args
+ * @param array $instance
+ */
public function widget( $args, $instance ) {
$c = ! empty( $instance['count'] ) ? '1' : '0';
$d = ! empty( $instance['dropdown'] ) ? '1' : '0';
}
if ( $d ) {
+ $dropdown_id = "{$this->id_base}-dropdown-{$this->number}";
?>
- <select name="archive-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'>
- <option value=""><?php esc_attr_e( 'Select Month' ); ?></option>
-
+ <label class="screen-reader-text" for="<?php echo esc_attr( $dropdown_id ); ?>"><?php echo $title; ?></label>
+ <select id="<?php echo esc_attr( $dropdown_id ); ?>" name="archive-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'>
<?php
/**
* Filter the arguments for the Archives widget drop-down.
*
* @param array $args An array of Archives widget drop-down arguments.
*/
- wp_get_archives( apply_filters( 'widget_archives_dropdown_args', array(
+ $dropdown_args = apply_filters( 'widget_archives_dropdown_args', array(
'type' => 'monthly',
'format' => 'option',
'show_post_count' => $c
- ) ) );
-?>
+ ) );
+
+ switch ( $dropdown_args['type'] ) {
+ case 'yearly':
+ $label = __( 'Select Year' );
+ break;
+ case 'monthly':
+ $label = __( 'Select Month' );
+ break;
+ case 'daily':
+ $label = __( 'Select Day' );
+ break;
+ case 'weekly':
+ $label = __( 'Select Week' );
+ break;
+ default:
+ $label = __( 'Select Post' );
+ break;
+ }
+ ?>
+
+ <option value=""><?php echo esc_attr( $label ); ?></option>
+ <?php wp_get_archives( $dropdown_args ); ?>
+
</select>
<?php
} else {
echo $args['after_widget'];
}
+ /**
+ * @param array $new_instance
+ * @param array $old_instance
+ * @return array
+ */
public function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$new_instance = wp_parse_args( (array) $new_instance, array( 'title' => '', 'count' => 0, 'dropdown' => '') );
return $instance;
}
+ /**
+ * @param array $instance
+ */
public function form( $instance ) {
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'count' => 0, 'dropdown' => '') );
$title = strip_tags($instance['title']);
parent::__construct('meta', __('Meta'), $widget_ops);
}
+ /**
+ * @param array $args
+ * @param array $instance
+ */
public function widget( $args, $instance ) {
-
/** This filter is documented in wp-includes/default-widgets.php */
$title = apply_filters( 'widget_title', empty($instance['title']) ? __( 'Meta' ) : $instance['title'], $instance, $this->id_base );
echo $args['after_widget'];
}
+ /**
+ * @param array $new_instance
+ * @param array $old_instance
+ * @return array
+ */
public function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
return $instance;
}
+ /**
+ * @param array $instance
+ */
public function form( $instance ) {
$instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
$title = strip_tags($instance['title']);
parent::__construct('calendar', __('Calendar'), $widget_ops);
}
+ /**
+ * @param array $args
+ * @param array $instance
+ */
public function widget( $args, $instance ) {
-
/** This filter is documented in wp-includes/default-widgets.php */
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
echo $args['after_widget'];
}
+ /**
+ * @param array $new_instance
+ * @param array $old_instance
+ * @return array
+ */
public function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
return $instance;
}
+ /**
+ * @param array $instance
+ */
public function form( $instance ) {
$instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
$title = strip_tags($instance['title']);
parent::__construct('text', __('Text'), $widget_ops, $control_ops);
}
+ /**
+ * @param array $args
+ * @param array $instance
+ */
public function widget( $args, $instance ) {
-
/** This filter is documented in wp-includes/default-widgets.php */
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
echo $args['after_widget'];
}
+ /**
+ * @param array $new_instance
+ * @param array $old_instance
+ * @return array
+ */
public function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
$instance['text'] = $new_instance['text'];
else
$instance['text'] = stripslashes( wp_filter_post_kses( addslashes($new_instance['text']) ) ); // wp_filter_post_kses() expects slashed
- $instance['filter'] = isset($new_instance['filter']);
+ $instance['filter'] = ! empty( $new_instance['filter'] );
return $instance;
}
+ /**
+ * @param array $instance
+ */
public function form( $instance ) {
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'text' => '' ) );
$title = strip_tags($instance['title']);
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
- <textarea class="widefat" rows="16" cols="20" id="<?php echo $this->get_field_id('text'); ?>" name="<?php echo $this->get_field_name('text'); ?>"><?php echo $text; ?></textarea>
+ <p><label for="<?php echo $this->get_field_id( 'text' ); ?>"><?php _e( 'Content:' ); ?></label>
+ <textarea class="widefat" rows="16" cols="20" id="<?php echo $this->get_field_id('text'); ?>" name="<?php echo $this->get_field_name('text'); ?>"><?php echo $text; ?></textarea></p>
<p><input id="<?php echo $this->get_field_id('filter'); ?>" name="<?php echo $this->get_field_name('filter'); ?>" type="checkbox" <?php checked(isset($instance['filter']) ? $instance['filter'] : 0); ?> /> <label for="<?php echo $this->get_field_id('filter'); ?>"><?php _e('Automatically add paragraphs'); ?></label></p>
<?php
parent::__construct('categories', __('Categories'), $widget_ops);
}
+ /**
+ * @staticvar bool $first_dropdown
+ *
+ * @param array $args
+ * @param array $instance
+ */
public function widget( $args, $instance ) {
+ static $first_dropdown = true;
/** This filter is documented in wp-includes/default-widgets.php */
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Categories' ) : $instance['title'], $instance, $this->id_base );
echo $args['before_title'] . $title . $args['after_title'];
}
- $cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h);
+ $cat_args = array(
+ 'orderby' => 'name',
+ 'show_count' => $c,
+ 'hierarchical' => $h
+ );
if ( $d ) {
- $cat_args['show_option_none'] = __('Select Category');
+ $dropdown_id = ( $first_dropdown ) ? 'cat' : "{$this->id_base}-dropdown-{$this->number}";
+ $first_dropdown = false;
+
+ echo '<label class="screen-reader-text" for="' . esc_attr( $dropdown_id ) . '">' . $title . '</label>';
+
+ $cat_args['show_option_none'] = __( 'Select Category' );
+ $cat_args['id'] = $dropdown_id;
/**
* Filter the arguments for the Categories widget drop-down.
<script type='text/javascript'>
/* <![CDATA[ */
- var dropdown = document.getElementById("cat");
+(function() {
+ var dropdown = document.getElementById( "<?php echo esc_js( $dropdown_id ); ?>" );
function onCatChange() {
- if ( dropdown.options[dropdown.selectedIndex].value > 0 ) {
- location.href = "<?php echo home_url(); ?>/?cat="+dropdown.options[dropdown.selectedIndex].value;
+ if ( dropdown.options[ dropdown.selectedIndex ].value > 0 ) {
+ location.href = "<?php echo home_url(); ?>/?cat=" + dropdown.options[ dropdown.selectedIndex ].value;
}
}
dropdown.onchange = onCatChange;
+})();
/* ]]> */
</script>
echo $args['after_widget'];
}
+ /**
+ * @param array $new_instance
+ * @param array $old_instance
+ * @return array
+ */
public function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
return $instance;
}
+ /**
+ * @param array $instance
+ */
public function form( $instance ) {
//Defaults
$instance = wp_parse_args( (array) $instance, array( 'title' => '') );
add_action( 'switch_theme', array($this, 'flush_widget_cache') );
}
- public function widget($args, $instance) {
+ /**
+ * @param array $args
+ * @param array $instance
+ */
+ public function widget( $args, $instance ) {
$cache = array();
if ( ! $this->is_preview() ) {
$cache = wp_cache_get( 'widget_recent_posts', 'widget' );
}
}
+ /**
+ * @param array $new_instance
+ * @param array $old_instance
+ * @return array
+ */
public function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
return $instance;
}
+ /**
+ * @access public
+ */
public function flush_widget_cache() {
wp_cache_delete('widget_recent_posts', 'widget');
}
+ /**
+ * @param array $instance
+ */
public function form( $instance ) {
$title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
$number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5;
add_action( 'transition_comment_status', array($this, 'flush_widget_cache') );
}
+ /**
+ * @access public
+ */
public function recent_comments_style() {
-
/**
* Filter the Recent Comments default widget styles.
*
<?php
}
+ /**
+ * @access public
+ */
public function flush_widget_cache() {
wp_cache_delete('widget_recent_comments', 'widget');
}
+ /**
+ * @global array $comments
+ * @global object $comment
+ *
+ * @param array $args
+ * @param array $instance
+ */
public function widget( $args, $instance ) {
global $comments, $comment;
}
$output .= '<ul id="recentcomments">';
- if ( $comments ) {
+ if ( is_array( $comments ) && $comments ) {
// Prime cache for associated posts. (Prime post term cache if we need it for permalinks.)
$post_ids = array_unique( wp_list_pluck( $comments, 'comment_post_ID' ) );
_prime_post_caches( $post_ids, strpos( get_option( 'permalink_structure' ), '%category%' ), false );
}
}
+ /**
+ * @param array $new_instance
+ * @param array $old_instance
+ * @return array
+ */
public function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
return $instance;
}
+ /**
+ * @param array $instance
+ */
public function form( $instance ) {
$title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
$number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5;
parent::__construct( 'rss', __('RSS'), $widget_ops, $control_ops );
}
- public function widget($args, $instance) {
-
+ /**
+ * @param array $args
+ * @param array $instance
+ */
+ public function widget( $args, $instance ) {
if ( isset($instance['error']) && $instance['error'] )
return;
unset($rss);
}
- public function update($new_instance, $old_instance) {
+ /**
+ * @param array $new_instance
+ * @param array $old_instance
+ * @return array
+ */
+ public function update( $new_instance, $old_instance ) {
$testurl = ( isset( $new_instance['url'] ) && ( !isset( $old_instance['url'] ) || ( $new_instance['url'] != $old_instance['url'] ) ) );
return wp_widget_rss_process( $new_instance, $testurl );
}
- public function form($instance) {
-
- if ( empty($instance) )
+ /**
+ * @param array $instance
+ */
+ public function form( $instance ) {
+ if ( empty( $instance ) ) {
$instance = array( 'title' => '', 'url' => '', 'items' => 10, 'error' => false, 'show_summary' => 0, 'show_author' => 0, 'show_date' => 0 );
+ }
$instance['number'] = $this->number;
wp_widget_rss_form( $instance );
parent::__construct('tag_cloud', __('Tag Cloud'), $widget_ops);
}
+ /**
+ * @param array $args
+ * @param array $instance
+ */
public function widget( $args, $instance ) {
$current_taxonomy = $this->_get_current_taxonomy($instance);
if ( !empty($instance['title']) ) {
echo $args['after_widget'];
}
+ /**
+ * @param array $new_instance
+ * @param array $old_instance
+ * @return array
+ */
public function update( $new_instance, $old_instance ) {
+ $instance = array();
$instance['title'] = strip_tags(stripslashes($new_instance['title']));
$instance['taxonomy'] = stripslashes($new_instance['taxonomy']);
return $instance;
}
+ /**
+ * @param array $instance
+ */
public function form( $instance ) {
$current_taxonomy = $this->_get_current_taxonomy($instance);
?>
</select></p><?php
}
+ /**
+ * @param array $instance
+ * @return string
+ */
public function _get_current_taxonomy($instance) {
if ( !empty($instance['taxonomy']) && taxonomy_exists($instance['taxonomy']) )
return $instance['taxonomy'];
parent::__construct( 'nav_menu', __('Custom Menu'), $widget_ops );
}
- public function widget($args, $instance) {
+ /**
+ * @param array $args
+ * @param array $instance
+ */
+ public function widget( $args, $instance ) {
// Get menu
$nav_menu = ! empty( $instance['nav_menu'] ) ? wp_get_nav_menu_object( $instance['nav_menu'] ) : false;
if ( !empty($instance['title']) )
echo $args['before_title'] . $instance['title'] . $args['after_title'];
- wp_nav_menu( array( 'fallback_cb' => '', 'menu' => $nav_menu ) );
+ $nav_menu_args = array(
+ 'fallback_cb' => '',
+ 'menu' => $nav_menu
+ );
+
+ /**
+ * Filter the arguments for the Custom Menu widget.
+ *
+ * @since 4.2.0
+ *
+ * @param array $nav_menu_args {
+ * An array of arguments passed to wp_nav_menu() to retrieve a custom menu.
+ *
+ * @type callback|bool $fallback_cb Callback to fire if the menu doesn't exist. Default empty.
+ * @type mixed $menu Menu ID, slug, or name.
+ * }
+ * @param stdClass $nav_menu Nav menu object for the current menu.
+ * @param array $args Display arguments for the current widget.
+ */
+ wp_nav_menu( apply_filters( 'widget_nav_menu_args', $nav_menu_args, $nav_menu, $args ) );
echo $args['after_widget'];
}
+ /**
+ * @param array $new_instance
+ * @param array $old_instance
+ * @return array
+ */
public function update( $new_instance, $old_instance ) {
$instance = array();
if ( ! empty( $new_instance['title'] ) ) {
return $instance;
}
+ /**
+ * @param array $instance
+ */
public function form( $instance ) {
$title = isset( $instance['title'] ) ? $instance['title'] : '';
$nav_menu = isset( $instance['nav_menu'] ) ? $instance['nav_menu'] : '';
$menus = wp_get_nav_menus();
// If no menus exists, direct the user to go and create some.
- if ( !$menus ) {
- echo '<p>'. sprintf( __('No menus have been created yet. <a href="%s">Create some</a>.'), admin_url('nav-menus.php') ) .'</p>';
- return;
- }
?>
- <p>
- <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:') ?></label>
- <input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo $title; ?>" />
- </p>
- <p>
- <label for="<?php echo $this->get_field_id('nav_menu'); ?>"><?php _e('Select Menu:'); ?></label>
- <select id="<?php echo $this->get_field_id('nav_menu'); ?>" name="<?php echo $this->get_field_name('nav_menu'); ?>">
- <option value="0"><?php _e( '— Select —' ) ?></option>
- <?php
- foreach ( $menus as $menu ) {
- echo '<option value="' . $menu->term_id . '"'
- . selected( $nav_menu, $menu->term_id, false )
- . '>'. esc_html( $menu->name ) . '</option>';
+ <p class="nav-menu-widget-no-menus-message" <?php if ( ! empty( $menus ) ) { echo ' style="display:none" '; } ?>>
+ <?php
+ if ( isset( $GLOBALS['wp_customize'] ) && $GLOBALS['wp_customize'] instanceof WP_Customize_Manager ) {
+ $url = 'javascript: wp.customize.panel( "nav_menus" ).focus();';
+ } else {
+ $url = admin_url( 'nav-menus.php' );
}
- ?>
- </select>
+ ?>
+ <?php echo sprintf( __( 'No menus have been created yet. <a href="%s">Create some</a>.' ), esc_attr( $url ) ); ?>
</p>
+ <div class="nav-menu-widget-form-controls" <?php if ( empty( $menus ) ) { echo ' style="display:none" '; } ?>>
+ <p>
+ <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ) ?></label>
+ <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo esc_attr( $title ); ?>"/>
+ </p>
+ <p>
+ <label for="<?php echo $this->get_field_id( 'nav_menu' ); ?>"><?php _e( 'Select Menu:' ); ?></label>
+ <select id="<?php echo $this->get_field_id( 'nav_menu' ); ?>" name="<?php echo $this->get_field_name( 'nav_menu' ); ?>">
+ <option value="0"><?php _e( '— Select —' ); ?></option>
+ <?php foreach ( $menus as $menu ) : ?>
+ <option value="<?php echo esc_attr( $menu->term_id ); ?>" <?php selected( $nav_menu, $menu->term_id ); ?>>
+ <?php echo esc_html( $menu->name ); ?>
+ </option>
+ <?php endforeach; ?>
+ </select>
+ </p>
+ </div>
<?php
}
}
*/
do_action( 'widgets_init' );
}
-
-add_action('init', 'wp_widgets_init', 1);