Version Description
Download this release
Release Info
Developer | rmahfoud |
Plugin | WP Hide Post |
Version | 1.2.1 |
Comparing to | |
See all releases |
Code changes from version 2.0.2 to 1.2.1
- .gitignore +0 -1
- admin/class-wp-hide-post-admin.php +0 -1065
- admin/conditions.php +0 -137
- admin/css/wp-hide-post-admin.css +0 -43
- admin/index.php +0 -1
- admin/js/wp-hide-post-admin.js +0 -242
- admin/license/LicenseItem.php +0 -648
- admin/license/LicenseManager.php +0 -56
- admin/license/autoload.php +0 -18
- admin/partials/metabox_page_edit-display.php +0 -38
- admin/partials/notice-display.php +0 -8
- admin/partials/quick-edit-display.php +0 -8
- admin/settings/assets/chosen-sprite.png +0 -0
- admin/settings/assets/chosen.jquery.min.js +0 -2
- admin/settings/assets/chosen.min.css +0 -3
- admin/settings/autoload.php +0 -38
- admin/settings/class_settings.php +0 -393
- admin/settings/class_settingsAPI.php +0 -644
- admin/settings/class_settingsAPICustom.php +0 -234
- includes/class-wp-hide-post-activator.php +0 -133
- includes/class-wp-hide-post-deactivator.php +0 -36
- includes/class-wp-hide-post-i18n.php +0 -47
- includes/class-wp-hide-post-loader.php +0 -137
- includes/class-wp-hide-post.php +0 -387
- includes/helpers.php +0 -261
- includes/index.php +0 -1
- index.php +0 -1
- public/class-wp-hide-post-public.php +0 -501
- public/css/plugin-name-public.css +0 -4
- public/index.php +0 -1
- public/js/wp-hide-post-public.js +0 -32
- public/partials/wp-hide-post-public-display.php +0 -16
- readme.txt +106 -177
- screenshot-1.png +0 -0
- screenshot-10.png +0 -0
- screenshot-11.png +0 -0
- screenshot-2.png +0 -0
- screenshot-3.png +0 -0
- screenshot-4.png +0 -0
- screenshot-5.png +0 -0
- screenshot-6.png +0 -0
- screenshot-7.png +0 -0
- screenshot-8.png +0 -0
- screenshot-9.png +0 -0
- uninstall.php +0 -31
- upgrade.php +89 -0
- wp-hide-post-api.php +21 -0
- wp-hide-post.php +546 -81
- languages/wp-hide-post.pot → wp-hide-post.pot +0 -0
.gitignore
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
ignore
|
|
admin/class-wp-hide-post-admin.php
DELETED
@@ -1,1065 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* The admin-specific functionality of the plugin.
|
5 |
-
*
|
6 |
-
* @link http://scriptburn.com
|
7 |
-
* @since 1.2.2
|
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 |
-
/**
|
58 |
-
* Initialize the class and set its properties.
|
59 |
-
*
|
60 |
-
* @since 1.2.2
|
61 |
-
* @param string $wp_hide_post The name of this plugin.
|
62 |
-
* @param string $version The version of this plugin.
|
63 |
-
*/
|
64 |
-
public function __construct($wp_hide_post, $version)
|
65 |
-
{
|
66 |
-
|
67 |
-
$this->wp_hide_post = $wp_hide_post;
|
68 |
-
$this->version = $version;
|
69 |
-
|
70 |
-
$this->post_types = wphp_get_setting('wphp_gen', 'wphp_post_types');
|
71 |
-
if (!is_array($this->post_types))
|
72 |
-
{
|
73 |
-
$this->post_types = ['post', 'page'];
|
74 |
-
}
|
75 |
-
|
76 |
-
return $this;
|
77 |
-
}
|
78 |
-
public function allowedPostTypes($post_type = null)
|
79 |
-
{
|
80 |
-
if (!is_null($post_type))
|
81 |
-
{
|
82 |
-
return in_array($post_type, $this->post_types);
|
83 |
-
}
|
84 |
-
return $this->post_types;
|
85 |
-
}
|
86 |
-
|
87 |
-
public function plugin_init()
|
88 |
-
{
|
89 |
-
$post_types = $this->list_custom_post_types();
|
90 |
-
|
91 |
-
foreach ($this->allowedPostTypes() as $post_type)
|
92 |
-
{
|
93 |
-
if ($post_type == 'page' || (!empty($post_types[$post_type]) && $post_types[$post_type]->hierarchical))
|
94 |
-
{
|
95 |
-
wp_hide_post()->get_loader()->add_action("manage_pages_custom_column", $this->plugin_admin, 'manage_posts_columns', 10);
|
96 |
-
|
97 |
-
}
|
98 |
-
else
|
99 |
-
{
|
100 |
-
wp_hide_post()->get_loader()->add_action("manage_{$post_type}_posts_columns", $this->plugin_admin, 'manage_posts_columns', 10);
|
101 |
-
wp_hide_post()->get_loader()->add_action("manage_edit-{$post_type}_columns", $this->plugin_admin, 'manage_posts_columns', 10);
|
102 |
-
}
|
103 |
-
|
104 |
-
}
|
105 |
-
}
|
106 |
-
/**
|
107 |
-
* Register the stylesheets for the admin area.
|
108 |
-
*
|
109 |
-
* @since 1.2.2
|
110 |
-
*/
|
111 |
-
public function enqueue_styles()
|
112 |
-
{
|
113 |
-
global $pagenow;
|
114 |
-
/**
|
115 |
-
* This function is provided for demonstration purposes only.
|
116 |
-
*
|
117 |
-
* An instance of this class should be passed to the run() function
|
118 |
-
* defined in wp_hide_post_Loader as all of the hooks are defined
|
119 |
-
* in that particular class.
|
120 |
-
*
|
121 |
-
* The wp_hide_post_Loader will then create the relationship
|
122 |
-
* between the defined hooks and the functions defined in this
|
123 |
-
* class.
|
124 |
-
*/
|
125 |
-
|
126 |
-
wp_enqueue_style($this->wp_hide_post, plugin_dir_url(__FILE__) . 'css/wp-hide-post-admin.css', array(), $this->version, 'all');
|
127 |
-
if ($pagenow == 'edit.php')
|
128 |
-
{
|
129 |
-
wp_enqueue_style('scb_settings', plugin_dir_url(__FILE__) . 'settings/assets/chosen.min.css');
|
130 |
-
}
|
131 |
-
|
132 |
-
}
|
133 |
-
|
134 |
-
/**
|
135 |
-
* Register the JavaScript for the admin area.
|
136 |
-
*
|
137 |
-
* @since 1.2.2
|
138 |
-
*/
|
139 |
-
public function enqueue_scripts()
|
140 |
-
{
|
141 |
-
global $wp_scripts, $pagenow;
|
142 |
-
|
143 |
-
/**
|
144 |
-
* This function is provided for demonstration purposes only.
|
145 |
-
*
|
146 |
-
* An instance of this class should be passed to the run() function
|
147 |
-
* defined in wp_hide_post_Loader as all of the hooks are defined
|
148 |
-
* in that particular class.
|
149 |
-
*
|
150 |
-
* The wp_hide_post_Loader will then create the relationship
|
151 |
-
* between the defined hooks and the functions defined in this
|
152 |
-
* class.
|
153 |
-
*/
|
154 |
-
wp_enqueue_script('jquery');
|
155 |
-
|
156 |
-
if (is_admin())
|
157 |
-
{
|
158 |
-
wp_enqueue_script('jquery-ui-dialog');
|
159 |
-
wp_enqueue_script('jquery-ui-tabs');
|
160 |
-
wp_enqueue_script('jquery-ui-progressbar');
|
161 |
-
wp_enqueue_script('jquery-ui-accordion');
|
162 |
-
wp_enqueue_script('jquery-ui-selectable');
|
163 |
-
wp_enqueue_script('jquery-ui-datepicker');
|
164 |
-
|
165 |
-
$ui = $wp_scripts->query('jquery-ui-core');
|
166 |
-
$protocol = is_ssl() ? 'https' : 'http';
|
167 |
-
$url = "$protocol://ajax.googleapis.com/ajax/libs/jqueryui/{$ui->ver}/themes/smoothness/jquery-ui.css";
|
168 |
-
|
169 |
-
wp_enqueue_style('jquery-ui-smoothness', $url, false, null);
|
170 |
-
}
|
171 |
-
wp_enqueue_script($this->wp_hide_post, plugin_dir_url(__FILE__) . 'js/wp-hide-post-admin.js', array('jquery'), $this->version, false);
|
172 |
-
if ($pagenow == 'edit.php')
|
173 |
-
{
|
174 |
-
wp_enqueue_script('scb_settings', plugin_dir_url(__FILE__) . 'settings/assets/chosen.jquery.min.js', array('jquery'));
|
175 |
-
}
|
176 |
-
|
177 |
-
}
|
178 |
-
|
179 |
-
/**
|
180 |
-
* Hook to watch for the activation of 'WP low Profiler', and forbid it...
|
181 |
-
* @return unknown_type
|
182 |
-
*/
|
183 |
-
public function activate_lowprofiler()
|
184 |
-
{
|
185 |
-
$wp_hide_post_Activator = new wp_hide_post_Activator();
|
186 |
-
p_l("called: wphp_activate_lowprofiler");
|
187 |
-
$wp_hide_post_Activator->migrate();
|
188 |
-
|
189 |
-
$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');
|
190 |
-
$err1_sorry = __("Cannot install 'WP low Profiler' because of a conflict. Sorry for this inconvenience.", 'wp-hide-post');
|
191 |
-
$err2_cleanup = __("The downloaded files were cleaned-up and no further action is required.", 'wp-hide-post');
|
192 |
-
$err3_return = __("Return to plugins page...", 'wp-hide-post');
|
193 |
-
$return_url = admin_url('plugins.php');
|
194 |
-
|
195 |
-
$html = <<<HTML
|
196 |
-
${err1_sorry}<br />${err2_cleanup}<br /><a href="${$return_url}">${err3_return}</a>
|
197 |
-
<script language="javascript">window.alert("${msgbox}");</script>
|
198 |
-
HTML;
|
199 |
-
// show the error page with the message...
|
200 |
-
wp_die($html, 'WP low Profiler Activation Not Allowed', array('response' => '200'));
|
201 |
-
}
|
202 |
-
|
203 |
-
/**
|
204 |
-
* @param $action_links
|
205 |
-
* @param $plugin
|
206 |
-
* @return unknown_type
|
207 |
-
*/
|
208 |
-
public function plugin_install_action_links_wp_lowprofiler($action_links, $plugin)
|
209 |
-
{
|
210 |
-
p_l("called: plugin_install_action_links_wp_lowprofiler");
|
211 |
-
if ($plugin['name'] == 'WP low Profiler')
|
212 |
-
{
|
213 |
-
$alt = '<a href="' . admin_url('plugin-install.php?tab=plugin-information&plugin=wp-hide-post&TB_iframe=true&width=600&height=800') . '" class="thickbox onclick" title="WP Hide Post">' . __('Check "WP Hide Post"') . '</a>';
|
214 |
-
$action_links = array(
|
215 |
-
__('Deprecated'),
|
216 |
-
$alt);
|
217 |
-
}
|
218 |
-
return $action_links;
|
219 |
-
}
|
220 |
-
|
221 |
-
/*
|
222 |
-
Return all allowed post visibility types
|
223 |
-
*/
|
224 |
-
public function get_post_visibility_types()
|
225 |
-
{
|
226 |
-
if ($this->post_visibility_types)
|
227 |
-
{
|
228 |
-
return $this->post_visibility_types;
|
229 |
-
}
|
230 |
-
$this->post_visibility_types = [
|
231 |
-
'post_front' =>
|
232 |
-
[
|
233 |
-
'label' => wphp_('Hide on the front page.'),
|
234 |
-
'short_label' => 'Front page',
|
235 |
-
'description' => '',
|
236 |
-
],
|
237 |
-
'post_category' =>
|
238 |
-
[
|
239 |
-
'label' => wphp_('Hide on category pages.'),
|
240 |
-
'short_label' => 'Category pages',
|
241 |
-
'description' => '',
|
242 |
-
],
|
243 |
-
'post_tag' =>
|
244 |
-
[
|
245 |
-
'label' => wphp_('Hide on tag pages.'),
|
246 |
-
'short_label' => 'Tag pages',
|
247 |
-
'description' => '',
|
248 |
-
|
249 |
-
],
|
250 |
-
'post_author' =>
|
251 |
-
[
|
252 |
-
'label' => wphp_('Hide on author pages.'),
|
253 |
-
'short_label' => 'Author pages',
|
254 |
-
'description' => '',
|
255 |
-
|
256 |
-
],
|
257 |
-
'post_archive' =>
|
258 |
-
[
|
259 |
-
'label' => wphp_('Hide in date archives (month, day, year, etc...) '),
|
260 |
-
'short_label' => 'Archives',
|
261 |
-
'description' => '',
|
262 |
-
|
263 |
-
],
|
264 |
-
'post_search' =>
|
265 |
-
[
|
266 |
-
'label' => wphp_('Hide in search results. '),
|
267 |
-
'short_label' => 'Search results',
|
268 |
-
'description' => '',
|
269 |
-
|
270 |
-
],
|
271 |
-
'post_feed' =>
|
272 |
-
[
|
273 |
-
'label' => wphp_('Hide in feeds.'),
|
274 |
-
'short_label' => 'Feeds',
|
275 |
-
'description' => '',
|
276 |
-
],
|
277 |
-
'post_rel' =>
|
278 |
-
[
|
279 |
-
'label' => wphp_('Remove from next previous rel link'),
|
280 |
-
'short_label' => 'Meta rel link',
|
281 |
-
'description' => 'Remove post from Meta rel link <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>In Single Post page</div>',
|
282 |
-
],
|
283 |
-
|
284 |
-
];
|
285 |
-
$this->post_visibility_types = apply_filters('wphp_post_visibility_types', $this->post_visibility_types);
|
286 |
-
|
287 |
-
return $this->post_visibility_types;
|
288 |
-
}
|
289 |
-
/*
|
290 |
-
Return all allowed post visibility types
|
291 |
-
*/
|
292 |
-
public function get_page_visibility_types()
|
293 |
-
{
|
294 |
-
if ($this->page_visibility_types)
|
295 |
-
{
|
296 |
-
return $this->page_visibility_types;
|
297 |
-
}
|
298 |
-
$this->page_visibility_types = [
|
299 |
-
|
300 |
-
'hide_frontpage' =>
|
301 |
-
[
|
302 |
-
'label' => wphp_('Hide when listing pages on the front page. '),
|
303 |
-
'short_label' => 'Front page',
|
304 |
-
'description' => '',
|
305 |
-
],
|
306 |
-
'hide_always' =>
|
307 |
-
[
|
308 |
-
'label' => wphp_('Hide everywhere pages are listed.'),
|
309 |
-
'short_label' => 'Always',
|
310 |
-
'description' => 'Will still show up in sitemap.xml if you generate one automatically',
|
311 |
-
|
312 |
-
],
|
313 |
-
'nohide_search' =>
|
314 |
-
[
|
315 |
-
'label' => wphp_('Hide everywhere but keep in search results.'),
|
316 |
-
'short_label' => 'Hide but keep in search',
|
317 |
-
'description' => 'Will still show up in sitemap.xml if you generate one automatically',
|
318 |
-
|
319 |
-
],
|
320 |
-
];
|
321 |
-
$this->page_visibility_types = apply_filters('wphp_page_visibility_types', $this->page_visibility_types);
|
322 |
-
|
323 |
-
return $this->page_visibility_types;
|
324 |
-
}
|
325 |
-
|
326 |
-
public function get_visibility_types($post_type)
|
327 |
-
{
|
328 |
-
if ($post_type == 'page')
|
329 |
-
{
|
330 |
-
return $this->get_page_visibility_types();
|
331 |
-
}
|
332 |
-
else
|
333 |
-
{
|
334 |
-
return $this->get_post_visibility_types();
|
335 |
-
|
336 |
-
}
|
337 |
-
}
|
338 |
-
|
339 |
-
private function save_visibility($post_type, $post_id, $is_bulk = false)
|
340 |
-
{
|
341 |
-
if (!$this->allowedPostTypes($post_type) || !current_user_can($post_type == 'page' ? 'edit_page' : 'edit_post', $post_id))
|
342 |
-
{
|
343 |
-
p_l(" save_visibility $post_type");
|
344 |
-
return;
|
345 |
-
}
|
346 |
-
p_l(" save_visibility bulk=" . ($is_bulk ? 1 : 0));
|
347 |
-
foreach ($_POST[WPHP_VISIBILITY_NAME . "_old"] as $index => $value)
|
348 |
-
{
|
349 |
-
if (empty($_POST[WPHP_VISIBILITY_NAME][$index]))
|
350 |
-
{
|
351 |
-
$_POST[WPHP_VISIBILITY_NAME][$index] = 0;
|
352 |
-
}
|
353 |
-
if ((int) $_POST[WPHP_VISIBILITY_NAME . "_old"][$index] != $_POST[WPHP_VISIBILITY_NAME][$index] || $is_bulk)
|
354 |
-
{
|
355 |
-
// p_l("$post_id,$index,".$_POST[WPHP_VISIBILITY_NAME][$index]);
|
356 |
-
$this->update_visibility(
|
357 |
-
$post_id,
|
358 |
-
$index,
|
359 |
-
(int) $_POST[WPHP_VISIBILITY_NAME][$index]
|
360 |
-
);
|
361 |
-
}
|
362 |
-
|
363 |
-
}
|
364 |
-
}
|
365 |
-
|
366 |
-
/**
|
367 |
-
*
|
368 |
-
* @param $id
|
369 |
-
* @return unknown_type
|
370 |
-
*/
|
371 |
-
public function save_post($id)
|
372 |
-
{
|
373 |
-
|
374 |
-
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
|
375 |
-
{
|
376 |
-
return $id;
|
377 |
-
}
|
378 |
-
$item_type = get_post_type($id);
|
379 |
-
|
380 |
-
if (empty($_POST["wphp_{$item_type}_edit_nonce"]) || !wp_verify_nonce($_POST["wphp_{$item_type}_edit_nonce"], "wphp_{$item_type}_edit_nonce"))
|
381 |
-
{
|
382 |
-
//p_l('no verify nonce ' . "wphp_{$item_type}_edit_nonce");
|
383 |
-
return $id;
|
384 |
-
}
|
385 |
-
|
386 |
-
p_l("called: wphp_save_post");
|
387 |
-
|
388 |
-
$this->save_visibility($item_type, $id);
|
389 |
-
}
|
390 |
-
|
391 |
-
public function save_bulk_edit_data()
|
392 |
-
{
|
393 |
-
//p_d($_POST);
|
394 |
-
$post_type = empty($_POST['post_type']) ? '' : $_POST['post_type'];
|
395 |
-
|
396 |
-
$post_ids = (isset($_POST['post_ids']) && !empty($_POST['post_ids'])) ? $_POST['post_ids'] : array();
|
397 |
-
|
398 |
-
if (empty($post_ids) || !is_array($post_ids))
|
399 |
-
{
|
400 |
-
die();
|
401 |
-
}
|
402 |
-
foreach ($post_ids as $post_id)
|
403 |
-
{
|
404 |
-
|
405 |
-
$this->save_visibility($post_type, $post_id, true);
|
406 |
-
}
|
407 |
-
die();
|
408 |
-
}
|
409 |
-
|
410 |
-
/**
|
411 |
-
*
|
412 |
-
* @param $id
|
413 |
-
* @param $lp_flag
|
414 |
-
* @param $lp_value
|
415 |
-
* @return unknown_type
|
416 |
-
*/
|
417 |
-
public function update_visibility($id, $lp_flag, $lp_value)
|
418 |
-
{
|
419 |
-
|
420 |
-
if ($lp_value)
|
421 |
-
{
|
422 |
-
update_post_meta($id, WPHP_META_VALUE_PREFIX . $lp_flag, $lp_value);
|
423 |
-
}
|
424 |
-
else
|
425 |
-
{
|
426 |
-
delete_post_meta($id, WPHP_META_VALUE_PREFIX . $lp_flag);
|
427 |
-
}
|
428 |
-
}
|
429 |
-
|
430 |
-
/**
|
431 |
-
*
|
432 |
-
* @param $item_type
|
433 |
-
* @param $id
|
434 |
-
* @param $lp_flag
|
435 |
-
* @return unknown_type
|
436 |
-
*/
|
437 |
-
public function unset_low_profile($item_type, $id, $lp_flag)
|
438 |
-
{
|
439 |
-
p_l("called: unset_low_profile");
|
440 |
-
global $wpdb;
|
441 |
-
// Delete the flag from the database table
|
442 |
-
$wpdb->query("DELETE FROM " . WPHP_TABLE_NAME . " WHERE post_id = $id AND meta_key = '$lp_flag'");
|
443 |
-
}
|
444 |
-
|
445 |
-
/**
|
446 |
-
*
|
447 |
-
* @param $item_type
|
448 |
-
* @param $id
|
449 |
-
* @param $lp_flag
|
450 |
-
* @param $lp_value
|
451 |
-
* @return unknown_type
|
452 |
-
*/
|
453 |
-
public function set_low_profile($item_type, $id, $lp_flag, $lp_value)
|
454 |
-
{
|
455 |
-
p_l("called: set_low_profile");
|
456 |
-
global $wpdb;
|
457 |
-
// Ensure No Duplicates!
|
458 |
-
update_post_meta($id, $lp_flag, $lp_value);
|
459 |
-
return;
|
460 |
-
$check = $wpdb->get_var("SELECT count(*) FROM " . WPHP_TABLE_NAME . " WHERE post_id = $id AND meta_key='$lp_flag'");
|
461 |
-
if (!$check)
|
462 |
-
{
|
463 |
-
$wpdb->query("INSERT INTO " . WPHP_TABLE_NAME . "(post_id, meta_key, meta_value) VALUES($id, '$lp_flag', '$lp_value')");
|
464 |
-
}
|
465 |
-
elseif ($item_type == 'page' && $lp_flag == WPHP_META_VALUE_PREFIX . "page_flags")
|
466 |
-
{
|
467 |
-
$wpdb->query("UPDATE " . WPHP_TABLE_NAME . " set meta_value = '$lp_value' WHERE post_id = $id and meta_key = '$lp_flag'");
|
468 |
-
}
|
469 |
-
}
|
470 |
-
/**
|
471 |
-
*
|
472 |
-
* @param $post_id
|
473 |
-
* @return unknown_type
|
474 |
-
*/
|
475 |
-
public function delete_post($post_id)
|
476 |
-
{
|
477 |
-
p_l("called: wphp_delete_post");
|
478 |
-
global $wpdb;
|
479 |
-
// Delete all post flags from the database table
|
480 |
-
$wpdb->query("DELETE FROM " . WPHP_TABLE_NAME . " WHERE post_id = $post_id and meta_key like '" . WPHP_META_VALUE_PREFIX . "%'");
|
481 |
-
}
|
482 |
-
|
483 |
-
// ad our metabox to page
|
484 |
-
public function add_meta_boxes($postType)
|
485 |
-
{
|
486 |
-
if (in_array($postType, $this->post_types))
|
487 |
-
{
|
488 |
-
$post_type = get_post_type_object($postType);
|
489 |
-
if ($post_type)
|
490 |
-
{
|
491 |
-
add_meta_box('hidepostdivpost', sprintf(wphp_('%1$s Visibility'), ucwords($post_type->labels->singular_name)), array($this, 'metabox_post_edit'), $postType);
|
492 |
-
}
|
493 |
-
}
|
494 |
-
elseif ($postType == 'page')
|
495 |
-
{
|
496 |
-
add_meta_box('hidepostdivpage', __('Page Visibility', 'wp-hide-post'), array($this, 'metabox_page_edit'), 'page');
|
497 |
-
}
|
498 |
-
}
|
499 |
-
|
500 |
-
// return the visibility options set for a page or post
|
501 |
-
|
502 |
-
public function get_visibility_type_values($post_type, $post_id)
|
503 |
-
{
|
504 |
-
global $wpdb;
|
505 |
-
$post_id = (int) $post_id;
|
506 |
-
|
507 |
-
if ($post_type == 'page')
|
508 |
-
{
|
509 |
-
$visibility_types = $this->get_page_visibility_types();
|
510 |
-
}
|
511 |
-
else
|
512 |
-
{
|
513 |
-
$visibility_types = $this->get_post_visibility_types();
|
514 |
-
}
|
515 |
-
if (!$post_id)
|
516 |
-
{
|
517 |
-
return $visibility_types;
|
518 |
-
}
|
519 |
-
|
520 |
-
//p_d("SELECT meta_key from " . WPHP_TABLE_NAME . " where post_id = $id and meta_key like '". WPHP_META_VALUE_PREFIX ."%'");
|
521 |
-
$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);
|
522 |
-
if ($flags)
|
523 |
-
{
|
524 |
-
foreach ($flags as $flag_array)
|
525 |
-
{
|
526 |
-
$flag = $flag_array[0];
|
527 |
-
// remove the prefix _wplp_
|
528 |
-
|
529 |
-
$flag = substr($flag, strlen(WPHP_META_VALUE_PREFIX));
|
530 |
-
|
531 |
-
if (isset($visibility_types[$flag]))
|
532 |
-
{
|
533 |
-
$visibility_types[$flag]['value'] = 1;
|
534 |
-
}
|
535 |
-
}
|
536 |
-
}
|
537 |
-
return $visibility_types;
|
538 |
-
}
|
539 |
-
/**
|
540 |
-
*
|
541 |
-
* @return unknown_type
|
542 |
-
*/
|
543 |
-
public function metabox_edit($post_id, $post_type, $meta_box = true)
|
544 |
-
{
|
545 |
-
p_l("called: metabox_edit $post_id, $post_type");
|
546 |
-
|
547 |
-
//wp_nonce_field(plugin_basename(__FILE__), "wphp_{$post_type}_edit_nonce");
|
548 |
-
|
549 |
-
$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") . '" />';
|
550 |
-
if ($post_type !== 'page')
|
551 |
-
{
|
552 |
-
$pre[] = '<script>(function($)
|
553 |
-
{
|
554 |
-
$(document).ready(function()
|
555 |
-
{
|
556 |
-
$("#wphp_checkall").change(function()
|
557 |
-
{
|
558 |
-
$(".wphp_multicheck").prop("checked", $(this).prop("checked"));
|
559 |
-
});
|
560 |
-
});
|
561 |
-
})(jQuery);</script>';
|
562 |
-
}
|
563 |
-
|
564 |
-
$pre[] = '<div style="padding:10px;background:#e5e5e5"> <label for="wphp_checkall" style="font-weight:bold" >
|
565 |
-
<input type="checkbox" id="wphp_checkall" />
|
566 |
-
|
567 |
-
Check All
|
568 |
-
|
569 |
-
</label>
|
570 |
-
</div>';
|
571 |
-
|
572 |
-
$tmpl = '<div style="padding:10px;padding-bottom:0px"> <label for="%1$s_new_%2$s" class="selectit">
|
573 |
-
<input type="checkbox" id="%1$s_new_%2$s" name="%1$s[%2$s]" value="%3$s" %4$s class="wphp_multicheck"/>
|
574 |
-
|
575 |
-
%5$s
|
576 |
-
|
577 |
-
</label>
|
578 |
-
%8$s
|
579 |
-
<input type="hidden" name="%1$s_old[%2$s]" value="%6$s"/>
|
580 |
-
<input type="hidden" name="%1$s_name[%2$s]" value="%7$s"/></div>';
|
581 |
-
|
582 |
-
$html = [];
|
583 |
-
$index = 0;
|
584 |
-
foreach ($this->get_visibility_type_values($post_type, $post_id) as $type => $detail)
|
585 |
-
{
|
586 |
-
$detail['value'] = empty($detail['value']) ? 0 : (int) $detail['value'];
|
587 |
-
|
588 |
-
$html[] = sprintf($tmpl,
|
589 |
-
WPHP_VISIBILITY_NAME,
|
590 |
-
$type,
|
591 |
-
1,
|
592 |
-
$detail['value'] ? 'checked' : '',
|
593 |
-
$detail['label'],
|
594 |
-
$detail['value'],
|
595 |
-
$type,
|
596 |
-
empty($detail['description']) ? '' : sprintf('<p style=" padding-left: 30px;" class="description">%1$s</p>', $detail['description'])
|
597 |
-
);
|
598 |
-
$index++;
|
599 |
-
}
|
600 |
-
return (implode("\n", $pre) . implode("", $html) . ($meta_box ? $this->defualt_info('widget') : ''));
|
601 |
-
|
602 |
-
}
|
603 |
-
|
604 |
-
public function metabox_post_edit($post)
|
605 |
-
{
|
606 |
-
echo ($this->metabox_edit($post->ID, $post->post_type));
|
607 |
-
}
|
608 |
-
public function metabox_page_edit($post)
|
609 |
-
{
|
610 |
-
echo ($this->metabox_edit($post->ID, $post->post_type));
|
611 |
-
}
|
612 |
-
|
613 |
-
public function list_custom_post_types()
|
614 |
-
{
|
615 |
-
|
616 |
-
$args = array(
|
617 |
-
'public' => true,
|
618 |
-
'_builtin' => true,
|
619 |
-
);
|
620 |
-
|
621 |
-
$output = 'objects'; // names or objects, note names is the default
|
622 |
-
$operator = 'or'; // 'and' or 'or'
|
623 |
-
|
624 |
-
$types = (array) get_post_types($args, $output, $operator);
|
625 |
-
unset($types['revision']);
|
626 |
-
unset($types['nav_menu_item']);
|
627 |
-
|
628 |
-
return empty($types) || !is_array($types) ? [] : $types;
|
629 |
-
|
630 |
-
}
|
631 |
-
public function create_post_type()
|
632 |
-
{
|
633 |
-
register_post_type('acme_product',
|
634 |
-
array(
|
635 |
-
'labels' => array(
|
636 |
-
'name' => __('Products'),
|
637 |
-
'singular_name' => __('Product'),
|
638 |
-
),
|
639 |
-
'public' => true,
|
640 |
-
'has_archive' => true,
|
641 |
-
)
|
642 |
-
);
|
643 |
-
|
644 |
-
register_post_type('acme_item',
|
645 |
-
array(
|
646 |
-
'labels' => array(
|
647 |
-
'name' => __('Items'),
|
648 |
-
'singular_name' => __('Item'),
|
649 |
-
),
|
650 |
-
'public' => true,
|
651 |
-
'has_archive' => true,
|
652 |
-
)
|
653 |
-
);
|
654 |
-
|
655 |
-
register_post_type('acme_test',
|
656 |
-
array(
|
657 |
-
'labels' => array(
|
658 |
-
'name' => __('Tests'),
|
659 |
-
'singular_name' => __('Test'),
|
660 |
-
),
|
661 |
-
'public' => true,
|
662 |
-
'has_archive' => true,
|
663 |
-
)
|
664 |
-
);
|
665 |
-
}
|
666 |
-
public function register_setting_page()
|
667 |
-
{
|
668 |
-
// p_d($this->list_custom_post_types());
|
669 |
-
$setting_obj = wp_hide_post()->settingManager();
|
670 |
-
wp_hide_post()->settingManager()->register_tab(['id' => 'wphp_gen', 'title' => 'General']);
|
671 |
-
$options = [];
|
672 |
-
foreach ((array) $this->list_custom_post_types() as $type => $detail)
|
673 |
-
{
|
674 |
-
$detail = (array) $detail;
|
675 |
-
|
676 |
-
$options[$type] = $detail['labels']->name;
|
677 |
-
}
|
678 |
-
|
679 |
-
wp_hide_post()->settingManager()->register_setting_field('wphp_gen', array(
|
680 |
-
array('name' => 'wphp_post_types',
|
681 |
-
'label' => wphp_('Allowed custom post types'),
|
682 |
-
'desc' => wphp_('Allow WP hide post widget in these custom post types'),
|
683 |
-
'type' => 'multi',
|
684 |
-
'options' => $options,
|
685 |
-
'placeholder' => 'Select custom post type',
|
686 |
-
),
|
687 |
-
array('name' => 'show_in_quickedit',
|
688 |
-
'label' => wphp_('Show in quick edit?'),
|
689 |
-
'desc' => wphp_('Allow WP hide post widget in quick edit?'),
|
690 |
-
'type' => 'yesno',
|
691 |
-
'default' => 1,
|
692 |
-
),
|
693 |
-
));
|
694 |
-
}
|
695 |
-
|
696 |
-
public function admin_menu()
|
697 |
-
{
|
698 |
-
$parent_slug = wp_hide_post()->get_wp_hide_post();
|
699 |
-
add_submenu_page('options-general.php', wphp_('WP Hide Post'), wphp_("WP Hide Post"), 'manage_options', $parent_slug . '_settings_api', array(wp_hide_post()->settingManager(), 'plugin_page'));
|
700 |
-
}
|
701 |
-
public function register_plugin($licenses)
|
702 |
-
{
|
703 |
-
$licenses[] = ['id' => wp_hide_post()->info('id'), 'type' => 'plugin', 'name' => wp_hide_post()->info('name'), 'label' => 'WP hide Post Plugin', 'file' => wp_hide_post()->info('basename')];
|
704 |
-
|
705 |
-
return $licenses;
|
706 |
-
}
|
707 |
-
public function admin_footer()
|
708 |
-
{
|
709 |
-
|
710 |
-
?>
|
711 |
-
<script>
|
712 |
-
var wphp_hide_on_data=[];
|
713 |
-
wphp_hide_on_data['visibility_name'] = '<?php echo (WPHP_VISIBILITY_NAME); ?>';
|
714 |
-
wphp_hide_on_data['visibility_types']=[]
|
715 |
-
<?php
|
716 |
-
|
717 |
-
foreach (['post', 'page'] as $post_type)
|
718 |
-
{
|
719 |
-
echo (" wphp_hide_on_data['visibility_types']['$post_type']=[];\n");
|
720 |
-
|
721 |
-
foreach ($this->get_visibility_types($post_type) as $visibility_type => $data)
|
722 |
-
{
|
723 |
-
echo (" wphp_hide_on_data['visibility_types']['$post_type']['$visibility_type']='" . (empty($data['value']) ? '0' : (int) $data) . "';\n");
|
724 |
-
}
|
725 |
-
}
|
726 |
-
?>
|
727 |
-
</script>
|
728 |
-
<?php
|
729 |
-
}
|
730 |
-
/* quick edit box */
|
731 |
-
// add our custom column to post list box show we can display where the post is hidden
|
732 |
-
public function manage_posts_columns($columns)
|
733 |
-
{
|
734 |
-
|
735 |
-
$columns['wphp_hide_on'] = 'Hidden On';
|
736 |
-
return $columns;
|
737 |
-
}
|
738 |
-
|
739 |
-
// display data of our custom column
|
740 |
-
public function render_custom_column_data($column, $post_id)
|
741 |
-
{
|
742 |
-
static $nonce_data;
|
743 |
-
if ($column != 'wphp_hide_on')
|
744 |
-
{
|
745 |
-
return;
|
746 |
-
}
|
747 |
-
$current_v = isset($_GET['wphp_hidden_on']) ? $_GET['wphp_hidden_on'] : [];
|
748 |
-
$current_v = is_array($current_v) ? $current_v : [$current_v];
|
749 |
-
$post_type = get_post_type($post_id);
|
750 |
-
|
751 |
-
// we will store nonce in this variable
|
752 |
-
// we will only fill this variable if this function is called first time
|
753 |
-
// only in first call this variable will have array data
|
754 |
-
$items = [];
|
755 |
-
if (!$nonce_data)
|
756 |
-
{
|
757 |
-
|
758 |
-
$nonce_data = [
|
759 |
-
'nonce_field' => "wphp_{$post_type}_edit_nonce",
|
760 |
-
'nonce_value' => wp_create_nonce("wphp_{$post_type}_edit_nonce"),
|
761 |
-
'visibility_name' => WPHP_VISIBILITY_NAME,
|
762 |
-
];
|
763 |
-
$nonce_data = sprintf('<input type="hidden" class="wphp_hide_on_data" value="%1$s" />', urlencode(json_encode($nonce_data)));
|
764 |
-
}
|
765 |
-
switch ($column)
|
766 |
-
{
|
767 |
-
case 'wphp_hide_on':
|
768 |
-
|
769 |
-
$values = $this->get_visibility_type_values($post_type, $post_id);
|
770 |
-
$data = [];
|
771 |
-
foreach ($values as $visibility_type => $item)
|
772 |
-
{
|
773 |
-
if (isset($item['value']))
|
774 |
-
{
|
775 |
-
if ($item['value'])
|
776 |
-
{
|
777 |
-
$items[$visibility_type] = sprintf('<span %1$s>%2$s</span>',
|
778 |
-
in_array($visibility_type, $current_v) ? 'class="visibility_item"' : '',
|
779 |
-
(isset($item['short_label']) ? $item['short_label'] : $visibility_type)
|
780 |
-
);
|
781 |
-
}
|
782 |
-
$data[$visibility_type] = empty($item['value']) ? 0 : (int) $item['value'];
|
783 |
-
}
|
784 |
-
}
|
785 |
-
$items = [implode(" , ", $items)];
|
786 |
-
|
787 |
-
$items[] = sprintf('<input type="hidden" class="wphp_hidden_on" value="%2$s" />', $post_id, urlencode(json_encode($data)));
|
788 |
-
|
789 |
-
$items[] = $nonce_data;
|
790 |
-
|
791 |
-
echo implode("\n", $items);
|
792 |
-
break;
|
793 |
-
}
|
794 |
-
|
795 |
-
}
|
796 |
-
|
797 |
-
//render our quick edit and bulk edit box
|
798 |
-
public function display_custom_quickedit($column_name, $post_type)
|
799 |
-
{
|
800 |
-
|
801 |
-
if ($column_name != 'wphp_hide_on')
|
802 |
-
{
|
803 |
-
|
804 |
-
return;
|
805 |
-
}
|
806 |
-
|
807 |
-
if (!wphp_get_setting('wphp_gen', 'show_in_quickedit'))
|
808 |
-
{
|
809 |
-
|
810 |
-
return;
|
811 |
-
}
|
812 |
-
|
813 |
-
if (!$this->allowedPostTypes($post_type))
|
814 |
-
{
|
815 |
-
|
816 |
-
return;
|
817 |
-
}
|
818 |
-
|
819 |
-
static $printNonce;
|
820 |
-
if (!$printNonce)
|
821 |
-
{
|
822 |
-
$pre[] = '<input type="hidden" id="wphp_' . $post_type . '_edit_nonce" name="wphp_' . $post_type . '_edit_nonce" value="" />';
|
823 |
-
}
|
824 |
-
|
825 |
-
$tmpl = '<div style="padding:10px;padding-bottom:0px"> <label for="%1$s_new_%2$s" class="selectit">
|
826 |
-
<input type="checkbox" id="%1$s_new_%2$s" name="%1$s[%2$s]" value="%3$s" %4$s class="wphp_multicheck"/>
|
827 |
-
|
828 |
-
%5$s
|
829 |
-
</label>%8$s
|
830 |
-
<input type="hidden" name="%1$s_old[%2$s]" value="%6$s"/>
|
831 |
-
<input type="hidden" name="%1$s_name[%2$s]" value="%7$s"/></div>';
|
832 |
-
|
833 |
-
$html = [];
|
834 |
-
$index = 0;
|
835 |
-
$allChecked = false;
|
836 |
-
$pre=[];
|
837 |
-
foreach ($this->get_visibility_types($post_type) as $type => $detail)
|
838 |
-
{
|
839 |
-
$detail['value'] = empty($detail['value']) ? 0 : (int) $detail['value'];
|
840 |
-
|
841 |
-
$html[] = sprintf($tmpl,
|
842 |
-
WPHP_VISIBILITY_NAME,
|
843 |
-
$type,
|
844 |
-
1,
|
845 |
-
$detail['value'] ? 'checked' : '',
|
846 |
-
$detail['label'],
|
847 |
-
$detail['value'],
|
848 |
-
$type,
|
849 |
-
empty($detail['description']) ? '' : sprintf('<p style=" padding-left: 30px;" class="description">%1$s</p>', $detail['description'])
|
850 |
-
);
|
851 |
-
$allChecked = $detail['value'];
|
852 |
-
$index++;
|
853 |
-
}
|
854 |
-
if ($post_type !== 'page')
|
855 |
-
{
|
856 |
-
$pre[] = '<script>(function($)
|
857 |
-
{
|
858 |
-
$(document).ready(function()
|
859 |
-
{
|
860 |
-
$("#wphp_checkall").change(function()
|
861 |
-
{
|
862 |
-
$(".wphp_multicheck").prop("checked", $(this).prop("checked"));
|
863 |
-
});
|
864 |
-
});
|
865 |
-
})(jQuery);</script>';
|
866 |
-
|
867 |
-
|
868 |
-
$pre[] = '<div style="padding:10px;background:#e5e5e5"> <label for="wphp_checkall" style="font-weight:bold" >
|
869 |
-
<input type="checkbox" id="wphp_checkall" ' . ($allChecked ? 'checked' : '') . ' />
|
870 |
-
|
871 |
-
Check All
|
872 |
-
|
873 |
-
</label>
|
874 |
-
</div>';
|
875 |
-
}
|
876 |
-
$post_type_obj = get_post_type_object($post_type);
|
877 |
-
|
878 |
-
$title = sprintf(wphp_('%1$s Visibility'), ucwords($post_type_obj->labels->singular_name));
|
879 |
-
$html = implode("\n", $pre) . implode("", $html);
|
880 |
-
require WPHP_PLUGIN_DIR . 'admin/partials/quick-edit-display.php';
|
881 |
-
|
882 |
-
}
|
883 |
-
|
884 |
-
// store the data in js var which will be used in click event of quick edit link
|
885 |
-
// and set the correct data in our quick edit box
|
886 |
-
public function post_row_actions_insert_data_as_js1($actions, $post)
|
887 |
-
{
|
888 |
-
static $js_var;
|
889 |
-
if (!$this->allowedPostTypes($post->post_type))
|
890 |
-
{
|
891 |
-
return;
|
892 |
-
}
|
893 |
-
$values = [];
|
894 |
-
if (!$js_var)
|
895 |
-
{
|
896 |
-
echo ("\n<script>\n var wphp_hide_on_data=[]; \n
|
897 |
-
wphp_hide_on_data['visibility_name']='" . WPHP_VISIBILITY_NAME . "';\n
|
898 |
-
wphp_hide_on_data['nonce_field']='" . "wphp_{$post->post_type}_edit_nonce" . "';\n
|
899 |
-
wphp_hide_on_data['nonce_value']='" . wp_create_nonce("wphp_{$post->post_type}_edit_nonce") . "';\n
|
900 |
-
wphp_hide_on_data['visibility_values']=[];\n
|
901 |
-
|
902 |
-
</script>\n");
|
903 |
-
$js_var = true;
|
904 |
-
}
|
905 |
-
foreach ($this->get_visibility_type_values($post->post_type, $post->ID) as $visibility_type => $detail)
|
906 |
-
{
|
907 |
-
if (isset($detail['value']))
|
908 |
-
{
|
909 |
-
$values[$visibility_type] = (int) $detail['value'];
|
910 |
-
}
|
911 |
-
}
|
912 |
-
|
913 |
-
if (count($values))
|
914 |
-
{
|
915 |
-
echo ("<script>\n
|
916 |
-
wphp_hide_on_data['visibility_values'][" . $post->ID . "]=JSON.parse('" . json_encode($values) . "');\n
|
917 |
-
</script>\n");
|
918 |
-
}
|
919 |
-
return $actions;
|
920 |
-
$nonce = wp_create_nonce('myfield_' . $post->ID);
|
921 |
-
$myfielvalue = get_post_meta($post->ID, 'myfield', true);
|
922 |
-
$actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="';
|
923 |
-
$actions['inline hide-if-no-js'] .= esc_attr(__('Edit this item inline')) . '"';
|
924 |
-
$actions['inline hide-if-no-js'] .= " onclick=\"set_wphp_hide_on_value('{$post->ID}')\" >";
|
925 |
-
$actions['inline hide-if-no-js'] .= __('Quick Edit1');
|
926 |
-
$actions['inline hide-if-no-js'] .= '</a>';
|
927 |
-
return $actions;
|
928 |
-
}
|
929 |
-
|
930 |
-
// add our custom filter selectbox in admin post list box
|
931 |
-
public function restrict_manage_posts()
|
932 |
-
{
|
933 |
-
|
934 |
-
$type = 'post';
|
935 |
-
if (isset($_GET['post_type']))
|
936 |
-
{
|
937 |
-
$type = $_GET['post_type'];
|
938 |
-
}
|
939 |
-
|
940 |
-
if (!$this->allowedPostTypes($type))
|
941 |
-
{
|
942 |
-
return;
|
943 |
-
}
|
944 |
-
$values = $this->get_visibility_types($type);
|
945 |
-
|
946 |
-
$values['all'] = ['short_label' => 'All Hidden'];
|
947 |
-
|
948 |
-
?>
|
949 |
-
<select name="wphp_hidden_on[]" class=" scb-sett-select-chosen chosen-select" multiple data-placeholder="Select Hidden option">
|
950 |
-
<?php
|
951 |
-
$current_v = isset($_GET['wphp_hidden_on']) ? $_GET['wphp_hidden_on'] : [];
|
952 |
-
$current_v = is_array($current_v) ? $current_v : [$current_v];
|
953 |
-
|
954 |
-
foreach ($values as $visibility_type => $item)
|
955 |
-
{
|
956 |
-
printf
|
957 |
-
(
|
958 |
-
'<option value="%1$s"%2$s >%3$s</option>',
|
959 |
-
$visibility_type,
|
960 |
-
in_array($visibility_type, $current_v) ? ' selected="selected"' : '',
|
961 |
-
isset($item['short_label']) ? $item['short_label'] : $visibility_type
|
962 |
-
);
|
963 |
-
}
|
964 |
-
?>
|
965 |
-
</select>
|
966 |
-
<?php
|
967 |
-
|
968 |
-
}
|
969 |
-
|
970 |
-
// Filter the posts acording to selected filter in post list select box
|
971 |
-
public function query_posts_join_custom_filter($join, &$wp_query)
|
972 |
-
{
|
973 |
-
|
974 |
-
global $wpdb, $pagenow;
|
975 |
-
|
976 |
-
$type = 'post';
|
977 |
-
if (isset($_GET['post_type']))
|
978 |
-
{
|
979 |
-
$type = $_GET['post_type'];
|
980 |
-
}
|
981 |
-
|
982 |
-
if (!$this->allowedPostTypes($type))
|
983 |
-
{
|
984 |
-
return;
|
985 |
-
}
|
986 |
-
|
987 |
-
if (!(is_admin() && $pagenow == 'edit.php' && isset($_GET['wphp_hidden_on']) && $_GET['wphp_hidden_on'] != ''))
|
988 |
-
{
|
989 |
-
return;
|
990 |
-
}
|
991 |
-
$current_v = isset($_GET['wphp_hidden_on']) ? $_GET['wphp_hidden_on'] : [];
|
992 |
-
$current_v = is_array($current_v) ? $current_v : [$current_v];
|
993 |
-
|
994 |
-
$join .= ' inner JOIN ' . WPHP_TABLE_NAME . ' wphptbl ON ' . WP_POSTS_TABLE_NAME . ".ID = wphptbl.post_id ";
|
995 |
-
|
996 |
-
if (in_array('all', $current_v))
|
997 |
-
{
|
998 |
-
$join .= sprintf(' AND wphptbl.meta_key like "%1$s%%"', WPHP_META_VALUE_PREFIX);
|
999 |
-
}
|
1000 |
-
else
|
1001 |
-
{
|
1002 |
-
|
1003 |
-
foreach ($current_v as $key => $v)
|
1004 |
-
{
|
1005 |
-
$current_v[$key] = esc_sql(WPHP_META_VALUE_PREFIX . $v);
|
1006 |
-
}
|
1007 |
-
$join .= " AND wphptbl.meta_key in ('" . implode("','", $current_v) . "') ";
|
1008 |
-
|
1009 |
-
}
|
1010 |
-
|
1011 |
-
return $join;
|
1012 |
-
|
1013 |
-
}
|
1014 |
-
public function defualt_info($page)
|
1015 |
-
{
|
1016 |
-
$info = get_transient('wphp_notices_' . $page);
|
1017 |
-
if (!$info)
|
1018 |
-
{
|
1019 |
-
|
1020 |
-
$response = wp_remote_get('http://scriptburn' . (wphp_is_demo() ? '.loc' : '.com') . "/wphp_info.php?page=" . $page);
|
1021 |
-
|
1022 |
-
if (is_array($response) && !empty($response['body']))
|
1023 |
-
{
|
1024 |
-
$info = $response['body'];
|
1025 |
-
set_transient('wphp_notices_' . $page, $info, 86400);
|
1026 |
-
}
|
1027 |
-
else
|
1028 |
-
{
|
1029 |
-
|
1030 |
-
$info = '<hr/>
|
1031 |
-
<div>
|
1032 |
-
<div style="float:left">
|
1033 |
-
<a href="http://scriptburn.com/wp-hide-post/#comments">
|
1034 |
-
%1$s
|
1035 |
-
</a>
|
1036 |
-
</div>
|
1037 |
-
<div style="float:right">
|
1038 |
-
<a href="http://wordpress.org/extend/plugins/wp-hide-post/">
|
1039 |
-
%2$s
|
1040 |
-
</a>
|
1041 |
-
</div>
|
1042 |
-
</div><div style="clear:both">
|
1043 |
-
<div style="text-align:center">
|
1044 |
-
<a href="http://konceptus.net/donate/">
|
1045 |
-
<img src="https://www.paypalobjects.com/webstatic/en_US/btn/btn_donate_pp_142x27.png"/>
|
1046 |
-
</a>
|
1047 |
-
</div>
|
1048 |
-
<div style="clear:both">
|
1049 |
-
</div>
|
1050 |
-
';
|
1051 |
-
return sprintf($info,
|
1052 |
-
wphp_("Leave feedback and report bugs..."),
|
1053 |
-
wphp_("Give 'WP Hide Post' a good rating...")
|
1054 |
-
);
|
1055 |
-
}
|
1056 |
-
}
|
1057 |
-
return $info;
|
1058 |
-
|
1059 |
-
}
|
1060 |
-
public function wsa_footer()
|
1061 |
-
{
|
1062 |
-
|
1063 |
-
echo $this->defualt_info('footer');
|
1064 |
-
}
|
1065 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/conditions.php
DELETED
@@ -1,137 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if (!function_exists('wphp_is_hide_frontpage_page'))
|
4 |
-
{
|
5 |
-
function wphp_is_hide_frontpage_page($join = null, $query = null)
|
6 |
-
{
|
7 |
-
global $wp;
|
8 |
-
$ret = false;
|
9 |
-
if (!is_null($query))
|
10 |
-
{
|
11 |
-
$ret = ($query->get('page_id') == get_option('page_on_front') && get_option('page_on_front')) || empty($wp->query_string);
|
12 |
-
}
|
13 |
-
return $ret || is_front_page();
|
14 |
-
}
|
15 |
-
}
|
16 |
-
if (!function_exists('wphp_is_hide_always_page'))
|
17 |
-
{
|
18 |
-
function wphp_is_hide_always_page()
|
19 |
-
{
|
20 |
-
|
21 |
-
return is_front_page() || is_feed() || is_category() || is_tag() || is_date() || is_search();
|
22 |
-
}
|
23 |
-
}
|
24 |
-
if (!function_exists('wphp_is_nohide_search_page'))
|
25 |
-
{
|
26 |
-
function wphp_is_nohide_search_page()
|
27 |
-
{
|
28 |
-
|
29 |
-
return (is_front_page() || is_feed() || is_category() || is_tag() || is_date()) && !is_search();
|
30 |
-
}
|
31 |
-
}
|
32 |
-
|
33 |
-
/**
|
34 |
-
*
|
35 |
-
* @return unknown_type
|
36 |
-
*/
|
37 |
-
if (!function_exists('wphp_is_post_front_post'))
|
38 |
-
{
|
39 |
-
function wphp_is_post_front_post()
|
40 |
-
{
|
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()
|
113 |
-
{
|
114 |
-
return is_search();
|
115 |
-
}
|
116 |
-
}
|
117 |
-
if (!function_exists('wphp_is_post_rel_post'))
|
118 |
-
{
|
119 |
-
function wphp_is_post_rel_post()
|
120 |
-
{
|
121 |
-
return is_single();
|
122 |
-
}
|
123 |
-
}
|
124 |
-
|
125 |
-
if (!function_exists('wphp_is_post_sidebar'))
|
126 |
-
{
|
127 |
-
function wphp_is_post_sidebar(&$join, &$wp_query)
|
128 |
-
{
|
129 |
-
|
130 |
-
if (property_exists($wp_query, 'query'))
|
131 |
-
{
|
132 |
-
return !empty($wp_query->query['wphp_inside_recent_post_sidebar']) && $wp_query->query['wphp_inside_recent_post_sidebar'];
|
133 |
-
}
|
134 |
-
return false;
|
135 |
-
|
136 |
-
}
|
137 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/css/wp-hide-post-admin.css
DELETED
@@ -1,43 +0,0 @@
|
|
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 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/index.php
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
<?php // Silence is golden
|
|
admin/js/wp-hide-post-admin.js
DELETED
@@ -1,242 +0,0 @@
|
|
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
DELETED
@@ -1,648 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class WPHP_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 |
-
public function __construct($store, $item_type, $item_name, $encrypter = null, $options = [])
|
19 |
-
{
|
20 |
-
$this->store = $store;
|
21 |
-
$this->item_name = $item_name;
|
22 |
-
$this->safe_item_name = strtolower(preg_replace("/[^\da-z][-]/i", '', $this->item_name));
|
23 |
-
$this->item_type = $item_type;
|
24 |
-
$this->random = $this->RandomString(4);
|
25 |
-
$this->encrypter = $encrypter;
|
26 |
-
$valid_items = array('plugin', 'module', 'theme');
|
27 |
-
$this->options = $options;
|
28 |
-
if (isset($this->options['license_folder']) && file_exists($this->options['license_folder']))
|
29 |
-
{
|
30 |
-
$this->license_file = $this->options['license_folder'] . "/" . (@$this->options['license_file'] ? $this->options['license_file'] : 'license');
|
31 |
-
}
|
32 |
-
|
33 |
-
if (!in_array($item_type, $valid_items))
|
34 |
-
{
|
35 |
-
if (!$is_custom)
|
36 |
-
{
|
37 |
-
throw new \Exception('Invalid item Type');
|
38 |
-
return false;
|
39 |
-
}
|
40 |
-
}
|
41 |
-
|
42 |
-
}
|
43 |
-
public function store_url()
|
44 |
-
{
|
45 |
-
return $this->store;
|
46 |
-
}
|
47 |
-
public function name()
|
48 |
-
{
|
49 |
-
return $this->item_name;
|
50 |
-
}
|
51 |
-
public function type()
|
52 |
-
{
|
53 |
-
return $this->item_type;
|
54 |
-
}
|
55 |
-
public static function add($store, $item_type, $item_name)
|
56 |
-
{
|
57 |
-
return new static($store, $item_type, $item_name);
|
58 |
-
}
|
59 |
-
public function RandomString($length)
|
60 |
-
{
|
61 |
-
$original_string = array_merge(range(0, 9), range('a', 'z'), range('A', 'Z'));
|
62 |
-
$original_string = implode("", $original_string);
|
63 |
-
return substr(str_shuffle($original_string), 0, $length);
|
64 |
-
}
|
65 |
-
public function prefix()
|
66 |
-
{
|
67 |
-
return "license." . $this->item_type . "_" . $this->safe_item_name . "_license_";
|
68 |
-
}
|
69 |
-
public function get_license_key()
|
70 |
-
{
|
71 |
-
if (isset($this->options['get_license_key']) && is_callable($this->options['get_license_key']))
|
72 |
-
{
|
73 |
-
return call_user_func($this->options['get_license_key'], ['this' => $this]);
|
74 |
-
}
|
75 |
-
|
76 |
-
$key_name = $this->prefix() . 'key';
|
77 |
-
return $this->read_license_data($key_name);
|
78 |
-
|
79 |
-
}
|
80 |
-
public function set_license_key($key)
|
81 |
-
{
|
82 |
-
if (isset($this->options['set_license_key']) && is_callable($this->options['set_license_key']))
|
83 |
-
{
|
84 |
-
return call_user_func($this->options['set_license_key'], ['this' => $this, 'key' => $key]);
|
85 |
-
}
|
86 |
-
|
87 |
-
$key_name = $this->prefix() . 'key';
|
88 |
-
$this->write_license_data($key_name, $key);
|
89 |
-
}
|
90 |
-
|
91 |
-
public function validate_license_file()
|
92 |
-
{
|
93 |
-
if (!$this->license_file)
|
94 |
-
{
|
95 |
-
|
96 |
-
throw new \Exception('unable to find license');
|
97 |
-
|
98 |
-
}
|
99 |
-
|
100 |
-
if (!file_exists($this->license_file))
|
101 |
-
{
|
102 |
-
$this->write_license_file('', [], $age = 0, false);
|
103 |
-
}
|
104 |
-
|
105 |
-
$cnt = file_get_contents($this->license_file);
|
106 |
-
|
107 |
-
if (!$cnt)
|
108 |
-
{
|
109 |
-
throw new \Exception('unable to read license');
|
110 |
-
}
|
111 |
-
if (substr($cnt, 0, 3) != 'SCB')
|
112 |
-
{
|
113 |
-
throw new \Exception('Invalid license file');
|
114 |
-
}
|
115 |
-
return substr($cnt, 3);
|
116 |
-
}
|
117 |
-
public function read_license_file($key)
|
118 |
-
{
|
119 |
-
$cnt = $this->validate_license_file();
|
120 |
-
|
121 |
-
$cnt = base64_decode($cnt);
|
122 |
-
|
123 |
-
$cnt = @unserialize($cnt);
|
124 |
-
|
125 |
-
if (!is_array($cnt))
|
126 |
-
{
|
127 |
-
throw new \Exception('Invalid license file data');
|
128 |
-
}
|
129 |
-
if (!(isset($cnt[$key])))
|
130 |
-
{
|
131 |
-
return false;
|
132 |
-
}
|
133 |
-
$key_data = $cnt[$key];
|
134 |
-
if (is_string($key_data['data']))
|
135 |
-
{
|
136 |
-
$key_data_1 = @json_decode($key_data['data']);
|
137 |
-
if ($key_data_1)
|
138 |
-
{
|
139 |
-
$key_data['data'] = $key_data_1;
|
140 |
-
}
|
141 |
-
}
|
142 |
-
if (is_string($key_data['data']))
|
143 |
-
{
|
144 |
-
$key_data_1 = @unserialize($key_data['data']);
|
145 |
-
if ($key_data_1)
|
146 |
-
{
|
147 |
-
$key_data['data'] = $key_data_1;
|
148 |
-
}
|
149 |
-
}
|
150 |
-
if (!(isset($key_data['expire']) && isset($key_data['data'])))
|
151 |
-
{
|
152 |
-
throw new \Exception('Invalid license file data (1)');
|
153 |
-
}
|
154 |
-
if ($key_data['expire'] != 0)
|
155 |
-
{
|
156 |
-
if (time() > $key_data['expire'])
|
157 |
-
{
|
158 |
-
unset($cnt[$key]);
|
159 |
-
return false;
|
160 |
-
}
|
161 |
-
}
|
162 |
-
return $key_data['data'];
|
163 |
-
}
|
164 |
-
|
165 |
-
public function write_license_file($key, $data, $age = 0, $validate = true)
|
166 |
-
{
|
167 |
-
$cnt = $validate ? $this->validate_license_file() : false;
|
168 |
-
|
169 |
-
$cnt = base64_decode($cnt);
|
170 |
-
$cnt = @json_decode($cnt);
|
171 |
-
if (!is_array($cnt))
|
172 |
-
{
|
173 |
-
$cnt = [];
|
174 |
-
}
|
175 |
-
if ($data === false && isset($cnt[$key]))
|
176 |
-
{
|
177 |
-
unset($cnt[$key]);
|
178 |
-
}
|
179 |
-
else
|
180 |
-
{
|
181 |
-
$cnt[$key] = ['expire' => $age != 0 ? time() + $age : 0, 'data' => $data];
|
182 |
-
}
|
183 |
-
$cnt = "SCB" . base64_encode(serialize($cnt));
|
184 |
-
|
185 |
-
file_put_contents($this->license_file, $cnt);
|
186 |
-
}
|
187 |
-
public function read_license_data($key = "")
|
188 |
-
{
|
189 |
-
|
190 |
-
if (isset($this->options['read_license_data']) && is_callable($this->options['read_license_data']))
|
191 |
-
{
|
192 |
-
return call_user_func($this->options['read_license_data'], ['key' => $key]);
|
193 |
-
}
|
194 |
-
elseif (isset($this->options['license_storage']) && $this->options['license_storage'] == 'file')
|
195 |
-
{
|
196 |
-
return $this->read_license_file($key);
|
197 |
-
}
|
198 |
-
else
|
199 |
-
{
|
200 |
-
return get_transient($key);
|
201 |
-
}
|
202 |
-
}
|
203 |
-
public function write_license_data($key, $data, $age = 0)
|
204 |
-
{
|
205 |
-
if (isset($this->options['write_license_data']) && is_callable($this->options['write_license_data']))
|
206 |
-
{
|
207 |
-
return call_user_func($this->options['write_license_data'], ['key' => $key, 'data' => $data, 'age' => $age]);
|
208 |
-
}
|
209 |
-
elseif (isset($this->options['license_storage']) && $this->options['license_storage'] == 'file')
|
210 |
-
{
|
211 |
-
return $this->write_license_file($key, $data, $age);
|
212 |
-
}
|
213 |
-
else
|
214 |
-
{
|
215 |
-
set_transient($key, $data, $age);
|
216 |
-
}
|
217 |
-
}
|
218 |
-
public function delete_license_data($key)
|
219 |
-
{
|
220 |
-
if (isset($this->options['delete_license_data']) && is_callable($this->options['delete_license_data']))
|
221 |
-
{
|
222 |
-
return call_user_func($this->options['delete_license_data'], ['key' => $key]);
|
223 |
-
}
|
224 |
-
elseif (isset($this->options['license_storage']) && $this->options['license_storage'] == 'file')
|
225 |
-
{
|
226 |
-
return $this->write_license_file($key, false);
|
227 |
-
}
|
228 |
-
else
|
229 |
-
{
|
230 |
-
delete_transient($data_name);
|
231 |
-
}
|
232 |
-
}
|
233 |
-
|
234 |
-
public function get_license_data($key = "")
|
235 |
-
{
|
236 |
-
|
237 |
-
$backtrace = debug_backtrace();
|
238 |
-
$calle = $backtrace[1]['function'];
|
239 |
-
$data_name = $this->prefix() . 'data';
|
240 |
-
|
241 |
-
if (!isset($this->license_data[$data_name]))
|
242 |
-
{
|
243 |
-
$data = $this->read_license_data($data_name);
|
244 |
-
if ($data === false || is_null($data))
|
245 |
-
{
|
246 |
-
$this->debug('license', __FUNCTION__ . "-" . __LINE__, 'not found data setting-' . $data_name . "-" . $calle);
|
247 |
-
|
248 |
-
}
|
249 |
-
|
250 |
-
if (($data === false || is_null($data)) && $_SERVER['REQUEST_METHOD'] == 'GET')
|
251 |
-
{
|
252 |
-
$this->debug('license', __FUNCTION__ . "-" . __LINE__, 'license ttl expired');
|
253 |
-
$this->check_license(true);
|
254 |
-
|
255 |
-
$data = $this->read_license_data($data_name);
|
256 |
-
//print_r($data);
|
257 |
-
// die('x');
|
258 |
-
}
|
259 |
-
|
260 |
-
/*
|
261 |
-
else
|
262 |
-
{
|
263 |
-
$data = $this->decodeIt($data);
|
264 |
-
$expires_in = (int) (@$data['expires_in']);
|
265 |
-
if ($expires_in <= time())
|
266 |
-
{
|
267 |
-
// $this->debug('license', __FUNCTION__ . "-" . __LINE__, 'license ttl expired cheating');
|
268 |
-
$this->check_license(true);
|
269 |
-
$data = get_transient($data_name);
|
270 |
-
|
271 |
-
}
|
272 |
-
}
|
273 |
-
*/
|
274 |
-
|
275 |
-
$this->license_data[$data_name] = is_array($data) ? $data : $this->decodeIt($data);
|
276 |
-
$this->debug('license', __FUNCTION__ . "-" . __LINE__, $this->license_data[$data_name]);
|
277 |
-
|
278 |
-
}
|
279 |
-
if ($key && isset($this->license_data[$data_name][$key]))
|
280 |
-
{
|
281 |
-
return $this->license_data[$data_name][$key];
|
282 |
-
}
|
283 |
-
else
|
284 |
-
{
|
285 |
-
return $this->license_data[$data_name];
|
286 |
-
}
|
287 |
-
|
288 |
-
}
|
289 |
-
|
290 |
-
public function set_license_data($data = "")
|
291 |
-
{
|
292 |
-
|
293 |
-
$data_name = $this->prefix() . 'data';
|
294 |
-
unset($this->license_data[$data_name]);
|
295 |
-
//$this->debug('license', __FUNCTION__ . "-" . __LINE__,$data_name );
|
296 |
-
if (!$data)
|
297 |
-
{
|
298 |
-
$this->delete_license_data($data_name);
|
299 |
-
return;
|
300 |
-
}
|
301 |
-
$this->write_license_data($data_name, $data, 60 * 60 * 24);
|
302 |
-
$this->debug('license', __FUNCTION__ . "-" . __LINE__, "$data_name--" . $data);
|
303 |
-
|
304 |
-
}
|
305 |
-
|
306 |
-
public function send_request($request, $method = "get")
|
307 |
-
{
|
308 |
-
|
309 |
-
if (!empty($_SESSION['license_request'][$this->item_name]['last']))
|
310 |
-
{
|
311 |
-
$time = (int) $_SESSION['license_request'][$request][$this->item_name]['last'];
|
312 |
-
if ($time - time() > 0)
|
313 |
-
{
|
314 |
-
throw new \Exception("Please Wait 10 secs to perform this opretion again ");
|
315 |
-
}
|
316 |
-
}
|
317 |
-
$_SESSION['license_request'][$request][$this->item_name]['last'] = time() + 10;
|
318 |
-
// $this->debug('license', __FUNCTION__ . "-" . __LINE__, $request);
|
319 |
-
//$this->debug('license', __FUNCTION__ . "-" . __LINE__, $plugin_data);
|
320 |
-
$api_params = array(
|
321 |
-
'edd_action' => $request,
|
322 |
-
'license' => trim($this->get_license_key()),
|
323 |
-
'item_name' => urlencode($this->item_name), // the name of our product in EDD
|
324 |
-
'url' => wphp_license_manager()->base_url(),
|
325 |
-
);
|
326 |
-
|
327 |
-
if ($method == 'get')
|
328 |
-
{
|
329 |
-
$api_params['rand'] = $this->RandomString(5);
|
330 |
-
$url = $this->store . "?" . http_build_query($api_params);
|
331 |
-
// p_d( $url );
|
332 |
-
//$this->debug('license', __FUNCTION__ . "-" . __LINE__, $url);
|
333 |
-
$response = wphp_license_manager()->sendGetRequest($url . http_build_query($api_params));
|
334 |
-
}
|
335 |
-
else
|
336 |
-
{
|
337 |
-
$url = $this->store;
|
338 |
-
$response = wphp_license_manager()->sendPostRequest($url, ['form_params' => $api_params, 'http_errors' => true]);
|
339 |
-
}
|
340 |
-
|
341 |
-
$backtrace = debug_backtrace();
|
342 |
-
$calle = $backtrace[1]['function'];
|
343 |
-
|
344 |
-
$this->debug('license', __FUNCTION__ . "-" . __LINE__ . "-" . __LINE__, $calle . "-" . $url);
|
345 |
-
if (!$response->status)
|
346 |
-
{
|
347 |
-
throw new \Exception('License Server communication error');
|
348 |
-
}
|
349 |
-
$license_data = (string) $response->body;
|
350 |
-
|
351 |
-
$check = '"' . $this->decode_signature;
|
352 |
-
if (substr($license_data, 0, strlen($check)) == $check)
|
353 |
-
{
|
354 |
-
$license_data = substr($license_data, 1);
|
355 |
-
if (substr($license_data, strlen($license_data) - 1) == '"')
|
356 |
-
{
|
357 |
-
$license_data = substr($license_data, 0, strlen($license_data) - 1);
|
358 |
-
}
|
359 |
-
}
|
360 |
-
elseif (!is_object(@json_decode($license_data)))
|
361 |
-
{
|
362 |
-
throw new \Exception('License checksum error');
|
363 |
-
}
|
364 |
-
|
365 |
-
// $this->debug('license', __FUNCTION__ . "-" . __LINE__ . "-" . __LINE__, "NoDecoded:" . print_r(($license_data), true));
|
366 |
-
|
367 |
-
//$this->debug('license', __FUNCTION__ . "-" . __LINE__ . "-" . __LINE__, "Decoded:" . print_r($this->decodeIt($license_data), true));
|
368 |
-
if (!$license_data)
|
369 |
-
{
|
370 |
-
throw new \Exception('License verification faile');
|
371 |
-
}
|
372 |
-
return $license_data;
|
373 |
-
|
374 |
-
}
|
375 |
-
public function activate_license()
|
376 |
-
{
|
377 |
-
|
378 |
-
$response = $this->send_request('activate_license');
|
379 |
-
|
380 |
-
if ($response)
|
381 |
-
{
|
382 |
-
$this->set_license_data($response);
|
383 |
-
return true;
|
384 |
-
}
|
385 |
-
|
386 |
-
return false;
|
387 |
-
|
388 |
-
}
|
389 |
-
public function deactivate_license()
|
390 |
-
{
|
391 |
-
|
392 |
-
$response = $this->send_request('deactivate_license');
|
393 |
-
if ($response)
|
394 |
-
{
|
395 |
-
$this->set_license_data($response);
|
396 |
-
return true;
|
397 |
-
}
|
398 |
-
|
399 |
-
return false;
|
400 |
-
}
|
401 |
-
public function check_license($fresh = false)
|
402 |
-
{
|
403 |
-
|
404 |
-
$backtrace = debug_backtrace();
|
405 |
-
$calle = $backtrace[1]['function'];
|
406 |
-
|
407 |
-
$this->debug('license', __FUNCTION__ . "-" . __LINE__ . "-" . __LINE__, $calle);
|
408 |
-
|
409 |
-
if ($fresh)
|
410 |
-
{
|
411 |
-
if (!$response = $this->send_request('check_license'))
|
412 |
-
{
|
413 |
-
return false;
|
414 |
-
}
|
415 |
-
}
|
416 |
-
else
|
417 |
-
{
|
418 |
-
return true;
|
419 |
-
}
|
420 |
-
$this->set_license_data($response);
|
421 |
-
return true;
|
422 |
-
}
|
423 |
-
|
424 |
-
public function getKey()
|
425 |
-
{
|
426 |
-
if ($this->key)
|
427 |
-
{
|
428 |
-
return $this->key;
|
429 |
-
}
|
430 |
-
$k = ["1234567890", "cc6042d5c823eb37ce499cf85083ca03"];
|
431 |
-
$keys = array();
|
432 |
-
|
433 |
-
if (!is_array($k))
|
434 |
-
{
|
435 |
-
$keys[] = $k;
|
436 |
-
}
|
437 |
-
else
|
438 |
-
{
|
439 |
-
$keys = $k;
|
440 |
-
}
|
441 |
-
|
442 |
-
$this->key = $keys;
|
443 |
-
return $this->key;
|
444 |
-
}
|
445 |
-
public function encodeIt($data)
|
446 |
-
{
|
447 |
-
$key = $this->getKey();
|
448 |
-
}
|
449 |
-
|
450 |
-
public function checkSignature(&$return)
|
451 |
-
{
|
452 |
-
if (is_object($return) || is_array($return))
|
453 |
-
{
|
454 |
-
//error_log(__LINE__ . "-checkSignature");
|
455 |
-
return false;
|
456 |
-
}
|
457 |
-
if (!is_string($return))
|
458 |
-
{
|
459 |
-
//error_log(__LINE__ . "-checkSignature");
|
460 |
-
|
461 |
-
return false;
|
462 |
-
}
|
463 |
-
$sig = substr(trim($return), 0, strlen($this->decode_signature));
|
464 |
-
//error_log(__LINE__ . "-checkSignature -" . ($sig . "!=" . $this->decode_signature));
|
465 |
-
|
466 |
-
if ($sig != $this->decode_signature)
|
467 |
-
{
|
468 |
-
$arr = json_decode($return, true);
|
469 |
-
if (is_array($arr))
|
470 |
-
{
|
471 |
-
//error_log(__LINE__ . "-checkSignature");
|
472 |
-
$return = $arr;
|
473 |
-
return false;
|
474 |
-
}
|
475 |
-
else
|
476 |
-
{
|
477 |
-
return false;
|
478 |
-
}
|
479 |
-
}
|
480 |
-
else
|
481 |
-
{
|
482 |
-
$part = substr($return, strlen($this->decode_signature));
|
483 |
-
|
484 |
-
$this->debug('license', __FUNCTION__ . "-" . __LINE__, "part $part");
|
485 |
-
|
486 |
-
$return = $part;
|
487 |
-
return true;
|
488 |
-
}
|
489 |
-
}
|
490 |
-
public function decodeIt($data)
|
491 |
-
{
|
492 |
-
$backtrace = debug_backtrace();
|
493 |
-
$calle = $backtrace[1]['function'];
|
494 |
-
$encryption = $this->encrypter;
|
495 |
-
$keys = $this->getKey();
|
496 |
-
$sig = $this->checkSignature($data);
|
497 |
-
$this->debug('license', __FUNCTION__ . "-" . __LINE__, "Called by $calle");
|
498 |
-
|
499 |
-
if (!$sig)
|
500 |
-
{
|
501 |
-
$this->debug('license', __FUNCTION__ . "-" . __LINE__, "Invalid sig");
|
502 |
-
|
503 |
-
return ($data);
|
504 |
-
}
|
505 |
-
//
|
506 |
-
|
507 |
-
$data = base64_decode($data);
|
508 |
-
$arr = unserialize($data);
|
509 |
-
|
510 |
-
if (!isset($arr['hash']) || !isset($arr['data']))
|
511 |
-
{
|
512 |
-
$this->debug('license', __FUNCTION__ . "-" . __LINE__, 'no hash');
|
513 |
-
//$this->debug('license', __FUNCTION__ . "-" . __LINE__, $arr);
|
514 |
-
return false;
|
515 |
-
}
|
516 |
-
$decrypted = "";
|
517 |
-
foreach ($keys as $key)
|
518 |
-
{
|
519 |
-
$decrypt = $encryption->decrypt(base64_decode($arr['data']), $key);
|
520 |
-
if ($this->item_name == 'scriptburn-whois')
|
521 |
-
{
|
522 |
-
// p_n($key );
|
523 |
-
// p_n($decrypt );
|
524 |
-
}
|
525 |
-
$this->debug('license', __FUNCTION__ . "-" . __LINE__, 'decoded ' . $decrypt);
|
526 |
-
|
527 |
-
if ($arr['hash'] === md5($decrypt))
|
528 |
-
{
|
529 |
-
$decrypted = $decrypt;
|
530 |
-
break;
|
531 |
-
}
|
532 |
-
}
|
533 |
-
if ($this->item_name == 'scriptburn-whois')
|
534 |
-
{
|
535 |
-
// p_d('x');
|
536 |
-
}
|
537 |
-
if (!$decrypted)
|
538 |
-
{
|
539 |
-
$this->debug('license', __FUNCTION__ . "-" . __LINE__, 'no md5 ');
|
540 |
-
return false;
|
541 |
-
}
|
542 |
-
|
543 |
-
$arr = @(@unserialize(@base64_decode($decrypted)));
|
544 |
-
//$this->debug('license', __FUNCTION__ . "-" . __LINE__, 'final');
|
545 |
-
//$this->debug('license', __FUNCTION__ . "-" . __LINE__, $arr);
|
546 |
-
|
547 |
-
if (!is_array($arr))
|
548 |
-
{
|
549 |
-
$this->debug('license', __FUNCTION__ . "-" . __LINE__, 'no array');
|
550 |
-
return false;
|
551 |
-
}
|
552 |
-
|
553 |
-
return $arr;
|
554 |
-
|
555 |
-
}
|
556 |
-
public function is_valid()
|
557 |
-
{
|
558 |
-
|
559 |
-
if ($this->get_license_data('license') == 'valid')
|
560 |
-
{
|
561 |
-
return true;
|
562 |
-
}
|
563 |
-
else
|
564 |
-
{
|
565 |
-
return false;
|
566 |
-
}
|
567 |
-
}
|
568 |
-
public function extendedInfo($data = "")
|
569 |
-
{
|
570 |
-
try
|
571 |
-
{
|
572 |
-
$arr['missing'] = "License Key does not exist";
|
573 |
-
$arr['license_not_activable'] = "Trying to activate bundle license for WP Movies";
|
574 |
-
$arr['revoked'] = "License key revoked ";
|
575 |
-
$arr['no_activations_left'] = "Maximum no of license activations used";
|
576 |
-
$arr['expired'] = "This license has expired for WP Movies";
|
577 |
-
$arr['key_mismatch'] = "License keys don't match ";
|
578 |
-
$arr['invalid_item_id'] = 'Invalid item Id ';
|
579 |
-
$arr['item_name_mismatch'] = "Item names don't match";
|
580 |
-
$arr['license_not_activable'] = "License can not be activated";
|
581 |
-
|
582 |
-
$arr_license['site_inactive'] = "License for this domain is not active";
|
583 |
-
$arr_license['disabled'] = " License key disabled";
|
584 |
-
$arr_license['inactive'] = "This license is not active";
|
585 |
-
|
586 |
-
$arr_license['disabled'] = " License key disabled";
|
587 |
-
$arr_license['valid'] = "License is active and valid";
|
588 |
-
$arr_license['invalid'] = "License is invalid";
|
589 |
-
|
590 |
-
$arr_license['expired'] = "License is Expired";
|
591 |
-
$arr_license['item_name_mismatch'] = "Item names don't match for this License";
|
592 |
-
$arr_license['invalid_item_id'] = "Invalid item Id for this License";
|
593 |
-
$arr_license['deactivated'] = "License has been deactivated ";
|
594 |
-
$arr_license['unknown'] = "Unknown license Status";
|
595 |
-
|
596 |
-
$data = $data ? $data : $this->get_license_data();
|
597 |
-
|
598 |
-
if (!(is_array($data) || is_object($data)))
|
599 |
-
{
|
600 |
-
$data = [];
|
601 |
-
}
|
602 |
-
if (is_object($data))
|
603 |
-
{
|
604 |
-
$data = (array) $data;
|
605 |
-
}
|
606 |
-
|
607 |
-
if (!isset($data['license']))
|
608 |
-
{
|
609 |
-
$data['license'] = 'unknown';
|
610 |
-
}
|
611 |
-
$data['license_info'] = isset($arr_license[$data['license']]) ? $arr_license[$data['license']] : $data['license'];
|
612 |
-
$data['error_info'] = isset($data['error']) ? isset($arr[$data['error']]) ? $arr[@$data['error']] : @$data['error'] : '';
|
613 |
-
|
614 |
-
$msg[] = isset($data['license']) ? (isset($arr_license[$data['license']]) ? $arr_license[$data['license']] : "Unknown license Status-{$data['license']} ") : "Unknown license Status";
|
615 |
-
$msg[] = isset($data['error']) ? (isset($arr_license[$data['error']]) ? $arr_license[$data['error']] : "Unknown license Error-{$data['error']} ") : "";
|
616 |
-
$data['message'] = $msg[0] ? $msg[0] . ($msg[1] ? " $msg[1]" : '') : ($msg[1] ? $msg[1] : '');
|
617 |
-
|
618 |
-
return $data;
|
619 |
-
|
620 |
-
}
|
621 |
-
catch (\Exception $e)
|
622 |
-
{
|
623 |
-
$data['license'] = 'unknown';
|
624 |
-
$data['license_info'] = isset($arr_license[$data['license']]) ? $arr_license[$data['license']] : $data['license'];
|
625 |
-
$data['message'] = $e->getMessage();
|
626 |
-
return $data;
|
627 |
-
}
|
628 |
-
}
|
629 |
-
public function debug($section, $name, $msg)
|
630 |
-
{
|
631 |
-
return;
|
632 |
-
if ($this->item_type != 'plugin')
|
633 |
-
{
|
634 |
-
// return;
|
635 |
-
}
|
636 |
-
static $first;
|
637 |
-
if (!$first)
|
638 |
-
{
|
639 |
-
$first = time();
|
640 |
-
p_l("$first=============debug started===================");
|
641 |
-
|
642 |
-
}
|
643 |
-
p_l("$first [Debug for [$section] item [$name]-> " . (is_array($msg) || is_object($msg) ? print_r($msg, true) : $msg) . "\n");
|
644 |
-
|
645 |
-
//file_put_contents(dirname(__FILE__)."/testlog.txt","[Debug for [$section] item [$name]-> " . (is_array($msg) || is_object($msg) ? print_r($msg, true) : $msg) . "\n");
|
646 |
-
}
|
647 |
-
|
648 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/license/LicenseManager.php
DELETED
@@ -1,56 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class WPHP_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 |
-
|
15 |
-
return self::$instance;
|
16 |
-
}
|
17 |
-
public function add($id, $store, $item_type, $item_name, $encrypter = null, $options = [])
|
18 |
-
{
|
19 |
-
if (isset($this->items[$id]))
|
20 |
-
{
|
21 |
-
return $this->items[$id];
|
22 |
-
}
|
23 |
-
$this->items[$id] = new WPHP_LicenseItem($store, $item_type, $item_name, $encrypter, $options);
|
24 |
-
return $this->items[$id];
|
25 |
-
}
|
26 |
-
public function items()
|
27 |
-
{
|
28 |
-
return $this->items;
|
29 |
-
}
|
30 |
-
public function item($id)
|
31 |
-
{
|
32 |
-
if (isset($this->items[$id]))
|
33 |
-
{
|
34 |
-
return $this->items[$id];
|
35 |
-
}
|
36 |
-
}
|
37 |
-
|
38 |
-
public function base_url()
|
39 |
-
{
|
40 |
-
return home_url();
|
41 |
-
}
|
42 |
-
public function sendGetRequest($url)
|
43 |
-
{
|
44 |
-
$response = wp_remote_get($url);
|
45 |
-
if (is_array($response))
|
46 |
-
{
|
47 |
-
|
48 |
-
return (object) ['status' => 1, 'body' => $response['body']];
|
49 |
-
}
|
50 |
-
else
|
51 |
-
{
|
52 |
-
return (object) ['status' => 1, 'message' => $response->get_error_message()];
|
53 |
-
|
54 |
-
}
|
55 |
-
}
|
56 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/license/autoload.php
DELETED
@@ -1,18 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
include_once __DIR__ . "/LicenseManager.php";
|
3 |
-
include_once __DIR__ . "/LicenseItem.php";
|
4 |
-
if (!function_exists('wphp_store_url'))
|
5 |
-
{
|
6 |
-
function wphp_store_url()
|
7 |
-
{
|
8 |
-
return "http://scriptburn.loc";
|
9 |
-
}
|
10 |
-
}
|
11 |
-
function wphp_license_manager()
|
12 |
-
{
|
13 |
-
return WPHP_LicenseManager::getInstance();
|
14 |
-
}
|
15 |
-
function wphp_get_license($item)
|
16 |
-
{
|
17 |
-
return wphp_license_manager()->item($item);
|
18 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/partials/metabox_page_edit-display.php
DELETED
@@ -1,38 +0,0 @@
|
|
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');?>/> <?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');?>/> <?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');?>/> <?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);?>/> <?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
DELETED
@@ -1,8 +0,0 @@
|
|
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
DELETED
@@ -1,8 +0,0 @@
|
|
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/settings/assets/chosen-sprite.png
DELETED
Binary file
|
admin/settings/assets/chosen.jquery.min.js
DELETED
@@ -1,2 +0,0 @@
|
|
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={"<":"<",">":">",'"':""","'":"'","`":"`"},c=/&(?!\w+;)|[\<\>\"\'\`]/g,a.replace(c,function(a){return b[a]||"&"})):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
DELETED
@@ -1,3 +0,0 @@
|
|
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
DELETED
@@ -1,38 +0,0 @@
|
|
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 |
-
|
20 |
-
if (!function_exists('wphp_get_default_setting'))
|
21 |
-
{
|
22 |
-
function wphp_get_default_setting($section = '', $name = "")
|
23 |
-
{
|
24 |
-
|
25 |
-
$default_general['max_upload_size'] = 200000;
|
26 |
-
|
27 |
-
$settings['general'] = $default_general;
|
28 |
-
|
29 |
-
$default = array();
|
30 |
-
|
31 |
-
foreach ($settings as $key => $setting)
|
32 |
-
{
|
33 |
-
$default = array_merge($default, $setting);
|
34 |
-
}
|
35 |
-
|
36 |
-
return $section ? ($name ? @$settings[$section][$name] : @$settings[$section]) : $default;
|
37 |
-
}
|
38 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/settings/class_settings.php
DELETED
@@ -1,393 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if (!class_exists('wphp_settings'))
|
4 |
-
{
|
5 |
-
class wphp_settings
|
6 |
-
{
|
7 |
-
private $pages, $settings_api, $asignment_fields = [], $license_fields = [], $asignment_section, $license_section, $tabs = []
|
8 |
-
|
9 |
-
, $settings = [];
|
10 |
-
private static $instance;
|
11 |
-
public $test;
|
12 |
-
public static function instance()
|
13 |
-
{
|
14 |
-
if (!self::$instance)
|
15 |
-
{
|
16 |
-
self::$instance = new wphp_settings();
|
17 |
-
|
18 |
-
}
|
19 |
-
return self::$instance;
|
20 |
-
}
|
21 |
-
public function __construct()
|
22 |
-
{
|
23 |
-
$this->setup();
|
24 |
-
}
|
25 |
-
public function api()
|
26 |
-
{
|
27 |
-
return $this->settings_api;
|
28 |
-
}
|
29 |
-
public function setup()
|
30 |
-
{
|
31 |
-
$this->settings_api = new wphp_settingsAPICustom();
|
32 |
-
add_action('init', array($this, 'init'));
|
33 |
-
|
34 |
-
add_action('admin_init', array($this, 'admin_init'));
|
35 |
-
|
36 |
-
add_action('wp_ajax_manage_license', array($this, 'manage_license'));
|
37 |
-
|
38 |
-
}
|
39 |
-
public function register_tab($tabs)
|
40 |
-
{
|
41 |
-
$tabs = is_array($tabs) && isset($tabs[0]) ? $tabs : [$tabs];
|
42 |
-
|
43 |
-
foreach ($tabs as $item => $tab)
|
44 |
-
{
|
45 |
-
if (!(isset($tab['id']) && $tab['id'] && isset($tab['title']) && $tab['title']))
|
46 |
-
{
|
47 |
-
unset($tabs[$item]);
|
48 |
-
continue;
|
49 |
-
}
|
50 |
-
if (isset($this->tabs[$tab['id']]))
|
51 |
-
{
|
52 |
-
unset($tabs[$item]);
|
53 |
-
}
|
54 |
-
else
|
55 |
-
{
|
56 |
-
$this->tabs[$tab['id']] = ['id' => $tab['id'], 'title' => $tab['title'], 'label' => @$tab['label']];
|
57 |
-
}
|
58 |
-
}
|
59 |
-
return $tabs;
|
60 |
-
}
|
61 |
-
public function register_assignment_field($settings)
|
62 |
-
{
|
63 |
-
if (!$this->pages)
|
64 |
-
{
|
65 |
-
$pages = get_pages(['sort_order' => 'desc',
|
66 |
-
'sort_column' => 'post_date']);
|
67 |
-
foreach ($pages as $page)
|
68 |
-
{
|
69 |
-
$this->pages[$page->ID] = $page->post_title . "(" . $page->ID . ")";
|
70 |
-
|
71 |
-
}
|
72 |
-
}
|
73 |
-
$settings = is_array($settings) && isset($settings[0]) ? $settings : [$settings];
|
74 |
-
foreach ($settings as $key => $setting)
|
75 |
-
{
|
76 |
-
$settings[$key]['type'] = 'select';
|
77 |
-
$settings[$key]['options'] = $this->pages;
|
78 |
-
}
|
79 |
-
$settings = $this->register_setting_field('wpm_assign', $settings, true);
|
80 |
-
$this->asignment_fields = array_merge($this->asignment_fields, $settings);
|
81 |
-
return $settings;
|
82 |
-
}
|
83 |
-
public function register_setting_field($tab, $settings, $return = false)
|
84 |
-
{
|
85 |
-
$setting_temp = [];
|
86 |
-
$settings = is_array($settings) && isset($settings[0]) ? $settings : [$settings];
|
87 |
-
|
88 |
-
foreach ($settings as $item => $setting)
|
89 |
-
{
|
90 |
-
if (!(isset($setting['name']) && $setting['label']))
|
91 |
-
{
|
92 |
-
unset($settings[$item]);
|
93 |
-
continue;
|
94 |
-
}
|
95 |
-
$key = array_search($setting['name'], array_column(isset($this->settings[$tab]) && is_array($this->settings[$tab]) ? $this->settings[$tab] : [], 'name'));
|
96 |
-
|
97 |
-
if ($key !== false)
|
98 |
-
{
|
99 |
-
unset($settings[$key]);
|
100 |
-
}
|
101 |
-
else
|
102 |
-
{
|
103 |
-
$setting_temp[] = $setting;
|
104 |
-
|
105 |
-
}
|
106 |
-
}
|
107 |
-
|
108 |
-
if ($return)
|
109 |
-
{
|
110 |
-
return $setting_temp;
|
111 |
-
}
|
112 |
-
else
|
113 |
-
{
|
114 |
-
$this->settings[$tab] = array_merge(
|
115 |
-
is_array(@$this->settings[$tab]) ? $this->settings[$tab] : [], $setting_temp);
|
116 |
-
}
|
117 |
-
|
118 |
-
return $setting_temp;
|
119 |
-
}
|
120 |
-
public function init()
|
121 |
-
{
|
122 |
-
global $wpmovies_var;
|
123 |
-
$licenses = [];
|
124 |
-
$this->license_fields = [];
|
125 |
-
$store = wphp_store_url();
|
126 |
-
|
127 |
-
$licenses = apply_filters('scb_license_items', $licenses);
|
128 |
-
|
129 |
-
foreach ($licenses as $license)
|
130 |
-
{
|
131 |
-
|
132 |
-
$this->license_fields[] = array(
|
133 |
-
'name' => $license['id'],
|
134 |
-
'label' => $license['label'],
|
135 |
-
'desc' => 'dd',
|
136 |
-
'type' => 'text',
|
137 |
-
'default' => '',
|
138 |
-
'callback' => array($this, 'callback_license_text_box'),
|
139 |
-
'sanitize_callback' => function ()
|
140 |
-
{
|
141 |
-
return '';
|
142 |
-
},
|
143 |
-
);
|
144 |
-
if (function_exists('wphp_license_manager'))
|
145 |
-
{
|
146 |
-
|
147 |
-
wphp_license_manager()->add(
|
148 |
-
wp_hide_post()->info('id'),
|
149 |
-
$store,
|
150 |
-
$license['type'],
|
151 |
-
$license['name'],
|
152 |
-
null,
|
153 |
-
['license_folder' => wp_hide_post()->info('dir')]
|
154 |
-
);
|
155 |
-
|
156 |
-
}
|
157 |
-
}
|
158 |
-
|
159 |
-
}
|
160 |
-
public function callback_license_text_box($args)
|
161 |
-
{
|
162 |
-
$license_key = '';
|
163 |
-
$license_info = '';
|
164 |
-
|
165 |
-
if (function_exists('wphp_license_manager'))
|
166 |
-
{
|
167 |
-
$obj_license = wphp_get_license($args['id']);
|
168 |
-
|
169 |
-
if (!is_null($obj_license))
|
170 |
-
{
|
171 |
-
|
172 |
-
$license_key = $obj_license->get_license_key();
|
173 |
-
$license_info = $obj_license->extendedInfo();
|
174 |
-
}
|
175 |
-
}
|
176 |
-
|
177 |
-
$status = @$license_info['license'] == 'valid' ? 1 : 0;
|
178 |
-
|
179 |
-
$value = esc_attr($this->settings_api->get_option($args['id'], $args['section'], $args['std']));
|
180 |
-
$size = isset($args['size']) && !is_null($args['size']) ? $args['size'] : 'regular';
|
181 |
-
$type = isset($args['type']) ? $args['type'] : 'text';
|
182 |
-
$html = sprintf('<input type="%1$s" class="%2$s-text" id="wpm_lic_txt_%4$s" name="%3$s[%4$s]" value="%5$s" />',
|
183 |
-
$type, $size, $args['section'], $args['id'], $license_key);
|
184 |
-
|
185 |
-
$html .= sprintf('<input data-key="%1$s" data-status="%2$s" data-id="%3$s" id="wpm_lic_btn_%3$s" value="%4$s" type="submit" class="wpm_lic_class button" name="license_action" >', $license_key, $status, $args['id'], ($status ? 'Deactivate' : 'Activate'));
|
186 |
-
|
187 |
-
$html .= sprintf('<p class="license_tatus %2$s" id="wpm_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'] . " " : ''));
|
188 |
-
|
189 |
-
echo $html;
|
190 |
-
}
|
191 |
-
public function admin_init()
|
192 |
-
{
|
193 |
-
//set the settings
|
194 |
-
$this->settings_api->set_sections($this->get_settings_sections());
|
195 |
-
$this->settings_api->set_fields($this->get_settings_fields());
|
196 |
-
//initialize settings
|
197 |
-
$this->settings_api->admin_init();
|
198 |
-
}
|
199 |
-
|
200 |
-
public function get_settings_sections()
|
201 |
-
{
|
202 |
-
$this->license_section = array(
|
203 |
-
'id' => 'wpm_lic',
|
204 |
-
'title' => __('Licenses', 'wp_movies'),
|
205 |
-
);
|
206 |
-
|
207 |
-
$this->tabs = apply_filters('scb_setting_tabs', $this->tabs);
|
208 |
-
|
209 |
-
return array_merge(['wpm_lic' => $this->license_section], $this->tabs);
|
210 |
-
|
211 |
-
}
|
212 |
-
/**
|
213 |
-
* Returns all the settings fields
|
214 |
-
*
|
215 |
-
* @return array settings fields
|
216 |
-
*/
|
217 |
-
public function get_settings_fields()
|
218 |
-
{
|
219 |
-
|
220 |
-
$this->settings = apply_filters('scb_setting_fields', $this->settings);
|
221 |
-
$this->settings[$this->license_section['id']] = $this->license_fields;
|
222 |
-
$this->settings[$this->asignment_section['id']] = $this->asignment_fields;
|
223 |
-
|
224 |
-
return $this->settings;
|
225 |
-
|
226 |
-
}
|
227 |
-
public function plugin_page()
|
228 |
-
{
|
229 |
-
echo '<div class="wrap">';
|
230 |
-
$this->settings_api->show_navigation();
|
231 |
-
settings_errors();
|
232 |
-
$this->settings_api->show_forms();
|
233 |
-
$this->script();
|
234 |
-
echo '</div>';
|
235 |
-
}
|
236 |
-
/**
|
237 |
-
* Get all the pages
|
238 |
-
*
|
239 |
-
* @return array page names with key value pairs
|
240 |
-
*/
|
241 |
-
public function get_pages()
|
242 |
-
{
|
243 |
-
$pages = get_pages();
|
244 |
-
$pages_options = array();
|
245 |
-
if ($pages)
|
246 |
-
{
|
247 |
-
foreach ($pages as $page)
|
248 |
-
{
|
249 |
-
$pages_options[$page->ID] = $page->post_title;
|
250 |
-
}
|
251 |
-
}
|
252 |
-
return $pages_options;
|
253 |
-
}
|
254 |
-
public function manage_license()
|
255 |
-
{
|
256 |
-
$response['status'] = 0;
|
257 |
-
$response['error'] = 'Unknown Error';
|
258 |
-
$response['lic_id'] = @$_REQUEST['id'];
|
259 |
-
$response['lic_key'] = @$_REQUEST['key'];
|
260 |
-
|
261 |
-
$obj_license = wphp_get_license($response['lic_id']);
|
262 |
-
|
263 |
-
if (!$obj_license)
|
264 |
-
{
|
265 |
-
$response['error'] = 'Invalid Plugin Or theme(1)';
|
266 |
-
}
|
267 |
-
elseif (!$response['lic_key'])
|
268 |
-
{
|
269 |
-
$response['error'] = 'Invalid Plugin Or theme(2)';
|
270 |
-
}
|
271 |
-
else
|
272 |
-
{
|
273 |
-
$obj_license->set_license_key($response['lic_key']);
|
274 |
-
|
275 |
-
if (@$_REQUEST['status'])
|
276 |
-
{
|
277 |
-
$obj_license->deactivate_license();
|
278 |
-
}
|
279 |
-
else
|
280 |
-
{
|
281 |
-
$obj_license->activate_license();
|
282 |
-
}
|
283 |
-
$response['error'] = "";
|
284 |
-
$response['status'] = 1;
|
285 |
-
$license_info = $obj_license->extendedInfo();
|
286 |
-
$response['lic_status'] = $license_info['license'] == 'valid' ? 1 : 0;
|
287 |
-
|
288 |
-
$license_info = $obj_license->extendedInfo();
|
289 |
-
|
290 |
-
$response['lic_msg'] = $license_info['license_info'] . ($license_info['error_info'] ? " -" . $license_info['error_info'] . " " : '');
|
291 |
-
$response['lic_btn'] = ($response['lic_status'] ? 'Deactivate' : 'Activate');
|
292 |
-
|
293 |
-
}
|
294 |
-
|
295 |
-
wp_send_json($response);
|
296 |
-
}
|
297 |
-
public function script()
|
298 |
-
{
|
299 |
-
?>
|
300 |
-
<style type="text/css">
|
301 |
-
.scb-sett-select
|
302 |
-
{
|
303 |
-
}
|
304 |
-
.scb-sett-select-chosen{
|
305 |
-
width: 300px;
|
306 |
-
}
|
307 |
-
.chosen-container-multi .chosen-choices {
|
308 |
-
-webkit-border-radius: 3px;
|
309 |
-
border-radius: 3px;
|
310 |
-
border-color: #dfdfdf;
|
311 |
-
background-image: none;
|
312 |
-
}
|
313 |
-
.chosen-container .search-field input {
|
314 |
-
width: 90%!important;
|
315 |
-
}
|
316 |
-
.chosen-container-multi .chosen-choices input {
|
317 |
-
margin: 2px;
|
318 |
-
height: 27px!important;
|
319 |
-
border-color: #dfdfdf;
|
320 |
-
}
|
321 |
-
.chosen-container .search-field {
|
322 |
-
float: none!important;
|
323 |
-
}
|
324 |
-
</style>
|
325 |
-
|
326 |
-
<script>
|
327 |
-
jQuery(document).ready(function($)
|
328 |
-
{
|
329 |
-
$('.wpm_lic_class').on('click', function(event)
|
330 |
-
{
|
331 |
-
event.preventDefault();
|
332 |
-
var data = {
|
333 |
-
action: 'manage_license',
|
334 |
-
id: $(this).data('id'),
|
335 |
-
key: $(this).data('key'),
|
336 |
-
status: $(this).data('status'),
|
337 |
-
};
|
338 |
-
$('#wpm_lic_btn_' + $(this).data('id')).data('label', $('#wpm_lic_btn_' + $(this).data('id')).val());
|
339 |
-
$('#wpm_lic_btn_' + $(this).data('id')).val('Please Wait..');
|
340 |
-
$('#wpm_lic_btn_' + $(this).data('id')).attr('disabled', true);
|
341 |
-
$.post(ajaxurl, data, function(response)
|
342 |
-
{
|
343 |
-
if (!response.status)
|
344 |
-
{
|
345 |
-
showModalMsg(wphp_texts.error, response.error,
|
346 |
-
{});
|
347 |
-
$('#wpm_lic_btn_' + response.lic_id).val($('#wpm_lic_btn_' + response.lic_id).data('label'));
|
348 |
-
$('#wpm_lic_btn_' + response.lic_id).attr('disabled', false)
|
349 |
-
}
|
350 |
-
else
|
351 |
-
{
|
352 |
-
$('#wpm_lic_txt_' + response.lic_id).data('status', response.lic_status);
|
353 |
-
$('#wpm_lic_btn_' + response.lic_id).val(response.lic_btn);
|
354 |
-
$('#wpm_lic_btn_' + response.lic_id).attr('disabled', false);
|
355 |
-
$('#wpm_lic_status_' + response.lic_id).html(response.lic_msg);
|
356 |
-
}
|
357 |
-
$('#wpm_lic_status_' + response.lic_id).removeClass().addClass("license_status " + (response.lic_status ? 'license_status_valid' : 'license_status_invalid'));
|
358 |
-
$('#wpm_lic_btn_' + response.lic_id).data('status', response.lic_status);
|
359 |
-
}).fail(function(xhr, err)
|
360 |
-
{
|
361 |
-
id = $(this)[0].data.split('&')[1].split("=")[1];
|
362 |
-
$('#wpm_lic_btn_' + id).val($('#wpm_lic_btn_' + id).data('label'));
|
363 |
-
$('#wpm_lic_btn_' + id).attr('disabled', false)
|
364 |
-
showModalMsg(wphp_texts.error, formatErrorMessage(xhr, err));
|
365 |
-
})
|
366 |
-
});
|
367 |
-
});
|
368 |
-
</script>
|
369 |
-
|
370 |
-
<style type="text/css">
|
371 |
-
.license_status_valid{color:green;}
|
372 |
-
.license_status_invalid{color:red;}
|
373 |
-
|
374 |
-
|
375 |
-
div.description {
|
376 |
-
margin-top: 4px;
|
377 |
-
margin-bottom: 0;
|
378 |
-
font-size: 13px;
|
379 |
-
font-style: italic;
|
380 |
-
margin: 2px 0 5px;
|
381 |
-
color: #666;
|
382 |
-
}
|
383 |
-
|
384 |
-
</style>
|
385 |
-
<?php
|
386 |
-
|
387 |
-
}
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
}
|
392 |
-
|
393 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/settings/class_settingsAPI.php
DELETED
@@ -1,644 +0,0 @@
|
|
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 |
-
$html .= sprintf('<a href="#%1$s" class="nav-tab" id="%1$s-tab">%2$s</a>', $tab['id'], $tab['title']);
|
514 |
-
}
|
515 |
-
|
516 |
-
$html .= '</h2>';
|
517 |
-
|
518 |
-
echo $html;
|
519 |
-
}
|
520 |
-
|
521 |
-
/**
|
522 |
-
* Show the section settings forms
|
523 |
-
*
|
524 |
-
* This function displays every sections in a different form
|
525 |
-
*/
|
526 |
-
public function show_forms($page = "options.php")
|
527 |
-
{
|
528 |
-
?>
|
529 |
-
<div class="metabox-holder">
|
530 |
-
<?php foreach ($this->settings_sections as $form)
|
531 |
-
{
|
532 |
-
?>
|
533 |
-
<div id="<?php echo $form['id']; ?>" class="group" style="display: none;">
|
534 |
-
<form method="post" action="<?php echo ($page); ?>">
|
535 |
-
<?php
|
536 |
-
do_action('wsa_form_top_' . $form['id'], $form);
|
537 |
-
settings_fields($form['id']);
|
538 |
-
|
539 |
-
do_settings_sections($form['id']);
|
540 |
-
|
541 |
-
do_action('wsa_form_bottom_' . $form['id'], $form);
|
542 |
-
?>
|
543 |
-
<div style="padding-left: 10px">
|
544 |
-
<?php submit_button();?>
|
545 |
-
</div>
|
546 |
-
<?php do_action('wsa_form_last_' . $form['id'], $form);?>
|
547 |
-
</form>
|
548 |
-
</div>
|
549 |
-
<?php }?>
|
550 |
-
<?php do_action('wsa_global_footer', $form);?>
|
551 |
-
</div>
|
552 |
-
<?php
|
553 |
-
$this->script();
|
554 |
-
}
|
555 |
-
|
556 |
-
/**
|
557 |
-
* Tabbable JavaScript codes & Initiate Color Picker
|
558 |
-
*
|
559 |
-
* This code uses localstorage for displaying active tabs
|
560 |
-
*/
|
561 |
-
public function script()
|
562 |
-
{
|
563 |
-
?>
|
564 |
-
<script>
|
565 |
-
jQuery(document).ready(function($) {
|
566 |
-
//Initiate Color Picker
|
567 |
-
$('.wp-color-picker-field').wpColorPicker();
|
568 |
-
|
569 |
-
// Switches option sections
|
570 |
-
$('.group').hide();
|
571 |
-
var activetab = '';
|
572 |
-
if (typeof(localStorage) != 'undefined' ) {
|
573 |
-
activetab = localStorage.getItem("activetab");
|
574 |
-
}
|
575 |
-
if (activetab != '' && $(activetab).length ) {
|
576 |
-
$(activetab).fadeIn();
|
577 |
-
} else {
|
578 |
-
$('.group:first').fadeIn();
|
579 |
-
}
|
580 |
-
$('.group .collapsed').each(function(){
|
581 |
-
$(this).find('input:checked').parent().parent().parent().nextAll().each(
|
582 |
-
function(){
|
583 |
-
if ($(this).hasClass('last')) {
|
584 |
-
$(this).removeClass('hidden');
|
585 |
-
return false;
|
586 |
-
}
|
587 |
-
$(this).filter('.hidden').removeClass('hidden');
|
588 |
-
});
|
589 |
-
});
|
590 |
-
|
591 |
-
if (activetab != '' && $(activetab + '-tab').length ) {
|
592 |
-
$(activetab + '-tab').addClass('nav-tab-active');
|
593 |
-
}
|
594 |
-
else {
|
595 |
-
$('.nav-tab-wrapper a:first').addClass('nav-tab-active');
|
596 |
-
}
|
597 |
-
$('.nav-tab-wrapper a').click(function(evt) {
|
598 |
-
$('.nav-tab-wrapper a').removeClass('nav-tab-active');
|
599 |
-
$(this).addClass('nav-tab-active').blur();
|
600 |
-
var clicked_group = $(this).attr('href');
|
601 |
-
if (typeof(localStorage) != 'undefined' ) {
|
602 |
-
localStorage.setItem("activetab", $(this).attr('href'));
|
603 |
-
}
|
604 |
-
$('.group').hide();
|
605 |
-
$(clicked_group).fadeIn();
|
606 |
-
evt.preventDefault();
|
607 |
-
});
|
608 |
-
|
609 |
-
$('.wpsa-browse').on('click', function (event) {
|
610 |
-
event.preventDefault();
|
611 |
-
|
612 |
-
var self = $(this);
|
613 |
-
|
614 |
-
// Create the media frame.
|
615 |
-
var file_frame = wp.media.frames.file_frame = wp.media({
|
616 |
-
title: self.data('uploader_title'),
|
617 |
-
button: {
|
618 |
-
text: self.data('uploader_button_text'),
|
619 |
-
},
|
620 |
-
multiple: false
|
621 |
-
});
|
622 |
-
|
623 |
-
file_frame.on('select', function () {
|
624 |
-
attachment = file_frame.state().get('selection').first().toJSON();
|
625 |
-
|
626 |
-
self.prev('.wpsa-url').val(attachment.url);
|
627 |
-
});
|
628 |
-
|
629 |
-
// Finally, open the modal
|
630 |
-
file_frame.open();
|
631 |
-
});
|
632 |
-
});
|
633 |
-
</script>
|
634 |
-
|
635 |
-
<style type="text/css">
|
636 |
-
/** WordPress 3.8 Fix **/
|
637 |
-
.form-table th { padding: 20px 10px; }
|
638 |
-
#wpbody-content .metabox-holder { padding-top: 5px; }
|
639 |
-
</style>
|
640 |
-
<?php
|
641 |
-
}
|
642 |
-
|
643 |
-
}
|
644 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/settings/class_settingsAPICustom.php
DELETED
@@ -1,234 +0,0 @@
|
|
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'], $section['title'], $callback, $section['id']);
|
45 |
-
}
|
46 |
-
|
47 |
-
//register settings fields
|
48 |
-
foreach ($this->settings_fields as $section => $field)
|
49 |
-
{
|
50 |
-
foreach ($field as $option)
|
51 |
-
{
|
52 |
-
if (!isset($option['name']) || !isset($option['label']))
|
53 |
-
{
|
54 |
-
continue;
|
55 |
-
}
|
56 |
-
$type = isset($option['type']) ? $option['type'] : 'text';
|
57 |
-
|
58 |
-
$args = array(
|
59 |
-
'id' => $option['name'],
|
60 |
-
'label_for' => $args['label_for'] = "{$section}[{$option['name']}]",
|
61 |
-
'desc' => isset($option['desc']) ? $option['desc'] : '',
|
62 |
-
'name' => $option['label'],
|
63 |
-
'section' => $section,
|
64 |
-
'size' => isset($option['size']) ? $option['size'] : null,
|
65 |
-
'options' => isset($option['options']) ? $option['options'] : '',
|
66 |
-
'std' => isset($option['default']) ? $option['default'] : '',
|
67 |
-
'sanitize_callback' => isset($option['sanitize_callback']) ? $option['sanitize_callback'] : '',
|
68 |
-
'type' => $type,
|
69 |
-
);
|
70 |
-
$args = array_merge($option, $args);
|
71 |
-
$callable = isset($option['callback']) && (is_callable($option['callback']) || is_array($option['callback'])) ? $option['callback'] : array($this, 'callback_' . $type);
|
72 |
-
add_settings_field($section . '[' . $option['name'] . ']', $option['label'], $callable, $section, $section, $args);
|
73 |
-
}
|
74 |
-
}
|
75 |
-
|
76 |
-
// creates our settings in the options table
|
77 |
-
$th = $this;
|
78 |
-
foreach ($this->settings_sections as $section)
|
79 |
-
{
|
80 |
-
register_setting($section['id'], $section['id'],
|
81 |
-
function ($options) use ($th, $section)
|
82 |
-
{
|
83 |
-
return $th->sanitize_options($section, $options);
|
84 |
-
});
|
85 |
-
}
|
86 |
-
}
|
87 |
-
public function callback_yesno($args)
|
88 |
-
{
|
89 |
-
$args['options'] = ['1' => 'Yes', '0' => 'No'];
|
90 |
-
$value = esc_attr($this->get_option($args['id'], $args['section'], $args['std']));
|
91 |
-
$size = isset($args['size']) && !is_null($args['size']) ? $args['size'] : 'regular';
|
92 |
-
$html = sprintf('<select class="%1$s" name="%2$s[%3$s]" id="%2$s[%3$s]">', $size, $args['section'], $args['id']);
|
93 |
-
|
94 |
-
foreach ($args['options'] as $key => $label)
|
95 |
-
{
|
96 |
-
$html .= sprintf('<option value="%s"%s>%s</option>', $key, selected($value, $key, false), $label);
|
97 |
-
}
|
98 |
-
|
99 |
-
$html .= sprintf('</select>');
|
100 |
-
$html .= $this->get_field_description($args);
|
101 |
-
|
102 |
-
echo $html;
|
103 |
-
}
|
104 |
-
/**
|
105 |
-
* Displays a selectbox for a settings field
|
106 |
-
*
|
107 |
-
* @param array $args settings field args
|
108 |
-
*/
|
109 |
-
public function callback_select($args)
|
110 |
-
{
|
111 |
-
|
112 |
-
$value = ($this->get_option($args['id'], $args['section'], $args['std']));
|
113 |
-
if (!is_array($value))
|
114 |
-
{
|
115 |
-
$value = esc_attr($value);
|
116 |
-
}
|
117 |
-
$value = is_array($value) ? $value : [$value];
|
118 |
-
$size = isset($args['multiple']) ? '' : (isset($args['size']) && !is_null($args['size']) ? $args['size'] : 'regular');
|
119 |
-
if (isset($args['class']))
|
120 |
-
{
|
121 |
-
$size .= ' ' . $args['class'];
|
122 |
-
}
|
123 |
-
$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']) ? '[]' : '');
|
124 |
-
|
125 |
-
foreach ($args['options'] as $key => $label)
|
126 |
-
{
|
127 |
-
$extra = '';
|
128 |
-
if (is_array($label))
|
129 |
-
{
|
130 |
-
$extra = $label['extra'];
|
131 |
-
$label = @$label['text'];
|
132 |
-
}
|
133 |
-
$html .= sprintf('<option %s value="%s"%s>%s</option>', $extra, $key, in_array($key, $value) ? 'selected' : '', $label);
|
134 |
-
}
|
135 |
-
|
136 |
-
$html .= sprintf('</select>');
|
137 |
-
$html .= $this->get_field_description($args);
|
138 |
-
|
139 |
-
echo $html;
|
140 |
-
}
|
141 |
-
/**
|
142 |
-
* Displays a selectbox for a settings field
|
143 |
-
*
|
144 |
-
* @param array $args settings field args
|
145 |
-
*/
|
146 |
-
public function callback_multi($args)
|
147 |
-
{
|
148 |
-
$args['multiple'] = 1;
|
149 |
-
$args['class'] = 'scb-sett-select-chosen chosen-select';
|
150 |
-
|
151 |
-
echo ($this->callback_select($args));
|
152 |
-
}
|
153 |
-
public function get_sanitize_callback($slug = '')
|
154 |
-
{
|
155 |
-
if (empty($slug))
|
156 |
-
{
|
157 |
-
return false;
|
158 |
-
}
|
159 |
-
|
160 |
-
// Iterate over registered fields and see if we can find proper callback
|
161 |
-
|
162 |
-
foreach ($this->settings_fields as $section => $options)
|
163 |
-
{
|
164 |
-
foreach ($options as $option)
|
165 |
-
{
|
166 |
-
if ($option['name'] != $slug)
|
167 |
-
{
|
168 |
-
continue;
|
169 |
-
}
|
170 |
-
|
171 |
-
// Return the callback name
|
172 |
-
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);
|
173 |
-
}
|
174 |
-
}
|
175 |
-
|
176 |
-
return false;
|
177 |
-
}
|
178 |
-
|
179 |
-
public function sanitize_callback_yesno($option_value)
|
180 |
-
{
|
181 |
-
return (int) (boolean) $option_value;
|
182 |
-
}
|
183 |
-
|
184 |
-
public function sanitize_options($section, $options)
|
185 |
-
{
|
186 |
-
// print_n($options);
|
187 |
-
$options = apply_filters('scb_pre_sanitize_section', $options, $section);
|
188 |
-
|
189 |
-
foreach ($options as $option_slug => $option_value)
|
190 |
-
{
|
191 |
-
$sanitize_callback = $this->get_sanitize_callback($option_slug);
|
192 |
-
// If callback is set, call it
|
193 |
-
if ($sanitize_callback)
|
194 |
-
{
|
195 |
-
// print_n($option_slug);
|
196 |
-
|
197 |
-
$options[$option_slug] = call_user_func($sanitize_callback, $option_value);
|
198 |
-
continue;
|
199 |
-
}
|
200 |
-
}
|
201 |
-
|
202 |
-
return apply_filters('scb_post_sanitize_section', $options, $section);
|
203 |
-
}
|
204 |
-
public function show_navigation()
|
205 |
-
{
|
206 |
-
$html = '<h2 class="nav-tab-wrapper">';
|
207 |
-
|
208 |
-
foreach ($this->settings_sections as $tab)
|
209 |
-
{
|
210 |
-
$html .= sprintf('<a href="#%1$s" class="nav-tab" id="%1$s-tab">%2$s</a>', $tab['id'], (!empty($tab['label']) ? $tab['label'] : $tab['title']));
|
211 |
-
}
|
212 |
-
|
213 |
-
$html .= '</h2>';
|
214 |
-
|
215 |
-
echo $html;
|
216 |
-
}
|
217 |
-
public function get_field_description($args)
|
218 |
-
{
|
219 |
-
if (!empty($args['desc']))
|
220 |
-
{
|
221 |
-
|
222 |
-
$desc = '<p class="description">' . $args['desc'] . '</p>';
|
223 |
-
}
|
224 |
-
else
|
225 |
-
{
|
226 |
-
$desc = '';
|
227 |
-
}
|
228 |
-
|
229 |
-
return $desc;
|
230 |
-
}
|
231 |
-
|
232 |
-
}
|
233 |
-
|
234 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/class-wp-hide-post-activator.php
DELETED
@@ -1,133 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Fired during plugin activation
|
5 |
-
*
|
6 |
-
* @link http://scriptburn.com
|
7 |
-
* @since 1.2.2
|
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 1.2.2
|
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 |
-
$this->migrate();
|
36 |
-
update_option('wphp_version', wp_hide_post()->info('version'));
|
37 |
-
}
|
38 |
-
|
39 |
-
public function migrate()
|
40 |
-
{
|
41 |
-
wphp_init();
|
42 |
-
$this->migrate_db(); // in case any tables were created, clean them up
|
43 |
-
$this->remove_wp_low_profiler(); // remove the files of the plugin
|
44 |
-
}
|
45 |
-
/**
|
46 |
-
* Migrate to the new database schema and clean up old schema...
|
47 |
-
* Should run only once in the lifetime of the plugin...
|
48 |
-
* @return unknown_type
|
49 |
-
*/
|
50 |
-
public function migrate_db()
|
51 |
-
{
|
52 |
-
p_l("called: wphp_migrate_db");
|
53 |
-
/* When I first released this plugin, I was young and crazy and didn't know about the postmeta table.
|
54 |
-
* With time I became wiser and wiser and decided to migrate the implementation to rely on postmeta.
|
55 |
-
* I hope it was not a bad idea...
|
56 |
-
*/
|
57 |
-
global $wpdb;
|
58 |
-
global $table_prefix;
|
59 |
-
$dbname = $wpdb->get_var("SELECT database()");
|
60 |
-
if (!$dbname)
|
61 |
-
{
|
62 |
-
return;
|
63 |
-
}
|
64 |
-
|
65 |
-
$legacy_table_name = "${table_prefix}lowprofiler_posts";
|
66 |
-
$legacy_table_exists = $wpdb->get_var("SELECT COUNT(*) AS count FROM information_schema.tables WHERE table_schema = '$dbname' AND table_name = '$legacy_table_name';");
|
67 |
-
if ($legacy_table_exists)
|
68 |
-
{
|
69 |
-
p_l("Migrating legacy table...");
|
70 |
-
// move everything to the postmeta table
|
71 |
-
$existing = $wpdb->get_results("SELECT wplp_post_id, wplp_flag, wplp_value from $legacy_table_name", ARRAY_N);
|
72 |
-
// scan them one by one and insert the corresponding fields in the postmeta table
|
73 |
-
$count = 0;
|
74 |
-
foreach ($existing as $existing_array)
|
75 |
-
{
|
76 |
-
$wplp_post_id = $existing_array[0];
|
77 |
-
$wplp_flag = $existing_array[1];
|
78 |
-
$wplp_value = $existing_array[2];
|
79 |
-
if ($wplp_flag == 'home')
|
80 |
-
{
|
81 |
-
$wplp_flag = 'front';
|
82 |
-
}
|
83 |
-
|
84 |
-
if ($wplp_value == 'home')
|
85 |
-
{
|
86 |
-
$wplp_value = 'front';
|
87 |
-
}
|
88 |
-
|
89 |
-
if ($wplp_flag != 'page')
|
90 |
-
{
|
91 |
-
$wpdb->query("INSERT INTO " . WPHP_TABLE_NAME . "(post_id, meta_key, meta_value) VALUES($wplp_post_id, '_wplp_post_$wplp_flag', '1')");
|
92 |
-
}
|
93 |
-
else
|
94 |
-
{
|
95 |
-
$wpdb->query("INSERT INTO " . WPHP_TABLE_NAME . "(post_id, meta_key, meta_value) VALUES($wplp_post_id, '_wplp_page_flags', $wplp_value)");
|
96 |
-
}
|
97 |
-
++$count;
|
98 |
-
}
|
99 |
-
p_l("$count entries migrated from legacy table.");
|
100 |
-
// delete the old table
|
101 |
-
$wpdb->query("TRUNCATE TABLE $legacy_table_name");
|
102 |
-
$wpdb->query("DROP TABLE $legacy_table_name");
|
103 |
-
p_l("Legacy table deleted.");
|
104 |
-
}
|
105 |
-
}
|
106 |
-
|
107 |
-
/**
|
108 |
-
*
|
109 |
-
* @return unknown_type
|
110 |
-
*/
|
111 |
-
public function remove_wp_low_profiler()
|
112 |
-
{
|
113 |
-
p_l("called: wphp_remove_wp_low_profiler");
|
114 |
-
$plugin_list = get_plugins('/wp-low-profiler');
|
115 |
-
if (isset($plugin_list['wp-low-profiler.php']))
|
116 |
-
{
|
117 |
-
p_l("The 'WP low Profiler' plugin is present. Cleaning it up...");
|
118 |
-
$plugins = array('wp-low-profiler/wp-low-profiler.php');
|
119 |
-
if (is_plugin_active('wp-low-profiler/wp-low-profiler.php'))
|
120 |
-
{
|
121 |
-
p_l("The 'WP low Profiler' plugin is active. Deactivating...");
|
122 |
-
deactivate_plugins($plugins, true); // silent deactivate
|
123 |
-
}
|
124 |
-
p_l("Deleting plugin 'WP low Profiler'...");
|
125 |
-
delete_plugins($plugins, '');
|
126 |
-
}
|
127 |
-
else
|
128 |
-
{
|
129 |
-
p_l("The 'WP low Profiler' plugin does not exist.");
|
130 |
-
}
|
131 |
-
|
132 |
-
}
|
133 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/class-wp-hide-post-deactivator.php
DELETED
@@ -1,36 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Fired during plugin deactivation
|
5 |
-
*
|
6 |
-
* @link http://scriptburn.com
|
7 |
-
* @since 1.2.2
|
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 1.2.2
|
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
DELETED
@@ -1,47 +0,0 @@
|
|
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 1.2.2
|
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 1.2.2
|
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
DELETED
@@ -1,137 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Register all actions and filters for the plugin
|
5 |
-
*
|
6 |
-
* @link http://scriptburn.com
|
7 |
-
* @since 1.2.2
|
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
DELETED
@@ -1,387 +0,0 @@
|
|
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 1.2.2
|
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 1.2.2
|
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 version = '1.2.2';
|
80 |
-
const db_version = 1;
|
81 |
-
const id = 'wp-hide-post';
|
82 |
-
const name = 'Wp Hide Post';
|
83 |
-
const title = '';
|
84 |
-
const dir = '';
|
85 |
-
const url = '';
|
86 |
-
const file = '';
|
87 |
-
|
88 |
-
/**
|
89 |
-
* Define the core functionality of the plugin.
|
90 |
-
*
|
91 |
-
* Set the plugin name and the plugin version that can be used throughout the plugin.
|
92 |
-
* Load the dependencies, define the locale, and set the hooks for the admin area and
|
93 |
-
* the public-facing side of the site.
|
94 |
-
*
|
95 |
-
* @since 1.2.2
|
96 |
-
*/
|
97 |
-
|
98 |
-
public static function getInstance()
|
99 |
-
{
|
100 |
-
if (is_null(self::$instance))
|
101 |
-
{
|
102 |
-
self::$instance = new static();
|
103 |
-
}
|
104 |
-
|
105 |
-
return self::$instance;
|
106 |
-
}
|
107 |
-
|
108 |
-
public function __construct()
|
109 |
-
{
|
110 |
-
|
111 |
-
$this->define_globals();
|
112 |
-
$this->load_dependencies();
|
113 |
-
$this->init();
|
114 |
-
$this->set_locale();
|
115 |
-
$this->define_admin_hooks();
|
116 |
-
$this->define_public_hooks();
|
117 |
-
|
118 |
-
}
|
119 |
-
|
120 |
-
/**
|
121 |
-
* Load the required dependencies for this plugin.
|
122 |
-
*
|
123 |
-
* Include the following files that make up the plugin:
|
124 |
-
*
|
125 |
-
* - wp_hide_post_Loader. Orchestrates the hooks of the plugin.
|
126 |
-
* - wp_hide_post_i18n. Defines internationalization functionality.
|
127 |
-
* - wp_hide_post_Admin. Defines all hooks for the admin area.
|
128 |
-
* - wp_hide_post_Public. Defines all hooks for the public side of the site.
|
129 |
-
*
|
130 |
-
* Create an instance of the loader which will be used to register the hooks
|
131 |
-
* with WordPress.
|
132 |
-
*
|
133 |
-
* @since 1.2.2
|
134 |
-
* @access private
|
135 |
-
*/
|
136 |
-
private function load_dependencies()
|
137 |
-
{
|
138 |
-
/**
|
139 |
-
* This file contains usfull functions to be used in global scope througout the plugin
|
140 |
-
*/
|
141 |
-
require_once WPHP_PLUGIN_DIR . 'includes/helpers.php';
|
142 |
-
|
143 |
-
/**
|
144 |
-
* The class responsible for orchestrating the actions and filters of the
|
145 |
-
* core plugin.
|
146 |
-
*/
|
147 |
-
require_once WPHP_PLUGIN_DIR . 'includes/class-wp-hide-post-loader.php';
|
148 |
-
|
149 |
-
/**
|
150 |
-
* The class responsible for defining internationalization functionality
|
151 |
-
* of the plugin.
|
152 |
-
*/
|
153 |
-
require_once WPHP_PLUGIN_DIR . 'includes/class-wp-hide-post-i18n.php';
|
154 |
-
|
155 |
-
/**
|
156 |
-
* The class responsible for defining all actions that occur in the admin area.
|
157 |
-
*/
|
158 |
-
require_once WPHP_PLUGIN_DIR . 'admin/class-wp-hide-post-admin.php';
|
159 |
-
|
160 |
-
/**
|
161 |
-
* The class responsible for defining all actions that occur in the public-facing
|
162 |
-
* side of the site.
|
163 |
-
*/
|
164 |
-
require_once WPHP_PLUGIN_DIR . 'public/class-wp-hide-post-public.php';
|
165 |
-
|
166 |
-
/**
|
167 |
-
* The class responsible for defining all actions that occur in the public-facing
|
168 |
-
* side of the site.
|
169 |
-
*/
|
170 |
-
require_once WPHP_PLUGIN_DIR . 'public/class-wp-hide-post-public.php';
|
171 |
-
require_once WPHP_PLUGIN_DIR . 'admin/license/autoload.php';
|
172 |
-
|
173 |
-
require_once WPHP_PLUGIN_DIR . 'admin/settings/autoload.php';
|
174 |
-
require_once WPHP_PLUGIN_DIR . 'admin/conditions.php';
|
175 |
-
|
176 |
-
$this->loader = new wp_hide_post_Loader();
|
177 |
-
$this->plugin_admin = new wp_hide_post_Admin(
|
178 |
-
$this->get_wp_hide_post(),
|
179 |
-
$this->get_version());
|
180 |
-
|
181 |
-
}
|
182 |
-
public function settingManager()
|
183 |
-
{
|
184 |
-
return $this->settingManager;
|
185 |
-
}
|
186 |
-
public function pluginAdmin()
|
187 |
-
{
|
188 |
-
return $this->plugin_admin;
|
189 |
-
}
|
190 |
-
/**
|
191 |
-
* Define the locale for this plugin for internationalization.
|
192 |
-
*
|
193 |
-
* Uses the wp_hide_post_i18n class in order to set the domain and to register the hook
|
194 |
-
* with WordPress.
|
195 |
-
*
|
196 |
-
* @since 1.2.2
|
197 |
-
* @access private
|
198 |
-
*/
|
199 |
-
private function set_locale()
|
200 |
-
{
|
201 |
-
|
202 |
-
$plugin_i18n = new wp_hide_post_i18n();
|
203 |
-
|
204 |
-
$this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain');
|
205 |
-
|
206 |
-
}
|
207 |
-
|
208 |
-
/**
|
209 |
-
* Register all of the hooks related to the admin area functionality
|
210 |
-
* of the plugin.
|
211 |
-
*
|
212 |
-
* @since 1.2.2
|
213 |
-
* @access private
|
214 |
-
*/
|
215 |
-
private function define_admin_hooks()
|
216 |
-
{
|
217 |
-
|
218 |
-
//add our styles
|
219 |
-
$this->loader->add_action('admin_enqueue_scripts', $this->plugin_admin, 'enqueue_styles');
|
220 |
-
|
221 |
-
// add our scripts
|
222 |
-
$this->loader->add_action('admin_enqueue_scripts', $this->plugin_admin, 'enqueue_scripts');
|
223 |
-
|
224 |
-
// watch when wp-low-profiler get activated
|
225 |
-
$this->loader->add_action('activate_wp-low-profiler/wp-low-profiler.php', $this->plugin_admin, 'activate_lowprofiler');
|
226 |
-
|
227 |
-
// mark wp-low-profiler as depriciated
|
228 |
-
$this->loader->add_action('plugin_install_action_links', $this->plugin_admin, 'plugin_install_action_links_wp_lowprofiler', 10, 2);
|
229 |
-
|
230 |
-
$this->loader->add_action('save_post', $this->plugin_admin, 'save_post');
|
231 |
-
$this->loader->add_action('delete_post', $this->plugin_admin, 'delete_post');
|
232 |
-
|
233 |
-
$this->loader->add_action('add_meta_boxes', $this->plugin_admin, 'add_meta_boxes');
|
234 |
-
$this->loader->add_action('init', $this->plugin_admin, 'register_setting_page');
|
235 |
-
$this->loader->add_action('admin_menu', $this->plugin_admin, 'admin_menu');
|
236 |
-
$this->loader->add_filter('scb_license_items', $this->plugin_admin, 'register_plugin', 10);
|
237 |
-
$this->loader->add_filter('init', $this->plugin_admin, 'create_post_type', 10);
|
238 |
-
|
239 |
-
// loop through all allowed post types as saved in setting section of the plugin where we this plugin can work
|
240 |
-
foreach ($this->plugin_admin->allowedPostTypes() as $post_type)
|
241 |
-
{
|
242 |
-
// add our custom column to posts list
|
243 |
-
$this->loader->add_filter("manage_{$post_type}_posts_columns", $this->plugin_admin, 'manage_posts_columns', 10);
|
244 |
-
// some plugins still using this old filter
|
245 |
-
$this->loader->add_filter("manage_edit-{$post_type}_columns", $this->plugin_admin, 'manage_posts_columns', 10);
|
246 |
-
|
247 |
-
}
|
248 |
-
|
249 |
-
// add this in case a custom post type is hierarchical type this works for page
|
250 |
-
$this->loader->add_action("manage_pages_custom_column", $this->plugin_admin, 'render_custom_column_data', 10, 2);
|
251 |
-
|
252 |
-
//renders custom column data for posts
|
253 |
-
$this->loader->add_action("manage_posts_custom_column", $this->plugin_admin, 'render_custom_column_data', 10, 2);
|
254 |
-
|
255 |
-
// add our custom filter selectbox in admin post list box
|
256 |
-
$this->loader->add_action("restrict_manage_posts", $this->plugin_admin, 'restrict_manage_posts');
|
257 |
-
|
258 |
-
// Filter the posts acording to selected filter in post list select box
|
259 |
-
$this->loader->add_filter('posts_join_paged', $this->plugin_admin, 'query_posts_join_custom_filter', 10, 2);
|
260 |
-
|
261 |
-
//render our quick edit box
|
262 |
-
$this->loader->add_action('quick_edit_custom_box', $this->plugin_admin, 'display_custom_quickedit', 10, 2);
|
263 |
-
|
264 |
-
//render our bulk edit box
|
265 |
-
$this->loader->add_action('bulk_edit_custom_box', $this->plugin_admin, 'display_custom_quickedit', 10, 2);
|
266 |
-
|
267 |
-
// print our available visibility type items in footer js
|
268 |
-
// which we will use when sending our data to server in bulk edit save
|
269 |
-
$this->loader->add_action('admin_footer', $this->plugin_admin, 'admin_footer');
|
270 |
-
|
271 |
-
//Save bulk edit data
|
272 |
-
$this->loader->add_action('wp_ajax_save_bulk_edit_data', $this->plugin_admin, 'save_bulk_edit_data');
|
273 |
-
|
274 |
-
$this->loader->add_action('wsa_global_footer', $this->plugin_admin, 'wsa_footer');
|
275 |
-
|
276 |
-
}
|
277 |
-
|
278 |
-
/**
|
279 |
-
* Register all of the hooks related to the public-facing functionality
|
280 |
-
* of the plugin.
|
281 |
-
*
|
282 |
-
* @since 1.2.2
|
283 |
-
* @access private
|
284 |
-
*/
|
285 |
-
private function define_public_hooks()
|
286 |
-
{
|
287 |
-
if (is_admin())
|
288 |
-
{
|
289 |
-
return;
|
290 |
-
}
|
291 |
-
$plugin_public = new wp_hide_post_Public($this->get_wp_hide_post(), $this->get_version());
|
292 |
-
|
293 |
-
$this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_styles');
|
294 |
-
$this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_scripts');
|
295 |
-
// $this->loader->add_filter('get_pages', $plugin_public, 'exclude_low_profile_pages');
|
296 |
-
|
297 |
-
//add where clauss in main filter query
|
298 |
-
$this->loader->add_filter('posts_where_paged', $plugin_public, 'query_posts_where');
|
299 |
-
|
300 |
-
//add join clauss in main filter query
|
301 |
-
$this->loader->add_filter('posts_join_paged', $plugin_public, 'query_posts_join', 10, 2);
|
302 |
-
|
303 |
-
//$this->loader->add_filter('widget_posts_args', $plugin_public, 'widget_posts_args');
|
304 |
-
|
305 |
-
// only for testing purpose , Enables hidepost enabled post type to appear everywhere
|
306 |
-
if (wphp_is_demo())
|
307 |
-
{
|
308 |
-
$this->loader->add_action('pre_get_posts', $plugin_public, 'test_enable_allposts_everywhere');
|
309 |
-
|
310 |
-
}
|
311 |
-
// used to add join clause to remove next and previous rel link of post from single page
|
312 |
-
$this->loader->add_filter('get_next_post_join', $plugin_public, 'post_excluded_terms_join_rel', 10, 1);
|
313 |
-
$this->loader->add_filter('get_previous_post_join', $plugin_public, 'post_excluded_terms_join_rel', 10, 1);
|
314 |
-
|
315 |
-
// used to add where clause to remove next and previous rel link of post from single page
|
316 |
-
$this->loader->add_filter('get_next_post_where', $plugin_public, 'query_posts_where_rel_exclude', 10, 1);
|
317 |
-
$this->loader->add_filter('get_previous_post_where', $plugin_public, 'query_posts_where_rel_exclude', 10, 1);
|
318 |
-
|
319 |
-
}
|
320 |
-
|
321 |
-
/**
|
322 |
-
* Run the loader to execute all of the hooks with WordPress.
|
323 |
-
*
|
324 |
-
* @since 1.2.2
|
325 |
-
*/
|
326 |
-
public function run()
|
327 |
-
{
|
328 |
-
$this->loader->run();
|
329 |
-
}
|
330 |
-
|
331 |
-
/**
|
332 |
-
* The name of the plugin used to uniquely identify it within the context of
|
333 |
-
* WordPress and to define internationalization functionality.
|
334 |
-
*
|
335 |
-
* @since 1.0.0
|
336 |
-
* @return string The name of the plugin.
|
337 |
-
*/
|
338 |
-
public function get_wp_hide_post()
|
339 |
-
{
|
340 |
-
return $this->info('id');
|
341 |
-
}
|
342 |
-
|
343 |
-
public function info($name)
|
344 |
-
{
|
345 |
-
return defined('static::' . $name) ? constant('self::' . $name) : '';
|
346 |
-
}
|
347 |
-
/**
|
348 |
-
* The reference to the class that orchestrates the hooks with the plugin.
|
349 |
-
*
|
350 |
-
* @since 1.0.0
|
351 |
-
* @return wp_hide_post_Loader Orchestrates the hooks of the plugin.
|
352 |
-
*/
|
353 |
-
public function get_loader()
|
354 |
-
{
|
355 |
-
return $this->loader;
|
356 |
-
}
|
357 |
-
|
358 |
-
/**
|
359 |
-
* Retrieve the version number of the plugin.
|
360 |
-
*
|
361 |
-
* @since 1.0.0
|
362 |
-
* @return string The version number of the plugin.
|
363 |
-
*/
|
364 |
-
public function get_version()
|
365 |
-
{
|
366 |
-
return $this->version;
|
367 |
-
}
|
368 |
-
public function init()
|
369 |
-
{
|
370 |
-
$this->settingManager = wphp_settings::instance();
|
371 |
-
wphp_init();
|
372 |
-
}
|
373 |
-
public function define_globals()
|
374 |
-
{
|
375 |
-
|
376 |
-
$this->dir = untrailingslashit(plugin_dir_path(__FILE__)) . DIRECTORY_SEPARATOR;
|
377 |
-
$this->url = plugin_dir_url(__FILE__);
|
378 |
-
|
379 |
-
$this->title = __('WP Hide Post', 'wp_movies');
|
380 |
-
$this->file = __FILE__;
|
381 |
-
$this->basename = apply_filters('scb_plugin_basename', plugin_basename($this->file));
|
382 |
-
}
|
383 |
-
}
|
384 |
-
function wp_hide_post()
|
385 |
-
{
|
386 |
-
return wp_hide_post::getInstance();
|
387 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/helpers.php
DELETED
@@ -1,261 +0,0 @@
|
|
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)
|
141 |
-
{
|
142 |
-
$types = array_flip(wphp_allowed_post_types());
|
143 |
-
unset($types['page']);
|
144 |
-
|
145 |
-
$types = array_flip($types);
|
146 |
-
return !is_admin() && ((in_array($item_type, $types) && !is_single()) || $item_type == 'page');
|
147 |
-
}
|
148 |
-
}
|
149 |
-
if (!function_exists('wphp_init'))
|
150 |
-
{
|
151 |
-
function wphp_init()
|
152 |
-
{
|
153 |
-
global $table_prefix;
|
154 |
-
if (!defined('WPHP_TABLE_NAME'))
|
155 |
-
{
|
156 |
-
define('WPHP_TABLE_NAME', "${table_prefix}postmeta");
|
157 |
-
}
|
158 |
-
|
159 |
-
if (!defined('WP_POSTS_TABLE_NAME'))
|
160 |
-
{
|
161 |
-
define('WP_POSTS_TABLE_NAME', "${table_prefix}posts");
|
162 |
-
}
|
163 |
-
|
164 |
-
if (!defined('WPHP_DEBUG'))
|
165 |
-
{
|
166 |
-
define('WPHP_DEBUG', defined('WP_DEBUG') && WP_DEBUG ? 1 : 0);
|
167 |
-
}
|
168 |
-
|
169 |
-
if (!defined('WPHP_META_VALUE_PREFIX'))
|
170 |
-
{
|
171 |
-
define('WPHP_META_VALUE_PREFIX', '_wphp_');
|
172 |
-
}
|
173 |
-
if (!defined('WPHP_VISIBILITY_NAME'))
|
174 |
-
{
|
175 |
-
define('WPHP_VISIBILITY_NAME', 'wphp_visibility_type');
|
176 |
-
}
|
177 |
-
}
|
178 |
-
}
|
179 |
-
if (!function_exists('wphp_'))
|
180 |
-
{
|
181 |
-
function wphp_($text)
|
182 |
-
{
|
183 |
-
return __($text, 'wp-hide-post');
|
184 |
-
}
|
185 |
-
}
|
186 |
-
if (!function_exists('wphp_is_demo'))
|
187 |
-
{
|
188 |
-
function wphp_is_demo()
|
189 |
-
{
|
190 |
-
return $_SERVER['HTTP_HOST'] == 'wphidepost.loc';
|
191 |
-
}
|
192 |
-
}
|
193 |
-
if (!function_exists('wphp_get_setting'))
|
194 |
-
{
|
195 |
-
function wphp_get_setting($section, $option = false, $default = false)
|
196 |
-
{
|
197 |
-
static $default_setting;
|
198 |
-
if (!$default_setting)
|
199 |
-
{
|
200 |
-
$default_setting = wphp_get_default_setting();
|
201 |
-
}
|
202 |
-
$options = get_option($section);
|
203 |
-
|
204 |
-
if (!$option)
|
205 |
-
{
|
206 |
-
return $options;
|
207 |
-
}
|
208 |
-
if (isset($options[$option]))
|
209 |
-
{
|
210 |
-
return $options[$option];
|
211 |
-
}
|
212 |
-
elseif ($default)
|
213 |
-
{
|
214 |
-
|
215 |
-
if (isset($default_setting[$option]))
|
216 |
-
{
|
217 |
-
return $default_setting[$option];
|
218 |
-
}
|
219 |
-
else
|
220 |
-
{
|
221 |
-
return null;
|
222 |
-
}
|
223 |
-
}
|
224 |
-
else
|
225 |
-
{
|
226 |
-
return null;
|
227 |
-
}
|
228 |
-
}
|
229 |
-
}
|
230 |
-
if (!function_exists('wphp_visibility_types'))
|
231 |
-
{
|
232 |
-
function wphp_visibility_types($joined = false)
|
233 |
-
{
|
234 |
-
static $post_visibility_joined;
|
235 |
-
$post_visibility = wp_hide_post()->pluginAdmin()->get_post_visibility_types();
|
236 |
-
return $post_visibility;
|
237 |
-
if ($joined)
|
238 |
-
{
|
239 |
-
if ($post_visibility_joined)
|
240 |
-
{
|
241 |
-
return $post_visibility_joined;
|
242 |
-
}
|
243 |
-
else
|
244 |
-
{
|
245 |
-
if (!count($post_visibility_joined))
|
246 |
-
{
|
247 |
-
$post_visibility_joined = "";
|
248 |
-
}
|
249 |
-
else
|
250 |
-
{
|
251 |
-
$post_visibility_joined = "in ('" . implode("','", array_keys($post_visibility)) . "')";
|
252 |
-
}
|
253 |
-
return $post_visibility_joined;
|
254 |
-
}
|
255 |
-
}
|
256 |
-
else
|
257 |
-
{
|
258 |
-
return $post_visibility;
|
259 |
-
}
|
260 |
-
}
|
261 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/index.php
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
<?php // Silence is golden
|
|
index.php
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
<?php // Silence is golden
|
|
public/class-wp-hide-post-public.php
DELETED
@@ -1,501 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* The public-facing functionality of the plugin.
|
5 |
-
*
|
6 |
-
* @link http://scriptburn.com
|
7 |
-
* @since 1.2.2
|
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 |
-
|
170 |
-
$where .= ' AND ' . WPHP_TABLE_NAME . '.post_id IS NULL ';
|
171 |
-
|
172 |
-
//echo "\n<!-- WPHP: ".$where." -->\n";
|
173 |
-
return $where;
|
174 |
-
}
|
175 |
-
|
176 |
-
/**
|
177 |
-
*
|
178 |
-
* @param $where
|
179 |
-
* @return unknown_type
|
180 |
-
*/
|
181 |
-
public function query_posts_where($where)
|
182 |
-
{
|
183 |
-
p_l("called: wphp_query_posts_where");
|
184 |
-
// filter posts on one of the three kinds of contexts: front, category, feed
|
185 |
-
if (wphp_is_applicable('post') && wphp_is_applicable('page'))
|
186 |
-
{
|
187 |
-
$where .= ' AND ' . WPHP_TABLE_NAME . '.post_id IS NULL ';
|
188 |
-
}
|
189 |
-
//echo "\n<!-- WPHP: ".$where." -->\n";
|
190 |
-
return $where;
|
191 |
-
}
|
192 |
-
|
193 |
-
//add our custom variablein this filter so in query_posts_join wer will know that the Wp-query
|
194 |
-
// is being called from recent posts widget
|
195 |
-
public function widget_posts_args($posts_args)
|
196 |
-
{
|
197 |
-
$posts_args['wphp_inside_recent_post_sidebar'] = 1;
|
198 |
-
|
199 |
-
return $posts_args;
|
200 |
-
}
|
201 |
-
|
202 |
-
private function get_exclude_join($alias = false, &$wp_query = null)
|
203 |
-
{
|
204 |
-
if (!$alias)
|
205 |
-
{
|
206 |
-
$alias = WP_POSTS_TABLE_NAME;
|
207 |
-
}
|
208 |
-
$join = "";
|
209 |
-
// $join .= ' LEFT JOIN ' . WPHP_TABLE_NAME . ' wphptbl ON ' . WP_POSTS_TABLE_NAME . ".ID = wphptbl.post_id and wphptbl.meta_key like '" . WPHP_META_VALUE_PREFIX . "%'";
|
210 |
-
|
211 |
-
$join .= ' LEFT JOIN ' . WPHP_TABLE_NAME . ' ON ' . $alias . ".ID = " . WPHP_TABLE_NAME . ".post_id and " . WPHP_TABLE_NAME . ".meta_key like '" . WPHP_META_VALUE_PREFIX . "%' and (";
|
212 |
-
// filter posts
|
213 |
-
$can_display = null;
|
214 |
-
$keys = [];
|
215 |
-
$visibility_types_data['post'] = wp_hide_post()->pluginAdmin()->get_visibility_types('post');
|
216 |
-
$visibility_types_data['page'] = wp_hide_post()->pluginAdmin()->get_visibility_types('page');
|
217 |
-
$post_joins = [];
|
218 |
-
foreach ($visibility_types_data as $post_type => $visibility_types)
|
219 |
-
{
|
220 |
-
$post_joins[$post_type][] = $alias . '.' . wphp_allowed_post_types(true);
|
221 |
-
foreach ($visibility_types as $visibility_type => $detail)
|
222 |
-
{
|
223 |
-
$parameters = array($join, $wp_query, isset($wp_query->query['wphp_inside_recent_post_sidebar']) ? 1 : 0);
|
224 |
-
$condition = !empty($detail['condition']) ? $detail['condition'] : $visibility_type;
|
225 |
-
$callbacks = [];
|
226 |
-
if (!empty($detail['condition_callback']))
|
227 |
-
{
|
228 |
-
$callbacks[] = $detail['condition_callback'];
|
229 |
-
}
|
230 |
-
$callbacks[] = 'wphp_is_' . $condition . "_" . $post_type;
|
231 |
-
|
232 |
-
foreach ($callbacks as $callback)
|
233 |
-
{
|
234 |
-
if ($callback)
|
235 |
-
{
|
236 |
-
|
237 |
-
if (is_callable($callback))
|
238 |
-
{
|
239 |
-
$ret = $callback($join, $wp_query);
|
240 |
-
// p_n("$callback-" . ($ret ? 1 : 0));
|
241 |
-
if ($ret)
|
242 |
-
{
|
243 |
-
$keys[] = sprintf('%1$s%2$s', WPHP_META_VALUE_PREFIX, $condition);
|
244 |
-
break;
|
245 |
-
}
|
246 |
-
}
|
247 |
-
}
|
248 |
-
}
|
249 |
-
}
|
250 |
-
|
251 |
-
if (!count($keys))
|
252 |
-
{
|
253 |
-
$post_joins[$post_type][] = sprintf(WPHP_TABLE_NAME . '.meta_key not like "%1$s"', WPHP_META_VALUE_PREFIX);
|
254 |
-
}
|
255 |
-
else
|
256 |
-
{
|
257 |
-
$post_joins[$post_type][] = sprintf(WPHP_TABLE_NAME . '.meta_key in ( %1$s)', "'" . implode("','", $keys) . "'");
|
258 |
-
}
|
259 |
-
}
|
260 |
-
foreach ($post_joins as $post_type => $joins)
|
261 |
-
{
|
262 |
-
$post_joins[$post_type] = "( " . implode(" and ", $joins) . ")";
|
263 |
-
}
|
264 |
-
|
265 |
-
$join .= implode(" OR ", $post_joins) . ")";
|
266 |
-
|
267 |
-
return $join;
|
268 |
-
}
|
269 |
-
/**
|
270 |
-
*
|
271 |
-
* @param $join
|
272 |
-
* @return unknown_type
|
273 |
-
*/
|
274 |
-
public function query_posts_join($join, &$wp_query)
|
275 |
-
{
|
276 |
-
//p_n($wp_query);
|
277 |
-
//p_n($wp_query);
|
278 |
-
|
279 |
-
if (isset($wp_query->query['wphp_inside_recent_post_sidebar']))
|
280 |
-
{
|
281 |
-
//p_n($wp_query);
|
282 |
-
}
|
283 |
-
|
284 |
-
p_l("called: wphp_query_posts_join");
|
285 |
-
if (wphp_is_applicable('post') && wphp_is_applicable('page'))
|
286 |
-
{
|
287 |
-
if (!$join)
|
288 |
-
{
|
289 |
-
$join = '';
|
290 |
-
}
|
291 |
-
|
292 |
-
$join .= $this->get_exclude_join(WP_POSTS_TABLE_NAME, $wp_query);
|
293 |
-
|
294 |
-
}
|
295 |
-
|
296 |
-
return $join;
|
297 |
-
}
|
298 |
-
/**
|
299 |
-
*
|
300 |
-
* @param $join
|
301 |
-
* @return unknown_type
|
302 |
-
*/
|
303 |
-
public function query_posts_join3($join, &$wp_query)
|
304 |
-
{
|
305 |
-
//p_n($wp_query);
|
306 |
-
//p_n($wp_query);
|
307 |
-
|
308 |
-
if (isset($wp_query->query['wphp_inside_recent_post_sidebar']))
|
309 |
-
{
|
310 |
-
//p_n($wp_query);
|
311 |
-
}
|
312 |
-
|
313 |
-
p_l("called: wphp_query_posts_join");
|
314 |
-
if (wphp_is_applicable('post') && wphp_is_applicable('page'))
|
315 |
-
{
|
316 |
-
if (!$join)
|
317 |
-
{
|
318 |
-
$join = '';
|
319 |
-
}
|
320 |
-
|
321 |
-
// $join .= ' LEFT JOIN ' . WPHP_TABLE_NAME . ' wphptbl ON ' . WP_POSTS_TABLE_NAME . ".ID = wphptbl.post_id and wphptbl.meta_key like '" . WPHP_META_VALUE_PREFIX . "%'";
|
322 |
-
|
323 |
-
$join .= ' LEFT JOIN ' . WPHP_TABLE_NAME . ' wphptbl ON ' . WP_POSTS_TABLE_NAME . ".ID = wphptbl.post_id ";
|
324 |
-
// filter posts
|
325 |
-
$join .= ' AND ((' . WP_POSTS_TABLE_NAME . '.' . wphp_allowed_post_types(true);
|
326 |
-
$can_display = null;
|
327 |
-
$keys = [];
|
328 |
-
foreach (wphp_visibility_types() as $visibility_type => $detail)
|
329 |
-
{
|
330 |
-
$parameters = array($join, $wp_query, isset($wp_query->query['wphp_inside_recent_post_sidebar']) ? 1 : 0);
|
331 |
-
$condition = !empty($detail['condition']) ? $detail['condition'] : $visibility_type;
|
332 |
-
$callbacks = [];
|
333 |
-
if (!empty($detail['condition_callback']))
|
334 |
-
{
|
335 |
-
$callbacks[] = $detail['condition_callback'];
|
336 |
-
}
|
337 |
-
$callbacks[] = 'wphp_is_' . $condition;
|
338 |
-
|
339 |
-
foreach ($callbacks as $callback)
|
340 |
-
{
|
341 |
-
if ($callback)
|
342 |
-
{
|
343 |
-
|
344 |
-
if (is_callable($callback))
|
345 |
-
{
|
346 |
-
$ret = $callback($join, $wp_query);
|
347 |
-
// p_n("$callback-" . ($ret ? 1 : 0));
|
348 |
-
if ($ret)
|
349 |
-
{
|
350 |
-
$keys[] = sprintf('%1$s%2$s', WPHP_META_VALUE_PREFIX, $condition);
|
351 |
-
break;
|
352 |
-
}
|
353 |
-
}
|
354 |
-
}
|
355 |
-
}
|
356 |
-
|
357 |
-
}
|
358 |
-
if (!count($keys))
|
359 |
-
{
|
360 |
-
$join .= sprintf(' AND wphptbl.meta_key not like "%1$s"', WPHP_META_VALUE_PREFIX);
|
361 |
-
}
|
362 |
-
else
|
363 |
-
{
|
364 |
-
$join .= sprintf(' AND wphptbl.meta_key in ( %1$s)', "'" . implode("','", $keys) . "'");
|
365 |
-
}
|
366 |
-
|
367 |
-
$join .= ')';
|
368 |
-
// pages
|
369 |
-
$join .= ' OR (' . WP_POSTS_TABLE_NAME . ".post_type = 'page' AND wphptbl.meta_key <> '" . WPHP_META_VALUE_PREFIX . "page_flags'";
|
370 |
-
if (wphp_is_post_search_post())
|
371 |
-
{
|
372 |
-
$join .= " AND wphptbl.meta_key = '" . WPHP_META_VALUE_PREFIX . "page_search' ";
|
373 |
-
}
|
374 |
-
else
|
375 |
-
{
|
376 |
-
$join .= " AND wphptbl.meta_key not like '" . WPHP_META_VALUE_PREFIX . "%' ";
|
377 |
-
}
|
378 |
-
|
379 |
-
$join .= '))';
|
380 |
-
}
|
381 |
-
//echo "\n<!-- WPHP: ".$join." -->\n";
|
382 |
-
if (isset($wp_query->query['wphp_inside_recent_post_sidebar']))
|
383 |
-
{
|
384 |
-
// p_n($join);
|
385 |
-
}
|
386 |
-
|
387 |
-
return $join;
|
388 |
-
}
|
389 |
-
/**
|
390 |
-
*
|
391 |
-
* @param $join
|
392 |
-
* @return unknown_type
|
393 |
-
*/
|
394 |
-
public function query_posts_join1($join)
|
395 |
-
{
|
396 |
-
|
397 |
-
p_l("called: wphp_query_posts_join");
|
398 |
-
if (wphp_is_applicable('post') && wphp_is_applicable('page'))
|
399 |
-
{
|
400 |
-
if (!$join)
|
401 |
-
{
|
402 |
-
$join = '';
|
403 |
-
}
|
404 |
-
|
405 |
-
$join .= ' LEFT JOIN ' . WPHP_TABLE_NAME . ' wphptbl ON ' . WP_POSTS_TABLE_NAME . ".ID = wphptbl.post_id and wphptbl.meta_key like '" . WPHP_META_VALUE_PREFIX . "%'";
|
406 |
-
// filter posts
|
407 |
-
$join .= ' AND ((' . WP_POSTS_TABLE_NAME . '.' . wphp_allowed_post_types(true);
|
408 |
-
|
409 |
-
if (wphp_is_post_front())
|
410 |
-
{
|
411 |
-
$join .= ' AND wphptbl.meta_key = \'_wplp_post_front\' ';
|
412 |
-
}
|
413 |
-
elseif (wphp_is_post_category())
|
414 |
-
{
|
415 |
-
$join .= ' AND wphptbl.meta_key = \'_wplp_post_category\' ';
|
416 |
-
}
|
417 |
-
elseif (wphp_is_post_tag())
|
418 |
-
{
|
419 |
-
$join .= ' AND wphptbl.meta_key = \'_wplp_post_tag\' ';
|
420 |
-
}
|
421 |
-
elseif (wphp_is_post_author())
|
422 |
-
{
|
423 |
-
$join .= ' AND wphptbl.meta_key = \'_wplp_post_author\' ';
|
424 |
-
}
|
425 |
-
elseif (wphp_is_post_archive())
|
426 |
-
{
|
427 |
-
$join .= ' AND wphptbl.meta_key = \'_wplp_post_archive\' ';
|
428 |
-
}
|
429 |
-
elseif (wphp_is_post_feed())
|
430 |
-
{
|
431 |
-
$join .= ' AND wphptbl.meta_key = \'_wplp_post_feed\' ';
|
432 |
-
}
|
433 |
-
elseif (wphp_is_post_search())
|
434 |
-
{
|
435 |
-
$join .= ' AND wphptbl.meta_key = \'_wplp_post_search\' ';
|
436 |
-
}
|
437 |
-
else
|
438 |
-
{
|
439 |
-
$join .= ' AND wphptbl.meta_key not like \'_wplp_%\' ';
|
440 |
-
}
|
441 |
-
|
442 |
-
$join .= ')';
|
443 |
-
// pages
|
444 |
-
$join .= ' OR (' . WP_POSTS_TABLE_NAME . '.post_type = \'page\' AND wphptbl.meta_key <> \'_wplp_page_flags\'';
|
445 |
-
if (wphp_is_post_search())
|
446 |
-
{
|
447 |
-
$join .= ' AND wphptbl.meta_key = \'_wplp_page_search\' ';
|
448 |
-
}
|
449 |
-
else
|
450 |
-
{
|
451 |
-
$join .= ' AND wphptbl.meta_key not like \'_wplp_%\' ';
|
452 |
-
}
|
453 |
-
|
454 |
-
$join .= '))';
|
455 |
-
}
|
456 |
-
p_d($join);
|
457 |
-
//echo "\n<!-- WPHP: ".$join." -->\n";
|
458 |
-
return $join;
|
459 |
-
}
|
460 |
-
|
461 |
-
public function post_excluded_terms_join_rel($join)
|
462 |
-
{
|
463 |
-
//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
|
464 |
-
$join .= $this->get_exclude_join('p');
|
465 |
-
return $join;
|
466 |
-
}
|
467 |
-
public function test_enable_allposts_everywhere($query)
|
468 |
-
{
|
469 |
-
|
470 |
-
// Only filter the main query on the front-end
|
471 |
-
if (is_admin() || !$query->is_main_query())
|
472 |
-
{
|
473 |
-
return;
|
474 |
-
}
|
475 |
-
|
476 |
-
global $wp;
|
477 |
-
$front = false;
|
478 |
-
|
479 |
-
// If the latest posts are showing on the home page
|
480 |
-
if ((is_home() && empty($wp->query_string)))
|
481 |
-
{
|
482 |
-
$front = true;
|
483 |
-
}
|
484 |
-
|
485 |
-
// If a static page is set as the home page
|
486 |
-
if (($query->get('page_id') == get_option('page_on_front') && get_option('page_on_front')) || empty($wp->query_string))
|
487 |
-
{
|
488 |
-
$front = true;
|
489 |
-
}
|
490 |
-
|
491 |
-
if ($front || is_archive())
|
492 |
-
{
|
493 |
-
|
494 |
-
$query->set('post_type', wphp_allowed_post_types());
|
495 |
-
|
496 |
-
}
|
497 |
-
//endif;
|
498 |
-
return $query;
|
499 |
-
|
500 |
-
}
|
501 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public/css/plugin-name-public.css
DELETED
@@ -1,4 +0,0 @@
|
|
1 |
-
/**
|
2 |
-
* All of the CSS for your public-facing functionality should be
|
3 |
-
* included in this file.
|
4 |
-
*/
|
|
|
|
|
|
|
|
public/index.php
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
<?php // Silence is golden
|
|
public/js/wp-hide-post-public.js
DELETED
@@ -1,32 +0,0 @@
|
|
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
DELETED
@@ -1,16 +0,0 @@
|
|
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 1.2.2
|
10 |
-
*
|
11 |
-
* @package wp_hide_post
|
12 |
-
* @subpackage wp_hide_post/public/partials
|
13 |
-
*/
|
14 |
-
?>
|
15 |
-
|
16 |
-
<!-- This file should primarily consist of HTML with a little bit of PHP. -->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
readme.txt
CHANGED
@@ -1,177 +1,106 @@
|
|
1 |
-
=== WP Hide Post ===
|
2 |
-
Contributors: scriptburn
|
3 |
-
Donate link: http://
|
4 |
-
Tags: SEO,hide,show,visbility,privacy,customization,sitemap,filter
|
5 |
-
Requires at least: 2.6
|
6 |
-
Tested up to: 4.
|
7 |
-
Stable tag: 2.
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
* The
|
19 |
-
* The
|
20 |
-
* The
|
21 |
-
* The
|
22 |
-
* The
|
23 |
-
*
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
* Hide a page
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
1.
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
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.2 =
|
115 |
-
*Release Date - 12 August 2016*
|
116 |
-
|
117 |
-
* Fixed an issue which was displaying error when activating the plugin
|
118 |
-
|
119 |
-
= 2.0 =
|
120 |
-
*Release Date - 11 August 2016*
|
121 |
-
|
122 |
-
* Fix to include Blog page when Hide on the front page option is checked.
|
123 |
-
* Added Quick Edit option for post and page in post list page.
|
124 |
-
* Added Bulk Edit option for post and page in post list page.
|
125 |
-
* Added Search for hidden post option in post list page.
|
126 |
-
* Added a new column “Hidden On” in post list page.
|
127 |
-
* Added “Check all” Option in hide post widget to select all options at once in post or custom post type page.
|
128 |
-
* Added a setting option in setting page where you can select what on which post type you want to show hide post widget.
|
129 |
-
* Added a setting option in setting page where you can choose whether to show hide post widest in quick edit mode or not
|
130 |
-
|
131 |
-
|
132 |
-
= 1.1.9 =
|
133 |
-
*Release Date - 16 July 2015*
|
134 |
-
|
135 |
-
* Compatibility with Wordpress 4.2.2
|
136 |
-
|
137 |
-
= 1.1.4 =
|
138 |
-
*Release Date - 24 October 2009*
|
139 |
-
|
140 |
-
* Added compatibility with Wordpress 2.8.5
|
141 |
-
|
142 |
-
= 1.1.3 =
|
143 |
-
*Release Date - 07 August 2009*
|
144 |
-
|
145 |
-
* Extended support for Wordpress 2.6
|
146 |
-
|
147 |
-
= 1.1.2 =
|
148 |
-
*Release Date - 07 August 2009*
|
149 |
-
|
150 |
-
* Bug fixes.
|
151 |
-
|
152 |
-
= 1.1.1 =
|
153 |
-
*Release Date - 05 August 2009*
|
154 |
-
|
155 |
-
* Reduce the number of SQL queries to hide pages to a single queries for all pages, rather than one query per page.
|
156 |
-
|
157 |
-
= 1.1.0 =
|
158 |
-
*Release Date - 04 August 2009*
|
159 |
-
|
160 |
-
* Bug fix: bulk update clears "Visibility Attributes". Split code into separate files.
|
161 |
-
|
162 |
-
= 1.0.4 =
|
163 |
-
*Release Date - 24 July 2009*
|
164 |
-
|
165 |
-
= 1.0.3 =
|
166 |
-
*Release Date - 24 July 2009*
|
167 |
-
|
168 |
-
* Initial public release of 'WP Hide Post' and deprecation of 'WP low Profiler'
|
169 |
-
|
170 |
-
|
171 |
-
* Minor bug fixes
|
172 |
-
== Development Blog ==
|
173 |
-
|
174 |
-
Please visit the plugin page at [ScriptBurn.com](http://scriptburn.com/wp-hide-post/), and feel free to leave feedback, bug reports and comments.
|
175 |
-
|
176 |
-
== Upgrade Notice ==
|
177 |
-
n/a
|
1 |
+
=== WP Hide Post ===
|
2 |
+
Contributors: scriptburn
|
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: 4.2.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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
screenshot-1.png
CHANGED
Binary file
|
screenshot-10.png
DELETED
Binary file
|
screenshot-11.png
DELETED
Binary file
|
screenshot-2.png
CHANGED
Binary file
|
screenshot-3.png
CHANGED
Binary file
|
screenshot-4.png
CHANGED
Binary file
|
screenshot-5.png
DELETED
Binary file
|
screenshot-6.png
DELETED
Binary file
|
screenshot-7.png
DELETED
Binary file
|
screenshot-8.png
DELETED
Binary file
|
screenshot-9.png
DELETED
Binary file
|
uninstall.php
DELETED
@@ -1,31 +0,0 @@
|
|
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 1.2.2
|
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
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* Copyright 2015 Scriptburn (email : support@scriptburn.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
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* Copyright 2015 scriptburn (email : support@scriptburn.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,81 +1,546 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
{
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
/**
|
46 |
-
*
|
47 |
-
*
|
48 |
-
|
49 |
-
|
50 |
-
{
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
*
|
73 |
-
|
74 |
-
|
75 |
-
{
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 Scriptburn (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&plugin=wp-hide-post&TB_iframe=true&width=600&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); ?>/> <?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); ?>/> <?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); ?>/> <?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); ?>/> <?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); ?>/> <?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); ?>/> <?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); ?>/> <?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'); ?>/> <?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'); ?>/> <?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'); ?>/> <?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); ?>/> <?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 |
+
?>
|
languages/wp-hide-post.pot → wp-hide-post.pot
RENAMED
File without changes
|