WP Hide Post - Version 2.0.6

Version Description

Release Date - 31 July 2017

Fix: post was not hiding if the static page was selected as homepage Fix: Compatibility with old version of PHP

Download this release

Release Info

Developer rmahfoud
Plugin Icon wp plugin WP Hide Post
Version 2.0.6
Comparing to
See all releases

Code changes from version 1.2.0 to 2.0.6

Files changed (57) hide show
  1. admin/class-wp-hide-post-admin.php +1141 -0
  2. admin/class-wp-hide-post-dbupdate.php +203 -0
  3. admin/conditions.php +152 -0
  4. admin/css/wp-hide-post-admin.css +63 -0
  5. admin/index.php +1 -0
  6. admin/js/wp-hide-post-admin.js +242 -0
  7. admin/license/LicenseItem.php +722 -0
  8. admin/license/LicenseManager.php +59 -0
  9. admin/license/autoload.php +17 -0
  10. admin/license/encryption.php +85 -0
  11. admin/partials/metabox_page_edit-display.php +38 -0
  12. admin/partials/notice-display.php +8 -0
  13. admin/partials/quick-edit-display.php +9 -0
  14. admin/plugin/EDD_SL_Plugin_Updater.php +387 -0
  15. admin/plugin/EDD_SL_Theme_Updater.php +142 -0
  16. admin/plugin/SCB_Item_Helper.php +190 -0
  17. admin/plugin/autoload.php +15 -0
  18. admin/plugin/testlog.txt +14 -0
  19. admin/settings/assets/chosen-sprite.png +0 -0
  20. admin/settings/assets/chosen-sprite@2x.png +0 -0
  21. admin/settings/assets/chosen.jquery.min.js +2 -0
  22. admin/settings/assets/chosen.min.css +3 -0
  23. admin/settings/autoload.php +277 -0
  24. admin/settings/browser.php +1102 -0
  25. admin/settings/class_settings.php +565 -0
  26. admin/settings/class_settingsAPI.php +657 -0
  27. admin/settings/class_settingsAPICustom.php +297 -0
  28. includes/class-wp-hide-post-activator.php +76 -0
  29. includes/class-wp-hide-post-deactivator.php +36 -0
  30. includes/class-wp-hide-post-i18n.php +47 -0
  31. includes/class-wp-hide-post-loader.php +137 -0
  32. includes/class-wp-hide-post.php +488 -0
  33. includes/helpers.php +454 -0
  34. includes/index.php +1 -0
  35. index.php +1 -0
  36. wp-hide-post.pot → languages/wp-hide-post.pot +0 -0
  37. public/class-wp-hide-post-public.php +386 -0
  38. public/css/plugin-name-public.css +4 -0
  39. public/index.php +1 -0
  40. public/js/wp-hide-post-public.js +32 -0
  41. public/partials/wp-hide-post-public-display.php +15 -0
  42. readme.txt +200 -106
  43. screenshot-1.png +0 -0
  44. screenshot-10.png +0 -0
  45. screenshot-11.png +0 -0
  46. screenshot-2.png +0 -0
  47. screenshot-3.png +0 -0
  48. screenshot-4.png +0 -0
  49. screenshot-5.png +0 -0
  50. screenshot-6.png +0 -0
  51. screenshot-7.png +0 -0
  52. screenshot-8.png +0 -0
  53. screenshot-9.png +0 -0
  54. uninstall.php +31 -0
  55. upgrade.php +0 -89
  56. wp-hide-post-api.php +0 -21
  57. wp-hide-post.php +114 -546
admin/class-wp-hide-post-admin.php ADDED
@@ -0,0 +1,1141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * The admin-specific functionality of the plugin.
5
+ *
6
+ * @link http://scriptburn.com
7
+ * @since 2.0
8
+ *
9
+ * @package wp_hide_post
10
+ * @subpackage wp_hide_post/admin
11
+ */
12
+
13
+ /**
14
+ * The admin-specific functionality of the plugin.
15
+ *
16
+ * Defines the plugin name, version, and two examples hooks for how to
17
+ * enqueue the admin-specific stylesheet and JavaScript.
18
+ *
19
+ * @package wp_hide_post
20
+ * @subpackage wp_hide_post/admin
21
+ * @author ScriptBurn <support@scriptburn.com>
22
+ */
23
+ class wp_hide_post_Admin
24
+ {
25
+
26
+ /**
27
+ * The ID of this plugin.
28
+ *
29
+ * @since 1.2.2
30
+ * @access private
31
+ * @var string $wp_hide_post The ID of this plugin.
32
+ */
33
+ private $wp_hide_post;
34
+
35
+ /**
36
+ * The version of this plugin.
37
+ *
38
+ * @since 1.2.2
39
+ * @access private
40
+ * @var string $version The current version of this plugin.
41
+ */
42
+ private $version;
43
+
44
+ /**
45
+ * Allowed post types where widget can be displayed
46
+ *
47
+ * @since 1.2.2
48
+ * @access private
49
+ * @var string $version The current version of this plugin.
50
+ */
51
+ private $post_types;
52
+
53
+ private $post_visibility_types;
54
+
55
+ private $page_visibility_types;
56
+ private $info;
57
+ private $license;
58
+ private $item_url = 'http://scriptburn.com/downloads/wp-hide-post/';
59
+ /**
60
+ * Initialize the class and set its properties.
61
+ *
62
+ * @since 1.2.2
63
+ * @param string $wp_hide_post The name of this plugin.
64
+ * @param string $version The version of this plugin.
65
+ */
66
+ public function __construct($wp_hide_post, $version, $license)
67
+ {
68
+ //p_d($license->is_valid(),1);
69
+ $this->wp_hide_post = $wp_hide_post;
70
+ $this->version = $version;
71
+ $this->license = $license;
72
+ $this->post_types =is_object($this->license) && $this->license->is_valid() ? wphp_get_setting('wphp_gen', 'wphp_post_types') : false;
73
+ if (!is_array($this->post_types))
74
+ {
75
+ $this->post_types = array('post', 'page');
76
+ }
77
+
78
+ return $this;
79
+ }
80
+ public function allowedPostTypes($post_type = null)
81
+ {
82
+
83
+ if (!is_null($post_type))
84
+ {
85
+ return in_array($post_type, $this->post_types);
86
+ }
87
+ return $this->post_types;
88
+ }
89
+
90
+ public function plugin_init1()
91
+ {
92
+ $post_types = scb_custom_post_types();
93
+
94
+ foreach ($this->allowedPostTypes() as $post_type)
95
+ {
96
+ if ($post_type == 'page' || (!empty($post_types[$post_type]) && $post_types[$post_type]->hierarchical))
97
+ {
98
+ wp_hide_post()->get_loader()->add_action("manage_pages_custom_column", $this->plugin_admin, 'manage_posts_columns', 10);
99
+
100
+ }
101
+ else
102
+ {
103
+ wp_hide_post()->get_loader()->add_action("manage_{$post_type}_posts_columns", $this->plugin_admin, 'manage_posts_columns', 10);
104
+ wp_hide_post()->get_loader()->add_action("manage_edit-{$post_type}_columns", $this->plugin_admin, 'manage_posts_columns', 10);
105
+ }
106
+
107
+ }
108
+ }
109
+ /**
110
+ * Register the stylesheets for the admin area.
111
+ *
112
+ * @since 1.2.2
113
+ */
114
+ public function enqueue_styles()
115
+ {
116
+ global $pagenow;
117
+ /**
118
+ * This function is provided for demonstration purposes only.
119
+ *
120
+ * An instance of this class should be passed to the run() function
121
+ * defined in wp_hide_post_Loader as all of the hooks are defined
122
+ * in that particular class.
123
+ *
124
+ * The wp_hide_post_Loader will then create the relationship
125
+ * between the defined hooks and the functions defined in this
126
+ * class.
127
+ */
128
+
129
+ wp_enqueue_style($this->wp_hide_post, plugin_dir_url(__FILE__) . 'css/wp-hide-post-admin.css', array(), $this->version, 'all');
130
+ if ($pagenow == 'edit.php')
131
+ {
132
+ wp_enqueue_style('scb_settings', plugin_dir_url(__FILE__) . 'settings/assets/chosen.min.css');
133
+ }
134
+
135
+ }
136
+
137
+ /**
138
+ * Register the JavaScript for the admin area.
139
+ *
140
+ * @since 1.2.2
141
+ */
142
+ public function enqueue_scripts()
143
+ {
144
+ global $wp_scripts, $pagenow;
145
+
146
+ /**
147
+ * This function is provided for demonstration purposes only.
148
+ *
149
+ * An instance of this class should be passed to the run() function
150
+ * defined in wp_hide_post_Loader as all of the hooks are defined
151
+ * in that particular class.
152
+ *
153
+ * The wp_hide_post_Loader will then create the relationship
154
+ * between the defined hooks and the functions defined in this
155
+ * class.
156
+ */
157
+ wp_enqueue_script('jquery');
158
+
159
+ if (is_admin())
160
+ {
161
+ wp_enqueue_script('jquery-ui-dialog');
162
+ wp_enqueue_script('jquery-ui-tabs');
163
+
164
+ $ui = $wp_scripts->query('jquery-ui-core');
165
+ $protocol = is_ssl() ? 'https' : 'http';
166
+ $url = "$protocol://ajax.googleapis.com/ajax/libs/jqueryui/{$ui->ver}/themes/smoothness/jquery-ui.css";
167
+
168
+ wp_enqueue_style('jquery-ui-smoothness', $url, false, null);
169
+ }
170
+ wp_enqueue_script($this->wp_hide_post, plugin_dir_url(__FILE__) . 'js/wp-hide-post-admin.js', array('jquery'), $this->version, false);
171
+ if ($pagenow == 'edit.php')
172
+ {
173
+ wp_enqueue_script('scb_settings', plugin_dir_url(__FILE__) . 'settings/assets/chosen.jquery.min.js', array('jquery'));
174
+ }
175
+
176
+ }
177
+
178
+ /**
179
+ * Hook to watch for the activation of 'WP low Profiler', and forbid it...
180
+ * @return unknown_type
181
+ */
182
+ public function activate_lowprofiler()
183
+ {
184
+ $wp_hide_post_Activator = new wp_hide_post_Activator();
185
+ p_l("called: wphp_activate_lowprofiler");
186
+ $wp_hide_post_Activator->migrate();
187
+
188
+ $msgbox = __("'WP low Profiler' has been deprecated and replaced by 'WP Hide Post' which you already have active! Activation failed and plugin files cleaned up.", 'wp-hide-post');
189
+ $err1_sorry = __("Cannot install 'WP low Profiler' because of a conflict. Sorry for this inconvenience.", 'wp-hide-post');
190
+ $err2_cleanup = __("The downloaded files were cleaned-up and no further action is required.", 'wp-hide-post');
191
+ $err3_return = __("Return to plugins page...", 'wp-hide-post');
192
+ $return_url = admin_url('plugins.php');
193
+
194
+ $html = <<<HTML
195
+ ${err1_sorry}<br />${err2_cleanup}<br /><a href="${$return_url}">${err3_return}</a>
196
+ <script language="javascript">window.alert("${msgbox}");</script>
197
+ HTML;
198
+ // show the error page with the message...
199
+ wp_die($html, 'WP low Profiler Activation Not Allowed', array('response' => '200'));
200
+ }
201
+
202
+ /**
203
+ * @param $action_links
204
+ * @param $plugin
205
+ * @return unknown_type
206
+ */
207
+ public function plugin_install_action_links_wp_lowprofiler($action_links, $plugin)
208
+ {
209
+ p_l("called: plugin_install_action_links_wp_lowprofiler");
210
+ if ($plugin['name'] == 'WP low Profiler')
211
+ {
212
+ $alt = '<a href="' . admin_url('plugin-install.php?tab=plugin-information&amp;plugin=wp-hide-post&amp;TB_iframe=true&amp;width=600&amp;height=800') . '" class="thickbox onclick" title="WP Hide Post">' . __('Check "WP Hide Post"') . '</a>';
213
+ $action_links = array(
214
+ __('Deprecated'),
215
+ $alt);
216
+ }
217
+ return $action_links;
218
+ }
219
+
220
+ /*
221
+ Return all allowed post visibility types
222
+ */
223
+ public function get_post_visibility_types()
224
+ {
225
+ if ($this->post_visibility_types)
226
+ {
227
+ return $this->post_visibility_types;
228
+ }
229
+ $this->post_visibility_types = array(
230
+ 'post_front' => array(
231
+ 'label' => wphp_('Hide on the front page.'),
232
+ 'short_label' => 'Front page',
233
+ 'description' => '',
234
+ ),
235
+ 'post_category' => array(
236
+ 'label' => wphp_('Hide on category pages.'),
237
+ 'short_label' => 'Category pages',
238
+ 'description' => '',
239
+ ),
240
+ 'post_tag' => array(
241
+ 'label' => wphp_('Hide on tag pages.'),
242
+ 'short_label' => 'Tag pages',
243
+ 'description' => '',
244
+
245
+ ),
246
+ 'post_author' => array(
247
+ 'label' => wphp_('Hide on author pages.'),
248
+ 'short_label' => 'Author pages',
249
+ 'description' => '',
250
+
251
+ ),
252
+ 'post_archive' => array(
253
+ 'label' => wphp_('Hide in date archives (month, day, year, etc...) '),
254
+ 'short_label' => 'Archives',
255
+ 'description' => '',
256
+
257
+ ),
258
+ 'post_search' => array(
259
+ 'label' => wphp_('Hide in search results. '),
260
+ 'short_label' => 'Search results',
261
+ 'description' => '',
262
+
263
+ ),
264
+ 'post_feed' => array(
265
+ 'label' => wphp_('Hide in feeds.'),
266
+ 'short_label' => 'Feeds',
267
+ 'description' => '',
268
+ ),
269
+
270
+ 'post_recent' => array(
271
+ 'label' => wphp_('Hide in Wp Native Recent post widget.'),
272
+ 'short_label' => 'Recent post',
273
+ 'description' => '',
274
+ 'no_auto_join' => true,
275
+ ),
276
+ 'post_rel' => array(
277
+ 'label' => wphp_('Remove from next previous rel link'),
278
+ 'short_label' => 'Meta rel link',
279
+ 'description' => 'Remove post from Meta rel link In Single Post page<div style="background:green;color:white;padding:5px">' . htmlentities("<link rel='prev' title='Post title previous' href='http://your-previous-post-url' />") . '</div><div style="background:green;color:white;padding:5px">' . htmlentities("<link rel='next' title='Post title next' href='http://your-next-post-url' />") . '</div><div></div>',
280
+ ),
281
+
282
+ );
283
+ $this->post_visibility_types = apply_filters('wphp_post_visibility_types', $this->post_visibility_types);
284
+
285
+ return $this->post_visibility_types;
286
+ }
287
+ /*
288
+ Return all allowed post visibility types
289
+ */
290
+ public function get_page_visibility_types()
291
+ {
292
+ if ($this->page_visibility_types)
293
+ {
294
+ return $this->page_visibility_types;
295
+ }
296
+ $this->page_visibility_types = array(
297
+
298
+ 'hide_frontpage' => array(
299
+ 'label' => wphp_('Hide when listing pages on the front page. '),
300
+ 'short_label' => 'Front page',
301
+ 'description' => '',
302
+ ),
303
+ 'hide_always' => array(
304
+ 'label' => wphp_('Hide everywhere pages are listed.'),
305
+ 'short_label' => 'Always',
306
+ 'description' => 'Will still show up in sitemap.xml if you generate one automatically',
307
+
308
+ ),
309
+ 'nohide_search' => array(
310
+ 'label' => wphp_('Hide everywhere but keep in search results.'),
311
+ 'short_label' => 'Hide but keep in search',
312
+ 'description' => 'Will still show up in sitemap.xml if you generate one automatically',
313
+
314
+ ),
315
+ );
316
+ $this->page_visibility_types = apply_filters('wphp_page_visibility_types', $this->page_visibility_types);
317
+
318
+ return $this->page_visibility_types;
319
+ }
320
+
321
+ public function get_visibility_types($post_type)
322
+ {
323
+ if ($post_type == 'page')
324
+ {
325
+ return $this->get_page_visibility_types();
326
+ }
327
+ else
328
+ {
329
+ return $this->get_post_visibility_types();
330
+
331
+ }
332
+ }
333
+
334
+ private function save_visibility($post_type, $post_id, $is_bulk = false)
335
+ {
336
+ if (!$this->allowedPostTypes($post_type) || !current_user_can($post_type == 'page' ? 'edit_page' : 'edit_post', $post_id))
337
+ {
338
+ p_l(" save_visibility $post_type");
339
+ return;
340
+ }
341
+ p_l(" save_visibility bulk=" . ($is_bulk ? 1 : 0));
342
+ foreach ($_POST[WPHP_VISIBILITY_NAME . "_old"] as $index => $value)
343
+ {
344
+ if (empty($_POST[WPHP_VISIBILITY_NAME][$index]))
345
+ {
346
+ $_POST[WPHP_VISIBILITY_NAME][$index] = 0;
347
+ }
348
+ if ((int) $_POST[WPHP_VISIBILITY_NAME . "_old"][$index] != $_POST[WPHP_VISIBILITY_NAME][$index] || $is_bulk)
349
+ {
350
+ p_l("$post_id,$index," . $_POST[WPHP_VISIBILITY_NAME][$index]);
351
+ $this->update_visibility(
352
+ $post_id,
353
+ $index,
354
+ (int) $_POST[WPHP_VISIBILITY_NAME][$index]
355
+ );
356
+ }
357
+
358
+ }
359
+ }
360
+
361
+ /**
362
+ *
363
+ * @param $id
364
+ * @return unknown_type
365
+ */
366
+ public function save_post($id)
367
+ {
368
+ p_l("save_post");
369
+ if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
370
+ {
371
+ return $id;
372
+ }
373
+ $item_type = get_post_type($id);
374
+
375
+ if (empty($_POST["wphp_{$item_type}_edit_nonce"]) || !wp_verify_nonce($_POST["wphp_{$item_type}_edit_nonce"], "wphp_{$item_type}_edit_nonce"))
376
+ {
377
+ p_l('no verify nonce ' . "wphp_{$item_type}_edit_nonce");
378
+ return $id;
379
+ }
380
+
381
+ p_l("called: wphp_save_post");
382
+
383
+ $this->save_visibility($item_type, $id);
384
+ }
385
+
386
+ public function save_bulk_edit_data()
387
+ {
388
+ //p_d($_POST);
389
+ p_l("save_bulk_edit_data");
390
+ $post_type = empty($_POST['post_type']) ? '' : $_POST['post_type'];
391
+
392
+ $post_ids = (isset($_POST['post_ids']) && !empty($_POST['post_ids'])) ? $_POST['post_ids'] : array();
393
+
394
+ if (empty($post_ids) || !is_array($post_ids))
395
+ {
396
+ die();
397
+ }
398
+ foreach ($post_ids as $post_id)
399
+ {
400
+
401
+ $this->save_visibility($post_type, $post_id, true);
402
+ }
403
+ die();
404
+ }
405
+
406
+ /**
407
+ *
408
+ * @param $id
409
+ * @param $lp_flag
410
+ * @param $lp_value
411
+ * @return unknown_type
412
+ */
413
+ public function update_visibility($id, $lp_flag, $lp_value)
414
+ {
415
+
416
+ if ($lp_value)
417
+ {
418
+ update_post_meta($id, WPHP_META_VALUE_PREFIX . $lp_flag, $lp_value);
419
+ }
420
+ else
421
+ {
422
+ delete_post_meta($id, WPHP_META_VALUE_PREFIX . $lp_flag);
423
+ }
424
+ }
425
+
426
+ /**
427
+ *
428
+ * @param $item_type
429
+ * @param $id
430
+ * @param $lp_flag
431
+ * @return unknown_type
432
+ */
433
+ public function unset_low_profile($item_type, $id, $lp_flag)
434
+ {
435
+ p_l("called: unset_low_profile");
436
+ global $wpdb;
437
+ // Delete the flag from the database table
438
+ $wpdb->query("DELETE FROM " . WPHP_TABLE_NAME . " WHERE post_id = $id AND meta_key = '$lp_flag'");
439
+ }
440
+
441
+ /**
442
+ *
443
+ * @param $item_type
444
+ * @param $id
445
+ * @param $lp_flag
446
+ * @param $lp_value
447
+ * @return unknown_type
448
+ */
449
+ public function set_low_profile($item_type, $id, $lp_flag, $lp_value)
450
+ {
451
+ p_l("called: set_low_profile");
452
+ global $wpdb;
453
+ // Ensure No Duplicates!
454
+ update_post_meta($id, $lp_flag, $lp_value);
455
+ return;
456
+ $check = $wpdb->get_var("SELECT count(*) FROM " . WPHP_TABLE_NAME . " WHERE post_id = $id AND meta_key='$lp_flag'");
457
+ if (!$check)
458
+ {
459
+ $wpdb->query("INSERT INTO " . WPHP_TABLE_NAME . "(post_id, meta_key, meta_value) VALUES($id, '$lp_flag', '$lp_value')");
460
+ }
461
+ elseif ($item_type == 'page' && $lp_flag == WPHP_META_VALUE_PREFIX . "page_flags")
462
+ {
463
+ $wpdb->query("UPDATE " . WPHP_TABLE_NAME . " set meta_value = '$lp_value' WHERE post_id = $id and meta_key = '$lp_flag'");
464
+ }
465
+ }
466
+ /**
467
+ *
468
+ * @param $post_id
469
+ * @return unknown_type
470
+ */
471
+ public function delete_post($post_id)
472
+ {
473
+ p_l("called: wphp_delete_post");
474
+ global $wpdb;
475
+ // Delete all post flags from the database table
476
+ $wpdb->query("DELETE FROM " . WPHP_TABLE_NAME . " WHERE post_id = $post_id and meta_key like '" . WPHP_META_VALUE_PREFIX . "%'");
477
+ }
478
+
479
+ // ad our metabox to page
480
+ public function add_meta_boxes($postType)
481
+ {
482
+ if (in_array($postType, $this->post_types))
483
+ {
484
+ $post_type = get_post_type_object($postType);
485
+ if ($post_type)
486
+ {
487
+ add_meta_box('hidepostdivpost', sprintf(wphp_('%1$s Visibility'), ucwords($post_type->labels->singular_name)), array($this, 'metabox_post_edit'), $postType);
488
+ }
489
+ }
490
+ elseif ($postType == 'page')
491
+ {
492
+ add_meta_box('hidepostdivpage', __('Page Visibility', 'wp-hide-post'), array($this, 'metabox_page_edit'), 'page');
493
+ }
494
+ }
495
+
496
+ // return the visibility options set for a page or post
497
+
498
+ public function get_visibility_type_values($post_type, $post_id)
499
+ {
500
+ global $wpdb;
501
+ $post_id = (int) $post_id;
502
+
503
+ if ($post_type == 'page')
504
+ {
505
+ $visibility_types = $this->get_page_visibility_types();
506
+ }
507
+ else
508
+ {
509
+ $visibility_types = $this->get_post_visibility_types();
510
+ }
511
+ if (!$post_id)
512
+ {
513
+ return $visibility_types;
514
+ }
515
+
516
+ //p_d("SELECT meta_key from " . WPHP_TABLE_NAME . " where post_id = $id and meta_key like '". WPHP_META_VALUE_PREFIX ."%'");
517
+ $flags = $wpdb->get_results("SELECT meta_key from " . WPHP_TABLE_NAME . " where post_id = $post_id and meta_key like '" . WPHP_META_VALUE_PREFIX . "%'", ARRAY_N);
518
+ if ($flags)
519
+ {
520
+ foreach ($flags as $flag_array)
521
+ {
522
+ $flag = $flag_array[0];
523
+ // remove the prefix _wplp_
524
+
525
+ $flag = substr($flag, strlen(WPHP_META_VALUE_PREFIX));
526
+
527
+ if (isset($visibility_types[$flag]))
528
+ {
529
+ $visibility_types[$flag]['value'] = 1;
530
+ }
531
+ }
532
+ }
533
+ return $visibility_types;
534
+ }
535
+ /**
536
+ *
537
+ * @return unknown_type
538
+ */
539
+ public function metabox_edit($post_id, $post_type, $meta_box = true)
540
+ {
541
+ p_l("called: metabox_edit $post_id, $post_type");
542
+
543
+ //wp_nonce_field(plugin_basename(__FILE__), "wphp_{$post_type}_edit_nonce");
544
+
545
+ $pre[] = '<input type="hidden" id="wphp_' . $post_type . '_edit_nonce" name="wphp_' . $post_type . '_edit_nonce" value="' . wp_create_nonce("wphp_{$post_type}_edit_nonce") . '" />';
546
+ if ($post_type !== 'page')
547
+ {
548
+ $pre[] = '<script>(function($)
549
+ {
550
+ $(document).ready(function()
551
+ {
552
+ $(".wphp_checkall").change(function()
553
+ {
554
+ $(".wphp_checkall").parent().parent().parent().find(".wphp_multicheck").prop("checked", $(this).prop("checked"));
555
+ });
556
+ });
557
+ })(jQuery);</script>';
558
+ }
559
+
560
+ $pre[] = '<div style="padding:10px;background:#e5e5e5"> <label for="wphp_checkallcheck" style="font-weight:bold" >
561
+ <input type="checkbox" class="wphp_checkall" id="wphp_checkallcheck" />
562
+ &nbsp;
563
+ Check All
564
+
565
+ </label>
566
+ </div>';
567
+
568
+ $tmpl = '<div style="padding:10px;padding-bottom:0px"> <label for="%1$s_new_%2$s" class="selectit">
569
+ <input type="checkbox" id="%1$s_new_%2$s" name="%1$s[%2$s]" value="%3$s" %4$s class="wphp_multicheck"/>
570
+ &nbsp;
571
+ %5$s
572
+
573
+ </label>
574
+ %8$s
575
+ <input type="hidden" name="%1$s_old[%2$s]" value="%6$s"/>
576
+ <input type="hidden" name="%1$s_name[%2$s]" value="%7$s"/></div>';
577
+
578
+ $html = array();
579
+ $index = 0;
580
+ foreach ($this->get_visibility_type_values($post_type, $post_id) as $type => $detail)
581
+ {
582
+ $detail['value'] = empty($detail['value']) ? 0 : (int) $detail['value'];
583
+
584
+ $html[] = sprintf($tmpl,
585
+ WPHP_VISIBILITY_NAME,
586
+ $type,
587
+ 1,
588
+ $detail['value'] ? 'checked' : '',
589
+ $detail['label'],
590
+ $detail['value'],
591
+ $type,
592
+ empty($detail['description']) ? '' : sprintf('<p style=" padding-left: 30px;" class="description">%1$s</p>', $detail['description'])
593
+ );
594
+ $index++;
595
+ }
596
+ return (implode("\n", $pre) . implode("", $html) . ($meta_box ? $this->default_info('widget') : ''));
597
+
598
+ }
599
+
600
+ public function metabox_post_edit($post)
601
+ {
602
+ echo ($this->metabox_edit($post->ID, $post->post_type));
603
+ }
604
+ public function metabox_page_edit($post)
605
+ {
606
+ echo ($this->metabox_edit($post->ID, $post->post_type));
607
+ }
608
+
609
+ public function create_post_type()
610
+ {
611
+ return ;
612
+ register_post_type('acme_product',
613
+ array(
614
+ 'labels' => array(
615
+ 'name' => __('Products'),
616
+ 'singular_name' => __('Product'),
617
+ ),
618
+ 'public' => true,
619
+ 'has_archive' => true,
620
+ )
621
+ );
622
+
623
+ register_post_type('acme_item',
624
+ array(
625
+ 'labels' => array(
626
+ 'name' => __('Items'),
627
+ 'singular_name' => __('Item'),
628
+ ),
629
+ 'public' => true,
630
+ 'has_archive' => true,
631
+ )
632
+ );
633
+
634
+ register_post_type('acme_test',
635
+ array(
636
+ 'labels' => array(
637
+ 'name' => __('Tests'),
638
+ 'singular_name' => __('Test'),
639
+ ),
640
+ 'public' => true,
641
+ 'has_archive' => true,
642
+ )
643
+ );
644
+ }
645
+ public function register_setting_page()
646
+ {
647
+
648
+ $valid = is_object($this->license) && $this->license->is_valid();
649
+ wp_hide_post()->settingManager()->register_tab(array('id' => 'wphp_gen', 'title' => 'General'));
650
+ $options = array();
651
+ foreach ((array) scb_custom_post_types() as $type => $detail)
652
+ {
653
+ $detail = (array) $detail;
654
+ $options[$type] = array('text' => $detail['labels']->name);
655
+ if (!$valid && !$detail['_builtin'])
656
+ {
657
+ $options[$type]['extra'] = 'disabled';
658
+ $options[$type]['text'] .= " -- For WP hide post Pro users only";
659
+ }
660
+ }
661
+ $pro = '<div><a target="_blank" style="color:red" href="http://scriptburn.com/wphp">For WP hide post Pro Users only</a></div>';
662
+ wp_hide_post()->settingManager()->register_setting_field('wphp_gen', array(
663
+ array('name' => 'wphp_post_types',
664
+ 'label' => wphp_('Allowed custom post types'),
665
+ 'desc' => wphp_('Allow WP hide post widget in these custom post types'),
666
+ 'type' => 'multi',
667
+ 'options' => $options,
668
+ 'placeholder' => 'Select custom post type',
669
+ ),
670
+ array('name' => 'show_in_quickedit',
671
+ 'label' => wphp_('Enable quick edit?'),
672
+ 'desc' => wphp_('Display WP hide post widget in quick edit?') . ($valid ? '' : $pro),
673
+ 'type' => 'yesno',
674
+ 'default' => 1,
675
+ 'disabled' => $valid ? '' : 'disabled',
676
+ ),
677
+ array('name' => 'show_in_bulkedit',
678
+ 'label' => wphp_('Enable bulk edit?'),
679
+ 'desc' => wphp_('Display WP hide post widget in bulk edit?') . ($valid ? '' : $pro),
680
+ 'type' => 'yesno',
681
+ 'default' => 1,
682
+ 'disabled' => $valid ? '' : 'disabled',
683
+ ),
684
+ ));
685
+ }
686
+
687
+ public function admin_menu()
688
+ {
689
+
690
+ add_submenu_page('options-general.php', wphp_('WP Hide Post'), wphp_("WP Hide Post"), 'manage_options', wp_hide_post()->setting_menu_page(), array(wp_hide_post()->settingManager(), 'plugin_page'));
691
+ }
692
+ public function register_plugin($licenses)
693
+ {
694
+ $licenses[] = array('id' => 'wp-hide-post-pro',
695
+ 'type' => 'plugin',
696
+ 'name' => 'WP Hide Post Pro',
697
+ 'label' => 'WP hide Post Plugin',
698
+ 'options' => array(
699
+ 'license_text' => array('invalid' => 'Get your WP Hide Post Pro license from here <a href="http://scriptburn.com/wphp" target="_blank">here</a>'),
700
+ 'store_url' => "http://scriptburn.com",
701
+ 'file' => wp_hide_post()->info('file'),
702
+
703
+ ),
704
+ );
705
+
706
+ return $licenses;
707
+ }
708
+ public function admin_footer()
709
+ {
710
+
711
+ ?>
712
+ <script>
713
+ var wphp_hide_on_data=[];
714
+ wphp_hide_on_data['visibility_name'] = '<?php echo (WPHP_VISIBILITY_NAME); ?>';
715
+ wphp_hide_on_data['visibility_types']=[]
716
+ <?php
717
+
718
+ foreach (array('post', 'page') as $post_type)
719
+ {
720
+ echo (" wphp_hide_on_data['visibility_types']['$post_type']=[];\n");
721
+
722
+ foreach ($this->get_visibility_types($post_type) as $visibility_type => $data)
723
+ {
724
+ echo (" wphp_hide_on_data['visibility_types']['$post_type']['$visibility_type']='" . (empty($data['value']) ? '0' : (int) $data) . "';\n");
725
+ }
726
+ }
727
+ ?>
728
+ </script>
729
+ <?php
730
+ }
731
+ /* quick edit box */
732
+ // add our custom column to post list box show we can display where the post is hidden
733
+ public function manage_posts_columns($columns)
734
+ {
735
+
736
+ $columns['wphp_hide_on'] = 'Hidden On';
737
+ return $columns;
738
+ }
739
+
740
+ // display data of our custom column
741
+ public function render_custom_column_data($column, $post_id)
742
+ {
743
+ static $nonce_data;
744
+ if ($column != 'wphp_hide_on')
745
+ {
746
+ return;
747
+ }
748
+ $current_v = isset($_GET['wphp_hidden_on']) ? $_GET['wphp_hidden_on'] : array();
749
+ $current_v = is_array($current_v) ? $current_v : array($current_v);
750
+ $post_type = get_post_type($post_id);
751
+
752
+ // we will store nonce in this variable
753
+ // we will only fill this variable if this function is called first time
754
+ // only in first call this variable will have array data
755
+ $items = array();
756
+ if (!$nonce_data)
757
+ {
758
+
759
+ $nonce_data = array(
760
+ 'nonce_field' => "wphp_{$post_type}_edit_nonce",
761
+ 'nonce_value' => wp_create_nonce("wphp_{$post_type}_edit_nonce"),
762
+ 'visibility_name' => WPHP_VISIBILITY_NAME,
763
+ );
764
+ $nonce_data = sprintf('<input type="hidden" class="wphp_hide_on_data" value="%1$s" />', urlencode(json_encode($nonce_data)));
765
+ }
766
+ switch ($column)
767
+ {
768
+ case 'wphp_hide_on':
769
+
770
+ $values = $this->get_visibility_type_values($post_type, $post_id);
771
+ $data = array();
772
+ foreach ($values as $visibility_type => $item)
773
+ {
774
+ if (isset($item['value']))
775
+ {
776
+ if ($item['value'])
777
+ {
778
+ $items[$visibility_type] = sprintf('<span %1$s>%2$s</span>',
779
+ in_array($visibility_type, $current_v) ? 'class="visibility_item"' : '',
780
+ (isset($item['short_label']) ? $item['short_label'] : $visibility_type)
781
+ );
782
+ }
783
+ $data[$visibility_type] = empty($item['value']) ? 0 : (int) $item['value'];
784
+ }
785
+ }
786
+ $items = array(implode(" , ", $items));
787
+
788
+ $items[] = sprintf('<input type="hidden" class="wphp_hidden_on" value="%2$s" />', $post_id, urlencode(json_encode($data)));
789
+
790
+ $items[] = $nonce_data;
791
+
792
+ echo implode("\n", $items);
793
+ break;
794
+ }
795
+
796
+ }
797
+ public function display_custom_bulkedit($column_name, $post_type)
798
+ {
799
+ if ( !wphp_get_setting('wphp_gen', 'show_in_bulkedit'))
800
+ {
801
+ return;
802
+ }
803
+ $this->display_custom_quickedit($column_name, $post_type);
804
+ }
805
+ //render our quick edit and bulk edit box
806
+ public function display_custom_quickedit($column_name, $post_type)
807
+ {
808
+ $valid =is_object($this->license) && $this->license->is_valid();
809
+
810
+ if (!wphp_get_setting('wphp_gen', 'show_in_quickedit'))
811
+ {
812
+ return;
813
+ }
814
+
815
+ $pre = array();
816
+ if ($column_name != 'wphp_hide_on')
817
+ {
818
+
819
+ return;
820
+ }
821
+
822
+ if (!$this->allowedPostTypes($post_type))
823
+ {
824
+
825
+ return;
826
+ }
827
+
828
+ static $printNonce;
829
+ // p_l("display_custom_quickedit $printNonce");
830
+ if (!$printNonce)
831
+ {
832
+ $printNonce = wp_create_nonce("wphp_{$post_type}_edit_nonce");
833
+ $printNonce = '<input type="hidden" id="wphp_' . $post_type . '_edit_nonce" name="wphp_' . $post_type . '_edit_nonce" value="' . $printNonce . '" />';
834
+ $pre[] = $printNonce;
835
+ }
836
+
837
+ $tmpl = '<div style="padding:10px;padding-bottom:0px"> <label for="%1$s_new_%2$s" class="selectit">
838
+ <input type="checkbox" id="%1$s_new_%2$s" name="%1$s[%2$s]" value="%3$s" %4$s class="wphp_multicheck" %9$s/>
839
+ &nbsp;
840
+ %5$s
841
+ </label>%8$s
842
+ <input type="hidden" name="%1$s_old[%2$s]" value="%6$s" %9$s/>
843
+ <input type="hidden" name="%1$s_name[%2$s]" value="%7$s" %9$s/></div>';
844
+
845
+ $html = array();
846
+ $index = 0;
847
+ $allChecked = false;
848
+
849
+ foreach ($this->get_visibility_types($post_type) as $type => $detail)
850
+ {
851
+ $detail['value'] = empty($detail['value']) ? 0 : (int) $detail['value'];
852
+
853
+ $html[] = sprintf($tmpl,
854
+ WPHP_VISIBILITY_NAME,
855
+ $type,
856
+ 1,
857
+ $detail['value'] ? 'checked' : '',
858
+ $detail['label'],
859
+ $detail['value'],
860
+ $type,
861
+ empty($detail['description']) ? '' : sprintf('<p style=" padding-left: 30px;" class="description">%1$s</p>', $detail['description']),
862
+ $valid ? '' : 'disabled'
863
+ );
864
+ $allChecked = $detail['value'];
865
+ $index++;
866
+ }
867
+ $pro = '<div style="padding:10px;padding-bottom:0px"><a target="_blank" style="color:red" href="http://scriptburn.com/wphp">For WP hide post Pro Users only</a></div>';
868
+ if ($post_type !== 'page')
869
+ {
870
+ $pre[] = '<script>(function($)
871
+ {
872
+ $(document).ready(function()
873
+ {
874
+ $(".wphp_checkall").change(function()
875
+ {
876
+ $(".wphp_checkall").parent().parent().parent().find(".wphp_multicheck").prop("checked", $(this).prop("checked"));
877
+ });
878
+ });
879
+ })(jQuery);</script>';
880
+
881
+ $pre[] = '<div style="padding:10px;background:#e5e5e5"> <label for="wphp_checkallcheck" style="font-weight:bold" >
882
+ <input ' . ($valid ? '' : 'disabled') . ' type="checkbox" id="wphp_checkallcheck" class="wphp_checkall" ' . ($allChecked ? 'checked' : '') . ' />
883
+ &nbsp;
884
+ Check All
885
+
886
+ </label>
887
+ </div>';
888
+ }
889
+ $post_type_obj = get_post_type_object($post_type);
890
+
891
+ $title = sprintf(wphp_('%1$s Visibility'), ucwords($post_type_obj->labels->singular_name));
892
+ $html = implode("\n", $pre) . implode("", $html) . ($valid?'':$pro);
893
+ require WPHP_PLUGIN_DIR . 'admin/partials/quick-edit-display.php';
894
+
895
+ }
896
+
897
+ // store the data in js var which will be used in click event of quick edit link
898
+ // and set the correct data in our quick edit box
899
+ public function post_row_actions_insert_data_as_js1($actions, $post)
900
+ {
901
+ static $js_var;
902
+ if (!$this->allowedPostTypes($post->post_type))
903
+ {
904
+ return;
905
+ }
906
+ $values = array();
907
+ if (!$js_var)
908
+ {
909
+ echo ("\n<script>\n var wphp_hide_on_data=[]; \n
910
+ wphp_hide_on_data['visibility_name']='" . WPHP_VISIBILITY_NAME . "';\n
911
+ wphp_hide_on_data['nonce_field']='" . "wphp_{$post->post_type}_edit_nonce" . "';\n
912
+ wphp_hide_on_data['nonce_value']='" . wp_create_nonce("wphp_{$post->post_type}_edit_nonce") . "';\n
913
+ wphp_hide_on_data['visibility_values']=[];\n
914
+
915
+ </script>\n");
916
+ $js_var = true;
917
+ }
918
+ foreach ($this->get_visibility_type_values($post->post_type, $post->ID) as $visibility_type => $detail)
919
+ {
920
+ if (isset($detail['value']))
921
+ {
922
+ $values[$visibility_type] = (int) $detail['value'];
923
+ }
924
+ }
925
+
926
+ if (count($values))
927
+ {
928
+ echo ("<script>\n
929
+ wphp_hide_on_data['visibility_values'][" . $post->ID . "]=JSON.parse('" . json_encode($values) . "');\n
930
+ </script>\n");
931
+ }
932
+ return $actions;
933
+ $nonce = wp_create_nonce('myfield_' . $post->ID);
934
+ $myfielvalue = get_post_meta($post->ID, 'myfield', true);
935
+ $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="';
936
+ $actions['inline hide-if-no-js'] .= esc_attr(__('Edit this item inline')) . '"';
937
+ $actions['inline hide-if-no-js'] .= " onclick=\"set_wphp_hide_on_value('{$post->ID}')\" >";
938
+ $actions['inline hide-if-no-js'] .= __('Quick Edit1');
939
+ $actions['inline hide-if-no-js'] .= '</a>';
940
+ return $actions;
941
+ }
942
+
943
+ // add our custom filter selectbox in admin post list box
944
+ public function restrict_manage_posts()
945
+ {
946
+
947
+ $type = 'post';
948
+ if (isset($_GET['post_type']))
949
+ {
950
+ $type = $_GET['post_type'];
951
+ }
952
+
953
+ if (!$this->allowedPostTypes($type))
954
+ {
955
+ return;
956
+ }
957
+ $values = $this->get_visibility_types($type);
958
+
959
+ $values['all'] = array('short_label' => 'All Hidden');
960
+
961
+ ?>
962
+ <select name="wphp_hidden_on[]" class=" scb-sett-select-chosen chosen-select" multiple data-placeholder="Select Hidden option">
963
+ <?php
964
+ $current_v = isset($_GET['wphp_hidden_on']) ? $_GET['wphp_hidden_on'] : array();
965
+ $current_v = is_array($current_v) ? $current_v : array($current_v);
966
+
967
+ foreach ($values as $visibility_type => $item)
968
+ {
969
+ printf
970
+ (
971
+ '<option value="%1$s"%2$s >%3$s</option>',
972
+ $visibility_type,
973
+ in_array($visibility_type, $current_v) ? ' selected="selected"' : '',
974
+ isset($item['short_label']) ? $item['short_label'] : $visibility_type
975
+ );
976
+ }
977
+ ?>
978
+ </select>
979
+ <?php
980
+
981
+ }
982
+
983
+ // Filter the posts acording to selected filter in post list select box
984
+ public function query_posts_join_custom_filter($join, $wp_query)
985
+ {
986
+
987
+ global $wpdb, $pagenow;
988
+
989
+ $type = 'post';
990
+ if (isset($_GET['post_type']))
991
+ {
992
+ $type = $_GET['post_type'];
993
+ }
994
+
995
+ if (!$this->allowedPostTypes($type))
996
+ {
997
+ return $join;
998
+ }
999
+
1000
+ if (!(is_admin() && $pagenow == 'edit.php' && isset($_GET['wphp_hidden_on']) && $_GET['wphp_hidden_on'] != ''))
1001
+ {
1002
+ return $join;
1003
+ }
1004
+
1005
+ $current_v = isset($_GET['wphp_hidden_on']) ? $_GET['wphp_hidden_on'] : array();
1006
+ $current_v = is_array($current_v) ? $current_v : array($current_v);
1007
+
1008
+ $join .= ' inner JOIN ' . WPHP_TABLE_NAME . ' wphptbl ON ' . WP_POSTS_TABLE_NAME . ".ID = wphptbl.post_id ";
1009
+
1010
+ if (in_array('all', $current_v))
1011
+ {
1012
+ $join .= sprintf(' AND wphptbl.meta_key like "%1$s%%"', WPHP_META_VALUE_PREFIX);
1013
+ }
1014
+ else
1015
+ {
1016
+
1017
+ foreach ($current_v as $key => $v)
1018
+ {
1019
+ $current_v[$key] = esc_sql(WPHP_META_VALUE_PREFIX . $v);
1020
+ }
1021
+ $join .= " AND wphptbl.meta_key in ('" . implode("','", $current_v) . "') ";
1022
+
1023
+ }
1024
+ return $join;
1025
+
1026
+ }
1027
+ public function default_info($page)
1028
+ {
1029
+ $info = get_transient('wphp_notices_' . $page);
1030
+
1031
+ if (!$info)
1032
+ {
1033
+
1034
+ $obj_license = scb_get_license(wp_hide_post()->info('id'));
1035
+ $args['action'] = 'wphp_footer';
1036
+ $args['page'] = $page;
1037
+ if (is_object($obj_license))
1038
+ {
1039
+ $info = $obj_license->extendedInfo();
1040
+ $args = array_merge($args, array(
1041
+ 'license' => $info['license'],
1042
+ 'price' => isset($info['price']) ? $info['price'] : 0,
1043
+ 'payment_id' => isset($info['payment_id']) ? $info['payment_id'] : '',
1044
+
1045
+ ));
1046
+ }
1047
+ $args['price'] = isset($args['price']) ? $args['price'] : 0;
1048
+ $url = "http://scriptburn.com/wp-admin/admin-ajax.php?" . http_build_query($args);
1049
+ $response = wp_remote_get($url, array('decompress' => false));
1050
+
1051
+ if (is_array($response) && !empty($response['body']))
1052
+ {
1053
+
1054
+ $info = @json_decode($response['body']);
1055
+ if (is_object($info))
1056
+ {
1057
+ $info = property_exists($info, 'response') ? $info->response : $this->default_footer($args['price']);
1058
+ }
1059
+ else
1060
+ {
1061
+ $info = $response['body'];
1062
+ }
1063
+
1064
+ set_transient('wphp_notices_' . $page, $info, 86400);
1065
+ }
1066
+ elseif ($response == "0")
1067
+ {
1068
+ $info = "";
1069
+ }
1070
+ else
1071
+ {
1072
+
1073
+ $info = $this->default_footer($args['price']);
1074
+ }
1075
+ }
1076
+ return $info;
1077
+
1078
+ }
1079
+ public function default_footer($price)
1080
+ {
1081
+ $info = '<hr/>
1082
+ <div>
1083
+ <div style="float:left">
1084
+ <a href="http://scriptburn.com/wp-hide-post/#comments">
1085
+ %1$s
1086
+ </a>
1087
+ </div>
1088
+ <div style="float:right">
1089
+ <a href="http://wordpress.org/extend/plugins/wp-hide-post/">
1090
+ %2$s
1091
+ </a>
1092
+ </div>
1093
+ </div><div style="clear:both">' . $price ? '' : '
1094
+ <div style="text-align:center">
1095
+ <a href="http://scriptburn.com/wp-hide-post">
1096
+ <img src="http://www.paypalobjects.com/webstatic/en_US/btn/btn_donate_pp_142x27.png"/>
1097
+ </a>
1098
+ </div>
1099
+ <div style="clear:both">
1100
+ </div>
1101
+ ';
1102
+ return sprintf($info,
1103
+ wphp_("Leave feedback and report bugs..."),
1104
+ wphp_("Give 'WP Hide Post' a good rating...")
1105
+ );
1106
+
1107
+ }
1108
+ public function wsa_footer()
1109
+ {
1110
+
1111
+ echo $this->default_info('footer');
1112
+ }
1113
+
1114
+ public function maybe_update()
1115
+ {
1116
+
1117
+ // bail if this plugin data doesn't need updating
1118
+ // delete_option('wpmovies_db_ver');
1119
+ $db_updated = (int) (empty($_REQUEST['db_updated']) ? 0 : $_REQUEST['db_updated']);
1120
+ if ($db_updated)
1121
+ {
1122
+ return;
1123
+ }
1124
+ $wphp_db_ver = (int) get_option('wphp_db_ver');
1125
+ // error_log($wpmovies_db_ver . ">=" . self::WPMOVIES_DB_VER);
1126
+ if ($wphp_db_ver >= WPHP_DB_VER)
1127
+ {
1128
+ return;
1129
+ }
1130
+
1131
+ require_once WPHP_PLUGIN_DIR . 'admin/class-wp-hide-post-dbupdate.php';
1132
+ $db_updater = new wp_hide_post_DB_Update();
1133
+ $ret = $db_updater->db_update();
1134
+
1135
+ if ($ret)
1136
+ {
1137
+ set_transient('wphp_db_updated', 1, 30);
1138
+ }
1139
+ }
1140
+
1141
+ }
admin/class-wp-hide-post-dbupdate.php ADDED
@@ -0,0 +1,203 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * The admin-specific functionality of the plugin.
5
+ *
6
+ * @link http://scriptburn.com
7
+ * @since 2.0
8
+ *
9
+ * @package wp_hide_post
10
+ * @subpackage wp_hide_post/admin
11
+ */
12
+
13
+ /**
14
+ * The admin-specific functionality of the plugin.
15
+ *
16
+ * Defines the plugin name, version, and two examples hooks for how to
17
+ * enqueue the admin-specific stylesheet and JavaScript.
18
+ *
19
+ * @package wp_hide_post
20
+ * @subpackage wp_hide_post/admin
21
+ * @author ScriptBurn <support@scriptburn.com>
22
+ */
23
+ class wp_hide_post_DB_Update
24
+ {
25
+
26
+ /**
27
+ * The ID of this plugin.
28
+ *
29
+ * @since 1.2.2
30
+ * @access private
31
+ * @var string $wp_hide_post The ID of this plugin.
32
+ */
33
+ private $wp_hide_post;
34
+
35
+ /**
36
+ * The version of this plugin.
37
+ *
38
+ * @since 1.2.2
39
+ * @access private
40
+ * @var string $version The current version of this plugin.
41
+ */
42
+ private $version;
43
+
44
+ /**
45
+ * Initiates db update process
46
+ *
47
+ * @since 1.2.2
48
+ * @access private
49
+ * @var string $version The current version of this plugin.
50
+ */
51
+ public function db_update()
52
+ {
53
+ p_l("db_update");
54
+ // no PHP timeout for running updates
55
+ //set_time_limit(0);
56
+
57
+ $db_updated = false;
58
+ // this is the current database schema version number
59
+
60
+ $current_db_ver = (int) get_option('wphp_db_ver');
61
+
62
+ // this is the target version that we need to reach
63
+ $target_db_ver = WPHP_DB_VER;
64
+
65
+ // error_log("$current_db_ver < $target_db_ver");
66
+ //$loop;
67
+ while ($current_db_ver < $target_db_ver)
68
+ {
69
+
70
+ // increment the current db_ver by one
71
+ $current_db_ver++;
72
+
73
+ // each db version will require a separate update function
74
+ $func = "update_to_ver_{$current_db_ver}";
75
+ p_l("calling $func");
76
+ if (method_exists($this, $func))
77
+ {
78
+ $ret = call_user_func_array(array($this, $func), array());
79
+ if ($ret && !$db_updated)
80
+ {
81
+ $db_updated = true;
82
+ }
83
+ }
84
+
85
+ // update the option in the database, so that this process can always
86
+ // pick up where it left off
87
+
88
+ update_option('wphp_db_ver', $current_db_ver);
89
+ }
90
+ return $db_updated;
91
+ }
92
+
93
+ /**
94
+ * Migrate to the new database schema and clean up old schema...
95
+ * Should run only once in the lifetime of the plugin...
96
+ * @return unknown_type
97
+ */
98
+
99
+ public function update_to_ver_1()
100
+ {
101
+ global $wpdb;
102
+ p_l("called:update_to_ver_1");
103
+ /* When I first released this plugin, I was young and crazy and didn't know about the postmeta table.
104
+ * With time I became wiser and wiser and decided to migrate the implementation to rely on postmeta.
105
+ * I hope it was not a bad idea...
106
+ */
107
+ global $wpdb;
108
+ global $table_prefix;
109
+ $dbname = $wpdb->get_var("SELECT database()");
110
+ if (!$dbname)
111
+ {
112
+ return;
113
+ }
114
+
115
+ $legacy_table_name = "${table_prefix}lowprofiler_posts";
116
+ $legacy_table_exists = $wpdb->get_var("SELECT COUNT(*) AS count FROM information_schema.tables WHERE table_schema = '$dbname' AND table_name = '$legacy_table_name';");
117
+ if ($legacy_table_exists)
118
+ {
119
+ p_l("Migrating legacy table...");
120
+ // move everything to the postmeta table
121
+ $existing = $wpdb->get_results("SELECT wplp_post_id, wplp_flag, wplp_value from $legacy_table_name", ARRAY_N);
122
+ // scan them one by one and insert the corresponding fields in the postmeta table
123
+ $count = 0;
124
+ foreach ($existing as $existing_array)
125
+ {
126
+ $wplp_post_id = $existing_array[0];
127
+ $wplp_flag = $existing_array[1];
128
+ $wplp_value = $existing_array[2];
129
+ if ($wplp_flag == 'home')
130
+ {
131
+ $wplp_flag = 'front';
132
+ }
133
+
134
+ if ($wplp_value == 'home')
135
+ {
136
+ $wplp_value = 'front';
137
+ }
138
+
139
+ if ($wplp_flag != 'page')
140
+ {
141
+ $wpdb->query("INSERT INTO " . WPHP_TABLE_NAME . "(post_id, meta_key, meta_value) VALUES($wplp_post_id, '_wplp_post_$wplp_flag', '1')");
142
+ }
143
+ else
144
+ {
145
+ $wpdb->query("INSERT INTO " . WPHP_TABLE_NAME . "(post_id, meta_key, meta_value) VALUES($wplp_post_id, '_wplp_page_flags', $wplp_value)");
146
+ }
147
+ ++$count;
148
+ }
149
+ p_l("$count entries migrated from legacy table.");
150
+ // delete the old table
151
+ $wpdb->query("TRUNCATE TABLE $legacy_table_name");
152
+ $wpdb->query("DROP TABLE $legacy_table_name");
153
+ p_l("Legacy table deleted.");
154
+ }
155
+ return true;
156
+ }
157
+ public function update_to_ver_2()
158
+ {
159
+ p_l("in update_to_ver_2");
160
+ global $wpdb;
161
+ $results = $wpdb->get_results("select * from $wpdb->postmeta where meta_key='_wplp_page_flags' ", ARRAY_A);
162
+ if ($results)
163
+ {
164
+ foreach ($results as $result)
165
+ {
166
+ //p_l($result);
167
+ if ($result['meta_value'] == 'all')
168
+ {
169
+ p_l("all");
170
+ $meta_old = get_post_meta($result['post_id'], '_wplp_page_search', true);
171
+
172
+ if ($meta_old)
173
+ {
174
+ //Hide everywhere pages are listed.
175
+ p_l("always");
176
+ $new_meta_name = WPHP_META_VALUE_PREFIX . 'hide_always';
177
+
178
+ update_post_meta($result['post_id'], $new_meta_name, '1');
179
+
180
+ }
181
+ else
182
+ {
183
+ //Hide everywhere pages are listed. but Keep in search results.
184
+ p_l("always no search");
185
+ $new_meta_name = WPHP_META_VALUE_PREFIX . 'nohide_search';
186
+ update_post_meta($result['post_id'], $new_meta_name, '1');
187
+
188
+ }
189
+ }
190
+ elseif ($result['meta_value'] == 'front')
191
+ {
192
+ p_l("front");
193
+
194
+ $new_meta_name = WPHP_META_VALUE_PREFIX . 'hide_frontpage';
195
+
196
+ update_post_meta($result['post_id'], $new_meta_name, '1');
197
+
198
+ }
199
+
200
+ }
201
+ }
202
+ }
203
+ }
admin/conditions.php ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if (!function_exists('wphp_is_hide_frontpage_page'))
4
+ {
5
+ function wphp_is_hide_frontpage_page($args)
6
+ {
7
+ global $wp;
8
+ $ret = false;
9
+ if (!empty($args['wp_query']))
10
+ {
11
+
12
+ $ret = ($args['wp_query']->get('page_id') == get_option('page_on_front') && get_option('page_on_front')) || empty($args['wp_query']->query_string);
13
+ }
14
+ return $ret || is_front_page();
15
+ }
16
+ }
17
+ if (!function_exists('wphp_is_hide_always_page'))
18
+ {
19
+ function wphp_is_hide_always_page()
20
+ {
21
+
22
+ return (is_front_page() || is_feed() || is_category() || is_tag() || is_date() || is_search());
23
+ }
24
+ }
25
+ if (!function_exists('wphp_is_nohide_search_page'))
26
+ {
27
+ function wphp_is_nohide_search_page()
28
+ {
29
+
30
+ return (is_front_page() || is_feed() || is_category() || is_tag() || is_date()) && !is_search();
31
+ }
32
+ }
33
+
34
+ /**
35
+ *
36
+ * @return unknown_type
37
+ */
38
+ if (!function_exists('wphp_is_post_front_post'))
39
+ {
40
+ function wphp_is_post_front_post()
41
+ {
42
+ return is_front_page() || is_home();
43
+ }
44
+ }
45
+ /**
46
+ *
47
+ * @return unknown_type
48
+ */
49
+
50
+ if (!function_exists('wphp_is_post_feed_post'))
51
+ {
52
+ function wphp_is_post_feed_post()
53
+ {
54
+ return is_feed();
55
+ }
56
+ }
57
+ /**
58
+ *
59
+ * @return unknown_type
60
+ */
61
+
62
+ if (!function_exists('wphp_is_post_category_post'))
63
+ {
64
+ function wphp_is_post_category_post()
65
+ {
66
+ return !wphp_is_post_front_post() && !wphp_is_post_feed_post() && is_category();
67
+ }
68
+ }
69
+ /**
70
+ *
71
+ * @return unknown_type
72
+ */
73
+
74
+ if (!function_exists('wphp_is_post_tag_post'))
75
+ {
76
+ function wphp_is_post_tag_post()
77
+ {
78
+ return !wphp_is_post_front_post() && !wphp_is_post_feed_post() && is_tag();
79
+ }
80
+ }
81
+ /**
82
+ *
83
+ * @return unknown_type
84
+ */
85
+
86
+ if (!function_exists('wphp_is_post_author_post'))
87
+ {
88
+ function wphp_is_post_author_post()
89
+ {
90
+ return !wphp_is_post_front_post() && !wphp_is_post_feed_post() && is_author();
91
+ }
92
+ }
93
+ /**
94
+ *
95
+ * @return unknown_type
96
+ */
97
+
98
+ if (!function_exists('wphp_is_post_archive_post'))
99
+ {
100
+ function wphp_is_post_archive_post()
101
+ {
102
+ return !wphp_is_post_front_post() && !wphp_is_post_feed_post() && is_date();
103
+ }
104
+ }
105
+ /**
106
+ *
107
+ * @return unknown_type
108
+ */
109
+
110
+ if (!function_exists('wphp_is_post_search_post'))
111
+ {
112
+ function wphp_is_post_search_post($args)
113
+ {
114
+ if (isset($args['wp_query']) && $args['wp_query']->is_main_query())
115
+ {
116
+ return is_search();
117
+ }
118
+ }
119
+ }
120
+ if (!function_exists('wphp_is_post_rel_post'))
121
+ {
122
+ function wphp_is_post_rel_post($args)
123
+ {
124
+ return wphp_is_rel_query($args);
125
+ }
126
+ }
127
+ if (!function_exists('wphp_is_post_recent_post'))
128
+ {
129
+ function wphp_is_post_recent_post($args)
130
+ {
131
+
132
+ return wphp_is_post_sidebar($args['wp_query']);
133
+ }
134
+ }
135
+ if (!function_exists('wphp_is_post_sidebar'))
136
+ {
137
+ function wphp_is_post_sidebar($wp_query)
138
+ {
139
+ $sidebar = false;
140
+ if (property_exists($wp_query, 'query'))
141
+ {
142
+ $sidebar = !empty($wp_query->query['wphp_inside_recent_post_sidebar']) && $wp_query->query['wphp_inside_recent_post_sidebar'];
143
+ }
144
+ return $sidebar;
145
+
146
+ }
147
+ }
148
+
149
+ function wphp_is_rel_query($args)
150
+ {
151
+ return isset($args['from_rel_query']) && $args['from_rel_query'];
152
+ }
admin/css/wp-hide-post-admin.css ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .visibility_item {
2
+ background-color: green;
3
+ color: white;
4
+ padding-left: 5px;
5
+ padding-right: 5px;
6
+ padding-top: 2px;
7
+ padding-bottom: 2px;
8
+ }
9
+
10
+ .scb-sett-select {}
11
+
12
+ .scb-sett-select-chosen {
13
+ width: 300px;
14
+ }
15
+
16
+ .tablenav .actions .scb-sett-select-chosen {
17
+ width: 500px;
18
+ }
19
+
20
+ .chosen-container-multi .chosen-choices {
21
+ -webkit-border-radius: 3px;
22
+ border-radius: 3px;
23
+ border-color: #dfdfdf;
24
+ background-image: none;
25
+ }
26
+
27
+ .chosen-container .search-field input {
28
+ width: 90%!important;
29
+ }
30
+
31
+ .chosen-container-multi .chosen-choices input {
32
+ margin: 2px;
33
+ height: 27px!important;
34
+ border-color: #dfdfdf;
35
+ }
36
+
37
+ .chosen-container .search-field {
38
+ float: none!important;
39
+ }
40
+
41
+ .tablenav .actions {
42
+ overflow: visible;
43
+ }
44
+
45
+ .positioned-divs {
46
+
47
+ }
48
+
49
+ .positioned-divs .div-under {
50
+ z-index: 1;
51
+ }
52
+
53
+ .positioned-divs .div-over {
54
+ z-index: 2;
55
+ left: 0;
56
+ top: 0px;
57
+ position: absolute;
58
+ width: 100%;
59
+ height: 100%;
60
+ z-index: 2;
61
+ background: grey;
62
+ opacity: .5;
63
+ }
admin/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden
admin/js/wp-hide-post-admin.js ADDED
@@ -0,0 +1,242 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var $ = jQuery.noConflict();
2
+ var wphp_texts = {
3
+ "sure_remove": "Are you sure to remove this item?",
4
+ "unable_process": "Unable to process",
5
+ "procesed_sucess": "Procesed sucessfully",
6
+ "error": "Error",
7
+ "no_connection": "Not connected.Please verify your network connection.",
8
+ "page_not_found": "The requested page not found. [404]",
9
+ "internal_server_error": "Internal Server Error [500].",
10
+ "json_failed": "Requested JSON parse failed.",
11
+ "time_out": "Time out error.",
12
+ "ajax_aborted": "Ajax request aborted.",
13
+ "uncaught_error": "Uncaught Error",
14
+ "confirm": "Confirm",
15
+ };
16
+ $(document).ready(function()
17
+ {
18
+ $(".chosen-select").chosen(
19
+ {
20
+ 'width': '400px'
21
+ });
22
+ $("body").append('<div id="dialog-message" style="display:none;z-index:2000" title=""></div>');
23
+ modalDialog = $("#dialog-message").dialog(
24
+ {
25
+ modal: true,
26
+ autoOpen: false,
27
+ autoResize: true,
28
+ buttons:
29
+ {
30
+ Ok: function()
31
+ {
32
+ $(this).dialog("close");
33
+ }
34
+ }
35
+ });
36
+ /* quick edit ajax handler */
37
+ $('a.editinline1').on('click', function(event)
38
+ {
39
+ var id = inlineEditPost.getId(this);
40
+ set_wphp_hide_on_value(id);
41
+ return true;;
42
+ //$('.wphp_quickedit').html("");
43
+ var data = {
44
+ 'action': 'wphp_post_visibility_data',
45
+ 'post_id': post_id,
46
+ 'post_type': $("#posts-filter [name='post_type']").val()
47
+ };
48
+ var save_btn = $('#edit-' + post_id).find('.inline-edit-save>.save')
49
+ $(save_btn).data('label', $(save_btn).val());
50
+ $(save_btn).val('loading..');
51
+ $(save_btn).attr('disabled', true);
52
+ $.ajax(
53
+ {
54
+ type: "POST",
55
+ url: ajaxurl,
56
+ data: data,
57
+ dataType: 'json',
58
+ success: function(response)
59
+ {
60
+ if (!response.status)
61
+ {
62
+ showModalMsg(wphp_texts.error, response.error,
63
+ {});
64
+ $(save_btn).val($(save_btn).data('label'));
65
+ $(save_btn).attr('disabled', false)
66
+ }
67
+ else
68
+ {
69
+ $(save_btn).val($(save_btn).data('label'));
70
+ $(save_btn).attr('disabled', false);
71
+ $('.wphp_quickedit').replaceWith(response.html);
72
+ }
73
+ },
74
+ fail: function(xhr, err)
75
+ {
76
+ id = $(this)[0].data.split('&')[1].split("=")[1];
77
+ $(save_btn).val($(save_btn).data('label'));
78
+ $(save_btn).attr('disabled', false)
79
+ showModalMsg(wphp_texts.error, formatErrorMessage(xhr, err));
80
+ }
81
+ });
82
+ });
83
+ });
84
+
85
+ function showModalMsg(title, body, option)
86
+ {
87
+ option = typeof option === 'undefined' ?
88
+ {} : option;
89
+ option.title = title
90
+ $(modalDialog).dialog(option);
91
+ $(modalDialog).html(htmlBody(body));
92
+ $(modalDialog).dialog("open");
93
+ }
94
+
95
+ function htmlBody(body)
96
+ {
97
+ html = "";
98
+ if (body instanceof Array)
99
+ {
100
+ for (var item in body)
101
+ {
102
+ html = html + body[item] + "</br>";
103
+ }
104
+ }
105
+ else
106
+ {
107
+ html = body;
108
+ }
109
+ return html;
110
+ }
111
+
112
+ function formatErrorMessage(jqXHR, exception)
113
+ {
114
+ if (jqXHR.status === 0)
115
+ {
116
+ return (wphp_texts.no_connection);
117
+ }
118
+ else if (jqXHR.status == 404)
119
+ {
120
+ return (wphp_texts.page_not_found);
121
+ }
122
+ else if (jqXHR.status == 500)
123
+ {
124
+ return (wphp_texts.internal_server_error);
125
+ }
126
+ else if (exception === 'parsererror')
127
+ {
128
+ return (wphp_texts.json_failed);
129
+ }
130
+ else if (exception === 'timeout')
131
+ {
132
+ return (wphp_texts.time_out);
133
+ }
134
+ else if (exception === 'abort')
135
+ {
136
+ return (wphp_texts.ajax_aborted);
137
+ }
138
+ else
139
+ {
140
+ return (wphp_texts.uncaught_error + '\n' + jqXHR.responseText);
141
+ }
142
+ }
143
+ // add date to our quick edit box
144
+ function set_wphp_hide_on_value(post_id)
145
+ {
146
+ // define the edit row
147
+ var $edit_row = $('#edit-' + post_id);
148
+ var $post_row = $('#post-' + post_id);
149
+ // get the data
150
+ var $wphp_hide_on = $('.column-wphp_hide_on', $post_row);
151
+ // populate the data
152
+ //$(':input[name="book_author"]', $edit_row).val($book_author);
153
+ //$(':input[name="inprint"]', $edit_row).attr('checked', $inprint);
154
+ ///
155
+ if (!$('.wphp_hidden_on', $wphp_hide_on).length || !$('.wphp_hide_on_data', $wphp_hide_on).length)
156
+ {
157
+ return;
158
+ }
159
+ visibility_values = JSON.parse(decodeURIComponent($('.wphp_hidden_on', $wphp_hide_on).val()));
160
+ wphp_hide_on_data = JSON.parse(decodeURIComponent($('.wphp_hide_on_data', $wphp_hide_on).val()));
161
+
162
+ $('#' + wphp_hide_on_data['nonce_field'], $edit_row).val(wphp_hide_on_data['nonce_value']);
163
+
164
+
165
+ // refresh the quick menu properly
166
+ if (visibility_values === 'undefined' || !Object.keys(visibility_values).length)
167
+ {
168
+ return;
169
+ }
170
+ for (key in visibility_values)
171
+ {
172
+ if (visibility_values[key])
173
+ {
174
+ $('[name="wphp_visibility_type\[' + key + '\]"]', $edit_row).attr('checked', 'checked');
175
+ }
176
+ $('[name="wphp_visibility_type_old\[' + key + '\]"]', $edit_row).val(visibility_values[key]);
177
+ //jQuery('#myfield').val(fieldValue);
178
+ }
179
+ }
180
+ $(document).ready(function()
181
+ {
182
+ if(typeof inlineEditPost!=='undefined')
183
+ {
184
+
185
+
186
+ // we create a copy of the WP inline edit post function
187
+ var $wp_inline_edit = inlineEditPost.edit;
188
+ // and then we overwrite the function with our own code
189
+ inlineEditPost.edit = function(id)
190
+ {
191
+ // "call" the original WP edit function
192
+ // we don't want to leave WordPress hanging
193
+ $wp_inline_edit.apply(this, arguments);
194
+ // now we take care of our business
195
+ // get the post ID
196
+ var $post_id = 0;
197
+ if (typeof(id) == 'object') $post_id = parseInt(this.getId(id));
198
+ if ($post_id > 0)
199
+ {
200
+ set_wphp_hide_on_value($post_id);
201
+ }
202
+ };
203
+ }
204
+ $('#bulk_edit').on('click', function(event)
205
+ {
206
+ // define the bulk edit row
207
+ var $bulk_row = $('#bulk-edit');
208
+ // get the selected post ids that are being edited
209
+ var $post_ids = new Array();
210
+ $bulk_row.find('#bulk-titles').children().each(function()
211
+ {
212
+ $post_ids.push($(this).attr('id').replace(/^(ttle)/i, ''));
213
+ });
214
+ var data = {
215
+ 'action': 'save_bulk_edit_data',
216
+ 'post_ids': $post_ids,
217
+ 'post_type':inlineEditPost.type
218
+ }
219
+ for (key in wphp_hide_on_data['visibility_types'][inlineEditPost.type])
220
+ {
221
+ itm_name = wphp_hide_on_data['visibility_name'] + '[' + key + ']';
222
+ itm_name_esc = wphp_hide_on_data['visibility_name'] + '\\[' + key + '\\]';
223
+ itm_old = wphp_hide_on_data['visibility_name'] + '_old[' + key + ']';
224
+ itm_old_esc = wphp_hide_on_data['visibility_name'] + '_old\\[' + key + '\\]';
225
+ itm1 = wphp_hide_on_data['visibility_name'] + '\\[' + key + '\\]';
226
+ data[itm_name] = $("[ name=" + itm_name_esc + "]").attr('checked') ? 1 : 0;
227
+ data[itm_old] = $("[ name=" + itm_old_esc + "]").val();
228
+ a = 1;
229
+ }
230
+ // save the data
231
+ $.ajax(
232
+ {
233
+ url: ajaxurl, // this is a variable that WordPress has already defined for us
234
+ type: 'POST',
235
+ async: false,
236
+ cache: false,
237
+ 'data': data
238
+ });
239
+
240
+ a=1;
241
+ });
242
+ });
admin/license/LicenseItem.php ADDED
@@ -0,0 +1,722 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class SCB_LicenseItem
4
+ {
5
+
6
+ private $item_name = "";
7
+ private $safe_item_name = "";
8
+ private $item_file_name = "";
9
+ private $random = "";
10
+ private $item_type = "";
11
+ private $decode_signature = "SCB_DECODED";
12
+ private $store = "";
13
+ private $license_data = array();
14
+ private $key = false;
15
+ private $encrypter;
16
+ protected $options;
17
+ public $license_file;
18
+ private $extended_info;
19
+ public function __construct($store, $item_type, $item_name, $encrypter = null, $options = array())
20
+ {
21
+ $this->store = $store;
22
+ $this->item_name = $item_name;
23
+ $this->safe_item_name = strtolower(preg_replace("/[^\da-z][-]/i", '', $this->item_name));
24
+ $this->item_type = $item_type;
25
+ $this->random = $this->RandomString(4);
26
+ $this->encrypter = $encrypter;
27
+ $valid_items = array('plugin', 'module', 'theme');
28
+ $this->options = $options;
29
+ if (isset($this->options['license_file']))
30
+ {
31
+ $this->license_file = $this->options['license_file'];
32
+ }
33
+ elseif (isset($this->options['license_folder']) && file_exists($this->options['license_folder']))
34
+ {
35
+ $this->license_file = $this->options['license_folder'] . "/" . (@$this->options['license_file'] ? $this->options['license_file'] : 'license');
36
+ }
37
+
38
+ if (!in_array($item_type, $valid_items))
39
+ {
40
+ if (!$is_custom)
41
+ {
42
+ throw new \Exception('Invalid item Type');
43
+ return false;
44
+ }
45
+ }
46
+ if (isset($this->options['file']))
47
+ {
48
+ $theme_item = new SCB_Item_Helper($this->store, $this->options['file'], $this->get_license_key(), $this->item_type, $this->is_valid());
49
+ }
50
+
51
+ }
52
+ public function options($name = null)
53
+ {
54
+ if (!is_null($name))
55
+ {
56
+ if (isset($this->options[$name]))
57
+ {
58
+ return $this->options[$name];
59
+ }
60
+ else
61
+ {
62
+ return '';
63
+ }
64
+ }
65
+ else
66
+ {
67
+ return $this->options;
68
+ }
69
+ }
70
+ public function store_url()
71
+ {
72
+ return $this->store;
73
+ }
74
+ public function name()
75
+ {
76
+ return $this->item_name;
77
+ }
78
+ public function type()
79
+ {
80
+ return $this->item_type;
81
+ }
82
+ public static function add($store, $item_type, $item_name)
83
+ {
84
+ return new static($store, $item_type, $item_name);
85
+ }
86
+ public function RandomString($length)
87
+ {
88
+ $original_string = array_merge(range(0, 9), range('a', 'z'), range('A', 'Z'));
89
+ $original_string = implode("", $original_string);
90
+ return substr(str_shuffle($original_string), 0, $length);
91
+ }
92
+ public function prefix()
93
+ {
94
+ return "license." . $this->item_type . "_" . $this->safe_item_name . "_license_";
95
+ }
96
+ public function get_license_key()
97
+ {
98
+ if (isset($this->options['get_license_key']) && is_callable($this->options['get_license_key']))
99
+ {
100
+ return call_user_func($this->options['get_license_key'], array('this' => $this));
101
+ }
102
+
103
+ $key_name = $this->prefix() . 'key';
104
+ return $this->read_license_data($key_name);
105
+
106
+ }
107
+ public function set_license_key($key)
108
+ {
109
+ if (isset($this->options['set_license_key']) && is_callable($this->options['set_license_key']))
110
+ {
111
+ return call_user_func($this->options['set_license_key'], array('this' => $this, 'key' => $key));
112
+ }
113
+
114
+ $key_name = $this->prefix() . 'key';
115
+ $this->write_license_data($key_name, $key);
116
+ }
117
+
118
+ public function validate_license_file()
119
+ {
120
+ if (!$this->license_file)
121
+ {
122
+
123
+ throw new \Exception('unable to find license');
124
+
125
+ }
126
+
127
+ if (!file_exists($this->license_file))
128
+ {
129
+ $this->write_license_file('', array(), $age = 0, false);
130
+ }
131
+
132
+ $cnt = file_get_contents($this->license_file);
133
+
134
+ if (!$cnt)
135
+ {
136
+ throw new \Exception('unable to read license');
137
+ }
138
+ if (substr($cnt, 0, 3) != 'SCB')
139
+ {
140
+ throw new \Exception('Invalid license file');
141
+ }
142
+ return substr($cnt, 3);
143
+ }
144
+ public function read_license_file($key)
145
+ {
146
+ $cnt = $this->validate_license_file();
147
+
148
+ $cnt = base64_decode($cnt);
149
+
150
+ $cnt = @unserialize($cnt);
151
+
152
+ if (!is_array($cnt))
153
+ {
154
+ throw new \Exception('Invalid license file data');
155
+ }
156
+ if (!(isset($cnt[$key])))
157
+ {
158
+ return false;
159
+ }
160
+ $key_data = $cnt[$key];
161
+ if (is_string($key_data['data']))
162
+ {
163
+ $key_data_1 = @json_decode($key_data['data']);
164
+ if ($key_data_1)
165
+ {
166
+ $key_data['data'] = $key_data_1;
167
+ }
168
+ }
169
+ if (is_string($key_data['data']))
170
+ {
171
+ $key_data_1 = @unserialize($key_data['data']);
172
+ if ($key_data_1)
173
+ {
174
+ $key_data['data'] = $key_data_1;
175
+ }
176
+ }
177
+ if (!(isset($key_data['expire']) && isset($key_data['data'])))
178
+ {
179
+ throw new \Exception('Invalid license file data (1)');
180
+ }
181
+ if ($key_data['expire'] != 0)
182
+ {
183
+ if (time() > $key_data['expire'])
184
+ {
185
+ unset($cnt[$key]);
186
+ return false;
187
+ }
188
+ }
189
+ return $key_data['data'];
190
+ }
191
+
192
+ public function write_license_file($key, $data, $age = 0, $validate = true)
193
+ {
194
+ $cnt = $validate ? $this->validate_license_file() : false;
195
+
196
+ $cnt = base64_decode($cnt);
197
+ $cnt = @json_decode($cnt);
198
+ if (!is_array($cnt))
199
+ {
200
+ $cnt = array();
201
+ }
202
+ if ($data === false && isset($cnt[$key]))
203
+ {
204
+ unset($cnt[$key]);
205
+ }
206
+ else
207
+ {
208
+ $cnt[$key] = array('expire' => $age != 0 ? time() + $age : 0, 'data' => $data);
209
+ }
210
+ $cnt = "SCB" . base64_encode(serialize($cnt));
211
+
212
+ file_put_contents($this->license_file, $cnt);
213
+ }
214
+ public function read_license_data($key = "")
215
+ {
216
+
217
+ if (isset($this->options['read_license_data']) && is_callable($this->options['read_license_data']))
218
+ {
219
+ return call_user_func($this->options['read_license_data'], array('key' => $key));
220
+ }
221
+ elseif (isset($this->options['license_storage']) && $this->options['license_storage'] == 'file')
222
+ {
223
+ return $this->read_license_file($key);
224
+ }
225
+ else
226
+ {
227
+ return get_transient($key);
228
+ }
229
+ }
230
+ public function write_license_data($key, $data, $age = 0)
231
+ {
232
+ if (isset($this->options['write_license_data']) && is_callable($this->options['write_license_data']))
233
+ {
234
+ return call_user_func($this->options['write_license_data'], array('key' => $key, 'data' => $data, 'age' => $age));
235
+ }
236
+ elseif (isset($this->options['license_storage']) && $this->options['license_storage'] == 'file')
237
+ {
238
+ return $this->write_license_file($key, $data, $age);
239
+ }
240
+ else
241
+ {
242
+ set_transient($key, $data, $age);
243
+ }
244
+ }
245
+ public function delete_license_data($key)
246
+ {
247
+ if (isset($this->options['delete_license_data']) && is_callable($this->options['delete_license_data']))
248
+ {
249
+ return call_user_func($this->options['delete_license_data'], array('key' => $key));
250
+ }
251
+ elseif (isset($this->options['license_storage']) && $this->options['license_storage'] == 'file')
252
+ {
253
+ return $this->write_license_file($key, false);
254
+ }
255
+ else
256
+ {
257
+ delete_transient($data_name);
258
+ }
259
+ }
260
+
261
+ public function get_license_data($key = "")
262
+ {
263
+
264
+ $backtrace = debug_backtrace();
265
+ $calle = $backtrace[1]['function'];
266
+ $data_name = $this->prefix() . 'data';
267
+
268
+ if (!isset($this->license_data[$data_name]))
269
+ {
270
+ $data = $this->read_license_data($data_name);
271
+ if ($data === false || is_null($data))
272
+ {
273
+ $this->debug('license', __FUNCTION__ . "-" . __LINE__, 'not found data setting-' . $data_name . "-" . $calle);
274
+
275
+ }
276
+
277
+ if (($data === false || is_null($data)) && $_SERVER['REQUEST_METHOD'] == 'GET')
278
+ {
279
+ $this->debug('license', __FUNCTION__ . "-" . __LINE__, 'license ttl expired');
280
+ $this->check_license(true);
281
+
282
+ $data = $this->read_license_data($data_name);
283
+ //print_r($data);
284
+ // die('x');
285
+ }
286
+
287
+ /*
288
+ else
289
+ {
290
+ $data = $this->decodeIt($data);
291
+ $expires_in = (int) (@$data['expires_in']);
292
+ if ($expires_in <= time())
293
+ {
294
+ // $this->debug('license', __FUNCTION__ . "-" . __LINE__, 'license ttl expired cheating');
295
+ $this->check_license(true);
296
+ $data = get_transient($data_name);
297
+
298
+ }
299
+ }
300
+ */
301
+
302
+ $this->license_data[$data_name] = is_array($data) ? $data : $this->decodeIt($data);
303
+ $this->debug('license', __FUNCTION__ . "-" . __LINE__, $this->license_data[$data_name]);
304
+
305
+ }
306
+ if ($key && isset($this->license_data[$data_name][$key]))
307
+ {
308
+ return $this->license_data[$data_name][$key];
309
+ }
310
+ else
311
+ {
312
+ return $this->license_data[$data_name];
313
+ }
314
+
315
+ }
316
+
317
+ public function set_license_data($data = "")
318
+ {
319
+
320
+ $data_name = $this->prefix() . 'data';
321
+ unset($this->license_data[$data_name]);
322
+ //$this->debug('license', __FUNCTION__ . "-" . __LINE__,$data_name );
323
+ if (!$data)
324
+ {
325
+ $this->delete_license_data($data_name);
326
+ return;
327
+ }
328
+ $this->write_license_data($data_name, $data, 60 * 60 * 24);
329
+ $this->debug('license', __FUNCTION__ . "-" . __LINE__, "$data_name--" . $data);
330
+
331
+ }
332
+
333
+ public function send_request($request, $method = "get")
334
+ {
335
+
336
+ if (!empty($_SESSION['license_request'][$this->item_name]['last']))
337
+ {
338
+ $time = (int) $_SESSION['license_request'][$request][$this->item_name]['last'];
339
+ if ($time - time() > 0)
340
+ {
341
+ throw new \Exception("Please Wait 10 secs to perform this opretion again ");
342
+ }
343
+ }
344
+ $_SESSION['license_request'][$request][$this->item_name]['last'] = time() + 10;
345
+ // $this->debug('license', __FUNCTION__ . "-" . __LINE__, $request);
346
+ //$this->debug('license', __FUNCTION__ . "-" . __LINE__, $plugin_data);
347
+ $api_params = array(
348
+ 'edd_action' => $request,
349
+ 'license' => trim($this->get_license_key()),
350
+ 'item_name' => urlencode($this->item_name), // the name of our product in EDD
351
+ 'url' => scb_license_manager()->base_url(),
352
+ );
353
+
354
+ if ($method == 'get')
355
+ {
356
+ $api_params['rand'] = $this->RandomString(5);
357
+ $url = $this->store . "?" . http_build_query($api_params);
358
+
359
+ // p_d( $url );
360
+ //$this->debug('license', __FUNCTION__ . "-" . __LINE__, $url);
361
+ $response = scb_license_manager()->sendGetRequest($url . http_build_query($api_params));
362
+
363
+ }
364
+ else
365
+ {
366
+ $url = $this->store;
367
+ $response = scb_license_manager()->sendPostRequest($url, array('form_params' => $api_params, 'http_errors' => true));
368
+ }
369
+
370
+ $backtrace = debug_backtrace();
371
+ $calle = $backtrace[1]['function'];
372
+
373
+ $this->debug('license', __FUNCTION__ . "-" . __LINE__ . "-" . __LINE__, $calle . "-" . $url);
374
+ if (!$response->status)
375
+ {
376
+ throw new \Exception('License Server communication error');
377
+ }
378
+ $license_data = (string) $response->body;
379
+
380
+ $check = '"' . $this->decode_signature;
381
+
382
+ if (substr($license_data, 0, strlen($check)) == $check)
383
+ {
384
+ $license_data = substr($license_data, 1);
385
+
386
+ if (substr($license_data, strlen($license_data) - 1) == '"')
387
+ {
388
+ $license_data = substr($license_data, 0, strlen($license_data) - 1);
389
+ }
390
+
391
+ }
392
+
393
+ if (!is_object(@json_decode($license_data)))
394
+ {
395
+ //throw new \Exception('License checksum error');
396
+ }
397
+
398
+ // $this->debug('license', __FUNCTION__ . "-" . __LINE__ . "-" . __LINE__, "NoDecoded:" . print_r(($license_data), true));
399
+
400
+ //$this->debug('license', __FUNCTION__ . "-" . __LINE__ . "-" . __LINE__, "Decoded:" . print_r($this->decodeIt($license_data), true));
401
+ if (!$license_data)
402
+ {
403
+ throw new \Exception('License verification faile');
404
+ }
405
+ return $license_data;
406
+
407
+ }
408
+ public function activate_license()
409
+ {
410
+ try
411
+ {
412
+ $response = $this->send_request('activate_license');
413
+
414
+ if ($response)
415
+ {
416
+ $this->set_license_data($response);
417
+ return true;
418
+ }
419
+ }
420
+ catch (\Exception $e)
421
+ {
422
+ return false;
423
+
424
+ }
425
+
426
+ return false;
427
+
428
+ }
429
+ public function deactivate_license()
430
+ {
431
+ try
432
+ {
433
+ $response = $this->send_request('deactivate_license');
434
+ if ($response)
435
+ {
436
+ $this->set_license_data($response);
437
+ return true;
438
+ }
439
+ }
440
+ catch (\Exception $e)
441
+ {
442
+ return false;
443
+
444
+ }
445
+ return false;
446
+ }
447
+ public function check_license($fresh = false)
448
+ {
449
+ try
450
+ {
451
+ $backtrace = debug_backtrace();
452
+ $calle = $backtrace[1]['function'];
453
+
454
+ $this->debug('license', __FUNCTION__ . "-" . __LINE__ . "-" . __LINE__, $calle);
455
+
456
+ if ($fresh)
457
+ {
458
+ if (!$response = $this->send_request('check_license'))
459
+ {
460
+ return false;
461
+ }
462
+ }
463
+ else
464
+ {
465
+ return true;
466
+ }
467
+ $this->set_license_data($response);
468
+ }
469
+ catch (\Exception $e)
470
+ {
471
+ return false;
472
+
473
+ }
474
+
475
+ return true;
476
+ }
477
+
478
+ public function getKey()
479
+ {
480
+ if ($this->key)
481
+ {
482
+ return $this->key;
483
+ }
484
+ $k = array("cc6042d5c823eb37ce499cf85083ca03", "1234567890");
485
+ $keys = array();
486
+
487
+ if (!is_array($k))
488
+ {
489
+ $keys[] = $k;
490
+ }
491
+ else
492
+ {
493
+ $keys = $k;
494
+ }
495
+
496
+ $this->key = $keys;
497
+ return $this->key;
498
+ }
499
+ public function encodeIt($data)
500
+ {
501
+ $key = $this->getKey();
502
+ }
503
+
504
+ public function checkSignature(&$return)
505
+ {
506
+ if (is_object($return) || is_array($return))
507
+ {
508
+ //error_log(__LINE__ . "-checkSignature");
509
+ return false;
510
+ }
511
+ if (!is_string($return))
512
+ {
513
+ //error_log(__LINE__ . "-checkSignature");
514
+
515
+ return false;
516
+ }
517
+ $sig = substr(trim($return), 0, strlen($this->decode_signature));
518
+ //error_log(__LINE__ . "-checkSignature -" . ($sig . "!=" . $this->decode_signature));
519
+
520
+ if ($sig != $this->decode_signature)
521
+ {
522
+ $arr = json_decode($return, true);
523
+ if (is_array($arr))
524
+ {
525
+ //error_log(__LINE__ . "-checkSignature");
526
+ $return = $arr;
527
+ return false;
528
+ }
529
+ else
530
+ {
531
+ return false;
532
+ }
533
+ }
534
+ else
535
+ {
536
+ $part = substr($return, strlen($this->decode_signature));
537
+
538
+ $this->debug('license', __FUNCTION__ . "-" . __LINE__, "part $part");
539
+
540
+ $return = $part;
541
+ return true;
542
+ }
543
+ }
544
+ public function decrypt($data, $key)
545
+ {
546
+ if (is_object($this->encrypter))
547
+ {
548
+
549
+ return $this->encrypter->decrypt($data, $key);
550
+ }
551
+ else
552
+ {
553
+ return $data;
554
+ }
555
+
556
+ }
557
+ public function decodeIt($data)
558
+ {
559
+ $backtrace = debug_backtrace();
560
+ $calle = $backtrace[1]['function'];
561
+ $encryption = $this->encrypter;
562
+ $keys = $this->getKey();
563
+ $sig = $this->checkSignature($data);
564
+ $this->debug('license', __FUNCTION__ . "-" . __LINE__, "Called by $calle");
565
+
566
+ if (!$sig)
567
+ {
568
+ $this->debug('license', __FUNCTION__ . "-" . __LINE__, "Invalid sig");
569
+
570
+ return ($data);
571
+ }
572
+ //
573
+
574
+ $data = base64_decode($data);
575
+ $arr = unserialize($data);
576
+
577
+ if (!isset($arr['hash']) || !isset($arr['data']))
578
+ {
579
+ $this->debug('license', __FUNCTION__ . "-" . __LINE__, 'no hash');
580
+ //$this->debug('license', __FUNCTION__ . "-" . __LINE__, $arr);
581
+ return false;
582
+ }
583
+ $decrypted = "";
584
+ foreach ($keys as $key)
585
+ {
586
+ $decrypt = $this->decrypt(base64_decode($arr['data']), $key);
587
+ //$decrypt = $encryption->decrypt( base64_decode($arr['data']), $key);
588
+
589
+ if ($this->item_name == 'scriptburn-whois')
590
+ {
591
+ // p_n($key );
592
+ // p_n($decrypt );
593
+ }
594
+ $this->debug('license', __FUNCTION__ . "-" . __LINE__, 'decoded ' . $decrypt);
595
+
596
+ if ($arr['hash'] === md5($decrypt))
597
+ {
598
+ $decrypted = $decrypt;
599
+ break;
600
+ }
601
+ }
602
+ if ($this->item_name == 'scriptburn-whois')
603
+ {
604
+ // p_d('x');
605
+ }
606
+ if (!$decrypted)
607
+ {
608
+ $this->debug('license', __FUNCTION__ . "-" . __LINE__, 'no md5 ');
609
+ return false;
610
+ }
611
+
612
+ $arr = @(@unserialize(@base64_decode($decrypted)));
613
+ //$this->debug('license', __FUNCTION__ . "-" . __LINE__, 'final');
614
+ //$this->debug('license', __FUNCTION__ . "-" . __LINE__, $arr);
615
+
616
+ if (!is_array($arr))
617
+ {
618
+ $this->debug('license', __FUNCTION__ . "-" . __LINE__, 'no array');
619
+ return false;
620
+ }
621
+
622
+ return $arr;
623
+
624
+ }
625
+ public function is_valid()
626
+ {
627
+
628
+ if ($this->get_license_data('license') == 'valid')
629
+ {
630
+ return true;
631
+ }
632
+ else
633
+ {
634
+ return false;
635
+ }
636
+ }
637
+ public function extendedInfo($data = "")
638
+ {
639
+ if ($this->extended_info)
640
+ {
641
+ return $this->extended_info;
642
+ }
643
+ try
644
+ {
645
+ $arr['missing'] = "License Key does not exist";
646
+ $arr['license_not_activable'] = "Trying to activate bundle license for WP Movies";
647
+ $arr['revoked'] = "License key revoked ";
648
+ $arr['no_activations_left'] = "Maximum no of license activations used";
649
+ $arr['expired'] = "This license has expired for WP Movies";
650
+ $arr['key_mismatch'] = "License keys don't match ";
651
+ $arr['invalid_item_id'] = 'Invalid item Id ';
652
+ $arr['item_name_mismatch'] = "Item names don't match";
653
+ $arr['license_not_activable'] = "License can not be activated";
654
+
655
+ $arr_license['site_inactive'] = "License for this domain is not active";
656
+ $arr_license['disabled'] = " License key disabled";
657
+ $arr_license['inactive'] = "This license is not active";
658
+
659
+ $arr_license['disabled'] = " License key disabled";
660
+ $arr_license['valid'] = "License is active and valid";
661
+ $arr_license['invalid'] = "License is invalid";
662
+
663
+ $arr_license['expired'] = "License is Expired";
664
+ $arr_license['item_name_mismatch'] = "Item names don't match for this License";
665
+ $arr_license['invalid_item_id'] = "Invalid item Id for this License";
666
+ $arr_license['deactivated'] = "License has been deactivated ";
667
+ $arr_license['unknown'] = "Unknown license Status";
668
+
669
+ $data = $data ? $data : $this->get_license_data();
670
+
671
+ if (!(is_array($data) || is_object($data)))
672
+ {
673
+ $data = array();
674
+ }
675
+ if (is_object($data))
676
+ {
677
+ $data = (array) $data;
678
+ }
679
+
680
+ if (!isset($data['license']))
681
+ {
682
+ $data['license'] = 'unknown';
683
+ }
684
+ $data['license_info'] = isset($arr_license[$data['license']]) ? $arr_license[$data['license']] : $data['license'];
685
+ $data['error_info'] = isset($data['error']) ? isset($arr[$data['error']]) ? $arr[@$data['error']] : @$data['error'] : '';
686
+
687
+ $msg[] = isset($data['license']) ? (isset($arr_license[$data['license']]) ? $arr_license[$data['license']] : "Unknown license Status-{$data['license']} ") : "Unknown license Status";
688
+ $msg[] = isset($data['error']) ? (isset($arr_license[$data['error']]) ? $arr_license[$data['error']] : "Unknown license Error-{$data['error']} ") : "";
689
+ $data['message'] = $msg[0] ? $msg[0] . ($msg[1] ? " $msg[1]" : '') : ($msg[1] ? $msg[1] : '');
690
+ $this->extended_info = $data;
691
+ return $this->extended_info;
692
+
693
+ }
694
+ catch (\Exception $e)
695
+ {
696
+ $data['license'] = 'unknown';
697
+ $data['license_info'] = isset($arr_license[$data['license']]) ? $arr_license[$data['license']] : $data['license'];
698
+ $data['message'] = $e->getMessage();
699
+ $this->extended_info = $data;
700
+ return $this->extended_info;
701
+ }
702
+ }
703
+ public function debug($section, $name, $msg)
704
+ {
705
+ return;
706
+ if ($this->item_type != 'plugin')
707
+ {
708
+ // return;
709
+ }
710
+ static $first;
711
+ if (!$first)
712
+ {
713
+ $first = time();
714
+ p_l("$first=============debug started===================");
715
+
716
+ }
717
+ p_l("$first [Debug for [$section] item [$name]-> " . (is_array($msg) || is_object($msg) ? print_r($msg, true) : $msg) . "\n");
718
+
719
+ //file_put_contents(dirname(__FILE__)."/testlog.txt","[Debug for [$section] item [$name]-> " . (is_array($msg) || is_object($msg) ? print_r($msg, true) : $msg) . "\n");
720
+ }
721
+
722
+ }
admin/license/LicenseManager.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class SCB_LicenseManager
4
+ {
5
+
6
+ private $items;
7
+ private static $instance;
8
+ public static function getInstance()
9
+ {
10
+ if (is_null(self::$instance))
11
+ {
12
+ self::$instance = new static();
13
+ }
14
+ return self::$instance;
15
+ }
16
+ public function add($id, $store, $item_type, $item_name, $encrypter = null, $options = array())
17
+ {
18
+ if (isset($this->items[$id]))
19
+ {
20
+ return $this->items[$id];
21
+ }
22
+ if (is_null($encrypter))
23
+ {
24
+ $encrypter = new Encryption();
25
+ }
26
+ $this->items[$id] = new SCB_LicenseItem($store?$store:'http://scriptburn.com', $item_type, $item_name, $encrypter, $options);
27
+ return $this->items[$id];
28
+ }
29
+ public function items()
30
+ {
31
+ return $this->items;
32
+ }
33
+ public function item($id)
34
+ {
35
+ if (isset($this->items[$id]))
36
+ {
37
+ return $this->items[$id];
38
+ }
39
+ }
40
+
41
+ public function base_url()
42
+ {
43
+ return home_url();
44
+ }
45
+ public function sendGetRequest($url)
46
+ {
47
+ $response = wp_remote_get($url);
48
+ if (is_array($response))
49
+ {
50
+
51
+ return (object) array('status' => 1, 'body' => $response['body']);
52
+ }
53
+ else
54
+ {
55
+ return (object) array('status' => 1, 'message' => $response->get_error_message());
56
+
57
+ }
58
+ }
59
+ }
admin/license/autoload.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ include_once __DIR__ . "/LicenseManager.php";
3
+ include_once __DIR__ . "/LicenseItem.php";
4
+ include_once __DIR__ . "/encryption.php";
5
+ if (!defined('OPENSSL_RAW_DATA'))
6
+ {
7
+ define('OPENSSL_RAW_DATA', 1);
8
+ }
9
+
10
+ function scb_license_manager()
11
+ {
12
+ return SCB_LicenseManager::getInstance();
13
+ }
14
+ function scb_get_license($item)
15
+ {
16
+ return scb_license_manager()->item($item);
17
+ }
admin/license/encryption.php ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * A class to handle secure encryption and decryption of arbitrary data
4
+ *
5
+ * Note that this is not just straight encryption. It also has a few other
6
+ * features in it to make the encrypted data far more secure. Note that any
7
+ * other implementations used to decrypt data will have to do the same exact
8
+ * operations.
9
+ *
10
+ * Security Benefits:
11
+ *
12
+ * - Uses Key stretching
13
+ * - Hides the Initialization Vector
14
+ * - Does HMAC verification of source data
15
+ *
16
+ */
17
+ class Encryption
18
+ {
19
+
20
+ const METHOD = 'aes-256-cbc';
21
+
22
+ /**
23
+ * Encrypts (but does not authenticate) a message
24
+ *
25
+ * @param string $message - plaintext message
26
+ * @param string $key - encryption key (raw binary expected)
27
+ * @param boolean $encode - set to TRUE to return a base64-encoded
28
+ * @return string (raw binary)
29
+ */
30
+ public static function encrypt($message, $key, $encode = false)
31
+ {
32
+ $ivSize = openssl_cipher_iv_length(self::METHOD);
33
+ $iv = openssl_random_pseudo_bytes($ivSize);
34
+
35
+ $ciphertext = openssl_encrypt(
36
+ $message,
37
+ self::METHOD,
38
+ $key,
39
+ OPENSSL_RAW_DATA,
40
+ $iv
41
+ );
42
+
43
+ // Now let's pack the IV and the ciphertext together
44
+ // Naively, we can just concatenate
45
+ if ($encode)
46
+ {
47
+ return base64_encode($iv . $ciphertext);
48
+ }
49
+ return $iv . $ciphertext;
50
+ }
51
+
52
+ /**
53
+ * Decrypts (but does not verify) a message
54
+ *
55
+ * @param string $message - ciphertext message
56
+ * @param string $key - encryption key (raw binary expected)
57
+ * @param boolean $encoded - are we expecting an encoded string?
58
+ * @return string
59
+ */
60
+ public static function decrypt($message, $key, $encoded = false)
61
+ {
62
+ if ($encoded)
63
+ {
64
+ $message = base64_decode($message, true);
65
+ if ($message === false)
66
+ {
67
+ throw new Exception('Encryption failure');
68
+ }
69
+ }
70
+
71
+ $ivSize = openssl_cipher_iv_length(self::METHOD);
72
+ $iv = mb_substr($message, 0, $ivSize, '8bit');
73
+ $ciphertext = mb_substr($message, $ivSize, null, '8bit');
74
+
75
+ $plaintext = openssl_decrypt(
76
+ $ciphertext,
77
+ self::METHOD,
78
+ $key,
79
+ OPENSSL_RAW_DATA,
80
+ $iv
81
+ );
82
+
83
+ return $plaintext;
84
+ }
85
+ }
admin/partials/metabox_page_edit-display.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <input type="hidden" name="old_wplp_page" value="<?php echo $wplp_page; ?>"/>
2
+ <label class="selectit"><input type="radio" id="wplp_page_none" name="wplp_page" value="none"<?php checked($wplp_page, 'none');?>/>&nbsp;<?php _e('Show normally everywhere.', 'wp-hide-post');?></label>
3
+ <br />
4
+ <br />
5
+ <label class="selectit"><input type="radio" id="wplp_page_front" name="wplp_page" value="front"<?php checked($wplp_page, 'front');?>/>&nbsp;<?php _e('Hide when listing pages on the front page.', 'wp-hide-post');?></label>
6
+ <br />
7
+ <br />
8
+ <label class="selectit"><input type="radio" id="wplp_page_all" name="wplp_page" value="all"<?php checked($wplp_page, 'all');?>/>&nbsp;<?php _e('Hide everywhere pages are listed.', 'wp-hide-post');?><sup>*</sup></label>
9
+ <div style="height:18px;margin-left:20px">
10
+ <div id="wplp_page_search_show_div">
11
+ <label class="selectit"><input type="checkbox" id="wplp_page_search_show" name="wplp_page_search_show" value="1"<?php checked($wplp_page_search_show, 1);?>/>&nbsp;<?php _e('Keep in search results.', 'wp-hide-post');?></label>
12
+ <input type="hidden" name="old_wplp_page_search_show" value="<?php echo $wplp_page_search_show; ?>"/>
13
+ </div>
14
+ </div>
15
+ <br />
16
+ <div style="float:right;clear:both;font-size:x-small;">* Will still show up in sitemap.xml if you generate one automatically. See <a href="http://www.scriptburn.com/wp-low-profiler/">details</a>.</div>
17
+ <br />
18
+ <br />
19
+ <br />
20
+ <div style="float:right;font-size: xx-small;"><a href="http://www.scriptburn.com/posts/wp-hide-post/#comments"><?php _e("Leave feedback and report bugs...", 'wp-hide-post');?></a></div>
21
+ <br />
22
+ <div style="float:right;clear:both;font-size:xx-small;"><a href="http://wordpress.org/extend/plugins/wp-hide-post/"><?php _e("Give 'WP Hide Post' a good rating...", 'wp-hide-post');?></a></div>
23
+ <br />
24
+ <script type="text/javascript">
25
+ <!--
26
+ // toggle the wplp_page_search_show checkbox
27
+ var wplp_page_search_show_callback = function () {
28
+ if(jQuery("#wplp_page_all").is(":checked"))
29
+ jQuery("#wplp_page_search_show_div").show();
30
+ else
31
+ jQuery("#wplp_page_search_show_div").hide();
32
+ };
33
+ jQuery("#wplp_page_all").change(wplp_page_search_show_callback);
34
+ jQuery("#wplp_page_front").change(wplp_page_search_show_callback);
35
+ jQuery("#wplp_page_none").change(wplp_page_search_show_callback);
36
+ jQuery(document).ready( wplp_page_search_show_callback );
37
+ //-->
38
+ </script>
admin/partials/notice-display.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <fieldset class="inline-edit-col-right wphp_quickedit" >
2
+ <div class="inline-edit-col">
3
+ <span class="title inline-edit-categories-label">
4
+ <?php echo ($title); ?>
5
+ </span>
6
+ <?php echo ($html); ?>
7
+ </div>
8
+ </fieldset>
admin/partials/quick-edit-display.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+
2
+ <fieldset class="inline-edit-col-right wphp_quickedit" >
3
+ <div class="inline-edit-col">
4
+ <span class="title inline-edit-categories-label">
5
+ <?php echo ($title); ?>
6
+ </span>
7
+ <?php echo ($html); ?>
8
+ </div>
9
+ </fieldset>
admin/plugin/EDD_SL_Plugin_Updater.php ADDED
@@ -0,0 +1,387 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // uncomment this line for testing
4
+ //set_site_transient( 'update_plugins', null );
5
+
6
+ /**
7
+ * Allows plugins to use their own update API.
8
+ *
9
+ * @author Pippin Williamson
10
+ * @version 1.6
11
+ */
12
+ class EDD_SL_Plugin_Updater
13
+ {
14
+ private $api_url = '';
15
+ private $api_data = array();
16
+ private $name = '';
17
+ private $slug = '';
18
+ private $requests;
19
+
20
+ /**
21
+ * Class constructor.
22
+ *
23
+ * @uses plugin_basename()
24
+ * @uses hook()
25
+ *
26
+ * @param string $_api_url The URL pointing to the custom API endpoint.
27
+ * @param string $_plugin_file Path to the plugin file.
28
+ * @param array $_api_data Optional data to send with API calls.
29
+ * @return void
30
+ */
31
+ public function __construct($_api_url, $_plugin_file, $_api_data = null)
32
+ {
33
+ $this->api_url = trailingslashit($_api_url);
34
+ $this->api_data = $_api_data;
35
+ $this->name = plugin_basename($_plugin_file);
36
+ $this->slug = basename($_plugin_file, '.php');
37
+ $this->version = $_api_data['version'];
38
+
39
+ // Set up hooks.
40
+ if (wphp_ispro())
41
+ {
42
+ $this->init();
43
+ add_action('admin_init', array($this, 'show_changelog'));
44
+ }
45
+ }
46
+
47
+ /**
48
+ * Set up WordPress filters to hook into WP's update process.
49
+ *
50
+ * @uses add_filter()
51
+ *
52
+ * @return void
53
+ */
54
+ public function init()
55
+ {
56
+
57
+ add_filter('pre_set_site_transient_update_plugins', array($this, 'check_update'));
58
+ add_filter('plugins_api', array($this, 'plugins_api_filter'), 10, 3);
59
+
60
+ add_action('after_plugin_row_' . $this->name, array($this, 'show_update_notification'), 10, 2);
61
+
62
+ }
63
+
64
+ /**
65
+ * Check for Updates at the defined API endpoint and modify the update array.
66
+ *
67
+ * This function dives into the update API just when WordPress creates its update array,
68
+ * then adds a custom API call and injects the custom plugin data retrieved from the API.
69
+ * It is reassembled from parts of the native WordPress plugin update code.
70
+ * See wp-includes/update.php line 121 for the original wp_update_plugins() function.
71
+ *
72
+ * @uses api_request()
73
+ *
74
+ * @param array $_transient_data Update array build by WordPress.
75
+ * @return array Modified update array with custom plugin data.
76
+ */
77
+ public function check_update($_transient_data)
78
+ {
79
+
80
+ global $pagenow;
81
+
82
+ if (!is_object($_transient_data))
83
+ {
84
+ $_transient_data = new stdClass;
85
+ }
86
+
87
+ if ('plugins.php' == $pagenow && is_multisite())
88
+ {
89
+ return $_transient_data;
90
+ }
91
+ if (isset($this->requests[$this->slug]))
92
+ {
93
+ return $this->requests[$this->slug];
94
+ }
95
+ if (empty($_transient_data->response) || empty($_transient_data->response[$this->name]))
96
+ {
97
+
98
+ $version_info = $this->api_request('plugin_latest_version', array('slug' => $this->slug));
99
+ p_l($version_info);
100
+ if (false !== $version_info && is_object($version_info) && isset($version_info->new_version))
101
+ {
102
+
103
+ $this->did_check = true;
104
+
105
+ if (version_compare($this->version, $version_info->new_version, '<'))
106
+ {
107
+
108
+ $_transient_data->response[$this->name] = $version_info;
109
+ $_transient_data->response[$this->name]->plugin = $this->name;
110
+ }
111
+
112
+ $_transient_data->last_checked = time();
113
+ //$_transient_data->last_updated=date( ( 'M j, Y @ H:i' )
114
+ $_transient_data->checked[$this->name] = $this->version;
115
+
116
+ }
117
+ $this->requests[$this->slug] = $_transient_data;
118
+ }
119
+ //error_log(prin$_transient_data);
120
+
121
+ return $_transient_data;
122
+ }
123
+
124
+ /**
125
+ * show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise!
126
+ *
127
+ * @param string $file
128
+ * @param array $plugin
129
+ */
130
+ public function show_update_notification($file, $plugin)
131
+ {
132
+
133
+ if (!current_user_can('update_plugins'))
134
+ {
135
+ return;
136
+ }
137
+
138
+ if (!is_multisite())
139
+ {
140
+ return;
141
+ }
142
+
143
+ if ($this->name != $file)
144
+ {
145
+ return;
146
+ }
147
+
148
+ // Remove our filter on the site transient
149
+ remove_filter('pre_set_site_transient_update_plugins', array($this, 'check_update'), 10);
150
+
151
+ $update_cache = get_site_transient('update_plugins');
152
+
153
+ if (!is_object($update_cache) || empty($update_cache->response) || empty($update_cache->response[$this->name]))
154
+ {
155
+
156
+ $cache_key = md5('edd_plugin_' . sanitize_key($this->name) . '_version_info');
157
+ $version_info = get_transient($cache_key);
158
+
159
+ if (false === $version_info)
160
+ {
161
+
162
+ $version_info = $this->api_request('plugin_latest_version', array('slug' => $this->slug));
163
+ //p_l($version_info);
164
+
165
+ set_transient($cache_key, $version_info, 3600);
166
+ }
167
+
168
+ if (!is_object($version_info))
169
+ {
170
+ return;
171
+ }
172
+
173
+ if (version_compare($this->version, $version_info->new_version, '<'))
174
+ {
175
+
176
+ $update_cache->response[$this->name] = $version_info;
177
+
178
+ }
179
+
180
+ $update_cache->last_checked = time();
181
+ $update_cache->checked[$this->name] = $this->version;
182
+
183
+ set_site_transient('update_plugins', $update_cache);
184
+
185
+ }
186
+ else
187
+ {
188
+
189
+ $version_info = $update_cache->response[$this->name];
190
+
191
+ }
192
+
193
+ // Restore our filter
194
+ add_filter('pre_set_site_transient_update_plugins', array($this, 'check_update'));
195
+
196
+ if (!empty($update_cache->response[$this->name]) && version_compare($this->version, $version_info->new_version, '<'))
197
+ {
198
+
199
+ // build a plugin list row, with update notification
200
+ $wp_list_table = _get_list_table('WP_Plugins_List_Table');
201
+ echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">';
202
+
203
+ $changelog_link = self_admin_url('index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911');
204
+
205
+ if (empty($version_info->download_link))
206
+ {
207
+ printf(
208
+ __('There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'edd'),
209
+ esc_html($version_info->name),
210
+ esc_url($changelog_link),
211
+ esc_html($version_info->new_version)
212
+ );
213
+ }
214
+ else
215
+ {
216
+ printf(
217
+ __('There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a> or <a href="%4$s">update now</a>.', 'edd'),
218
+ esc_html($version_info->name),
219
+ esc_url($changelog_link),
220
+ esc_html($version_info->new_version),
221
+ esc_url(wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=') . $this->name, 'upgrade-plugin_' . $this->name))
222
+ );
223
+ }
224
+
225
+ echo '</div></td></tr>';
226
+ }
227
+ }
228
+
229
+ /**
230
+ * Updates information on the "View version x.x details" page with custom data.
231
+ *
232
+ * @uses api_request()
233
+ *
234
+ * @param mixed $_data
235
+ * @param string $_action
236
+ * @param object $_args
237
+ * @return object $_data
238
+ */
239
+ public function plugins_api_filter($_data, $_action = '', $_args = null)
240
+ {
241
+
242
+ if ($_action != 'plugin_information')
243
+ {
244
+
245
+ return $_data;
246
+
247
+ }
248
+
249
+ if (!isset($_args->slug) || ($_args->slug != $this->slug))
250
+ {
251
+
252
+ return $_data;
253
+
254
+ }
255
+
256
+ $to_send = array(
257
+ 'slug' => $this->slug,
258
+ 'is_ssl' => is_ssl(),
259
+ 'fields' => array(
260
+ 'banners' => false, // These will be supported soon hopefully
261
+ 'reviews' => false,
262
+ ),
263
+ );
264
+
265
+ $api_response = $this->api_request('plugin_information', $to_send);
266
+
267
+ if (false !== $api_response)
268
+ {
269
+ $_data = $api_response;
270
+ }
271
+
272
+ return $_data;
273
+ }
274
+
275
+ /**
276
+ * Disable SSL verification in order to prevent download update failures
277
+ *
278
+ * @param array $args
279
+ * @param string $url
280
+ * @return object $array
281
+ */
282
+ public function http_request_args($args, $url)
283
+ {
284
+ // If it is an https request and we are performing a package download, disable ssl verification
285
+ if (strpos($url, 'https://') !== false && strpos($url, 'edd_action=package_download'))
286
+ {
287
+ $args['sslverify'] = false;
288
+ }
289
+ return $args;
290
+ }
291
+
292
+ /**
293
+ * Calls the API and, if successfull, returns the object delivered by the API.
294
+ *
295
+ * @uses get_bloginfo()
296
+ * @uses wp_remote_post()
297
+ * @uses is_wp_error()
298
+ *
299
+ * @param string $_action The requested action.
300
+ * @param array $_data Parameters for the API action.
301
+ * @return false||object
302
+ */
303
+ private function api_request($_action, $_data)
304
+ {
305
+
306
+ global $wp_version;
307
+
308
+ $data = array_merge($this->api_data, $_data);
309
+
310
+ if ($data['slug'] != $this->slug)
311
+ {
312
+ return;
313
+ }
314
+
315
+ if (empty($data['license']))
316
+ {
317
+ return;
318
+ }
319
+
320
+ if ($this->api_url == home_url())
321
+ {
322
+ return false; // Don't allow a plugin to ping itself
323
+ }
324
+
325
+ $api_params = array(
326
+ 'edd_action' => 'get_version',
327
+ 'license' => $data['license'],
328
+ 'item_name' => isset($data['item_name']) ? $data['item_name'] : false,
329
+ 'item_id' => isset($data['item_id']) ? $data['item_id'] : false,
330
+ 'slug' => $data['slug'],
331
+ 'author' => $data['author'],
332
+ 'url' => home_url(),
333
+ );
334
+
335
+ $request = wp_remote_post($this->api_url, array('timeout' => 15, 'sslverify' => false, 'body' => $api_params));
336
+ //p_l($request);
337
+ if (!is_wp_error($request))
338
+ {
339
+ $request = json_decode(wp_remote_retrieve_body($request));
340
+ }
341
+
342
+ if ($request && isset($request->sections))
343
+ {
344
+ $request->sections = maybe_unserialize($request->sections);
345
+ }
346
+ else
347
+ {
348
+ $request = false;
349
+ }
350
+
351
+ return $request;
352
+ }
353
+
354
+ public function show_changelog()
355
+ {
356
+
357
+ if (empty($_REQUEST['edd_sl_action']) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'])
358
+ {
359
+ return;
360
+ }
361
+
362
+ if (empty($_REQUEST['plugin']))
363
+ {
364
+ return;
365
+ }
366
+
367
+ if (empty($_REQUEST['slug']))
368
+ {
369
+ return;
370
+ }
371
+
372
+ if (!current_user_can('update_plugins'))
373
+ {
374
+ wp_die(__('You do not have permission to install plugin updates', 'edd'), __('Error', 'edd'), array('response' => 403));
375
+ }
376
+
377
+ $response = $this->api_request('plugin_latest_version', array('slug' => $_REQUEST['slug']));
378
+
379
+ if ($response && isset($response->sections['changelog']))
380
+ {
381
+ echo '<div style="background:#fff;padding:10px;">' . $response->sections['changelog'] . '</div>';
382
+ }
383
+
384
+ exit;
385
+ }
386
+
387
+ }
admin/plugin/EDD_SL_Theme_Updater.php ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class EDD_SL_Theme_Updater {
3
+ private $remote_api_url;
4
+ private $request_data;
5
+ private $response_key;
6
+ private $theme_slug;
7
+ private $license_key;
8
+ private $version;
9
+ private $author;
10
+
11
+ function __construct( $args = array() ) {
12
+ $args = wp_parse_args( $args, array(
13
+ 'remote_api_url' => 'http://scriptburn.com',
14
+ 'request_data' => array(),
15
+ 'theme_slug' => get_template(),
16
+ 'item_name' => '',
17
+ 'license' => '',
18
+ 'version' => '',
19
+ 'author' => ''
20
+ ) );
21
+ extract( $args );
22
+
23
+ $theme = wp_get_theme( sanitize_key( $theme_slug ) );
24
+ $this->license = $license;
25
+ $this->item_name = $item_name;
26
+ $this->version = ! empty( $version ) ? $version : $theme->get( 'Version' );
27
+ $this->theme_slug = sanitize_key( $theme_slug );
28
+ $this->author = $author;
29
+ $this->remote_api_url = $remote_api_url;
30
+ $this->response_key = $this->theme_slug . '-update-response';
31
+
32
+ add_filter( 'site_transient_update_themes', array( &$this, 'theme_update_transient' ) );
33
+ add_filter( 'delete_site_transient_update_themes', array( &$this, 'delete_theme_update_transient' ) );
34
+ add_action( 'load-update-core.php', array( &$this, 'delete_theme_update_transient' ) );
35
+ add_action( 'load-themes.php', array( &$this, 'delete_theme_update_transient' ) );
36
+ add_action( 'load-themes.php', array( &$this, 'load_themes_screen' ) );
37
+ //$this->check_for_update();
38
+ }
39
+
40
+ function load_themes_screen() {
41
+ add_thickbox();
42
+ add_action( 'admin_notices', array( &$this, 'update_nag' ) );
43
+ }
44
+
45
+ function update_nag() {
46
+ error_log("update_nag");
47
+ $theme = wp_get_theme( $this->theme_slug );
48
+
49
+ $api_response = get_transient( $this->response_key );
50
+
51
+ if( false === $api_response )
52
+ return;
53
+
54
+ $update_url = wp_nonce_url( 'update.php?action=upgrade-theme&amp;theme=' . urlencode( $this->theme_slug ), 'upgrade-theme_' . $this->theme_slug );
55
+ $update_onclick = ' onclick="if ( confirm(\'' . esc_js( __( "Updating this theme will lose any customizations you have made. 'Cancel' to stop, 'OK' to update." ) ) . '\') ) {return true;}return false;"';
56
+
57
+ if ( version_compare( $this->version, $api_response->new_version, '<' ) ) {
58
+
59
+ echo '<div id="update-nag">';
60
+ printf( '<strong>%1$s %2$s</strong> is available. <a href="%3$s" class="thickbox" title="%4s">Check out what\'s new</a> or <a href="%5$s"%6$s>update now</a>.',
61
+ $theme->get( 'Name' ),
62
+ $api_response->new_version,
63
+ '#TB_inline?width=640&amp;inlineId=' . $this->theme_slug . '_changelog',
64
+ $theme->get( 'Name' ),
65
+ $update_url,
66
+ $update_onclick
67
+ );
68
+ echo '</div>';
69
+ echo '<div id="' . $this->theme_slug . '_' . 'changelog" style="display:none;">';
70
+ echo wpautop( $api_response->sections['changelog'] );
71
+ echo '</div>';
72
+ }
73
+ }
74
+
75
+ function theme_update_transient( $value ) {
76
+ $update_data = $this->check_for_update();
77
+ if ( $update_data ) {
78
+ $value->response[ $this->theme_slug ] = $update_data;
79
+ }
80
+ return $value;
81
+ }
82
+
83
+ function delete_theme_update_transient() {
84
+ delete_transient( $this->response_key );
85
+ }
86
+
87
+ function check_for_update() {
88
+
89
+ $theme = wp_get_theme( $this->theme_slug );
90
+ //delete_transient( $this->response_key );
91
+ $update_data = get_transient( $this->response_key );
92
+ //print_nice($update_data);
93
+ if ( false === $update_data ) {
94
+ $failed = false;
95
+
96
+
97
+ if( empty( $this->license ) )
98
+ return false;
99
+
100
+ $api_params = array(
101
+ 'edd_action' => 'get_version',
102
+ 'license' => $this->license,
103
+ 'name' => $this->item_name,
104
+ 'slug' => $this->theme_slug,
105
+ 'author' => $this->author,
106
+ 'url' => home_url()
107
+ );
108
+
109
+ $response = wp_remote_post( $this->remote_api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
110
+ //print_nice($response);
111
+ // make sure the response was successful
112
+ if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
113
+ $failed = true;
114
+ }
115
+
116
+ $update_data = json_decode( wp_remote_retrieve_body( $response ) );
117
+ if ( ! is_object( $update_data ) ) {
118
+ $failed = true;
119
+ }
120
+
121
+ // if the response failed, try again in 30 minutes
122
+ if ( $failed ) {
123
+ $data = new stdClass;
124
+ $data->new_version = $this->version;
125
+ set_transient( $this->response_key, $data, strtotime( '+30 minutes' ) );
126
+ return false;
127
+ }
128
+
129
+ // if the status is 'ok', return the update arguments
130
+ if ( ! $failed ) {
131
+ $update_data->sections = maybe_unserialize( $update_data->sections );
132
+ set_transient( $this->response_key, $update_data, strtotime( '+12 hours' ) );
133
+ }
134
+ }
135
+ //die('x');
136
+ if ( version_compare( $this->version, $update_data->new_version, '>=' ) ) {
137
+ return false;
138
+ }
139
+
140
+ return (array) $update_data;
141
+ }
142
+ }
admin/plugin/SCB_Item_Helper.php ADDED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if (!class_exists('SCB_Item_Helper'))
4
+ {
5
+
6
+ class SCB_Item_Helper
7
+ {
8
+ private $item_file_name = "";
9
+ private $store = "";
10
+ private $item_arr = array();
11
+ private $license_key = "";
12
+ private $item_type = 'plugin';
13
+ private $license_status = '';
14
+ private $transient_name = 'scb_lic_data';
15
+
16
+ public function __construct($store, $item_file_name, $license_key, $item_type = 'plugin', $license_status)
17
+ {
18
+ global $pagenow;
19
+ $custom_name = substr($item_type, 7);
20
+ $is_custom = substr($item_type, 0, 7) == 'custom_' && strlen($custom_name) > 0;
21
+ $valid_items = array('plugin', 'theme');
22
+ if (!in_array($item_type, $valid_items))
23
+ {
24
+ if (!$is_custom)
25
+ {
26
+ throw new Exception('Invalid tem Type');
27
+ return false;
28
+ }
29
+ }
30
+ if (substr($item_file_name, 0, strlen(WP_PLUGIN_DIR)) == WP_PLUGIN_DIR)
31
+ {
32
+ $this->item_file_name = ltrim(substr($item_file_name, strlen(WP_PLUGIN_DIR)), "/");
33
+ }
34
+ else
35
+ {
36
+ $this->item_file_name = $item_file_name;
37
+ }
38
+ $this->store = $store;
39
+ $this->item_type = $item_type;
40
+ $this->license_key = $license_key;
41
+ $this->license_status = $license_status;
42
+ //$this->debug('license', __FUNCTION__ . "-" . __LINE__, 'init');
43
+
44
+ if (!$is_custom)
45
+ {
46
+ add_action('admin_init', array($this, $item_type . '_updater'));
47
+ }
48
+ else
49
+ {
50
+ call_user_function($custom_name . "_updater");
51
+
52
+ }
53
+ $update_cache = get_site_transient('update_plugins');
54
+ if ( isset($update_cache->response[$this->item_file_name]) && ($update_cache->response[$this->item_file_name]->upgrade_notice) )
55
+ {
56
+ $upgrade_notice=$update_cache->response[$this->item_file_name]->upgrade_notice;
57
+ $hook = "in_plugin_update_message-" . $this->item_file_name;
58
+ add_action($hook, function ($plugin_data, $r) use($upgrade_notice)
59
+ {
60
+
61
+ echo($upgrade_notice);
62
+
63
+ }, 20, 2);
64
+ }
65
+
66
+ }
67
+ public function get_license_key()
68
+ {
69
+ return $this->license_key;
70
+
71
+ }
72
+ public function refresh_plugin_data()
73
+ {
74
+ $default = array('version' => "0", 'license' => "", "item_name" => '', "author" => "");
75
+
76
+ try {
77
+ $plugin_file = WP_PLUGIN_DIR . "/" . $this->item_file_name;
78
+ // $this->debug('license', __FUNCTION__ . "-" . __LINE__, $plugin_file);
79
+ if (!function_exists('get_plugin_data'))
80
+ {
81
+ include_once ABSPATH . "wp-admin/includes/plugin.php";
82
+ }
83
+ //$this->debug('license', __FUNCTION__ . "-" . __LINE__, $d);
84
+
85
+ $this->item_arr[$this->item_file_name] = get_plugin_data($plugin_file);
86
+ set_transient($this->transient_name, $this->item_arr);
87
+ return $this->item_arr;
88
+ }
89
+ catch (exception $e)
90
+ {
91
+ return $default;
92
+ }
93
+ }
94
+ public function plugin_data($key = "", $fresh = false)
95
+ {
96
+ if ($fresh)
97
+ {
98
+ $this->refresh_plugin_data();
99
+ }
100
+ else
101
+ {
102
+
103
+ $this->item_arr = get_transient($this->transient_name);
104
+ if (!isset($this->item_arr[$this->item_file_name]))
105
+ {
106
+ $ret = $this->refresh_plugin_data();
107
+ return $key ? $ret[$this->item_file_name][$key] : $ret[$this->item_file_name];
108
+
109
+ }
110
+
111
+ }
112
+ return $key ? $this->item_arr[$this->item_file_name][$key] : $this->item_arr[$this->item_file_name];
113
+
114
+ }
115
+ public function refresh_theme_data()
116
+ {
117
+ $default = array('version' => "0", 'license' => "", "item_name" => '', "author" => "");
118
+
119
+ try {
120
+ $theme_file = get_theme_root() . "/" . $this->item_file_name;
121
+ // $this->debug('license', __FUNCTION__ . "-" . __LINE__, $plugin_file);
122
+ if (!function_exists('wp_get_theme'))
123
+ {
124
+ include_once ABSPATH . "wp-admin/includes/theme.php";
125
+ }
126
+ //$this->debug('license', __FUNCTION__ . "-" . __LINE__, $d);
127
+
128
+ $this->item_arr[$this->item_file_name] = wp_get_theme($this->item_file_name);
129
+ set_transient('wpmovies_themes', $this->item_arr);
130
+ $return = $this->item_arr[$this->item_file_name];
131
+ }
132
+ catch (exception $e)
133
+ {
134
+ return $default;
135
+ }
136
+ }
137
+ public function theme_data($key = "", $fresh = false)
138
+ {
139
+ if ($fresh)
140
+ {
141
+ $this->refresh_theme_data();
142
+ }
143
+ else
144
+ {
145
+
146
+ $this->item_arr = get_transient('wpmovies_themes');
147
+ if (!isset($this->item_arr[$this->item_file_name]))
148
+ {
149
+ $ret = $this->refresh_theme_data();
150
+ return $key ? $ret[$this->item_file_name][$key] : $ret[$this->item_file_name];
151
+ }
152
+ }
153
+ return $key ? $this->item_arr[$this->item_file_name][$key] : $this->item_arr[$this->item_file_name];
154
+
155
+ }
156
+
157
+ public function plugin_updater()
158
+ {
159
+
160
+ $plugin_data = $this->plugin_data("", true);
161
+ $plugin_conf = array(
162
+ 'version' => $plugin_data['Version'], // current version number
163
+ 'license' => $this->get_license_key(),
164
+ 'item_name' => $plugin_data['Name'],
165
+ 'author' => $plugin_data['AuthorName'],
166
+ 'url' => home_url(),
167
+ );
168
+ //$this->debug('license', __FUNCTION__ . "-" . __LINE__, 'plugin_updater');
169
+
170
+ $updater = new EDD_SL_Plugin_Updater($this->store, $this->item_file_name, $plugin_conf);
171
+ }
172
+
173
+ public function theme_updater()
174
+ {
175
+ $theme_data = $this->theme_data("", true);
176
+ $theme_conf = array(
177
+ 'theme_slug' => $this->item_file_name,
178
+ 'remote_api_url' => $this->store,
179
+ 'version' => $theme_data->Version, // current version number
180
+ 'license' => $this->get_license_key(),
181
+ 'item_name' => $theme_data->Name,
182
+ 'author' => $theme_data->Author,
183
+ 'url' => home_url(),
184
+ );
185
+ $edd_updater = new EDD_SL_Theme_Updater($theme_conf);
186
+ }
187
+
188
+ }
189
+
190
+ }
admin/plugin/autoload.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (!class_exists('EDD_SL_Plugin_Updater'))
3
+ {
4
+ include_once dirname(__FILE__) . "/EDD_SL_Plugin_Updater.php";
5
+ }
6
+
7
+ if (!class_exists('EDD_SL_Theme_Updater'))
8
+ {
9
+ include_once dirname(__FILE__) . "/EDD_SL_Theme_Updater.php";
10
+ }
11
+
12
+ if (!class_exists('SCB_Item_Helper'))
13
+ {
14
+ include_once dirname(__FILE__) . "/SCB_Item_Helper.php";
15
+ }
admin/plugin/testlog.txt ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [Debug for [license] item [get_license_data-97]-> Array
2
+ (
3
+ [success] => 1
4
+ [license] => invalid
5
+ [item_name] => WP+movies
6
+ [expires] =>
7
+ [payment_id] =>
8
+ [customer_name] =>
9
+ [customer_email] =>
10
+ [license_limit] =>
11
+ [site_count] => 0
12
+ [activations_left] => unlimited
13
+ )
14
+
admin/settings/assets/chosen-sprite.png ADDED
Binary file
admin/settings/assets/chosen-sprite@2x.png ADDED
Binary file
admin/settings/assets/chosen.jquery.min.js ADDED
@@ -0,0 +1,2 @@
 
 
1
+ /* Chosen v1.1.0 | (c) 2011-2013 by Harvest | MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md */
2
+ !function(){var a,AbstractChosen,Chosen,SelectParser,b,c={}.hasOwnProperty,d=function(a,b){function d(){this.constructor=a}for(var e in b)c.call(b,e)&&(a[e]=b[e]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a};SelectParser=function(){function SelectParser(){this.options_index=0,this.parsed=[]}return SelectParser.prototype.add_node=function(a){return"OPTGROUP"===a.nodeName.toUpperCase()?this.add_group(a):this.add_option(a)},SelectParser.prototype.add_group=function(a){var b,c,d,e,f,g;for(b=this.parsed.length,this.parsed.push({array_index:b,group:!0,label:this.escapeExpression(a.label),children:0,disabled:a.disabled}),f=a.childNodes,g=[],d=0,e=f.length;e>d;d++)c=f[d],g.push(this.add_option(c,b,a.disabled));return g},SelectParser.prototype.add_option=function(a,b,c){return"OPTION"===a.nodeName.toUpperCase()?(""!==a.text?(null!=b&&(this.parsed[b].children+=1),this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,value:a.value,text:a.text,html:a.innerHTML,selected:a.selected,disabled:c===!0?c:a.disabled,group_array_index:b,classes:a.className,style:a.style.cssText})):this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,empty:!0}),this.options_index+=1):void 0},SelectParser.prototype.escapeExpression=function(a){var b,c;return null==a||a===!1?"":/[\&\<\>\"\'\`]/.test(a)?(b={"<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},c=/&(?!\w+;)|[\<\>\"\'\`]/g,a.replace(c,function(a){return b[a]||"&amp;"})):a},SelectParser}(),SelectParser.select_to_array=function(a){var b,c,d,e,f;for(c=new SelectParser,f=a.childNodes,d=0,e=f.length;e>d;d++)b=f[d],c.add_node(b);return c.parsed},AbstractChosen=function(){function AbstractChosen(a,b){this.form_field=a,this.options=null!=b?b:{},AbstractChosen.browser_is_supported()&&(this.is_multiple=this.form_field.multiple,this.set_default_text(),this.set_default_values(),this.setup(),this.set_up_html(),this.register_observers())}return AbstractChosen.prototype.set_default_values=function(){var a=this;return this.click_test_action=function(b){return a.test_active_click(b)},this.activate_action=function(b){return a.activate_field(b)},this.active_field=!1,this.mouse_on_container=!1,this.results_showing=!1,this.result_highlighted=null,this.allow_single_deselect=null!=this.options.allow_single_deselect&&null!=this.form_field.options[0]&&""===this.form_field.options[0].text?this.options.allow_single_deselect:!1,this.disable_search_threshold=this.options.disable_search_threshold||0,this.disable_search=this.options.disable_search||!1,this.enable_split_word_search=null!=this.options.enable_split_word_search?this.options.enable_split_word_search:!0,this.group_search=null!=this.options.group_search?this.options.group_search:!0,this.search_contains=this.options.search_contains||!1,this.single_backstroke_delete=null!=this.options.single_backstroke_delete?this.options.single_backstroke_delete:!0,this.max_selected_options=this.options.max_selected_options||1/0,this.inherit_select_classes=this.options.inherit_select_classes||!1,this.display_selected_options=null!=this.options.display_selected_options?this.options.display_selected_options:!0,this.display_disabled_options=null!=this.options.display_disabled_options?this.options.display_disabled_options:!0},AbstractChosen.prototype.set_default_text=function(){return this.default_text=this.form_field.getAttribute("data-placeholder")?this.form_field.getAttribute("data-placeholder"):this.is_multiple?this.options.placeholder_text_multiple||this.options.placeholder_text||AbstractChosen.default_multiple_text:this.options.placeholder_text_single||this.options.placeholder_text||AbstractChosen.default_single_text,this.results_none_found=this.form_field.getAttribute("data-no_results_text")||this.options.no_results_text||AbstractChosen.default_no_result_text},AbstractChosen.prototype.mouse_enter=function(){return this.mouse_on_container=!0},AbstractChosen.prototype.mouse_leave=function(){return this.mouse_on_container=!1},AbstractChosen.prototype.input_focus=function(){var a=this;if(this.is_multiple){if(!this.active_field)return setTimeout(function(){return a.container_mousedown()},50)}else if(!this.active_field)return this.activate_field()},AbstractChosen.prototype.input_blur=function(){var a=this;return this.mouse_on_container?void 0:(this.active_field=!1,setTimeout(function(){return a.blur_test()},100))},AbstractChosen.prototype.results_option_build=function(a){var b,c,d,e,f;for(b="",f=this.results_data,d=0,e=f.length;e>d;d++)c=f[d],b+=c.group?this.result_add_group(c):this.result_add_option(c),(null!=a?a.first:void 0)&&(c.selected&&this.is_multiple?this.choice_build(c):c.selected&&!this.is_multiple&&this.single_set_selected_text(c.text));return b},AbstractChosen.prototype.result_add_option=function(a){var b,c;return a.search_match?this.include_option_in_results(a)?(b=[],a.disabled||a.selected&&this.is_multiple||b.push("active-result"),!a.disabled||a.selected&&this.is_multiple||b.push("disabled-result"),a.selected&&b.push("result-selected"),null!=a.group_array_index&&b.push("group-option"),""!==a.classes&&b.push(a.classes),c=document.createElement("li"),c.className=b.join(" "),c.style.cssText=a.style,c.setAttribute("data-option-array-index",a.array_index),c.innerHTML=a.search_text,this.outerHTML(c)):"":""},AbstractChosen.prototype.result_add_group=function(a){var b;return a.search_match||a.group_match?a.active_options>0?(b=document.createElement("li"),b.className="group-result",b.innerHTML=a.search_text,this.outerHTML(b)):"":""},AbstractChosen.prototype.results_update_field=function(){return this.set_default_text(),this.is_multiple||this.results_reset_cleanup(),this.result_clear_highlight(),this.results_build(),this.results_showing?this.winnow_results():void 0},AbstractChosen.prototype.reset_single_select_options=function(){var a,b,c,d,e;for(d=this.results_data,e=[],b=0,c=d.length;c>b;b++)a=d[b],a.selected?e.push(a.selected=!1):e.push(void 0);return e},AbstractChosen.prototype.results_toggle=function(){return this.results_showing?this.results_hide():this.results_show()},AbstractChosen.prototype.results_search=function(){return this.results_showing?this.winnow_results():this.results_show()},AbstractChosen.prototype.winnow_results=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m;for(this.no_results_clear(),e=0,g=this.get_search_text(),a=g.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),d=this.search_contains?"":"^",c=new RegExp(d+a,"i"),j=new RegExp(a,"i"),m=this.results_data,k=0,l=m.length;l>k;k++)b=m[k],b.search_match=!1,f=null,this.include_option_in_results(b)&&(b.group&&(b.group_match=!1,b.active_options=0),null!=b.group_array_index&&this.results_data[b.group_array_index]&&(f=this.results_data[b.group_array_index],0===f.active_options&&f.search_match&&(e+=1),f.active_options+=1),(!b.group||this.group_search)&&(b.search_text=b.group?b.label:b.html,b.search_match=this.search_string_match(b.search_text,c),b.search_match&&!b.group&&(e+=1),b.search_match?(g.length&&(h=b.search_text.search(j),i=b.search_text.substr(0,h+g.length)+"</em>"+b.search_text.substr(h+g.length),b.search_text=i.substr(0,h)+"<em>"+i.substr(h)),null!=f&&(f.group_match=!0)):null!=b.group_array_index&&this.results_data[b.group_array_index].search_match&&(b.search_match=!0)));return this.result_clear_highlight(),1>e&&g.length?(this.update_results_content(""),this.no_results(g)):(this.update_results_content(this.results_option_build()),this.winnow_results_set_highlight())},AbstractChosen.prototype.search_string_match=function(a,b){var c,d,e,f;if(b.test(a))return!0;if(this.enable_split_word_search&&(a.indexOf(" ")>=0||0===a.indexOf("["))&&(d=a.replace(/\[|\]/g,"").split(" "),d.length))for(e=0,f=d.length;f>e;e++)if(c=d[e],b.test(c))return!0},AbstractChosen.prototype.choices_count=function(){var a,b,c,d;if(null!=this.selected_option_count)return this.selected_option_count;for(this.selected_option_count=0,d=this.form_field.options,b=0,c=d.length;c>b;b++)a=d[b],a.selected&&(this.selected_option_count+=1);return this.selected_option_count},AbstractChosen.prototype.choices_click=function(a){return a.preventDefault(),this.results_showing||this.is_disabled?void 0:this.results_show()},AbstractChosen.prototype.keyup_checker=function(a){var b,c;switch(b=null!=(c=a.which)?c:a.keyCode,this.search_field_scale(),b){case 8:if(this.is_multiple&&this.backstroke_length<1&&this.choices_count()>0)return this.keydown_backstroke();if(!this.pending_backstroke)return this.result_clear_highlight(),this.results_search();break;case 13:if(a.preventDefault(),this.results_showing)return this.result_select(a);break;case 27:return this.results_showing&&this.results_hide(),!0;case 9:case 38:case 40:case 16:case 91:case 17:break;default:return this.results_search()}},AbstractChosen.prototype.clipboard_event_checker=function(){var a=this;return setTimeout(function(){return a.results_search()},50)},AbstractChosen.prototype.container_width=function(){return null!=this.options.width?this.options.width:""+this.form_field.offsetWidth+"px"},AbstractChosen.prototype.include_option_in_results=function(a){return this.is_multiple&&!this.display_selected_options&&a.selected?!1:!this.display_disabled_options&&a.disabled?!1:a.empty?!1:!0},AbstractChosen.prototype.search_results_touchstart=function(a){return this.touch_started=!0,this.search_results_mouseover(a)},AbstractChosen.prototype.search_results_touchmove=function(a){return this.touch_started=!1,this.search_results_mouseout(a)},AbstractChosen.prototype.search_results_touchend=function(a){return this.touch_started?this.search_results_mouseup(a):void 0},AbstractChosen.prototype.outerHTML=function(a){var b;return a.outerHTML?a.outerHTML:(b=document.createElement("div"),b.appendChild(a),b.innerHTML)},AbstractChosen.browser_is_supported=function(){return"Microsoft Internet Explorer"===window.navigator.appName?document.documentMode>=8:/iP(od|hone)/i.test(window.navigator.userAgent)?!1:/Android/i.test(window.navigator.userAgent)&&/Mobile/i.test(window.navigator.userAgent)?!1:!0},AbstractChosen.default_multiple_text="Select Some Options",AbstractChosen.default_single_text="Select an Option",AbstractChosen.default_no_result_text="No results match",AbstractChosen}(),a=jQuery,a.fn.extend({chosen:function(b){return AbstractChosen.browser_is_supported()?this.each(function(){var c,d;c=a(this),d=c.data("chosen"),"destroy"===b&&d?d.destroy():d||c.data("chosen",new Chosen(this,b))}):this}}),Chosen=function(c){function Chosen(){return b=Chosen.__super__.constructor.apply(this,arguments)}return d(Chosen,c),Chosen.prototype.setup=function(){return this.form_field_jq=a(this.form_field),this.current_selectedIndex=this.form_field.selectedIndex,this.is_rtl=this.form_field_jq.hasClass("chosen-rtl")},Chosen.prototype.set_up_html=function(){var b,c;return b=["chosen-container"],b.push("chosen-container-"+(this.is_multiple?"multi":"single")),this.inherit_select_classes&&this.form_field.className&&b.push(this.form_field.className),this.is_rtl&&b.push("chosen-rtl"),c={"class":b.join(" "),style:"width: "+this.container_width()+";",title:this.form_field.title},this.form_field.id.length&&(c.id=this.form_field.id.replace(/[^\w]/g,"_")+"_chosen"),this.container=a("<div />",c),this.is_multiple?this.container.html('<ul class="chosen-choices"><li class="search-field"><input type="text" value="'+this.default_text+'" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chosen-drop"><ul class="chosen-results"></ul></div>'):this.container.html('<a class="chosen-single chosen-default" tabindex="-1"><span>'+this.default_text+'</span><div><b></b></div></a><div class="chosen-drop"><div class="chosen-search"><input type="text" autocomplete="off" /></div><ul class="chosen-results"></ul></div>'),this.form_field_jq.hide().after(this.container),this.dropdown=this.container.find("div.chosen-drop").first(),this.search_field=this.container.find("input").first(),this.search_results=this.container.find("ul.chosen-results").first(),this.search_field_scale(),this.search_no_results=this.container.find("li.no-results").first(),this.is_multiple?(this.search_choices=this.container.find("ul.chosen-choices").first(),this.search_container=this.container.find("li.search-field").first()):(this.search_container=this.container.find("div.chosen-search").first(),this.selected_item=this.container.find(".chosen-single").first()),this.results_build(),this.set_tab_index(),this.set_label_behavior(),this.form_field_jq.trigger("chosen:ready",{chosen:this})},Chosen.prototype.register_observers=function(){var a=this;return this.container.bind("mousedown.chosen",function(b){a.container_mousedown(b)}),this.container.bind("mouseup.chosen",function(b){a.container_mouseup(b)}),this.container.bind("mouseenter.chosen",function(b){a.mouse_enter(b)}),this.container.bind("mouseleave.chosen",function(b){a.mouse_leave(b)}),this.search_results.bind("mouseup.chosen",function(b){a.search_results_mouseup(b)}),this.search_results.bind("mouseover.chosen",function(b){a.search_results_mouseover(b)}),this.search_results.bind("mouseout.chosen",function(b){a.search_results_mouseout(b)}),this.search_results.bind("mousewheel.chosen DOMMouseScroll.chosen",function(b){a.search_results_mousewheel(b)}),this.search_results.bind("touchstart.chosen",function(b){a.search_results_touchstart(b)}),this.search_results.bind("touchmove.chosen",function(b){a.search_results_touchmove(b)}),this.search_results.bind("touchend.chosen",function(b){a.search_results_touchend(b)}),this.form_field_jq.bind("chosen:updated.chosen",function(b){a.results_update_field(b)}),this.form_field_jq.bind("chosen:activate.chosen",function(b){a.activate_field(b)}),this.form_field_jq.bind("chosen:open.chosen",function(b){a.container_mousedown(b)}),this.form_field_jq.bind("chosen:close.chosen",function(b){a.input_blur(b)}),this.search_field.bind("blur.chosen",function(b){a.input_blur(b)}),this.search_field.bind("keyup.chosen",function(b){a.keyup_checker(b)}),this.search_field.bind("keydown.chosen",function(b){a.keydown_checker(b)}),this.search_field.bind("focus.chosen",function(b){a.input_focus(b)}),this.search_field.bind("cut.chosen",function(b){a.clipboard_event_checker(b)}),this.search_field.bind("paste.chosen",function(b){a.clipboard_event_checker(b)}),this.is_multiple?this.search_choices.bind("click.chosen",function(b){a.choices_click(b)}):this.container.bind("click.chosen",function(a){a.preventDefault()})},Chosen.prototype.destroy=function(){return a(this.container[0].ownerDocument).unbind("click.chosen",this.click_test_action),this.search_field[0].tabIndex&&(this.form_field_jq[0].tabIndex=this.search_field[0].tabIndex),this.container.remove(),this.form_field_jq.removeData("chosen"),this.form_field_jq.show()},Chosen.prototype.search_field_disabled=function(){return this.is_disabled=this.form_field_jq[0].disabled,this.is_disabled?(this.container.addClass("chosen-disabled"),this.search_field[0].disabled=!0,this.is_multiple||this.selected_item.unbind("focus.chosen",this.activate_action),this.close_field()):(this.container.removeClass("chosen-disabled"),this.search_field[0].disabled=!1,this.is_multiple?void 0:this.selected_item.bind("focus.chosen",this.activate_action))},Chosen.prototype.container_mousedown=function(b){return this.is_disabled||(b&&"mousedown"===b.type&&!this.results_showing&&b.preventDefault(),null!=b&&a(b.target).hasClass("search-choice-close"))?void 0:(this.active_field?this.is_multiple||!b||a(b.target)[0]!==this.selected_item[0]&&!a(b.target).parents("a.chosen-single").length||(b.preventDefault(),this.results_toggle()):(this.is_multiple&&this.search_field.val(""),a(this.container[0].ownerDocument).bind("click.chosen",this.click_test_action),this.results_show()),this.activate_field())},Chosen.prototype.container_mouseup=function(a){return"ABBR"!==a.target.nodeName||this.is_disabled?void 0:this.results_reset(a)},Chosen.prototype.search_results_mousewheel=function(a){var b;return a.originalEvent&&(b=-a.originalEvent.wheelDelta||a.originalEvent.detail),null!=b?(a.preventDefault(),"DOMMouseScroll"===a.type&&(b=40*b),this.search_results.scrollTop(b+this.search_results.scrollTop())):void 0},Chosen.prototype.blur_test=function(){return!this.active_field&&this.container.hasClass("chosen-container-active")?this.close_field():void 0},Chosen.prototype.close_field=function(){return a(this.container[0].ownerDocument).unbind("click.chosen",this.click_test_action),this.active_field=!1,this.results_hide(),this.container.removeClass("chosen-container-active"),this.clear_backstroke(),this.show_search_field_default(),this.search_field_scale()},Chosen.prototype.activate_field=function(){return this.container.addClass("chosen-container-active"),this.active_field=!0,this.search_field.val(this.search_field.val()),this.search_field.focus()},Chosen.prototype.test_active_click=function(b){var c;return c=a(b.target).closest(".chosen-container"),c.length&&this.container[0]===c[0]?this.active_field=!0:this.close_field()},Chosen.prototype.results_build=function(){return this.parsing=!0,this.selected_option_count=null,this.results_data=SelectParser.select_to_array(this.form_field),this.is_multiple?this.search_choices.find("li.search-choice").remove():this.is_multiple||(this.single_set_selected_text(),this.disable_search||this.form_field.options.length<=this.disable_search_threshold?(this.search_field[0].readOnly=!0,this.container.addClass("chosen-container-single-nosearch")):(this.search_field[0].readOnly=!1,this.container.removeClass("chosen-container-single-nosearch"))),this.update_results_content(this.results_option_build({first:!0})),this.search_field_disabled(),this.show_search_field_default(),this.search_field_scale(),this.parsing=!1},Chosen.prototype.result_do_highlight=function(a){var b,c,d,e,f;if(a.length){if(this.result_clear_highlight(),this.result_highlight=a,this.result_highlight.addClass("highlighted"),d=parseInt(this.search_results.css("maxHeight"),10),f=this.search_results.scrollTop(),e=d+f,c=this.result_highlight.position().top+this.search_results.scrollTop(),b=c+this.result_highlight.outerHeight(),b>=e)return this.search_results.scrollTop(b-d>0?b-d:0);if(f>c)return this.search_results.scrollTop(c)}},Chosen.prototype.result_clear_highlight=function(){return this.result_highlight&&this.result_highlight.removeClass("highlighted"),this.result_highlight=null},Chosen.prototype.results_show=function(){return this.is_multiple&&this.max_selected_options<=this.choices_count()?(this.form_field_jq.trigger("chosen:maxselected",{chosen:this}),!1):(this.container.addClass("chosen-with-drop"),this.results_showing=!0,this.search_field.focus(),this.search_field.val(this.search_field.val()),this.winnow_results(),this.form_field_jq.trigger("chosen:showing_dropdown",{chosen:this}))},Chosen.prototype.update_results_content=function(a){return this.search_results.html(a)},Chosen.prototype.results_hide=function(){return this.results_showing&&(this.result_clear_highlight(),this.container.removeClass("chosen-with-drop"),this.form_field_jq.trigger("chosen:hiding_dropdown",{chosen:this})),this.results_showing=!1},Chosen.prototype.set_tab_index=function(){var a;return this.form_field.tabIndex?(a=this.form_field.tabIndex,this.form_field.tabIndex=-1,this.search_field[0].tabIndex=a):void 0},Chosen.prototype.set_label_behavior=function(){var b=this;return this.form_field_label=this.form_field_jq.parents("label"),!this.form_field_label.length&&this.form_field.id.length&&(this.form_field_label=a("label[for='"+this.form_field.id+"']")),this.form_field_label.length>0?this.form_field_label.bind("click.chosen",function(a){return b.is_multiple?b.container_mousedown(a):b.activate_field()}):void 0},Chosen.prototype.show_search_field_default=function(){return this.is_multiple&&this.choices_count()<1&&!this.active_field?(this.search_field.val(this.default_text),this.search_field.addClass("default")):(this.search_field.val(""),this.search_field.removeClass("default"))},Chosen.prototype.search_results_mouseup=function(b){var c;return c=a(b.target).hasClass("active-result")?a(b.target):a(b.target).parents(".active-result").first(),c.length?(this.result_highlight=c,this.result_select(b),this.search_field.focus()):void 0},Chosen.prototype.search_results_mouseover=function(b){var c;return c=a(b.target).hasClass("active-result")?a(b.target):a(b.target).parents(".active-result").first(),c?this.result_do_highlight(c):void 0},Chosen.prototype.search_results_mouseout=function(b){return a(b.target).hasClass("active-result")?this.result_clear_highlight():void 0},Chosen.prototype.choice_build=function(b){var c,d,e=this;return c=a("<li />",{"class":"search-choice"}).html("<span>"+b.html+"</span>"),b.disabled?c.addClass("search-choice-disabled"):(d=a("<a />",{"class":"search-choice-close","data-option-array-index":b.array_index}),d.bind("click.chosen",function(a){return e.choice_destroy_link_click(a)}),c.append(d)),this.search_container.before(c)},Chosen.prototype.choice_destroy_link_click=function(b){return b.preventDefault(),b.stopPropagation(),this.is_disabled?void 0:this.choice_destroy(a(b.target))},Chosen.prototype.choice_destroy=function(a){return this.result_deselect(a[0].getAttribute("data-option-array-index"))?(this.show_search_field_default(),this.is_multiple&&this.choices_count()>0&&this.search_field.val().length<1&&this.results_hide(),a.parents("li").first().remove(),this.search_field_scale()):void 0},Chosen.prototype.results_reset=function(){return this.reset_single_select_options(),this.form_field.options[0].selected=!0,this.single_set_selected_text(),this.show_search_field_default(),this.results_reset_cleanup(),this.form_field_jq.trigger("change"),this.active_field?this.results_hide():void 0},Chosen.prototype.results_reset_cleanup=function(){return this.current_selectedIndex=this.form_field.selectedIndex,this.selected_item.find("abbr").remove()},Chosen.prototype.result_select=function(a){var b,c;return this.result_highlight?(b=this.result_highlight,this.result_clear_highlight(),this.is_multiple&&this.max_selected_options<=this.choices_count()?(this.form_field_jq.trigger("chosen:maxselected",{chosen:this}),!1):(this.is_multiple?b.removeClass("active-result"):this.reset_single_select_options(),c=this.results_data[b[0].getAttribute("data-option-array-index")],c.selected=!0,this.form_field.options[c.options_index].selected=!0,this.selected_option_count=null,this.is_multiple?this.choice_build(c):this.single_set_selected_text(c.text),(a.metaKey||a.ctrlKey)&&this.is_multiple||this.results_hide(),this.search_field.val(""),(this.is_multiple||this.form_field.selectedIndex!==this.current_selectedIndex)&&this.form_field_jq.trigger("change",{selected:this.form_field.options[c.options_index].value}),this.current_selectedIndex=this.form_field.selectedIndex,this.search_field_scale())):void 0},Chosen.prototype.single_set_selected_text=function(a){return null==a&&(a=this.default_text),a===this.default_text?this.selected_item.addClass("chosen-default"):(this.single_deselect_control_build(),this.selected_item.removeClass("chosen-default")),this.selected_item.find("span").text(a)},Chosen.prototype.result_deselect=function(a){var b;return b=this.results_data[a],this.form_field.options[b.options_index].disabled?!1:(b.selected=!1,this.form_field.options[b.options_index].selected=!1,this.selected_option_count=null,this.result_clear_highlight(),this.results_showing&&this.winnow_results(),this.form_field_jq.trigger("change",{deselected:this.form_field.options[b.options_index].value}),this.search_field_scale(),!0)},Chosen.prototype.single_deselect_control_build=function(){return this.allow_single_deselect?(this.selected_item.find("abbr").length||this.selected_item.find("span").first().after('<abbr class="search-choice-close"></abbr>'),this.selected_item.addClass("chosen-single-with-deselect")):void 0},Chosen.prototype.get_search_text=function(){return this.search_field.val()===this.default_text?"":a("<div/>").text(a.trim(this.search_field.val())).html()},Chosen.prototype.winnow_results_set_highlight=function(){var a,b;return b=this.is_multiple?[]:this.search_results.find(".result-selected.active-result"),a=b.length?b.first():this.search_results.find(".active-result").first(),null!=a?this.result_do_highlight(a):void 0},Chosen.prototype.no_results=function(b){var c;return c=a('<li class="no-results">'+this.results_none_found+' "<span></span>"</li>'),c.find("span").first().html(b),this.search_results.append(c),this.form_field_jq.trigger("chosen:no_results",{chosen:this})},Chosen.prototype.no_results_clear=function(){return this.search_results.find(".no-results").remove()},Chosen.prototype.keydown_arrow=function(){var a;return this.results_showing&&this.result_highlight?(a=this.result_highlight.nextAll("li.active-result").first())?this.result_do_highlight(a):void 0:this.results_show()},Chosen.prototype.keyup_arrow=function(){var a;return this.results_showing||this.is_multiple?this.result_highlight?(a=this.result_highlight.prevAll("li.active-result"),a.length?this.result_do_highlight(a.first()):(this.choices_count()>0&&this.results_hide(),this.result_clear_highlight())):void 0:this.results_show()},Chosen.prototype.keydown_backstroke=function(){var a;return this.pending_backstroke?(this.choice_destroy(this.pending_backstroke.find("a").first()),this.clear_backstroke()):(a=this.search_container.siblings("li.search-choice").last(),a.length&&!a.hasClass("search-choice-disabled")?(this.pending_backstroke=a,this.single_backstroke_delete?this.keydown_backstroke():this.pending_backstroke.addClass("search-choice-focus")):void 0)},Chosen.prototype.clear_backstroke=function(){return this.pending_backstroke&&this.pending_backstroke.removeClass("search-choice-focus"),this.pending_backstroke=null},Chosen.prototype.keydown_checker=function(a){var b,c;switch(b=null!=(c=a.which)?c:a.keyCode,this.search_field_scale(),8!==b&&this.pending_backstroke&&this.clear_backstroke(),b){case 8:this.backstroke_length=this.search_field.val().length;break;case 9:this.results_showing&&!this.is_multiple&&this.result_select(a),this.mouse_on_container=!1;break;case 13:a.preventDefault();break;case 38:a.preventDefault(),this.keyup_arrow();break;case 40:a.preventDefault(),this.keydown_arrow()}},Chosen.prototype.search_field_scale=function(){var b,c,d,e,f,g,h,i,j;if(this.is_multiple){for(d=0,h=0,f="position:absolute; left: -1000px; top: -1000px; display:none;",g=["font-size","font-style","font-weight","font-family","line-height","text-transform","letter-spacing"],i=0,j=g.length;j>i;i++)e=g[i],f+=e+":"+this.search_field.css(e)+";";return b=a("<div />",{style:f}),b.text(this.search_field.val()),a("body").append(b),h=b.width()+25,b.remove(),c=this.container.outerWidth(),h>c-10&&(h=c-10),this.search_field.css({width:h+"px"})}},Chosen}(AbstractChosen)}.call(this);
admin/settings/assets/chosen.min.css ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ /* Chosen v1.0.0 | (c) 2011-2013 by Harvest | MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md */
2
+
3
+ .chosen-container{position:relative;display:inline-block;vertical-align:middle;font-size:13px;zoom:1;*display:inline;-webkit-user-select:none;-moz-user-select:none;user-select:none}.chosen-container .chosen-drop{position:absolute;top:100%;left:-9999px;z-index:1010;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;width:100%;border:1px solid #aaa;border-top:0;background:#fff;box-shadow:0 4px 5px rgba(0,0,0,.15)}.chosen-container.chosen-with-drop .chosen-drop{left:0}.chosen-container a{cursor:pointer}.chosen-container-single .chosen-single{position:relative;display:block;overflow:hidden;padding:0 0 0 8px;height:23px;border:1px solid #aaa;border-radius:5px;background-color:#fff;background:-webkit-gradient(linear,50% 0,50% 100%,color-stop(20%,#fff),color-stop(50%,#f6f6f6),color-stop(52%,#eee),color-stop(100%,#f4f4f4));background:-webkit-linear-gradient(top,#fff 20%,#f6f6f6 50%,#eee 52%,#f4f4f4 100%);background:-moz-linear-gradient(top,#fff 20%,#f6f6f6 50%,#eee 52%,#f4f4f4 100%);background:-o-linear-gradient(top,#fff 20%,#f6f6f6 50%,#eee 52%,#f4f4f4 100%);background:linear-gradient(top,#fff 20%,#f6f6f6 50%,#eee 52%,#f4f4f4 100%);background-clip:padding-box;box-shadow:0 0 3px #fff inset,0 1px 1px rgba(0,0,0,.1);color:#444;text-decoration:none;white-space:nowrap;line-height:24px}.chosen-container-single .chosen-default{color:#999}.chosen-container-single .chosen-single span{display:block;overflow:hidden;margin-right:26px;text-overflow:ellipsis;white-space:nowrap}.chosen-container-single .chosen-single-with-deselect span{margin-right:38px}.chosen-container-single .chosen-single abbr{position:absolute;top:6px;right:26px;display:block;width:12px;height:12px;background:url(chosen-sprite.png) -42px 1px no-repeat;font-size:1px}.chosen-container-single .chosen-single abbr:hover{background-position:-42px -10px}.chosen-container-single.chosen-disabled .chosen-single abbr:hover{background-position:-42px -10px}.chosen-container-single .chosen-single div{position:absolute;top:0;right:0;display:block;width:18px;height:100%}.chosen-container-single .chosen-single div b{display:block;width:100%;height:100%;background:url(chosen-sprite.png) no-repeat 0 2px}.chosen-container-single .chosen-search{position:relative;z-index:1010;margin:0;padding:3px 4px;white-space:nowrap}.chosen-container-single .chosen-search input[type=text]{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;margin:1px 0;padding:4px 20px 4px 5px;width:100%;height:auto;outline:0;border:1px solid #aaa;background:#fff url(chosen-sprite.png) no-repeat 100% -20px;background:url(chosen-sprite.png) no-repeat 100% -20px,-webkit-gradient(linear,50% 0,50% 100%,color-stop(1%,#eee),color-stop(15%,#fff));background:url(chosen-sprite.png) no-repeat 100% -20px,-webkit-linear-gradient(#eee 1%,#fff 15%);background:url(chosen-sprite.png) no-repeat 100% -20px,-moz-linear-gradient(#eee 1%,#fff 15%);background:url(chosen-sprite.png) no-repeat 100% -20px,-o-linear-gradient(#eee 1%,#fff 15%);background:url(chosen-sprite.png) no-repeat 100% -20px,linear-gradient(#eee 1%,#fff 15%);font-size:1em;font-family:sans-serif;line-height:normal;border-radius:0}.chosen-container-single .chosen-drop{margin-top:-1px;border-radius:0 0 4px 4px;background-clip:padding-box}.chosen-container-single.chosen-container-single-nosearch .chosen-search{position:absolute;left:-9999px}.chosen-container .chosen-results{position:relative;overflow-x:hidden;overflow-y:auto;margin:0 4px 4px 0;padding:0 0 0 4px;max-height:240px;-webkit-overflow-scrolling:touch}.chosen-container .chosen-results li{display:none;margin:0;padding:5px 6px;list-style:none;line-height:15px}.chosen-container .chosen-results li.active-result{display:list-item;cursor:pointer}.chosen-container .chosen-results li.disabled-result{display:list-item;color:#ccc;cursor:default}.chosen-container .chosen-results li.highlighted{background-color:#3875d7;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(20%,#3875d7),color-stop(90%,#2a62bc));background-image:-webkit-linear-gradient(#3875d7 20%,#2a62bc 90%);background-image:-moz-linear-gradient(#3875d7 20%,#2a62bc 90%);background-image:-o-linear-gradient(#3875d7 20%,#2a62bc 90%);background-image:linear-gradient(#3875d7 20%,#2a62bc 90%);color:#fff}.chosen-container .chosen-results li.no-results{display:list-item;background:#f4f4f4}.chosen-container .chosen-results li.group-result{display:list-item;font-weight:700;cursor:default}.chosen-container .chosen-results li.group-option{padding-left:15px}.chosen-container .chosen-results li em{font-style:normal;text-decoration:underline}.chosen-container-multi .chosen-choices{position:relative;overflow:hidden;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;margin:0;padding:0;width:100%;height:auto!important;height:1%;border:1px solid #aaa;background-color:#fff;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(1%,#eee),color-stop(15%,#fff));background-image:-webkit-linear-gradient(#eee 1%,#fff 15%);background-image:-moz-linear-gradient(#eee 1%,#fff 15%);background-image:-o-linear-gradient(#eee 1%,#fff 15%);background-image:linear-gradient(#eee 1%,#fff 15%);cursor:text}.chosen-container-multi .chosen-choices li{float:left;list-style:none}.chosen-container-multi .chosen-choices li.search-field{margin:0;padding:0;white-space:nowrap}.chosen-container-multi .chosen-choices li.search-field input[type=text]{margin:1px 0;padding:5px;height:15px;outline:0;border:0!important;background:transparent!important;box-shadow:none;color:#666;font-size:100%;font-family:sans-serif;line-height:normal;border-radius:0}.chosen-container-multi .chosen-choices li.search-field .default{color:#999}.chosen-container-multi .chosen-choices li.search-choice{position:relative;margin:3px 0 3px 5px;padding:3px 20px 3px 5px;border:1px solid #aaa;border-radius:3px;background-color:#e4e4e4;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(20%,#f4f4f4),color-stop(50%,#f0f0f0),color-stop(52%,#e8e8e8),color-stop(100%,#eee));background-image:-webkit-linear-gradient(#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:-moz-linear-gradient(#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:-o-linear-gradient(#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:linear-gradient(#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-clip:padding-box;box-shadow:0 0 2px #fff inset,0 1px 0 rgba(0,0,0,.05);color:#333;line-height:13px;cursor:default}.chosen-container-multi .chosen-choices li.search-choice .search-choice-close{position:absolute;top:4px;right:3px;display:block;width:12px;height:12px;background:url(chosen-sprite.png) -42px 1px no-repeat;font-size:1px}.chosen-container-multi .chosen-choices li.search-choice .search-choice-close:hover{background-position:-42px -10px}.chosen-container-multi .chosen-choices li.search-choice-disabled{padding-right:5px;border:1px solid #ccc;background-color:#e4e4e4;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(20%,#f4f4f4),color-stop(50%,#f0f0f0),color-stop(52%,#e8e8e8),color-stop(100%,#eee));background-image:-webkit-linear-gradient(top,#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:-moz-linear-gradient(top,#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:-o-linear-gradient(top,#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:linear-gradient(top,#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);color:#666}.chosen-container-multi .chosen-choices li.search-choice-focus{background:#d4d4d4}.chosen-container-multi .chosen-choices li.search-choice-focus .search-choice-close{background-position:-42px -10px}.chosen-container-multi .chosen-results{margin:0;padding:0}.chosen-container-multi .chosen-drop .result-selected{display:list-item;color:#ccc;cursor:default}.chosen-container-active .chosen-single{border:1px solid #5897fb;box-shadow:0 0 5px rgba(0,0,0,.3)}.chosen-container-active.chosen-with-drop .chosen-single{border:1px solid #aaa;-moz-border-radius-bottomright:0;border-bottom-right-radius:0;-moz-border-radius-bottomleft:0;border-bottom-left-radius:0;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(20%,#eee),color-stop(80%,#fff));background-image:-webkit-linear-gradient(#eee 20%,#fff 80%);background-image:-moz-linear-gradient(#eee 20%,#fff 80%);background-image:-o-linear-gradient(#eee 20%,#fff 80%);background-image:linear-gradient(#eee 20%,#fff 80%);box-shadow:0 1px 0 #fff inset}.chosen-container-active.chosen-with-drop .chosen-single div{border-left:0;background:transparent}.chosen-container-active.chosen-with-drop .chosen-single div b{background-position:-18px 2px}.chosen-container-active .chosen-choices{border:1px solid #5897fb;box-shadow:0 0 5px rgba(0,0,0,.3)}.chosen-container-active .chosen-choices li.search-field input[type=text]{color:#111!important}.chosen-disabled{opacity:.5!important;cursor:default}.chosen-disabled .chosen-single{cursor:default}.chosen-disabled .chosen-choices .search-choice .search-choice-close{cursor:default}.chosen-rtl{text-align:right}.chosen-rtl .chosen-single{overflow:visible;padding:0 8px 0 0}.chosen-rtl .chosen-single span{margin-right:0;margin-left:26px;direction:rtl}.chosen-rtl .chosen-single-with-deselect span{margin-left:38px}.chosen-rtl .chosen-single div{right:auto;left:3px}.chosen-rtl .chosen-single abbr{right:auto;left:26px}.chosen-rtl .chosen-choices li{float:right}.chosen-rtl .chosen-choices li.search-field input[type=text]{direction:rtl}.chosen-rtl .chosen-choices li.search-choice{margin:3px 5px 3px 0;padding:3px 5px 3px 19px}.chosen-rtl .chosen-choices li.search-choice .search-choice-close{right:auto;left:4px}.chosen-rtl.chosen-container-single-nosearch .chosen-search,.chosen-rtl .chosen-drop{left:9999px}.chosen-rtl.chosen-container-single .chosen-results{margin:0 0 4px 4px;padding:0 4px 0 0}.chosen-rtl .chosen-results li.group-option{padding-right:15px;padding-left:0}.chosen-rtl.chosen-container-active.chosen-with-drop .chosen-single div{border-right:0}.chosen-rtl .chosen-search input[type=text]{padding:4px 5px 4px 20px;background:#fff url(chosen-sprite.png) no-repeat -30px -20px;background:url(chosen-sprite.png) no-repeat -30px -20px,-webkit-gradient(linear,50% 0,50% 100%,color-stop(1%,#eee),color-stop(15%,#fff));background:url(chosen-sprite.png) no-repeat -30px -20px,-webkit-linear-gradient(#eee 1%,#fff 15%);background:url(chosen-sprite.png) no-repeat -30px -20px,-moz-linear-gradient(#eee 1%,#fff 15%);background:url(chosen-sprite.png) no-repeat -30px -20px,-o-linear-gradient(#eee 1%,#fff 15%);background:url(chosen-sprite.png) no-repeat -30px -20px,linear-gradient(#eee 1%,#fff 15%);direction:rtl}.chosen-rtl.chosen-container-single .chosen-single div b{background-position:6px 2px}.chosen-rtl.chosen-container-single.chosen-with-drop .chosen-single div b{background-position:-12px 2px}@media only screen and (-webkit-min-device-pixel-ratio:2),only screen and (min-resolution:144dpi){.chosen-rtl .chosen-search input[type=text],.chosen-container-single .chosen-single abbr,.chosen-container-single .chosen-single div b,.chosen-container-single .chosen-search input[type=text],.chosen-container-multi .chosen-choices .search-choice .search-choice-close,.chosen-container .chosen-results-scroll-down span,.chosen-container .chosen-results-scroll-up span{background-image:url(chosen-sprite@2x.png)!important;background-size:52px 37px!important;background-repeat:no-repeat!important}}
admin/settings/autoload.php ADDED
@@ -0,0 +1,277 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (!defined('SCB_SETTING_BASE'))
3
+ {
4
+ define('SCB_SETTING_BASE', __DIR__);
5
+ }
6
+
7
+ if (!class_exists('wphp_settingsAPI'))
8
+ {
9
+ include_once dirname(__FILE__) . "/class_settingsAPI.php";
10
+ }
11
+ if (!class_exists('wphp_settings'))
12
+ {
13
+ include_once dirname(__FILE__) . "/class_settings.php";
14
+ }
15
+ if (!class_exists('wphp_settingsAPICustom'))
16
+ {
17
+ include_once dirname(__FILE__) . "/class_settingsAPICustom.php";
18
+ }
19
+ if (!class_exists('Browser'))
20
+ {
21
+ include_once dirname(__FILE__) . "/browser.php";
22
+ }
23
+ if (!function_exists('wphp_get_default_setting'))
24
+ {
25
+ function wphp_get_default_setting($section = '', $name = "")
26
+ {
27
+
28
+ $default_general['max_upload_size'] = 200000;
29
+
30
+ $settings['general'] = $default_general;
31
+
32
+ $default = array();
33
+
34
+ foreach ($settings as $key => $setting)
35
+ {
36
+ $default = array_merge($default, $setting);
37
+ }
38
+
39
+ return $section ? ($name ? @$settings[$section][$name] : @$settings[$section]) : $default;
40
+ }
41
+ }
42
+ /**
43
+ * Get system info
44
+ *
45
+ * @since 2.0
46
+ * @access public
47
+ * @global object $wpdb Used to query the database using the WordPress Database API
48
+ * @return string $return A string containing the info to output
49
+ */
50
+
51
+ function scb_systems_info($sep="\n")
52
+ {
53
+ global $wpdb;
54
+
55
+ if (!class_exists('Browser'))
56
+ {
57
+ require_once 'browser.php';
58
+ }
59
+
60
+ $browser = new Browser();
61
+
62
+ // Get theme info
63
+ if (get_bloginfo('version') < '3.4')
64
+ {
65
+ $theme_data = get_theme_data(get_stylesheet_directory() . '/style.css');
66
+ $theme = $theme_data['Name'] . ' ' . $theme_data['Version'];
67
+ }
68
+ else
69
+ {
70
+ $theme_data = wp_get_theme();
71
+ $theme = $theme_data->Name . ' ' . $theme_data->Version;
72
+ }
73
+
74
+ // Try to identify the hosting provider
75
+ $host = wphp_get_host();
76
+
77
+ $return = '### Begin System Info ###' . "$sep$sep";
78
+
79
+ // Start with the basics...
80
+ $return .= '-- Site Info' . "$sep$sep";
81
+ $return .= 'Site URL: ' . site_url() . "$sep";
82
+ $return .= 'Home URL: ' . home_url() . "$sep";
83
+ $return .= 'Multisite: ' . (is_multisite() ? 'Yes' : 'No') . "$sep";
84
+
85
+ $return = apply_filters('scb_sysinfo_after_site_info', $return);
86
+
87
+ // Can we determine the site's host?
88
+ if ($host)
89
+ {
90
+ $return .= "$sep" . '-- Hosting Provider' . "$sep$sep";
91
+ $return .= 'Host: ' . $host . "$sep";
92
+
93
+ $return = apply_filters('scb_sysinfo_after_host_info', $return);
94
+ }
95
+
96
+ // The local users' browser information, handled by the Browser class
97
+ $return .= "$sep" . '-- User Browser' . "$sep$sep";
98
+ $return .= $browser;
99
+
100
+ $return = apply_filters('scb_sysinfo_after_user_browser', $return);
101
+
102
+ // WordPress configuration
103
+ $return .= "$sep" . '-- WordPress Configuration' . "$sep$sep";
104
+ $return .= 'Version: ' . get_bloginfo('version') . "$sep";
105
+ $return .= 'Language: ' . (defined('WPLANG') && WPLANG ? WPLANG : 'en_US') . "$sep";
106
+ $return .= 'Permalink Structure: ' . (get_option('permalink_structure') ? get_option('permalink_structure') : 'Default') . "$sep";
107
+ $return .= 'Active Theme: ' . $theme . "$sep";
108
+ $return .= 'Show On Front: ' . get_option('show_on_front') . "$sep";
109
+
110
+ // Only show page specs if frontpage is set to 'page'
111
+ if (get_option('show_on_front') == 'page')
112
+ {
113
+ $front_page_id = get_option('page_on_front');
114
+ $blog_page_id = get_option('page_for_posts');
115
+
116
+ $return .= 'Page On Front: ' . ($front_page_id != 0 ? get_the_title($front_page_id) . ' (#' . $front_page_id . ')' : 'Unset') . "$sep";
117
+ $return .= 'Page For Posts: ' . ($blog_page_id != 0 ? get_the_title($blog_page_id) . ' (#' . $blog_page_id . ')' : 'Unset') . "$sep";
118
+ }
119
+
120
+ // Make sure wp_remote_post() is working
121
+ $request['cmd'] = '_notify-validate';
122
+
123
+ $params = array(
124
+ 'sslverify' => false,
125
+ 'timeout' => 60,
126
+ 'user-agent' => 'SCB/' . WPHP_VER,
127
+ 'body' => $request,
128
+ );
129
+
130
+ $response = wp_remote_post('https://www.paypal.com/cgi-bin/webscr', $params);
131
+
132
+ if (!is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300)
133
+ {
134
+ $WP_REMOTE_POST = 'wp_remote_post() works';
135
+ }
136
+ else
137
+ {
138
+ $WP_REMOTE_POST = 'wp_remote_post() does not work';
139
+ }
140
+
141
+ $return .= 'Remote Post: ' . $WP_REMOTE_POST . "$sep";
142
+ $return .= 'Table Prefix: ' . 'Length: ' . strlen($wpdb->prefix) . ' Status: ' . (strlen($wpdb->prefix) > 16 ? 'ERROR: Too long' : 'Acceptable') . "$sep";
143
+ $return .= 'WP_DEBUG: ' . (defined('WP_DEBUG') ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set') . "$sep";
144
+ $return .= 'Memory Limit: ' . WP_MEMORY_LIMIT . "$sep";
145
+ $return .= 'Registered Post Types: ' . implode(', ', scb_custom_post_types('names')) . "$sep";
146
+
147
+ $return = apply_filters('scb_sysinfo_after_wordpress_config', $return);
148
+
149
+ // EDD configuration
150
+
151
+ $return = apply_filters('scb_sysinfo_after_plugin_config', $return);
152
+
153
+ // Must-use plugins
154
+ if ( ! function_exists( 'get_plugins' ) ) {
155
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
156
+ }
157
+ $muplugins = function_exists('get_mu_plugins')?get_mu_plugins():array();
158
+ if (count($muplugins > 0))
159
+ {
160
+ $return .= "$sep" . '-- Must-Use Plugins' . "$sep$sep";
161
+
162
+ foreach ($muplugins as $plugin => $plugin_data)
163
+ {
164
+ $return .= $plugin_data['Name'] . ': ' . $plugin_data['Version'] . "$sep";
165
+ }
166
+
167
+ $return = apply_filters('scb_sysinfo_after_wordpress_mu_plugins', $return);
168
+ }
169
+
170
+ // WordPress active plugins
171
+ $return .= "$sep" . '-- WordPress Active Plugins' . "$sep$sep";
172
+
173
+ $plugins = get_plugins();
174
+ $active_plugins = get_option('active_plugins', array());
175
+
176
+ foreach ($plugins as $plugin_path => $plugin)
177
+ {
178
+ if (!in_array($plugin_path, $active_plugins))
179
+ {
180
+ continue;
181
+ }
182
+
183
+ $return .= $plugin['Name'] . ': ' . $plugin['Version'] . "$sep";
184
+ }
185
+
186
+ $return = apply_filters('scb_sysinfo_after_wordpress_plugins', $return);
187
+
188
+ // WordPress inactive plugins
189
+ $return .= "$sep" . '-- WordPress Inactive Plugins' . "$sep$sep";
190
+
191
+ foreach ($plugins as $plugin_path => $plugin)
192
+ {
193
+ if (in_array($plugin_path, $active_plugins))
194
+ {
195
+ continue;
196
+ }
197
+
198
+ $return .= $plugin['Name'] . ': ' . $plugin['Version'] . "$sep";
199
+ }
200
+
201
+ $return = apply_filters('scb_sysinfo_after_wordpress_plugins_inactive', $return);
202
+
203
+ if (is_multisite())
204
+ {
205
+ // WordPress Multisite active plugins
206
+ $return .= "$sep" . '-- Network Active Plugins' . "$sep$sep";
207
+
208
+ $plugins = wp_get_active_network_plugins();
209
+ $active_plugins = get_site_option('active_sitewide_plugins', array());
210
+
211
+ foreach ($plugins as $plugin_path)
212
+ {
213
+ $plugin_base = plugin_basename($plugin_path);
214
+
215
+ if (!array_key_exists($plugin_base, $active_plugins))
216
+ {
217
+ continue;
218
+ }
219
+
220
+ $plugin = get_plugin_data($plugin_path);
221
+ $return .= $plugin['Name'] . ': ' . $plugin['Version'] . "$sep";
222
+ }
223
+
224
+ $return = apply_filters('scb_sysinfo_after_wordpress_ms_plugins', $return);
225
+ }
226
+
227
+ // Server configuration (really just versioning)
228
+ $return .= "$sep" . '-- Webserver Configuration' . "$sep$sep";
229
+ $return .= 'PHP Version: ' . PHP_VERSION . "$sep";
230
+ $return .= 'MySQL Version: ' . $wpdb->db_version() . "$sep";
231
+ $return .= 'Webserver Info: ' . $_SERVER['SERVER_SOFTWARE'] . "$sep";
232
+
233
+ $return = apply_filters('scb_sysinfo_after_webserver_config', $return);
234
+
235
+ // PHP configs... now we're getting to the important stuff
236
+ $return .= "$sep" . '-- PHP Configuration' . "$sep$sep";
237
+ $return .= 'Safe Mode: ' . (ini_get('safe_mode') ? 'Enabled' : 'Disabled' . "$sep");
238
+ $return .= 'Memory Limit: ' . ini_get('memory_limit') . "$sep";
239
+ $return .= 'Upload Max Size: ' . ini_get('upload_max_filesize') . "$sep";
240
+ $return .= 'Post Max Size: ' . ini_get('post_max_size') . "$sep";
241
+ $return .= 'Upload Max Filesize: ' . ini_get('upload_max_filesize') . "$sep";
242
+ $return .= 'Time Limit: ' . ini_get('max_execution_time') . "$sep";
243
+ $return .= 'Max Input Vars: ' . ini_get('max_input_vars') . "$sep";
244
+ $return .= 'Display Errors: ' . (ini_get('display_errors') ? 'On (' . ini_get('display_errors') . ')' : 'N/A') . "$sep";
245
+
246
+ $return = apply_filters('scb_sysinfo_after_php_config', $return);
247
+
248
+ // PHP extensions and such
249
+ $return .= "$sep" . '-- PHP Extensions' . "$sep$sep";
250
+ $return .= 'cURL: ' . (function_exists('curl_init') ? 'Supported' : 'Not Supported') . "$sep";
251
+ $return .= 'fsockopen: ' . (function_exists('fsockopen') ? 'Supported' : 'Not Supported') . "$sep";
252
+ $return .= 'SOAP Client: ' . (class_exists('SoapClient') ? 'Installed' : 'Not Installed') . "$sep";
253
+ $return .= 'Suhosin: ' . (extension_loaded('suhosin') ? 'Installed' : 'Not Installed') . "$sep";
254
+
255
+ $return = apply_filters('scb_sysinfo_after_php_ext', $return);
256
+
257
+ // Session stuff
258
+ $return .= "$sep" . '-- Session Configuration' . "$sep$sep";
259
+
260
+ $return .= 'Session: ' . (isset($_SESSION) ? 'Enabled' : 'Disabled') . "$sep";
261
+
262
+ // The rest of this is only relevant is session is enabled
263
+ if (isset($_SESSION))
264
+ {
265
+ $return .= 'Session Name: ' . esc_html(ini_get('session.name')) . "$sep";
266
+ $return .= 'Cookie Path: ' . esc_html(ini_get('session.cookie_path')) . "$sep";
267
+ $return .= 'Save Path: ' . esc_html(ini_get('session.save_path')) . "$sep";
268
+ $return .= 'Use Cookies: ' . (ini_get('session.use_cookies') ? 'On' : 'Off') . "$sep";
269
+ $return .= 'Use Only Cookies: ' . (ini_get('session.use_only_cookies') ? 'On' : 'Off') . "$sep";
270
+ }
271
+
272
+ $return = apply_filters('scb_sysinfo_after_session_config', $return);
273
+
274
+ $return .= "$sep" . '### End System Info ###';
275
+
276
+ return $return;
277
+ }
admin/settings/browser.php ADDED
@@ -0,0 +1,1102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // Exit if accessed directly
4
+
5
+ /**
6
+ * Modified to remove var
7
+ * Chris Christoff on 12/26/2012
8
+ * Changes: Changes vars to publics
9
+ *
10
+ * Modified to work for EDD by
11
+ * Chris Christoff on 12/23/2012
12
+ * Changes: Removed the browser string return and added spacing. Also removed return HTML formatting.
13
+ *
14
+ * Modified to add formatted User Agent string for EDD System Info by
15
+ * Chris Christoff on 12/23/2012
16
+ * Changes: Split user string and add formatting so we can print a nicely
17
+ * formatted user agent string on the EDD System Info
18
+ *
19
+ * File: Browser.php
20
+ * Author: Chris Schuld (http://chrisschuld.com/)
21
+ * Last Modified: August 20th, 2010
22
+ *
23
+ * @version 1.9
24
+ * @package PegasusPHP
25
+ *
26
+ * Copyright (C) 2008-2010 Chris Schuld (chris@chrisschuld.com)
27
+ *
28
+ * This program is free software; you can redistribute it and/or
29
+ * modify it under the terms of the GNU General Public License as
30
+ * published by the Free Software Foundation; either version 2 of
31
+ * the License, or (at your option) any later version.
32
+ *
33
+ * This program is distributed in the hope that it will be useful,
34
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
35
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36
+ * GNU General Public License for more details at:
37
+ * http://www.gnu.org/copyleft/gpl.html
38
+ *
39
+ *
40
+ * Typical Usage:
41
+ *
42
+ * $browser = new Browser();
43
+ * if( $browser->getBrowser() == Browser::BROWSER_FIREFOX && $browser->getVersion() >= 2 ) {
44
+ * echo 'You have FireFox version 2 or greater';
45
+ * }
46
+ *
47
+ * User Agents Sampled from: http://www.useragentstring.com/
48
+ *
49
+ * This implementation is based on the original work from Gary White
50
+ * http://apptools.com/phptools/browser/
51
+ *
52
+ * UPDATES:
53
+ *
54
+ * 2010-08-20 (v1.9):
55
+ * + Added MSN Explorer Browser (legacy)
56
+ * + Added Bing/MSN Robot (Thanks Rob MacDonald)
57
+ * + Added the Android Platform (PLATFORM_ANDROID)
58
+ * + Fixed issue with Android 1.6/2.2 (Thanks Tom Hirashima)
59
+ *
60
+ * 2010-04-27 (v1.8):
61
+ * + Added iPad Support
62
+ *
63
+ * 2010-03-07 (v1.7):
64
+ * + *MAJOR* Rebuild (preg_match and other "slow" routine removal(s))
65
+ * + Almost allof Gary's original code has been replaced
66
+ * + Large PHPUNIT testing environment created to validate new releases and additions
67
+ * + Added FreeBSD Platform
68
+ * + Added OpenBSD Platform
69
+ * + Added NetBSD Platform
70
+ * + Added SunOS Platform
71
+ * + Added OpenSolaris Platform
72
+ * + Added support of the Iceweazel Browser
73
+ * + Added isChromeFrame() call to check if chromeframe is in use
74
+ * + Moved the Opera check in front of the Firefox check due to legacy Opera User Agents
75
+ * + Added the __toString() method (Thanks Deano)
76
+ *
77
+ * 2009-11-15:
78
+ * + Updated the checkes for Firefox
79
+ * + Added the NOKIA platform
80
+ * + Added Checks for the NOKIA brower(s)
81
+ *
82
+ * 2009-11-08:
83
+ * + PHP 5.3 Support
84
+ * + Added support for BlackBerry OS and BlackBerry browser
85
+ * + Added support for the Opera Mini browser
86
+ * + Added additional documenation
87
+ * + Added support for isRobot() and isMobile()
88
+ * + Added support for Opera version 10
89
+ * + Added support for deprecated Netscape Navigator version 9
90
+ * + Added support for IceCat
91
+ * + Added support for Shiretoko
92
+ *
93
+ * 2010-04-27 (v1.8):
94
+ * + Added iPad Support
95
+ *
96
+ * 2009-08-18:
97
+ * + Updated to support PHP 5.3 - removed all deprecated function calls
98
+ * + Updated to remove all double quotes (") -- converted to single quotes (')
99
+ *
100
+ * 2009-04-27:
101
+ * + Updated the IE check to remove a typo and bug (thanks John)
102
+ *
103
+ * 2009-04-22:
104
+ * + Added detection for GoogleBot
105
+ * + Added detection for the W3C Validator.
106
+ * + Added detection for Yahoo! Slurp
107
+ *
108
+ * 2009-03-14:
109
+ * + Added detection for iPods.
110
+ * + Added Platform detection for iPhones
111
+ * + Added Platform detection for iPods
112
+ *
113
+ * 2009-02-16: (Rick Hale)
114
+ * + Added version detection for Android phones.
115
+ *
116
+ * 2008-12-09:
117
+ * + Removed unused constant
118
+ *
119
+ * 2008-11-07:
120
+ * + Added Google's Chrome to the detection list
121
+ * + Added isBrowser(string) to the list of functions special thanks to
122
+ * Daniel 'mavrick' Lang for the function concept (http://mavrick.id.au)
123
+ *
124
+ *
125
+ * Gary White noted: "Since browser detection is so unreliable, I am
126
+ * no longer maintaining this script. You are free to use and or
127
+ * modify/update it as you want, however the author assumes no
128
+ * responsibility for the accuracy of the detected values."
129
+ *
130
+ * Anyone experienced with Gary's script might be interested in these notes:
131
+ *
132
+ * Added class constants
133
+ * Added detection and version detection for Google's Chrome
134
+ * Updated the version detection for Amaya
135
+ * Updated the version detection for Firefox
136
+ * Updated the version detection for Lynx
137
+ * Updated the version detection for WebTV
138
+ * Updated the version detection for NetPositive
139
+ * Updated the version detection for IE
140
+ * Updated the version detection for OmniWeb
141
+ * Updated the version detection for iCab
142
+ * Updated the version detection for Safari
143
+ * Updated Safari to remove mobile devices (iPhone)
144
+ * Added detection for iPhone
145
+ * Added detection for robots
146
+ * Added detection for mobile devices
147
+ * Added detection for BlackBerry
148
+ * Removed Netscape checks (matches heavily with firefox & mozilla)
149
+ *
150
+ */
151
+
152
+ class Browser {
153
+ public $_agent = '';
154
+ public $_browser_name = '';
155
+ public $_version = '';
156
+ public $_platform = '';
157
+ public $_os = '';
158
+ public $_is_aol = false;
159
+ public $_is_mobile = false;
160
+ public $_is_robot = false;
161
+ public $_aol_version = '';
162
+
163
+ public $BROWSER_UNKNOWN = 'unknown';
164
+ public $VERSION_UNKNOWN = 'unknown';
165
+
166
+ public $BROWSER_OPERA = 'Opera'; // Http://www.opera.com/
167
+ public $BROWSER_OPERA_MINI = 'Opera Mini'; // Http://www.opera.com/mini/
168
+ public $BROWSER_WEBTV = 'WebTV'; // Http://www.webtv.net/pc/
169
+ public $BROWSER_IE = 'Internet Explorer'; // Http://www.microsoft.com/ie/
170
+ public $BROWSER_POCKET_IE = 'Pocket Internet Explorer'; // Http://en.wikipedia.org/wiki/Internet_Explorer_Mobile
171
+ public $BROWSER_KONQUEROR = 'Konqueror'; // Http://www.konqueror.org/
172
+ public $BROWSER_ICAB = 'iCab'; // Http://www.icab.de/
173
+ public $BROWSER_OMNIWEB = 'OmniWeb'; // Http://www.omnigroup.com/applications/omniweb/
174
+ public $BROWSER_FIREBIRD = 'Firebird'; // Http://www.ibphoenix.com/
175
+ public $BROWSER_FIREFOX = 'Firefox'; // Http://www.mozilla.com/en-US/firefox/firefox.html
176
+ public $BROWSER_ICEWEASEL = 'Iceweasel'; // Http://www.geticeweasel.org/
177
+ public $BROWSER_SHIRETOKO = 'Shiretoko'; // Http://wiki.mozilla.org/Projects/shiretoko
178
+ public $BROWSER_MOZILLA = 'Mozilla'; // Http://www.mozilla.com/en-US/
179
+ public $BROWSER_AMAYA = 'Amaya'; // Http://www.w3.org/Amaya/
180
+ public $BROWSER_LYNX = 'Lynx'; // Http://en.wikipedia.org/wiki/Lynx
181
+ public $BROWSER_SAFARI = 'Safari'; // Http://apple.com
182
+ public $BROWSER_IPHONE = 'iPhone'; // Http://apple.com
183
+ public $BROWSER_IPOD = 'iPod'; // Http://apple.com
184
+ public $BROWSER_IPAD = 'iPad'; // Http://apple.com
185
+ public $BROWSER_CHROME = 'Chrome'; // Http://www.google.com/chrome
186
+ public $BROWSER_ANDROID = 'Android'; // Http://www.android.com/
187
+ public $BROWSER_GOOGLEBOT = 'GoogleBot'; // Http://en.wikipedia.org/wiki/Googlebot
188
+ public $BROWSER_SLURP = 'Yahoo! Slurp'; // Http://en.wikipedia.org/wiki/Yahoo!_Slurp
189
+ public $BROWSER_W3CVALIDATOR = 'W3C Validator'; // Http://validator.w3.org/
190
+ public $BROWSER_BLACKBERRY = 'BlackBerry'; // Http://www.blackberry.com/
191
+ public $BROWSER_ICECAT = 'IceCat'; // Http://en.wikipedia.org/wiki/GNU_IceCat
192
+ public $BROWSER_NOKIA_S60 = 'Nokia S60 OSS Browser'; // Http://en.wikipedia.org/wiki/Web_Browser_for_S60
193
+ public $BROWSER_NOKIA = 'Nokia Browser'; // * all other WAP-based browsers on the Nokia Platform
194
+ public $BROWSER_MSN = 'MSN Browser'; // Http://explorer.msn.com/
195
+ public $BROWSER_MSNBOT = 'MSN Bot'; // Http://search.msn.com/msnbot.htm
196
+ // Http://en.wikipedia.org/wiki/Msnbot (used for Bing as well)
197
+
198
+ public $BROWSER_NETSCAPE_NAVIGATOR = 'Netscape Navigator'; // Http://browser.netscape.com/ (DEPRECATED)
199
+ public $BROWSER_GALEON = 'Galeon'; // Http://galeon.sourceforge.net/ (DEPRECATED)
200
+ public $BROWSER_NETPOSITIVE = 'NetPositive'; // Http://en.wikipedia.org/wiki/NetPositive (DEPRECATED)
201
+ public $BROWSER_PHOENIX = 'Phoenix'; // Http://en.wikipedia.org/wiki/History_of_Mozilla_Firefox (DEPRECATED)
202
+
203
+ public $PLATFORM_UNKNOWN = 'unknown';
204
+ public $PLATFORM_WINDOWS = 'Windows';
205
+ public $PLATFORM_WINDOWS_CE = 'Windows CE';
206
+ public $PLATFORM_APPLE = 'Apple';
207
+ public $PLATFORM_LINUX = 'Linux';
208
+ public $PLATFORM_OS2 = 'OS/2';
209
+ public $PLATFORM_BEOS = 'BeOS';
210
+ public $PLATFORM_IPHONE = 'iPhone';
211
+ public $PLATFORM_IPOD = 'iPod';
212
+ public $PLATFORM_IPAD = 'iPad';
213
+ public $PLATFORM_BLACKBERRY = 'BlackBerry';
214
+ public $PLATFORM_NOKIA = 'Nokia';
215
+ public $PLATFORM_FREEBSD = 'FreeBSD';
216
+ public $PLATFORM_OPENBSD = 'OpenBSD';
217
+ public $PLATFORM_NETBSD = 'NetBSD';
218
+ public $PLATFORM_SUNOS = 'SunOS';
219
+ public $PLATFORM_OPENSOLARIS = 'OpenSolaris';
220
+ public $PLATFORM_ANDROID = 'Android';
221
+
222
+ public $OPERATING_SYSTEM_UNKNOWN = 'unknown';
223
+
224
+ function __construct( $useragent="" ) {
225
+ $this->reset();
226
+ if ( $useragent != "" ) {
227
+ $this->setUserAgent( $useragent );
228
+ } else {
229
+ $this->determine();
230
+ }
231
+ }
232
+
233
+ /**
234
+ * Reset all properties
235
+ */
236
+ function reset() {
237
+ $this->_agent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : "";
238
+ $this->_browser_name = $this->BROWSER_UNKNOWN;
239
+ $this->_version = $this->VERSION_UNKNOWN;
240
+ $this->_platform = $this->PLATFORM_UNKNOWN;
241
+ $this->_os = $this->OPERATING_SYSTEM_UNKNOWN;
242
+ $this->_is_aol = false;
243
+ $this->_is_mobile = false;
244
+ $this->_is_robot = false;
245
+ $this->_aol_version = $this->VERSION_UNKNOWN;
246
+ }
247
+
248
+ /**
249
+ * Check to see if the specific browser is valid
250
+ *
251
+ * @param string $browserName
252
+ * @return True if the browser is the specified browser
253
+ */
254
+ function isBrowser( $browserName ) { return 0 == strcasecmp( $this->_browser_name, trim( $browserName ) ); }
255
+
256
+ /**
257
+ * The name of the browser. All return types are from the class contants
258
+ *
259
+ * @return string Name of the browser
260
+ */
261
+ function getBrowser() { return $this->_browser_name; }
262
+ /**
263
+ * Set the name of the browser
264
+ *
265
+ * @param unknown $browser The name of the Browser
266
+ */
267
+ function setBrowser( $browser ) { return $this->_browser_name = $browser; }
268
+ /**
269
+ * The name of the platform. All return types are from the class contants
270
+ *
271
+ * @return string Name of the browser
272
+ */
273
+ function getPlatform() { return $this->_platform; }
274
+ /**
275
+ * Set the name of the platform
276
+ *
277
+ * @param unknown $platform The name of the Platform
278
+ */
279
+ function setPlatform( $platform ) { return $this->_platform = $platform; }
280
+ /**
281
+ * The version of the browser.
282
+ *
283
+ * @return string Version of the browser (will only contain alpha-numeric characters and a period)
284
+ */
285
+ function getVersion() { return $this->_version; }
286
+ /**
287
+ * Set the version of the browser
288
+ *
289
+ * @param unknown $version The version of the Browser
290
+ */
291
+ function setVersion( $version ) { $this->_version = preg_replace( '/[^0-9,.,a-z,A-Z-]/', '', $version ); }
292
+ /**
293
+ * The version of AOL.
294
+ *
295
+ * @return string Version of AOL (will only contain alpha-numeric characters and a period)
296
+ */
297
+ function getAolVersion() { return $this->_aol_version; }
298
+ /**
299
+ * Set the version of AOL
300
+ *
301
+ * @param unknown $version The version of AOL
302
+ */
303
+ function setAolVersion( $version ) { $this->_aol_version = preg_replace( '/[^0-9,.,a-z,A-Z]/', '', $version ); }
304
+ /**
305
+ * Is the browser from AOL?
306
+ *
307
+ * @return boolean True if the browser is from AOL otherwise false
308
+ */
309
+ function isAol() { return $this->_is_aol; }
310
+ /**
311
+ * Is the browser from a mobile device?
312
+ *
313
+ * @return boolean True if the browser is from a mobile device otherwise false
314
+ */
315
+ function isMobile() { return $this->_is_mobile; }
316
+ /**
317
+ * Is the browser from a robot (ex Slurp,GoogleBot)?
318
+ *
319
+ * @return boolean True if the browser is from a robot otherwise false
320
+ */
321
+ function isRobot() { return $this->_is_robot; }
322
+ /**
323
+ * Set the browser to be from AOL
324
+ *
325
+ * @param unknown $isAol
326
+ */
327
+ function setAol( $isAol ) { $this->_is_aol = $isAol; }
328
+ /**
329
+ * Set the Browser to be mobile
330
+ *
331
+ * @param boolean $value is the browser a mobile brower or not
332
+ */
333
+ function setMobile( $value=true ) { $this->_is_mobile = $value; }
334
+ /**
335
+ * Set the Browser to be a robot
336
+ *
337
+ * @param boolean $value is the browser a robot or not
338
+ */
339
+ function setRobot( $value=true ) { $this->_is_robot = $value; }
340
+ /**
341
+ * Get the user agent value in use to determine the browser
342
+ *
343
+ * @return string The user agent from the HTTP header
344
+ */
345
+ function getUserAgent() { return $this->_agent; }
346
+ /**
347
+ * Set the user agent value (the construction will use the HTTP header value - this will overwrite it)
348
+ *
349
+ * @param unknown $agent_string The value for the User Agent
350
+ */
351
+ function setUserAgent( $agent_string ) {
352
+ $this->reset();
353
+ $this->_agent = $agent_string;
354
+ $this->determine();
355
+ }
356
+ /**
357
+ * Used to determine if the browser is actually "chromeframe"
358
+ *
359
+ * @since 1.7
360
+ * @return boolean True if the browser is using chromeframe
361
+ */
362
+ function isChromeFrame() {
363
+ return strpos( $this->_agent, "chromeframe" ) !== false;
364
+ }
365
+ /**
366
+ * Returns a formatted string with a summary of the details of the browser.
367
+ *
368
+ * @return string formatted string with a summary of the browser
369
+ */
370
+ function __toString() {
371
+ $text1 = $this->getUserAgent(); //grabs the UA (user agent) string
372
+ $UAline1 = substr( $text1, 0, 32 ); //the first line we print should only be the first 32 characters of the UA string
373
+ $text2 = $this->getUserAgent();//now we grab it again and save it to a string
374
+ $towrapUA = str_replace( $UAline1, '', $text2 );//the rest of the printoff (other than first line) is equivolent
375
+ // To the whole string minus the part we printed off. IE
376
+ // User Agent: thefirst32charactersfromUAline1
377
+ // the rest of it is now stored in
378
+ // $text2 to be printed off
379
+ // But we need to add spaces before each line that is split other than line 1
380
+ $space = '';
381
+ for ( $i = 0; $i < 25; $i++ ) {
382
+ $space .= ' ';
383
+ }
384
+ // Now we split the remaining string of UA ($text2) into lines that are prefixed by spaces for formatting
385
+ $wordwrapped = chunk_split( $towrapUA, 32, "\n $space" );
386
+ return "Platform: {$this->getPlatform()} \n".
387
+ "Browser Name: {$this->getBrowser()} \n" .
388
+ "Browser Version: {$this->getVersion()} \n" .
389
+ "User Agent String: $UAline1 \n\t\t\t " .
390
+ "$wordwrapped";
391
+ }
392
+ /**
393
+ * Protected routine to calculate and determine what the browser is in use (including platform)
394
+ */
395
+ function determine() {
396
+ $this->checkPlatform();
397
+ $this->checkBrowsers();
398
+ $this->checkForAol();
399
+ }
400
+ /**
401
+ * Protected routine to determine the browser type
402
+ *
403
+ * @return boolean True if the browser was detected otherwise false
404
+ */
405
+ function checkBrowsers() {
406
+ return (
407
+ // Well-known, well-used
408
+ // Special Notes:
409
+ // (1) Opera must be checked before FireFox due to the odd
410
+ // user agents used in some older versions of Opera
411
+ // (2) WebTV is strapped onto Internet Explorer so we must
412
+ // check for WebTV before IE
413
+ // (3) (deprecated) Galeon is based on Firefox and needs to be
414
+ // tested before Firefox is tested
415
+ // (4) OmniWeb is based on Safari so OmniWeb check must occur
416
+ // before Safari
417
+ // (5) Netscape 9+ is based on Firefox so Netscape checks
418
+ // before FireFox are necessary
419
+ $this->checkBrowserWebTv() ||
420
+ $this->checkBrowserInternetExplorer() ||
421
+ $this->checkBrowserOpera() ||
422
+ $this->checkBrowserGaleon() ||
423
+ $this->checkBrowserNetscapeNavigator9Plus() ||
424
+ $this->checkBrowserFirefox() ||
425
+ $this->checkBrowserChrome() ||
426
+ $this->checkBrowserOmniWeb() ||
427
+
428
+ // Common mobile
429
+ $this->checkBrowserAndroid() ||
430
+ $this->checkBrowseriPad() ||
431
+ $this->checkBrowseriPod() ||
432
+ $this->checkBrowseriPhone() ||
433
+ $this->checkBrowserBlackBerry() ||
434
+ $this->checkBrowserNokia() ||
435
+
436
+ // Common bots
437
+ $this->checkBrowserGoogleBot() ||
438
+ $this->checkBrowserMSNBot() ||
439
+ $this->checkBrowserSlurp() ||
440
+
441
+ // WebKit base check (post mobile and others)
442
+ $this->checkBrowserSafari() ||
443
+
444
+ // Everyone else
445
+ $this->checkBrowserNetPositive() ||
446
+ $this->checkBrowserFirebird() ||
447
+ $this->checkBrowserKonqueror() ||
448
+ $this->checkBrowserIcab() ||
449
+ $this->checkBrowserPhoenix() ||
450
+ $this->checkBrowserAmaya() ||
451
+ $this->checkBrowserLynx() ||
452
+
453
+ $this->checkBrowserShiretoko() ||
454
+ $this->checkBrowserIceCat() ||
455
+ $this->checkBrowserW3CValidator() ||
456
+ $this->checkBrowserMozilla() /* Mozilla is such an open standard that you must check it last */
457
+ );
458
+ }
459
+
460
+ /**
461
+ * Determine if the user is using a BlackBerry (last updated 1.7)
462
+ *
463
+ * @return boolean True if the browser is the BlackBerry browser otherwise false
464
+ */
465
+ function checkBrowserBlackBerry() {
466
+ if ( stripos( $this->_agent, 'blackberry' ) !== false ) {
467
+ $aresult = explode( "/", stristr( $this->_agent, "BlackBerry" ) );
468
+ $aversion = explode( ' ', $aresult[1] );
469
+ $this->setVersion( $aversion[0] );
470
+ $this->_browser_name = $this->BROWSER_BLACKBERRY;
471
+ $this->setMobile( true );
472
+ return true;
473
+ }
474
+ return false;
475
+ }
476
+
477
+ /**
478
+ * Determine if the user is using an AOL User Agent (last updated 1.7)
479
+ *
480
+ * @return boolean True if the browser is from AOL otherwise false
481
+ */
482
+ function checkForAol() {
483
+ $this->setAol( false );
484
+ $this->setAolVersion( $this->VERSION_UNKNOWN );
485
+
486
+ if ( stripos( $this->_agent, 'aol' ) !== false ) {
487
+ $aversion = explode( ' ', stristr( $this->_agent, 'AOL' ) );
488
+ $this->setAol( true );
489
+ $this->setAolVersion( preg_replace( '/[^0-9\.a-z]/i', '', $aversion[1] ) );
490
+ return true;
491
+ }
492
+ return false;
493
+ }
494
+
495
+ /**
496
+ * Determine if the browser is the GoogleBot or not (last updated 1.7)
497
+ *
498
+ * @return boolean True if the browser is the GoogletBot otherwise false
499
+ */
500
+ function checkBrowserGoogleBot() {
501
+ if ( stripos( $this->_agent, 'googlebot' ) !== false ) {
502
+ $aresult = explode( '/', stristr( $this->_agent, 'googlebot' ) );
503
+ $aversion = explode( ' ', $aresult[1] );
504
+ $this->setVersion( str_replace( ';', '', $aversion[0] ) );
505
+ $this->_browser_name = $this->BROWSER_GOOGLEBOT;
506
+ $this->setRobot( true );
507
+ return true;
508
+ }
509
+ return false;
510
+ }
511
+
512
+ /**
513
+ * Determine if the browser is the MSNBot or not (last updated 1.9)
514
+ *
515
+ * @return boolean True if the browser is the MSNBot otherwise false
516
+ */
517
+ function checkBrowserMSNBot() {
518
+ if ( stripos( $this->_agent, "msnbot" ) !== false ) {
519
+ $aresult = explode( "/", stristr( $this->_agent, "msnbot" ) );
520
+ $aversion = explode( " ", $aresult[1] );
521
+ $this->setVersion( str_replace( ";", "", $aversion[0] ) );
522
+ $this->_browser_name = $this->BROWSER_MSNBOT;
523
+ $this->setRobot( true );
524
+ return true;
525
+ }
526
+ return false;
527
+ }
528
+
529
+ /**
530
+ * Determine if the browser is the W3C Validator or not (last updated 1.7)
531
+ *
532
+ * @return boolean True if the browser is the W3C Validator otherwise false
533
+ */
534
+ function checkBrowserW3CValidator() {
535
+ if ( stripos( $this->_agent, 'W3C-checklink' ) !== false ) {
536
+ $aresult = explode( '/', stristr( $this->_agent, 'W3C-checklink' ) );
537
+ $aversion = explode( ' ', $aresult[1] );
538
+ $this->setVersion( $aversion[0] );
539
+ $this->_browser_name = $this->BROWSER_W3CVALIDATOR;
540
+ return true;
541
+ } else if ( stripos( $this->_agent, 'W3C_Validator' ) !== false ) {
542
+ // Some of the Validator versions do not delineate w/ a slash - add it back in
543
+ $ua = str_replace( "W3C_Validator ", "W3C_Validator/", $this->_agent );
544
+ $aresult = explode( '/', stristr( $ua, 'W3C_Validator' ) );
545
+ $aversion = explode( ' ', $aresult[1] );
546
+ $this->setVersion( $aversion[0] );
547
+ $this->_browser_name = $this->BROWSER_W3CVALIDATOR;
548
+ return true;
549
+ }
550
+ return false;
551
+ }
552
+
553
+ /**
554
+ * Determine if the browser is the Yahoo! Slurp Robot or not (last updated 1.7)
555
+ *
556
+ * @return boolean True if the browser is the Yahoo! Slurp Robot otherwise false
557
+ */
558
+ function checkBrowserSlurp() {
559
+ if ( stripos( $this->_agent, 'slurp' ) !== false ) {
560
+ $aresult = explode( '/', stristr( $this->_agent, 'Slurp' ) );
561
+ $aversion = explode( ' ', $aresult[1] );
562
+ $this->setVersion( $aversion[0] );
563
+ $this->_browser_name = $this->BROWSER_SLURP;
564
+ $this->setRobot( true );
565
+ $this->setMobile( false );
566
+ return true;
567
+ }
568
+ return false;
569
+ }
570
+
571
+ /**
572
+ * Determine if the browser is Internet Explorer or not (last updated 1.7)
573
+ *
574
+ * @return boolean True if the browser is Internet Explorer otherwise false
575
+ */
576
+ function checkBrowserInternetExplorer() {
577
+
578
+ // Test for v1 - v1.5 IE
579
+ if ( stripos( $this->_agent, 'microsoft internet explorer' ) !== false ) {
580
+ $this->setBrowser( $this->BROWSER_IE );
581
+ $this->setVersion( '1.0' );
582
+ $aresult = stristr( $this->_agent, '/' );
583
+ if ( preg_match( '/308|425|426|474|0b1/i', $aresult ) ) {
584
+ $this->setVersion( '1.5' );
585
+ }
586
+ return true;
587
+ }
588
+ // Test for versions > 1.5
589
+ else if ( stripos( $this->_agent, 'msie' ) !== false && stripos( $this->_agent, 'opera' ) === false ) {
590
+ // See if the browser is the odd MSN Explorer
591
+ if ( stripos( $this->_agent, 'msnb' ) !== false ) {
592
+ $aresult = explode( ' ', stristr( str_replace( ';', '; ', $this->_agent ), 'MSN' ) );
593
+ $this->setBrowser( $this->BROWSER_MSN );
594
+ $this->setVersion( str_replace( array( '(', ')', ';' ), '', $aresult[1] ) );
595
+ return true;
596
+ }
597
+ $aresult = explode( ' ', stristr( str_replace( ';', '; ', $this->_agent ), 'msie' ) );
598
+ $this->setBrowser( $this->BROWSER_IE );
599
+ $this->setVersion( str_replace( array( '(', ')', ';' ), '', $aresult[1] ) );
600
+ return true;
601
+ }
602
+ // Test for Pocket IE
603
+ else if ( stripos( $this->_agent, 'mspie' ) !== false || stripos( $this->_agent, 'pocket' ) !== false ) {
604
+ $aresult = explode( ' ', stristr( $this->_agent, 'mspie' ) );
605
+ $this->setPlatform( $this->PLATFORM_WINDOWS_CE );
606
+ $this->setBrowser( $this->BROWSER_POCKET_IE );
607
+ $this->setMobile( true );
608
+
609
+ if ( stripos( $this->_agent, 'mspie' ) !== false ) {
610
+ $this->setVersion( $aresult[1] );
611
+ } else {
612
+ $aversion = explode( '/', $this->_agent );
613
+ $this->setVersion( $aversion[1] );
614
+ }
615
+ return true;
616
+ }
617
+ return false;
618
+ }
619
+
620
+ /**
621
+ * Determine if the browser is Opera or not (last updated 1.7)
622
+ *
623
+ * @return boolean True if the browser is Opera otherwise false
624
+ */
625
+ function checkBrowserOpera() {
626
+ if ( stripos( $this->_agent, 'opera mini' ) !== false ) {
627
+ $resultant = stristr( $this->_agent, 'opera mini' );
628
+ if ( preg_match( '/\//', $resultant ) ) {
629
+ $aresult = explode( '/', $resultant );
630
+ $aversion = explode( ' ', $aresult[1] );
631
+ $this->setVersion( $aversion[0] );
632
+ } else {
633
+ $aversion = explode( ' ', stristr( $resultant, 'opera mini' ) );
634
+ $this->setVersion( $aversion[1] );
635
+ }
636
+ $this->_browser_name = $this->BROWSER_OPERA_MINI;
637
+ $this->setMobile( true );
638
+ return true;
639
+ } else if ( stripos( $this->_agent, 'opera' ) !== false ) {
640
+ $resultant = stristr( $this->_agent, 'opera' );
641
+ if ( preg_match( '/Version\/(10.*)$/', $resultant, $matches ) ) {
642
+ $this->setVersion( $matches[1] );
643
+ } else if ( preg_match( '/\//', $resultant ) ) {
644
+ $aresult = explode( '/', str_replace( "(", " ", $resultant ) );
645
+ $aversion = explode( ' ', $aresult[1] );
646
+ $this->setVersion( $aversion[0] );
647
+ } else {
648
+ $aversion = explode( ' ', stristr( $resultant, 'opera' ) );
649
+ $this->setVersion( isset( $aversion[1] )?$aversion[1]:"" );
650
+ }
651
+ $this->_browser_name = $this->BROWSER_OPERA;
652
+ return true;
653
+ }
654
+ return false;
655
+ }
656
+
657
+ /**
658
+ * Determine if the browser is Chrome or not (last updated 1.7)
659
+ *
660
+ * @return boolean True if the browser is Chrome otherwise false
661
+ */
662
+ function checkBrowserChrome() {
663
+ if ( stripos( $this->_agent, 'Chrome' ) !== false ) {
664
+ $aresult = explode( '/', stristr( $this->_agent, 'Chrome' ) );
665
+ $aversion = explode( ' ', $aresult[1] );
666
+ $this->setVersion( $aversion[0] );
667
+ $this->setBrowser( $this->BROWSER_CHROME );
668
+ return true;
669
+ }
670
+ return false;
671
+ }
672
+
673
+
674
+ /**
675
+ * Determine if the browser is WebTv or not (last updated 1.7)
676
+ *
677
+ * @return boolean True if the browser is WebTv otherwise false
678
+ */
679
+ function checkBrowserWebTv() {
680
+ if ( stripos( $this->_agent, 'webtv' ) !== false ) {
681
+ $aresult = explode( '/', stristr( $this->_agent, 'webtv' ) );
682
+ $aversion = explode( ' ', $aresult[1] );
683
+ $this->setVersion( $aversion[0] );
684
+ $this->setBrowser( $this->BROWSER_WEBTV );
685
+ return true;
686
+ }
687
+ return false;
688
+ }
689
+
690
+ /**
691
+ * Determine if the browser is NetPositive or not (last updated 1.7)
692
+ *
693
+ * @return boolean True if the browser is NetPositive otherwise false
694
+ */
695
+ function checkBrowserNetPositive() {
696
+ if ( stripos( $this->_agent, 'NetPositive' ) !== false ) {
697
+ $aresult = explode( '/', stristr( $this->_agent, 'NetPositive' ) );
698
+ $aversion = explode( ' ', $aresult[1] );
699
+ $this->setVersion( str_replace( array( '(', ')', ';' ), '', $aversion[0] ) );
700
+ $this->setBrowser( $this->BROWSER_NETPOSITIVE );
701
+ return true;
702
+ }
703
+ return false;
704
+ }
705
+
706
+ /**
707
+ * Determine if the browser is Galeon or not (last updated 1.7)
708
+ *
709
+ * @return boolean True if the browser is Galeon otherwise false
710
+ */
711
+ function checkBrowserGaleon() {
712
+ if ( stripos( $this->_agent, 'galeon' ) !== false ) {
713
+ $aresult = explode( ' ', stristr( $this->_agent, 'galeon' ) );
714
+ $aversion = explode( '/', $aresult[0] );
715
+ $this->setVersion( $aversion[1] );
716
+ $this->setBrowser( $this->BROWSER_GALEON );
717
+ return true;
718
+ }
719
+ return false;
720
+ }
721
+
722
+ /**
723
+ * Determine if the browser is Konqueror or not (last updated 1.7)
724
+ *
725
+ * @return boolean True if the browser is Konqueror otherwise false
726
+ */
727
+ function checkBrowserKonqueror() {
728
+ if ( stripos( $this->_agent, 'Konqueror' ) !== false ) {
729
+ $aresult = explode( ' ', stristr( $this->_agent, 'Konqueror' ) );
730
+ $aversion = explode( '/', $aresult[0] );
731
+ $this->setVersion( $aversion[1] );
732
+ $this->setBrowser( $this->BROWSER_KONQUEROR );
733
+ return true;
734
+ }
735
+ return false;
736
+ }
737
+
738
+ /**
739
+ * Determine if the browser is iCab or not (last updated 1.7)
740
+ *
741
+ * @return boolean True if the browser is iCab otherwise false
742
+ */
743
+ function checkBrowserIcab() {
744
+ if ( stripos( $this->_agent, 'icab' ) !== false ) {
745
+ $aversion = explode( ' ', stristr( str_replace( '/', ' ', $this->_agent ), 'icab' ) );
746
+ $this->setVersion( $aversion[1] );
747
+ $this->setBrowser( $this->BROWSER_ICAB );
748
+ return true;
749
+ }
750
+ return false;
751
+ }
752
+
753
+ /**
754
+ * Determine if the browser is OmniWeb or not (last updated 1.7)
755
+ *
756
+ * @return boolean True if the browser is OmniWeb otherwise false
757
+ */
758
+ function checkBrowserOmniWeb() {
759
+ if ( stripos( $this->_agent, 'omniweb' ) !== false ) {
760
+ $aresult = explode( '/', stristr( $this->_agent, 'omniweb' ) );
761
+ $aversion = explode( ' ', isset( $aresult[1] )?$aresult[1]:"" );
762
+ $this->setVersion( $aversion[0] );
763
+ $this->setBrowser( $this->BROWSER_OMNIWEB );
764
+ return true;
765
+ }
766
+ return false;
767
+ }
768
+
769
+ /**
770
+ * Determine if the browser is Phoenix or not (last updated 1.7)
771
+ *
772
+ * @return boolean True if the browser is Phoenix otherwise false
773
+ */
774
+ function checkBrowserPhoenix() {
775
+ if ( stripos( $this->_agent, 'Phoenix' ) !== false ) {
776
+ $aversion = explode( '/', stristr( $this->_agent, 'Phoenix' ) );
777
+ $this->setVersion( $aversion[1] );
778
+ $this->setBrowser( $this->BROWSER_PHOENIX );
779
+ return true;
780
+ }
781
+ return false;
782
+ }
783
+
784
+ /**
785
+ * Determine if the browser is Firebird or not (last updated 1.7)
786
+ *
787
+ * @return boolean True if the browser is Firebird otherwise false
788
+ */
789
+ function checkBrowserFirebird() {
790
+ if ( stripos( $this->_agent, 'Firebird' ) !== false ) {
791
+ $aversion = explode( '/', stristr( $this->_agent, 'Firebird' ) );
792
+ $this->setVersion( $aversion[1] );
793
+ $this->setBrowser( $this->BROWSER_FIREBIRD );
794
+ return true;
795
+ }
796
+ return false;
797
+ }
798
+
799
+ /**
800
+ * Determine if the browser is Netscape Navigator 9+ or not (last updated 1.7)
801
+ * NOTE: (http://browser.netscape.com/ - Official support ended on March 1st, 2008)
802
+ *
803
+ * @return boolean True if the browser is Netscape Navigator 9+ otherwise false
804
+ */
805
+ function checkBrowserNetscapeNavigator9Plus() {
806
+ if ( stripos( $this->_agent, 'Firefox' ) !== false && preg_match( '/Navigator\/([^ ]*)/i', $this->_agent, $matches ) ) {
807
+ $this->setVersion( $matches[1] );
808
+ $this->setBrowser( $this->BROWSER_NETSCAPE_NAVIGATOR );
809
+ return true;
810
+ } else if ( stripos( $this->_agent, 'Firefox' ) === false && preg_match( '/Netscape6?\/([^ ]*)/i', $this->_agent, $matches ) ) {
811
+ $this->setVersion( $matches[1] );
812
+ $this->setBrowser( $this->BROWSER_NETSCAPE_NAVIGATOR );
813
+ return true;
814
+ }
815
+ return false;
816
+ }
817
+
818
+ /**
819
+ * Determine if the browser is Shiretoko or not (https://wiki.mozilla.org/Projects/shiretoko) (last updated 1.7)
820
+ *
821
+ * @return boolean True if the browser is Shiretoko otherwise false
822
+ */
823
+ function checkBrowserShiretoko() {
824
+ if ( stripos( $this->_agent, 'Mozilla' ) !== false && preg_match( '/Shiretoko\/([^ ]*)/i', $this->_agent, $matches ) ) {
825
+ $this->setVersion( $matches[1] );
826
+ $this->setBrowser( $this->BROWSER_SHIRETOKO );
827
+ return true;
828
+ }
829
+ return false;
830
+ }
831
+
832
+ /**
833
+ * Determine if the browser is Ice Cat or not (http://en.wikipedia.org/wiki/GNU_IceCat) (last updated 1.7)
834
+ *
835
+ * @return boolean True if the browser is Ice Cat otherwise false
836
+ */
837
+ function checkBrowserIceCat() {
838
+ if ( stripos( $this->_agent, 'Mozilla' ) !== false && preg_match( '/IceCat\/([^ ]*)/i', $this->_agent, $matches ) ) {
839
+ $this->setVersion( $matches[1] );
840
+ $this->setBrowser( $this->BROWSER_ICECAT );
841
+ return true;
842
+ }
843
+ return false;
844
+ }
845
+
846
+ /**
847
+ * Determine if the browser is Nokia or not (last updated 1.7)
848
+ *
849
+ * @return boolean True if the browser is Nokia otherwise false
850
+ */
851
+ function checkBrowserNokia() {
852
+ if ( preg_match( "/Nokia([^\/]+)\/([^ SP]+)/i", $this->_agent, $matches ) ) {
853
+ $this->setVersion( $matches[2] );
854
+ if ( stripos( $this->_agent, 'Series60' ) !== false || strpos( $this->_agent, 'S60' ) !== false ) {
855
+ $this->setBrowser( $this->BROWSER_NOKIA_S60 );
856
+ } else {
857
+ $this->setBrowser( $this->BROWSER_NOKIA );
858
+ }
859
+ $this->setMobile( true );
860
+ return true;
861
+ }
862
+ return false;
863
+ }
864
+
865
+ /**
866
+ * Determine if the browser is Firefox or not (last updated 1.7)
867
+ *
868
+ * @return boolean True if the browser is Firefox otherwise false
869
+ */
870
+ function checkBrowserFirefox() {
871
+ if ( stripos( $this->_agent, 'safari' ) === false ) {
872
+ if ( preg_match( "/Firefox[\/ \(]([^ ;\)]+)/i", $this->_agent, $matches ) ) {
873
+ $this->setVersion( $matches[1] );
874
+ $this->setBrowser( $this->BROWSER_FIREFOX );
875
+ return true;
876
+ } else if ( preg_match( "/Firefox$/i", $this->_agent, $matches ) ) {
877
+ $this->setVersion( "" );
878
+ $this->setBrowser( $this->BROWSER_FIREFOX );
879
+ return true;
880
+ }
881
+ }
882
+ return false;
883
+ }
884
+
885
+ /**
886
+ * Determine if the browser is Firefox or not (last updated 1.7)
887
+ *
888
+ * @return boolean True if the browser is Firefox otherwise false
889
+ */
890
+ function checkBrowserIceweasel() {
891
+ if ( stripos( $this->_agent, 'Iceweasel' ) !== false ) {
892
+ $aresult = explode( '/', stristr( $this->_agent, 'Iceweasel' ) );
893
+ $aversion = explode( ' ', $aresult[1] );
894
+ $this->setVersion( $aversion[0] );
895
+ $this->setBrowser( $this->BROWSER_ICEWEASEL );
896
+ return true;
897
+ }
898
+ return false;
899
+ }
900
+ /**
901
+ * Determine if the browser is Mozilla or not (last updated 1.7)
902
+ *
903
+ * @return boolean True if the browser is Mozilla otherwise false
904
+ */
905
+ function checkBrowserMozilla() {
906
+ if ( stripos( $this->_agent, 'mozilla' ) !== false && preg_match( '/rv:[0-9].[0-9][a-b]?/i', $this->_agent ) && stripos( $this->_agent, 'netscape' ) === false ) {
907
+ $aversion = explode( ' ', stristr( $this->_agent, 'rv:' ) );
908
+ preg_match( '/rv:[0-9].[0-9][a-b]?/i', $this->_agent, $aversion );
909
+ $this->setVersion( str_replace( 'rv:', '', $aversion[0] ) );
910
+ $this->setBrowser( $this->BROWSER_MOZILLA );
911
+ return true;
912
+ } else if ( stripos( $this->_agent, 'mozilla' ) !== false && preg_match( '/rv:[0-9]\.[0-9]/i', $this->_agent ) && stripos( $this->_agent, 'netscape' ) === false ) {
913
+ $aversion = explode( '', stristr( $this->_agent, 'rv:' ) );
914
+ $this->setVersion( str_replace( 'rv:', '', $aversion[0] ) );
915
+ $this->setBrowser( $this->BROWSER_MOZILLA );
916
+ return true;
917
+ } else if ( stripos( $this->_agent, 'mozilla' ) !== false && preg_match( '/mozilla\/([^ ]*)/i', $this->_agent, $matches ) && stripos( $this->_agent, 'netscape' ) === false ) {
918
+ $this->setVersion( $matches[1] );
919
+ $this->setBrowser( $this->BROWSER_MOZILLA );
920
+ return true;
921
+ }
922
+ return false;
923
+ }
924
+
925
+ /**
926
+ * Determine if the browser is Lynx or not (last updated 1.7)
927
+ *
928
+ * @return boolean True if the browser is Lynx otherwise false
929
+ */
930
+ function checkBrowserLynx() {
931
+ if ( stripos( $this->_agent, 'lynx' ) !== false ) {
932
+ $aresult = explode( '/', stristr( $this->_agent, 'Lynx' ) );
933
+ $aversion = explode( ' ', ( isset( $aresult[1] )?$aresult[1]:"" ) );
934
+ $this->setVersion( $aversion[0] );
935
+ $this->setBrowser( $this->BROWSER_LYNX );
936
+ return true;
937
+ }
938
+ return false;
939
+ }
940
+
941
+ /**
942
+ * Determine if the browser is Amaya or not (last updated 1.7)
943
+ *
944
+ * @return boolean True if the browser is Amaya otherwise false
945
+ */
946
+ function checkBrowserAmaya() {
947
+ if ( stripos( $this->_agent, 'amaya' ) !== false ) {
948
+ $aresult = explode( '/', stristr( $this->_agent, 'Amaya' ) );
949
+ $aversion = explode( ' ', $aresult[1] );
950
+ $this->setVersion( $aversion[0] );
951
+ $this->setBrowser( $this->BROWSER_AMAYA );
952
+ return true;
953
+ }
954
+ return false;
955
+ }
956
+
957
+ /**
958
+ * Determine if the browser is Safari or not (last updated 1.7)
959
+ *
960
+ * @return boolean True if the browser is Safari otherwise false
961
+ */
962
+ function checkBrowserSafari() {
963
+ if ( stripos( $this->_agent, 'Safari' ) !== false && stripos( $this->_agent, 'iPhone' ) === false && stripos( $this->_agent, 'iPod' ) === false ) {
964
+ $aresult = explode( '/', stristr( $this->_agent, 'Version' ) );
965
+ if ( isset( $aresult[1] ) ) {
966
+ $aversion = explode( ' ', $aresult[1] );
967
+ $this->setVersion( $aversion[0] );
968
+ } else {
969
+ $this->setVersion( $this->VERSION_UNKNOWN );
970
+ }
971
+ $this->setBrowser( $this->BROWSER_SAFARI );
972
+ return true;
973
+ }
974
+ return false;
975
+ }
976
+
977
+ /**
978
+ * Determine if the browser is iPhone or not (last updated 1.7)
979
+ *
980
+ * @return boolean True if the browser is iPhone otherwise false
981
+ */
982
+ function checkBrowseriPhone() {
983
+ if ( stripos( $this->_agent, 'iPhone' ) !== false ) {
984
+ $aresult = explode( '/', stristr( $this->_agent, 'Version' ) );
985
+ if ( isset( $aresult[1] ) ) {
986
+ $aversion = explode( ' ', $aresult[1] );
987
+ $this->setVersion( $aversion[0] );
988
+ } else {
989
+ $this->setVersion( $this->VERSION_UNKNOWN );
990
+ }
991
+ $this->setMobile( true );
992
+ $this->setBrowser( $this->BROWSER_IPHONE );
993
+ return true;
994
+ }
995
+ return false;
996
+ }
997
+
998
+ /**
999
+ * Determine if the browser is iPod or not (last updated 1.7)
1000
+ *
1001
+ * @return boolean True if the browser is iPod otherwise false
1002
+ */
1003
+ function checkBrowseriPad() {
1004
+ if ( stripos( $this->_agent, 'iPad' ) !== false ) {
1005
+ $aresult = explode( '/', stristr( $this->_agent, 'Version' ) );
1006
+ if ( isset( $aresult[1] ) ) {
1007
+ $aversion = explode( ' ', $aresult[1] );
1008
+ $this->setVersion( $aversion[0] );
1009
+ } else {
1010
+ $this->setVersion( $this->VERSION_UNKNOWN );
1011
+ }
1012
+ $this->setMobile( true );
1013
+ $this->setBrowser( $this->BROWSER_IPAD );
1014
+ return true;
1015
+ }
1016
+ return false;
1017
+ }
1018
+
1019
+ /**
1020
+ * Determine if the browser is iPod or not (last updated 1.7)
1021
+ *
1022
+ * @return boolean True if the browser is iPod otherwise false
1023
+ */
1024
+ function checkBrowseriPod() {
1025
+ if ( stripos( $this->_agent, 'iPod' ) !== false ) {
1026
+ $aresult = explode( '/', stristr( $this->_agent, 'Version' ) );
1027
+ if ( isset( $aresult[1] ) ) {
1028
+ $aversion = explode( ' ', $aresult[1] );
1029
+ $this->setVersion( $aversion[0] );
1030
+ } else {
1031
+ $this->setVersion( $this->VERSION_UNKNOWN );
1032
+ }
1033
+ $this->setMobile( true );
1034
+ $this->setBrowser( $this->BROWSER_IPOD );
1035
+ return true;
1036
+ }
1037
+ return false;
1038
+ }
1039
+
1040
+ /**
1041
+ * Determine if the browser is Android or not (last updated 1.7)
1042
+ *
1043
+ * @return boolean True if the browser is Android otherwise false
1044
+ */
1045
+ function checkBrowserAndroid() {
1046
+ if ( stripos( $this->_agent, 'Android' ) !== false ) {
1047
+ $aresult = explode( ' ', stristr( $this->_agent, 'Android' ) );
1048
+ if ( isset( $aresult[1] ) ) {
1049
+ $aversion = explode( ' ', $aresult[1] );
1050
+ $this->setVersion( $aversion[0] );
1051
+ } else {
1052
+ $this->setVersion( $this->VERSION_UNKNOWN );
1053
+ }
1054
+ $this->setMobile( true );
1055
+ $this->setBrowser( $this->BROWSER_ANDROID );
1056
+ return true;
1057
+ }
1058
+ return false;
1059
+ }
1060
+
1061
+ /**
1062
+ * Determine the user's platform (last updated 1.7)
1063
+ */
1064
+ function checkPlatform() {
1065
+ if ( stripos( $this->_agent, 'windows' ) !== false ) {
1066
+ $this->_platform = $this->PLATFORM_WINDOWS;
1067
+ } else if ( stripos( $this->_agent, 'iPad' ) !== false ) {
1068
+ $this->_platform = $this->PLATFORM_IPAD;
1069
+ } else if ( stripos( $this->_agent, 'iPod' ) !== false ) {
1070
+ $this->_platform = $this->PLATFORM_IPOD;
1071
+ } else if ( stripos( $this->_agent, 'iPhone' ) !== false ) {
1072
+ $this->_platform = $this->PLATFORM_IPHONE;
1073
+ } elseif ( stripos( $this->_agent, 'mac' ) !== false ) {
1074
+ $this->_platform = $this->PLATFORM_APPLE;
1075
+ } elseif ( stripos( $this->_agent, 'android' ) !== false ) {
1076
+ $this->_platform = $this->PLATFORM_ANDROID;
1077
+ } elseif ( stripos( $this->_agent, 'linux' ) !== false ) {
1078
+ $this->_platform = $this->PLATFORM_LINUX;
1079
+ } else if ( stripos( $this->_agent, 'Nokia' ) !== false ) {
1080
+ $this->_platform = $this->PLATFORM_NOKIA;
1081
+ } else if ( stripos( $this->_agent, 'BlackBerry' ) !== false ) {
1082
+ $this->_platform = $this->PLATFORM_BLACKBERRY;
1083
+ } elseif ( stripos( $this->_agent, 'FreeBSD' ) !== false ) {
1084
+ $this->_platform = $this->PLATFORM_FREEBSD;
1085
+ } elseif ( stripos( $this->_agent, 'OpenBSD' ) !== false ) {
1086
+ $this->_platform = $this->PLATFORM_OPENBSD;
1087
+ } elseif ( stripos( $this->_agent, 'NetBSD' ) !== false ) {
1088
+ $this->_platform = $this->PLATFORM_NETBSD;
1089
+ } elseif ( stripos( $this->_agent, 'OpenSolaris' ) !== false ) {
1090
+ $this->_platform = $this->PLATFORM_OPENSOLARIS;
1091
+ } elseif ( stripos( $this->_agent, 'SunOS' ) !== false ) {
1092
+ $this->_platform = $this->PLATFORM_SUNOS;
1093
+ } elseif ( stripos( $this->_agent, 'OS\/2' ) !== false ) {
1094
+ $this->_platform = $this->PLATFORM_OS2;
1095
+ } elseif ( stripos( $this->_agent, 'BeOS' ) !== false ) {
1096
+ $this->_platform = $this->PLATFORM_BEOS;
1097
+ } elseif ( stripos( $this->_agent, 'win' ) !== false ) {
1098
+ $this->_platform = $this->PLATFORM_WINDOWS;
1099
+ }
1100
+
1101
+ }
1102
+ }
admin/settings/class_settings.php ADDED
@@ -0,0 +1,565 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if (!class_exists('wphp_settings'))
4
+ {
5
+
6
+ class wphp_settings
7
+ {
8
+ private $pages, $settings_api, $asignment_fields = array(), $license_fields = array(), $asignment_section,
9
+ $core_section, $tabs = array()
10
+
11
+ , $settings = array(), $info_section, $info_fields, $all_tabs;
12
+ private $options;
13
+ private static $instance;
14
+ public $test;
15
+ public static function instance($options = array())
16
+ {
17
+ if (!self::$instance)
18
+ {
19
+ self::$instance = new wphp_settings($options);
20
+
21
+ }
22
+ return self::$instance;
23
+ }
24
+ public function __construct($options = array())
25
+ {
26
+ $this->options = $options;
27
+ $this->setup();
28
+ add_action('scb_download_sysinfo', array($this, 'tools_sysinfo_download'));
29
+
30
+ }
31
+ public function options($name = null)
32
+ {
33
+ if (!is_null($name))
34
+ {
35
+ if (isset($this->options[$name]))
36
+ {
37
+ return $this->options[$name];
38
+ }
39
+ else
40
+ {
41
+ return '';
42
+ }
43
+ }
44
+ else
45
+ {
46
+ return $this->options;
47
+ }
48
+ }
49
+ public function api()
50
+ {
51
+ return $this->settings_api;
52
+ }
53
+ public function setup()
54
+ {
55
+ $this->settings_api = new wphp_settingsAPICustom();
56
+ add_action('init', array($this, 'init'));
57
+
58
+ add_action('admin_init', array($this, 'admin_init'));
59
+
60
+ add_action('wp_ajax_manage_license', array($this, 'manage_license'));
61
+
62
+ }
63
+ public function register_tab($tabs)
64
+ {
65
+ $tabs = is_array($tabs) && isset($tabs[0]) ? $tabs : array($tabs);
66
+
67
+ foreach ($tabs as $item => $tab)
68
+ {
69
+ if (!(isset($tab['id']) && $tab['id'] && isset($tab['title']) && $tab['title']))
70
+ {
71
+ unset($tabs[$item]);
72
+ continue;
73
+ }
74
+ if (isset($this->tabs[$tab['id']]))
75
+ {
76
+ unset($tabs[$item]);
77
+ }
78
+ else
79
+ {
80
+
81
+ $tab['title'] = isset($tab['title']) ? $tab['title'] : '';
82
+ $tab['label'] = isset($tab['label']) ? $tab['label'] : '';
83
+ $tab['label'] = $tab['label'] ? $tab['label'] : $tab['title'];
84
+ $tab['label'] = $tab['label'] ? $tab['label'] : $tab['id'];
85
+ $tab['options'] = isset($tab['options']) ? $tab['options'] : array();
86
+ $this->tabs[$tab['id']] = array('id' => $tab['id'], 'title' => $tab['title'], 'label' => $tab['label'], 'options' => $tab['options']);
87
+ }
88
+ }
89
+ return $tabs;
90
+ }
91
+ public function register_assignment_field($settings)
92
+ {
93
+ if (!$this->pages)
94
+ {
95
+ $pages = get_pages(array('sort_order' => 'desc',
96
+ 'sort_column' => 'post_date'));
97
+ foreach ($pages as $page)
98
+ {
99
+ $this->pages[$page->ID] = $page->post_title . "(" . $page->ID . ")";
100
+
101
+ }
102
+ }
103
+ $settings = is_array($settings) && isset($settings[0]) ? $settings : array($settings);
104
+ foreach ($settings as $key => $setting)
105
+ {
106
+ $settings[$key]['type'] = 'select';
107
+ $settings[$key]['options'] = $this->pages;
108
+ }
109
+ $settings = $this->register_setting_field('wpm_assign', $settings, true);
110
+ $this->asignment_fields = array_merge($this->asignment_fields, $settings);
111
+ return $settings;
112
+ }
113
+ public function register_setting_field($tab, $settings, $return = false)
114
+ {
115
+ $setting_temp = array();
116
+ $settings = is_array($settings) && isset($settings[0]) ? $settings : array($settings);
117
+
118
+ foreach ($settings as $item => $setting)
119
+ {
120
+ if (!(isset($setting['name']) && $setting['label']))
121
+ {
122
+ unset($settings[$item]);
123
+ continue;
124
+ }
125
+ $key = array_search($setting['name'], array_column(isset($this->settings[$tab]) && is_array($this->settings[$tab]) ? $this->settings[$tab] : array(), 'name'));
126
+
127
+ if ($key !== false)
128
+ {
129
+ unset($settings[$key]);
130
+ }
131
+ else
132
+ {
133
+ $setting_temp[] = $setting;
134
+
135
+ }
136
+ }
137
+
138
+ if ($return)
139
+ {
140
+ return $setting_temp;
141
+ }
142
+ else
143
+ {
144
+ $this->settings[$tab] = array_merge(
145
+ isset($this->settings[$tab]) && is_array(@$this->settings[$tab]) ? $this->settings[$tab] : array(), $setting_temp);
146
+ }
147
+
148
+ return $setting_temp;
149
+ }
150
+ public function init()
151
+ {
152
+ global $wpmovies_var;
153
+ $licenses = array();
154
+ $this->license_fields = array();
155
+
156
+ $licenses = apply_filters('scb_license_items', $licenses);
157
+
158
+ foreach ($licenses as $license)
159
+ {
160
+
161
+ $license['options'] = isset($license['options']) ? $license['options'] : array();
162
+ $this->license_fields[$license['id']] = array(
163
+ 'name' => $license['id'],
164
+ 'label' => $license['label'],
165
+ 'desc' => 'dd',
166
+ 'type' => 'text',
167
+ 'default' => '',
168
+ 'options' => isset($license['options']) ? $license['options'] : array(),
169
+ 'callback' => array($this, 'callback_license_text_box'),
170
+ 'sanitize_callback' => function ()
171
+ {
172
+ return '';
173
+ },
174
+ );
175
+ if (function_exists('scb_license_manager'))
176
+ {
177
+ $license['options']['license_file'] = isset($license['file']) ? $license['file'] : null;
178
+ $license['options']['license_folder'] = isset($license['folder']) ? $license['folder'] : null;
179
+
180
+ scb_license_manager()->add(
181
+ $license['id'],
182
+ isset($license['options']['store_url']) ? $license['options']['store_url'] : null,
183
+ $license['type'],
184
+ $license['name'],
185
+ null,
186
+ $license['options']
187
+ );
188
+
189
+ }
190
+ }
191
+
192
+ }
193
+ public function callback_info_page()
194
+ {
195
+
196
+ $info = scb_systems_info();
197
+ echo ('<textarea readonly="readonly" onclick="this.focus(); this.select()" id="system-info-textarea" name="scb-sysinfo">' . $info . "</textarea>");
198
+
199
+ }
200
+
201
+ public function callback_support_page()
202
+ {
203
+
204
+ echo ("support");
205
+
206
+ }
207
+
208
+ public function callback_license_text_box($args)
209
+ {
210
+
211
+ $license_key = '';
212
+ $license_info = '';
213
+
214
+ if (function_exists('scb_license_manager'))
215
+ {
216
+ $obj_license = scb_get_license($args['id']);
217
+
218
+ if (!is_null($obj_license))
219
+ {
220
+
221
+ $license_key = $obj_license->get_license_key();
222
+ $license_info = $obj_license->extendedInfo();
223
+ }
224
+ }
225
+ $license_info['license'] = isset($license_info['license']) ? $license_info['license'] : 'unknown';
226
+ $status = @$license_info['license'] == 'valid' ? 1 : 0;
227
+
228
+ $value = esc_attr($this->settings_api->get_option($args['id'], $args['section'], $args['std']));
229
+ // p_d( $value );
230
+ $size = isset($args['size']) && !is_null($args['size']) ? $args['size'] : 'regular';
231
+ $type = isset($args['type']) ? $args['type'] : 'text';
232
+
233
+ $key_input_id = '#scb_lic_txt_' . $args['id'];
234
+ $html = sprintf('<input type="%1$s" class="%2$s-text" id="scb_lic_txt_%4$s" name="%3$s[%4$s]" value="%5$s" />',
235
+ $type, $size, $args['section'], $args['id'], $license_key);
236
+
237
+ $html .= sprintf('<input data-key="%1$s" data-status="%2$s" data-id="%3$s" id="scb_lic_btn_%3$s" value="%4$s" type="submit" class="scb_lic_class button" name="license_action" >', $key_input_id, $status, $args['id'], ($status ? 'Deactivate' : 'Activate'));
238
+ $license_info['license_info'] = isset($license_info['license_info']) ? $license_info['license_info'] : '';
239
+ $license_info['error_info'] = isset($license_info['error_info']) ? $license_info['error_info'] : '';
240
+ $html .= sprintf('<p class="license_status %2$s" id="scb_lic_status_%1$s" >%3$s</p>', $args['id'], ($status ? 'license_status_valid' : 'license_status_invalid'), $license_info['license_info'] . ($license_info['error_info'] ? " -" . $license_info['error_info'] . " " : ''));
241
+
242
+ $license_text = $obj_license->options('license_text');
243
+
244
+ if (isset($license_text[$license_info['license']]))
245
+ {
246
+ $html .= "<p>" . $license_text[$license_info['license']] . "</p>";
247
+ }
248
+
249
+ echo $html;
250
+ }
251
+ public function admin_init()
252
+ {
253
+ //set the settings
254
+
255
+ $this->settings_api->set_sections($this->get_settings_sections());
256
+ $this->settings_api->set_fields($this->get_settings_fields());
257
+ //initialize settings
258
+ $this->settings_api->admin_init();
259
+
260
+ if (isset($_POST['option_page']) && isset($this->all_tabs[$_POST['option_page']]) && isset($this->all_tabs[@$_POST['option_page']]['options']['form']['pre_handler']) && is_callable($this->all_tabs[@$_POST['option_page']]['options']['form']['pre_handler']))
261
+ {
262
+ $ret = call_user_func_array($this->all_tabs[$_POST['option_page']]['options']['form']['pre_handler'], array($_POST));
263
+ }
264
+ }
265
+
266
+ public function get_settings_sections()
267
+ {
268
+ $th = $this;
269
+ $this->core_sections['license'] = array(
270
+ 'id' => 'scb_lic',
271
+ 'title' => __('Licenses', 'scb_plugin'),
272
+ 'options' => array('no_submit' => true),
273
+
274
+ );
275
+
276
+ $this->core_sections['info'] = array(
277
+ 'id' => 'scb_info',
278
+ 'title' => __('System Info', 'scb_plugin'),
279
+ 'callback' => array($this, 'callback_info_page'),
280
+ 'options' => array(
281
+ 'no_submit' => false,
282
+ 'button' => array('text' => 'Download Systme info file'),
283
+ 'form' => array('pre_handler' => function () use ($th)
284
+ {
285
+ do_action('scb_download_sysinfo', $th->options['id'] . "_sysinfo.txt");
286
+ }),
287
+ ),
288
+ );
289
+
290
+ $this->core_sections['support'] = array(
291
+ 'id' => 'scb_support',
292
+ 'label' => __('Support', 'scb_plugin'),
293
+ 'callback' => is_callable($this->options('support_callback')) ? $this->options('support_callback') : array($this, 'callback_support_page'),
294
+ 'options' => array(
295
+ 'no_submit' => true,
296
+ ),
297
+ );
298
+
299
+ $this->tabs = apply_filters('scb_setting_tabs', $this->tabs);
300
+ $this->all_tabs = array_merge(
301
+ array('scb_lic' => $this->core_sections['license']),
302
+ $this->tabs,
303
+ array('scb_info' => $this->core_sections['info']),
304
+ array('scb_support' => $this->core_sections['support'])
305
+ );
306
+ return $this->all_tabs;
307
+
308
+ }
309
+
310
+ /**
311
+ * Returns all the settings fields
312
+ *
313
+ * @return array settings fields
314
+ */
315
+ public function get_settings_fields()
316
+ {
317
+
318
+ $this->settings = apply_filters('scb_setting_fields', $this->settings);
319
+ $this->settings[$this->core_sections['license']['id']] = $this->license_fields;
320
+ // $this->settings[$this->core_sections['info']['id']] = $this->info_fields;
321
+
322
+ $this->settings[$this->asignment_section['id']] = $this->asignment_fields;
323
+
324
+ return $this->settings;
325
+
326
+ }
327
+ public function plugin_page()
328
+ {
329
+ //p_n($_POST);
330
+ //p_d($this->all_tabs);
331
+ if (isset($_POST['option_page']) && isset($this->all_tabs[$_POST['option_page']]) && is_callable($this->all_tabs[$_POST['option_page']]['options']['form']['post_handler']))
332
+ {
333
+ $ret = call_user_func_array($this->all_tabs[$_POST['option_page']]['options']['form']['post_handler'], array($_POST));
334
+ }
335
+ echo '<div class="wrap">';
336
+ $this->settings_api->show_navigation();
337
+ settings_errors(null, false, true);
338
+ $this->settings_api->show_forms("options.php", $this->options);
339
+ $this->script();
340
+ echo '</div>';
341
+ }
342
+
343
+ /**
344
+ * Generates a System Info download file
345
+ *
346
+ * @since 2.0
347
+ * @return void
348
+ */
349
+
350
+ public function tools_sysinfo_download($filename)
351
+ {
352
+
353
+ if (!current_user_can('manage_options'))
354
+ {
355
+ return;
356
+ }
357
+ @ob_end_clean();
358
+ nocache_headers();
359
+
360
+ header('Content-Type: text/plain');
361
+ header('Content-Disposition: attachment; filename="' . $filename . '"');
362
+
363
+ // die( wp_strip_all_tags($_POST['scb-sysinfo']);
364
+ die(wp_strip_all_tags($_POST['scb-sysinfo']));
365
+ }
366
+
367
+ /**
368
+ * Get all the pages
369
+ *
370
+ * @return array page names with key value pairs
371
+ */
372
+ public function get_pages()
373
+ {
374
+ $pages = get_pages();
375
+ $pages_options = array();
376
+ if ($pages)
377
+ {
378
+ foreach ($pages as $page)
379
+ {
380
+ $pages_options[$page->ID] = $page->post_title;
381
+ }
382
+ }
383
+ return $pages_options;
384
+ }
385
+ public function manage_license()
386
+ {
387
+
388
+ try
389
+ {
390
+ $response['status'] = 0;
391
+ $response['error'] = 'Unknown Error';
392
+ $response['lic_id'] = @$_REQUEST['id'];
393
+ $response['lic_key'] = @$_REQUEST['key'];
394
+
395
+ $obj_license = scb_get_license($response['lic_id']);
396
+
397
+ if (!$obj_license)
398
+ {
399
+ $response['error'] = 'Invalid Plugin Or theme(1)';
400
+ }
401
+ elseif (!$response['lic_key'])
402
+ {
403
+ $response['error'] = 'Invalid Plugin Or theme(2)';
404
+ }
405
+ else
406
+ {
407
+ $obj_license->set_license_key($response['lic_key']);
408
+
409
+ if (@$_REQUEST['status'])
410
+ {
411
+ $obj_license->deactivate_license();
412
+ }
413
+ else
414
+ {
415
+ $obj_license->activate_license();
416
+ }
417
+ $response['error'] = "";
418
+ $response['status'] = 1;
419
+ $license_info = $obj_license->extendedInfo();
420
+
421
+ $license_info['license'] = isset($license_info['license']) ? $license_info['license'] : 'unknown';
422
+
423
+ $response['lic_status'] = $license_info['license'] == 'valid' ? 1 : 0;
424
+
425
+ $license_info = $obj_license->extendedInfo();
426
+
427
+ $response['lic_msg'][] = $license_info['license_info'] . ($license_info['error_info'] ? " -" . $license_info['error_info'] . " " : '');
428
+
429
+ $license_text = $obj_license->options('license_text');
430
+
431
+ if (isset($license_text[$license_info['license']]))
432
+ {
433
+ $response['lic_msg'][] = "<br/>" . $license_text[$license_info['license']];
434
+ }
435
+ $response['lic_msg'] = implode("\n", $response['lic_msg']);
436
+ $response['lic_btn'] = ($response['lic_status'] ? 'Deactivate' : 'Activate');
437
+
438
+ }
439
+ }
440
+ catch (Exception $e)
441
+ {
442
+ $response['status'] = 0;
443
+ $response['error'] = $e->getMessage();
444
+ }
445
+ wp_send_json($response);
446
+ }
447
+ public function script()
448
+ {
449
+ ?>
450
+ <style type="text/css">
451
+ .scb-sett-select
452
+ {
453
+ }
454
+ .scb-sett-select-chosen{
455
+ width: 300px;
456
+ }
457
+ .chosen-container-multi .chosen-choices {
458
+ -webkit-border-radius: 3px;
459
+ border-radius: 3px;
460
+ border-color: #dfdfdf;
461
+ background-image: none;
462
+ }
463
+ .chosen-container .search-field input {
464
+ width: 90%!important;
465
+ }
466
+ .chosen-container-multi .chosen-choices input {
467
+ margin: 2px;
468
+ height: 27px!important;
469
+ border-color: #dfdfdf;
470
+ }
471
+ .chosen-container .search-field {
472
+ float: none!important;
473
+
474
+ }
475
+ #system-info-textarea {
476
+ background: 0 0;
477
+ font-family: Menlo,Monaco,monospace;
478
+ display: block;
479
+ overflow: auto;
480
+ white-space: pre;
481
+ width: 100%;
482
+ height: 400px;
483
+ }
484
+ </style>
485
+
486
+ <script>
487
+ var scb_setting_tabs_options={};
488
+ <?php foreach ($this->all_tabs as $tab_id => $tab)
489
+ {
490
+ if (isset($tab['options']) && is_array($tab['options']) && count($tab['options']))
491
+ {
492
+ echo ("scb_setting_tabs_options['$tab_id'] = " . json_encode($tab['options']) . "\n");
493
+ }
494
+ }
495
+ // (isset($tab['options'])?json_encode($tab)?'')
496
+ ?>
497
+ jQuery(document).ready(function($)
498
+
499
+ {
500
+
501
+
502
+
503
+ $('.scb_lic_class').on('click', function(event)
504
+ {
505
+ event.preventDefault();
506
+ var data = {
507
+ action: 'manage_license',
508
+ id: $(this).data('id'),
509
+ key: $($(this).data('key')).val(),
510
+ status: $(this).data('status'),
511
+ };
512
+ $('#scb_lic_btn_' + $(this).data('id')).data('label', $('#scb_lic_btn_' + $(this).data('id')).val());
513
+ $('#scb_lic_btn_' + $(this).data('id')).val('Please Wait..');
514
+ $('#scb_lic_btn_' + $(this).data('id')).attr('disabled', true);
515
+ $.post(ajaxurl, data, function(response)
516
+ {
517
+ if (!response.status)
518
+ {
519
+ showModalMsg(wphp_texts.error, response.error,
520
+ {});
521
+ $('#scb_lic_btn_' + response.lic_id).val($('#scb_lic_btn_' + response.lic_id).data('label'));
522
+ $('#scb_lic_btn_' + response.lic_id).attr('disabled', false)
523
+ }
524
+ else
525
+ {
526
+ $('#scb_lic_txt_' + response.lic_id).data('status', response.lic_status);
527
+ $('#scb_lic_btn_' + response.lic_id).val(response.lic_btn);
528
+ $('#scb_lic_btn_' + response.lic_id).attr('disabled', false);
529
+ $('#scb_lic_status_' + response.lic_id).html(response.lic_msg);
530
+ }
531
+ $('#scb_lic_status_' + response.lic_id).removeClass().addClass("license_status " + (response.lic_status ? 'license_status_valid' : 'license_status_invalid'));
532
+ $('#scb_lic_btn_' + response.lic_id).data('status', response.lic_status);
533
+ }).fail(function(xhr, err)
534
+ {
535
+ id = $(this)[0].data.split('&')[1].split("=")[1];
536
+ $('#scb_lic_btn_' + id).val($('#scb_lic_btn_' + id).data('label'));
537
+ $('#scb_lic_btn_' + id).attr('disabled', false)
538
+ showModalMsg(wphp_texts.error, formatErrorMessage(xhr, err));
539
+ })
540
+ });
541
+ });
542
+ </script>
543
+
544
+ <style type="text/css">
545
+ .license_status_valid{color:green;}
546
+ .license_status_invalid{color:red;}
547
+
548
+
549
+ div.description {
550
+ margin-top: 4px;
551
+ margin-bottom: 0;
552
+ font-size: 13px;
553
+ font-style: italic;
554
+ margin: 2px 0 5px;
555
+ color: #666;
556
+ }
557
+
558
+ </style>
559
+ <?php
560
+
561
+ }
562
+
563
+ }
564
+
565
+ }
admin/settings/class_settingsAPI.php ADDED
@@ -0,0 +1,657 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * weDevs Settings API wrapper class
5
+ *
6
+ * @version 1.2 (18-Oct-2015)
7
+ *
8
+ * @author Tareq Hasan <tareq@weDevs.com>
9
+ * @link http://tareq.weDevs.com Tareq's Planet
10
+ * @example src/settings-api.php How to use the class
11
+ */
12
+ if (!class_exists('wphp_settingsAPI'))
13
+ {
14
+ class wphp_settingsAPI
15
+ {
16
+
17
+ /**
18
+ * settings sections array
19
+ *
20
+ * @var array
21
+ */
22
+ protected $settings_sections = array();
23
+
24
+ /**
25
+ * Settings fields array
26
+ *
27
+ * @var array
28
+ */
29
+ protected $settings_fields = array();
30
+
31
+ public function __construct()
32
+ {
33
+ add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
34
+ }
35
+
36
+ /**
37
+ * Enqueue scripts and styles
38
+ */
39
+ public function admin_enqueue_scripts()
40
+ {
41
+ wp_enqueue_style('wp-color-picker');
42
+ wp_enqueue_media();
43
+ wp_enqueue_script('wp-color-picker');
44
+ wp_enqueue_script('jquery');
45
+ }
46
+
47
+ /**
48
+ * Set settings sections
49
+ *
50
+ * @param array $sections setting sections array
51
+ */
52
+ public function set_sections($sections)
53
+ {
54
+ $this->settings_sections = $sections;
55
+
56
+ return $this;
57
+ }
58
+
59
+ /**
60
+ * Add a single section
61
+ *
62
+ * @param array $section
63
+ */
64
+ public function add_section($section)
65
+ {
66
+ $this->settings_sections[] = $section;
67
+
68
+ return $this;
69
+ }
70
+
71
+ /**
72
+ * Set settings fields
73
+ *
74
+ * @param array $fields settings fields array
75
+ */
76
+ public function set_fields($fields)
77
+ {
78
+ $this->settings_fields = $fields;
79
+
80
+ return $this;
81
+ }
82
+
83
+ public function add_field($section, $field)
84
+ {
85
+ $defaults = array(
86
+ 'name' => '',
87
+ 'label' => '',
88
+ 'desc' => '',
89
+ 'type' => 'text',
90
+ );
91
+
92
+ $arg = wp_parse_args($field, $defaults);
93
+ $this->settings_fields[$section][] = $arg;
94
+
95
+ return $this;
96
+ }
97
+
98
+ /**
99
+ * Initialize and registers the settings sections and fileds to WordPress
100
+ *
101
+ * Usually this should be called at `admin_init` hook.
102
+ *
103
+ * This function gets the initiated settings sections and fields. Then
104
+ * registers them to WordPress and ready for use.
105
+ */
106
+ public function admin_init()
107
+ {
108
+ //register settings sections
109
+ foreach ($this->settings_sections as $section)
110
+ {
111
+ if (false == get_option($section['id']))
112
+ {
113
+ add_option($section['id']);
114
+ }
115
+
116
+ if (isset($section['desc']) && !empty($section['desc']))
117
+ {
118
+ $section['desc'] = '<div class="inside">' . $section['desc'] . '</div>';
119
+ $callback = create_function('', 'echo "' . str_replace('"', '\"', $section['desc']) . '";');
120
+ }
121
+ else if (isset($section['callback']))
122
+ {
123
+ $callback = $section['callback'];
124
+ }
125
+ else
126
+ {
127
+ $callback = null;
128
+ }
129
+
130
+ add_settings_section($section['id'], $section['title'], $callback, $section['id']);
131
+ }
132
+
133
+ //register settings fields
134
+ foreach ($this->settings_fields as $section => $field)
135
+ {
136
+ foreach ($field as $option)
137
+ {
138
+
139
+ $type = isset($option['type']) ? $option['type'] : 'text';
140
+
141
+ $args = array(
142
+ 'id' => $option['name'],
143
+ 'label_for' => $args['label_for'] = "{$section}[{$option['name']}]",
144
+ 'desc' => isset($option['desc']) ? $option['desc'] : '',
145
+ 'name' => $option['label'],
146
+ 'section' => $section,
147
+ 'size' => isset($option['size']) ? $option['size'] : null,
148
+ 'options' => isset($option['options']) ? $option['options'] : '',
149
+ 'std' => isset($option['default']) ? $option['default'] : '',
150
+ 'sanitize_callback' => isset($option['sanitize_callback']) ? $option['sanitize_callback'] : '',
151
+ 'type' => $type,
152
+ );
153
+
154
+ add_settings_field($section . '[' . $option['name'] . ']', $option['label'], array($this, 'callback_' . $type), $section, $section, $args);
155
+ }
156
+ }
157
+
158
+ // creates our settings in the options table
159
+ foreach ($this->settings_sections as $section)
160
+ {
161
+ register_setting($section['id'], $section['id'], array($this, 'sanitize_options'));
162
+ }
163
+ }
164
+
165
+ /**
166
+ * Get field description for display
167
+ *
168
+ * @param array $args settings field args
169
+ */
170
+ public function get_field_description($args)
171
+ {
172
+ if (!empty($args['desc']))
173
+ {
174
+
175
+ $desc = '<p class="description">' . $args['desc'] . '</p>';
176
+ }
177
+ else
178
+ {
179
+ $desc = '';
180
+ }
181
+
182
+ return $desc;
183
+ }
184
+
185
+ /**
186
+ * Displays a text field for a settings field
187
+ *
188
+ * @param array $args settings field args
189
+ */
190
+ public function callback_text($args)
191
+ {
192
+
193
+ $value = esc_attr($this->get_option($args['id'], $args['section'], $args['std']));
194
+ $size = isset($args['size']) && !is_null($args['size']) ? $args['size'] : 'regular';
195
+ $type = isset($args['type']) ? $args['type'] : 'text';
196
+
197
+ $html = sprintf('<input type="%1$s" class="%2$s-text" id="%3$s[%4$s]" name="%3$s[%4$s]" value="%5$s"/>', $type, $size, $args['section'], $args['id'], $value);
198
+ $html .= $this->get_field_description($args);
199
+
200
+ echo $html;
201
+ }
202
+
203
+ /**
204
+ * Displays a url field for a settings field
205
+ *
206
+ * @param array $args settings field args
207
+ */
208
+ public function callback_url($args)
209
+ {
210
+ $this->callback_text($args);
211
+ }
212
+
213
+ /**
214
+ * Displays a number field for a settings field
215
+ *
216
+ * @param array $args settings field args
217
+ */
218
+ public function callback_number($args)
219
+ {
220
+ $this->callback_text($args);
221
+ }
222
+
223
+ /**
224
+ * Displays a checkbox for a settings field
225
+ *
226
+ * @param array $args settings field args
227
+ */
228
+ public function callback_checkbox($args)
229
+ {
230
+
231
+ $value = esc_attr($this->get_option($args['id'], $args['section'], $args['std']));
232
+
233
+ $html = '<fieldset>';
234
+ $html .= sprintf('<label for="wpuf-%1$s[%2$s]">', $args['section'], $args['id']);
235
+ $html .= sprintf('<input type="hidden" name="%1$s[%2$s]" value="off" />', $args['section'], $args['id']);
236
+ $html .= sprintf('<input type="checkbox" class="checkbox" id="wpuf-%1$s[%2$s]" name="%1$s[%2$s]" value="on" %3$s />', $args['section'], $args['id'], checked($value, 'on', false));
237
+ $html .= sprintf('%1$s</label>', $args['desc']);
238
+ $html .= '</fieldset>';
239
+
240
+ echo $html;
241
+ }
242
+
243
+ /**
244
+ * Displays a multicheckbox a settings field
245
+ *
246
+ * @param array $args settings field args
247
+ */
248
+ public function callback_multicheck($args)
249
+ {
250
+
251
+ $value = $this->get_option($args['id'], $args['section'], $args['std']);
252
+ $html = '<fieldset>';
253
+
254
+ foreach ($args['options'] as $key => $label)
255
+ {
256
+ $checked = isset($value[$key]) ? $value[$key] : '0';
257
+ $html .= sprintf('<label for="wpuf-%1$s[%2$s][%3$s]">', $args['section'], $args['id'], $key);
258
+ $html .= sprintf('<input type="checkbox" class="checkbox" id="wpuf-%1$s[%2$s][%3$s]" name="%1$s[%2$s][%3$s]" value="%3$s" %4$s />', $args['section'], $args['id'], $key, checked($checked, $key, false));
259
+ $html .= sprintf('%1$s</label><br>', $label);
260
+ }
261
+
262
+ $html .= $this->get_field_description($args);
263
+ $html .= '</fieldset>';
264
+
265
+ echo $html;
266
+ }
267
+
268
+ /**
269
+ * Displays a multicheckbox a settings field
270
+ *
271
+ * @param array $args settings field args
272
+ */
273
+ public function callback_radio($args)
274
+ {
275
+
276
+ $value = $this->get_option($args['id'], $args['section'], $args['std']);
277
+ $html = '<fieldset>';
278
+
279
+ foreach ($args['options'] as $key => $label)
280
+ {
281
+ $html .= sprintf('<label for="wpuf-%1$s[%2$s][%3$s]">', $args['section'], $args['id'], $key);
282
+ $html .= sprintf('<input type="radio" class="radio" id="wpuf-%1$s[%2$s][%3$s]" name="%1$s[%2$s]" value="%3$s" %4$s />', $args['section'], $args['id'], $key, checked($value, $key, false));
283
+ $html .= sprintf('%1$s</label><br>', $label);
284
+ }
285
+
286
+ $html .= $this->get_field_description($args);
287
+ $html .= '</fieldset>';
288
+
289
+ echo $html;
290
+ }
291
+
292
+ /**
293
+ * Displays a selectbox for a settings field
294
+ *
295
+ * @param array $args settings field args
296
+ */
297
+ public function callback_select($args)
298
+ {
299
+
300
+ $value = esc_attr($this->get_option($args['id'], $args['section'], $args['std']));
301
+ $size = isset($args['size']) && !is_null($args['size']) ? $args['size'] : 'regular';
302
+ $html = sprintf('<select class="%1$s" name="%2$s[%3$s]" id="%2$s[%3$s]">', $size, $args['section'], $args['id']);
303
+
304
+ foreach ($args['options'] as $key => $label)
305
+ {
306
+ $html .= sprintf('<option value="%s"%s>%s</option>', $key, selected($value, $key, false), $label);
307
+ }
308
+
309
+ $html .= sprintf('</select>');
310
+ $html .= $this->get_field_description($args);
311
+
312
+ echo $html;
313
+ }
314
+
315
+ /**
316
+ * Displays a textarea for a settings field
317
+ *
318
+ * @param array $args settings field args
319
+ */
320
+ public function callback_textarea($args)
321
+ {
322
+
323
+ $value = esc_textarea($this->get_option($args['id'], $args['section'], $args['std']));
324
+ $size = isset($args['size']) && !is_null($args['size']) ? $args['size'] : 'regular';
325
+
326
+ $html = sprintf('<textarea rows="5" cols="55" class="%1$s-text" id="%2$s[%3$s]" name="%2$s[%3$s]">%4$s</textarea>', $size, $args['section'], $args['id'], $value);
327
+ $html .= $this->get_field_description($args);
328
+
329
+ echo $html;
330
+ }
331
+
332
+ /**
333
+ * Displays a textarea for a settings field
334
+ *
335
+ * @param array $args settings field args
336
+ * @return string
337
+ */
338
+ public function callback_html($args)
339
+ {
340
+ echo $this->get_field_description($args);
341
+ }
342
+
343
+ /**
344
+ * Displays a rich text textarea for a settings field
345
+ *
346
+ * @param array $args settings field args
347
+ */
348
+ public function callback_wysiwyg($args)
349
+ {
350
+
351
+ $value = $this->get_option($args['id'], $args['section'], $args['std']);
352
+ $size = isset($args['size']) && !is_null($args['size']) ? $args['size'] : '500px';
353
+
354
+ echo '<div style="max-width: ' . $size . ';">';
355
+
356
+ $editor_settings = array(
357
+ 'teeny' => true,
358
+ 'textarea_name' => $args['section'] . '[' . $args['id'] . ']',
359
+ 'textarea_rows' => 10,
360
+ );
361
+
362
+ if (isset($args['options']) && is_array($args['options']))
363
+ {
364
+ $editor_settings = array_merge($editor_settings, $args['options']);
365
+ }
366
+
367
+ wp_editor($value, $args['section'] . '-' . $args['id'], $editor_settings);
368
+
369
+ echo '</div>';
370
+
371
+ echo $this->get_field_description($args);
372
+ }
373
+
374
+ /**
375
+ * Displays a file upload field for a settings field
376
+ *
377
+ * @param array $args settings field args
378
+ */
379
+ public function callback_file($args)
380
+ {
381
+
382
+ $value = esc_attr($this->get_option($args['id'], $args['section'], $args['std']));
383
+ $size = isset($args['size']) && !is_null($args['size']) ? $args['size'] : 'regular';
384
+ $id = $args['section'] . '[' . $args['id'] . ']';
385
+ $label = isset($args['options']['button_label']) ? $args['options']['button_label'] : __('Choose File');
386
+
387
+ $html = sprintf('<input type="text" class="%1$s-text wpsa-url" id="%2$s[%3$s]" name="%2$s[%3$s]" value="%4$s"/>', $size, $args['section'], $args['id'], $value);
388
+ $html .= '<input type="button" class="button wpsa-browse" value="' . $label . '" />';
389
+ $html .= $this->get_field_description($args);
390
+
391
+ echo $html;
392
+ }
393
+
394
+ /**
395
+ * Displays a password field for a settings field
396
+ *
397
+ * @param array $args settings field args
398
+ */
399
+ public function callback_password($args)
400
+ {
401
+
402
+ $value = esc_attr($this->get_option($args['id'], $args['section'], $args['std']));
403
+ $size = isset($args['size']) && !is_null($args['size']) ? $args['size'] : 'regular';
404
+
405
+ $html = sprintf('<input type="password" class="%1$s-text" id="%2$s[%3$s]" name="%2$s[%3$s]" value="%4$s"/>', $size, $args['section'], $args['id'], $value);
406
+ $html .= $this->get_field_description($args);
407
+
408
+ echo $html;
409
+ }
410
+
411
+ /**
412
+ * Displays a color picker field for a settings field
413
+ *
414
+ * @param array $args settings field args
415
+ */
416
+ public function callback_color($args)
417
+ {
418
+
419
+ $value = esc_attr($this->get_option($args['id'], $args['section'], $args['std']));
420
+ $size = isset($args['size']) && !is_null($args['size']) ? $args['size'] : 'regular';
421
+
422
+ $html = sprintf('<input type="text" class="%1$s-text wp-color-picker-field" id="%2$s[%3$s]" name="%2$s[%3$s]" value="%4$s" data-default-color="%5$s" />', $size, $args['section'], $args['id'], $value, $args['std']);
423
+ $html .= $this->get_field_description($args);
424
+
425
+ echo $html;
426
+ }
427
+
428
+ /**
429
+ * Sanitize callback for Settings API
430
+ */
431
+ public function sanitize_options($arg1, $options)
432
+ {
433
+
434
+ foreach ($options as $option_slug => $option_value)
435
+ {
436
+ $sanitize_callback = $this->get_sanitize_callback($option_slug);
437
+
438
+ // If callback is set, call it
439
+ if ($sanitize_callback)
440
+ {
441
+ $options[$option_slug] = call_user_func($sanitize_callback, $option_value);
442
+ continue;
443
+ }
444
+ }
445
+
446
+ return $options;
447
+ }
448
+
449
+ /**
450
+ * Get sanitization callback for given option slug
451
+ *
452
+ * @param string $slug option slug
453
+ *
454
+ * @return mixed string or bool false
455
+ */
456
+ public function get_sanitize_callback($slug = '')
457
+ {
458
+ if (empty($slug))
459
+ {
460
+ return false;
461
+ }
462
+
463
+ // Iterate over registered fields and see if we can find proper callback
464
+ foreach ($this->settings_fields as $section => $options)
465
+ {
466
+ foreach ($options as $option)
467
+ {
468
+ if ($option['name'] != $slug)
469
+ {
470
+ continue;
471
+ }
472
+
473
+ // Return the callback name
474
+ return isset($option['sanitize_callback']) && is_callable($option['sanitize_callback']) ? $option['sanitize_callback'] : false;
475
+ }
476
+ }
477
+
478
+ return false;
479
+ }
480
+
481
+ /**
482
+ * Get the value of a settings field
483
+ *
484
+ * @param string $option settings field name
485
+ * @param string $section the section name this field belongs to
486
+ * @param string $default default text if it's not found
487
+ * @return string
488
+ */
489
+ public function get_option($option, $section, $default = '')
490
+ {
491
+
492
+ $options = get_option($section);
493
+
494
+ if (isset($options[$option]))
495
+ {
496
+ return $options[$option];
497
+ }
498
+
499
+ return $default;
500
+ }
501
+
502
+ /**
503
+ * Show navigations as tab
504
+ *
505
+ * Shows all the settings section labels as tab
506
+ */
507
+ public function show_navigation()
508
+ {
509
+ $html = '<h2 class="nav-tab-wrapper">';
510
+
511
+ foreach ($this->settings_sections as $tab)
512
+ {
513
+ p_n($tab);
514
+ $html .= sprintf('<a href="#%1$s" class="nav-tab" id="%1$s-tab">%2$s</a>', $tab['id'], $tab['title']);
515
+ }
516
+
517
+ $html .= '</h2>';
518
+
519
+ echo $html;
520
+ }
521
+
522
+ /**
523
+ * Show the section settings forms
524
+ *
525
+ * This function displays every sections in a different form
526
+ */
527
+ public function show_forms1($page = "options.php",$options=array())
528
+ {
529
+ ?>
530
+ <div class="metabox-holder">
531
+ <?php foreach ($this->settings_sections as $form)
532
+ {
533
+ $button['type'] = isset($form['options']['button']['type']) ? $form['options']['button']['type'] : 'primary';
534
+ $button['text'] = isset($form['options']['button']['text']) ? $form['options']['button']['text'] : null;
535
+ $button['name'] = isset($form['options']['button']['name']) ? $form['options']['button']['name'] : null;
536
+
537
+
538
+ ?>
539
+ <div id="<?php echo $form['id']; ?>" class="group" style="display: none;">
540
+ <form method="post" action="<?php echo (isset($form['options']['form']['page']) ? $form['options']['form']['page'] : $page); ?>">
541
+ <?php
542
+ do_action('wsa_form_top_' . $form['id'], $form);
543
+ settings_fields($form['id']);
544
+
545
+ do_settings_sections($form['id']);
546
+
547
+ do_action('wsa_form_bottom_' . $form['id'], $form);
548
+ if (!(isset($form['options']['no_submit']) && $form['options']['no_submit']))
549
+ {
550
+ ?>
551
+ <div style="padding-left: 10px" class="scb_tab_submit_div">
552
+ <?php submit_button($button['text'], $button['type'], $button['name']);?>
553
+ </div>
554
+ <?php }?>
555
+ <?php do_action('wsa_form_last_' . $form['id'], $form);?>
556
+ </form>
557
+ </div>
558
+ <?php }?>
559
+ <?php do_action('wsa_global_footer', $form);?>
560
+ </div>
561
+ <?php
562
+ $this->script();
563
+ }
564
+
565
+ /**
566
+ * Tabbable JavaScript codes & Initiate Color Picker
567
+ *
568
+ * This code uses localstorage for displaying active tabs
569
+ */
570
+ public function script()
571
+ {
572
+ ?>
573
+ <script>
574
+
575
+
576
+
577
+ jQuery(document).ready(function($) {
578
+
579
+ //Initiate Color Picker
580
+ $('.wp-color-picker-field').wpColorPicker();
581
+
582
+ // Switches option sections
583
+ $('.group').hide();
584
+ var activetab = '';
585
+ if (typeof(localStorage) != 'undefined' ) {
586
+ activetab = localStorage.getItem("activetab");
587
+ }
588
+ if (activetab != '' && $(activetab).length ) {
589
+ $(activetab).fadeIn();
590
+ } else {
591
+ $('.group:first').fadeIn();
592
+ }
593
+ $('.group .collapsed').each(function(){
594
+ $(this).find('input:checked').parent().parent().parent().nextAll().each(
595
+ function(){
596
+ if ($(this).hasClass('last')) {
597
+ $(this).removeClass('hidden');
598
+ return false;
599
+ }
600
+ $(this).filter('.hidden').removeClass('hidden');
601
+ });
602
+ });
603
+
604
+ if (activetab != '' && $(activetab + '-tab').length ) {
605
+ $(activetab + '-tab').addClass('nav-tab-active');
606
+ }
607
+ else {
608
+ $('.nav-tab-wrapper a:first').addClass('nav-tab-active');
609
+ }
610
+ $('.nav-tab-wrapper a').click(function(evt) {
611
+ $('.nav-tab-wrapper a').removeClass('nav-tab-active');
612
+ $(this).addClass('nav-tab-active').blur();
613
+ var clicked_group = $(this).attr('href');
614
+ if (typeof(localStorage) != 'undefined' ) {
615
+ localStorage.setItem("activetab", $(this).attr('href'));
616
+ }
617
+ $('.group').hide();
618
+ $(clicked_group).fadeIn();
619
+ evt.preventDefault();
620
+ });
621
+
622
+ $('.wpsa-browse').on('click', function (event) {
623
+ event.preventDefault();
624
+
625
+ var self = $(this);
626
+
627
+ // Create the media frame.
628
+ var file_frame = wp.media.frames.file_frame = wp.media({
629
+ title: self.data('uploader_title'),
630
+ button: {
631
+ text: self.data('uploader_button_text'),
632
+ },
633
+ multiple: false
634
+ });
635
+
636
+ file_frame.on('select', function () {
637
+ attachment = file_frame.state().get('selection').first().toJSON();
638
+
639
+ self.prev('.wpsa-url').val(attachment.url);
640
+ });
641
+
642
+ // Finally, open the modal
643
+ file_frame.open();
644
+ });
645
+ });
646
+ </script>
647
+
648
+ <style type="text/css">
649
+ /** WordPress 3.8 Fix **/
650
+ .form-table th { padding: 20px 10px; }
651
+ #wpbody-content .metabox-holder { padding-top: 5px; }
652
+ </style>
653
+ <?php
654
+ }
655
+
656
+ }
657
+ }
admin/settings/class_settingsAPICustom.php ADDED
@@ -0,0 +1,297 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if (!class_exists('wphp_settingsAPICustom'))
4
+ {
5
+ class wphp_settingsAPICustom extends wphp_settingsAPI
6
+ {
7
+ public function admin_enqueue_scripts()
8
+ {
9
+ parent::admin_enqueue_scripts();
10
+
11
+ wp_enqueue_style('scb_settings', plugin_dir_url(__FILE__) . 'assets/chosen.min.css');
12
+ wp_enqueue_script('scb_settings', plugin_dir_url(__FILE__) . 'assets/chosen.jquery.min.js', array('jquery'));
13
+
14
+ }
15
+
16
+ public function admin_init()
17
+ {
18
+ //register settings sections
19
+ foreach ($this->settings_sections as $section)
20
+ {
21
+ if (!isset($section['id']))
22
+ {
23
+ continue;
24
+ }
25
+ if (false == get_option($section['id']))
26
+ {
27
+ add_option($section['id']);
28
+ }
29
+
30
+ if (isset($section['desc']) && !empty($section['desc']))
31
+ {
32
+ $section['desc'] = '<div class="inside">' . $section['desc'] . '</div>';
33
+ $callback = create_function('', 'echo "' . str_replace('"', '\"', $section['desc']) . '";');
34
+ }
35
+ else if (isset($section['callback']))
36
+ {
37
+ $callback = $section['callback'];
38
+ }
39
+ else
40
+ {
41
+ $callback = null;
42
+ }
43
+
44
+ add_settings_section($section['id'], isset($section['title'])?$section['title']:'', $callback, $section['id']);
45
+ }
46
+
47
+ //register settings fields
48
+ foreach ($this->settings_fields as $section => $field)
49
+ {
50
+ if (!is_array($field) || !count($field))
51
+ {
52
+ continue;
53
+ }
54
+
55
+ foreach ($field as $option)
56
+ {
57
+ if (!isset($option['name']) || !isset($option['label']))
58
+ {
59
+ continue;
60
+ }
61
+ $type = isset($option['type']) ? $option['type'] : 'text';
62
+
63
+ $args = array(
64
+ 'id' => $option['name'],
65
+ 'label_for' => $args['label_for'] = "{$section}[{$option['name']}]",
66
+ 'desc' => isset($option['desc']) ? $option['desc'] : '',
67
+ 'name' => $option['label'],
68
+ 'section' => $section,
69
+ 'size' => isset($option['size']) ? $option['size'] : null,
70
+ 'options' => isset($option['options']) ? $option['options'] : '',
71
+ 'std' => isset($option['default']) ? $option['default'] : '',
72
+ 'sanitize_callback' => isset($option['sanitize_callback']) ? $option['sanitize_callback'] : '',
73
+ 'type' => $type,
74
+
75
+ );
76
+ $args = array_merge($option, $args);
77
+ $callable = isset($option['callback']) && (is_callable($option['callback']) || is_array($option['callback'])) ? $option['callback'] : array($this, 'callback_' . $type);
78
+ add_settings_field($section . '[' . $option['name'] . ']', $option['label'], $callable, $section, $section, $args);
79
+ }
80
+ }
81
+
82
+ // creates our settings in the options table
83
+ $th = $this;
84
+ foreach ($this->settings_sections as $section)
85
+ {
86
+ register_setting($section['id'], $section['id'],
87
+ function ($options) use ($th, $section)
88
+ {
89
+ return $th->sanitize_options($section, $options);
90
+ });
91
+ }
92
+ }
93
+ public function callback_yesno($args)
94
+ {
95
+
96
+ $args['options'] = array('1' => 'Yes', '0' => 'No');
97
+ $value = esc_attr($this->get_option($args['id'], $args['section'], $args['std']));
98
+ $size = isset($args['size']) && !is_null($args['size']) ? $args['size'] : 'regular';
99
+ $html = sprintf('<select class="%1$s" name="%2$s[%3$s]" id="%2$s[%3$s]" %4$s>', $size, $args['section'], $args['id'],isset($args['disabled'])?$args['disabled']:'');
100
+
101
+ foreach ($args['options'] as $key => $label)
102
+ {
103
+ $html .= sprintf('<option value="%s"%s>%s</option>', $key, selected($value, $key, false), $label);
104
+ }
105
+
106
+ $html .= sprintf('</select>');
107
+ $html .= $this->get_field_description($args);
108
+
109
+ echo $html;
110
+ }
111
+ /**
112
+ * Displays a selectbox for a settings field
113
+ *
114
+ * @param array $args settings field args
115
+ */
116
+ public function callback_select($args)
117
+ {
118
+
119
+ $value = ($this->get_option($args['id'], $args['section'], $args['std']));
120
+ if (!is_array($value))
121
+ {
122
+ $value = esc_attr($value);
123
+ }
124
+ $value = is_array($value) ? $value : array($value);
125
+ $size = isset($args['multiple']) ? '' : (isset($args['size']) && !is_null($args['size']) ? $args['size'] : 'regular');
126
+ if (isset($args['class']))
127
+ {
128
+ $size .= ' ' . $args['class'];
129
+ }
130
+ $html = sprintf('<select class="%1$s" name="%2$s[%3$s]%6$s" id="%2$s[%3$s]" %4$s %5$s>', $size, $args['section'], $args['id'], isset($args['multiple']) ? 'multiple' : '', empty($args['placeholder']) ? '' : 'data-placeholder="' . $args['placeholder'] . '"', isset($args['multiple']) ? '[]' : '');
131
+
132
+ foreach ($args['options'] as $key => $label)
133
+ {
134
+ $extra = '';
135
+ if (is_array($label))
136
+ {
137
+ $extra = isset($label['extra'])?$label['extra']:'';
138
+ $label = @$label['text'];
139
+ }
140
+ $html .= sprintf('<option %s value="%s"%s>%s</option>', $extra, $key, in_array($key, $value) ? 'selected' : '', $label);
141
+ }
142
+
143
+ $html .= sprintf('</select>');
144
+ $html .= $this->get_field_description($args);
145
+
146
+ echo $html;
147
+ }
148
+ /**
149
+ * Displays a selectbox for a settings field
150
+ *
151
+ * @param array $args settings field args
152
+ */
153
+ public function callback_multi($args)
154
+ {
155
+ $args['multiple'] = 1;
156
+ $args['class'] = 'scb-sett-select-chosen chosen-select';
157
+
158
+ echo ($this->callback_select($args));
159
+ }
160
+ public function get_sanitize_callback($slug = '')
161
+ {
162
+ if (empty($slug))
163
+ {
164
+ return false;
165
+ }
166
+
167
+ // Iterate over registered fields and see if we can find proper callback
168
+
169
+ foreach ($this->settings_fields as $section => $options)
170
+ {
171
+ foreach ($options as $option)
172
+ {
173
+ if ($option['name'] != $slug)
174
+ {
175
+ continue;
176
+ }
177
+
178
+ // Return the callback name
179
+ return isset($option['sanitize_callback']) && is_callable($option['sanitize_callback']) ? $option['sanitize_callback'] : (is_callable(array($this, 'sanitize_callback_' . $option['type'])) ? array($this, 'sanitize_callback_' . $option['type']) : false);
180
+ }
181
+ }
182
+
183
+ return false;
184
+ }
185
+
186
+ public function sanitize_callback_yesno($option_value)
187
+ {
188
+ return (int) (boolean) $option_value;
189
+ }
190
+
191
+ public function sanitize_options($section, $options)
192
+ {
193
+ // print_n($options);
194
+ $options = apply_filters('scb_pre_sanitize_section', $options, $section);
195
+
196
+ foreach ($options as $option_slug => $option_value)
197
+ {
198
+ $sanitize_callback = $this->get_sanitize_callback($option_slug);
199
+ // If callback is set, call it
200
+ if ($sanitize_callback)
201
+ {
202
+ // print_n($option_slug);
203
+
204
+ $options[$option_slug] = call_user_func($sanitize_callback, $option_value);
205
+ continue;
206
+ }
207
+ }
208
+
209
+ return apply_filters('scb_post_sanitize_section', $options, $section);
210
+ }
211
+ public function show_navigation()
212
+ {
213
+ $html='';
214
+ if(wphp_settings::instance()->options('page_title'))
215
+ {
216
+ $html="<h1>".wphp_settings::instance()->options('page_title')."</h1>";
217
+ }
218
+ $html .= '<h2 class="nav-tab-wrapper scb-set-nav">';
219
+
220
+ foreach ($this->settings_sections as $tab)
221
+ {
222
+
223
+ $html .= sprintf('<a href="#%1$s" class="nav-tab" id="%1$s-tab" data-tab-id="%1$s">%2$s</a>', $tab['id'], (!empty($tab['label']) ? $tab['label'] : $tab['title']));
224
+ }
225
+
226
+ $html .= '</h2>';
227
+
228
+ echo $html;
229
+ }
230
+ /**
231
+ * Show the section settings forms
232
+ *
233
+ * This function displays every sections in a different form
234
+ */
235
+ public function show_forms($page = "options.php", $options = array())
236
+ {
237
+ ?>
238
+ <div class="metabox-holder">
239
+ <?php
240
+ foreach ($this->settings_sections as $form)
241
+ {
242
+ $button['type'] = isset($form['options']['button']['type']) ? $form['options']['button']['type'] : 'primary';
243
+ $button['text'] = isset($form['options']['button']['text']) ? $form['options']['button']['text'] : null;
244
+ $button['name'] = isset($form['options']['button']['name']) ? $form['options']['button']['name'] : null;
245
+ if (isset($form['options']['form']['page']))
246
+ {
247
+ $page = $form['options']['form']['page'];
248
+ }
249
+ elseif (isset($form['options']['form']['handler']) && is_callable($form['options']['form']['handler']))
250
+ {
251
+ $page = 'options-general.php?page=' . $options['setting_page_name'];
252
+ }
253
+
254
+ ?>
255
+ <div id="<?php echo $form['id']; ?>" class="group" style="display: none;">
256
+ <form method="post" action="<?php echo ($page); ?>">
257
+ <?php
258
+ do_action('wsa_form_top_' . $form['id'], $form);
259
+ settings_fields($form['id']);
260
+
261
+ do_settings_sections($form['id']);
262
+
263
+ do_action('wsa_form_bottom_' . $form['id'], $form);
264
+ if (!(isset($form['options']['no_submit']) && $form['options']['no_submit']))
265
+ {
266
+ ?>
267
+ <div style="padding-left: 10px" class="scb_tab_submit_div">
268
+ <?php submit_button($button['text'], $button['type'], $button['name']);?>
269
+ </div>
270
+ <?php }?>
271
+ <?php do_action('wsa_form_last_' . $form['id'], $form);?>
272
+ </form>
273
+ </div>
274
+ <?php }?>
275
+ <?php do_action('wsa_global_footer', $form);?>
276
+ </div>
277
+ <?php
278
+ $this->script();
279
+ }
280
+ public function get_field_description($args)
281
+ {
282
+ if (!empty($args['desc']))
283
+ {
284
+
285
+ $desc = '<p class="description">' . $args['desc'] . '</p>';
286
+ }
287
+ else
288
+ {
289
+ $desc = '';
290
+ }
291
+
292
+ return $desc;
293
+ }
294
+
295
+ }
296
+
297
+ }
includes/class-wp-hide-post-activator.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Fired during plugin activation
5
+ *
6
+ * @link http://scriptburn.com
7
+ * @since 2.0
8
+ *
9
+ * @package wp_hide_post
10
+ * @subpackage wp_hide_post/includes
11
+ */
12
+
13
+ /**
14
+ * Fired during plugin activation.
15
+ *
16
+ * This class defines all code necessary to run during the plugin's activation.
17
+ *
18
+ * @since 2.0
19
+ * @package wp_hide_post
20
+ * @subpackage wp_hide_post/includes
21
+ * @author ScriptBurn <support@scriptburn.com>
22
+ */
23
+ class wp_hide_post_Activator
24
+ {
25
+
26
+ /**
27
+ * Short Description. (use period)
28
+ *
29
+ * Long Description.
30
+ *
31
+ * @since 1.2.2
32
+ */
33
+ public function activate()
34
+ {
35
+ delete_transient('wphp_notices_footer');
36
+ delete_transient('wphp_notices_widget');
37
+
38
+ if(!get_option('wphp_support_hash'))
39
+ {
40
+ add_option('wphp_support_hash',base64_encode(wp_generate_password(32,true,false)));
41
+ }
42
+ $this->remove_wp_low_profiler();
43
+
44
+ require_once WPHP_PLUGIN_DIR . 'admin/class-wp-hide-post-dbupdate.php';
45
+ $db_updater = new wp_hide_post_DB_Update();
46
+ $db_updater->update_to_ver_2();
47
+ }
48
+
49
+ /**
50
+ *
51
+ * @return unknown_type
52
+ */
53
+ public function remove_wp_low_profiler()
54
+ {
55
+ p_l("called: wphp_remove_wp_low_profiler");
56
+ $plugin_list = get_plugins('/wp-low-profiler');
57
+ if (isset($plugin_list['wp-low-profiler.php']))
58
+ {
59
+ p_l("The 'WP low Profiler' plugin is present. Cleaning it up...");
60
+ $plugins = array('wp-low-profiler/wp-low-profiler.php');
61
+ if (is_plugin_active('wp-low-profiler/wp-low-profiler.php'))
62
+ {
63
+ p_l("The 'WP low Profiler' plugin is active. Deactivating...");
64
+ deactivate_plugins($plugins, true); // silent deactivate
65
+ }
66
+ p_l("Deleting plugin 'WP low Profiler'...");
67
+ delete_plugins($plugins, '');
68
+ }
69
+ else
70
+ {
71
+ p_l("The 'WP low Profiler' plugin does not exist.");
72
+ }
73
+
74
+ }
75
+
76
+ }
includes/class-wp-hide-post-deactivator.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Fired during plugin deactivation
5
+ *
6
+ * @link http://scriptburn.com
7
+ * @since 2.0
8
+ *
9
+ * @package wp_hide_post
10
+ * @subpackage wp_hide_post/includes
11
+ */
12
+
13
+ /**
14
+ * Fired during plugin deactivation.
15
+ *
16
+ * This class defines all code necessary to run during the plugin's deactivation.
17
+ *
18
+ * @since 2.0
19
+ * @package wp_hide_post
20
+ * @subpackage wp_hide_post/includes
21
+ * @author ScriptBurn <support@scriptburn.com>
22
+ */
23
+ class wp_hide_post_Deactivator {
24
+
25
+ /**
26
+ * Short Description. (use period)
27
+ *
28
+ * Long Description.
29
+ *
30
+ * @since 1.2.2
31
+ */
32
+ public function deactivate() {
33
+
34
+ }
35
+
36
+ }
includes/class-wp-hide-post-i18n.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Define the internationalization functionality
5
+ *
6
+ * Loads and defines the internationalization files for this plugin
7
+ * so that it is ready for translation.
8
+ *
9
+ * @link http://scriptburn.com
10
+ * @since 2.0
11
+ *
12
+ * @package wp_hide_post
13
+ * @subpackage wp_hide_post/includes
14
+ */
15
+
16
+ /**
17
+ * Define the internationalization functionality.
18
+ *
19
+ * Loads and defines the internationalization files for this plugin
20
+ * so that it is ready for translation.
21
+ *
22
+ * @since 2.0
23
+ * @package wp_hide_post
24
+ * @subpackage wp_hide_post/includes
25
+ * @author ScriptBurn <support@scriptburn.com>
26
+ */
27
+ class wp_hide_post_i18n {
28
+
29
+
30
+ /**
31
+ * Load the plugin text domain for translation.
32
+ *
33
+ * @since 1.2.2
34
+ */
35
+ public function load_plugin_textdomain() {
36
+
37
+ load_plugin_textdomain(
38
+ 'wp-hide-post',
39
+ false,
40
+ dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/'
41
+ );
42
+
43
+ }
44
+
45
+
46
+
47
+ }
includes/class-wp-hide-post-loader.php ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Register all actions and filters for the plugin
5
+ *
6
+ * @link http://scriptburn.com
7
+ * @since 2.0
8
+ *
9
+ * @package wp_hide_post
10
+ * @subpackage wp_hide_post/includes
11
+ */
12
+
13
+ /**
14
+ * Register all actions and filters for the plugin.
15
+ *
16
+ * Maintain a list of all hooks that are registered throughout
17
+ * the plugin, and register them with the WordPress API. Call the
18
+ * run function to execute the list of actions and filters.
19
+ *
20
+ * @package wp_hide_post
21
+ * @subpackage wp_hide_post/includes
22
+ * @author ScriptBurn <support@scriptburn.com>
23
+ */
24
+ class wp_hide_post_Loader
25
+ {
26
+
27
+ /**
28
+ * The array of actions registered with WordPress.
29
+ *
30
+ * @since 1.2.2
31
+ * @access protected
32
+ * @var array $actions The actions registered with WordPress to fire when the plugin loads.
33
+ */
34
+ protected $actions;
35
+
36
+ /**
37
+ * The array of filters registered with WordPress.
38
+ *
39
+ * @since 1.2.2
40
+ * @access protected
41
+ * @var array $filters The filters registered with WordPress to fire when the plugin loads.
42
+ */
43
+ protected $filters;
44
+
45
+ /**
46
+ * Initialize the collections used to maintain the actions and filters.
47
+ *
48
+ * @since 1.2.2
49
+ */
50
+ public function __construct()
51
+ {
52
+
53
+ $this->actions = array();
54
+ $this->filters = array();
55
+
56
+ }
57
+
58
+ /**
59
+ * Add a new action to the collection to be registered with WordPress.
60
+ *
61
+ * @since 1.2.2
62
+ * @param string $hook The name of the WordPress action that is being registered.
63
+ * @param object $component A reference to the instance of the object on which the action is defined.
64
+ * @param string $callback The name of the function definition on the $component.
65
+ * @param int $priority Optional. he priority at which the function should be fired. Default is 10.
66
+ * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1.
67
+ */
68
+ public function add_action($hook, $component, $callback, $priority = 10, $accepted_args = 1)
69
+ {
70
+ $this->actions = $this->add($this->actions, $hook, $component, $callback, $priority, $accepted_args);
71
+ }
72
+
73
+ /**
74
+ * Add a new filter to the collection to be registered with WordPress.
75
+ *
76
+ * @since 1.2.2
77
+ * @param string $hook The name of the WordPress filter that is being registered.
78
+ * @param object $component A reference to the instance of the object on which the filter is defined.
79
+ * @param string $callback The name of the function definition on the $component.
80
+ * @param int $priority Optional. he priority at which the function should be fired. Default is 10.
81
+ * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1
82
+ */
83
+ public function add_filter($hook, $component, $callback, $priority = 10, $accepted_args = 1)
84
+ {
85
+ $this->filters = $this->add($this->filters, $hook, $component, $callback, $priority, $accepted_args);
86
+ }
87
+
88
+ /**
89
+ * A utility function that is used to register the actions and hooks into a single
90
+ * collection.
91
+ *
92
+ * @since 1.2.2
93
+ * @access private
94
+ * @param array $hooks The collection of hooks that is being registered (that is, actions or filters).
95
+ * @param string $hook The name of the WordPress filter that is being registered.
96
+ * @param object $component A reference to the instance of the object on which the filter is defined.
97
+ * @param string $callback The name of the function definition on the $component.
98
+ * @param int $priority The priority at which the function should be fired.
99
+ * @param int $accepted_args The number of arguments that should be passed to the $callback.
100
+ * @return array The collection of actions and filters registered with WordPress.
101
+ */
102
+ private function add($hooks, $hook, $component, $callback, $priority, $accepted_args)
103
+ {
104
+
105
+ $hooks[] = array(
106
+ 'hook' => $hook,
107
+ 'component' => $component,
108
+ 'callback' => $callback,
109
+ 'priority' => $priority,
110
+ 'accepted_args' => $accepted_args,
111
+ );
112
+
113
+ return $hooks;
114
+
115
+ }
116
+
117
+ /**
118
+ * Register the filters and actions with WordPress.
119
+ *
120
+ * @since 1.2.2
121
+ */
122
+ public function run()
123
+ {
124
+
125
+ foreach ($this->filters as $hook)
126
+ {
127
+ add_filter($hook['hook'], array($hook['component'], $hook['callback']), $hook['priority'], $hook['accepted_args']);
128
+ }
129
+
130
+ foreach ($this->actions as $hook)
131
+ {
132
+ add_action($hook['hook'], array($hook['component'], $hook['callback']), $hook['priority'], $hook['accepted_args']);
133
+ }
134
+
135
+ }
136
+
137
+ }
includes/class-wp-hide-post.php ADDED
@@ -0,0 +1,488 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * The file that defines the core plugin class
5
+ *
6
+ * A class definition that includes attributes and functions used across both the
7
+ * public-facing side of the site and the admin area.
8
+ *
9
+ * @link http://scriptburn.com
10
+ * @since 2.0
11
+ *
12
+ * @package wp_hide_post
13
+ * @subpackage wp_hide_post/includes
14
+ */
15
+
16
+ /**
17
+ * The core plugin class.
18
+ *
19
+ * This is used to define internationalization, admin-specific hooks, and
20
+ * public-facing site hooks.
21
+ *
22
+ * Also maintains the unique identifier of this plugin as well as the current
23
+ * version of the plugin.
24
+ *
25
+ * @since 2.0
26
+ * @package wp_hide_post
27
+ * @subpackage wp_hide_post/includes
28
+ * @author ScriptBurn <support@scriptburn.com>
29
+ */
30
+ class wp_hide_post
31
+ {
32
+
33
+ /**
34
+ * The loader that's responsible for maintaining and registering all hooks that power
35
+ * the plugin.
36
+ *
37
+ * @since 1.2.2
38
+ * @access protected
39
+ * @var wp_hide_post_Loader $loader Maintains and registers all hooks for the plugin.
40
+ */
41
+ protected $loader;
42
+
43
+ /**
44
+ * The unique identifier of this plugin.
45
+ *
46
+ * @since 1.2.2
47
+ * @access protected
48
+ * @var string $wp_hide_post The string used to uniquely identify this plugin.
49
+ */
50
+ protected $wp_hide_post;
51
+
52
+ /**
53
+ * The current version of the plugin.
54
+ *
55
+ * @since 1.2.2
56
+ * @access protected
57
+ * @var string $version The current version of the plugin.
58
+ */
59
+ protected $version;
60
+
61
+ /**
62
+ * Holds the single instance of setting manage class
63
+ *
64
+ * @since 1.2.2
65
+ * @access protected
66
+ * @var string $version The current version of the plugin.
67
+ */
68
+ protected $settingManager;
69
+ /**
70
+ * Holds the single instance of this class
71
+ *
72
+ * @since 1.2.2
73
+ * @access protected
74
+ * @var string $version The current version of the plugin.
75
+ */
76
+ private static $instance;
77
+ private $plugin_admin;
78
+
79
+ const id = 'wp-hide-post';
80
+ const name = 'WP Hide Post';
81
+
82
+ private $info;
83
+
84
+ /**
85
+ * Define the core functionality of the plugin.
86
+ *
87
+ * Set the plugin name and the plugin version that can be used throughout the plugin.
88
+ * Load the dependencies, define the locale, and set the hooks for the admin area and
89
+ * the public-facing side of the site.
90
+ *
91
+ * @since 1.2.2
92
+ */
93
+
94
+ public static function getInstance()
95
+ {
96
+ if (is_null(self::$instance))
97
+ {
98
+ self::$instance = new self();
99
+ }
100
+
101
+ return self::$instance;
102
+ }
103
+
104
+ public function __construct()
105
+ {
106
+
107
+ $this->define_globals();
108
+ $this->load_dependencies();
109
+ $this->init();
110
+
111
+ $this->plugin_admin = new wp_hide_post_Admin(
112
+ $this->get_wp_hide_post(),
113
+ $this->get_version(), $this->license());
114
+
115
+ $this->set_locale();
116
+ $this->define_admin_hooks();
117
+ $this->define_public_hooks();
118
+
119
+ }
120
+
121
+ /**
122
+ * Load the required dependencies for this plugin.
123
+ *
124
+ * Include the following files that make up the plugin:
125
+ *
126
+ * - wp_hide_post_Loader. Orchestrates the hooks of the plugin.
127
+ * - wp_hide_post_i18n. Defines internationalization functionality.
128
+ * - wp_hide_post_Admin. Defines all hooks for the admin area.
129
+ * - wp_hide_post_Public. Defines all hooks for the public side of the site.
130
+ *
131
+ * Create an instance of the loader which will be used to register the hooks
132
+ * with WordPress.
133
+ *
134
+ * @since 1.2.2
135
+ * @access private
136
+ */
137
+ private function load_dependencies()
138
+ {
139
+ /**
140
+ * This file contains usfull functions to be used in global scope througout the plugin
141
+ */
142
+ require_once WPHP_PLUGIN_DIR . 'includes/helpers.php';
143
+
144
+ /**
145
+ * The class responsible for orchestrating the actions and filters of the
146
+ * core plugin.
147
+ */
148
+ require_once WPHP_PLUGIN_DIR . 'includes/class-wp-hide-post-loader.php';
149
+
150
+ /**
151
+ * The class responsible for defining internationalization functionality
152
+ * of the plugin.
153
+ */
154
+ require_once WPHP_PLUGIN_DIR . 'includes/class-wp-hide-post-i18n.php';
155
+
156
+ /**
157
+ * The class responsible for defining all actions that occur in the admin area.
158
+ */
159
+ require_once WPHP_PLUGIN_DIR . 'admin/class-wp-hide-post-admin.php';
160
+
161
+ /**
162
+ * The class responsible for defining all actions that occur in the public-facing
163
+ * side of the site.
164
+ */
165
+ require_once WPHP_PLUGIN_DIR . 'public/class-wp-hide-post-public.php';
166
+
167
+ /**
168
+ * The class responsible for defining all actions that occur in the public-facing
169
+ * side of the site.
170
+ */
171
+ require_once WPHP_PLUGIN_DIR . 'public/class-wp-hide-post-public.php';
172
+ require_once WPHP_PLUGIN_DIR . 'admin/license/autoload.php';
173
+
174
+ require_once WPHP_PLUGIN_DIR . 'admin/settings/autoload.php';
175
+ require_once WPHP_PLUGIN_DIR . 'admin/conditions.php';
176
+ require_once WPHP_PLUGIN_DIR . 'admin/plugin/autoload.php';
177
+
178
+ $this->loader = new wp_hide_post_Loader();
179
+
180
+ }
181
+ public function settingManager()
182
+ {
183
+ return $this->settingManager;
184
+ }
185
+ public function pluginAdmin()
186
+ {
187
+ return $this->plugin_admin;
188
+ }
189
+ /**
190
+ * Define the locale for this plugin for internationalization.
191
+ *
192
+ * Uses the wp_hide_post_i18n class in order to set the domain and to register the hook
193
+ * with WordPress.
194
+ *
195
+ * @since 1.2.2
196
+ * @access private
197
+ */
198
+ private function set_locale()
199
+ {
200
+
201
+ $plugin_i18n = new wp_hide_post_i18n();
202
+
203
+ $this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain');
204
+
205
+ }
206
+
207
+ /**
208
+ * Register all of the hooks related to the admin area functionality
209
+ * of the plugin.
210
+ *
211
+ * @since 1.2.2
212
+ * @access private
213
+ */
214
+ private function define_admin_hooks()
215
+ {
216
+ $this->loader->add_filter('scb_license_items', $this->plugin_admin, 'register_plugin', 10);
217
+ $this->loader->add_action('init', $this->plugin_admin, 'register_setting_page');
218
+
219
+ //add our styles
220
+ $this->loader->add_action('admin_enqueue_scripts', $this->plugin_admin, 'enqueue_styles');
221
+
222
+ // add our scripts
223
+ $this->loader->add_action('admin_enqueue_scripts', $this->plugin_admin, 'enqueue_scripts');
224
+
225
+ // watch when wp-low-profiler get activated
226
+ $this->loader->add_action('activate_wp-low-profiler/wp-low-profiler.php', $this->plugin_admin, 'activate_lowprofiler');
227
+
228
+ // mark wp-low-profiler as depriciated
229
+ $this->loader->add_action('plugin_install_action_links', $this->plugin_admin, 'plugin_install_action_links_wp_lowprofiler', 10, 2);
230
+
231
+ $this->loader->add_action('save_post', $this->plugin_admin, 'save_post');
232
+ $this->loader->add_action('delete_post', $this->plugin_admin, 'delete_post');
233
+
234
+ $this->loader->add_action('add_meta_boxes', $this->plugin_admin, 'add_meta_boxes');
235
+ $this->loader->add_action('admin_menu', $this->plugin_admin, 'admin_menu');
236
+ if (wphp_is_demo())
237
+ {
238
+ $this->loader->add_filter('init', $this->plugin_admin, 'create_post_type', 10);
239
+ }
240
+ // loop through all allowed post types as saved in setting section of the plugin where we this plugin can work
241
+
242
+ foreach ($this->plugin_admin->allowedPostTypes() as $post_type)
243
+ {
244
+ // add our custom column to posts list
245
+ $this->loader->add_filter("manage_{$post_type}_posts_columns", $this->plugin_admin, 'manage_posts_columns', 10);
246
+ // some plugins still using this old filter
247
+ $this->loader->add_filter("manage_edit-{$post_type}_columns", $this->plugin_admin, 'manage_posts_columns', 10);
248
+
249
+ }
250
+
251
+ // add this in case a custom post type is hierarchical type this works for page
252
+ $this->loader->add_action("manage_pages_custom_column", $this->plugin_admin, 'render_custom_column_data', 10, 2);
253
+
254
+ //renders custom column data for posts
255
+ $this->loader->add_action("manage_posts_custom_column", $this->plugin_admin, 'render_custom_column_data', 10, 2);
256
+
257
+ // add our custom filter selectbox in admin post list box
258
+ $this->loader->add_action("restrict_manage_posts", $this->plugin_admin, 'restrict_manage_posts');
259
+
260
+ // Filter the posts acording to selected filter in post list select box
261
+ $this->loader->add_filter('posts_join_paged', $this->plugin_admin, 'query_posts_join_custom_filter', 10, 2);
262
+
263
+ //render our quick edit box
264
+ $this->loader->add_action('quick_edit_custom_box', $this->plugin_admin, 'display_custom_quickedit', 10, 2);
265
+
266
+ //render our bulk edit box
267
+ $this->loader->add_action('bulk_edit_custom_box', $this->plugin_admin, 'display_custom_bulkedit', 10, 2);
268
+
269
+ // print our available visibility type items in footer js
270
+ // which we will use when sending our data to server in bulk edit save
271
+ $this->loader->add_action('admin_footer', $this->plugin_admin, 'admin_footer');
272
+
273
+ //Save bulk edit data
274
+ $this->loader->add_action('wp_ajax_save_bulk_edit_data', $this->plugin_admin, 'save_bulk_edit_data');
275
+
276
+ //Our custom action to add fotter message in widget
277
+ $this->loader->add_action('wsa_global_footer', $this->plugin_admin, 'wsa_footer');
278
+
279
+ //Check if we need to update database
280
+ $this->loader->add_action('plugins_loaded', $this->plugin_admin, 'maybe_update', 1);
281
+
282
+ //returns system info data for support reques
283
+ add_action('plugins_loaded', function ()
284
+ {
285
+ if (isset($_REQUEST['support_info']))
286
+ {
287
+ if (isset($_REQUEST['hash']) && get_option('wphp_support_hash') == $_REQUEST['hash'])
288
+ {
289
+ echo (scb_systems_info("</br>"));
290
+ }
291
+
292
+ wp_die();
293
+ }
294
+ }, 1);
295
+
296
+ //$theme_item = new SCB_Item_Helper($this->store, $this->item_file_name, $this->get_license_key(), $this->item_type);
297
+
298
+ }
299
+
300
+ /**
301
+ * Register all of the hooks related to the public-facing functionality
302
+ * of the plugin.
303
+ *
304
+ * @since 1.2.2
305
+ * @access private
306
+ */
307
+ private function define_public_hooks()
308
+ {
309
+ if (is_admin())
310
+ {
311
+ return;
312
+ }
313
+ $plugin_public = new wp_hide_post_Public($this->get_wp_hide_post(), $this->get_version());
314
+
315
+ $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_styles');
316
+ $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_scripts');
317
+
318
+ //add where clauss in main filter query
319
+ $this->loader->add_filter('posts_where_paged', $plugin_public, 'query_posts_where', 10, 2);
320
+
321
+ //add join clauss in main filter query
322
+ $this->loader->add_filter('posts_join_paged', $plugin_public, 'query_posts_join', 10, 2);
323
+
324
+ $this->loader->add_filter('widget_posts_args', $plugin_public, 'widget_posts_args');
325
+
326
+ // only for testing purpose , Enables hidepost enabled post type to appear everywhere
327
+ if (wphp_is_demo())
328
+ {
329
+
330
+ //$this->loader->add_action('pre_get_posts', $plugin_public, 'test_enable_allposts_everywhere');
331
+
332
+ }
333
+ // used to add join clause to remove next and previous rel link of post from single page
334
+ $this->loader->add_filter('get_next_post_join', $plugin_public, 'post_excluded_terms_join_rel', 10, 1);
335
+ $this->loader->add_filter('get_previous_post_join', $plugin_public, 'post_excluded_terms_join_rel', 10, 1);
336
+
337
+ // used to add where clause to remove next and previous rel link of post from single page
338
+ $this->loader->add_filter('get_next_post_where', $plugin_public, 'query_posts_where_rel_exclude', 10, 1);
339
+ $this->loader->add_filter('get_previous_post_where', $plugin_public, 'query_posts_where_rel_exclude', 10, 1);
340
+
341
+ }
342
+
343
+ /**
344
+ * Run the loader to execute all of the hooks with WordPress.
345
+ *
346
+ * @since 1.2.2
347
+ */
348
+ public function run()
349
+ {
350
+ $this->loader->run();
351
+ }
352
+
353
+ /**
354
+ * The name of the plugin used to uniquely identify it within the context of
355
+ * WordPress and to define internationalization functionality.
356
+ *
357
+ * @since 1.0.0
358
+ * @return string The name of the plugin.
359
+ */
360
+ public function get_wp_hide_post()
361
+ {
362
+ return $this->info('id');
363
+ }
364
+
365
+ public function info($name)
366
+ {
367
+ if (defined('static::' . $name))
368
+ {
369
+ return constant('self::' . $name);
370
+ }
371
+ elseif (isset($this->info[$name]))
372
+ {
373
+ return $this->info[$name];
374
+ }
375
+ else
376
+ {
377
+ return "";
378
+
379
+ }
380
+ return defined('static::' . $name) ? constant('self::' . $name) : '';
381
+ }
382
+ /**
383
+ * The reference to the class that orchestrates the hooks with the plugin.
384
+ *
385
+ * @since 1.0.0
386
+ * @return wp_hide_post_Loader Orchestrates the hooks of the plugin.
387
+ */
388
+ public function get_loader()
389
+ {
390
+ return $this->loader;
391
+ }
392
+
393
+ /**
394
+ * Retrieve the version number of the plugin.
395
+ *
396
+ * @since 1.0.0
397
+ * @return string The version number of the plugin.
398
+ */
399
+ public function get_version()
400
+ {
401
+ return WPHP_VER;
402
+ }
403
+
404
+ public function setting_menu_page()
405
+ {
406
+ return $this->get_wp_hide_post() . '_settings_api';
407
+ }
408
+ public function license()
409
+ {
410
+ return SCB_LicenseManager::getInstance()->item('wp-hide-post-pro');
411
+ }
412
+ public function init()
413
+ {
414
+ $this->settingManager = wphp_settings::instance(array
415
+ (
416
+ 'id' => $this->info('id'),
417
+ 'page_title' => $this->info('title') . " settings",
418
+ 'setting_page_name' => $this->setting_menu_page(),
419
+ 'support_callback' => function ()
420
+ {
421
+ $obj_license = scb_get_license($this->info('id'));
422
+ $info = array();
423
+ $info['price'] = "0";
424
+ if (is_object($obj_license))
425
+ {
426
+ $info = $obj_license->extendedInfo();
427
+ $info['key'] = $obj_license->get_license_key();
428
+
429
+ }
430
+
431
+ $output = array();
432
+ $info['price'] = 1;
433
+ if ($info['price'] > 0)
434
+ {
435
+ $output[] = '<h2>For WP hide post Pro users</h2>';
436
+ if ($info['key'] && $info['license'] == 'valid')
437
+ {
438
+ $subject = ("WP hide post Pro Support Request");
439
+ $body = "";
440
+ $body .= "License:" . $info['key'] . "%0D%0A%0D%0A";
441
+ $body .= 'Systems Info:' . home_url() . "?support_info" . "%0D%0A%0D%0A";
442
+ $body .= 'Hash:' . get_option('wphp_support_hash') . "%0D%0A%0D%0A%0D%0A%0D%0A";
443
+ $body .= "Enter your message here ";
444
+ $output[] = sprintf('<a href="mailto:support@scriptburn.com?subject=%1$s&body=%2$s">Click here </a>', $subject, $body);
445
+ }
446
+ else
447
+ {
448
+ $output[] = "Sorry you don't have WP hide post Pro license";
449
+ }
450
+ $output[] = '<h2>For WP hide post Lite users</h2>';
451
+ }
452
+ $output[] = 'Please submit your questions <a target="_blank" href="https://github.com/scriptburn/wp-hide-post">Here</a>';
453
+ echo (implode("\n", $output));
454
+ },
455
+ ));
456
+ if (wphp_ispro())
457
+ {
458
+
459
+ scb_license_manager()->add(
460
+ 'wp-hide-post-pro',
461
+ null,
462
+ 'plugin',
463
+ 'WP Hide Post Pro',
464
+ null,
465
+ array(
466
+ 'license_text' => array('invalid' => 'Get your WP Hide Post Pro license from here <a href="http://scriptburn.com/wphp" target="_blank">here</a>'),
467
+ 'store_url' => "http://scriptburn.com",
468
+ 'file' => $this->info('file'),
469
+
470
+ )
471
+ );
472
+ }
473
+ }
474
+ public function define_globals()
475
+ {
476
+
477
+ $this->info['dir'] = WPHP_PLUGIN_DIR;
478
+ $this->info['url'] = WPHP_PLUGIN_URL;
479
+
480
+ $this->info['title'] = __('WP Hide Post', 'scb_plugin');
481
+ $this->info['file'] = WPHP_PLUGIN_FILE;
482
+ $this->info['basename'] = plugin_basename($this->info['file']);
483
+ }
484
+ }
485
+ function wp_hide_post()
486
+ {
487
+ return wp_hide_post::getInstance();
488
+ }
includes/helpers.php ADDED
@@ -0,0 +1,454 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if (!function_exists('print_nice'))
4
+ {
5
+ function print_nice($rr, $d = false, $extra = "")
6
+ {
7
+ if ($d)
8
+ {
9
+ return ($extra ? "<pre>" . $extra . "</pre>" : '') . "<pre>" . print_r($rr, true) . "</pre>";
10
+ }
11
+ else
12
+ {
13
+ echo (($extra ? "<pre>" . $extra . "</pre>" : '') . "<pre>" . print_r($rr, true) . "</pre>");
14
+ }
15
+ }
16
+ }
17
+ if (!function_exists('p_n'))
18
+ {
19
+ function p_n($rr, $d = false)
20
+ {
21
+ $bt = debug_backtrace();
22
+
23
+ $caller1 = $bt[0];
24
+ $caller2 = @$bt[1];
25
+
26
+ $caller1['file'] = str_replace(WPHP_PLUGIN_DIR, "", $caller1['file']);
27
+ $str = $caller1['file'] . "@" . @$caller2['function'] . "():$caller1[line]";
28
+
29
+ print_nice($rr, $d, $str);
30
+ }
31
+ }
32
+ if (!function_exists('p_d'))
33
+ {
34
+ function p_d($rr, $d = false)
35
+ {
36
+ $bt = debug_backtrace();
37
+
38
+ $caller1 = $bt[0];
39
+ $caller2 = @$bt[1];
40
+
41
+ $caller1['file'] = str_replace(WPHP_PLUGIN_DIR, "", @$caller1['file']);
42
+ $str = $caller1['file'] . "@" . @$caller2['function'] . "():" . @$caller1['line'];
43
+
44
+ if ($d)
45
+ {
46
+ ob_start();
47
+ var_dump($rr);
48
+ $rr = ob_get_clean();
49
+ $d = false;
50
+ }
51
+ print_nice($rr, $d, $str);
52
+ die('');
53
+ }
54
+ }
55
+ if (!function_exists('p_c'))
56
+ {
57
+ function p_c($msg)
58
+ {
59
+ $bt = debug_backtrace();
60
+
61
+ $caller1 = $bt[0];
62
+ $caller2 = @$bt[1];
63
+
64
+ $caller1['file'] = str_replace(WPHP_PLUGIN_DIR, "", $caller1['file']);
65
+ $str = microtime(true) . "-" . $caller1['file'] . "@" . @$caller2['function'] . "():$caller1[line]" . "-->";
66
+ $msg = json_encode($msg);
67
+ echo ("<script>console.log('$str' );console.log($msg)</script>");
68
+ }
69
+ }
70
+ if (!function_exists('p_l'))
71
+ {
72
+ function p_l($msg, $dump = false)
73
+ {
74
+ if (!defined('WPHP_DEBUG') || !WPHP_DEBUG)
75
+ {
76
+ return;
77
+ }
78
+ $bt = debug_backtrace();
79
+
80
+ $caller1 = $bt[0];
81
+ $caller2 = @$bt[1];
82
+
83
+ $caller1['file'] = str_replace(WPHP_PLUGIN_DIR, "", $caller1['file']);
84
+ $str = microtime(true) . "-" . $caller1['file'] . "@" . @$caller2['function'] . "():$caller1[line]" . "-->";
85
+
86
+ error_log($str);
87
+
88
+ if ($dump)
89
+ {
90
+ ob_start();
91
+ var_dump($msg);
92
+ $rr = ob_get_clean();
93
+ }
94
+ else
95
+ {
96
+ $rr = print_r($msg, 1);
97
+ }
98
+
99
+ error_log($rr);
100
+
101
+ }
102
+ }
103
+ if (!function_exists('_wphp_http_post'))
104
+ {
105
+ function _wphp_http_post($var, $default = null)
106
+ {
107
+ if (isset($_POST[$var]))
108
+ {
109
+ return $_POST[$var];
110
+ }
111
+ else
112
+ {
113
+ return $default;
114
+ }
115
+ }
116
+ }
117
+ if (!function_exists('wphp_allowed_post_types'))
118
+ {
119
+ function wphp_allowed_post_types($joined = false)
120
+ {
121
+ static $post_types, $post_types_joined;
122
+ if (!$post_types)
123
+ {
124
+ $post_types = wp_hide_post()->pluginAdmin()->allowedPostTypes();
125
+
126
+ }
127
+ if ($joined)
128
+ {
129
+ return $post_types_joined ? $post_types_joined : "post_type in ('" . implode("','", $post_types) . "')";
130
+ }
131
+ else
132
+ {
133
+ return $post_types;
134
+ }
135
+
136
+ }
137
+ }
138
+ if (!function_exists('wphp_is_applicable'))
139
+ {
140
+ function wphp_is_applicable($item_type, $wp_query = null)
141
+ {
142
+
143
+ $types = array_flip(wphp_allowed_post_types());
144
+ unset($types['page']);
145
+ $ret = 0;
146
+ $types = array_flip($types);
147
+
148
+ if (wphp_is_post_sidebar($wp_query))
149
+ {
150
+ //p_n(__LINE__);
151
+ $ret = 1;
152
+ }
153
+ elseif (is_admin() || is_singular())
154
+ {
155
+
156
+ if (@is_front_page())
157
+ {
158
+ $ret = 4;
159
+ }
160
+ else
161
+ {
162
+ $ret = 0;
163
+ }
164
+ }
165
+ elseif (in_array($item_type, $types) || $item_type == 'page')
166
+ {
167
+ // p_n(__LINE__);
168
+ $ret = 2;
169
+ }
170
+ else
171
+ {
172
+
173
+ $ret = 0;
174
+ }
175
+ p_l($ret);
176
+ return $ret;
177
+
178
+ }
179
+ }
180
+
181
+ if (!function_exists('wphp_'))
182
+ {
183
+ function wphp_($text)
184
+ {
185
+ return __($text, 'wp-hide-post');
186
+ }
187
+ }
188
+ if (!function_exists('wphp_is_demo'))
189
+ {
190
+ function wphp_is_demo()
191
+ {
192
+
193
+ return $_SERVER['HTTP_HOST'] == 'wphidepost.loc';
194
+ }
195
+ }
196
+ if (!function_exists('wphp_get_setting'))
197
+ {
198
+ function wphp_get_setting($section, $option = false, $default = false)
199
+ {
200
+ static $default_setting;
201
+ if (!$default_setting)
202
+ {
203
+ $default_setting = wphp_get_default_setting();
204
+ }
205
+ $options = get_option($section);
206
+
207
+ if (!$option)
208
+ {
209
+ return $options;
210
+ }
211
+ if (isset($options[$option]))
212
+ {
213
+ return $options[$option];
214
+ }
215
+ elseif ($default)
216
+ {
217
+
218
+ if (isset($default_setting[$option]))
219
+ {
220
+ return $default_setting[$option];
221
+ }
222
+ else
223
+ {
224
+ return null;
225
+ }
226
+ }
227
+ else
228
+ {
229
+ return null;
230
+ }
231
+ }
232
+ }
233
+ if (!function_exists('wphp_visibility_types'))
234
+ {
235
+ function wphp_visibility_types($joined = false)
236
+ {
237
+ static $post_visibility_joined;
238
+ $post_visibility = wp_hide_post()->pluginAdmin()->get_post_visibility_types();
239
+ return $post_visibility;
240
+ if ($joined)
241
+ {
242
+ if ($post_visibility_joined)
243
+ {
244
+ return $post_visibility_joined;
245
+ }
246
+ else
247
+ {
248
+ if (!count($post_visibility_joined))
249
+ {
250
+ $post_visibility_joined = "";
251
+ }
252
+ else
253
+ {
254
+ $post_visibility_joined = "in ('" . implode("','", array_keys($post_visibility)) . "')";
255
+ }
256
+ return $post_visibility_joined;
257
+ }
258
+ }
259
+ else
260
+ {
261
+ return $post_visibility;
262
+ }
263
+ }
264
+ }
265
+
266
+ if (!function_exists('array_column'))
267
+ {
268
+ /**
269
+ * Returns the values from a single column of the input array, identified by
270
+ * the $columnKey.
271
+ *
272
+ * Optionally, you may provide an $indexKey to index the values in the returned
273
+ * array by the values from the $indexKey column in the input array.
274
+ *
275
+ * @param array $input A multi-dimensional array (record set) from which to pull
276
+ * a column of values.
277
+ * @param mixed $columnKey The column of values to return. This value may be the
278
+ * integer key of the column you wish to retrieve, or it
279
+ * may be the string key name for an associative array.
280
+ * @param mixed $indexKey (Optional.) The column to use as the index/keys for
281
+ * the returned array. This value may be the integer key
282
+ * of the column, or it may be the string key name.
283
+ * @return array
284
+ */
285
+ function array_column($input = null, $columnKey = null, $indexKey = null)
286
+ {
287
+ // Using func_get_args() in order to check for proper number of
288
+ // parameters and trigger errors exactly as the built-in array_column()
289
+ // does in PHP 5.5.
290
+ $argc = func_num_args();
291
+ $params = func_get_args();
292
+ if ($argc < 2)
293
+ {
294
+ trigger_error("array_column() expects at least 2 parameters, {$argc} given", E_USER_WARNING);
295
+ return null;
296
+ }
297
+ if (!is_array($params[0]))
298
+ {
299
+ trigger_error(
300
+ 'array_column() expects parameter 1 to be array, ' . gettype($params[0]) . ' given',
301
+ E_USER_WARNING
302
+ );
303
+ return null;
304
+ }
305
+ if (!is_int($params[1])
306
+ && !is_float($params[1])
307
+ && !is_string($params[1])
308
+ && $params[1] !== null
309
+ && !(is_object($params[1]) && method_exists($params[1], '__toString'))
310
+ )
311
+ {
312
+ trigger_error('array_column(): The column key should be either a string or an integer', E_USER_WARNING);
313
+ return false;
314
+ }
315
+ if (isset($params[2])
316
+ && !is_int($params[2])
317
+ && !is_float($params[2])
318
+ && !is_string($params[2])
319
+ && !(is_object($params[2]) && method_exists($params[2], '__toString'))
320
+ )
321
+ {
322
+ trigger_error('array_column(): The index key should be either a string or an integer', E_USER_WARNING);
323
+ return false;
324
+ }
325
+ $paramsInput = $params[0];
326
+ $paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null;
327
+ $paramsIndexKey = null;
328
+ if (isset($params[2]))
329
+ {
330
+ if (is_float($params[2]) || is_int($params[2]))
331
+ {
332
+ $paramsIndexKey = (int) $params[2];
333
+ }
334
+ else
335
+ {
336
+ $paramsIndexKey = (string) $params[2];
337
+ }
338
+ }
339
+ $resultArray = array();
340
+ foreach ($paramsInput as $row)
341
+ {
342
+ $key = $value = null;
343
+ $keySet = $valueSet = false;
344
+ if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row))
345
+ {
346
+ $keySet = true;
347
+ $key = (string) $row[$paramsIndexKey];
348
+ }
349
+ if ($paramsColumnKey === null)
350
+ {
351
+ $valueSet = true;
352
+ $value = $row;
353
+ }
354
+ elseif (is_array($row) && array_key_exists($paramsColumnKey, $row))
355
+ {
356
+ $valueSet = true;
357
+ $value = $row[$paramsColumnKey];
358
+ }
359
+ if ($valueSet)
360
+ {
361
+ if ($keySet)
362
+ {
363
+ $resultArray[$key] = $value;
364
+ }
365
+ else
366
+ {
367
+ $resultArray[] = $value;
368
+ }
369
+ }
370
+ }
371
+ return $resultArray;
372
+ }
373
+ }
374
+
375
+ function wphp_get_host()
376
+ {
377
+ $host = false;
378
+
379
+ if (defined('WPE_APIKEY'))
380
+ {
381
+ $host = 'WP Engine';
382
+ }
383
+ elseif (defined('PAGELYBIN'))
384
+ {
385
+ $host = 'Pagely';
386
+ }
387
+ elseif (DB_HOST == 'localhost:/tmp/mysql5.sock')
388
+ {
389
+ $host = 'ICDSoft';
390
+ }
391
+ elseif (DB_HOST == 'mysqlv5')
392
+ {
393
+ $host = 'NetworkSolutions';
394
+ }
395
+ elseif (strpos(DB_HOST, 'ipagemysql.com') !== false)
396
+ {
397
+ $host = 'iPage';
398
+ }
399
+ elseif (strpos(DB_HOST, 'ipowermysql.com') !== false)
400
+ {
401
+ $host = 'IPower';
402
+ }
403
+ elseif (strpos(DB_HOST, '.gridserver.com') !== false)
404
+ {
405
+ $host = 'MediaTemple Grid';
406
+ }
407
+ elseif (strpos(DB_HOST, '.pair.com') !== false)
408
+ {
409
+ $host = 'pair Networks';
410
+ }
411
+ elseif (strpos(DB_HOST, '.stabletransit.com') !== false)
412
+ {
413
+ $host = 'Rackspace Cloud';
414
+ }
415
+ elseif (strpos(DB_HOST, '.sysfix.eu') !== false)
416
+ {
417
+ $host = 'SysFix.eu Power Hosting';
418
+ }
419
+ elseif (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false)
420
+ {
421
+ $host = 'Flywheel';
422
+ }
423
+ else
424
+ {
425
+ // Adding a general fallback for data gathering
426
+ $host = 'DBH: ' . DB_HOST . ', SRV: ' . $_SERVER['SERVER_NAME'];
427
+ }
428
+
429
+ return $host;
430
+ }
431
+
432
+ function scb_custom_post_types($output = 'objects')
433
+ {
434
+
435
+ $args = array(
436
+ 'public' => true,
437
+ '_builtin' => true,
438
+ );
439
+
440
+ $operator = 'or'; // 'and' or 'or'
441
+
442
+ $types = (array) get_post_types($args, $output, $operator);
443
+ unset($types['revision']);
444
+ unset($types['nav_menu_item']);
445
+ unset($types['attachment']);
446
+
447
+ return empty($types) || !is_array($types) ? array() : $types;
448
+
449
+ }
450
+
451
+ function wphp_ispro()
452
+ {
453
+ return (defined('WPHP_PRO') && WPHP_PRO) || wp_hide_post()->info('id') == 'wp-hide-post-pro';
454
+ }
includes/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden
index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden
wp-hide-post.pot → languages/wp-hide-post.pot RENAMED
File without changes
public/class-wp-hide-post-public.php ADDED
@@ -0,0 +1,386 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * The public-facing functionality of the plugin.
5
+ *
6
+ * @link http://scriptburn.com
7
+ * @since 2.0
8
+ *
9
+ * @package wp_hide_post
10
+ * @subpackage wp_hide_post/public
11
+ */
12
+
13
+ /**
14
+ * The public-facing functionality of the plugin.
15
+ *
16
+ * Defines the plugin name, version, and two examples hooks for how to
17
+ * enqueue the admin-specific stylesheet and JavaScript.
18
+ *
19
+ * @package wp_hide_post
20
+ * @subpackage wp_hide_post/public
21
+ * @author ScriptBurn <support@scriptburn.com>
22
+ */
23
+ class wp_hide_post_Public
24
+ {
25
+
26
+ /**
27
+ * The ID of this plugin.
28
+ *
29
+ * @since 1.2.2
30
+ * @access private
31
+ * @var string $wp_hide_post The ID of this plugin.
32
+ */
33
+ private $wp_hide_post;
34
+
35
+ /**
36
+ * The version of this plugin.
37
+ *
38
+ * @since 1.2.2
39
+ * @access private
40
+ * @var string $version The current version of this plugin.
41
+ */
42
+ private $version;
43
+
44
+ /**
45
+ * Initialize the class and set its properties.
46
+ *
47
+ * @since 1.2.2
48
+ * @param string $wp_hide_post The name of the plugin.
49
+ * @param string $version The version of this plugin.
50
+ */
51
+ public function __construct($wp_hide_post, $version)
52
+ {
53
+
54
+ $this->wp_hide_post = $wp_hide_post;
55
+ $this->version = $version;
56
+
57
+ }
58
+
59
+ /**
60
+ * Register the stylesheets for the public-facing side of the site.
61
+ *
62
+ * @since 1.2.2
63
+ */
64
+ public function enqueue_styles()
65
+ {
66
+
67
+ /**
68
+ * This function is provided for demonstration purposes only.
69
+ *
70
+ * An instance of this class should be passed to the run() function
71
+ * defined in wp_hide_post_Loader as all of the hooks are defined
72
+ * in that particular class.
73
+ *
74
+ * The wp_hide_post_Loader will then create the relationship
75
+ * between the defined hooks and the functions defined in this
76
+ * class.
77
+ */
78
+
79
+ // wp_enqueue_style($this->wp_hide_post, plugin_dir_url(__FILE__) . 'css/wp-hide-post-public.css', array(), $this->version, 'all');
80
+
81
+ }
82
+
83
+ /**
84
+ * Register the JavaScript for the public-facing side of the site.
85
+ *
86
+ * @since 1.2.2
87
+ */
88
+ public function enqueue_scripts()
89
+ {
90
+
91
+ /**
92
+ * This function is provided for demonstration purposes only.
93
+ *
94
+ * An instance of this class should be passed to the run() function
95
+ * defined in wp_hide_post_Loader as all of the hooks are defined
96
+ * in that particular class.
97
+ *
98
+ * The wp_hide_post_Loader will then create the relationship
99
+ * between the defined hooks and the functions defined in this
100
+ * class.
101
+ */
102
+
103
+ wp_enqueue_script($this->wp_hide_post, plugin_dir_url(__FILE__) . 'js/wp-hide-post-public.js', array('jquery'), $this->version, false);
104
+
105
+ }
106
+ private function exclude_low_profile_items($item_type, $posts)
107
+ {
108
+ p_l("called: exclude_low_profile_items");
109
+ if ($item_type != 'page')
110
+ {
111
+ return $posts;
112
+ }
113
+ // regular posts & search results are filtered in wphp_query_posts_join
114
+ else
115
+ {
116
+ if (wphp_is_applicable('page'))
117
+ {
118
+ global $wpdb;
119
+ // now loop over the pages, and exclude the ones with low profile in this context
120
+ $result = array();
121
+ $page_flags = $wpdb->get_results("SELECT post_id, meta_value FROM " . WPHP_TABLE_NAME . " WHERE meta_key = '_wplp_page_flags'", OBJECT_K);
122
+ if ($posts)
123
+ {
124
+ foreach ($posts as $post)
125
+ {
126
+ $check = isset($page_flags[$post->ID]) ? $page_flags[$post->ID]->meta_value : null;
127
+ if (($check == 'front' && wphp_is_front_page()) || $check == 'all')
128
+ {
129
+ // exclude page
130
+ }
131
+ else
132
+ {
133
+ $result[] = $post;
134
+ }
135
+
136
+ }
137
+ }
138
+ return $result;
139
+ }
140
+ else
141
+ {
142
+ return $posts;
143
+ }
144
+
145
+ }
146
+ }
147
+
148
+ /**
149
+ * Hook function to filter out hidden pages (get_pages)
150
+ * @param $posts
151
+ * @return unknown_type
152
+ */
153
+
154
+ public function exclude_low_profile_pages($posts)
155
+ {
156
+ p_l("called: wphp_exclude_low_profile_pages");
157
+ return $this->exclude_low_profile_items('page', $posts);
158
+ }
159
+
160
+ /**
161
+ *Remove item from rel post link
162
+ * @param $where
163
+ * @return unknown_type
164
+ *
165
+ */
166
+ public function query_posts_where_rel_exclude($where)
167
+ {
168
+ // filter posts on one of the three kinds of contexts: front, category, feed
169
+ $where .= ' AND ' . WPHP_TABLE_NAME . '.post_id IS NULL ';
170
+
171
+ //echo "\n<!-- WPHP: ".$where." -->\n";
172
+ return $where;
173
+ }
174
+
175
+ /**
176
+ *
177
+ * @param $where
178
+ * @return unknown_type
179
+ */
180
+ public function query_posts_where($where, $wp_query = null)
181
+ {
182
+
183
+ p_l("called: wphp_query_posts_where");
184
+
185
+ // filter posts on one of the three kinds of contexts: front, category, feed
186
+ if (wphp_is_applicable('post', $wp_query) && wphp_is_applicable('page', $wp_query))
187
+ {
188
+ // $where .= ' AND ' . WPHP_TABLE_NAME . '.post_id IS NULL ';
189
+ $where .= ' AND c.post_id IS NULL ';
190
+
191
+ }
192
+ //echo "\n<!-- WPHP: ".$where." -->\n";
193
+ return $where;
194
+ }
195
+
196
+ //add our custom variablein this filter so in query_posts_join wer will know that the Wp-query
197
+ // is being called from recent posts widget
198
+ public function widget_posts_args($posts_args)
199
+ {
200
+ // p_n("in widget_posts_args");
201
+ $posts_args['wphp_inside_recent_post_sidebar'] = 1;
202
+
203
+ return $posts_args;
204
+ }
205
+
206
+ private function get_exclude_join($params)
207
+ {
208
+
209
+ if (empty($params['table']))
210
+ {
211
+ $params['table'] = WP_POSTS_TABLE_NAME;
212
+ }
213
+ $params['wp_query'] = isset($params['wp_query']) ? $params['wp_query'] : null;
214
+ $params['from_rel_query'] = isset($params['from_rel_query']) ? $params['from_rel_query'] : null;
215
+ $join = "";
216
+ // $join .= ' -' . WPHP_TABLE_NAME . ' wphptbl ON ' . WP_POSTS_TABLE_NAME . ".ID = wphptbl.post_id and wphptbl.meta_key like '" . WPHP_META_VALUE_PREFIX . "%'";
217
+ //p_n($join);
218
+ //p_d(stripos( "JOIN " . WPHP_TABLE_NAME,$join),1);
219
+ $alias = "c";
220
+ if (stripos($join, "JOIN " . WPHP_TABLE_NAME) === false)
221
+ {
222
+ $join .= ' LEFT JOIN ' . WPHP_TABLE_NAME . " $alias ON " . $params['table'] . ".ID = " . $alias . ".post_id ";
223
+ }
224
+ $join .= " and " . $alias . ".meta_key like '" . WPHP_META_VALUE_PREFIX . "%' and (";
225
+ // filter posts
226
+ $can_display = null;
227
+ $keys = array();
228
+ $visibility_types_data['post'] = wp_hide_post()->pluginAdmin()->get_visibility_types('post');
229
+ $visibility_types_data['page'] = wp_hide_post()->pluginAdmin()->get_visibility_types('page');
230
+ $post_joins = array();
231
+
232
+ $args = $params;
233
+ $sidebar = wphp_is_post_sidebar($params['wp_query']);
234
+
235
+ foreach ($visibility_types_data as $post_type => $visibility_types)
236
+ {
237
+ if ($post_type == 'page')
238
+ {
239
+ $post_joins[$post_type][] = $params['table'] . '.' . "post_type='page'";
240
+
241
+ }
242
+ else
243
+ {
244
+ $post_joins[$post_type][] = $params['table'] . '.' . wphp_allowed_post_types(true);
245
+ }
246
+ if ($post_type == 'page' && is_search())
247
+ {
248
+ // $keys[] = '_wplp_page_search';
249
+ }
250
+ foreach ($visibility_types as $visibility_type => $detail)
251
+ {
252
+
253
+ if ($sidebar && $visibility_type != 'post_recent')
254
+ {
255
+ continue;
256
+ }
257
+ $condition = !empty($detail['condition']) ? $detail['condition'] : $visibility_type;
258
+ $callbacks = array();
259
+
260
+ if (!empty($detail['condition_callback']))
261
+ {
262
+ $callbacks[] = $detail['condition_callback'];
263
+ }
264
+ else
265
+ {
266
+ // p_n('wphp_is_' . $condition . "_" . $post_type);
267
+ $callbacks[] = 'wphp_is_' . $condition . "_" . $post_type;
268
+ }
269
+
270
+ foreach ($callbacks as $callback)
271
+ {
272
+ if ($callback)
273
+ {
274
+
275
+ if (is_callable($callback))
276
+ {
277
+
278
+ $ret = call_user_func_array($callback, array(($args)));
279
+
280
+ if ($ret)
281
+ {
282
+ $keys[] = sprintf('%1$s%2$s', WPHP_META_VALUE_PREFIX, $condition);
283
+ break;
284
+ }
285
+ }
286
+ }
287
+ }
288
+ }
289
+
290
+ if (!count($keys))
291
+ {
292
+
293
+ $post_joins[$post_type][] = sprintf($alias . '.meta_key not like "%1$s"', WPHP_META_VALUE_PREFIX);
294
+ }
295
+ else
296
+ {
297
+ $pre = "";
298
+
299
+ $post_joins[$post_type][] = sprintf("(" . $alias . '.meta_key in ( %1$s) %2$s)', "'" . implode("','", $keys) . "'", ' ' . $pre);
300
+
301
+ }
302
+
303
+ }
304
+ foreach ($post_joins as $post_type => $joins)
305
+ {
306
+ $post_joins[$post_type] = "( " . implode(" and ", $joins) . ")";
307
+ }
308
+
309
+ $join .= implode(" OR ", $post_joins) . ")";
310
+ //p_n($join);
311
+ return $join;
312
+ }
313
+ /**
314
+ *
315
+ * @param $join
316
+ * @return unknown_type
317
+ */
318
+ public function query_posts_join($join, &$wp_query)
319
+ {
320
+
321
+ if (isset($wp_query->query['wphp_inside_recent_post_sidebar']))
322
+ {
323
+ //p_n($wp_query);
324
+ }
325
+
326
+ // p_n("called: wphp_query_posts_join");
327
+ if (wphp_is_applicable('post', $wp_query) && wphp_is_applicable('page', $wp_query))
328
+ {
329
+
330
+ if (!$join)
331
+ {
332
+ $join = '';
333
+ }
334
+ $params = array('table' => WP_POSTS_TABLE_NAME, 'wp_query' => $wp_query);
335
+ $join .= $this->get_exclude_join($params);
336
+
337
+ }
338
+
339
+ return $join;
340
+ }
341
+
342
+ public function post_excluded_terms_join_rel($join)
343
+ {
344
+ // p_n("post_excluded_terms_join_rel");
345
+ //SELECT p.ID FROM scbposts AS p (join) WHERE p.post_date < '2016-07-25 12:58:19' AND p.post_type = 'post' AND ( p.post_status = 'publish' OR p.post_status = 'private' ) ORDER BY p.post_date DESC LIMIT 1
346
+ $params = array('table' => 'p', 'wp_query' => null, 'from_rel_query' => true);
347
+
348
+ $join .= ' LEFT JOIN ' . WPHP_TABLE_NAME . ' ON ' . $params['table'] . ".ID = " . WPHP_TABLE_NAME . ".post_id and " . WPHP_TABLE_NAME . ".meta_key ='" . WPHP_META_VALUE_PREFIX . "post_recent'";
349
+
350
+ return $join;
351
+ }
352
+ public function test_enable_allposts_everywhere($query)
353
+ {
354
+
355
+ // Only filter the main query on the front-end
356
+ if (is_admin() || !$query->is_main_query())
357
+ {
358
+ return;
359
+ }
360
+
361
+ global $wp;
362
+ $front = false;
363
+
364
+ // If the latest posts are showing on the home page
365
+ if ((is_home() && empty($wp->query_string)))
366
+ {
367
+ $front = true;
368
+ }
369
+
370
+ // If a static page is set as the home page
371
+ if (($query->get('page_id') == get_option('page_on_front') && get_option('page_on_front')) || empty($wp->query_string))
372
+ {
373
+ $front = true;
374
+ }
375
+
376
+ if ($front || is_archive())
377
+ {
378
+
379
+ $query->set('post_type', wphp_allowed_post_types());
380
+
381
+ }
382
+ //endif;
383
+ return $query;
384
+
385
+ }
386
+ }
public/css/plugin-name-public.css ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ /**
2
+ * All of the CSS for your public-facing functionality should be
3
+ * included in this file.
4
+ */
public/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden
public/js/wp-hide-post-public.js ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function( $ ) {
2
+ 'use strict';
3
+
4
+ /**
5
+ * All of the code for your public-facing JavaScript source
6
+ * should reside in this file.
7
+ *
8
+ * Note: It has been assumed you will write jQuery code here, so the
9
+ * $ function reference has been prepared for usage within the scope
10
+ * of this function.
11
+ *
12
+ * This enables you to define handlers, for when the DOM is ready:
13
+ *
14
+ * $(function() {
15
+ *
16
+ * });
17
+ *
18
+ * When the window is loaded:
19
+ *
20
+ * $( window ).load(function() {
21
+ *
22
+ * });
23
+ *
24
+ * ...and/or other possibilities.
25
+ *
26
+ * Ideally, it is not considered best practise to attach more than a
27
+ * single DOM-ready or window-load handler for a particular page.
28
+ * Although scripts in the WordPress core, Plugins and Themes may be
29
+ * practising this, we should strive to set a better example in our own work.
30
+ */
31
+
32
+ })( jQuery );
public/partials/wp-hide-post-public-display.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Provide a public-facing view for the plugin
5
+ *
6
+ * This file is used to markup the public-facing aspects of the plugin.
7
+ *
8
+ * @link http://scriptburn.com
9
+ * @since 2.0
10
+ *
11
+ * @package wp_hide_post
12
+ * @subpackage wp_hide_post/public/partials
13
+ */
14
+ ?>
15
+
readme.txt CHANGED
@@ -1,106 +1,200 @@
1
- === WP Hide Post ===
2
- Contributors: rmahfoud
3
- Donate link: http://www.konceptus.net/donate
4
- Tags: SEO,hide,show,visbility,privacy,customization,sitemap,filter
5
- Requires at least: 2.6
6
- Tested up to: 3.2
7
- Stable tag: 1.2.1
8
-
9
- Enables you to control the visibility of items on your blog by making posts/pages hidden on some parts of your blog, while still visible in other parts as well as to search engines. This plugin is the new incarnation of the 'WP low Profiler'. If this plugin already exists, it will be upgraded to this one, keeping all existing settings.
10
-
11
- == Description ==
12
-
13
- This plugin excels in giving you full control over the visibility of your a post. By default, any post you add to your WordPress blog will become the topmost post, and will show up immediately on the front page in the first position, and similarly in category/tag/archive pages. Sometimes, you want to create a "low-profile" addition to your blog that doesn't belong on the front page, or maybe you don't want it to show up anywhere else in your blog except when you explicitly link to it. This plugin allows you to create such "hidden gems".
14
-
15
- In particular, this plugin allows you to control the visibility of a **post** in various different views:
16
-
17
- * The Front Page (Homepage, depending on your theme, this may not be relevant)
18
- * The Category Page (listing the posts belonging to a category)
19
- * The Tag Page (listing the posts tagged with a given tag)
20
- * The Authors Page (listing the posts belonging to an author)
21
- * The Archive Pages (listing the posts belonging to time period: month, week, day, etc..)
22
- * The Search Results
23
- * Feeds
24
-
25
- The posts will disappear from the places you choose them to disappear. Everywhere else they will show up as regular posts. In particular, permalinks of the posts still work, and if you generate a sitemap, with something like the [Google XML Sitemaps](http://wordpress.org/extend/plugins/google-sitemap-generator/) the post will be there as well. This means that the content of your post will be indexed and searchable by search engines.
26
-
27
- For a WordPress **page**, this plugin also allows you to control the visibility with two options:
28
-
29
- * Hide a page on the front page (homepage) only.
30
- * Hide a page everywhere in the blog (hiding the page in the search results is optional).
31
-
32
- This means, technically, whenever pages are listed somewhere using the `get_pages` filter, this plugin will kick in and either filter it out or not according to the options you choose. The same rules apply regarding permalinks and sitemaps as they do for regular posts.
33
-
34
- "WP Hide Post" plugin is a great tool in your arsenal for SEO optimization. It allows you to add plenty of content to your blog, without forcing you to change the nature and presentation of your front page, for example. You can now create content that you otherwise would be reluctant to add to your blog because it would show immediately on the front page, or somewhere else where it would not belong. It's a must-have feature of WordPress.
35
-
36
- Please enjoy this plugin freely, comment and rate it profusely, and send me feedback and any ideas for new features.
37
-
38
- == Installation ==
39
-
40
- 1. Upload the `wp-hide-post` folder to the `/wp-content/plugins/` directory
41
- 1. Activate the plugin through the `Plugins` menu in WordPress
42
- 1. That's it!! Now whenever you edit a post/page or create a new one, you will see a small panel on the bottom right of the screen that shows the applicable options.
43
-
44
- == Frequently Asked Questions ==
45
-
46
- = What does this plugin do? =
47
-
48
- It enables you to create posts/pages that can be *hidden* (temporarily or permanently) from the homepage, feeds and/or other places. The post/page will remain accessible normally through other means, such as permalinks, archives, search, etc... and thus will remain visible to search engines.
49
-
50
- = How can I make a post or a page private so that no one can see it? =
51
-
52
- If you want to make a post/page completely private you don't need this plugin. WordPress supports options such as private and/or password-protected posts/pages out of the box.
53
-
54
- = Can I make a post or a page *hidden* for a while, but then make it normal again? =
55
-
56
- Yes. The *hidden* flags are just another set of attributes of a post/page. They can be added or removed at any time, just like editing anything else about the post.
57
-
58
- = I have an idea to improve this feature further, what can I do? =
59
-
60
- Please contact me on my blog [An Apple a Day](http://www.konceptus.net/wp-hide-post/). I'm looking forward to hearing any suggestions.
61
-
62
- = I just found something that doesn't look right, do I just sit on it? =
63
-
64
- By all means no! Please report any bugs on my blog [An Apple a Day](http://www.konceptus.net/wp-hide-post/). I'd really appreciate it. This is free software and I rely on the help of people like you to maintain it.
65
-
66
- = I'm worried this could reduce my search engine ranking. Is it gonna? =
67
-
68
- Not at all. On the contrary. All the content you include on your blog, even though it's not directly accessible from the homepage for example, it's still to be available when search engines crawl your site, and will remain linkable for those individuals that are interested in it. Furthermore, if you use some sitemap generation plugin (like the [Google XML Sitemaps](http://wordpress.org/extend/plugins/google-sitemap-generator/) plugin I use on my own [blog](http://www.konceptus.net/)) all the content will be published to web crawlers and will be picked up by search engines. In fact, this plugin will make your SEO more effective by allowing you to add content that you wouldn't otherwise want to show on your homepage.
69
-
70
- = I used the 'WP low Profiler' plugin before. This one sounds just like it. =
71
-
72
- This plugin is the new version of the 'WP low Profiler'. The name has been changed, but the functionality and codebase is identical. In fact, once you activate this plugin, it will upgrade the existing 'WP low Profiler' plugin and take its place. The last version of 'WP low Profiler', 2.0.3, corresponds to the first version of 'WP Hide Post', 1.0.3.
73
-
74
- = I already have 'WP low Profiler' installed and activated. What's going to happen to it? =
75
-
76
- 'WP Hide Post' will take the place of 'WP low Profiler'. Once 'WP Hide Post' is activated, 'WP low Profiler' is deactivated and deleted. All its data is imported first, so you won't loose any data.
77
-
78
- = I already have 'WP low Profiler' installed but it's not activated. What's going to happen to it? =
79
-
80
- Ditto. It will be deleted. If you had any existing data (if you had it active before) the data will persist.
81
-
82
- = Why did you change the name of 'WP low Profiler' 'to WP Hide Post'? =
83
-
84
- 'WP low Profiler' wasn't descriptive enough of the functionality of the plugin. Being 'low profile' could mean many things to many people. It was hard to find and many people who needed it didn't know it exists because of that.
85
-
86
- == Screenshots ==
87
-
88
- 1. Closup showing the *Visibility Attributes* for posts. [See Larger Version](http://www.konceptus.net/wp-content/uploads/screenshot-11.png)
89
- 2. A small panel will appear whenever you are editing or creating a **post**. You can check one or more of the *Visibility Attributes* as needed. [See Larger Version](http://www.konceptus.net/wp-content/uploads/screenshot-21.png)
90
- 3. Closup showing the *Visibility Attributes* for pages. [See Larger Version](http://www.konceptus.net/wp-content/uploads/screenshot-31.png)
91
- 4. Another panel will appear whenever you are editing or creating a new **page**. You can check one or more of the *Visibility Attributes* as needed. Note that options for pages are different from those of posts. [See Larger Version](http://www.konceptus.net/wp-content/uploads/screenshot-41.png)
92
-
93
- == Revision History ==
94
-
95
- * 01/02/2010: v1.1.9 - Compatibility with Wordpress 2.9
96
- * 10/24/2009: v1.1.4 - Added compatibility with Wordpress 2.8.5
97
- * 08/07/2009: v1.1.3 - Extended support for Wordpress 2.6
98
- * 08/07/2009: v1.1.2 - Bug fixes.
99
- * 08/05/2009: v1.1.1 - Reduce the number of SQL queries to hide pages to a single queries for all pages, rather than one query per page.
100
- * 08/04/2009: v1.1.0 - Bug fix: bulk update clears "Visibility Attributes". Split code into separate files.
101
- * 07/24/2009: v1.0.4 - Minor bug fixes
102
- * 07/24/2009: v1.0.3 - Initial public release of 'WP Hide Post' and deprecation of 'WP low Profiler'
103
-
104
- == Development Blog ==
105
-
106
- Please visit the plugin page at [An Apple a Day](http://www.konceptus.net/wp-hide-post/), and feel free to leave feedback, bug reports and comments.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === WP Hide Post ===
2
+ Contributors: scriptburn
3
+ Donate link: http://scriptburn.com/wp-hide-post/
4
+ Tags: SEO,hide,show,visbility,privacy,customization,sitemap,filter
5
+ Requires at least: 2.6
6
+ Tested up to: 4.8
7
+ Stable tag: 2.0.6
8
+ License: GPLv2
9
+
10
+ Control the visibility of items on your blog by making posts/pages hidden on some parts , while still visible in other parts and search engines.
11
+
12
+ == Description ==
13
+
14
+ This plugin excels in giving you full control over the visibility of your a post. By default, any post you add to your WordPress blog will become the topmost post, and will show up immediately on the front page in the first position, and similarly in category/tag/archive pages. Sometimes, you want to create a "low-profile" addition to your blog that doesn't belong on the front page, or maybe you don't want it to show up anywhere else in your blog except when you explicitly link to it. This plugin allows you to create such "hidden gems".
15
+
16
+ In particular, this plugin allows you to control the visibility of a **post** in various different views:
17
+
18
+ * The Front Page (Homepage, depending on your theme, this may not be relevant)
19
+ * The Category Page (listing the posts belonging to a category)
20
+ * The Tag Page (listing the posts tagged with a given tag)
21
+ * The Authors Page (listing the posts belonging to an author)
22
+ * The Archive Pages (listing the posts belonging to time period: month, week, day, etc..)
23
+ * The Search Results
24
+ * Feeds
25
+
26
+ The posts will disappear from the places you choose them to disappear. Everywhere else they will show up as regular posts. In particular, permalinks of the posts still work, and if you generate a sitemap, with something like the [Google XML Sitemaps](http://wordpress.org/extend/plugins/google-sitemap-generator/) the post will be there as well. This means that the content of your post will be indexed and searchable by search engines.
27
+
28
+ For a WordPress **page**, this plugin also allows you to control the visibility with two options:
29
+
30
+ * Hide a page on the front page (homepage) only.
31
+ * Hide a page everywhere in the blog (hiding the page in the search results is optional).
32
+
33
+ This means, technically, whenever pages are listed somewhere using the `get_pages` filter, this plugin will kick in and either filter it out or not according to the options you choose. The same rules apply regarding permalinks and sitemaps as they do for regular posts.
34
+
35
+ "WP Hide Post" plugin is a great tool in your arsenal for SEO optimization. It allows you to add plenty of content to your blog, without forcing you to change the nature and presentation of your front page, for example. You can now create content that you otherwise would be reluctant to add to your blog because it would show immediately on the front page, or somewhere else where it would not belong. It's a must-have feature of WordPress.
36
+
37
+ Please enjoy this plugin freely, comment and rate it profusely, and send me feedback and any ideas for new features.
38
+
39
+ == Installation ==
40
+
41
+ 1. Upload the `wp-hide-post` folder to the `/wp-content/plugins/` directory
42
+ 2. Activate the plugin through the `Plugins` menu in WordPress
43
+ 3. That's it!! Now whenever you edit a post/page or create a new one, you will see a small panel on the bottom right of the screen that shows the applicable options.
44
+
45
+ == Frequently Asked Questions ==
46
+
47
+ = What does this plugin do? =
48
+
49
+ It enables you to create posts/pages that can be *hidden* (temporarily or permanently) from the homepage, feeds and/or other places. The post/page will remain accessible normally through other means, such as permalinks, archives, search, etc... and thus will remain visible to search engines.
50
+
51
+ = How can I make a post or a page private so that no one can see it? =
52
+
53
+ If you want to make a post/page completely private you don't need this plugin. WordPress supports options such as private and/or password-protected posts/pages out of the box.
54
+
55
+ = Can I make a post or a page *hidden* for a while, but then make it normal again? =
56
+
57
+ Yes. The *hidden* flags are just another set of attributes of a post/page. They can be added or removed at any time, just like editing anything else about the post.
58
+
59
+ = I have an idea to improve this feature further, what can I do? =
60
+
61
+ Please contact me on my blog [ScriptBurn.com](http://scriptburn.com/wp-hide-post/). I'm looking forward to hearing any suggestions.
62
+
63
+ = I just found something that doesn't look right, do I just sit on it? =
64
+
65
+ By all means no! Please report any bugs on my blog [ScriptBurn.com](http://scriptburn.com/wp-hide-post/). I'd really appreciate it. This is free software and I rely on the help of people like you to maintain it.
66
+
67
+ = I'm worried this could reduce my search engine ranking. Is it gonna? =
68
+
69
+ Not at all. On the contrary. All the content you include on your blog, even though it's not directly accessible from the homepage for example, it's still to be available when search engines crawl your site, and will remain linkable for those individuals that are interested in it. Furthermore, if you use some sitemap generation plugin (like the [Google XML Sitemaps](http://wordpress.org/extend/plugins/google-sitemap-generator/) plugin I use on my own [ScriptBurn.com](http://scriptburn.com/)) all the content will be published to web crawlers and will be picked up by search engines. In fact, this plugin will make your SEO more effective by allowing you to add content that you wouldn't otherwise want to show on your homepage.
70
+
71
+ = I used the 'WP low Profiler' plugin before. This one sounds just like it. =
72
+
73
+ This plugin is the new version of the 'WP low Profiler'. The name has been changed, but the functionality and codebase is identical. In fact, once you activate this plugin, it will upgrade the existing 'WP low Profiler' plugin and take its place. The last version of 'WP low Profiler', 2.0.3, corresponds to the first version of 'WP Hide Post', 1.0.3.
74
+
75
+ = I already have 'WP low Profiler' installed and activated. What's going to happen to it? =
76
+
77
+ 'WP Hide Post' will take the place of 'WP low Profiler'. Once 'WP Hide Post' is activated, 'WP low Profiler' is deactivated and deleted. All its data is imported first, so you won't loose any data.
78
+
79
+ = I already have 'WP low Profiler' installed but it's not activated. What's going to happen to it? =
80
+
81
+ Ditto. It will be deleted. If you had any existing data (if you had it active before) the data will persist.
82
+
83
+ = Why did you change the name of 'WP low Profiler' 'to WP Hide Post'? =
84
+
85
+ 'WP low Profiler' wasn't descriptive enough of the functionality of the plugin. Being 'low profile' could mean many things to many people. It was hard to find and many people who needed it didn't know it exists because of that.
86
+
87
+ == Screenshots ==
88
+
89
+ 1. Closup showing the *Visibility Attributes* for posts. [See Larger Version](http://scriptburn.com/wp-content/uploads/wp-hide-post/screenshot-1.png)
90
+
91
+ 2. A small panel will appear whenever you are editing or creating a **normal post**. or *custom post* You can check one or more of the *Visibility Attributes* as needed. [See Larger Version](http://scriptburn.com/wp-content/uploads/wp-hide-post/screenshot-2.png)
92
+
93
+ 3. Another panel will appear whenever you click on *Quick Edit* in normal post or custom post list page. You can check one or more of the *Visibility Attributes* as needed. [See Larger Version](http://scriptburn.com/wp-content/uploads/wp-hide-post/screenshot-3.png)
94
+
95
+ 4. Another panel will appear whenever you use *Bulk Edit* in normal post or custom post list page. You can check one or more of the *Visibility Attributes* as needed and they will applied to selected posts. [See Larger Version](http://scriptburn.com/wp-content/uploads/wp-hide-post/screenshot-4.png)
96
+
97
+ 5. In normal post or custom post list page you can filter the posts acording to the hide option applied to them. You can also see all of the hide options applied to each post. [See Larger Version](http://scriptburn.com/wp-content/uploads/wp-hide-post/screenshot-5.png)
98
+
99
+ 6. Closup showing the *Visibility Attributes* for pages. [See Larger Version](http://scriptburn.com/wp-content/uploads/wp-hide-post/screenshot-6.png)
100
+
101
+ 7. Another panel will appear whenever you are editing or creating a new **page**. You can check one or more of the *Visibility Attributes* as needed. Note that options for pages are different from those of posts. [See Larger Version](http://scriptburn.com/wp-content/uploads/wp-hide-post/screenshot-7.png)
102
+
103
+ 8. Another panel will appear whenever you click on *Quick Edit* in **page** list. You can check one or more of the *Visibility Attributes* as needed. [See Larger Version](http://scriptburn.com/wp-content/uploads/wp-hide-post/screenshot-8.png)
104
+
105
+ 9. Another panel will appear whenever you use *Bulk Edit* **page** list. You can check one or more of the *Visibility Attributes* as needed and they will applied to selected pages. [See Larger Version](http://scriptburn.com/wp-content/uploads/wp-hide-post/screenshot-9.png)
106
+
107
+ 10. In list page you can filter the pages acording to the hide option applied to them. You can also see all of the hide options applied to each page. [See Larger Version](http://scriptburn.com/wp-content/uploads/wp-hide-post/screenshot-10.png)
108
+
109
+ 11. In **Settings->WP Hide Post** you can select custom post types where you hide post widget to appear. [See Larger Version](http://scriptburn.com/wp-content/uploads/wp-hide-post/screenshot-11.png)
110
+
111
+
112
+ == Changelog ==
113
+
114
+ = 2.0.6 =
115
+ *Release Date - 31 July 2017*
116
+
117
+ Fix: post was not hiding if the static page was selected as homepage
118
+ Fix: Compatibility with old version of PHP
119
+
120
+
121
+ = 2.0.5 =
122
+ *Release Date - 30 July 2017*
123
+
124
+ Fix: Compatibility with old version of PHP
125
+
126
+ = 2.0.4 =
127
+ *Release Date - 30 July 2017*
128
+
129
+ *Fix: An issue that prevented system info file download
130
+
131
+ = 2.0.3 =
132
+ *Release Date - 12 August 2016*
133
+
134
+ * Fixed "Check All" not working in Bulk edit page
135
+ * Added a function array_column for wordpress install which are running < PHP5.5.5
136
+
137
+ = 2.0.2 =
138
+ *Release Date - 12 August 2016*
139
+
140
+ * Fixed an issue which was displaying error when activating the plugin
141
+
142
+ = 2.0 =
143
+ *Release Date - 11 August 2016*
144
+
145
+ * Fix to include Blog page when Hide on the front page option is checked.
146
+ * Added Quick Edit option for post and page in post list page.
147
+ * Added Bulk Edit option for post and page in post list page.
148
+ * Added Search for hidden post option in post list page.
149
+ * Added a new column “Hidden On” in post list page.
150
+ * Added “Check all” Option in hide post widget to select all options at once in post or custom post type page.
151
+ * Added a setting option in setting page where you can select what on which post type you want to show hide post widget.
152
+ * Added a setting option in setting page where you can choose whether to show hide post widest in quick edit mode or not
153
+
154
+
155
+ = 1.1.9 =
156
+ *Release Date - 16 July 2015*
157
+
158
+ * Compatibility with Wordpress 4.2.2
159
+
160
+ = 1.1.4 =
161
+ *Release Date - 24 October 2009*
162
+
163
+ * Added compatibility with Wordpress 2.8.5
164
+
165
+ = 1.1.3 =
166
+ *Release Date - 07 August 2009*
167
+
168
+ * Extended support for Wordpress 2.6
169
+
170
+ = 1.1.2 =
171
+ *Release Date - 07 August 2009*
172
+
173
+ * Bug fixes.
174
+
175
+ = 1.1.1 =
176
+ *Release Date - 05 August 2009*
177
+
178
+ * Reduce the number of SQL queries to hide pages to a single queries for all pages, rather than one query per page.
179
+
180
+ = 1.1.0 =
181
+ *Release Date - 04 August 2009*
182
+
183
+ * Bug fix: bulk update clears "Visibility Attributes". Split code into separate files.
184
+
185
+ = 1.0.4 =
186
+ *Release Date - 24 July 2009*
187
+
188
+ = 1.0.3 =
189
+ *Release Date - 24 July 2009*
190
+
191
+ * Initial public release of 'WP Hide Post' and deprecation of 'WP low Profiler'
192
+
193
+
194
+ * Minor bug fixes
195
+ == Development Blog ==
196
+
197
+ Please visit the plugin page at [ScriptBurn.com](http://scriptburn.com/wp-hide-post/), and feel free to leave feedback, bug reports and comments.
198
+
199
+ == Upgrade Notice ==
200
+ n/a
screenshot-1.png CHANGED
Binary file
screenshot-10.png ADDED
Binary file
screenshot-11.png ADDED
Binary file
screenshot-2.png CHANGED
Binary file
screenshot-3.png CHANGED
Binary file
screenshot-4.png CHANGED
Binary file
screenshot-5.png ADDED
Binary file
screenshot-6.png ADDED
Binary file
screenshot-7.png ADDED
Binary file
screenshot-8.png ADDED
Binary file
screenshot-9.png ADDED
Binary file
uninstall.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Fired when the plugin is uninstalled.
5
+ *
6
+ * When populating this file, consider the following flow
7
+ * of control:
8
+ *
9
+ * - This method should be static
10
+ * - Check if the $_REQUEST content actually is the plugin name
11
+ * - Run an admin referrer check to make sure it goes through authentication
12
+ * - Verify the output of $_GET makes sense
13
+ * - Repeat with other user roles. Best directly by using the links/query string parameters.
14
+ * - Repeat things for multisite. Once for a single site in the network, once sitewide.
15
+ *
16
+ * This file may be updated more in future version of the Boilerplate; however, this is the
17
+ * general skeleton and outline for how the file should work.
18
+ *
19
+ * For more information, see the following discussion:
20
+ * https://github.com/tommcfarlin/WordPress-Plugin-Boilerplate/pull/123#issuecomment-28541913
21
+ *
22
+ * @link http://scriptburn.com
23
+ * @since 2.0
24
+ *
25
+ * @package wp_hide_post
26
+ */
27
+
28
+ // If uninstall not called from WordPress, then exit.
29
+ if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
30
+ exit;
31
+ }
upgrade.php DELETED
@@ -1,89 +0,0 @@
1
- <?php
2
- /* Copyright 2009 Robert Mahfoud (email : robert.mahfoud@gmail.com)
3
-
4
- This program is free software; you can redistribute it and/or modify
5
- it under the terms of the GNU General Public License as published by
6
- the Free Software Foundation; either version 2 of the License, or
7
- (at your option) any later version.
8
-
9
- This program is distributed in the hope that it will be useful,
10
- but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- GNU General Public License for more details.
13
-
14
- You should have received a copy of the GNU General Public License
15
- along with this program; if not, write to the Free Software
16
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
- */
18
-
19
-
20
- /**
21
- * Migrate to the new database schema and clean up old schema...
22
- * Should run only once in the lifetime of the plugin...
23
- * @return unknown_type
24
- */
25
- function wphp_migrate_db() {
26
- wphp_log("called: wphp_migrate_db");
27
- /* When I first released this plugin, I was young and crazy and didn't know about the postmeta table.
28
- * With time I became wiser and wiser and decided to migrate the implementation to rely on postmeta.
29
- * I hope it was not a bad idea...
30
- */
31
- global $wpdb;
32
- global $table_prefix;
33
- $dbname = $wpdb->get_var("SELECT database()");
34
- if( !$dbname )
35
- return;
36
- $legacy_table_name = "${table_prefix}lowprofiler_posts";
37
- $legacy_table_exists = $wpdb->get_var("SELECT COUNT(*) AS count FROM information_schema.tables WHERE table_schema = '$dbname' AND table_name = '$legacy_table_name';");
38
- if( $legacy_table_exists ) {
39
- wphp_log("Migrating legacy table...");
40
- // move everything to the postmeta table
41
- $existing = $wpdb->get_results("SELECT wplp_post_id, wplp_flag, wplp_value from $legacy_table_name", ARRAY_N);
42
- // scan them one by one and insert the corresponding fields in the postmeta table
43
- $count = 0;
44
- foreach($existing as $existing_array) {
45
- $wplp_post_id = $existing_array[0];
46
- $wplp_flag = $existing_array[1];
47
- $wplp_value = $existing_array[2];
48
- if( $wplp_flag == 'home' )
49
- $wplp_flag = 'front';
50
- if( $wplp_value == 'home' )
51
- $wplp_value = 'front';
52
- if( $wplp_flag != 'page' ) {
53
- $wpdb->query("INSERT INTO ".WPHP_TABLE_NAME."(post_id, meta_key, meta_value) VALUES($wplp_post_id, '_wplp_post_$wplp_flag', '1')");
54
- } else {
55
- $wpdb->query("INSERT INTO ".WPHP_TABLE_NAME."(post_id, meta_key, meta_value) VALUES($wplp_post_id, '_wplp_page_flags', $wplp_value)");
56
- }
57
- ++$count;
58
- }
59
- wphp_log("$count entries migrated from legacy table.");
60
- // delete the old table
61
- $wpdb->query("TRUNCATE TABLE $legacy_table_name");
62
- $wpdb->query("DROP TABLE $legacy_table_name");
63
- wphp_log("Legacy table deleted.");
64
- }
65
- }
66
-
67
-
68
- /**
69
- *
70
- * @return unknown_type
71
- */
72
- function wphp_remove_wp_low_profiler() {
73
- wphp_log("called: wphp_remove_wp_low_profiler");
74
- $plugin_list = get_plugins('/wp-low-profiler');
75
- if( isset($plugin_list['wp-low-profiler.php']) ) {
76
- wphp_log("The 'WP low Profiler' plugin is present. Cleaning it up...");
77
- $plugins = array('wp-low-profiler/wp-low-profiler.php');
78
- if( is_plugin_active('wp-low-profiler/wp-low-profiler.php') ) {
79
- wphp_log("The 'WP low Profiler' plugin is active. Deactivating...");
80
- deactivate_plugins($plugins, true); // silent deactivate
81
- }
82
- wphp_log("Deleting plugin 'WP low Profiler'...");
83
- delete_plugins($plugins, '');
84
- } else
85
- wphp_log("The 'WP low Profiler' plugin does not exist.");
86
-
87
- }
88
-
89
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wp-hide-post-api.php DELETED
@@ -1,21 +0,0 @@
1
- <?php
2
- /* Copyright 2009 Robert Mahfoud (email : robert.mahfoud@gmail.com)
3
-
4
- This program is free software; you can redistribute it and/or modify
5
- it under the terms of the GNU General Public License as published by
6
- the Free Software Foundation; either version 2 of the License, or
7
- (at your option) any later version.
8
-
9
- This program is distributed in the hope that it will be useful,
10
- but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- GNU General Public License for more details.
13
-
14
- You should have received a copy of the GNU General Public License
15
- along with this program; if not, write to the Free Software
16
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
- */
18
-
19
- require_once('./wp-hide-post.php');
20
-
21
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wp-hide-post.php CHANGED
@@ -1,546 +1,114 @@
1
- <?php
2
- /*
3
- Plugin Name: WP Hide Post
4
- Plugin URI: http://konceptus.net/wp-hide-post/
5
- Description: Enables a user to control the visibility of items on the blog by making posts and pages selectively hidden in different views throughout the blog, such as on the front page, category pages, search results, etc... The hidden item remains otherwise accessible directly using permalinks, and also visible to search engines as part of the sitemap (at least). This plugin enables new SEO possibilities for authors since it enables them to create new posts and pages without being forced to display them on their front and in feeds.
6
- Version: 1.2.0
7
- Author: scriptburn.com
8
- Author URI: http://www.scriptburn.com
9
- Text Domain: wp_hide_post
10
- */
11
-
12
- /* Copyright 2015 Robert Mahfoud (email : support@scriptburn.com)
13
-
14
- This program is free software; you can redistribute it and/or modify
15
- it under the terms of the GNU General Public License as published by
16
- the Free Software Foundation; either version 2 of the License, or
17
- (at your option) any later version.
18
-
19
- This program is distributed in the hope that it will be useful,
20
- but WITHOUT ANY WARRANTY; without even the implied warranty of
21
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
- GNU General Public License for more details.
23
-
24
- You should have received a copy of the GNU General Public License
25
- along with this program; if not, write to the Free Software
26
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27
- */
28
-
29
- /**
30
- *
31
- * @return unknown_type
32
- */
33
- function wphp_init() {
34
- global $table_prefix;
35
- if( !defined('WPHP_TABLE_NAME') )
36
- define('WPHP_TABLE_NAME', "${table_prefix}postmeta");
37
- if( !defined('WP_POSTS_TABLE_NAME') )
38
- define('WP_POSTS_TABLE_NAME', "${table_prefix}posts");
39
- if( !defined('WPHP_DEBUG') ) {
40
- define('WPHP_DEBUG', defined('WP_DEBUG') && WP_DEBUG ? 1 : 0);
41
- }
42
- }
43
- wphp_init();
44
-
45
- /**
46
- *
47
- * @param $msg
48
- * @return unknown_type
49
- */
50
- function wphp_log($msg) {
51
- if( defined('WPHP_DEBUG') && WPHP_DEBUG )
52
- error_log("WPHP-> $msg");
53
- }
54
-
55
- /**
56
- *
57
- * @return unknown_type
58
- */
59
- function wphp_is_front_page() {
60
- return is_front_page();
61
- }
62
-
63
- /**
64
- *
65
- * @return unknown_type
66
- */
67
- function wphp_is_feed() {
68
- return is_feed();
69
- }
70
-
71
- /**
72
- *
73
- * @return unknown_type
74
- */
75
- function wphp_is_category() {
76
- return !wphp_is_front_page() && !wphp_is_feed() && is_category();
77
- }
78
-
79
- /**
80
- *
81
- * @return unknown_type
82
- */
83
- function wphp_is_tag() {
84
- return !wphp_is_front_page() && !wphp_is_feed() && is_tag();
85
- }
86
-
87
- /**
88
- *
89
- * @return unknown_type
90
- */
91
- function wphp_is_author() {
92
- return !wphp_is_front_page() && !wphp_is_feed() && is_author();
93
- }
94
-
95
- /**
96
- *
97
- * @return unknown_type
98
- */
99
- function wphp_is_archive() {
100
- return !wphp_is_front_page() && !wphp_is_feed() && is_date();
101
- }
102
-
103
- /**
104
- *
105
- * @return unknown_type
106
- */
107
- function wphp_is_search() {
108
- return is_search();
109
- }
110
-
111
- /**
112
- *
113
- * @param $item_type
114
- * @return unknown_type
115
- */
116
- function wphp_is_applicable($item_type) {
117
- return !is_admin() && (($item_type == 'post' && !is_single()) || $item_type == 'page') ;
118
- }
119
-
120
-
121
- function _wphp_http_post($var, $default = null) {
122
- if( isset($_POST[$var]) )
123
- return $_POST[$var];
124
- else
125
- return $default;
126
- }
127
-
128
- /**
129
- * Creates Text Domain For Translations
130
- * @return unknown_type
131
- */
132
- function wphp_textdomain() {
133
- $plugin_dir = basename(dirname(__FILE__));
134
- load_plugin_textdomain('wp-hide-post', ABSPATH."/$plugin_dir", $plugin_dir);
135
- }
136
- add_action('init', 'wphp_textdomain');
137
-
138
- /**
139
- *
140
- * @param $item_type
141
- * @param $posts
142
- * @return unknown_type
143
- */
144
- function wphp_exclude_low_profile_items($item_type, $posts) {
145
- wphp_log("called: wphp_exclude_low_profile_items");
146
- if( $item_type != 'page' )
147
- return $posts; // regular posts & search results are filtered in wphp_query_posts_join
148
- else {
149
- if( wphp_is_applicable('page') ) {
150
- global $wpdb;
151
- // now loop over the pages, and exclude the ones with low profile in this context
152
- $result = array();
153
- $page_flags = $wpdb->get_results("SELECT post_id, meta_value FROM ".WPHP_TABLE_NAME." WHERE meta_key = '_wplp_page_flags'", OBJECT_K);
154
- if( $posts ) {
155
- foreach($posts as $post) {
156
- $check = isset($page_flags[ $post->ID ]) ? $page_flags[ $post->ID ]->meta_value : null;
157
- if( ($check == 'front' && wphp_is_front_page()) || $check == 'all') {
158
- // exclude page
159
- } else
160
- $result[] = $post;
161
- }
162
- }
163
- return $result;
164
- } else
165
- return $posts;
166
- }
167
- }
168
-
169
- /**
170
- * Hook function to filter out hidden pages (get_pages)
171
- * @param $posts
172
- * @return unknown_type
173
- */
174
- function wphp_exclude_low_profile_pages($posts) {
175
- wphp_log("called: wphp_exclude_low_profile_pages");
176
- return wphp_exclude_low_profile_items('page', $posts);
177
- }
178
- add_filter('get_pages', 'wphp_exclude_low_profile_pages');
179
-
180
- /**
181
- *
182
- * @param $where
183
- * @return unknown_type
184
- */
185
- function wphp_query_posts_where($where) {
186
- wphp_log("called: wphp_query_posts_where");
187
- // filter posts on one of the three kinds of contexts: front, category, feed
188
- if( wphp_is_applicable('post') && wphp_is_applicable('page') ) {
189
- $where .= ' AND wphptbl.post_id IS NULL ';
190
- }
191
- //echo "\n<!-- WPHP: ".$where." -->\n";
192
- return $where;
193
- }
194
- add_filter('posts_where_paged', 'wphp_query_posts_where');
195
-
196
- /**
197
- *
198
- * @param $join
199
- * @return unknown_type
200
- */
201
- function wphp_query_posts_join($join) {
202
- wphp_log("called: wphp_query_posts_join");
203
- if( wphp_is_applicable('post') && wphp_is_applicable('page')) {
204
- if( !$join )
205
- $join = '';
206
- $join .= ' LEFT JOIN '.WPHP_TABLE_NAME.' wphptbl ON '.WP_POSTS_TABLE_NAME.'.ID = wphptbl.post_id and wphptbl.meta_key like \'_wplp_%\'';
207
- // filter posts
208
- $join .= ' AND (('.WP_POSTS_TABLE_NAME.'.post_type = \'post\' ';
209
- if( wphp_is_front_page() )
210
- $join .= ' AND wphptbl.meta_key = \'_wplp_post_front\' ';
211
- elseif( wphp_is_category())
212
- $join .= ' AND wphptbl.meta_key = \'_wplp_post_category\' ';
213
- elseif( wphp_is_tag() )
214
- $join .= ' AND wphptbl.meta_key = \'_wplp_post_tag\' ';
215
- elseif( wphp_is_author() )
216
- $join .= ' AND wphptbl.meta_key = \'_wplp_post_author\' ';
217
- elseif( wphp_is_archive() )
218
- $join .= ' AND wphptbl.meta_key = \'_wplp_post_archive\' ';
219
- elseif( wphp_is_feed())
220
- $join .= ' AND wphptbl.meta_key = \'_wplp_post_feed\' ';
221
- elseif( wphp_is_search())
222
- $join .= ' AND wphptbl.meta_key = \'_wplp_post_search\' ';
223
- else
224
- $join .= ' AND wphptbl.meta_key not like \'_wplp_%\' ';
225
- $join .= ')';
226
- // pages
227
- $join .= ' OR ('.WP_POSTS_TABLE_NAME.'.post_type = \'page\' AND wphptbl.meta_key <> \'_wplp_page_flags\'';
228
- if( wphp_is_search())
229
- $join .= ' AND wphptbl.meta_key = \'_wplp_page_search\' ';
230
- else
231
- $join .= ' AND wphptbl.meta_key not like \'_wplp_%\' ';
232
- $join .= '))';
233
- }
234
- //echo "\n<!-- WPHP: ".$join." -->\n";
235
- return $join;
236
- }
237
- add_filter('posts_join_paged', 'wphp_query_posts_join');
238
-
239
-
240
- /*********************
241
- * ADMIN FUNCTIONS
242
- *********************/
243
-
244
-
245
- /**
246
- * Hook called when activating the plugin
247
- * @return unknown_type
248
- */
249
- function wphp_activate() {
250
- wphp_init();
251
- wphp_log("called: wphp_activate");
252
-
253
- require_once(dirname(__FILE__).'/upgrade.php');
254
- wphp_migrate_db();
255
- wphp_remove_wp_low_profiler();
256
- }
257
- add_action('activate_wp-hide-post/wp-hide-post.php', 'wphp_activate' );
258
- //register_activation_hook( __FILE__, 'wphp_activate' );
259
-
260
-
261
- /**
262
- * Hook to watch for the activation of 'WP low Profiler', and forbid it...
263
- * @return unknown_type
264
- */
265
- function wphp_activate_lowprofiler() {
266
- wphp_log("called: wphp_activate_lowprofiler");
267
- require_once(dirname(__FILE__).'/upgrade.php');
268
- wphp_migrate_db(); // in case any tables were created, clean them up
269
- wphp_remove_wp_low_profiler(); // remove the files of the plugin
270
-
271
- $msgbox = __("'WP low Profiler' has been deprecated and replaced by 'WP Hide Post' which you already have active! Activation failed and plugin files cleaned up.", 'wp-hide-post');
272
- $err1_sorry = __("Cannot install 'WP low Profiler' because of a conflict. Sorry for this inconvenience.", 'wp-hide-post');
273
- $err2_cleanup = __("The downloaded files were cleaned-up and no further action is required.", 'wp-hide-post');
274
- $err3_return = __("Return to plugins page...", 'wp-hide-post');
275
- $return_url = admin_url('plugins.php');
276
-
277
- $html = <<<HTML
278
- ${err1_sorry}<br />${err2_cleanup}<br /><a href="${$return_url}">${err3_return}</a>
279
- <script language="javascript">window.alert("${msgbox}");</script>
280
- HTML;
281
- // show the error page with the message...
282
- wp_die($html, 'WP low Profiler Activation Not Allowed', array( 'response' => '200') );
283
- }
284
- add_action('activate_wp-low-profiler/wp-low-profiler.php', 'wphp_activate_lowprofiler' );
285
-
286
- /**
287
- * @param $action_links
288
- * @param $plugin
289
- * @return unknown_type
290
- */
291
- function plugin_install_action_links_wp_lowprofiler($action_links, $plugin) {
292
- wphp_log("called: plugin_install_action_links_wp_lowprofiler");
293
- if( $plugin['name'] == 'WP low Profiler' ) {
294
- $alt = '<a href="' . admin_url('plugin-install.php?tab=plugin-information&amp;plugin=wp-hide-post&amp;TB_iframe=true&amp;width=600&amp;height=800') . '" class="thickbox onclick" title="WP Hide Post">' . __('Check "WP Hide Post"') . '</a>';
295
- $action_links = array(
296
- __('Deprecated'),
297
- $alt);
298
- }
299
- return $action_links;
300
- }
301
- add_filter('plugin_install_action_links', 'plugin_install_action_links_wp_lowprofiler', 10, 2);
302
-
303
- /**
304
- *
305
- * @param $id
306
- * @param $lp_flag
307
- * @param $lp_value
308
- * @return unknown_type
309
- */
310
- function wphp_update_visibility($id, $lp_flag, $lp_value) {
311
- wphp_log("called: wphp_update_visibility");
312
- global $wpdb;
313
- $item_type = get_post_type($id);
314
- if( ($item_type == 'post' && !$lp_value) || ($item_type == 'page' && ( ($lp_flag == '_wplp_page_flags' && $lp_value == 'none') || ($lp_flag == '_wplp_page_search' && !$lp_value) ) ) ) {
315
- wphp_unset_low_profile($item_type, $id, $lp_flag);
316
- } else {
317
- wphp_set_low_profile($item_type, $id, $lp_flag, $lp_value);
318
- }
319
- }
320
-
321
- /**
322
- *
323
- * @param $item_type
324
- * @param $id
325
- * @param $lp_flag
326
- * @return unknown_type
327
- */
328
- function wphp_unset_low_profile($item_type, $id, $lp_flag) {
329
- wphp_log("called: wphp_unset_low_profile");
330
- global $wpdb;
331
- // Delete the flag from the database table
332
- $wpdb->query("DELETE FROM ".WPHP_TABLE_NAME." WHERE post_id = $id AND meta_key = '$lp_flag'");
333
- }
334
-
335
- /**
336
- *
337
- * @param $item_type
338
- * @param $id
339
- * @param $lp_flag
340
- * @param $lp_value
341
- * @return unknown_type
342
- */
343
- function wphp_set_low_profile($item_type, $id, $lp_flag, $lp_value) {
344
- wphp_log("called: wphp_set_low_profile");
345
- global $wpdb;
346
- // Ensure No Duplicates!
347
- $check = $wpdb->get_var("SELECT count(*) FROM ".WPHP_TABLE_NAME." WHERE post_id = $id AND meta_key='$lp_flag'");
348
- if(!$check) {
349
- $wpdb->query("INSERT INTO ".WPHP_TABLE_NAME."(post_id, meta_key, meta_value) VALUES($id, '$lp_flag', '$lp_value')");
350
- } elseif( $item_type == 'page' && $lp_flag == "_wplp_page_flags" ) {
351
- $wpdb->query("UPDATE ".WPHP_TABLE_NAME." set meta_value = '$lp_value' WHERE post_id = $id and meta_key = '$lp_flag'");
352
- }
353
- }
354
-
355
- /**
356
- *
357
- * @return unknown_type
358
- */
359
- function wphp_add_post_edit_meta_box() {
360
- wphp_log("called: wphp_add_post_edit_meta_box");
361
- global $wp_version;
362
- if( ! $wp_version || $wp_version >= '2.7' ) {
363
- add_meta_box('hidepostdivpost', __('Post Visibility', 'wp-hide-post'), 'wphp_metabox_post_edit', 'post', 'side');
364
- add_meta_box('hidepostdivpage', __('Page Visibility', 'wp-hide-post'), 'wphp_metabox_page_edit', 'page', 'side');
365
- } else {
366
- add_meta_box('hidepostdivpost', __('Post Visibility', 'wp-hide-post'), 'wphp_metabox_post_edit', 'post');
367
- add_meta_box('hidepostdivpage', __('Page Visibility', 'wp-hide-post'), 'wphp_metabox_page_edit', 'page');
368
- }
369
-
370
- }
371
- add_action('admin_menu', 'wphp_add_post_edit_meta_box');
372
-
373
- /**
374
- *
375
- * @return unknown_type
376
- */
377
- function wphp_metabox_post_edit() {
378
- wphp_log("called: wphp_metabox_post_edit");
379
- global $wpdb;
380
-
381
- $id = isset($_GET['post']) ? intval($_GET['post']) : 0;
382
-
383
- $wplp_post_front = 0;
384
- $wplp_post_category = 0;
385
- $wplp_post_tag = 0;
386
- $wplp_post_author = 0;
387
- $wplp_post_archive = 0;
388
- $wplp_post_search = 0;
389
- $wplp_post_feed = 0;
390
-
391
- if($id > 0) {
392
- $flags = $wpdb->get_results("SELECT meta_key from ".WPHP_TABLE_NAME." where post_id = $id and meta_key like '_wplp_%'", ARRAY_N);
393
- if( $flags ) {
394
- foreach($flags as $flag_array) {
395
- $flag = $flag_array[0];
396
- // remove the leading _
397
- $flag = substr($flag, 1, strlen($flag)-1);
398
- ${$flag} = 1;
399
- }
400
- }
401
- }
402
- ?>
403
- <label for="wplp_post_front" class="selectit"><input type="checkbox" id="wplp_post_front" name="wplp_post_front" value="1"<?php checked($wplp_post_front, 1); ?>/>&nbsp;<?php _e('Hide on the front page.', 'wp-hide-post'); ?></label>
404
- <input type="hidden" name="old_wplp_post_front" value="<?php echo $wplp_post_front; ?>"/>
405
- <br />
406
- <label for="wplp_post_category" class="selectit"><input type="checkbox" id="wplp_post_category" name="wplp_post_category" value="1"<?php checked($wplp_post_category, 1); ?>/>&nbsp;<?php _e('Hide on category pages.', 'wp-hide-post'); ?></label>
407
- <input type="hidden" name="old_wplp_post_category" value="<?php echo $wplp_post_category; ?>"/>
408
- <br />
409
- <label for="wplp_post_tag" class="selectit"><input type="checkbox" id="wplp_post_tag" name="wplp_post_tag" value="1"<?php checked($wplp_post_tag, 1); ?>/>&nbsp;<?php _e('Hide on tag pages.', 'wp-hide-post'); ?></label>
410
- <input type="hidden" name="old_wplp_post_tag" value="<?php echo $wplp_post_tag; ?>"/>
411
- <br />
412
- <label for="wplp_post_author" class="selectit"><input type="checkbox" id="wplp_post_author" name="wplp_post_author" value="1"<?php checked($wplp_post_author, 1); ?>/>&nbsp;<?php _e('Hide on author pages.', 'wp-hide-post'); ?></label>
413
- <input type="hidden" name="old_wplp_post_author" value="<?php echo $wplp_post_author; ?>"/>
414
- <br />
415
- <label for="wplp_post_archive" class="selectit"><input type="checkbox" id="wplp_post_archive" name="wplp_post_archive" value="1"<?php checked($wplp_post_archive, 1); ?>/>&nbsp;<?php _e('Hide in date archives (month, day, year, etc...)', 'wp-hide-post'); ?></label>
416
- <input type="hidden" name="old_wplp_post_archive" value="<?php echo $wplp_post_archive; ?>"/>
417
- <br />
418
- <label for="wplp_post_search" class="selectit"><input type="checkbox" id="wplp_post_search" name="wplp_post_search" value="1"<?php checked($wplp_post_search, 1); ?>/>&nbsp;<?php _e('Hide in search results.', 'wp-hide-post'); ?></label>
419
- <input type="hidden" name="old_wplp_post_search" value="<?php echo $wplp_post_search; ?>"/>
420
- <br />
421
- <label for="wplp_post_feed" class="selectit"><input type="checkbox" id="wplp_post_feed" name="wplp_post_feed" value="1"<?php checked($wplp_post_feed, 1); ?>/>&nbsp;<?php _e('Hide in feeds.', 'wp-hide-post'); ?></label>
422
- <input type="hidden" name="old_wplp_post_feed" value="<?php echo $wplp_post_feed; ?>"/>
423
- <br />
424
- <div style="float:right;font-size: xx-small;"><a href="http://www.1apple1day.com/posts/wp-hide-post/#comments"><?php _e("Leave feedback and report bugs...", 'wp-hide-post'); ?></a></div>
425
- <br />
426
- <div style="float:right;font-size: xx-small;"><a href="http://wordpress.org/extend/plugins/wp-hide-post/"><?php _e("Give 'WP Hide Post' a good rating...", 'wp-hide-post'); ?></a></div>
427
- <br />
428
- <?php
429
- }
430
-
431
- /**
432
- *
433
- * @return unknown_type
434
- */
435
- function wphp_metabox_page_edit() {
436
- wphp_log("called: wphp_metabox_page_edit");
437
- global $wpdb;
438
-
439
- $id = isset($_GET['post']) ? intval($_GET['post']) : 0;
440
-
441
- $wplp_page = 'none';
442
- $wplp_page_search_show = 1;
443
-
444
- if($id > 0) {
445
- $flags = $wpdb->get_results("SELECT meta_value from ".WPHP_TABLE_NAME." where post_id = $id and meta_key = '_wplp_page_flags'", ARRAY_N);
446
- if( $flags )
447
- $wplp_page = $flags[0][0];
448
- $search = $wpdb->get_results("SELECT meta_value from ".WPHP_TABLE_NAME." where post_id = $id and meta_key = '_wplp_page_search'", ARRAY_N);
449
- if( $search )
450
- $wplp_page_search_show = ! $search[0][0];
451
- }
452
- ?>
453
- <input type="hidden" name="old_wplp_page" value="<?php echo $wplp_page; ?>"/>
454
- <label class="selectit"><input type="radio" id="wplp_page_none" name="wplp_page" value="none"<?php checked($wplp_page, 'none'); ?>/>&nbsp;<?php _e('Show normally everywhere.', 'wp-hide-post'); ?></label>
455
- <br />
456
- <br />
457
- <label class="selectit"><input type="radio" id="wplp_page_front" name="wplp_page" value="front"<?php checked($wplp_page, 'front'); ?>/>&nbsp;<?php _e('Hide when listing pages on the front page.', 'wp-hide-post'); ?></label>
458
- <br />
459
- <br />
460
- <label class="selectit"><input type="radio" id="wplp_page_all" name="wplp_page" value="all"<?php checked($wplp_page, 'all'); ?>/>&nbsp;<?php _e('Hide everywhere pages are listed.', 'wp-hide-post'); ?><sup>*</sup></label>
461
- <div style="height:18px;margin-left:20px">
462
- <div id="wplp_page_search_show_div">
463
- <label class="selectit"><input type="checkbox" id="wplp_page_search_show" name="wplp_page_search_show" value="1"<?php checked($wplp_page_search_show, 1); ?>/>&nbsp;<?php _e('Keep in search results.', 'wp-hide-post'); ?></label>
464
- <input type="hidden" name="old_wplp_page_search_show" value="<?php echo $wplp_page_search_show; ?>"/>
465
- </div>
466
- </div>
467
- <br />
468
- <div style="float:right;clear:both;font-size:x-small;">* Will still show up in sitemap.xml if you generate one automatically. See <a href="http://www.1apple1day.com/posts/wp-low-profiler/">details</a>.</div>
469
- <br />
470
- <br />
471
- <br />
472
- <div style="float:right;font-size: xx-small;"><a href="http://www.1apple1day.com/posts/wp-hide-post/#comments"><?php _e("Leave feedback and report bugs...", 'wp-hide-post'); ?></a></div>
473
- <br />
474
- <div style="float:right;clear:both;font-size:xx-small;"><a href="http://wordpress.org/extend/plugins/wp-hide-post/"><?php _e("Give 'WP Hide Post' a good rating...", 'wp-hide-post'); ?></a></div>
475
- <br />
476
- <script type="text/javascript">
477
- <!--
478
- // toggle the wplp_page_search_show checkbox
479
- var wplp_page_search_show_callback = function () {
480
- if(jQuery("#wplp_page_all").is(":checked"))
481
- jQuery("#wplp_page_search_show_div").show();
482
- else
483
- jQuery("#wplp_page_search_show_div").hide();
484
- };
485
- jQuery("#wplp_page_all").change(wplp_page_search_show_callback);
486
- jQuery("#wplp_page_front").change(wplp_page_search_show_callback);
487
- jQuery("#wplp_page_none").change(wplp_page_search_show_callback);
488
- jQuery(document).ready( wplp_page_search_show_callback );
489
- //-->
490
- </script>
491
- <?php
492
- }
493
-
494
- /**
495
- *
496
- * @param $id
497
- * @return unknown_type
498
- */
499
- function wphp_save_post($id) {
500
- wphp_log("called: wphp_save_post");
501
- $item_type = get_post_type($id);
502
- if( $item_type == 'post' ) {
503
- if( isset($_POST['old_wplp_post_front']) && _wphp_http_post('wplp_post_front', 0) != _wphp_http_post('old_wplp_post_front', 0) )
504
- wphp_update_visibility($id, '_wplp_post_front', _wphp_http_post('wplp_post_front', 0));
505
- if( isset($_POST['old_wplp_post_category']) && _wphp_http_post('wplp_post_category', 0) != _wphp_http_post('old_wplp_post_category', 0) )
506
- wphp_update_visibility($id, '_wplp_post_category', _wphp_http_post('wplp_post_category', 0));
507
- if( isset($_POST['old_wplp_post_tag']) && _wphp_http_post('wplp_post_tag', 0) != _wphp_http_post('old_wplp_post_tag', 0) )
508
- wphp_update_visibility($id, '_wplp_post_tag', _wphp_http_post('wplp_post_tag', 0));
509
- if( isset($_POST['old_wplp_post_author']) && _wphp_http_post('wplp_post_author', 0) != _wphp_http_post('old_wplp_post_author', 0) )
510
- wphp_update_visibility($id, '_wplp_post_author', _wphp_http_post('wplp_post_author', 0));
511
- if( isset($_POST['old_wplp_post_archive']) && _wphp_http_post('wplp_post_archive', 0) != _wphp_http_post('old_wplp_post_archive', 0) )
512
- wphp_update_visibility($id, '_wplp_post_archive', _wphp_http_post('wplp_post_archive', 0));
513
- if( isset($_POST['old_wplp_post_search']) && _wphp_http_post('wplp_post_search', 0) != _wphp_http_post('old_wplp_post_search', 0) )
514
- wphp_update_visibility($id, '_wplp_post_search', _wphp_http_post('wplp_post_search', 0));
515
- if( isset($_POST['old_wplp_post_feed']) && _wphp_http_post('wplp_post_feed', 0) != _wphp_http_post('old_wplp_post_feed', 0) )
516
- wphp_update_visibility($id, '_wplp_post_feed', _wphp_http_post('wplp_post_feed', 0));
517
- } elseif( $item_type == 'page' ) {
518
- if( isset($_POST['old_wplp_page']) ) {
519
- if( _wphp_http_post('wplp_page', 'none') != _wphp_http_post('old_wplp_page', 'none') ) {
520
- wphp_update_visibility($id, "_wplp_page_flags", _wphp_http_post('wplp_page', 'none'));
521
- }
522
- if( _wphp_http_post('wplp_page', 'none') == 'all' ) {
523
- if( isset($_POST['old_wplp_page_search_show']) && _wphp_http_post('wplp_page_search_show', 0) != _wphp_http_post('old_wplp_page_search_show', 0) )
524
- wphp_update_visibility($id, "_wplp_page_search", ! _wphp_http_post('wplp_page_search_show', 0));
525
- } else
526
- wphp_update_visibility($id, "_wplp_page_search", 0);
527
- }
528
- }
529
- }
530
- add_action('save_post', 'wphp_save_post');
531
-
532
- /**
533
- *
534
- * @param $post_id
535
- * @return unknown_type
536
- */
537
- function wphp_delete_post($post_id) {
538
- wphp_log("called: wphp_delete_post");
539
- global $wpdb;
540
- // Delete all post flags from the database table
541
- $wpdb->query("DELETE FROM ".WPHP_TABLE_NAME." WHERE post_id = $post_id and meta_key like '_wplp_%'");
542
- }
543
- add_action('delete_post', 'wphp_delete_post');
544
-
545
-
546
- ?>
1
+ <?php
2
+
3
+ /**
4
+ * The plugin bootstrap file
5
+ *
6
+ * This file is read by WordPress to generate the plugin information in the plugin
7
+ * admin area. This file also includes all of the dependencies used by the plugin,
8
+ * registers the activation and deactivation functions, and defines a function
9
+ * that starts the plugin.
10
+ *
11
+ * @link http://www.scriptburn.com
12
+ * @since 1.0.0
13
+ * @package wp_hide_post
14
+ *
15
+ * @wordpress-plugin
16
+ * Plugin Name: WP Hide Post
17
+ * Plugin URI: http://scriptburn.com/wp-hide-post
18
+ * Description: Control the visibility of items on your blog by making posts/pages hidden on some parts , while still visible in other parts and search engines.
19
+ * Version: 2.0.6
20
+ * Author: scriptburn.com
21
+ * Author URI: http://www.scriptburn.com
22
+ * License: GPL-2.0+
23
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
24
+ * Text Domain: wp_hide_post
25
+ * Domain Path: /languages
26
+ */
27
+
28
+ // If this file is called directly, abort.
29
+ if (!defined('WPINC'))
30
+ {
31
+ die;
32
+ }
33
+ global $table_prefix;
34
+ define('WPHP_VER', "2.0.6");
35
+ define('WPHP_DB_VER', "2");
36
+
37
+ define('WPHP_PLUGIN_DIR', __DIR__ . "/");
38
+ define('WPHP_PLUGIN_FILE',__FILE__);
39
+
40
+ define('WPHP_PLUGIN_URL',plugin_dir_url(WPHP_PLUGIN_FILE));
41
+
42
+
43
+ if (!defined('WPHP_TABLE_NAME'))
44
+ {
45
+ define('WPHP_TABLE_NAME', "${table_prefix}postmeta");
46
+ }
47
+
48
+ if (!defined('WP_POSTS_TABLE_NAME'))
49
+ {
50
+ define('WP_POSTS_TABLE_NAME', "${table_prefix}posts");
51
+ }
52
+
53
+ if (!defined('WPHP_DEBUG'))
54
+ {
55
+ define('WPHP_DEBUG', defined('WP_DEBUG') && WP_DEBUG ? 1 : 0);
56
+ }
57
+
58
+ if (!defined('WPHP_META_VALUE_PREFIX'))
59
+ {
60
+ define('WPHP_META_VALUE_PREFIX', '_wplp_');
61
+ }
62
+ if (!defined('WPHP_VISIBILITY_NAME'))
63
+ {
64
+ define('WPHP_VISIBILITY_NAME', 'wphp_visibility_type');
65
+ }
66
+
67
+ /**
68
+ * The code that runs during plugin activation.
69
+ * This action is documented in includes/class-wp-hide-post-activator.php
70
+ */
71
+ function activate_wp_hide_post()
72
+ {
73
+ require_once plugin_dir_path(__FILE__) . 'includes/class-wp-hide-post-activator.php';
74
+ $wphp = new wp_hide_post_Activator();
75
+ $wphp->activate();
76
+ }
77
+
78
+ /**
79
+ * The code that runs during plugin deactivation.
80
+ * This action is documented in includes/class-wp-hide-post-deactivator.php
81
+ */
82
+ function deactivate_wp_hide_post()
83
+ {
84
+ require_once plugin_dir_path(__FILE__) . 'includes/class-wp-hide-post-deactivator.php';
85
+ $wphp = new wp_hide_post_Deactivator();
86
+ $wphp->deactivate();
87
+ }
88
+
89
+ register_activation_hook(__FILE__, 'activate_wp_hide_post');
90
+ register_deactivation_hook(__FILE__, 'deactivate_wp_hide_post');
91
+
92
+ /**
93
+ * The core plugin class that is used to define internationalization,
94
+ * admin-specific hooks, and public-facing site hooks.
95
+ */
96
+ require plugin_dir_path(__FILE__) . 'includes/class-wp-hide-post.php';
97
+
98
+ /**
99
+ * Begins execution of the plugin.
100
+ *
101
+ * Since everything within the plugin is registered via hooks,
102
+ * then kicking off the plugin from this point in the file does
103
+ * not affect the page life cycle.
104
+ *
105
+ * @since 1.2.2
106
+ */
107
+ function run_wp_hide_post()
108
+ {
109
+
110
+ $plugin = wp_hide_post::getInstance() ;
111
+ $plugin->run();
112
+
113
+ }
114
+ run_wp_hide_post();