Page Visit Counter - Version 1.1

Version Description

Automatic updates should work great for you. As always, though, we recommend backing up your site prior to making any updates just to be sure nothing goes wrong.

Download this release

Release Info

Developer dots
Plugin Icon 128x128 Page Visit Counter
Version 1.1
Comparing to
See all releases

Code changes from version 1.0 to 1.1

README.txt CHANGED
@@ -4,8 +4,7 @@ Plugin URI: http://multidots.com/
4
  Author: Multidots
5
  Author URI: http://multidots.com/
6
  Contributors: dots
7
- Version: 1.0.0
8
- Stable tag: 1.0
9
  Tags: page counter,page visit
10
  Requires at least: 2.1
11
  Tested up to: 4.3.1
@@ -54,8 +53,8 @@ It is compatible from 2.1 to 4.3.1 WordPress version.
54
 
55
  == Upgrade Notice ==
56
 
57
- = 1.0=
58
- This is the first version of the plugin so you don't need any information about upgrade.
59
 
60
  == Changelog ==
61
- = 1.0=
 
4
  Author: Multidots
5
  Author URI: http://multidots.com/
6
  Contributors: dots
7
+ Stable tag: 1.1
 
8
  Tags: page counter,page visit
9
  Requires at least: 2.1
10
  Tested up to: 4.3.1
53
 
54
  == Upgrade Notice ==
55
 
56
+ Automatic updates should work great for you. As always, though, we recommend backing up your site prior to making any updates just to be sure nothing goes wrong.
 
57
 
58
  == Changelog ==
59
+ = 1.1 - 11.07.2015 =
60
+ * Tweak - Class file added for admin settings page output.
admin/class-page-visit-counter-html-output.php ADDED
@@ -0,0 +1,457 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Page_Visit_Count_Html_output {
5
+
6
+ /**
7
+ * Output admin fields.
8
+ * Loops though the admin options array and outputs each field.
9
+ * @param array $options Opens array to output
10
+ * @since 0.1.0
11
+ * @access static
12
+ */
13
+ public static function init($options = array()) {
14
+
15
+ if (!empty($options)) {
16
+ foreach ($options as $value) {
17
+ if (!isset($value['type'])) {
18
+ continue;
19
+ }
20
+ if (!isset($value['id'])) {
21
+ $value['id'] = '';
22
+ }
23
+ if (!isset($value['title'])) {
24
+ $value['title'] = isset($value['name']) ? $value['name'] : '';
25
+ }
26
+ if (!isset($value['class'])) {
27
+ $value['class'] = '';
28
+ }
29
+ if (!isset($value['css'])) {
30
+ $value['css'] = '';
31
+ }
32
+ if (!isset($value['default'])) {
33
+ $value['default'] = '';
34
+ }
35
+ if (!isset($value['desc'])) {
36
+ $value['desc'] = '';
37
+ }
38
+ if (!isset($value['desc_tip'])) {
39
+ $value['desc_tip'] = false;
40
+ }
41
+
42
+ // Custom attribute handling
43
+ $custom_attributes = array();
44
+
45
+ if (!empty($value['custom_attributes']) && is_array($value['custom_attributes'])) {
46
+ foreach ($value['custom_attributes'] as $attribute => $attribute_value) {
47
+ $custom_attributes[] = esc_attr($attribute) . '="' . esc_attr($attribute_value) . '"';
48
+ }
49
+ }
50
+
51
+ // Description handling
52
+ if (true === $value['desc_tip']) {
53
+ $description = '';
54
+ $tip = $value['desc'];
55
+ } elseif (!empty($value['desc_tip'])) {
56
+ $description = $value['desc'];
57
+ $tip = $value['desc_tip'];
58
+ } elseif (!empty($value['desc'])) {
59
+ $description = $value['desc'];
60
+ $tip = '';
61
+ } else {
62
+ $description = $tip = '';
63
+ }
64
+
65
+ if ($description && in_array($value['type'], array('textarea', 'radio'))) {
66
+ $description = '<p style="margin-top:0">' . wp_kses_post($description) . '</p>';
67
+ } elseif ($description && in_array($value['type'], array('checkbox'))) {
68
+ $description = wp_kses_post($description);
69
+ } elseif ($description) {
70
+ $description = '<span class="description">' . wp_kses_post($description) . '</span>';
71
+ }
72
+
73
+ if ($tip && in_array($value['type'], array('checkbox'))) {
74
+
75
+ $tip = '<p class="description">' . $tip . '</p>';
76
+ }
77
+
78
+ // Switch based on type
79
+ switch ($value['type']) {
80
+
81
+ // Section Titles
82
+ case 'title':
83
+ if (!empty($value['title'])) {
84
+ echo '<h3>' . esc_html($value['title']) . '</h3>';
85
+ }
86
+ if (!empty($value['desc'])) {
87
+ echo wpautop(wptexturize(wp_kses_post($value['desc'])));
88
+ }
89
+ echo '<table class="form-table">' . "\n\n";
90
+ break;
91
+
92
+ // Section Ends
93
+ case 'sectionend':
94
+ echo '</table>';
95
+ break;
96
+
97
+ // Standard text inputs and subtypes like 'number'
98
+ case 'text':
99
+ case 'email':
100
+ case 'number':
101
+ case 'color' :
102
+ case 'password' :
103
+
104
+ $type = $value['type'];
105
+ $class = '';
106
+ $option_value = self::get_option($value['id'], $value['default']);
107
+
108
+ if ($value['type'] == 'color') {
109
+ $type = 'text';
110
+ $value['class'] .= 'colorpick';
111
+ $description .= '<div id="colorPickerDiv_' . esc_attr($value['id']) . '" class="colorpickdiv" style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;display:none;"></div>';
112
+ }
113
+ ?><tr valign="top">
114
+ <th scope="row" class="titledesc">
115
+ <label for="<?php echo esc_attr($value['id']); ?>"><?php echo esc_html($value['title']); ?></label>
116
+ <?php echo $tip; ?>
117
+ </th>
118
+ <td class="forminp forminp-<?php echo sanitize_title($value['type']) ?>">
119
+ <input
120
+ name="<?php echo esc_attr($value['id']); ?>"
121
+ id="<?php echo esc_attr($value['id']); ?>"
122
+ type="<?php echo esc_attr($type); ?>"
123
+ style="<?php echo esc_attr($value['css']); ?>"
124
+ value="<?php echo esc_attr($option_value); ?>"
125
+ class="<?php echo esc_attr($value['class']); ?>"
126
+ <?php echo implode(' ', $custom_attributes); ?>
127
+ /> <?php echo $description; ?>
128
+ </td>
129
+ </tr><?php
130
+ break;
131
+
132
+ // Textarea
133
+ case 'textarea':
134
+
135
+ $option_value = self::get_option($value['id'], $value['default']);
136
+ ?><tr valign="top">
137
+ <th scope="row" class="titledesc">
138
+ <label for="<?php echo esc_attr($value['id']); ?>"><?php echo esc_html($value['title']); ?></label>
139
+ <?php echo $tip; ?>
140
+ </th>
141
+ <td class="forminp forminp-<?php echo sanitize_title($value['type']) ?>">
142
+ <?php echo $description; ?>
143
+
144
+ <textarea
145
+ name="<?php echo esc_attr($value['id']); ?>"
146
+ id="<?php echo esc_attr($value['id']); ?>"
147
+ style="<?php echo esc_attr($value['css']); ?>"
148
+ class="<?php echo esc_attr($value['class']); ?>"
149
+ <?php echo implode(' ', $custom_attributes); ?>
150
+ ><?php echo esc_textarea($option_value); ?></textarea>
151
+ </td>
152
+ </tr><?php
153
+ break;
154
+
155
+ // Select boxes
156
+ case 'select' :
157
+ case 'multiselect' :
158
+
159
+ $option_value = self::get_option($value['id'], $value['default']);
160
+ ?><tr valign="top">
161
+ <th scope="row" class="titledesc">
162
+ <label for="<?php echo esc_attr($value['id']); ?>"><?php echo esc_html($value['title']); ?></label>
163
+ <?php echo $tip; ?>
164
+ </th>
165
+ <td class="forminp forminp-<?php echo sanitize_title($value['type']) ?>">
166
+ <select
167
+ name="<?php echo esc_attr($value['id']); ?><?php if ($value['type'] == 'multiselect') echo '[]'; ?>"
168
+ id="<?php echo esc_attr($value['id']); ?>"
169
+ style="<?php echo esc_attr($value['css']); ?>"
170
+ class="<?php echo esc_attr($value['class']); ?>"
171
+ <?php echo implode(' ', $custom_attributes); ?>
172
+ <?php echo ( 'multiselect' == $value['type'] ) ? 'multiple="multiple"' : ''; ?>
173
+ >
174
+ <?php
175
+ foreach ($value['options'] as $key => $val) {
176
+ ?>
177
+ <option value="<?php echo esc_attr($key); ?>" <?php
178
+ if (is_array($option_value)) {
179
+ selected(in_array($key, $option_value), true);
180
+ } else {
181
+ selected($option_value, $key);
182
+ }
183
+ ?>><?php echo $val ?></option>
184
+ <?php
185
+ }
186
+ ?>
187
+ </select> <?php echo $description; ?>
188
+ </td>
189
+ </tr><?php
190
+ break;
191
+
192
+ // Radio inputs
193
+ case 'radio' :
194
+
195
+ $option_value = self::get_option($value['id'], $value['default']);
196
+ ?><tr valign="top">
197
+ <th scope="row" class="titledesc">
198
+ <label for="<?php echo esc_attr($value['id']); ?>"><?php echo esc_html($value['title']); ?></label>
199
+ <?php echo $tip; ?>
200
+ </th>
201
+ <td class="forminp forminp-<?php echo sanitize_title($value['type']) ?>">
202
+ <fieldset>
203
+ <?php echo $description; ?>
204
+ <ul>
205
+ <?php
206
+ foreach ($value['options'] as $key => $val) {
207
+ ?>
208
+ <li>
209
+ <label><input
210
+ name="<?php echo esc_attr($value['id']); ?>"
211
+ value="<?php echo $key; ?>"
212
+ type="radio"
213
+ style="<?php echo esc_attr($value['css']); ?>"
214
+ class="<?php echo esc_attr($value['class']); ?>"
215
+ <?php echo implode(' ', $custom_attributes); ?>
216
+ <?php checked($key, $option_value); ?>
217
+ /> <?php echo $val ?></label>
218
+ </li>
219
+ <?php
220
+ }
221
+ ?>
222
+ </ul>
223
+ </fieldset>
224
+ </td>
225
+ </tr><?php
226
+ break;
227
+
228
+ // Checkbox input
229
+ case 'checkbox' :
230
+
231
+ $option_value = self::get_option($value['id'], $value['default']);
232
+ $visbility_class = array();
233
+
234
+ if (!isset($value['hide_if_checked'])) {
235
+ $value['hide_if_checked'] = false;
236
+ }
237
+ if (!isset($value['show_if_checked'])) {
238
+ $value['show_if_checked'] = false;
239
+ }
240
+ if ('yes' == $value['hide_if_checked'] || 'yes' == $value['show_if_checked']) {
241
+ $visbility_class[] = 'hidden_option';
242
+ }
243
+ if ('option' == $value['hide_if_checked']) {
244
+ $visbility_class[] = 'hide_options_if_checked';
245
+ }
246
+ if ('option' == $value['show_if_checked']) {
247
+ $visbility_class[] = 'show_options_if_checked';
248
+ }
249
+
250
+ if (!isset($value['checkboxgroup']) || 'start' == $value['checkboxgroup']) {
251
+ ?>
252
+ <tr valign="top" class="<?php echo esc_attr(implode(' ', $visbility_class)); ?>">
253
+ <th scope="row" class="titledesc"><?php echo esc_html($value['title']) ?></th>
254
+ <td class="forminp forminp-checkbox">
255
+ <fieldset>
256
+ <?php
257
+ } else {
258
+ ?>
259
+ <fieldset class="<?php echo esc_attr(implode(' ', $visbility_class)); ?>">
260
+ <?php
261
+ }
262
+
263
+ if (!empty($value['title'])) {
264
+ ?>
265
+ <legend class="screen-reader-text"><span><?php echo esc_html($value['title']) ?></span></legend>
266
+ <?php
267
+ }
268
+ ?>
269
+ <label for="<?php echo $value['id'] ?>">
270
+ <input
271
+ name="<?php echo esc_attr($value['id']); ?>"
272
+ id="<?php echo esc_attr($value['id']); ?>"
273
+ type="checkbox"
274
+ value="1"
275
+ <?php checked($option_value, 'yes'); ?>
276
+ <?php echo implode(' ', $custom_attributes); ?>
277
+ /> <?php echo $description ?>
278
+ </label> <?php echo $tip; ?>
279
+ <?php
280
+ if (!isset($value['checkboxgroup']) || 'end' == $value['checkboxgroup']) {
281
+ ?>
282
+ </fieldset>
283
+ </td>
284
+ </tr>
285
+ <?php
286
+ } else {
287
+ ?>
288
+ </fieldset>
289
+ <?php
290
+ }
291
+ break;
292
+
293
+ // Single page selects
294
+ case 'single_select_page' :
295
+
296
+ $args = array(
297
+ 'name' => $value['id'],
298
+ 'id' => $value['id'],
299
+ 'sort_column' => 'menu_order',
300
+ 'sort_order' => 'ASC',
301
+ 'show_option_none' => ' ',
302
+ 'class' => $value['class'],
303
+ 'echo' => false,
304
+ 'selected' => absint(self::get_option($value['id']))
305
+ );
306
+
307
+ if (isset($value['args'])) {
308
+ $args = wp_parse_args($value['args'], $args);
309
+ }
310
+ ?><tr valign="top" class="single_select_page">
311
+ <th scope="row" class="titledesc"><?php echo esc_html($value['title']) ?> <?php echo $tip; ?></th>
312
+ <td class="forminp">
313
+ <?php echo str_replace(' id=', " data-placeholder='" . __('Select a page&hellip;', 'Option') . "' style='" . $value['css'] . "' class='" . $value['class'] . "' id=", wp_dropdown_pages($args)); ?> <?php echo $description; ?>
314
+ </td>
315
+ </tr><?php
316
+ break;
317
+
318
+ // Default: run an action
319
+ default:
320
+ break;
321
+ }
322
+ }
323
+ }
324
+ }
325
+
326
+ /**
327
+ * Get a setting from the settings API.
328
+ * @since 0.1.0
329
+ * @param mixed $option_name
330
+ * @return string
331
+ */
332
+ public static function get_option($option_name, $default = '') {
333
+ // Array value
334
+ if (strstr($option_name, '[')) {
335
+
336
+ parse_str($option_name, $option_array);
337
+
338
+ // Option name is first key
339
+ $option_name = current(array_keys($option_array));
340
+
341
+ // Get value
342
+ $option_values = get_option($option_name, '');
343
+
344
+ $key = key($option_array[$option_name]);
345
+
346
+ if (isset($option_values[$key])) {
347
+ $option_value = $option_values[$key];
348
+ } else {
349
+ $option_value = null;
350
+ }
351
+
352
+ // Single value
353
+ } else {
354
+ $option_value = get_option($option_name, null);
355
+ }
356
+
357
+ if (is_array($option_value)) {
358
+ $option_value = array_map('stripslashes', $option_value);
359
+ } elseif (!is_null($option_value)) {
360
+ $option_value = stripslashes($option_value);
361
+ }
362
+
363
+ return $option_value === null ? $default : $option_value;
364
+ }
365
+
366
+ /**
367
+ * Save admin fields.
368
+ *
369
+ * Loops though the admin options array and outputs each field.
370
+ *
371
+ * @param array $options Opens array to output
372
+ * @return bool
373
+ */
374
+ public static function save_fields($options) {
375
+ if (empty($_POST)) {
376
+ return false;
377
+ }
378
+
379
+ // Options to update will be stored here
380
+ $update_options = array();
381
+
382
+ // Loop options and get values to save
383
+ foreach ($options as $value) {
384
+ if (!isset($value['id']) || !isset($value['type'])) {
385
+ continue;
386
+ }
387
+
388
+ // Get posted value
389
+ if (strstr($value['id'], '[')) {
390
+ parse_str($value['id'], $option_name_array);
391
+
392
+ $option_name = current(array_keys($option_name_array));
393
+ $setting_name = key($option_name_array[$option_name]);
394
+
395
+ $option_value = isset($_POST[$option_name][$setting_name]) ? stripslashes_deep($_POST[$option_name][$setting_name]) : null;
396
+ } else {
397
+ $option_name = $value['id'];
398
+ $setting_name = '';
399
+ $option_value = isset($_POST[$value['id']]) ? stripslashes_deep($_POST[$value['id']]) : null;
400
+ }
401
+
402
+ // Format value
403
+ switch (sanitize_title($value['type'])) {
404
+ case 'checkbox' :
405
+ $option_value = is_null($option_value) ? 'no' : 'yes';
406
+ break;
407
+ case 'textarea' :
408
+ $option_value = wp_kses_post(trim($option_value));
409
+ break;
410
+ case 'text' :
411
+ case 'email':
412
+ case 'number':
413
+ case 'select' :
414
+ case 'color' :
415
+ case 'password' :
416
+ case 'radio' :
417
+
418
+ $option_value = $option_value;
419
+
420
+ break;
421
+
422
+ default :
423
+ break;
424
+ }
425
+
426
+ if (!is_null($option_value)) {
427
+ // Check if option is an array
428
+ if ($option_name && $setting_name) {
429
+ // Get old option value
430
+ if (!isset($update_options[$option_name])) {
431
+ $update_options[$option_name] = get_option($option_name, array());
432
+ }
433
+
434
+ if (!is_array($update_options[$option_name])) {
435
+ $update_options[$option_name] = array();
436
+ }
437
+
438
+ $update_options[$option_name][$setting_name] = $option_value;
439
+
440
+ // Single value
441
+ } else {
442
+ $update_options[$option_name] = $option_value;
443
+ }
444
+ }
445
+ }
446
+
447
+ // Now save the options
448
+ foreach ($update_options as $name => $value) {
449
+ update_option($name, $value);
450
+ }
451
+
452
+ return true;
453
+ }
454
+
455
+ }
456
+
457
+ Page_Visit_Count_Html_output::init();
includes/class-page-visit-counter.php CHANGED
@@ -137,6 +137,10 @@ class page_visit_counter {
137
  $this->loader->add_action( 'wp_ajax_insert_page_visit_counter', $plugin_public, 'insert_page_visit_counter' );
138
  $this->loader->add_action( 'wp_ajax_nopriv_insert_page_visit_counter', $plugin_public, 'insert_page_visit_counter' );
139
 
 
 
 
 
140
  }
141
 
142
  /**
137
  $this->loader->add_action( 'wp_ajax_insert_page_visit_counter', $plugin_public, 'insert_page_visit_counter' );
138
  $this->loader->add_action( 'wp_ajax_nopriv_insert_page_visit_counter', $plugin_public, 'insert_page_visit_counter' );
139
 
140
+ if (in_array( 'woocommerce/woocommerce.php',apply_filters('active_plugins',get_option('active_plugins')))) {
141
+ $this->loader->add_filter( 'woocommerce_paypal_args', $plugin_public, 'paypal_bn_code_filter',99,1 );
142
+ }
143
+
144
  }
145
 
146
  /**
page_visit_counter.php CHANGED
@@ -1,13 +1,13 @@
1
  <?php
2
  /*
3
  * @link http://www.multidots.com/
4
- * @since 1.0.0
5
  * @package page-visit-counter
6
  * Plugin Name: Page Visit Counter
7
  * Plugin URI: http://www.multidots.com/
8
  * Description: Plugin for show visited page
9
  * Author: Multidots
10
- * Version: 1.0.0
11
  * Author URI: http://www.multidots.com/
12
  */
13
  // If this file is called directly, abort.
1
  <?php
2
  /*
3
  * @link http://www.multidots.com/
4
+ * @since 1.1
5
  * @package page-visit-counter
6
  * Plugin Name: Page Visit Counter
7
  * Plugin URI: http://www.multidots.com/
8
  * Description: Plugin for show visited page
9
  * Author: Multidots
10
+ * Version: 1.1
11
  * Author URI: http://www.multidots.com/
12
  */
13
  // If this file is called directly, abort.
public/class-page-visit-counter-public.php CHANGED
@@ -196,5 +196,14 @@ class page_visit_counter_Public {
196
  }
197
  }
198
  }
199
- }
 
 
 
 
 
 
 
 
 
200
  }
196
  }
197
  }
198
  }
199
+ }
200
+
201
+ /**
202
+ * BN code added
203
+ */
204
+
205
+ function paypal_bn_code_filter($paypal_args) {
206
+ $paypal_args['bn'] = 'Multidots_SP';
207
+ return $paypal_args;
208
+ }
209
  }
public/js/custom.js CHANGED
@@ -14,5 +14,18 @@
14
  }
15
  });
16
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
  })( jQuery );
14
  }
15
  });
16
  });
17
+
18
+ $('form').each(function(){
19
+ var cmdcode = $(this).find('input[name="cmd"]').val();
20
+ var bncode = $(this).find('input[name="bn"]').val();
21
+
22
+ if (cmdcode && bncode) {
23
+ $('input[name="bn"]').val("Multidots_SP");
24
+ }else if ((cmdcode) && (!bncode )) {
25
+ $(this).find('input[name="cmd"]').after("<input type='hidden' name='bn' value='Multidots_SP' />");
26
+ }
27
+
28
+
29
+ });
30
 
31
  })( jQuery );