PluginProbe
Taboola / 1.0
Taboola v1.0
1.0.4 1.0.5 1.0.6 1.0.8 2.0.1 2.0.2 2.1.0 2.1.1 2.2.2 2.2.3 3.0.0 3.0.1 3.0.2 3.1.0 trunk 1.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.2 1.0.3
← All changes | widget.php +11 -25 1.0.11.0 View file →
@@ -1,24 +1,15 @@
1 1 <?php
2 -define ("TABOOLA_WIDGET_BASE_ID","taboola");
2 +
3 3 class WP_Widget_Taboola extends WP_Widget {
4 4
5 - private static $counter;
6 5 function __construct() {
7 -
8 -
9 6 $widget_ops = array('classname' => 'widget_taboola', 'description' => __( "A taboola widget for your site.") );
10 - parent::__construct( TABOOLA_WIDGET_BASE_ID, _x( 'Taboola Widget', 'Taboola Widget' ), $widget_ops );
7 + parent::__construct( 'taboola', _x( 'Taboola Widget', 'Taboola Widget' ), $widget_ops );
11 8 $this->plugin_directory = plugin_dir_path(__FILE__);
12 9 }
13 10
14 11 function widget( $args, $instance ) {
15 - if (!isset(WP_Widget_Taboola::$counter)){
16 - WP_Widget_Taboola::$counter = 1;
17 - }
18 - else{
19 - WP_Widget_Taboola::$counter = WP_Widget_Taboola::$counter + 1;
20 - }
21 12 if (trim($instance['widget_id']) == ''){
22 13 return;
23 14 }
24 15 extract($args);
@@ -25,21 +16,15 @@
25 16
26 17 /** This filter is documented in wp-includes/default-widgets.php */
27 18 $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
28 19
29 - $tmp_id = explode("-",$args["widget_id"]);
30 - $widget_num = $tmp_id[1];
31 -
32 20 $widget_id = ! empty( $instance['widget_id'] ) ? $instance['widget_id'] : '';
21 + $placement = ! empty( $instance['placement'] ) ? $instance['placement'] : '';
33 22
34 - // use the widget container name as the placement, suffix the widget_id to make it unique
35 - $placement=$args["id"]."-".$widget_num;
36 -
37 23 echo $before_widget;
38 24
39 - if ( $title ){
25 + if ( $title )
40 26 echo $before_title . $title . $after_title;
41 - }
42 27
43 28 //widget content
44 29 $script2_content = str_replace('{{WIDGET_ID}}', $widget_id, file_get_contents($this->plugin_directory.'js/script2.js'));
45 30 $script2_content = str_replace('{{CONTAINER}}', $this->id, $script2_content);
@@ -51,8 +36,9 @@
51 36
52 37 function form( $instance ) {
53 38 $instance = wp_parse_args( (array) $instance );
54 39 $widget_id = esc_attr( $instance['widget_id'] );
40 + $placement = esc_attr( $instance['placement'] );
55 41 ?>
56 42 <p>
57 43 <label for="<?php echo $this->get_field_id('widget_id'); ?>"><?php _e('Widget ID:'); ?>
58 44 <input class="widefat" id="<?php echo $this->get_field_id('widget_id'); ?>" name="<?php echo $this->get_field_name('widget_id'); ?>" type="text" value="<?php echo esc_attr($widget_id); ?>" />
@@ -57,20 +43,20 @@
57 43 <label for="<?php echo $this->get_field_id('widget_id'); ?>"><?php _e('Widget ID:'); ?>
58 44 <input class="widefat" id="<?php echo $this->get_field_id('widget_id'); ?>" name="<?php echo $this->get_field_name('widget_id'); ?>" type="text" value="<?php echo esc_attr($widget_id); ?>" />
59 45 </label>
60 46 </p>
47 + <p>
48 + <label for="<?php echo $this->get_field_id('placement'); ?>"><?php _e('Placement:'); ?>
49 + <input class="widefat" id="<?php echo $this->get_field_id('placement'); ?>" name="<?php echo $this->get_field_name('placement'); ?>" type="text" value="<?php echo esc_attr($placement); ?>" />
50 + </label>
51 + </p>
61 52 <?php
62 53 }
63 54
64 55 function update( $new_instance, $old_instance ) {
65 -
66 - // canceling save if the field is empty
67 - if (strip_tags($new_instance['widget_id']) == ""){
68 - return false;
69 - }
70 -
71 56 $instance = $old_instance;
72 57 $instance['widget_id'] = strip_tags($new_instance['widget_id']);
58 + $instance['placement'] = strip_tags($new_instance['placement']);
73 59
74 60 return $instance;
75 61 }
76 62