Edit File by line
/home/zeestwma/richards.../wp-inclu.../widgets
File: class-wp-widget-links.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Widget API: WP_Widget_Links class
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @subpackage Widgets
[5] Fix | Delete
* @since 4.4.0
[6] Fix | Delete
*/
[7] Fix | Delete
[8] Fix | Delete
/**
[9] Fix | Delete
* Core class used to implement a Links widget.
[10] Fix | Delete
*
[11] Fix | Delete
* @since 2.8.0
[12] Fix | Delete
*
[13] Fix | Delete
* @see WP_Widget
[14] Fix | Delete
*/
[15] Fix | Delete
class WP_Widget_Links extends WP_Widget {
[16] Fix | Delete
[17] Fix | Delete
/**
[18] Fix | Delete
* Sets up a new Links widget instance.
[19] Fix | Delete
*
[20] Fix | Delete
* @since 2.8.0
[21] Fix | Delete
*/
[22] Fix | Delete
public function __construct() {
[23] Fix | Delete
$widget_ops = array(
[24] Fix | Delete
'description' => __( 'Your blogroll' ),
[25] Fix | Delete
'customize_selective_refresh' => true,
[26] Fix | Delete
);
[27] Fix | Delete
parent::__construct( 'links', __( 'Links' ), $widget_ops );
[28] Fix | Delete
}
[29] Fix | Delete
[30] Fix | Delete
/**
[31] Fix | Delete
* Outputs the content for the current Links widget instance.
[32] Fix | Delete
*
[33] Fix | Delete
* @since 2.8.0
[34] Fix | Delete
*
[35] Fix | Delete
* @param array $args Display arguments including 'before_title', 'after_title',
[36] Fix | Delete
* 'before_widget', and 'after_widget'.
[37] Fix | Delete
* @param array $instance Settings for the current Links widget instance.
[38] Fix | Delete
*/
[39] Fix | Delete
public function widget( $args, $instance ) {
[40] Fix | Delete
$show_description = isset( $instance['description'] ) ? $instance['description'] : false;
[41] Fix | Delete
$show_name = isset( $instance['name'] ) ? $instance['name'] : false;
[42] Fix | Delete
$show_rating = isset( $instance['rating'] ) ? $instance['rating'] : false;
[43] Fix | Delete
$show_images = isset( $instance['images'] ) ? $instance['images'] : true;
[44] Fix | Delete
$category = isset( $instance['category'] ) ? $instance['category'] : false;
[45] Fix | Delete
$orderby = isset( $instance['orderby'] ) ? $instance['orderby'] : 'name';
[46] Fix | Delete
$order = 'rating' === $orderby ? 'DESC' : 'ASC';
[47] Fix | Delete
$limit = isset( $instance['limit'] ) ? $instance['limit'] : -1;
[48] Fix | Delete
[49] Fix | Delete
$before_widget = preg_replace( '/ id="[^"]*"/', ' id="%id"', $args['before_widget'] );
[50] Fix | Delete
[51] Fix | Delete
$widget_links_args = array(
[52] Fix | Delete
'title_before' => $args['before_title'],
[53] Fix | Delete
'title_after' => $args['after_title'],
[54] Fix | Delete
'category_before' => $before_widget,
[55] Fix | Delete
'category_after' => $args['after_widget'],
[56] Fix | Delete
'show_images' => $show_images,
[57] Fix | Delete
'show_description' => $show_description,
[58] Fix | Delete
'show_name' => $show_name,
[59] Fix | Delete
'show_rating' => $show_rating,
[60] Fix | Delete
'category' => $category,
[61] Fix | Delete
'class' => 'linkcat widget',
[62] Fix | Delete
'orderby' => $orderby,
[63] Fix | Delete
'order' => $order,
[64] Fix | Delete
'limit' => $limit,
[65] Fix | Delete
);
[66] Fix | Delete
[67] Fix | Delete
/**
[68] Fix | Delete
* Filters the arguments for the Links widget.
[69] Fix | Delete
*
[70] Fix | Delete
* @since 2.6.0
[71] Fix | Delete
* @since 4.4.0 Added the `$instance` parameter.
[72] Fix | Delete
*
[73] Fix | Delete
* @see wp_list_bookmarks()
[74] Fix | Delete
*
[75] Fix | Delete
* @param array $widget_links_args An array of arguments to retrieve the links list.
[76] Fix | Delete
* @param array $instance The settings for the particular instance of the widget.
[77] Fix | Delete
*/
[78] Fix | Delete
wp_list_bookmarks( apply_filters( 'widget_links_args', $widget_links_args, $instance ) );
[79] Fix | Delete
}
[80] Fix | Delete
[81] Fix | Delete
/**
[82] Fix | Delete
* Handles updating settings for the current Links widget instance.
[83] Fix | Delete
*
[84] Fix | Delete
* @since 2.8.0
[85] Fix | Delete
*
[86] Fix | Delete
* @param array $new_instance New settings for this instance as input by the user via
[87] Fix | Delete
* WP_Widget::form().
[88] Fix | Delete
* @param array $old_instance Old settings for this instance.
[89] Fix | Delete
* @return array Updated settings to save.
[90] Fix | Delete
*/
[91] Fix | Delete
public function update( $new_instance, $old_instance ) {
[92] Fix | Delete
$new_instance = (array) $new_instance;
[93] Fix | Delete
$instance = array(
[94] Fix | Delete
'images' => 0,
[95] Fix | Delete
'name' => 0,
[96] Fix | Delete
'description' => 0,
[97] Fix | Delete
'rating' => 0,
[98] Fix | Delete
);
[99] Fix | Delete
foreach ( $instance as $field => $val ) {
[100] Fix | Delete
if ( isset( $new_instance[ $field ] ) ) {
[101] Fix | Delete
$instance[ $field ] = 1;
[102] Fix | Delete
}
[103] Fix | Delete
}
[104] Fix | Delete
[105] Fix | Delete
$instance['orderby'] = 'name';
[106] Fix | Delete
if ( in_array( $new_instance['orderby'], array( 'name', 'rating', 'id', 'rand' ), true ) ) {
[107] Fix | Delete
$instance['orderby'] = $new_instance['orderby'];
[108] Fix | Delete
}
[109] Fix | Delete
[110] Fix | Delete
$instance['category'] = (int) $new_instance['category'];
[111] Fix | Delete
$instance['limit'] = ! empty( $new_instance['limit'] ) ? (int) $new_instance['limit'] : -1;
[112] Fix | Delete
[113] Fix | Delete
return $instance;
[114] Fix | Delete
}
[115] Fix | Delete
[116] Fix | Delete
/**
[117] Fix | Delete
* Outputs the settings form for the Links widget.
[118] Fix | Delete
*
[119] Fix | Delete
* @since 2.8.0
[120] Fix | Delete
*
[121] Fix | Delete
* @param array $instance Current settings.
[122] Fix | Delete
*/
[123] Fix | Delete
public function form( $instance ) {
[124] Fix | Delete
[125] Fix | Delete
// Defaults.
[126] Fix | Delete
$instance = wp_parse_args(
[127] Fix | Delete
(array) $instance,
[128] Fix | Delete
array(
[129] Fix | Delete
'images' => true,
[130] Fix | Delete
'name' => true,
[131] Fix | Delete
'description' => false,
[132] Fix | Delete
'rating' => false,
[133] Fix | Delete
'category' => false,
[134] Fix | Delete
'orderby' => 'name',
[135] Fix | Delete
'limit' => -1,
[136] Fix | Delete
)
[137] Fix | Delete
);
[138] Fix | Delete
$link_cats = get_terms( array( 'taxonomy' => 'link_category' ) );
[139] Fix | Delete
$limit = (int) $instance['limit'];
[140] Fix | Delete
if ( ! $limit ) {
[141] Fix | Delete
$limit = -1;
[142] Fix | Delete
}
[143] Fix | Delete
?>
[144] Fix | Delete
<p>
[145] Fix | Delete
<label for="<?php echo $this->get_field_id( 'category' ); ?>"><?php _e( 'Select Link Category:' ); ?></label>
[146] Fix | Delete
<select class="widefat" id="<?php echo $this->get_field_id( 'category' ); ?>" name="<?php echo $this->get_field_name( 'category' ); ?>">
[147] Fix | Delete
<option value=""><?php _ex( 'All Links', 'links widget' ); ?></option>
[148] Fix | Delete
<?php foreach ( $link_cats as $link_cat ) : ?>
[149] Fix | Delete
<option value="<?php echo (int) $link_cat->term_id; ?>" <?php selected( $instance['category'], $link_cat->term_id ); ?>>
[150] Fix | Delete
<?php echo esc_html( $link_cat->name ); ?>
[151] Fix | Delete
</option>
[152] Fix | Delete
<?php endforeach; ?>
[153] Fix | Delete
</select>
[154] Fix | Delete
<label for="<?php echo $this->get_field_id( 'orderby' ); ?>"><?php _e( 'Sort by:' ); ?></label>
[155] Fix | Delete
<select name="<?php echo $this->get_field_name( 'orderby' ); ?>" id="<?php echo $this->get_field_id( 'orderby' ); ?>" class="widefat">
[156] Fix | Delete
<option value="name"<?php selected( $instance['orderby'], 'name' ); ?>><?php _e( 'Link title' ); ?></option>
[157] Fix | Delete
<option value="rating"<?php selected( $instance['orderby'], 'rating' ); ?>><?php _e( 'Link rating' ); ?></option>
[158] Fix | Delete
<option value="id"<?php selected( $instance['orderby'], 'id' ); ?>><?php _e( 'Link ID' ); ?></option>
[159] Fix | Delete
<option value="rand"<?php selected( $instance['orderby'], 'rand' ); ?>><?php _ex( 'Random', 'Links widget' ); ?></option>
[160] Fix | Delete
</select>
[161] Fix | Delete
</p>
[162] Fix | Delete
[163] Fix | Delete
<p>
[164] Fix | Delete
<input class="checkbox" type="checkbox"<?php checked( $instance['images'], true ); ?> id="<?php echo $this->get_field_id( 'images' ); ?>" name="<?php echo $this->get_field_name( 'images' ); ?>" />
[165] Fix | Delete
<label for="<?php echo $this->get_field_id( 'images' ); ?>"><?php _e( 'Show Link Image' ); ?></label>
[166] Fix | Delete
<br />
[167] Fix | Delete
[168] Fix | Delete
<input class="checkbox" type="checkbox"<?php checked( $instance['name'], true ); ?> id="<?php echo $this->get_field_id( 'name' ); ?>" name="<?php echo $this->get_field_name( 'name' ); ?>" />
[169] Fix | Delete
<label for="<?php echo $this->get_field_id( 'name' ); ?>"><?php _e( 'Show Link Name' ); ?></label>
[170] Fix | Delete
<br />
[171] Fix | Delete
[172] Fix | Delete
<input class="checkbox" type="checkbox"<?php checked( $instance['description'], true ); ?> id="<?php echo $this->get_field_id( 'description' ); ?>" name="<?php echo $this->get_field_name( 'description' ); ?>" />
[173] Fix | Delete
<label for="<?php echo $this->get_field_id( 'description' ); ?>"><?php _e( 'Show Link Description' ); ?></label>
[174] Fix | Delete
<br />
[175] Fix | Delete
[176] Fix | Delete
<input class="checkbox" type="checkbox"<?php checked( $instance['rating'], true ); ?> id="<?php echo $this->get_field_id( 'rating' ); ?>" name="<?php echo $this->get_field_name( 'rating' ); ?>" />
[177] Fix | Delete
<label for="<?php echo $this->get_field_id( 'rating' ); ?>"><?php _e( 'Show Link Rating' ); ?></label>
[178] Fix | Delete
</p>
[179] Fix | Delete
[180] Fix | Delete
<p>
[181] Fix | Delete
<label for="<?php echo $this->get_field_id( 'limit' ); ?>"><?php _e( 'Number of links to show:' ); ?></label>
[182] Fix | Delete
<input id="<?php echo $this->get_field_id( 'limit' ); ?>" name="<?php echo $this->get_field_name( 'limit' ); ?>" type="text" value="<?php echo ( -1 !== $limit ) ? (int) $limit : ''; ?>" size="3" />
[183] Fix | Delete
</p>
[184] Fix | Delete
<?php
[185] Fix | Delete
}
[186] Fix | Delete
}
[187] Fix | Delete
[188] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function