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';
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']);
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 );
);
if ( $d ) {
- static $first_dropdown = true;
-
$dropdown_id = ( $first_dropdown ) ? 'cat' : "{$this->id_base}-dropdown-{$this->number}";
$first_dropdown = false;
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']));
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;
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 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 ) {
- 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);