Test Failed
Pull Request — master (#439)
by Kiran
19:28
created

geodir_twitter   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 93
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 93
loc 93
ccs 0
cts 24
cp 0
rs 10
c 0
b 0
f 0
wmc 6
lcom 0
cbo 0

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * GeoDirectory Widgets
4
 *
5
 * @since 1.0.0
6
 * @package GeoDirectory
7
 */
8
9
/**
10
 * Registers GeoDirectory sidebar.
11
 *
12
 * @since 1.0.0
13
 * @package GeoDirectory
14
 * @global array $geodir_sidebars List of geodirectory sidebars.
15
 */
16
function geodir_register_sidebar()
17
{
18
    global $geodir_sidebars;
19
20
    if (function_exists('register_sidebar')) {
21
        /*===========================*/
22
        /* Home page sidebars start*/
23
        /*===========================*/
24
25
        /**
26
         * Filter the `$before_widget` widget opening HTML tag.
27
         *
28
         * @since 1.0.0
29
         * @param string $var The HTML string to filter. Default = '<section id="%1$s" class="widget geodir-widget %2$s">'.
30
         * @see 'geodir_after_widget'
31
         */
32
        $before_widget = apply_filters('geodir_before_widget', '<section id="%1$s" class="widget geodir-widget %2$s">');
33
        /**
34
         * Filter the `$after_widget` widget closing HTML tag.
35
         *
36
         * @since 1.0.0
37
         * @param string $var The HTML string to filter. Default = '</section>'.
38
         * @see 'geodir_before_widget'
39
         */
40
        $after_widget = apply_filters('geodir_after_widget', '</section>');
41
        /**
42
         * Filter the `$before_title` widget title opening HTML tag.
43
         *
44
         * @since 1.0.0
45
         * @param string $var The HTML string to filter. Default = '<h3 class="widget-title">'.
46
         * @see 'geodir_after_title'
47
         */
48
        $before_title = apply_filters('geodir_before_title', '<h3 class="widget-title">');
49
        /**
50
         * Filter the `$after_title` widget title closing HTML tag.
51
         *
52
         * @since 1.0.0
53
         * @param string $var The HTML string to filter. Default = '</h3>'.
54
         * @see 'geodir_before_title'
55
         */
56
        $after_title = apply_filters('geodir_after_title', '</h3>');
57
58
        if (get_option('geodir_show_home_top_section')) {
59
            register_sidebars(1, array('id' => 'geodir_home_top', 'name' => __('GD Home Top Section', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title));
60
61
            $geodir_sidebars[] = 'geodir_home_top';
62
        }
63
64 View Code Duplication
        if (get_option('geodir_show_home_contant_section')) {
65
            register_sidebars(1, array('id' => 'geodir_home_content', 'name' => __('GD Home Content Section', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title));
66
67
            $geodir_sidebars[] = 'geodir_home_content';
68
        }
69
70 View Code Duplication
        if (get_option('geodir_show_home_right_section')) {
71
            register_sidebars(1, array('id' => 'geodir_home_right', 'name' => __('GD Home Right Section', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title));
72
73
            $geodir_sidebars[] = 'geodir_home_right';
74
        }
75
76 View Code Duplication
        if (get_option('geodir_show_home_left_section')) {
77
            register_sidebars(1, array('id' => 'geodir_home_left', 'name' => __('GD Home Left Section', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title));
78
79
            $geodir_sidebars[] = 'geodir_home_left';
80
        }
81
82 View Code Duplication
        if (get_option('geodir_show_home_bottom_section')) {
83
            register_sidebars(1, array('id' => 'geodir_home_bottom', 'name' => __('GD Home Bottom Section', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title));
84
85
            $geodir_sidebars[] = 'geodir_home_bottom';
86
        }
87
88
        /*===========================*/
89
        /* Home page sidebars end*/
90
        /*===========================*/
91
92
        /*===========================*/
93
        /* Listing page sidebars start*/
94
        /*===========================*/
95
96 View Code Duplication
        if (get_option('geodir_show_listing_top_section')) {
97
            register_sidebars(1, array('id' => 'geodir_listing_top', 'name' => __('GD Listing Top Section', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title));
98
99
            $geodir_sidebars[] = 'geodir_listing_top';
100
        }
101
102 View Code Duplication
        if (get_option('geodir_show_listing_left_section')) {
103
            register_sidebars(1, array('id' => 'geodir_listing_left_sidebar', 'name' => __('GD Listing Left Sidebar', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title));
104
105
            $geodir_sidebars[] = 'geodir_listing_left_sidebar';
106
        }
107
108 View Code Duplication
        if (get_option('geodir_show_listing_right_section')) {
109
            register_sidebars(1, array('id' => 'geodir_listing_right_sidebar', 'name' => __('GD Listing Right Sidebar', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title));
110
111
            $geodir_sidebars[] = 'geodir_listing_right_sidebar';
112
        }
113
114 View Code Duplication
        if (get_option('geodir_show_listing_bottom_section')) {
115
            register_sidebars(1, array('id' => 'geodir_listing_bottom', 'name' => __('GD Listing Bottom Section', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title));
116
117
            $geodir_sidebars[] = 'geodir_listing_bottom';
118
        }
119
120
        /*===========================*/
121
        /* Listing page sidebars start*/
122
        /*===========================*/
123
124
        /*===========================*/
125
        /* Search page sidebars start*/
126
        /*===========================*/
127
128 View Code Duplication
        if (get_option('geodir_show_search_top_section')) {
129
            register_sidebars(1, array('id' => 'geodir_search_top', 'name' => __('GD Search Top Section', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title));
130
131
            $geodir_sidebars[] = 'geodir_search_top';
132
        }
133
134 View Code Duplication
        if (get_option('geodir_show_search_left_section')) {
135
            register_sidebars(1, array('id' => 'geodir_search_left_sidebar', 'name' => __('GD Search Left Sidebar', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title));
136
137
            $geodir_sidebars[] = 'geodir_search_left_sidebar';
138
        }
139
140 View Code Duplication
        if (get_option('geodir_show_search_right_section')) {
141
            register_sidebars(1, array('id' => 'geodir_search_right_sidebar', 'name' => __('GD Search Right Sidebar', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title));
142
143
            $geodir_sidebars[] = 'geodir_search_right_sidebar';
144
        }
145
146 View Code Duplication
        if (get_option('geodir_show_search_bottom_section')) {
147
            register_sidebars(1, array('id' => 'geodir_search_bottom', 'name' => __('GD Search Bottom Section', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title));
148
149
            $geodir_sidebars[] = 'geodir_search_bottom';
150
        }
151
152
        /*===========================*/
153
        /* Search page sidebars end*/
154
        /*===========================*/
155
156
        /*==================================*/
157
        /* Detail/Single page sidebars start*/
158
        /*==================================*/
159 View Code Duplication
        if (get_option('geodir_show_detail_top_section')) {
160
            register_sidebars(1, array('id' => 'geodir_detail_top', 'name' => __('GD Detail Top Section', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title));
161
162
            $geodir_sidebars[] = 'geodir_detail_top';
163
        }
164
165
        register_sidebars(1, array('id' => 'geodir_detail_sidebar', 'name' => __('GD Detail Sidebar', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title));
166
167
        $geodir_sidebars[] = 'geodir_detail_sidebar';
168
169 View Code Duplication
        if (get_option('geodir_show_detail_bottom_section')) {
170
            register_sidebars(1, array('id' => 'geodir_detail_bottom', 'name' => __('GD Detail Bottom Section', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title));
171
172
            $geodir_sidebars[] = 'geodir_detail_bottom';
173
        }
174
175
        /*==================================*/
176
        /* Detail/Single page sidebars end*/
177
        /*==================================*/
178
179
        /*==================================*/
180
        /* Author page sidebars start       */
181
        /*==================================*/
182
183 View Code Duplication
        if (get_option('geodir_show_author_top_section')) {
184
            register_sidebars(1, array('id' => 'geodir_author_top', 'name' => __('GD Author Top Section', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title));
185
186
            $geodir_sidebars[] = 'geodir_author_top';
187
        }
188
189 View Code Duplication
        if (get_option('geodir_show_author_left_section')) {
190
            register_sidebars(1, array('id' => 'geodir_author_left_sidebar', 'name' => __('GD Author Left Sidebar', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title));
191
192
            $geodir_sidebars[] = 'geodir_author_left_sidebar';
193
        }
194
195 View Code Duplication
        if (get_option('geodir_show_author_right_section')) {
196
            register_sidebars(1, array('id' => 'geodir_author_right_sidebar', 'name' => __('GD Author Right Sidebar', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title));
197
198
            $geodir_sidebars[] = 'geodir_author_right_sidebar';
199
        }
200
201 View Code Duplication
        if (get_option('geodir_show_author_bottom_section')) {
202
            register_sidebars(1, array('id' => 'geodir_author_bottom', 'name' => __('GD Author Bottom Section', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title));
203
204
            $geodir_sidebars[] = 'geodir_author_bottom';
205
        }
206
207
        /*==================================*/
208
        /* Author page sidebars end         */
209
        /*==================================*/
210
211
        /*==================================*/
212
        /* Add listing page sidebars start       */
213
        /*==================================*/
214
215
        register_sidebars(1, array('id' => 'geodir_add_listing_sidebar', 'name' => __('GD Add Listing Right Sidebar', 'geodirectory'), 'before_widget' => $before_widget, 'after_widget' => $after_widget, 'before_title' => $before_title, 'after_title' => $after_title));
216
217
        $geodir_sidebars[] = 'geodir_add_listing_sidebar';
218
219
        /*==================================*/
220
        /* Add listing page sidebars end         */
221
        /*==================================*/
222
223
    }
224
}
225
226
227
if (!function_exists('register_geodir_widgets')) {
228
    /**
229
     * Registers all Widgets.
230
     *
231
     * @since 1.0.0
232
     * @package GeoDirectory
233
     */
234
    function register_geodir_widgets()
235
    {
236
        /**
237
         * Login Widget.
238
         *
239
         * @since 1.0.0
240
         */
241
        class geodir_loginwidget extends WP_Widget
242
        {
243
            /**
244
             * Register the login widget with WordPress.
245
             *
246
             * @since 1.0.0
247
             * @since 1.5.1 Changed from PHP4 style constructors to PHP5 __construct.
248
             */
249
            public function __construct() {
250
                $widget_ops = array('classname' => 'geodir_loginbox', 'description' => __('Geodirectory Loginbox Widget', 'geodirectory'));
251
                parent::__construct(
252
                    'geodir_loginbox', // Base ID
253
                    __('GD > Loginbox', 'geodirectory'), // Name
254
                    $widget_ops// Args
255
                );
256
            }
257
258
            /**
259
             * Front-end display content for login widget.
260
             *
261
             * @since 1.0.0
262
             * @since 1.5.1 Declare function public.
263
             *
264
             * @param array $args     Widget arguments.
265
             * @param array $instance Saved values from database.
266
             */
267
            public function widget($args, $instance)
268
            {
269
                geodir_loginwidget_output($args, $instance);
270
            }
271
272
            /**
273
             * Sanitize login widget form values as they are saved.
274
             *
275
             * @since 1.0.0
276
             * @since 1.5.1 Declare function public.
277
             *
278
             * @param array $new_instance Values just sent to be saved.
279
             * @param array $old_instance Previously saved values from database.
280
             *
281
             * @return array Updated safe values to be saved.
282
             */
283
            public function update($new_instance, $old_instance)
284
            {
285
                //save the widget
286
                $instance = $old_instance;
287
                $instance['title'] = strip_tags($new_instance['title']);
288
289
                return $instance;
290
            }
291
292
            /**
293
             * Back-end login widget settings form.
294
             *
295
             * @since 1.0.0
296
             * @since 1.5.1 Declare function public.
297
             *
298
             * @param array $instance Previously saved values from database.
299
             * @return string|void
300
             */
301
            public function form($instance)
302
            {
303
                //widgetform in backend
304
                $instance = wp_parse_args((array)$instance, array('title' => '', 't1' => '', 't2' => '', 't3' => '', 'img1' => '', 'desc1' => ''));
305
                $title = strip_tags($instance['title']);
306
307
                ?>
308
                <p><label
309
                        for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Widget Title', 'geodirectory'); ?>
310
                        : <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>"
311
                                 name="<?php echo $this->get_field_name('title'); ?>" type="text"
312
                                 value="<?php echo esc_attr($title); ?>"/></label></p>
313
314
315
            <?php
316
            }
317
        }
318
319
        register_widget('geodir_loginwidget');
320
321
322
        /**
323
         * GeoDirectory Social Like Widget.
324
         *
325
         * @since 1.0.0
326
         */
327
        class geodir_social_like_widget extends WP_Widget
328
        {
329
330
            /**
331
             * Register the social like widget with WordPress.
332
             *
333
             * @since 1.0.0
334
             * @since 1.5.1 Changed from PHP4 style constructors to PHP5 __construct.
335
             */
336
            public function __construct() {
337
                $widget_ops = array('classname' => 'geodir_social_like_widget', 'description' => __('GD > Twitter,Facebook and Google+ buttons', 'geodirectory'));
338
                parent::__construct(
339
                    'social_like_widget', // Base ID
340
                    __('GD > Social Like', 'geodirectory'), // Name
341
                    $widget_ops// Args
342
                );
343
            }
344
345
            /**
346
             * Front-end display content for social like widget.
347
             *
348
             * @since 1.0.0
349
             * @since 1.5.1 Declare function public.
350
             *
351
             * @param array $args     Widget arguments.
352
             * @param array $instance Saved values from database.
353
             */
354
            public function widget($args, $instance)
355
            {
356
                // prints the widget
357
                extract($args, EXTR_SKIP);
358
359
                /**
360
                 * Filter the widget title text.
361
                 *
362
                 * @since 1.0.0
363
                 * @global object $current_user Current user object.
364
                 * @param string $title The widget title text.
365
                 */
366
                $title = empty($instance['title']) ? '&nbsp;' : apply_filters('widget_title', $instance['title']);
0 ignored issues
show
Unused Code introduced by
$title is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
367
368
                global $current_user, $post;
369
                echo $before_widget;
370
                ?>
371
372
                <?php //if ( get_option('gd_tweet_button') ) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
373
                ?>
374
375
                <a href="http://twitter.com/share"
376
                   class="twitter-share-button"><?php _e('Tweet', 'geodirectory');?></a>
377
378
                <script type="text/javascript" src="//platform.twitter.com/widgets.js"></script>
379
380
                <?php //}
381
                ?>
382
383
                <?php // if ( get_option('gd_facebook_button') ) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
54% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
384
                ?>
385
386 View Code Duplication
                <iframe <?php if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)) {
387
                    echo 'allowtransparency="true"';
388
                }?> class="facebook"
389
                    src="//www.facebook.com/plugins/like.php?href=<?php echo urlencode(geodir_curPageURL()); ?>&amp;layout=button_count&amp;show_faces=false&amp;width=100&amp;action=like&amp;colorscheme=light"
390
                    style="border:none; overflow:hidden; width:100px; height:20px"></iframe>
391
392
393
                <?php //}
394
                ?>
395
396
                <?php //if ( get_option('gd_google_button') ) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
397
                ?>
398
                <script>
399
                    window.___gcfg = {
400
                        parsetags: 'explicit'
401
                    }
402
                </script>
403
                <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
404
405
                <div id="plusone-div"></div>
406
                <script type="text/javascript">gapi.plusone.render('plusone-div', {
407
                        "size": "medium",
408
                        "count": "true"
409
                    });</script>
410
                <?php //}
411
                echo $after_widget;
412
413
            }
414
415
            /**
416
             * Sanitize social like widget form values as they are saved.
417
             *
418
             * @since 1.0.0
419
             * @since 1.5.1 Declare function public.
420
             *
421
             * @param array $new_instance Values just sent to be saved.
422
             * @param array $old_instance Previously saved values from database.
423
             *
424
             * @return array Updated safe values to be saved.
425
             */
426
            public function update($new_instance, $old_instance)
427
            {
428
                //save the widget
429
                $instance = $old_instance;
430
                $instance['title'] = strip_tags($new_instance['title']);
431
                return $instance;
432
            }
433
434
            /**
435
             * Back-end social like widget settings form.
436
             *
437
             * @since 1.0.0
438
             * @since 1.5.1 Declare function public.
439
             *
440
             * @param array $instance Previously saved values from database.
441
             * @return string|void
442
             */
443
            public function form($instance)
444
            {
445
                //widgetform in backend
446
                $instance = wp_parse_args((array)$instance, array('title' => ''));
447
                $title = strip_tags($instance['title']);
0 ignored issues
show
Unused Code introduced by
$title is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
448
                ?>
449
                <p>No settings for this widget</p>
450
451
452
            <?php
453
            }
454
        }
455
456
        register_widget('geodir_social_like_widget');
457
458
459
        /**
460
         * GeoDirectory Feedburner Subscribe widget.
461
         *
462
         * @since 1.0.0
463
         */
464
        class geodirsubscribeWidget extends WP_Widget
465
        {
466
467
            /**
468
             * Register the feedburner subscribe widget with WordPress.
469
             *
470
             * @since 1.0.0
471
             * @since 1.5.1 Changed from PHP4 style constructors to PHP5 __construct.
472
             */
473
            public function __construct() {
474
                $widget_ops = array('classname' => 'geodir-subscribe', 'description' => __('GD > Google Feedburner Subscribe', 'geodirectory'));
475
                parent::__construct(
476
                    'widget_subscribeWidget', // Base ID
477
                    __('GD > Subscribe', 'geodirectory'), // Name
478
                    $widget_ops// Args
479
                );
480
            }
481
482
            /**
483
             * Front-end display content for feedburner subscribe widget.
484
             *
485
             * @since 1.0.0
486
             * @since 1.5.1 Declare function public.
487
             *
488
             * @param array $args     Widget arguments.
489
             * @param array $instance Saved values from database.
490
             */
491
            public function widget($args, $instance)
492
            {
493
                // prints the widget
494
                extract($args, EXTR_SKIP);
495
496
                /**
497
                 * Filter the widget instance id.
498
                 *
499
                 * @since 1.0.0
500
                 * @param string $id The widget instance id.
501
                 */
502
                $id = empty($instance['id']) ? '' : apply_filters('widget_id', $instance['id']);
503
504
                /** This filter is documented in geodirectory_widgets.php */
505
                $title = empty($instance['title']) ? '' : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
506
507
                /**
508
                 * Filter the widget text.
509
                 *
510
                 * @since 1.0.0
511
                 * @param string $text The widget text.
512
                 */
513
                $text = empty($instance['text']) ? '' : apply_filters('widget_text', $instance['text']);
514
515
                echo $before_widget;
516
                ?>
517
518
                <?php echo $before_title . $title; ?>  <a href="<?php if ($id) {
519
                echo 'http://feeds2.feedburner.com/' . $id;
520
            } else {
521
                bloginfo('rss_url');
522
            } ?>"><i class="fa fa-rss-square"></i> </a><?php echo $after_title;?>
523
524
                <?php if ($text <> "") { ?>
525
526
                <p><?php echo $text; ?> </p>
527
528
            <?php } ?>
529
530
                <form class="geodir-subscribe-form" action="http://feedburner.google.com/fb/a/mailverify" method="post"
531
                      target="popupwindow"
532
                      onsubmit="window.open('http://feedburner.google.com/fb/a/mailverify?uri=<?php echo $id; ?>', 'popupwindow', 'scrollbars=yes,width=550,height=520');return true">
533
534
                    <input type="text" class="field"
535
                           onfocus="if (this.value == '<?php _e('Your Email Address', 'geodirectory')?>') {this.value = '';}"
536
                           onblur="if (this.value == '') {this.value = '<?php _e('Your Email Address', 'geodirectory')?>';}"
537
                           name="email" value="<?php _e('Your Email Address', 'geodirectory')?>"/>
538
539
                    <input type="hidden" value="<?php echo $id; ?>" name="uri"/><input type="hidden" name="loc"
540
                                                                                       value="en_US"/>
541
542
                    <input class="btn_submit" type="submit" name="submit" value="Submit"/>
543
544
                </form>
545
546
                <?php
547
                echo $after_widget;
548
549
            }
550
551
            /**
552
             * Sanitize feedburner subscribe widget form values as they are saved.
553
             *
554
             * @since 1.0.0
555
             * @since 1.5.1 Declare function public.
556
             *
557
             * @param array $new_instance Values just sent to be saved.
558
             * @param array $old_instance Previously saved values from database.
559
             *
560
             * @return array Updated safe values to be saved.
561
             */
562
            public function update($new_instance, $old_instance)
563
            {
564
565
                //save the widget
566
                $instance = $old_instance;
567
                $instance['id'] = strip_tags($new_instance['id']);
568
                $instance['title'] = ($new_instance['title']);
569
                $instance['text'] = ($new_instance['text']);
570
571
572
                return $instance;
573
            }
574
575
            /**
576
             * Back-end feedburner subscribe widget settings form.
577
             *
578
             * @since 1.0.0
579
             * @since 1.5.1 Declare function public.
580
             *
581
             * @param array $instance Previously saved values from database.
582
             * @return string|void
583
             */
584
            public function form($instance)
585
            {
586
                //widgetform in backend
587
                $instance = wp_parse_args((array)$instance, array('title' => '', 'id' => '', 'advt1' => '', 'text' => '', 'twitter' => '', 'facebook' => '', 'digg' => '', 'myspace' => ''));
588
589
                $id = strip_tags($instance['id']);
590
591
                $title = strip_tags($instance['title']);
592
593
                $text = strip_tags($instance['text']);
594
595
596
597
                ?>
598
                <p><label
599
                        for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title', 'geodirectory');?>:
600
                        <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>"
601
                               name="<?php echo $this->get_field_name('title'); ?>" type="text"
602
                               value="<?php echo esc_attr($title); ?>"/></label></p>
603
604
                <p><label
605
                        for="<?php echo $this->get_field_id('id'); ?>"><?php _e('Feedburner ID (ex :- geotheme)', 'geodirectory');?>
606
                        : <input class="widefat" id="<?php echo $this->get_field_id('id'); ?>"
607
                                 name="<?php echo $this->get_field_name('id'); ?>" type="text"
608
                                 value="<?php echo esc_attr($id); ?>"/></label></p>
609
610
                <p><label
611
                        for="<?php echo $this->get_field_id('text'); ?>"><?php _e('Short Description', 'geodirectory');?>
612
                        <textarea class="widefat" rows="6" cols="20" id="<?php echo $this->get_field_id('text'); ?>"
613
                                  name="<?php echo $this->get_field_name('text'); ?>"><?php echo esc_attr($text); ?></textarea></label>
614
                </p>
615
            <?php
616
            }
617
        }
618
619
        register_widget('geodirsubscribeWidget');
620
621
        /**
622
         * GeoDirectory advertise widget.
623
         *
624
         * @since 1.0.0
625
         */
626 View Code Duplication
        class geodiradvtwidget extends WP_Widget
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
627
        {
628
629
            /**
630
             * Register the advertise widget with WordPress.
631
             *
632
             * @since 1.0.0
633
             * @since 1.5.1 Changed from PHP4 style constructors to PHP5 __construct.
634
             */
635
            public function __construct() {
636
                $widget_ops = array('classname' => 'GeoDirectory Advertise', 'description' => __('GD > common advertise widget in sidebar, bottom section', 'geodirectory'));
637
                parent::__construct(
638
                    'advtwidget', // Base ID
639
                    __('GD > Advertise', 'geodirectory'), // Name
640
                    $widget_ops// Args
641
                );
642
            }
643
644
645
            /**
646
             * Front-end display content for advertise widget.
647
             *
648
             * @since 1.0.0
649
             * @since 1.5.1 Declare function public.
650
             *
651
             * @param array $args     Widget arguments.
652
             * @param array $instance Saved values from database.
653
             */
654
            public function widget($args, $instance)
655
            {
656
657
                // prints the widget
658
659
                extract($args, EXTR_SKIP);
660
661
                /**
662
                 * Filter the description text.
663
                 *
664
                 * @since 1.0.0
665
                 * @param string $desc1 The widget description text.
666
                 */
667
                $desc1 = empty($instance['desc1']) ? '&nbsp;' : apply_filters('widget_desc1', $instance['desc1']);
668
                echo $before_widget;
669
                ?>
670
                <?php if ($desc1 <> "") { ?>
671
                <?php echo $desc1; ?>
672
            <?php }
673
                echo $after_widget;
674
            }
675
676
            /**
677
             * Sanitize advertise widget form values as they are saved.
678
             *
679
             * @since 1.0.0
680
             * @since 1.5.1 Declare function public.
681
             *
682
             * @param array $new_instance Values just sent to be saved.
683
             * @param array $old_instance Previously saved values from database.
684
             *
685
             * @return array Updated safe values to be saved.
686
             */
687
            public function update($new_instance, $old_instance)
688
            {
689
                //save the widget
690
                $instance = $old_instance;
691
                $instance['desc1'] = ($new_instance['desc1']);
692
                return $instance;
693
            }
694
695
            /**
696
             * Back-end advertise widget settings form.
697
             *
698
             * @since 1.0.0
699
             * @since 1.5.1 Declare function public.
700
             *
701
             * @param array $instance Previously saved values from database.
702
             * @return string|void
703
             */
704
            public function form($instance)
705
            {
706
                //widgetform in backend
707
                $instance = wp_parse_args((array)$instance, array('title' => '', 't1' => '', 't2' => '', 't3' => '', 'img1' => '', 'desc1' => ''));
708
709
                $desc1 = ($instance['desc1']);
710
                ?>
711
                <p><label
712
                        for="<?php echo $this->get_field_id('desc1'); ?>"><?php _e('Your Advt code (ex.google adsense, etc.)', 'geodirectory');?>
713
                        <textarea class="widefat" rows="6" cols="20" id="<?php echo $this->get_field_id('desc1'); ?>"
714
                                  name="<?php echo $this->get_field_name('desc1'); ?>"><?php echo esc_attr($desc1); ?></textarea></label>
715
                </p>
716
717
            <?php
718
            }
719
        }
720
721
        register_widget('geodiradvtwidget');
722
723
        /**
724
         * GeoDirectory Flickr widget.
725
         *
726
         * @since 1.0.0
727
         */
728
        class GeodirFlickrWidget extends WP_Widget
729
        {
730
731
            /**
732
             * Register the flickr widget with WordPress.
733
             *
734
             * @since 1.0.0
735
             * @since 1.5.1 Changed from PHP4 style constructors to PHP5 __construct.
736
             */
737
            public function __construct() {
738
                $widget_ops = array('classname' => 'Geo Dir Flickr Photos ', 'description' => __('GD > Flickr Photos', 'geodirectory'));
739
                parent::__construct(
740
                    'widget_flickrwidget', // Base ID
741
                    __('GD > Flickr Photos', 'geodirectory'), // Name
742
                    $widget_ops// Args
743
                );
744
            }
745
746
            /**
747
             * Front-end display content for flickr widget.
748
             *
749
             * @since 1.0.0
750
             * @since 1.5.1 Declare function public.
751
             *
752
             * @param array $args     Widget arguments.
753
             * @param array $instance Saved values from database.
754
             */
755
            public function widget($args, $instance)
756
            {
757
758
                // prints the widget
759
                extract($args, EXTR_SKIP);
760
761
                echo $before_widget;
762
763
                /** This filter is documented in geodirectory_widgets.php */
764
                $id = empty($instance['id']) ? '&nbsp;' : apply_filters('widget_id', $instance['id']);
765
766
                /**
767
                 * Filter the widget number.
768
                 *
769
                 * This is used in the flicker widget to show how many images to show.
770
                 *
771
                 * @since 1.0.0
772
                 * @param string $number The image count.
773
                 */
774
                $number = empty($instance['number']) ? '&nbsp;' : apply_filters('widget_number', $instance['number']);
775
                echo $before_title . __('Photo Gallery', 'geodirectory') . $after_title;
776
                ?>
777
778
                <div class="geodir-flickr clearfix">
779
780
                    <script type="text/javascript"
781
                            src="https://www.flickr.com/badge_code_v2.gne?count=<?php echo $number; ?>&amp;display=latest&amp;size=s&amp;layout=x&amp;source=user&amp;user=<?php echo $id; ?>"></script>
782
783
                </div>
784
785
786
                <?php echo $after_widget;
787
            }
788
789
            /**
790
             * Sanitize flickr widget form values as they are saved.
791
             *
792
             * @since 1.0.0
793
             * @since 1.5.1 Declare function public.
794
             *
795
             * @param array $new_instance Values just sent to be saved.
796
             * @param array $old_instance Previously saved values from database.
797
             *
798
             * @return array Updated safe values to be saved.
799
             */
800 View Code Duplication
            public function update($new_instance, $old_instance)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
801
            {
802
                //save the widget
803
                $instance = $old_instance;
804
                $instance['id'] = strip_tags($new_instance['id']);
805
                $instance['number'] = strip_tags($new_instance['number']);
806
                return $instance;
807
            }
808
809
            /**
810
             * Back-end flickr widget settings form.
811
             *
812
             * @since 1.0.0
813
             * @since 1.5.1 Declare function public.
814
             *
815
             * @param array $instance Previously saved values from database.
816
             * @return string|void
817
             */
818
            public function form($instance)
819
            {
820
821
                //widgetform in backend
822
                $instance = wp_parse_args((array)$instance, array('title' => '', 'id' => '', 'number' => ''));
823
                $id = strip_tags($instance['id']);
824
                $number = strip_tags($instance['number']);
825
                ?>
826
827
                <p>
828
                    <label
829
                        for="<?php echo $this->get_field_id('id'); ?>"><?php _e('Flickr ID', 'geodirectory');?>
830
                        (<a href="http://www.idgettr.com">idGettr</a>):
831
                        <input class="widefat" id="<?php echo $this->get_field_id('id'); ?>"
832
                               name="<?php echo $this->get_field_name('id'); ?>" type="text"
833
                               value="<?php echo esc_attr($id); ?>"/>
834
                    </label>
835
                </p>
836
837
                <p>
838
                    <label
839
                        for="<?php echo $this->get_field_id('number'); ?>"><?php _e('Number of photos:', 'geodirectory');?>
840
                        <input class="widefat" id="<?php echo $this->get_field_id('number'); ?>"
841
                               name="<?php echo $this->get_field_name('number'); ?>" type="text"
842
                               value="<?php echo esc_attr($number); ?>"/>
843
                    </label>
844
                </p>
845
            <?php
846
            }
847
        }
848
849
        register_widget('GeodirFlickrWidget');
850
851
        /**
852
         * GeoDirectory Twitter widget.
853
         *
854
         * @since 1.0.0
855
         */
856 View Code Duplication
        class geodir_twitter extends WP_Widget
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
857
        {
858
            /**
859
             * Register the Twitter widget with WordPress.
860
             *
861
             * @since 1.0.0
862
             * @since 1.5.1 Changed from PHP4 style constructors to PHP5 __construct.
863
             */
864
            public function __construct() {
865
                $widget_ops = array('classname' => 'Twitter', 'description' => __('GD > Twitter Feed', 'geodirectory'));
866
                parent::__construct(
867
                    'widget_Twidget', // Base ID
868
                    __('GD > Twitter', 'geodirectory'), // Name
869
                    $widget_ops// Args
870
                );
871
            }
872
873
874
            /**
875
             * Front-end display content for Twitter widget.
876
             *
877
             * @since 1.0.0
878
             * @since 1.5.1 Declare function public.
879
             *
880
             * @param array $args     Widget arguments.
881
             * @param array $instance Saved values from database.
882
             */
883
            public function widget($args, $instance)
884
            {
885
886
                // prints the widget
887
888
                extract($args, EXTR_SKIP);
889
890
                /**
891
                 * Filter the twitter widget description text.
892
                 *
893
                 * @since 1.0.0
894
                 * @param string $desc1 The widget description text.
895
                 */
896
                $desc1 = empty($instance['gd_tw_desc1']) ? '&nbsp;' : apply_filters('gd_tw_widget_desc1', $instance['gd_tw_desc1']);
897
                echo $before_widget;
898
                if ($desc1 <> "") {
899
                    echo $desc1;
900
                }
901
                echo $after_widget;
902
            }
903
904
            /**
905
             * Sanitize twitter widget form values as they are saved.
906
             *
907
             * @since 1.0.0
908
             * @since 1.5.1 Declare function public.
909
             *
910
             * @param array $new_instance Values just sent to be saved.
911
             * @param array $old_instance Previously saved values from database.
912
             *
913
             * @return array Updated safe values to be saved.
914
             */
915
            public function update($new_instance, $old_instance)
916
            {
917
                //save the widget
918
                $instance = $old_instance;
919
                $instance['gd_tw_desc1'] = ($new_instance['gd_tw_desc1']);
920
                return $instance;
921
            }
922
923
            /**
924
             * Back-end twitter widget settings form.
925
             *
926
             * @since 1.0.0
927
             * @since 1.5.1 Declare function public.
928
             *
929
             * @param array $instance Previously saved values from database.
930
             * @return string|void
931
             */
932
            public function form($instance)
933
            {
934
                //widgetform in backend
935
                $instance = wp_parse_args((array)$instance, array('title' => '', 't1' => '', 't2' => '', 't3' => '', 'img1' => '', 'gd_tw_desc1' => ''));
936
937
                $desc1 = ($instance['gd_tw_desc1']);
938
                ?>
939
                <p><label
940
                        for="<?php echo $this->get_field_id('gd_tw_desc1'); ?>"><?php _e('Your twitter code', 'geodirectory');?>
941
                        <textarea class="widefat" rows="6" cols="20"
942
                                  id="<?php echo $this->get_field_id('gd_tw_desc1'); ?>"
943
                                  name="<?php echo $this->get_field_name('gd_tw_desc1'); ?>"><?php echo esc_attr($desc1); ?></textarea></label>
944
                </p>
945
946
            <?php
947
            }
948
        }
949
950
        register_widget('geodir_twitter');
951
952
        /**
953
         * GeoDirectory Advanced Search widget.
954
         *
955
         * @since 1.0.0
956
         */
957
        class geodir_advance_search_widget extends WP_Widget
958
        {
959
            /**
960
             * Register the advanced search widget with WordPress.
961
             *
962
             * @since 1.0.0
963
             * @since 1.5.1 Changed from PHP4 style constructors to PHP5 __construct.
964
             */
965 View Code Duplication
            public function __construct() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
966
                $widget_ops = array('classname' => 'geodir_advance_search_widget', 'description' => __('GD > Search', 'geodirectory'),'post_type'=>'');
967
                parent::__construct(
968
                    'geodir_advance_search', // Base ID
969
                    __('GD > Search', 'geodirectory'), // Name
970
                    $widget_ops// Args
971
                );
972
            }
973
974
975
            /**
976
             * Front-end display content for advanced search widget.
977
             *
978
             * @since 1.0.0
979
             * @since 1.5.1 Declare function public.
980
             *
981
             * @param array $args     Widget arguments.
982
             * @param array $instance Saved values from database.
983
             */
984
            public function widget($args, $instance)
985
            {
986
                /**
987
                 * Filter the search widget arguments.
988
                 *
989
                 * @since 1.5.7
990
                 * @param array $args The widget arguments.
991
                 * @param array $instance The widget instance.
992
                 */
993
                $args = apply_filters('widget_geodir_advance_search_args',$args,$instance);
994
995
                // prints the widget
996
                extract($args, EXTR_SKIP);
997
998
                if(isset($post_type) && $post_type){
999
                    geodir_get_search_post_type($post_type);// set the post type
1000
                }else{
1001
                    geodir_get_search_post_type();// set the post type
1002
                }
1003
1004
                echo $before_widget;
1005
1006
                /** This filter is documented in geodirectory_widgets.php */
1007
                $title = empty($instance['title']) ? __('Search', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
0 ignored issues
show
Unused Code introduced by
$title is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
1008
1009
                geodir_get_template_part('listing', 'filter-form');
1010
1011
                echo $after_widget;
1012
1013
                // after outputing the search reset the CPT
1014
                global $geodir_search_post_type;
1015
                $geodir_search_post_type = '';
1016
            }
1017
1018
            /**
1019
             * Sanitize advanced search widget form values as they are saved.
1020
             *
1021
             * @since 1.0.0
1022
             * @since 1.5.1 Declare function public.
1023
             *
1024
             * @param array $new_instance Values just sent to be saved.
1025
             * @param array $old_instance Previously saved values from database.
1026
             *
1027
             * @return array Updated safe values to be saved.
1028
             */
1029
            public function update($new_instance, $old_instance)
1030
            {
1031
                //save the widget
1032
                //Nothing to save
1033
                return isset($instance) ? $instance : array();
0 ignored issues
show
Bug introduced by
The variable $instance does not exist. Did you mean $new_instance?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
1034
            }
1035
1036
            /**
1037
             * Back-end advanced search widget settings form.
1038
             *
1039
             * @since 1.0.0
1040
             * @since 1.5.1 Declare function public.
1041
             *
1042
             * @param array $instance Previously saved values from database.
1043
             * @return string|void
1044
             */
1045
            public function form($instance)
1046
            {
1047
                //widgetform in backend
1048
                echo __("This is a search widget to show advance search for gedodirectory listings.", 'geodirectory');
1049
            }
1050
        }
1051
1052
        register_widget('geodir_advance_search_widget');
1053
1054
1055
        /**
1056
         * Contains all functions for popular widget.
1057
         *
1058
         * @since 1.0.0
1059
         * @package GeoDirectory
1060
         */
1061
        include_once('geodirectory-widgets/geodirectory_popular_widget.php');
1062
        /**
1063
         * Contains all functions for listing slider widget.
1064
         *
1065
         * @since 1.0.0
1066
         * @package GeoDirectory
1067
         */
1068
        include_once('geodirectory-widgets/geodirectory_listing_slider_widget.php');
1069
        /**
1070
         * Contains all functions for home map widget.
1071
         *
1072
         * @since 1.0.0
1073
         * @package GeoDirectory
1074
         */
1075
        include_once('geodirectory-widgets/home_map_widget.php');
1076
        /**
1077
         * Contains all functions for listing map widget.
1078
         *
1079
         * @since 1.0.0
1080
         * @package GeoDirectory
1081
         */
1082
        include_once('geodirectory-widgets/listing_map_widget.php');
1083
        /**
1084
         * Contains all functions for reviews widget.
1085
         *
1086
         * @since 1.0.0
1087
         * @package GeoDirectory
1088
         */
1089
        include_once('geodirectory-widgets/geodirectory_reviews_widget.php');
1090
        /**
1091
         * Contains all functions for related listing widget.
1092
         *
1093
         * @since 1.0.0
1094
         * @package GeoDirectory
1095
         */
1096
        include_once('geodirectory-widgets/geodirectory_related_listing_widget.php');
1097
        /**
1098
         * Contains all functions for bestof widget.
1099
         *
1100
         * @since 1.0.0
1101
         * @package GeoDirectory
1102
         */
1103
        include_once('geodirectory-widgets/geodirectory_bestof_widget.php');
1104
		/**
1105
         * Contains all functions for cpt categories widget.
1106
         *
1107
         * @since 1.5.4
1108
         * @package GeoDirectory
1109
         */
1110
        include_once('geodirectory-widgets/geodirectory_cpt_categories_widget.php');
1111
        /**
1112
         * Contains all functions for features widget.
1113
         *
1114
         * @since 1.5.6
1115
         * @package GeoDirectory
1116
         * @todo make the image field recurring
1117
         */
1118
        include_once('geodirectory-widgets/geodirectory_features_widget.php');
1119
    }
1120
1121
}
1122
1123
1124