prefix = Easy_get_prefix();
/* Set the widget textdomain. */
$this->textdomain = Easy_get_textdomain();
/* Set up the widget options. */
$widget_options = array(
'classname' => 'bookmarks',
'description' => esc_html__( 'An advanced widget that gives you total control over the output of your bookmarks (links).', $this->textdomain )
);
/* Set up the widget control options. */
$control_options = array(
'width' => 800,
'height' => 350,
'id_base' => "{$this->prefix}-bookmarks"
);
/* Create the widget. */
$this->WP_Widget( "{$this->prefix}-bookmarks", esc_attr__( 'Bookmarks', $this->textdomain ), $widget_options, $control_options );
}
/**
* Outputs the widget based on the arguments input through the widget controls.
* @since 0.6.0
*/
function widget( $args, $instance ) {
extract( $args );
/* Set up the $before_widget ID for multiple widgets created by the bookmarks widget. */
if ( $instance['categorize'] )
$before_widget = preg_replace( '/id="[^"]*"/','id="%id"', $before_widget );
/* Add a class to $before_widget if one is set. */
if ( $instance['class'] )
$before_widget = str_replace( 'class="', 'class="' . esc_attr( $instance['class'] ) . ' ', $before_widget );
/* Set up the arguments for wp_list_bookmarks(). */
$args = array(
'title_li' => apply_filters( 'widget_title', $instance['title_li'], $instance, $this->id_base ),
'category' => !empty( $instance['category'] ) ? join( ', ', $instance['category'] ) : '',
'exclude_category' => !empty( $instance['exclude_category'] ) ? join( ', ', $instance['exclude_category'] ) : '',
'category_order' => $instance['category_order'],
'category_orderby' => $instance['category_orderby'],
'include' => !empty( $instance['include'] ) ? join( ', ', $instance['include'] ) : '',
'exclude' => !empty( $instance['exclude'] ) ? join( ', ', $instance['exclude'] ) : '',
'order' => $instance['order'],
'orderby' => $instance['orderby'],
'limit' => $instance['limit'] ? intval( $instance['limit'] ) : -1,
'between' => $instance['between'],
'link_before' => $instance['link_before'],
'link_after' => $instance['link_after'],
'search' => $instance['search'],
'categorize' => !empty( $instance['categorize'] ) ? true : false,
'show_description' => !empty( $instance['show_description'] ) ? true : false,
'hide_invisible' => !empty( $instance['hide_invisible'] ) ? true : false,
'show_rating' => !empty( $instance['show_rating'] ) ? true : false,
'show_updated' => !empty( $instance['show_updated'] ) ? true : false,
'show_images' => !empty( $instance['show_images'] ) ? true : false,
'show_name' => !empty( $instance['show_name'] ) ? true : false,
'show_private' => !empty( $instance['show_private'] ) ? true : false,
'title_before' => $before_title,
'title_after' => $after_title,
'category_before' => $before_widget,
'category_after' => $after_widget,
'category_name' => false,
'echo' => false
);
/* Output the bookmarks widget. */
echo str_replace( array( "\r", "\n", "\t" ), '', wp_list_bookmarks( $args ) );
}
/**
* Updates the widget control options for the particular instance of the widget.
* @since 0.6.0
*/
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
/* Set the instance to the new instance. */
$instance = $new_instance;
$instance['title_li'] = strip_tags( $new_instance['title_li'] );
$instance['limit'] = strip_tags( $new_instance['limit'] );
$instance['class'] = strip_tags( $new_instance['class'] );
$instance['search'] = strip_tags( $new_instance['search'] );
$instance['category_order'] = $new_instance['category_order'];
$instance['category_orderby'] = $new_instance['category_orderby'];
$instance['orderby'] = $new_instance['orderby'];
$instance['order'] = $new_instance['order'];
$instance['between'] = $new_instance['between'];
$instance['link_before'] = $new_instance['link_before'];
$instance['link_after'] = $new_instance['link_after'];
$instance['categorize'] = ( isset( $new_instance['categorize'] ) ? 1 : 0 );
$instance['hide_invisible'] = ( isset( $new_instance['hide_invisible'] ) ? 1 : 0 );
$instance['show_private'] = ( isset( $new_instance['show_private'] ) ? 1 : 0 );
$instance['show_rating'] = ( isset( $new_instance['show_rating'] ) ? 1 : 0 );
$instance['show_updated'] = ( isset( $new_instance['show_updated'] ) ? 1 : 0 );
$instance['show_images'] = ( isset( $new_instance['show_images'] ) ? 1 : 0 );
$instance['show_name'] = ( isset( $new_instance['show_name'] ) ? 1 : 0 );
$instance['show_description'] = ( isset( $new_instance['show_description'] ) ? 1 : 0 );
return $instance;
}
/**
* Displays the widget control options in the Widgets admin screen.
* @since 0.6.0
*/
function form( $instance ) {
/* Set up the default form values. */
$defaults = array(
'title_li' => esc_attr__( 'Bookmarks', $this->textdomain ),
'categorize' => true,
'category_order' => 'ASC',
'category_orderby' => 'name',
'category' => array(),
'exclude_category' => array(),
'limit' => '',
'order' => 'ASC',
'orderby' => 'name',
'include' => array(),
'exclude' => array(),
'search' => '',
'hide_invisible' => true,
'show_description' => false,
'show_images' => false,
'show_rating' => false,
'show_updated' => false,
'show_private' => false,
'show_name' => false,
'class' => 'linkcat',
'link_before' => '',
'link_after' => '',
'between' => '
',
);
/* Merge the user-selected arguments with the defaults. */
$instance = wp_parse_args( (array) $instance, $defaults );
$terms = get_terms( 'link_category' );
$bookmarks = get_bookmarks( array( 'hide_invisible' => false ) );
$category_order = array( 'ASC' => esc_attr__( 'Ascending', $this->textdomain ), 'DESC' => esc_attr__( 'Descending', $this->textdomain ) );
$category_orderby = array( 'count' => esc_attr__( 'Count', $this->textdomain ), 'ID' => esc_attr__( 'ID', $this->textdomain ), 'name' => esc_attr__( 'Name', $this->textdomain ), 'slug' => esc_attr__( 'Slug', $this->textdomain ) );
$order = array( 'ASC' => esc_attr__( 'Ascending', $this->textdomain ), 'DESC' => esc_attr__( 'Descending', $this->textdomain ) );
$orderby = array( 'id' => esc_attr__( 'ID', $this->textdomain ), 'description' => esc_attr__( 'Description', $this->textdomain ), 'length' => esc_attr__( 'Length', $this->textdomain ), 'name' => esc_attr__( 'Name', $this->textdomain ), 'notes' => esc_attr__( 'Notes', $this->textdomain ), 'owner' => esc_attr__( 'Owner', $this->textdomain ), 'rand' => esc_attr__( 'Random', $this->textdomain ), 'rating' => esc_attr__( 'Rating', $this->textdomain ), 'rel' => esc_attr__( 'Rel', $this->textdomain ), 'rss' => esc_attr__( 'RSS', $this->textdomain ), 'target' => esc_attr__( 'Target', $this->textdomain ), 'updated' => esc_attr__( 'Updated', $this->textdomain ), 'url' => esc_attr__( 'URL', $this->textdomain ) );
?>