Version Description
Release Date - 30 July 2017
*Fix: An issue that prevented system info file download
Download this release
Release Info
Developer | rmahfoud |
Plugin | WP Hide Post |
Version | 2.0.4 |
Comparing to | |
See all releases |
Code changes from version 2.0.2 to 2.0.4
- .gitignore +0 -1
- admin/class-wp-hide-post-admin.php +217 -142
- admin/class-wp-hide-post-dbupdate.php +203 -0
- admin/conditions.php +29 -13
- admin/css/wp-hide-post-admin.css +20 -0
- admin/license/LicenseItem.php +119 -46
- admin/license/LicenseManager.php +9 -6
- admin/license/autoload.php +8 -9
- admin/license/encryption.php +85 -0
- admin/partials/quick-edit-display.php +2 -1
- admin/plugin/EDD_SL_Plugin_Updater.php +384 -0
- admin/plugin/EDD_SL_Theme_Updater.php +142 -0
- admin/plugin/SCB_Item_Helper.php +189 -0
- admin/plugin/autoload.php +15 -0
- admin/plugin/testlog.txt +14 -0
- admin/settings/assets/chosen-sprite@2x.png +0 -0
- admin/settings/autoload.php +240 -1
- admin/settings/browser.php +1102 -0
- admin/settings/class_settings.php +259 -88
- admin/settings/class_settingsAPI.php +18 -5
- admin/settings/class_settingsAPICustom.php +71 -8
- includes/class-wp-hide-post-activator.php +12 -69
- includes/class-wp-hide-post-deactivator.php +2 -2
- includes/class-wp-hide-post-i18n.php +2 -2
- includes/class-wp-hide-post-loader.php +1 -1
- includes/class-wp-hide-post.php +129 -31
- includes/helpers.php +203 -23
- public/class-wp-hide-post-public.php +78 -193
- public/partials/wp-hide-post-public-display.php +1 -2
- readme.txt +13 -2
- uninstall.php +1 -1
- wp-hide-post.php +38 -5
.gitignore
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
ignore
|
|
admin/class-wp-hide-post-admin.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* The admin-specific functionality of the plugin.
|
5 |
*
|
6 |
* @link http://scriptburn.com
|
7 |
-
* @since
|
8 |
*
|
9 |
* @package wp_hide_post
|
10 |
* @subpackage wp_hide_post/admin
|
@@ -54,6 +54,8 @@ class wp_hide_post_Admin
|
|
54 |
|
55 |
private $page_visibility_types;
|
56 |
private $info;
|
|
|
|
|
57 |
/**
|
58 |
* Initialize the class and set its properties.
|
59 |
*
|
@@ -61,22 +63,23 @@ class wp_hide_post_Admin
|
|
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
|
71 |
if (!is_array($this->post_types))
|
72 |
{
|
73 |
-
$this->post_types =
|
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);
|
@@ -84,9 +87,9 @@ class wp_hide_post_Admin
|
|
84 |
return $this->post_types;
|
85 |
}
|
86 |
|
87 |
-
public function
|
88 |
{
|
89 |
-
$post_types =
|
90 |
|
91 |
foreach ($this->allowedPostTypes() as $post_type)
|
92 |
{
|
@@ -157,10 +160,6 @@ class wp_hide_post_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';
|
@@ -227,61 +226,60 @@ HTML;
|
|
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 |
-
|
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
|
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;
|
@@ -295,29 +293,26 @@ HTML;
|
|
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;
|
@@ -352,7 +347,7 @@ HTML;
|
|
352 |
}
|
353 |
if ((int) $_POST[WPHP_VISIBILITY_NAME . "_old"][$index] != $_POST[WPHP_VISIBILITY_NAME][$index] || $is_bulk)
|
354 |
{
|
355 |
-
|
356 |
$this->update_visibility(
|
357 |
$post_id,
|
358 |
$index,
|
@@ -370,7 +365,7 @@ HTML;
|
|
370 |
*/
|
371 |
public function save_post($id)
|
372 |
{
|
373 |
-
|
374 |
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
|
375 |
{
|
376 |
return $id;
|
@@ -379,7 +374,7 @@ HTML;
|
|
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 |
-
|
383 |
return $id;
|
384 |
}
|
385 |
|
@@ -391,6 +386,7 @@ HTML;
|
|
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();
|
@@ -553,16 +549,16 @@ HTML;
|
|
553 |
{
|
554 |
$(document).ready(function()
|
555 |
{
|
556 |
-
$("
|
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="
|
565 |
-
<input type="checkbox"
|
566 |
|
567 |
Check All
|
568 |
|
@@ -579,7 +575,7 @@ HTML;
|
|
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 |
{
|
@@ -597,7 +593,7 @@ HTML;
|
|
597 |
);
|
598 |
$index++;
|
599 |
}
|
600 |
-
return (implode("\n", $pre) . implode("", $html) . ($meta_box ? $this->
|
601 |
|
602 |
}
|
603 |
|
@@ -610,26 +606,9 @@ HTML;
|
|
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(
|
@@ -665,17 +644,20 @@ HTML;
|
|
665 |
}
|
666 |
public function register_setting_page()
|
667 |
{
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
$
|
672 |
-
foreach ((array) $this->list_custom_post_types() as $type => $detail)
|
673 |
{
|
674 |
-
$detail
|
675 |
-
|
676 |
-
|
|
|
|
|
|
|
|
|
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'),
|
@@ -685,22 +667,40 @@ HTML;
|
|
685 |
'placeholder' => 'Select custom post type',
|
686 |
),
|
687 |
array('name' => 'show_in_quickedit',
|
688 |
-
'label' => wphp_('
|
689 |
-
'desc' => wphp_('
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
690 |
'type' => 'yesno',
|
691 |
'default' => 1,
|
|
|
692 |
),
|
693 |
));
|
694 |
}
|
695 |
|
696 |
public function admin_menu()
|
697 |
{
|
698 |
-
|
699 |
-
add_submenu_page('options-general.php', wphp_('WP Hide Post'), wphp_("WP Hide Post"), 'manage_options',
|
700 |
}
|
701 |
public function register_plugin($licenses)
|
702 |
{
|
703 |
-
$licenses[] =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
704 |
|
705 |
return $licenses;
|
706 |
}
|
@@ -714,7 +714,7 @@ HTML;
|
|
714 |
wphp_hide_on_data['visibility_types']=[]
|
715 |
<?php
|
716 |
|
717 |
-
foreach (
|
718 |
{
|
719 |
echo (" wphp_hide_on_data['visibility_types']['$post_type']=[];\n");
|
720 |
|
@@ -744,22 +744,22 @@ HTML;
|
|
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 :
|
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)
|
@@ -767,7 +767,7 @@ HTML;
|
|
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']))
|
@@ -782,7 +782,7 @@ HTML;
|
|
782 |
$data[$visibility_type] = empty($item['value']) ? 0 : (int) $item['value'];
|
783 |
}
|
784 |
}
|
785 |
-
$items =
|
786 |
|
787 |
$items[] = sprintf('<input type="hidden" class="wphp_hidden_on" value="%2$s" />', $post_id, urlencode(json_encode($data)));
|
788 |
|
@@ -793,18 +793,26 @@ HTML;
|
|
793 |
}
|
794 |
|
795 |
}
|
796 |
-
|
797 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
798 |
public function display_custom_quickedit($column_name, $post_type)
|
799 |
{
|
|
|
800 |
|
801 |
-
if (
|
802 |
{
|
803 |
-
|
804 |
return;
|
805 |
}
|
806 |
|
807 |
-
|
|
|
808 |
{
|
809 |
|
810 |
return;
|
@@ -817,23 +825,26 @@ HTML;
|
|
817 |
}
|
818 |
|
819 |
static $printNonce;
|
|
|
820 |
if (!$printNonce)
|
821 |
{
|
822 |
-
$
|
|
|
|
|
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 |
-
|
837 |
foreach ($this->get_visibility_types($post_type) as $type => $detail)
|
838 |
{
|
839 |
$detail['value'] = empty($detail['value']) ? 0 : (int) $detail['value'];
|
@@ -846,37 +857,38 @@ HTML;
|
|
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 |
-
$("
|
861 |
{
|
862 |
-
$(".wphp_multicheck").prop("checked", $(this).prop("checked"));
|
863 |
});
|
864 |
});
|
865 |
})(jQuery);</script>';
|
866 |
-
|
867 |
|
868 |
-
|
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 |
}
|
@@ -890,7 +902,7 @@ HTML;
|
|
890 |
{
|
891 |
return;
|
892 |
}
|
893 |
-
$values =
|
894 |
if (!$js_var)
|
895 |
{
|
896 |
echo ("\n<script>\n var wphp_hide_on_data=[]; \n
|
@@ -943,13 +955,13 @@ HTML;
|
|
943 |
}
|
944 |
$values = $this->get_visibility_types($type);
|
945 |
|
946 |
-
$values['all'] =
|
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 :
|
953 |
|
954 |
foreach ($values as $visibility_type => $item)
|
955 |
{
|
@@ -981,15 +993,16 @@ $current_v = isset($_GET['wphp_hidden_on']) ? $_GET['wphp_hidden_on'] : [];
|
|
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 |
-
|
992 |
-
$current_v =
|
|
|
993 |
|
994 |
$join .= ' inner JOIN ' . WPHP_TABLE_NAME . ' wphptbl ON ' . WP_POSTS_TABLE_NAME . ".ID = wphptbl.post_id ";
|
995 |
|
@@ -1007,27 +1020,64 @@ $current_v = isset($_GET['wphp_hidden_on']) ? $_GET['wphp_hidden_on'] : [];
|
|
1007 |
$join .= " AND wphptbl.meta_key in ('" . implode("','", $current_v) . "') ";
|
1008 |
|
1009 |
}
|
1010 |
-
|
1011 |
return $join;
|
1012 |
|
1013 |
}
|
1014 |
-
public function
|
1015 |
{
|
1016 |
$info = get_transient('wphp_notices_' . $page);
|
|
|
1017 |
if (!$info)
|
1018 |
{
|
1019 |
|
1020 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1021 |
|
1022 |
if (is_array($response) && !empty($response['body']))
|
1023 |
{
|
1024 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1025 |
set_transient('wphp_notices_' . $page, $info, 86400);
|
1026 |
}
|
|
|
|
|
|
|
|
|
1027 |
else
|
1028 |
{
|
1029 |
|
1030 |
-
$info = '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1031 |
<div>
|
1032 |
<div style="float:left">
|
1033 |
<a href="http://scriptburn.com/wp-hide-post/#comments">
|
@@ -1039,27 +1089,52 @@ $current_v = isset($_GET['wphp_hidden_on']) ? $_GET['wphp_hidden_on'] : [];
|
|
1039 |
%2$s
|
1040 |
</a>
|
1041 |
</div>
|
1042 |
-
</div><div style="clear:both">
|
1043 |
<div style="text-align:center">
|
1044 |
-
<a href="http://
|
1045 |
-
<img src="
|
1046 |
</a>
|
1047 |
</div>
|
1048 |
<div style="clear:both">
|
1049 |
</div>
|
1050 |
';
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
}
|
1056 |
-
}
|
1057 |
-
return $info;
|
1058 |
|
1059 |
}
|
1060 |
public function wsa_footer()
|
1061 |
{
|
1062 |
|
1063 |
-
echo $this->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1064 |
}
|
|
|
1065 |
}
|
4 |
* The admin-specific functionality of the plugin.
|
5 |
*
|
6 |
* @link http://scriptburn.com
|
7 |
+
* @since 2.0
|
8 |
*
|
9 |
* @package wp_hide_post
|
10 |
* @subpackage wp_hide_post/admin
|
54 |
|
55 |
private $page_visibility_types;
|
56 |
private $info;
|
57 |
+
private $license;
|
58 |
+
private $item_url = 'http://scriptburn.com/downloads/wp-hide-post/';
|
59 |
/**
|
60 |
* Initialize the class and set its properties.
|
61 |
*
|
63 |
* @param string $wp_hide_post The name of this plugin.
|
64 |
* @param string $version The version of this plugin.
|
65 |
*/
|
66 |
+
public function __construct($wp_hide_post, $version, $license)
|
67 |
{
|
68 |
+
//p_d($license->is_valid(),1);
|
69 |
$this->wp_hide_post = $wp_hide_post;
|
70 |
$this->version = $version;
|
71 |
+
$this->license = $license;
|
72 |
+
$this->post_types = $this->license->is_valid() ? wphp_get_setting('wphp_gen', 'wphp_post_types') : false;
|
73 |
if (!is_array($this->post_types))
|
74 |
{
|
75 |
+
$this->post_types = array('post', 'page');
|
76 |
}
|
77 |
|
78 |
return $this;
|
79 |
}
|
80 |
public function allowedPostTypes($post_type = null)
|
81 |
{
|
82 |
+
|
83 |
if (!is_null($post_type))
|
84 |
{
|
85 |
return in_array($post_type, $this->post_types);
|
87 |
return $this->post_types;
|
88 |
}
|
89 |
|
90 |
+
public function plugin_init1()
|
91 |
{
|
92 |
+
$post_types = scb_custom_post_types();
|
93 |
|
94 |
foreach ($this->allowedPostTypes() as $post_type)
|
95 |
{
|
160 |
{
|
161 |
wp_enqueue_script('jquery-ui-dialog');
|
162 |
wp_enqueue_script('jquery-ui-tabs');
|
|
|
|
|
|
|
|
|
163 |
|
164 |
$ui = $wp_scripts->query('jquery-ui-core');
|
165 |
$protocol = is_ssl() ? 'https' : 'http';
|
226 |
{
|
227 |
return $this->post_visibility_types;
|
228 |
}
|
229 |
+
$this->post_visibility_types = array(
|
230 |
+
'post_front' => array(
|
|
|
231 |
'label' => wphp_('Hide on the front page.'),
|
232 |
'short_label' => 'Front page',
|
233 |
'description' => '',
|
234 |
+
),
|
235 |
+
'post_category' => array(
|
|
|
236 |
'label' => wphp_('Hide on category pages.'),
|
237 |
'short_label' => 'Category pages',
|
238 |
'description' => '',
|
239 |
+
),
|
240 |
+
'post_tag' => array(
|
|
|
241 |
'label' => wphp_('Hide on tag pages.'),
|
242 |
'short_label' => 'Tag pages',
|
243 |
'description' => '',
|
244 |
|
245 |
+
),
|
246 |
+
'post_author' => array(
|
|
|
247 |
'label' => wphp_('Hide on author pages.'),
|
248 |
'short_label' => 'Author pages',
|
249 |
'description' => '',
|
250 |
|
251 |
+
),
|
252 |
+
'post_archive' => array(
|
|
|
253 |
'label' => wphp_('Hide in date archives (month, day, year, etc...) '),
|
254 |
'short_label' => 'Archives',
|
255 |
'description' => '',
|
256 |
|
257 |
+
),
|
258 |
+
'post_search' => array(
|
|
|
259 |
'label' => wphp_('Hide in search results. '),
|
260 |
'short_label' => 'Search results',
|
261 |
'description' => '',
|
262 |
|
263 |
+
),
|
264 |
+
'post_feed' => array(
|
|
|
265 |
'label' => wphp_('Hide in feeds.'),
|
266 |
'short_label' => 'Feeds',
|
267 |
'description' => '',
|
268 |
+
),
|
269 |
+
|
270 |
+
'post_recent' => array(
|
271 |
+
'label' => wphp_('Hide in Wp Native Recent post widget.'),
|
272 |
+
'short_label' => 'Recent post',
|
273 |
+
'description' => '',
|
274 |
+
'no_auto_join' => true,
|
275 |
+
),
|
276 |
+
'post_rel' => array(
|
277 |
'label' => wphp_('Remove from next previous rel link'),
|
278 |
'short_label' => 'Meta rel link',
|
279 |
+
'description' => 'Remove post from Meta rel link In Single Post page<div style="background:green;color:white;padding:5px">' . htmlentities("<link rel='prev' title='Post title previous' href='http://your-previous-post-url' />") . '</div><div style="background:green;color:white;padding:5px">' . htmlentities("<link rel='next' title='Post title next' href='http://your-next-post-url' />") . '</div><div></div>',
|
280 |
+
),
|
281 |
|
282 |
+
);
|
283 |
$this->post_visibility_types = apply_filters('wphp_post_visibility_types', $this->post_visibility_types);
|
284 |
|
285 |
return $this->post_visibility_types;
|
293 |
{
|
294 |
return $this->page_visibility_types;
|
295 |
}
|
296 |
+
$this->page_visibility_types = array(
|
297 |
|
298 |
+
'hide_frontpage' => array(
|
|
|
299 |
'label' => wphp_('Hide when listing pages on the front page. '),
|
300 |
'short_label' => 'Front page',
|
301 |
'description' => '',
|
302 |
+
),
|
303 |
+
'hide_always' => array(
|
|
|
304 |
'label' => wphp_('Hide everywhere pages are listed.'),
|
305 |
'short_label' => 'Always',
|
306 |
'description' => 'Will still show up in sitemap.xml if you generate one automatically',
|
307 |
|
308 |
+
),
|
309 |
+
'nohide_search' => array(
|
|
|
310 |
'label' => wphp_('Hide everywhere but keep in search results.'),
|
311 |
'short_label' => 'Hide but keep in search',
|
312 |
'description' => 'Will still show up in sitemap.xml if you generate one automatically',
|
313 |
|
314 |
+
),
|
315 |
+
);
|
316 |
$this->page_visibility_types = apply_filters('wphp_page_visibility_types', $this->page_visibility_types);
|
317 |
|
318 |
return $this->page_visibility_types;
|
347 |
}
|
348 |
if ((int) $_POST[WPHP_VISIBILITY_NAME . "_old"][$index] != $_POST[WPHP_VISIBILITY_NAME][$index] || $is_bulk)
|
349 |
{
|
350 |
+
p_l("$post_id,$index," . $_POST[WPHP_VISIBILITY_NAME][$index]);
|
351 |
$this->update_visibility(
|
352 |
$post_id,
|
353 |
$index,
|
365 |
*/
|
366 |
public function save_post($id)
|
367 |
{
|
368 |
+
p_l("save_post");
|
369 |
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
|
370 |
{
|
371 |
return $id;
|
374 |
|
375 |
if (empty($_POST["wphp_{$item_type}_edit_nonce"]) || !wp_verify_nonce($_POST["wphp_{$item_type}_edit_nonce"], "wphp_{$item_type}_edit_nonce"))
|
376 |
{
|
377 |
+
p_l('no verify nonce ' . "wphp_{$item_type}_edit_nonce");
|
378 |
return $id;
|
379 |
}
|
380 |
|
386 |
public function save_bulk_edit_data()
|
387 |
{
|
388 |
//p_d($_POST);
|
389 |
+
p_l("save_bulk_edit_data");
|
390 |
$post_type = empty($_POST['post_type']) ? '' : $_POST['post_type'];
|
391 |
|
392 |
$post_ids = (isset($_POST['post_ids']) && !empty($_POST['post_ids'])) ? $_POST['post_ids'] : array();
|
549 |
{
|
550 |
$(document).ready(function()
|
551 |
{
|
552 |
+
$(".wphp_checkall").change(function()
|
553 |
{
|
554 |
+
$(".wphp_checkall").parent().parent().parent().find(".wphp_multicheck").prop("checked", $(this).prop("checked"));
|
555 |
});
|
556 |
});
|
557 |
})(jQuery);</script>';
|
558 |
}
|
559 |
|
560 |
+
$pre[] = '<div style="padding:10px;background:#e5e5e5"> <label for="wphp_checkallcheck" style="font-weight:bold" >
|
561 |
+
<input type="checkbox" class="wphp_checkall" id="wphp_checkallcheck" />
|
562 |
|
563 |
Check All
|
564 |
|
575 |
<input type="hidden" name="%1$s_old[%2$s]" value="%6$s"/>
|
576 |
<input type="hidden" name="%1$s_name[%2$s]" value="%7$s"/></div>';
|
577 |
|
578 |
+
$html = array();
|
579 |
$index = 0;
|
580 |
foreach ($this->get_visibility_type_values($post_type, $post_id) as $type => $detail)
|
581 |
{
|
593 |
);
|
594 |
$index++;
|
595 |
}
|
596 |
+
return (implode("\n", $pre) . implode("", $html) . ($meta_box ? $this->default_info('widget') : ''));
|
597 |
|
598 |
}
|
599 |
|
606 |
echo ($this->metabox_edit($post->ID, $post->post_type));
|
607 |
}
|
608 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
609 |
public function create_post_type()
|
610 |
{
|
611 |
+
return ;
|
612 |
register_post_type('acme_product',
|
613 |
array(
|
614 |
'labels' => array(
|
644 |
}
|
645 |
public function register_setting_page()
|
646 |
{
|
647 |
+
$valid = $this->license->is_valid();
|
648 |
+
wp_hide_post()->settingManager()->register_tab(array('id' => 'wphp_gen', 'title' => 'General'));
|
649 |
+
$options = array();
|
650 |
+
foreach ((array) scb_custom_post_types() as $type => $detail)
|
|
|
651 |
{
|
652 |
+
$detail = (array) $detail;
|
653 |
+
$options[$type] = array('text' => $detail['labels']->name);
|
654 |
+
if (!$valid && !$detail['_builtin'])
|
655 |
+
{
|
656 |
+
$options[$type]['extra'] = 'disabled';
|
657 |
+
$options[$type]['text'] .= " -- For WP hide post Pro users only";
|
658 |
+
}
|
659 |
}
|
660 |
+
$pro = '<div><a target="_blank" style="color:red" href="' . $this->item_url . '">For WP hide post Pro Users only</a></div>';
|
661 |
wp_hide_post()->settingManager()->register_setting_field('wphp_gen', array(
|
662 |
array('name' => 'wphp_post_types',
|
663 |
'label' => wphp_('Allowed custom post types'),
|
667 |
'placeholder' => 'Select custom post type',
|
668 |
),
|
669 |
array('name' => 'show_in_quickedit',
|
670 |
+
'label' => wphp_('Enable quick edit?'),
|
671 |
+
'desc' => wphp_('Display WP hide post widget in quick edit?') . ($valid ? '' : $pro),
|
672 |
+
'type' => 'yesno',
|
673 |
+
'default' => 1,
|
674 |
+
'disabled' => $valid ? '' : 'disabled',
|
675 |
+
),
|
676 |
+
array('name' => 'show_in_bulkedit',
|
677 |
+
'label' => wphp_('Enable bulk edit?'),
|
678 |
+
'desc' => wphp_('Display WP hide post widget in bulk edit?') . ($valid ? '' : $pro),
|
679 |
'type' => 'yesno',
|
680 |
'default' => 1,
|
681 |
+
'disabled' => $valid ? '' : 'disabled',
|
682 |
),
|
683 |
));
|
684 |
}
|
685 |
|
686 |
public function admin_menu()
|
687 |
{
|
688 |
+
|
689 |
+
add_submenu_page('options-general.php', wphp_('WP Hide Post'), wphp_("WP Hide Post"), 'manage_options', wp_hide_post()->setting_menu_page(), array(wp_hide_post()->settingManager(), 'plugin_page'));
|
690 |
}
|
691 |
public function register_plugin($licenses)
|
692 |
{
|
693 |
+
$licenses[] = array('id' => wp_hide_post()->info('id'),
|
694 |
+
'type' => 'plugin',
|
695 |
+
'name' => wp_hide_post()->info('name'),
|
696 |
+
'label' => 'WP hide Post Plugin',
|
697 |
+
'options' => array(
|
698 |
+
'license_text' => array('invalid' => 'Get your WP Hide Post Pro license from here <a href="http://scriptburn.com/wphp" target="_blank">here</a>'),
|
699 |
+
'store_url' => "http://scriptburn.com",
|
700 |
+
'file' => wp_hide_post()->info('file'),
|
701 |
+
|
702 |
+
),
|
703 |
+
);
|
704 |
|
705 |
return $licenses;
|
706 |
}
|
714 |
wphp_hide_on_data['visibility_types']=[]
|
715 |
<?php
|
716 |
|
717 |
+
foreach (array('post', 'page') as $post_type)
|
718 |
{
|
719 |
echo (" wphp_hide_on_data['visibility_types']['$post_type']=[];\n");
|
720 |
|
744 |
{
|
745 |
return;
|
746 |
}
|
747 |
+
$current_v = isset($_GET['wphp_hidden_on']) ? $_GET['wphp_hidden_on'] : array();
|
748 |
+
$current_v = is_array($current_v) ? $current_v : array($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 = array();
|
755 |
if (!$nonce_data)
|
756 |
{
|
757 |
|
758 |
+
$nonce_data = array(
|
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)
|
767 |
case 'wphp_hide_on':
|
768 |
|
769 |
$values = $this->get_visibility_type_values($post_type, $post_id);
|
770 |
+
$data = array();
|
771 |
foreach ($values as $visibility_type => $item)
|
772 |
{
|
773 |
if (isset($item['value']))
|
782 |
$data[$visibility_type] = empty($item['value']) ? 0 : (int) $item['value'];
|
783 |
}
|
784 |
}
|
785 |
+
$items = array(implode(" , ", $items));
|
786 |
|
787 |
$items[] = sprintf('<input type="hidden" class="wphp_hidden_on" value="%2$s" />', $post_id, urlencode(json_encode($data)));
|
788 |
|
793 |
}
|
794 |
|
795 |
}
|
796 |
+
public function display_custom_bulkedit($column_name, $post_type)
|
797 |
+
{
|
798 |
+
if ( !wphp_get_setting('wphp_gen', 'show_in_bulkedit'))
|
799 |
+
{
|
800 |
+
return;
|
801 |
+
}
|
802 |
+
$this->display_custom_quickedit($column_name, $post_type);
|
803 |
+
}
|
804 |
+
//render our quick edit and bulk edit box
|
805 |
public function display_custom_quickedit($column_name, $post_type)
|
806 |
{
|
807 |
+
$valid = $this->license->is_valid();
|
808 |
|
809 |
+
if (!wphp_get_setting('wphp_gen', 'show_in_quickedit'))
|
810 |
{
|
|
|
811 |
return;
|
812 |
}
|
813 |
|
814 |
+
$pre = array();
|
815 |
+
if ($column_name != 'wphp_hide_on')
|
816 |
{
|
817 |
|
818 |
return;
|
825 |
}
|
826 |
|
827 |
static $printNonce;
|
828 |
+
// p_l("display_custom_quickedit $printNonce");
|
829 |
if (!$printNonce)
|
830 |
{
|
831 |
+
$printNonce = wp_create_nonce("wphp_{$post_type}_edit_nonce");
|
832 |
+
$printNonce = '<input type="hidden" id="wphp_' . $post_type . '_edit_nonce" name="wphp_' . $post_type . '_edit_nonce" value="' . $printNonce . '" />';
|
833 |
+
$pre[] = $printNonce;
|
834 |
}
|
835 |
|
836 |
$tmpl = '<div style="padding:10px;padding-bottom:0px"> <label for="%1$s_new_%2$s" class="selectit">
|
837 |
+
<input type="checkbox" id="%1$s_new_%2$s" name="%1$s[%2$s]" value="%3$s" %4$s class="wphp_multicheck" %9$s/>
|
838 |
|
839 |
%5$s
|
840 |
</label>%8$s
|
841 |
+
<input type="hidden" name="%1$s_old[%2$s]" value="%6$s" %9$s/>
|
842 |
+
<input type="hidden" name="%1$s_name[%2$s]" value="%7$s" %9$s/></div>';
|
843 |
|
844 |
+
$html = array();
|
845 |
$index = 0;
|
846 |
$allChecked = false;
|
847 |
+
|
848 |
foreach ($this->get_visibility_types($post_type) as $type => $detail)
|
849 |
{
|
850 |
$detail['value'] = empty($detail['value']) ? 0 : (int) $detail['value'];
|
857 |
$detail['label'],
|
858 |
$detail['value'],
|
859 |
$type,
|
860 |
+
empty($detail['description']) ? '' : sprintf('<p style=" padding-left: 30px;" class="description">%1$s</p>', $detail['description']),
|
861 |
+
$valid ? '' : 'disabled'
|
862 |
);
|
863 |
$allChecked = $detail['value'];
|
864 |
$index++;
|
865 |
}
|
866 |
+
$pro = '<div style="padding:10px;padding-bottom:0px"><a target="_blank" style="color:red" href="' . $this->item_url . '">For WP hide post Pro Users only</a></div>';
|
867 |
if ($post_type !== 'page')
|
868 |
{
|
869 |
$pre[] = '<script>(function($)
|
870 |
{
|
871 |
$(document).ready(function()
|
872 |
{
|
873 |
+
$(".wphp_checkall").change(function()
|
874 |
{
|
875 |
+
$(".wphp_checkall").parent().parent().parent().find(".wphp_multicheck").prop("checked", $(this).prop("checked"));
|
876 |
});
|
877 |
});
|
878 |
})(jQuery);</script>';
|
|
|
879 |
|
880 |
+
$pre[] = '<div style="padding:10px;background:#e5e5e5"> <label for="wphp_checkallcheck" style="font-weight:bold" >
|
881 |
+
<input ' . ($valid ? '' : 'disabled') . ' type="checkbox" id="wphp_checkallcheck" class="wphp_checkall" ' . ($allChecked ? 'checked' : '') . ' />
|
882 |
|
883 |
Check All
|
884 |
|
885 |
</label>
|
886 |
</div>';
|
887 |
+
}
|
888 |
$post_type_obj = get_post_type_object($post_type);
|
889 |
|
890 |
$title = sprintf(wphp_('%1$s Visibility'), ucwords($post_type_obj->labels->singular_name));
|
891 |
+
$html = implode("\n", $pre) . implode("", $html) . ($valid?'':$pro);
|
892 |
require WPHP_PLUGIN_DIR . 'admin/partials/quick-edit-display.php';
|
893 |
|
894 |
}
|
902 |
{
|
903 |
return;
|
904 |
}
|
905 |
+
$values = array();
|
906 |
if (!$js_var)
|
907 |
{
|
908 |
echo ("\n<script>\n var wphp_hide_on_data=[]; \n
|
955 |
}
|
956 |
$values = $this->get_visibility_types($type);
|
957 |
|
958 |
+
$values['all'] = array('short_label' => 'All Hidden');
|
959 |
|
960 |
?>
|
961 |
<select name="wphp_hidden_on[]" class=" scb-sett-select-chosen chosen-select" multiple data-placeholder="Select Hidden option">
|
962 |
<?php
|
963 |
+
$current_v = isset($_GET['wphp_hidden_on']) ? $_GET['wphp_hidden_on'] : array();
|
964 |
+
$current_v = is_array($current_v) ? $current_v : array($current_v);
|
965 |
|
966 |
foreach ($values as $visibility_type => $item)
|
967 |
{
|
993 |
|
994 |
if (!$this->allowedPostTypes($type))
|
995 |
{
|
996 |
+
return $join;
|
997 |
}
|
998 |
|
999 |
if (!(is_admin() && $pagenow == 'edit.php' && isset($_GET['wphp_hidden_on']) && $_GET['wphp_hidden_on'] != ''))
|
1000 |
{
|
1001 |
+
return $join;
|
1002 |
}
|
1003 |
+
|
1004 |
+
$current_v = isset($_GET['wphp_hidden_on']) ? $_GET['wphp_hidden_on'] : array();
|
1005 |
+
$current_v = is_array($current_v) ? $current_v : array($current_v);
|
1006 |
|
1007 |
$join .= ' inner JOIN ' . WPHP_TABLE_NAME . ' wphptbl ON ' . WP_POSTS_TABLE_NAME . ".ID = wphptbl.post_id ";
|
1008 |
|
1020 |
$join .= " AND wphptbl.meta_key in ('" . implode("','", $current_v) . "') ";
|
1021 |
|
1022 |
}
|
|
|
1023 |
return $join;
|
1024 |
|
1025 |
}
|
1026 |
+
public function default_info($page)
|
1027 |
{
|
1028 |
$info = get_transient('wphp_notices_' . $page);
|
1029 |
+
|
1030 |
if (!$info)
|
1031 |
{
|
1032 |
|
1033 |
+
$obj_license = scb_get_license(wp_hide_post()->info('id'));
|
1034 |
+
$args['action'] = 'wphp_footer';
|
1035 |
+
$args['page'] = $page;
|
1036 |
+
if (is_object($obj_license))
|
1037 |
+
{
|
1038 |
+
$info = $obj_license->extendedInfo();
|
1039 |
+
$args = array_merge($args, array(
|
1040 |
+
'license' => $info['license'],
|
1041 |
+
'price' => isset($info['price']) ? $info['price'] : 0,
|
1042 |
+
'payment_id' => isset($info['payment_id']) ? $info['payment_id'] : '',
|
1043 |
+
|
1044 |
+
));
|
1045 |
+
}
|
1046 |
+
$args['price'] = isset($args['price']) ? $args['price'] : 0;
|
1047 |
+
$url = "http://scriptburn.com/wp-admin/admin-ajax.php?" . http_build_query($args);
|
1048 |
+
$response = wp_remote_get($url, array('decompress' => false));
|
1049 |
|
1050 |
if (is_array($response) && !empty($response['body']))
|
1051 |
{
|
1052 |
+
|
1053 |
+
$info = @json_decode($response['body']);
|
1054 |
+
if (is_object($info))
|
1055 |
+
{
|
1056 |
+
$info = property_exists($info, 'response') ? $info->response : $this->default_footer($args['price']);
|
1057 |
+
}
|
1058 |
+
else
|
1059 |
+
{
|
1060 |
+
$info = $response['body'];
|
1061 |
+
}
|
1062 |
+
|
1063 |
set_transient('wphp_notices_' . $page, $info, 86400);
|
1064 |
}
|
1065 |
+
elseif ($response == "0")
|
1066 |
+
{
|
1067 |
+
$info = "";
|
1068 |
+
}
|
1069 |
else
|
1070 |
{
|
1071 |
|
1072 |
+
$info = $this->default_footer($args['price']);
|
1073 |
+
}
|
1074 |
+
}
|
1075 |
+
return $info;
|
1076 |
+
|
1077 |
+
}
|
1078 |
+
public function default_footer($price)
|
1079 |
+
{
|
1080 |
+
$info = '<hr/>
|
1081 |
<div>
|
1082 |
<div style="float:left">
|
1083 |
<a href="http://scriptburn.com/wp-hide-post/#comments">
|
1089 |
%2$s
|
1090 |
</a>
|
1091 |
</div>
|
1092 |
+
</div><div style="clear:both">' . $price ? '' : '
|
1093 |
<div style="text-align:center">
|
1094 |
+
<a href="http://scriptburn.com/wp-hide-post">
|
1095 |
+
<img src="http://www.paypalobjects.com/webstatic/en_US/btn/btn_donate_pp_142x27.png"/>
|
1096 |
</a>
|
1097 |
</div>
|
1098 |
<div style="clear:both">
|
1099 |
</div>
|
1100 |
';
|
1101 |
+
return sprintf($info,
|
1102 |
+
wphp_("Leave feedback and report bugs..."),
|
1103 |
+
wphp_("Give 'WP Hide Post' a good rating...")
|
1104 |
+
);
|
|
|
|
|
|
|
1105 |
|
1106 |
}
|
1107 |
public function wsa_footer()
|
1108 |
{
|
1109 |
|
1110 |
+
echo $this->default_info('footer');
|
1111 |
+
}
|
1112 |
+
|
1113 |
+
public function maybe_update()
|
1114 |
+
{
|
1115 |
+
|
1116 |
+
// bail if this plugin data doesn't need updating
|
1117 |
+
// delete_option('wpmovies_db_ver');
|
1118 |
+
$db_updated = (int) (empty($_REQUEST['db_updated']) ? 0 : $_REQUEST['db_updated']);
|
1119 |
+
if ($db_updated)
|
1120 |
+
{
|
1121 |
+
return;
|
1122 |
+
}
|
1123 |
+
$wphp_db_ver = (int) get_option('wphp_db_ver');
|
1124 |
+
// error_log($wpmovies_db_ver . ">=" . self::WPMOVIES_DB_VER);
|
1125 |
+
if ($wphp_db_ver >= WPHP_DB_VER)
|
1126 |
+
{
|
1127 |
+
return;
|
1128 |
+
}
|
1129 |
+
|
1130 |
+
require_once WPHP_PLUGIN_DIR . 'admin/class-wp-hide-post-dbupdate.php';
|
1131 |
+
$db_updater = new wp_hide_post_DB_Update();
|
1132 |
+
$ret = $db_updater->db_update();
|
1133 |
+
|
1134 |
+
if ($ret)
|
1135 |
+
{
|
1136 |
+
set_transient('wphp_db_updated', 1, 30);
|
1137 |
+
}
|
1138 |
}
|
1139 |
+
|
1140 |
}
|
admin/class-wp-hide-post-dbupdate.php
ADDED
@@ -0,0 +1,203 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* The admin-specific functionality of the plugin.
|
5 |
+
*
|
6 |
+
* @link http://scriptburn.com
|
7 |
+
* @since 2.0
|
8 |
+
*
|
9 |
+
* @package wp_hide_post
|
10 |
+
* @subpackage wp_hide_post/admin
|
11 |
+
*/
|
12 |
+
|
13 |
+
/**
|
14 |
+
* The admin-specific functionality of the plugin.
|
15 |
+
*
|
16 |
+
* Defines the plugin name, version, and two examples hooks for how to
|
17 |
+
* enqueue the admin-specific stylesheet and JavaScript.
|
18 |
+
*
|
19 |
+
* @package wp_hide_post
|
20 |
+
* @subpackage wp_hide_post/admin
|
21 |
+
* @author ScriptBurn <support@scriptburn.com>
|
22 |
+
*/
|
23 |
+
class wp_hide_post_DB_Update
|
24 |
+
{
|
25 |
+
|
26 |
+
/**
|
27 |
+
* The ID of this plugin.
|
28 |
+
*
|
29 |
+
* @since 1.2.2
|
30 |
+
* @access private
|
31 |
+
* @var string $wp_hide_post The ID of this plugin.
|
32 |
+
*/
|
33 |
+
private $wp_hide_post;
|
34 |
+
|
35 |
+
/**
|
36 |
+
* The version of this plugin.
|
37 |
+
*
|
38 |
+
* @since 1.2.2
|
39 |
+
* @access private
|
40 |
+
* @var string $version The current version of this plugin.
|
41 |
+
*/
|
42 |
+
private $version;
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Initiates db update process
|
46 |
+
*
|
47 |
+
* @since 1.2.2
|
48 |
+
* @access private
|
49 |
+
* @var string $version The current version of this plugin.
|
50 |
+
*/
|
51 |
+
public function db_update()
|
52 |
+
{
|
53 |
+
p_l("db_update");
|
54 |
+
// no PHP timeout for running updates
|
55 |
+
//set_time_limit(0);
|
56 |
+
|
57 |
+
$db_updated = false;
|
58 |
+
// this is the current database schema version number
|
59 |
+
|
60 |
+
$current_db_ver = (int) get_option('wphp_db_ver');
|
61 |
+
|
62 |
+
// this is the target version that we need to reach
|
63 |
+
$target_db_ver = WPHP_DB_VER;
|
64 |
+
|
65 |
+
// error_log("$current_db_ver < $target_db_ver");
|
66 |
+
//$loop;
|
67 |
+
while ($current_db_ver < $target_db_ver)
|
68 |
+
{
|
69 |
+
|
70 |
+
// increment the current db_ver by one
|
71 |
+
$current_db_ver++;
|
72 |
+
|
73 |
+
// each db version will require a separate update function
|
74 |
+
$func = "update_to_ver_{$current_db_ver}";
|
75 |
+
p_l("calling $func");
|
76 |
+
if (method_exists($this, $func))
|
77 |
+
{
|
78 |
+
$ret = call_user_func_array(array($this, $func), array());
|
79 |
+
if ($ret && !$db_updated)
|
80 |
+
{
|
81 |
+
$db_updated = true;
|
82 |
+
}
|
83 |
+
}
|
84 |
+
|
85 |
+
// update the option in the database, so that this process can always
|
86 |
+
// pick up where it left off
|
87 |
+
|
88 |
+
update_option('wphp_db_ver', $current_db_ver);
|
89 |
+
}
|
90 |
+
return $db_updated;
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Migrate to the new database schema and clean up old schema...
|
95 |
+
* Should run only once in the lifetime of the plugin...
|
96 |
+
* @return unknown_type
|
97 |
+
*/
|
98 |
+
|
99 |
+
public function update_to_ver_1()
|
100 |
+
{
|
101 |
+
global $wpdb;
|
102 |
+
p_l("called:update_to_ver_1");
|
103 |
+
/* When I first released this plugin, I was young and crazy and didn't know about the postmeta table.
|
104 |
+
* With time I became wiser and wiser and decided to migrate the implementation to rely on postmeta.
|
105 |
+
* I hope it was not a bad idea...
|
106 |
+
*/
|
107 |
+
global $wpdb;
|
108 |
+
global $table_prefix;
|
109 |
+
$dbname = $wpdb->get_var("SELECT database()");
|
110 |
+
if (!$dbname)
|
111 |
+
{
|
112 |
+
return;
|
113 |
+
}
|
114 |
+
|
115 |
+
$legacy_table_name = "${table_prefix}lowprofiler_posts";
|
116 |
+
$legacy_table_exists = $wpdb->get_var("SELECT COUNT(*) AS count FROM information_schema.tables WHERE table_schema = '$dbname' AND table_name = '$legacy_table_name';");
|
117 |
+
if ($legacy_table_exists)
|
118 |
+
{
|
119 |
+
p_l("Migrating legacy table...");
|
120 |
+
// move everything to the postmeta table
|
121 |
+
$existing = $wpdb->get_results("SELECT wplp_post_id, wplp_flag, wplp_value from $legacy_table_name", ARRAY_N);
|
122 |
+
// scan them one by one and insert the corresponding fields in the postmeta table
|
123 |
+
$count = 0;
|
124 |
+
foreach ($existing as $existing_array)
|
125 |
+
{
|
126 |
+
$wplp_post_id = $existing_array[0];
|
127 |
+
$wplp_flag = $existing_array[1];
|
128 |
+
$wplp_value = $existing_array[2];
|
129 |
+
if ($wplp_flag == 'home')
|
130 |
+
{
|
131 |
+
$wplp_flag = 'front';
|
132 |
+
}
|
133 |
+
|
134 |
+
if ($wplp_value == 'home')
|
135 |
+
{
|
136 |
+
$wplp_value = 'front';
|
137 |
+
}
|
138 |
+
|
139 |
+
if ($wplp_flag != 'page')
|
140 |
+
{
|
141 |
+
$wpdb->query("INSERT INTO " . WPHP_TABLE_NAME . "(post_id, meta_key, meta_value) VALUES($wplp_post_id, '_wplp_post_$wplp_flag', '1')");
|
142 |
+
}
|
143 |
+
else
|
144 |
+
{
|
145 |
+
$wpdb->query("INSERT INTO " . WPHP_TABLE_NAME . "(post_id, meta_key, meta_value) VALUES($wplp_post_id, '_wplp_page_flags', $wplp_value)");
|
146 |
+
}
|
147 |
+
++$count;
|
148 |
+
}
|
149 |
+
p_l("$count entries migrated from legacy table.");
|
150 |
+
// delete the old table
|
151 |
+
$wpdb->query("TRUNCATE TABLE $legacy_table_name");
|
152 |
+
$wpdb->query("DROP TABLE $legacy_table_name");
|
153 |
+
p_l("Legacy table deleted.");
|
154 |
+
}
|
155 |
+
return true;
|
156 |
+
}
|
157 |
+
public function update_to_ver_2()
|
158 |
+
{
|
159 |
+
p_l("in update_to_ver_2");
|
160 |
+
global $wpdb;
|
161 |
+
$results = $wpdb->get_results("select * from $wpdb->postmeta where meta_key='_wplp_page_flags' ", ARRAY_A);
|
162 |
+
if ($results)
|
163 |
+
{
|
164 |
+
foreach ($results as $result)
|
165 |
+
{
|
166 |
+
//p_l($result);
|
167 |
+
if ($result['meta_value'] == 'all')
|
168 |
+
{
|
169 |
+
p_l("all");
|
170 |
+
$meta_old = get_post_meta($result['post_id'], '_wplp_page_search', true);
|
171 |
+
|
172 |
+
if ($meta_old)
|
173 |
+
{
|
174 |
+
//Hide everywhere pages are listed.
|
175 |
+
p_l("always");
|
176 |
+
$new_meta_name = WPHP_META_VALUE_PREFIX . 'hide_always';
|
177 |
+
|
178 |
+
update_post_meta($result['post_id'], $new_meta_name, '1');
|
179 |
+
|
180 |
+
}
|
181 |
+
else
|
182 |
+
{
|
183 |
+
//Hide everywhere pages are listed. but Keep in search results.
|
184 |
+
p_l("always no search");
|
185 |
+
$new_meta_name = WPHP_META_VALUE_PREFIX . 'nohide_search';
|
186 |
+
update_post_meta($result['post_id'], $new_meta_name, '1');
|
187 |
+
|
188 |
+
}
|
189 |
+
}
|
190 |
+
elseif ($result['meta_value'] == 'front')
|
191 |
+
{
|
192 |
+
p_l("front");
|
193 |
+
|
194 |
+
$new_meta_name = WPHP_META_VALUE_PREFIX . 'hide_frontpage';
|
195 |
+
|
196 |
+
update_post_meta($result['post_id'], $new_meta_name, '1');
|
197 |
+
|
198 |
+
}
|
199 |
+
|
200 |
+
}
|
201 |
+
}
|
202 |
+
}
|
203 |
+
}
|
admin/conditions.php
CHANGED
@@ -2,13 +2,14 @@
|
|
2 |
|
3 |
if (!function_exists('wphp_is_hide_frontpage_page'))
|
4 |
{
|
5 |
-
function wphp_is_hide_frontpage_page($
|
6 |
{
|
7 |
global $wp;
|
8 |
$ret = false;
|
9 |
-
if (!
|
10 |
{
|
11 |
-
|
|
|
12 |
}
|
13 |
return $ret || is_front_page();
|
14 |
}
|
@@ -18,7 +19,7 @@ if (!function_exists('wphp_is_hide_always_page'))
|
|
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'))
|
@@ -39,7 +40,7 @@ if (!function_exists('wphp_is_post_front_post'))
|
|
39 |
function wphp_is_post_front_post()
|
40 |
{
|
41 |
|
42 |
-
return is_front_page()|| is_home();
|
43 |
}
|
44 |
}
|
45 |
/**
|
@@ -109,29 +110,44 @@ if (!function_exists('wphp_is_post_archive_post'))
|
|
109 |
|
110 |
if (!function_exists('wphp_is_post_search_post'))
|
111 |
{
|
112 |
-
function wphp_is_post_search_post()
|
113 |
{
|
114 |
-
|
|
|
|
|
|
|
115 |
}
|
116 |
}
|
117 |
if (!function_exists('wphp_is_post_rel_post'))
|
118 |
{
|
119 |
-
function wphp_is_post_rel_post()
|
120 |
{
|
121 |
-
return
|
122 |
}
|
123 |
}
|
|
|
|
|
|
|
|
|
124 |
|
|
|
|
|
|
|
125 |
if (!function_exists('wphp_is_post_sidebar'))
|
126 |
{
|
127 |
-
function wphp_is_post_sidebar(
|
128 |
{
|
129 |
-
|
130 |
if (property_exists($wp_query, 'query'))
|
131 |
{
|
132 |
-
|
133 |
}
|
134 |
-
return
|
135 |
|
136 |
}
|
137 |
}
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
if (!function_exists('wphp_is_hide_frontpage_page'))
|
4 |
{
|
5 |
+
function wphp_is_hide_frontpage_page($args)
|
6 |
{
|
7 |
global $wp;
|
8 |
$ret = false;
|
9 |
+
if (!empty($args['wp_query']))
|
10 |
{
|
11 |
+
|
12 |
+
$ret = ($args['wp_query']->get('page_id') == get_option('page_on_front') && get_option('page_on_front')) || empty($args['wp_query']->query_string);
|
13 |
}
|
14 |
return $ret || is_front_page();
|
15 |
}
|
19 |
function wphp_is_hide_always_page()
|
20 |
{
|
21 |
|
22 |
+
return (is_front_page() || is_feed() || is_category() || is_tag() || is_date() || is_search());
|
23 |
}
|
24 |
}
|
25 |
if (!function_exists('wphp_is_nohide_search_page'))
|
40 |
function wphp_is_post_front_post()
|
41 |
{
|
42 |
|
43 |
+
return is_front_page() || is_home();
|
44 |
}
|
45 |
}
|
46 |
/**
|
110 |
|
111 |
if (!function_exists('wphp_is_post_search_post'))
|
112 |
{
|
113 |
+
function wphp_is_post_search_post($args)
|
114 |
{
|
115 |
+
if (isset($args['wp_query']) && $args['wp_query']->is_main_query())
|
116 |
+
{
|
117 |
+
return is_search();
|
118 |
+
}
|
119 |
}
|
120 |
}
|
121 |
if (!function_exists('wphp_is_post_rel_post'))
|
122 |
{
|
123 |
+
function wphp_is_post_rel_post($args)
|
124 |
{
|
125 |
+
return wphp_is_rel_query($args);
|
126 |
}
|
127 |
}
|
128 |
+
if (!function_exists('wphp_is_post_recent_post'))
|
129 |
+
{
|
130 |
+
function wphp_is_post_recent_post($args)
|
131 |
+
{
|
132 |
|
133 |
+
return wphp_is_post_sidebar($args['wp_query']);
|
134 |
+
}
|
135 |
+
}
|
136 |
if (!function_exists('wphp_is_post_sidebar'))
|
137 |
{
|
138 |
+
function wphp_is_post_sidebar($wp_query)
|
139 |
{
|
140 |
+
$sidebar = false;
|
141 |
if (property_exists($wp_query, 'query'))
|
142 |
{
|
143 |
+
$sidebar = !empty($wp_query->query['wphp_inside_recent_post_sidebar']) && $wp_query->query['wphp_inside_recent_post_sidebar'];
|
144 |
}
|
145 |
+
return $sidebar;
|
146 |
|
147 |
}
|
148 |
}
|
149 |
+
|
150 |
+
function wphp_is_rel_query($args)
|
151 |
+
{
|
152 |
+
return isset($args['from_rel_query']) && $args['from_rel_query'];
|
153 |
+
}
|
admin/css/wp-hide-post-admin.css
CHANGED
@@ -40,4 +40,24 @@
|
|
40 |
|
41 |
.tablenav .actions {
|
42 |
overflow: visible;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
}
|
40 |
|
41 |
.tablenav .actions {
|
42 |
overflow: visible;
|
43 |
+
}
|
44 |
+
|
45 |
+
.positioned-divs {
|
46 |
+
|
47 |
+
}
|
48 |
+
|
49 |
+
.positioned-divs .div-under {
|
50 |
+
z-index: 1;
|
51 |
+
}
|
52 |
+
|
53 |
+
.positioned-divs .div-over {
|
54 |
+
z-index: 2;
|
55 |
+
left: 0;
|
56 |
+
top: 0px;
|
57 |
+
position: absolute;
|
58 |
+
width: 100%;
|
59 |
+
height: 100%;
|
60 |
+
z-index: 2;
|
61 |
+
background: grey;
|
62 |
+
opacity: .5;
|
63 |
}
|
admin/license/LicenseItem.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class
|
4 |
{
|
5 |
|
6 |
private $item_name = "";
|
@@ -15,7 +15,8 @@ class WPHP_LicenseItem
|
|
15 |
private $encrypter;
|
16 |
protected $options;
|
17 |
public $license_file;
|
18 |
-
|
|
|
19 |
{
|
20 |
$this->store = $store;
|
21 |
$this->item_name = $item_name;
|
@@ -25,7 +26,11 @@ class WPHP_LicenseItem
|
|
25 |
$this->encrypter = $encrypter;
|
26 |
$valid_items = array('plugin', 'module', 'theme');
|
27 |
$this->options = $options;
|
28 |
-
if (isset($this->options['
|
|
|
|
|
|
|
|
|
29 |
{
|
30 |
$this->license_file = $this->options['license_folder'] . "/" . (@$this->options['license_file'] ? $this->options['license_file'] : 'license');
|
31 |
}
|
@@ -38,8 +43,30 @@ class WPHP_LicenseItem
|
|
38 |
return false;
|
39 |
}
|
40 |
}
|
|
|
|
|
|
|
|
|
41 |
|
42 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
public function store_url()
|
44 |
{
|
45 |
return $this->store;
|
@@ -70,7 +97,7 @@ class WPHP_LicenseItem
|
|
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'],
|
74 |
}
|
75 |
|
76 |
$key_name = $this->prefix() . 'key';
|
@@ -81,7 +108,7 @@ class WPHP_LicenseItem
|
|
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'],
|
85 |
}
|
86 |
|
87 |
$key_name = $this->prefix() . 'key';
|
@@ -99,7 +126,7 @@ class WPHP_LicenseItem
|
|
99 |
|
100 |
if (!file_exists($this->license_file))
|
101 |
{
|
102 |
-
$this->write_license_file('',
|
103 |
}
|
104 |
|
105 |
$cnt = file_get_contents($this->license_file);
|
@@ -170,7 +197,7 @@ class WPHP_LicenseItem
|
|
170 |
$cnt = @json_decode($cnt);
|
171 |
if (!is_array($cnt))
|
172 |
{
|
173 |
-
$cnt =
|
174 |
}
|
175 |
if ($data === false && isset($cnt[$key]))
|
176 |
{
|
@@ -178,7 +205,7 @@ class WPHP_LicenseItem
|
|
178 |
}
|
179 |
else
|
180 |
{
|
181 |
-
$cnt[$key] =
|
182 |
}
|
183 |
$cnt = "SCB" . base64_encode(serialize($cnt));
|
184 |
|
@@ -189,7 +216,7 @@ class WPHP_LicenseItem
|
|
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'],
|
193 |
}
|
194 |
elseif (isset($this->options['license_storage']) && $this->options['license_storage'] == 'file')
|
195 |
{
|
@@ -204,7 +231,7 @@ class WPHP_LicenseItem
|
|
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'],
|
208 |
}
|
209 |
elseif (isset($this->options['license_storage']) && $this->options['license_storage'] == 'file')
|
210 |
{
|
@@ -219,7 +246,7 @@ class WPHP_LicenseItem
|
|
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'],
|
223 |
}
|
224 |
elseif (isset($this->options['license_storage']) && $this->options['license_storage'] == 'file')
|
225 |
{
|
@@ -321,21 +348,22 @@ class WPHP_LicenseItem
|
|
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' =>
|
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 =
|
334 |
}
|
335 |
else
|
336 |
{
|
337 |
$url = $this->store;
|
338 |
-
$response =
|
339 |
}
|
340 |
|
341 |
$backtrace = debug_backtrace();
|
@@ -349,17 +377,21 @@ class WPHP_LicenseItem
|
|
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 |
-
|
|
|
361 |
{
|
362 |
-
throw new \Exception('License checksum error');
|
363 |
}
|
364 |
|
365 |
// $this->debug('license', __FUNCTION__ . "-" . __LINE__ . "-" . __LINE__, "NoDecoded:" . print_r(($license_data), true));
|
@@ -374,13 +406,20 @@ class WPHP_LicenseItem
|
|
374 |
}
|
375 |
public function activate_license()
|
376 |
{
|
|
|
|
|
|
|
377 |
|
378 |
-
|
379 |
-
|
380 |
-
|
|
|
|
|
|
|
|
|
381 |
{
|
382 |
-
|
383 |
-
|
384 |
}
|
385 |
|
386 |
return false;
|
@@ -388,36 +427,50 @@ class WPHP_LicenseItem
|
|
388 |
}
|
389 |
public function deactivate_license()
|
390 |
{
|
391 |
-
|
392 |
-
$response = $this->send_request('deactivate_license');
|
393 |
-
if ($response)
|
394 |
{
|
395 |
-
$this->
|
396 |
-
|
|
|
|
|
|
|
|
|
397 |
}
|
|
|
|
|
|
|
398 |
|
|
|
399 |
return false;
|
400 |
}
|
401 |
public function check_license($fresh = false)
|
402 |
{
|
|
|
|
|
|
|
|
|
403 |
|
404 |
-
|
405 |
-
$calle = $backtrace[1]['function'];
|
406 |
-
|
407 |
-
$this->debug('license', __FUNCTION__ . "-" . __LINE__ . "-" . __LINE__, $calle);
|
408 |
|
409 |
-
|
410 |
-
{
|
411 |
-
if (!$response = $this->send_request('check_license'))
|
412 |
{
|
413 |
-
|
|
|
|
|
|
|
414 |
}
|
|
|
|
|
|
|
|
|
|
|
415 |
}
|
416 |
-
|
417 |
{
|
418 |
-
return
|
|
|
419 |
}
|
420 |
-
|
421 |
return true;
|
422 |
}
|
423 |
|
@@ -427,7 +480,7 @@ class WPHP_LicenseItem
|
|
427 |
{
|
428 |
return $this->key;
|
429 |
}
|
430 |
-
$k =
|
431 |
$keys = array();
|
432 |
|
433 |
if (!is_array($k))
|
@@ -487,6 +540,19 @@ class WPHP_LicenseItem
|
|
487 |
return true;
|
488 |
}
|
489 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
490 |
public function decodeIt($data)
|
491 |
{
|
492 |
$backtrace = debug_backtrace();
|
@@ -516,7 +582,9 @@ class WPHP_LicenseItem
|
|
516 |
$decrypted = "";
|
517 |
foreach ($keys as $key)
|
518 |
{
|
519 |
-
$decrypt = $
|
|
|
|
|
520 |
if ($this->item_name == 'scriptburn-whois')
|
521 |
{
|
522 |
// p_n($key );
|
@@ -567,6 +635,10 @@ class WPHP_LicenseItem
|
|
567 |
}
|
568 |
public function extendedInfo($data = "")
|
569 |
{
|
|
|
|
|
|
|
|
|
570 |
try
|
571 |
{
|
572 |
$arr['missing'] = "License Key does not exist";
|
@@ -597,7 +669,7 @@ class WPHP_LicenseItem
|
|
597 |
|
598 |
if (!(is_array($data) || is_object($data)))
|
599 |
{
|
600 |
-
$data =
|
601 |
}
|
602 |
if (is_object($data))
|
603 |
{
|
@@ -611,11 +683,11 @@ class WPHP_LicenseItem
|
|
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[]
|
615 |
-
$msg[]
|
616 |
-
$data['message']
|
617 |
-
|
618 |
-
return $
|
619 |
|
620 |
}
|
621 |
catch (\Exception $e)
|
@@ -623,7 +695,8 @@ class WPHP_LicenseItem
|
|
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 |
-
|
|
|
627 |
}
|
628 |
}
|
629 |
public function debug($section, $name, $msg)
|
1 |
<?php
|
2 |
|
3 |
+
class SCB_LicenseItem
|
4 |
{
|
5 |
|
6 |
private $item_name = "";
|
15 |
private $encrypter;
|
16 |
protected $options;
|
17 |
public $license_file;
|
18 |
+
private $extended_info;
|
19 |
+
public function __construct($store, $item_type, $item_name, $encrypter = null, $options = array())
|
20 |
{
|
21 |
$this->store = $store;
|
22 |
$this->item_name = $item_name;
|
26 |
$this->encrypter = $encrypter;
|
27 |
$valid_items = array('plugin', 'module', 'theme');
|
28 |
$this->options = $options;
|
29 |
+
if (isset($this->options['license_file']))
|
30 |
+
{
|
31 |
+
$this->license_file = $this->options['license_file'];
|
32 |
+
}
|
33 |
+
elseif (isset($this->options['license_folder']) && file_exists($this->options['license_folder']))
|
34 |
{
|
35 |
$this->license_file = $this->options['license_folder'] . "/" . (@$this->options['license_file'] ? $this->options['license_file'] : 'license');
|
36 |
}
|
43 |
return false;
|
44 |
}
|
45 |
}
|
46 |
+
if (isset($this->options['file']))
|
47 |
+
{
|
48 |
+
$theme_item = new SCB_Item_Helper($this->store, $this->options['file'], $this->get_license_key(), $this->item_type, $this->is_valid());
|
49 |
+
}
|
50 |
|
51 |
}
|
52 |
+
public function options($name = null)
|
53 |
+
{
|
54 |
+
if (!is_null($name))
|
55 |
+
{
|
56 |
+
if (isset($this->options[$name]))
|
57 |
+
{
|
58 |
+
return $this->options[$name];
|
59 |
+
}
|
60 |
+
else
|
61 |
+
{
|
62 |
+
return '';
|
63 |
+
}
|
64 |
+
}
|
65 |
+
else
|
66 |
+
{
|
67 |
+
return $this->options;
|
68 |
+
}
|
69 |
+
}
|
70 |
public function store_url()
|
71 |
{
|
72 |
return $this->store;
|
97 |
{
|
98 |
if (isset($this->options['get_license_key']) && is_callable($this->options['get_license_key']))
|
99 |
{
|
100 |
+
return call_user_func($this->options['get_license_key'], array('this' => $this));
|
101 |
}
|
102 |
|
103 |
$key_name = $this->prefix() . 'key';
|
108 |
{
|
109 |
if (isset($this->options['set_license_key']) && is_callable($this->options['set_license_key']))
|
110 |
{
|
111 |
+
return call_user_func($this->options['set_license_key'], array('this' => $this, 'key' => $key));
|
112 |
}
|
113 |
|
114 |
$key_name = $this->prefix() . 'key';
|
126 |
|
127 |
if (!file_exists($this->license_file))
|
128 |
{
|
129 |
+
$this->write_license_file('', array(), $age = 0, false);
|
130 |
}
|
131 |
|
132 |
$cnt = file_get_contents($this->license_file);
|
197 |
$cnt = @json_decode($cnt);
|
198 |
if (!is_array($cnt))
|
199 |
{
|
200 |
+
$cnt = array();
|
201 |
}
|
202 |
if ($data === false && isset($cnt[$key]))
|
203 |
{
|
205 |
}
|
206 |
else
|
207 |
{
|
208 |
+
$cnt[$key] = array('expire' => $age != 0 ? time() + $age : 0, 'data' => $data);
|
209 |
}
|
210 |
$cnt = "SCB" . base64_encode(serialize($cnt));
|
211 |
|
216 |
|
217 |
if (isset($this->options['read_license_data']) && is_callable($this->options['read_license_data']))
|
218 |
{
|
219 |
+
return call_user_func($this->options['read_license_data'], array('key' => $key));
|
220 |
}
|
221 |
elseif (isset($this->options['license_storage']) && $this->options['license_storage'] == 'file')
|
222 |
{
|
231 |
{
|
232 |
if (isset($this->options['write_license_data']) && is_callable($this->options['write_license_data']))
|
233 |
{
|
234 |
+
return call_user_func($this->options['write_license_data'], array('key' => $key, 'data' => $data, 'age' => $age));
|
235 |
}
|
236 |
elseif (isset($this->options['license_storage']) && $this->options['license_storage'] == 'file')
|
237 |
{
|
246 |
{
|
247 |
if (isset($this->options['delete_license_data']) && is_callable($this->options['delete_license_data']))
|
248 |
{
|
249 |
+
return call_user_func($this->options['delete_license_data'], array('key' => $key));
|
250 |
}
|
251 |
elseif (isset($this->options['license_storage']) && $this->options['license_storage'] == 'file')
|
252 |
{
|
348 |
'edd_action' => $request,
|
349 |
'license' => trim($this->get_license_key()),
|
350 |
'item_name' => urlencode($this->item_name), // the name of our product in EDD
|
351 |
+
'url' => scb_license_manager()->base_url(),
|
352 |
);
|
353 |
|
354 |
if ($method == 'get')
|
355 |
{
|
356 |
$api_params['rand'] = $this->RandomString(5);
|
357 |
$url = $this->store . "?" . http_build_query($api_params);
|
358 |
+
|
359 |
// p_d( $url );
|
360 |
//$this->debug('license', __FUNCTION__ . "-" . __LINE__, $url);
|
361 |
+
$response = scb_license_manager()->sendGetRequest($url . http_build_query($api_params));
|
362 |
}
|
363 |
else
|
364 |
{
|
365 |
$url = $this->store;
|
366 |
+
$response = scb_license_manager()->sendPostRequest($url, array('form_params' => $api_params, 'http_errors' => true));
|
367 |
}
|
368 |
|
369 |
$backtrace = debug_backtrace();
|
377 |
$license_data = (string) $response->body;
|
378 |
|
379 |
$check = '"' . $this->decode_signature;
|
380 |
+
|
381 |
if (substr($license_data, 0, strlen($check)) == $check)
|
382 |
{
|
383 |
$license_data = substr($license_data, 1);
|
384 |
+
|
385 |
if (substr($license_data, strlen($license_data) - 1) == '"')
|
386 |
{
|
387 |
$license_data = substr($license_data, 0, strlen($license_data) - 1);
|
388 |
}
|
389 |
+
|
390 |
}
|
391 |
+
|
392 |
+
if (!is_object(@json_decode($license_data)))
|
393 |
{
|
394 |
+
//throw new \Exception('License checksum error');
|
395 |
}
|
396 |
|
397 |
// $this->debug('license', __FUNCTION__ . "-" . __LINE__ . "-" . __LINE__, "NoDecoded:" . print_r(($license_data), true));
|
406 |
}
|
407 |
public function activate_license()
|
408 |
{
|
409 |
+
try
|
410 |
+
{
|
411 |
+
$response = $this->send_request('activate_license');
|
412 |
|
413 |
+
if ($response)
|
414 |
+
{
|
415 |
+
$this->set_license_data($response);
|
416 |
+
return true;
|
417 |
+
}
|
418 |
+
}
|
419 |
+
catch (\Exception $e)
|
420 |
{
|
421 |
+
return false;
|
422 |
+
|
423 |
}
|
424 |
|
425 |
return false;
|
427 |
}
|
428 |
public function deactivate_license()
|
429 |
{
|
430 |
+
try
|
|
|
|
|
431 |
{
|
432 |
+
$response = $this->send_request('deactivate_license');
|
433 |
+
if ($response)
|
434 |
+
{
|
435 |
+
$this->set_license_data($response);
|
436 |
+
return true;
|
437 |
+
}
|
438 |
}
|
439 |
+
catch (\Exception $e)
|
440 |
+
{
|
441 |
+
return false;
|
442 |
|
443 |
+
}
|
444 |
return false;
|
445 |
}
|
446 |
public function check_license($fresh = false)
|
447 |
{
|
448 |
+
try
|
449 |
+
{
|
450 |
+
$backtrace = debug_backtrace();
|
451 |
+
$calle = $backtrace[1]['function'];
|
452 |
|
453 |
+
$this->debug('license', __FUNCTION__ . "-" . __LINE__ . "-" . __LINE__, $calle);
|
|
|
|
|
|
|
454 |
|
455 |
+
if ($fresh)
|
|
|
|
|
456 |
{
|
457 |
+
if (!$response = $this->send_request('check_license'))
|
458 |
+
{
|
459 |
+
return false;
|
460 |
+
}
|
461 |
}
|
462 |
+
else
|
463 |
+
{
|
464 |
+
return true;
|
465 |
+
}
|
466 |
+
$this->set_license_data($response);
|
467 |
}
|
468 |
+
catch (\Exception $e)
|
469 |
{
|
470 |
+
return false;
|
471 |
+
|
472 |
}
|
473 |
+
|
474 |
return true;
|
475 |
}
|
476 |
|
480 |
{
|
481 |
return $this->key;
|
482 |
}
|
483 |
+
$k = array("cc6042d5c823eb37ce499cf85083ca03", "1234567890");
|
484 |
$keys = array();
|
485 |
|
486 |
if (!is_array($k))
|
540 |
return true;
|
541 |
}
|
542 |
}
|
543 |
+
public function decrypt($data, $key)
|
544 |
+
{
|
545 |
+
if (is_object($this->encrypter))
|
546 |
+
{
|
547 |
+
|
548 |
+
return $this->encrypter->decrypt($data, $key);
|
549 |
+
}
|
550 |
+
else
|
551 |
+
{
|
552 |
+
return $data;
|
553 |
+
}
|
554 |
+
|
555 |
+
}
|
556 |
public function decodeIt($data)
|
557 |
{
|
558 |
$backtrace = debug_backtrace();
|
582 |
$decrypted = "";
|
583 |
foreach ($keys as $key)
|
584 |
{
|
585 |
+
$decrypt = $this->decrypt(base64_decode($arr['data']), $key);
|
586 |
+
//$decrypt = $encryption->decrypt( base64_decode($arr['data']), $key);
|
587 |
+
|
588 |
if ($this->item_name == 'scriptburn-whois')
|
589 |
{
|
590 |
// p_n($key );
|
635 |
}
|
636 |
public function extendedInfo($data = "")
|
637 |
{
|
638 |
+
if ($this->extended_info)
|
639 |
+
{
|
640 |
+
return $this->extended_info;
|
641 |
+
}
|
642 |
try
|
643 |
{
|
644 |
$arr['missing'] = "License Key does not exist";
|
669 |
|
670 |
if (!(is_array($data) || is_object($data)))
|
671 |
{
|
672 |
+
$data = array();
|
673 |
}
|
674 |
if (is_object($data))
|
675 |
{
|
683 |
$data['license_info'] = isset($arr_license[$data['license']]) ? $arr_license[$data['license']] : $data['license'];
|
684 |
$data['error_info'] = isset($data['error']) ? isset($arr[$data['error']]) ? $arr[@$data['error']] : @$data['error'] : '';
|
685 |
|
686 |
+
$msg[] = isset($data['license']) ? (isset($arr_license[$data['license']]) ? $arr_license[$data['license']] : "Unknown license Status-{$data['license']} ") : "Unknown license Status";
|
687 |
+
$msg[] = isset($data['error']) ? (isset($arr_license[$data['error']]) ? $arr_license[$data['error']] : "Unknown license Error-{$data['error']} ") : "";
|
688 |
+
$data['message'] = $msg[0] ? $msg[0] . ($msg[1] ? " $msg[1]" : '') : ($msg[1] ? $msg[1] : '');
|
689 |
+
$this->extended_info = $data;
|
690 |
+
return $this->extended_info;
|
691 |
|
692 |
}
|
693 |
catch (\Exception $e)
|
695 |
$data['license'] = 'unknown';
|
696 |
$data['license_info'] = isset($arr_license[$data['license']]) ? $arr_license[$data['license']] : $data['license'];
|
697 |
$data['message'] = $e->getMessage();
|
698 |
+
$this->extended_info = $data;
|
699 |
+
return $this->extended_info;
|
700 |
}
|
701 |
}
|
702 |
public function debug($section, $name, $msg)
|
admin/license/LicenseManager.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class
|
4 |
{
|
5 |
|
6 |
private $items;
|
@@ -11,16 +11,19 @@ class WPHP_LicenseManager
|
|
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 |
-
|
|
|
|
|
|
|
|
|
24 |
return $this->items[$id];
|
25 |
}
|
26 |
public function items()
|
@@ -45,11 +48,11 @@ class WPHP_LicenseManager
|
|
45 |
if (is_array($response))
|
46 |
{
|
47 |
|
48 |
-
return (object)
|
49 |
}
|
50 |
else
|
51 |
{
|
52 |
-
return (object)
|
53 |
|
54 |
}
|
55 |
}
|
1 |
<?php
|
2 |
|
3 |
+
class SCB_LicenseManager
|
4 |
{
|
5 |
|
6 |
private $items;
|
11 |
{
|
12 |
self::$instance = new static();
|
13 |
}
|
|
|
14 |
return self::$instance;
|
15 |
}
|
16 |
+
public function add($id, $store, $item_type, $item_name, $encrypter = null, $options = array())
|
17 |
{
|
18 |
if (isset($this->items[$id]))
|
19 |
{
|
20 |
return $this->items[$id];
|
21 |
}
|
22 |
+
if (is_null($encrypter))
|
23 |
+
{
|
24 |
+
$encrypter = new Encryption();
|
25 |
+
}
|
26 |
+
$this->items[$id] = new SCB_LicenseItem($store?$store:'http://scriptburn.com', $item_type, $item_name, $encrypter, $options);
|
27 |
return $this->items[$id];
|
28 |
}
|
29 |
public function items()
|
48 |
if (is_array($response))
|
49 |
{
|
50 |
|
51 |
+
return (object) array('status' => 1, 'body' => $response['body']);
|
52 |
}
|
53 |
else
|
54 |
{
|
55 |
+
return (object) array('status' => 1, 'message' => $response->get_error_message());
|
56 |
|
57 |
}
|
58 |
}
|
admin/license/autoload.php
CHANGED
@@ -1,18 +1,17 @@
|
|
1 |
<?php
|
2 |
include_once __DIR__ . "/LicenseManager.php";
|
3 |
include_once __DIR__ . "/LicenseItem.php";
|
4 |
-
|
|
|
5 |
{
|
6 |
-
|
7 |
-
{
|
8 |
-
return "http://scriptburn.loc";
|
9 |
-
}
|
10 |
}
|
11 |
-
|
|
|
12 |
{
|
13 |
-
return
|
14 |
}
|
15 |
-
function
|
16 |
{
|
17 |
-
return
|
18 |
}
|
1 |
<?php
|
2 |
include_once __DIR__ . "/LicenseManager.php";
|
3 |
include_once __DIR__ . "/LicenseItem.php";
|
4 |
+
include_once __DIR__ . "/encryption.php";
|
5 |
+
if (!defined('OPENSSL_RAW_DATA'))
|
6 |
{
|
7 |
+
define('OPENSSL_RAW_DATA', 1);
|
|
|
|
|
|
|
8 |
}
|
9 |
+
|
10 |
+
function scb_license_manager()
|
11 |
{
|
12 |
+
return SCB_LicenseManager::getInstance();
|
13 |
}
|
14 |
+
function scb_get_license($item)
|
15 |
{
|
16 |
+
return scb_license_manager()->item($item);
|
17 |
}
|
admin/license/encryption.php
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* A class to handle secure encryption and decryption of arbitrary data
|
4 |
+
*
|
5 |
+
* Note that this is not just straight encryption. It also has a few other
|
6 |
+
* features in it to make the encrypted data far more secure. Note that any
|
7 |
+
* other implementations used to decrypt data will have to do the same exact
|
8 |
+
* operations.
|
9 |
+
*
|
10 |
+
* Security Benefits:
|
11 |
+
*
|
12 |
+
* - Uses Key stretching
|
13 |
+
* - Hides the Initialization Vector
|
14 |
+
* - Does HMAC verification of source data
|
15 |
+
*
|
16 |
+
*/
|
17 |
+
class Encryption
|
18 |
+
{
|
19 |
+
|
20 |
+
const METHOD = 'aes-256-cbc';
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Encrypts (but does not authenticate) a message
|
24 |
+
*
|
25 |
+
* @param string $message - plaintext message
|
26 |
+
* @param string $key - encryption key (raw binary expected)
|
27 |
+
* @param boolean $encode - set to TRUE to return a base64-encoded
|
28 |
+
* @return string (raw binary)
|
29 |
+
*/
|
30 |
+
public static function encrypt($message, $key, $encode = false)
|
31 |
+
{
|
32 |
+
$ivSize = openssl_cipher_iv_length(self::METHOD);
|
33 |
+
$iv = openssl_random_pseudo_bytes($ivSize);
|
34 |
+
|
35 |
+
$ciphertext = openssl_encrypt(
|
36 |
+
$message,
|
37 |
+
self::METHOD,
|
38 |
+
$key,
|
39 |
+
OPENSSL_RAW_DATA,
|
40 |
+
$iv
|
41 |
+
);
|
42 |
+
|
43 |
+
// Now let's pack the IV and the ciphertext together
|
44 |
+
// Naively, we can just concatenate
|
45 |
+
if ($encode)
|
46 |
+
{
|
47 |
+
return base64_encode($iv . $ciphertext);
|
48 |
+
}
|
49 |
+
return $iv . $ciphertext;
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Decrypts (but does not verify) a message
|
54 |
+
*
|
55 |
+
* @param string $message - ciphertext message
|
56 |
+
* @param string $key - encryption key (raw binary expected)
|
57 |
+
* @param boolean $encoded - are we expecting an encoded string?
|
58 |
+
* @return string
|
59 |
+
*/
|
60 |
+
public static function decrypt($message, $key, $encoded = false)
|
61 |
+
{
|
62 |
+
if ($encoded)
|
63 |
+
{
|
64 |
+
$message = base64_decode($message, true);
|
65 |
+
if ($message === false)
|
66 |
+
{
|
67 |
+
throw new Exception('Encryption failure');
|
68 |
+
}
|
69 |
+
}
|
70 |
+
|
71 |
+
$ivSize = openssl_cipher_iv_length(self::METHOD);
|
72 |
+
$iv = mb_substr($message, 0, $ivSize, '8bit');
|
73 |
+
$ciphertext = mb_substr($message, $ivSize, null, '8bit');
|
74 |
+
|
75 |
+
$plaintext = openssl_decrypt(
|
76 |
+
$ciphertext,
|
77 |
+
self::METHOD,
|
78 |
+
$key,
|
79 |
+
OPENSSL_RAW_DATA,
|
80 |
+
$iv
|
81 |
+
);
|
82 |
+
|
83 |
+
return $plaintext;
|
84 |
+
}
|
85 |
+
}
|
admin/partials/quick-edit-display.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
-
|
|
|
2 |
<div class="inline-edit-col">
|
3 |
<span class="title inline-edit-categories-label">
|
4 |
<?php echo ($title); ?>
|
1 |
+
|
2 |
+
<fieldset class="inline-edit-col-right wphp_quickedit" >
|
3 |
<div class="inline-edit-col">
|
4 |
<span class="title inline-edit-categories-label">
|
5 |
<?php echo ($title); ?>
|
admin/plugin/EDD_SL_Plugin_Updater.php
ADDED
@@ -0,0 +1,384 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// uncomment this line for testing
|
4 |
+
//set_site_transient( 'update_plugins', null );
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Allows plugins to use their own update API.
|
8 |
+
*
|
9 |
+
* @author Pippin Williamson
|
10 |
+
* @version 1.6
|
11 |
+
*/
|
12 |
+
class EDD_SL_Plugin_Updater
|
13 |
+
{
|
14 |
+
private $api_url = '';
|
15 |
+
private $api_data = array();
|
16 |
+
private $name = '';
|
17 |
+
private $slug = '';
|
18 |
+
private $requests;
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Class constructor.
|
22 |
+
*
|
23 |
+
* @uses plugin_basename()
|
24 |
+
* @uses hook()
|
25 |
+
*
|
26 |
+
* @param string $_api_url The URL pointing to the custom API endpoint.
|
27 |
+
* @param string $_plugin_file Path to the plugin file.
|
28 |
+
* @param array $_api_data Optional data to send with API calls.
|
29 |
+
* @return void
|
30 |
+
*/
|
31 |
+
public function __construct($_api_url, $_plugin_file, $_api_data = null)
|
32 |
+
{
|
33 |
+
$this->api_url = trailingslashit($_api_url);
|
34 |
+
$this->api_data = $_api_data;
|
35 |
+
$this->name = plugin_basename($_plugin_file);
|
36 |
+
$this->slug = basename($_plugin_file, '.php');
|
37 |
+
$this->version = $_api_data['version'];
|
38 |
+
|
39 |
+
// Set up hooks.
|
40 |
+
$this->init();
|
41 |
+
add_action('admin_init', array($this, 'show_changelog'));
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Set up WordPress filters to hook into WP's update process.
|
46 |
+
*
|
47 |
+
* @uses add_filter()
|
48 |
+
*
|
49 |
+
* @return void
|
50 |
+
*/
|
51 |
+
public function init()
|
52 |
+
{
|
53 |
+
|
54 |
+
add_filter('pre_set_site_transient_update_plugins', array($this, 'check_update'));
|
55 |
+
add_filter('plugins_api', array($this, 'plugins_api_filter'), 10, 3);
|
56 |
+
|
57 |
+
add_action('after_plugin_row_' . $this->name, array($this, 'show_update_notification'), 10, 2);
|
58 |
+
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Check for Updates at the defined API endpoint and modify the update array.
|
63 |
+
*
|
64 |
+
* This function dives into the update API just when WordPress creates its update array,
|
65 |
+
* then adds a custom API call and injects the custom plugin data retrieved from the API.
|
66 |
+
* It is reassembled from parts of the native WordPress plugin update code.
|
67 |
+
* See wp-includes/update.php line 121 for the original wp_update_plugins() function.
|
68 |
+
*
|
69 |
+
* @uses api_request()
|
70 |
+
*
|
71 |
+
* @param array $_transient_data Update array build by WordPress.
|
72 |
+
* @return array Modified update array with custom plugin data.
|
73 |
+
*/
|
74 |
+
public function check_update($_transient_data)
|
75 |
+
{
|
76 |
+
|
77 |
+
global $pagenow;
|
78 |
+
|
79 |
+
if (!is_object($_transient_data))
|
80 |
+
{
|
81 |
+
$_transient_data = new stdClass;
|
82 |
+
}
|
83 |
+
|
84 |
+
if ('plugins.php' == $pagenow && is_multisite())
|
85 |
+
{
|
86 |
+
return $_transient_data;
|
87 |
+
}
|
88 |
+
if (isset($this->requests[$this->slug]))
|
89 |
+
{
|
90 |
+
return $this->requests[$this->slug];
|
91 |
+
}
|
92 |
+
if (empty($_transient_data->response) || empty($_transient_data->response[$this->name]))
|
93 |
+
{
|
94 |
+
|
95 |
+
$version_info = $this->api_request('plugin_latest_version', array('slug' => $this->slug));
|
96 |
+
p_l($version_info);
|
97 |
+
if (false !== $version_info && is_object($version_info) && isset($version_info->new_version))
|
98 |
+
{
|
99 |
+
|
100 |
+
$this->did_check = true;
|
101 |
+
|
102 |
+
if (version_compare($this->version, $version_info->new_version, '<'))
|
103 |
+
{
|
104 |
+
|
105 |
+
$_transient_data->response[$this->name] = $version_info;
|
106 |
+
$_transient_data->response[$this->name]->plugin = $this->name;
|
107 |
+
}
|
108 |
+
|
109 |
+
$_transient_data->last_checked = time();
|
110 |
+
//$_transient_data->last_updated=date( ( 'M j, Y @ H:i' )
|
111 |
+
$_transient_data->checked[$this->name] = $this->version;
|
112 |
+
|
113 |
+
}
|
114 |
+
$this->requests[$this->slug] = $_transient_data;
|
115 |
+
}
|
116 |
+
//error_log(prin$_transient_data);
|
117 |
+
|
118 |
+
return $_transient_data;
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise!
|
123 |
+
*
|
124 |
+
* @param string $file
|
125 |
+
* @param array $plugin
|
126 |
+
*/
|
127 |
+
public function show_update_notification($file, $plugin)
|
128 |
+
{
|
129 |
+
|
130 |
+
if (!current_user_can('update_plugins'))
|
131 |
+
{
|
132 |
+
return;
|
133 |
+
}
|
134 |
+
|
135 |
+
if (!is_multisite())
|
136 |
+
{
|
137 |
+
return;
|
138 |
+
}
|
139 |
+
|
140 |
+
if ($this->name != $file)
|
141 |
+
{
|
142 |
+
return;
|
143 |
+
}
|
144 |
+
|
145 |
+
// Remove our filter on the site transient
|
146 |
+
remove_filter('pre_set_site_transient_update_plugins', array($this, 'check_update'), 10);
|
147 |
+
|
148 |
+
$update_cache = get_site_transient('update_plugins');
|
149 |
+
|
150 |
+
if (!is_object($update_cache) || empty($update_cache->response) || empty($update_cache->response[$this->name]))
|
151 |
+
{
|
152 |
+
|
153 |
+
$cache_key = md5('edd_plugin_' . sanitize_key($this->name) . '_version_info');
|
154 |
+
$version_info = get_transient($cache_key);
|
155 |
+
|
156 |
+
if (false === $version_info)
|
157 |
+
{
|
158 |
+
|
159 |
+
$version_info = $this->api_request('plugin_latest_version', array('slug' => $this->slug));
|
160 |
+
//p_l($version_info);
|
161 |
+
|
162 |
+
set_transient($cache_key, $version_info, 3600);
|
163 |
+
}
|
164 |
+
|
165 |
+
if (!is_object($version_info))
|
166 |
+
{
|
167 |
+
return;
|
168 |
+
}
|
169 |
+
|
170 |
+
if (version_compare($this->version, $version_info->new_version, '<'))
|
171 |
+
{
|
172 |
+
|
173 |
+
$update_cache->response[$this->name] = $version_info;
|
174 |
+
|
175 |
+
}
|
176 |
+
|
177 |
+
$update_cache->last_checked = time();
|
178 |
+
$update_cache->checked[$this->name] = $this->version;
|
179 |
+
|
180 |
+
set_site_transient('update_plugins', $update_cache);
|
181 |
+
|
182 |
+
}
|
183 |
+
else
|
184 |
+
{
|
185 |
+
|
186 |
+
$version_info = $update_cache->response[$this->name];
|
187 |
+
|
188 |
+
}
|
189 |
+
|
190 |
+
// Restore our filter
|
191 |
+
add_filter('pre_set_site_transient_update_plugins', array($this, 'check_update'));
|
192 |
+
|
193 |
+
if (!empty($update_cache->response[$this->name]) && version_compare($this->version, $version_info->new_version, '<'))
|
194 |
+
{
|
195 |
+
|
196 |
+
// build a plugin list row, with update notification
|
197 |
+
$wp_list_table = _get_list_table('WP_Plugins_List_Table');
|
198 |
+
echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">';
|
199 |
+
|
200 |
+
$changelog_link = self_admin_url('index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911');
|
201 |
+
|
202 |
+
if (empty($version_info->download_link))
|
203 |
+
{
|
204 |
+
printf(
|
205 |
+
__('There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'edd'),
|
206 |
+
esc_html($version_info->name),
|
207 |
+
esc_url($changelog_link),
|
208 |
+
esc_html($version_info->new_version)
|
209 |
+
);
|
210 |
+
}
|
211 |
+
else
|
212 |
+
{
|
213 |
+
printf(
|
214 |
+
__('There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a> or <a href="%4$s">update now</a>.', 'edd'),
|
215 |
+
esc_html($version_info->name),
|
216 |
+
esc_url($changelog_link),
|
217 |
+
esc_html($version_info->new_version),
|
218 |
+
esc_url(wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=') . $this->name, 'upgrade-plugin_' . $this->name))
|
219 |
+
);
|
220 |
+
}
|
221 |
+
|
222 |
+
echo '</div></td></tr>';
|
223 |
+
}
|
224 |
+
}
|
225 |
+
|
226 |
+
/**
|
227 |
+
* Updates information on the "View version x.x details" page with custom data.
|
228 |
+
*
|
229 |
+
* @uses api_request()
|
230 |
+
*
|
231 |
+
* @param mixed $_data
|
232 |
+
* @param string $_action
|
233 |
+
* @param object $_args
|
234 |
+
* @return object $_data
|
235 |
+
*/
|
236 |
+
public function plugins_api_filter($_data, $_action = '', $_args = null)
|
237 |
+
{
|
238 |
+
|
239 |
+
if ($_action != 'plugin_information')
|
240 |
+
{
|
241 |
+
|
242 |
+
return $_data;
|
243 |
+
|
244 |
+
}
|
245 |
+
|
246 |
+
if (!isset($_args->slug) || ($_args->slug != $this->slug))
|
247 |
+
{
|
248 |
+
|
249 |
+
return $_data;
|
250 |
+
|
251 |
+
}
|
252 |
+
|
253 |
+
$to_send = array(
|
254 |
+
'slug' => $this->slug,
|
255 |
+
'is_ssl' => is_ssl(),
|
256 |
+
'fields' => array(
|
257 |
+
'banners' => false, // These will be supported soon hopefully
|
258 |
+
'reviews' => false,
|
259 |
+
),
|
260 |
+
);
|
261 |
+
|
262 |
+
$api_response = $this->api_request('plugin_information', $to_send);
|
263 |
+
|
264 |
+
if (false !== $api_response)
|
265 |
+
{
|
266 |
+
$_data = $api_response;
|
267 |
+
}
|
268 |
+
|
269 |
+
return $_data;
|
270 |
+
}
|
271 |
+
|
272 |
+
/**
|
273 |
+
* Disable SSL verification in order to prevent download update failures
|
274 |
+
*
|
275 |
+
* @param array $args
|
276 |
+
* @param string $url
|
277 |
+
* @return object $array
|
278 |
+
*/
|
279 |
+
public function http_request_args($args, $url)
|
280 |
+
{
|
281 |
+
// If it is an https request and we are performing a package download, disable ssl verification
|
282 |
+
if (strpos($url, 'https://') !== false && strpos($url, 'edd_action=package_download'))
|
283 |
+
{
|
284 |
+
$args['sslverify'] = false;
|
285 |
+
}
|
286 |
+
return $args;
|
287 |
+
}
|
288 |
+
|
289 |
+
/**
|
290 |
+
* Calls the API and, if successfull, returns the object delivered by the API.
|
291 |
+
*
|
292 |
+
* @uses get_bloginfo()
|
293 |
+
* @uses wp_remote_post()
|
294 |
+
* @uses is_wp_error()
|
295 |
+
*
|
296 |
+
* @param string $_action The requested action.
|
297 |
+
* @param array $_data Parameters for the API action.
|
298 |
+
* @return false||object
|
299 |
+
*/
|
300 |
+
private function api_request($_action, $_data)
|
301 |
+
{
|
302 |
+
|
303 |
+
global $wp_version;
|
304 |
+
|
305 |
+
$data = array_merge($this->api_data, $_data);
|
306 |
+
|
307 |
+
if ($data['slug'] != $this->slug)
|
308 |
+
{
|
309 |
+
return;
|
310 |
+
}
|
311 |
+
|
312 |
+
if (empty($data['license']))
|
313 |
+
{
|
314 |
+
return;
|
315 |
+
}
|
316 |
+
|
317 |
+
if ($this->api_url == home_url())
|
318 |
+
{
|
319 |
+
return false; // Don't allow a plugin to ping itself
|
320 |
+
}
|
321 |
+
|
322 |
+
$api_params = array(
|
323 |
+
'edd_action' => 'get_version',
|
324 |
+
'license' => $data['license'],
|
325 |
+
'item_name' => isset($data['item_name']) ? $data['item_name'] : false,
|
326 |
+
'item_id' => isset($data['item_id']) ? $data['item_id'] : false,
|
327 |
+
'slug' => $data['slug'],
|
328 |
+
'author' => $data['author'],
|
329 |
+
'url' => home_url(),
|
330 |
+
);
|
331 |
+
|
332 |
+
$request = wp_remote_post($this->api_url, array('timeout' => 15, 'sslverify' => false, 'body' => $api_params));
|
333 |
+
//p_l($request);
|
334 |
+
if (!is_wp_error($request))
|
335 |
+
{
|
336 |
+
$request = json_decode(wp_remote_retrieve_body($request));
|
337 |
+
}
|
338 |
+
|
339 |
+
if ($request && isset($request->sections))
|
340 |
+
{
|
341 |
+
$request->sections = maybe_unserialize($request->sections);
|
342 |
+
}
|
343 |
+
else
|
344 |
+
{
|
345 |
+
$request = false;
|
346 |
+
}
|
347 |
+
|
348 |
+
return $request;
|
349 |
+
}
|
350 |
+
|
351 |
+
public function show_changelog()
|
352 |
+
{
|
353 |
+
|
354 |
+
if (empty($_REQUEST['edd_sl_action']) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'])
|
355 |
+
{
|
356 |
+
return;
|
357 |
+
}
|
358 |
+
|
359 |
+
if (empty($_REQUEST['plugin']))
|
360 |
+
{
|
361 |
+
return;
|
362 |
+
}
|
363 |
+
|
364 |
+
if (empty($_REQUEST['slug']))
|
365 |
+
{
|
366 |
+
return;
|
367 |
+
}
|
368 |
+
|
369 |
+
if (!current_user_can('update_plugins'))
|
370 |
+
{
|
371 |
+
wp_die(__('You do not have permission to install plugin updates', 'edd'), __('Error', 'edd'), array('response' => 403));
|
372 |
+
}
|
373 |
+
|
374 |
+
$response = $this->api_request('plugin_latest_version', array('slug' => $_REQUEST['slug']));
|
375 |
+
|
376 |
+
if ($response && isset($response->sections['changelog']))
|
377 |
+
{
|
378 |
+
echo '<div style="background:#fff;padding:10px;">' . $response->sections['changelog'] . '</div>';
|
379 |
+
}
|
380 |
+
|
381 |
+
exit;
|
382 |
+
}
|
383 |
+
|
384 |
+
}
|
admin/plugin/EDD_SL_Theme_Updater.php
ADDED
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class EDD_SL_Theme_Updater {
|
3 |
+
private $remote_api_url;
|
4 |
+
private $request_data;
|
5 |
+
private $response_key;
|
6 |
+
private $theme_slug;
|
7 |
+
private $license_key;
|
8 |
+
private $version;
|
9 |
+
private $author;
|
10 |
+
|
11 |
+
function __construct( $args = array() ) {
|
12 |
+
$args = wp_parse_args( $args, array(
|
13 |
+
'remote_api_url' => 'http://scriptburn.com',
|
14 |
+
'request_data' => array(),
|
15 |
+
'theme_slug' => get_template(),
|
16 |
+
'item_name' => '',
|
17 |
+
'license' => '',
|
18 |
+
'version' => '',
|
19 |
+
'author' => ''
|
20 |
+
) );
|
21 |
+
extract( $args );
|
22 |
+
|
23 |
+
$theme = wp_get_theme( sanitize_key( $theme_slug ) );
|
24 |
+
$this->license = $license;
|
25 |
+
$this->item_name = $item_name;
|
26 |
+
$this->version = ! empty( $version ) ? $version : $theme->get( 'Version' );
|
27 |
+
$this->theme_slug = sanitize_key( $theme_slug );
|
28 |
+
$this->author = $author;
|
29 |
+
$this->remote_api_url = $remote_api_url;
|
30 |
+
$this->response_key = $this->theme_slug . '-update-response';
|
31 |
+
|
32 |
+
add_filter( 'site_transient_update_themes', array( &$this, 'theme_update_transient' ) );
|
33 |
+
add_filter( 'delete_site_transient_update_themes', array( &$this, 'delete_theme_update_transient' ) );
|
34 |
+
add_action( 'load-update-core.php', array( &$this, 'delete_theme_update_transient' ) );
|
35 |
+
add_action( 'load-themes.php', array( &$this, 'delete_theme_update_transient' ) );
|
36 |
+
add_action( 'load-themes.php', array( &$this, 'load_themes_screen' ) );
|
37 |
+
//$this->check_for_update();
|
38 |
+
}
|
39 |
+
|
40 |
+
function load_themes_screen() {
|
41 |
+
add_thickbox();
|
42 |
+
add_action( 'admin_notices', array( &$this, 'update_nag' ) );
|
43 |
+
}
|
44 |
+
|
45 |
+
function update_nag() {
|
46 |
+
error_log("update_nag");
|
47 |
+
$theme = wp_get_theme( $this->theme_slug );
|
48 |
+
|
49 |
+
$api_response = get_transient( $this->response_key );
|
50 |
+
|
51 |
+
if( false === $api_response )
|
52 |
+
return;
|
53 |
+
|
54 |
+
$update_url = wp_nonce_url( 'update.php?action=upgrade-theme&theme=' . urlencode( $this->theme_slug ), 'upgrade-theme_' . $this->theme_slug );
|
55 |
+
$update_onclick = ' onclick="if ( confirm(\'' . esc_js( __( "Updating this theme will lose any customizations you have made. 'Cancel' to stop, 'OK' to update." ) ) . '\') ) {return true;}return false;"';
|
56 |
+
|
57 |
+
if ( version_compare( $this->version, $api_response->new_version, '<' ) ) {
|
58 |
+
|
59 |
+
echo '<div id="update-nag">';
|
60 |
+
printf( '<strong>%1$s %2$s</strong> is available. <a href="%3$s" class="thickbox" title="%4s">Check out what\'s new</a> or <a href="%5$s"%6$s>update now</a>.',
|
61 |
+
$theme->get( 'Name' ),
|
62 |
+
$api_response->new_version,
|
63 |
+
'#TB_inline?width=640&inlineId=' . $this->theme_slug . '_changelog',
|
64 |
+
$theme->get( 'Name' ),
|
65 |
+
$update_url,
|
66 |
+
$update_onclick
|
67 |
+
);
|
68 |
+
echo '</div>';
|
69 |
+
echo '<div id="' . $this->theme_slug . '_' . 'changelog" style="display:none;">';
|
70 |
+
echo wpautop( $api_response->sections['changelog'] );
|
71 |
+
echo '</div>';
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
+
function theme_update_transient( $value ) {
|
76 |
+
$update_data = $this->check_for_update();
|
77 |
+
if ( $update_data ) {
|
78 |
+
$value->response[ $this->theme_slug ] = $update_data;
|
79 |
+
}
|
80 |
+
return $value;
|
81 |
+
}
|
82 |
+
|
83 |
+
function delete_theme_update_transient() {
|
84 |
+
delete_transient( $this->response_key );
|
85 |
+
}
|
86 |
+
|
87 |
+
function check_for_update() {
|
88 |
+
|
89 |
+
$theme = wp_get_theme( $this->theme_slug );
|
90 |
+
//delete_transient( $this->response_key );
|
91 |
+
$update_data = get_transient( $this->response_key );
|
92 |
+
//print_nice($update_data);
|
93 |
+
if ( false === $update_data ) {
|
94 |
+
$failed = false;
|
95 |
+
|
96 |
+
|
97 |
+
if( empty( $this->license ) )
|
98 |
+
return false;
|
99 |
+
|
100 |
+
$api_params = array(
|
101 |
+
'edd_action' => 'get_version',
|
102 |
+
'license' => $this->license,
|
103 |
+
'name' => $this->item_name,
|
104 |
+
'slug' => $this->theme_slug,
|
105 |
+
'author' => $this->author,
|
106 |
+
'url' => home_url()
|
107 |
+
);
|
108 |
+
|
109 |
+
$response = wp_remote_post( $this->remote_api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
|
110 |
+
//print_nice($response);
|
111 |
+
// make sure the response was successful
|
112 |
+
if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
|
113 |
+
$failed = true;
|
114 |
+
}
|
115 |
+
|
116 |
+
$update_data = json_decode( wp_remote_retrieve_body( $response ) );
|
117 |
+
if ( ! is_object( $update_data ) ) {
|
118 |
+
$failed = true;
|
119 |
+
}
|
120 |
+
|
121 |
+
// if the response failed, try again in 30 minutes
|
122 |
+
if ( $failed ) {
|
123 |
+
$data = new stdClass;
|
124 |
+
$data->new_version = $this->version;
|
125 |
+
set_transient( $this->response_key, $data, strtotime( '+30 minutes' ) );
|
126 |
+
return false;
|
127 |
+
}
|
128 |
+
|
129 |
+
// if the status is 'ok', return the update arguments
|
130 |
+
if ( ! $failed ) {
|
131 |
+
$update_data->sections = maybe_unserialize( $update_data->sections );
|
132 |
+
set_transient( $this->response_key, $update_data, strtotime( '+12 hours' ) );
|
133 |
+
}
|
134 |
+
}
|
135 |
+
//die('x');
|
136 |
+
if ( version_compare( $this->version, $update_data->new_version, '>=' ) ) {
|
137 |
+
return false;
|
138 |
+
}
|
139 |
+
|
140 |
+
return (array) $update_data;
|
141 |
+
}
|
142 |
+
}
|
admin/plugin/SCB_Item_Helper.php
ADDED
@@ -0,0 +1,189 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if (!class_exists('SCB_Item_Helper'))
|
4 |
+
{
|
5 |
+
|
6 |
+
class SCB_Item_Helper
|
7 |
+
{
|
8 |
+
private $item_file_name = "";
|
9 |
+
private $store = "";
|
10 |
+
private $item_arr = array();
|
11 |
+
private $license_key = "";
|
12 |
+
private $item_type = 'plugin';
|
13 |
+
private $license_status = '';
|
14 |
+
private $transient_name = 'scb_lic_data';
|
15 |
+
|
16 |
+
public function __construct($store, $item_file_name, $license_key, $item_type = 'plugin', $license_status)
|
17 |
+
{
|
18 |
+
global $pagenow;
|
19 |
+
$custom_name = substr($item_type, 7);
|
20 |
+
$is_custom = substr($item_type, 0, 7) == 'custom_' && strlen($custom_name) > 0;
|
21 |
+
$valid_items = array('plugin', 'theme');
|
22 |
+
if (!in_array($item_type, $valid_items))
|
23 |
+
{
|
24 |
+
if (!$is_custom)
|
25 |
+
{
|
26 |
+
throw new Exception('Invalid tem Type');
|
27 |
+
return false;
|
28 |
+
}
|
29 |
+
}
|
30 |
+
if (substr($item_file_name, 0, strlen(WP_PLUGIN_DIR)) == WP_PLUGIN_DIR)
|
31 |
+
{
|
32 |
+
$this->item_file_name = ltrim(substr($item_file_name, strlen(WP_PLUGIN_DIR)), "/");
|
33 |
+
}
|
34 |
+
else
|
35 |
+
{
|
36 |
+
$this->item_file_name = $item_file_name;
|
37 |
+
}
|
38 |
+
$this->store = $store;
|
39 |
+
$this->item_type = $item_type;
|
40 |
+
$this->license_key = $license_key;
|
41 |
+
$this->license_status = $license_status;
|
42 |
+
//$this->debug('license', __FUNCTION__ . "-" . __LINE__, 'init');
|
43 |
+
|
44 |
+
if (!$is_custom)
|
45 |
+
{
|
46 |
+
add_action('admin_init', array($this, $item_type . '_updater'));
|
47 |
+
}
|
48 |
+
else
|
49 |
+
{
|
50 |
+
call_user_function($custom_name . "_updater");
|
51 |
+
|
52 |
+
}
|
53 |
+
$update_cache = get_site_transient('update_plugins');
|
54 |
+
if ( isset($update_cache->response[$this->item_file_name]) && ($update_cache->response[$this->item_file_name]->upgrade_notice) )
|
55 |
+
{
|
56 |
+
$upgrade_notice=$update_cache->response[$this->item_file_name]->upgrade_notice;
|
57 |
+
$hook = "in_plugin_update_message-" . $this->item_file_name;
|
58 |
+
add_action($hook, function ($plugin_data, $r) use($upgrade_notice)
|
59 |
+
{
|
60 |
+
|
61 |
+
echo($upgrade_notice);
|
62 |
+
|
63 |
+
}, 20, 2);
|
64 |
+
}
|
65 |
+
|
66 |
+
}
|
67 |
+
public function get_license_key()
|
68 |
+
{
|
69 |
+
return $this->license_key;
|
70 |
+
|
71 |
+
}
|
72 |
+
public function refresh_plugin_data()
|
73 |
+
{
|
74 |
+
$default = array('version' => "0", 'license' => "", "item_name" => '', "author" => "");
|
75 |
+
|
76 |
+
try {
|
77 |
+
$plugin_file = WP_PLUGIN_DIR . "/" . $this->item_file_name;
|
78 |
+
// $this->debug('license', __FUNCTION__ . "-" . __LINE__, $plugin_file);
|
79 |
+
if (!function_exists('get_plugin_data'))
|
80 |
+
{
|
81 |
+
include_once ABSPATH . "wp-admin/includes/plugin.php";
|
82 |
+
}
|
83 |
+
//$this->debug('license', __FUNCTION__ . "-" . __LINE__, $d);
|
84 |
+
|
85 |
+
$this->item_arr[$this->item_file_name] = get_plugin_data($plugin_file);
|
86 |
+
set_transient($this->transient_name, $this->item_arr);
|
87 |
+
return $this->item_arr;
|
88 |
+
}
|
89 |
+
catch (exception $e)
|
90 |
+
{
|
91 |
+
return $default;
|
92 |
+
}
|
93 |
+
}
|
94 |
+
public function plugin_data($key = "", $fresh = false)
|
95 |
+
{
|
96 |
+
if ($fresh)
|
97 |
+
{
|
98 |
+
$this->refresh_plugin_data();
|
99 |
+
}
|
100 |
+
else
|
101 |
+
{
|
102 |
+
|
103 |
+
$this->item_arr = get_transient($this->transient_name);
|
104 |
+
if (!isset($this->item_arr[$this->item_file_name]))
|
105 |
+
{
|
106 |
+
$ret = $this->refresh_plugin_data();
|
107 |
+
return $key ? $ret[$this->item_file_name][$key] : $ret[$this->item_file_name];
|
108 |
+
|
109 |
+
}
|
110 |
+
|
111 |
+
}
|
112 |
+
return $key ? $this->item_arr[$this->item_file_name][$key] : $this->item_arr[$this->item_file_name];
|
113 |
+
|
114 |
+
}
|
115 |
+
public function refresh_theme_data()
|
116 |
+
{
|
117 |
+
$default = array('version' => "0", 'license' => "", "item_name" => '', "author" => "");
|
118 |
+
|
119 |
+
try {
|
120 |
+
$theme_file = get_theme_root() . "/" . $this->item_file_name;
|
121 |
+
// $this->debug('license', __FUNCTION__ . "-" . __LINE__, $plugin_file);
|
122 |
+
if (!function_exists('wp_get_theme'))
|
123 |
+
{
|
124 |
+
include_once ABSPATH . "wp-admin/includes/theme.php";
|
125 |
+
}
|
126 |
+
//$this->debug('license', __FUNCTION__ . "-" . __LINE__, $d);
|
127 |
+
|
128 |
+
$this->item_arr[$this->item_file_name] = wp_get_theme($this->item_file_name);
|
129 |
+
set_transient('wpmovies_themes', $this->item_arr);
|
130 |
+
$return = $this->item_arr[$this->item_file_name];
|
131 |
+
}
|
132 |
+
catch (exception $e)
|
133 |
+
{
|
134 |
+
return $default;
|
135 |
+
}
|
136 |
+
}
|
137 |
+
public function theme_data($key = "", $fresh = false)
|
138 |
+
{
|
139 |
+
if ($fresh)
|
140 |
+
{
|
141 |
+
$this->refresh_theme_data();
|
142 |
+
}
|
143 |
+
else
|
144 |
+
{
|
145 |
+
|
146 |
+
$this->item_arr = get_transient('wpmovies_themes');
|
147 |
+
if (!isset($this->item_arr[$this->item_file_name]))
|
148 |
+
{
|
149 |
+
$ret = $this->refresh_theme_data();
|
150 |
+
return $key ? $ret[$this->item_file_name][$key] : $ret[$this->item_file_name];
|
151 |
+
}
|
152 |
+
}
|
153 |
+
return $key ? $this->item_arr[$this->item_file_name][$key] : $this->item_arr[$this->item_file_name];
|
154 |
+
|
155 |
+
}
|
156 |
+
|
157 |
+
public function plugin_updater()
|
158 |
+
{
|
159 |
+
$plugin_data = $this->plugin_data("", true);
|
160 |
+
$plugin_conf = array(
|
161 |
+
'version' => $plugin_data['Version'], // current version number
|
162 |
+
'license' => $this->get_license_key(),
|
163 |
+
'item_name' => $plugin_data['Name'],
|
164 |
+
'author' => $plugin_data['AuthorName'],
|
165 |
+
'url' => home_url(),
|
166 |
+
);
|
167 |
+
//$this->debug('license', __FUNCTION__ . "-" . __LINE__, 'plugin_updater');
|
168 |
+
|
169 |
+
$updater = new EDD_SL_Plugin_Updater($this->store, $this->item_file_name, $plugin_conf);
|
170 |
+
}
|
171 |
+
|
172 |
+
public function theme_updater()
|
173 |
+
{
|
174 |
+
$theme_data = $this->theme_data("", true);
|
175 |
+
$theme_conf = array(
|
176 |
+
'theme_slug' => $this->item_file_name,
|
177 |
+
'remote_api_url' => $this->store,
|
178 |
+
'version' => $theme_data->Version, // current version number
|
179 |
+
'license' => $this->get_license_key(),
|
180 |
+
'item_name' => $theme_data->Name,
|
181 |
+
'author' => $theme_data->Author,
|
182 |
+
'url' => home_url(),
|
183 |
+
);
|
184 |
+
$edd_updater = new EDD_SL_Theme_Updater($theme_conf);
|
185 |
+
}
|
186 |
+
|
187 |
+
}
|
188 |
+
|
189 |
+
}
|
admin/plugin/autoload.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if (!class_exists('EDD_SL_Plugin_Updater'))
|
3 |
+
{
|
4 |
+
include_once dirname(__FILE__) . "/EDD_SL_Plugin_Updater.php";
|
5 |
+
}
|
6 |
+
|
7 |
+
if (!class_exists('EDD_SL_Theme_Updater'))
|
8 |
+
{
|
9 |
+
include_once dirname(__FILE__) . "/EDD_SL_Theme_Updater.php";
|
10 |
+
}
|
11 |
+
|
12 |
+
if (!class_exists('SCB_Item_Helper'))
|
13 |
+
{
|
14 |
+
include_once dirname(__FILE__) . "/SCB_Item_Helper.php";
|
15 |
+
}
|
admin/plugin/testlog.txt
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[Debug for [license] item [get_license_data-97]-> Array
|
2 |
+
(
|
3 |
+
[success] => 1
|
4 |
+
[license] => invalid
|
5 |
+
[item_name] => WP+movies
|
6 |
+
[expires] =>
|
7 |
+
[payment_id] =>
|
8 |
+
[customer_name] =>
|
9 |
+
[customer_email] =>
|
10 |
+
[license_limit] =>
|
11 |
+
[site_count] => 0
|
12 |
+
[activations_left] => unlimited
|
13 |
+
)
|
14 |
+
|
admin/settings/assets/chosen-sprite@2x.png
ADDED
Binary file
|
admin/settings/autoload.php
CHANGED
@@ -16,7 +16,10 @@ 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 = "")
|
@@ -36,3 +39,239 @@ if (!function_exists('wphp_get_default_setting'))
|
|
36 |
return $section ? ($name ? @$settings[$section][$name] : @$settings[$section]) : $default;
|
37 |
}
|
38 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
{
|
17 |
include_once dirname(__FILE__) . "/class_settingsAPICustom.php";
|
18 |
}
|
19 |
+
if (!class_exists('Browser'))
|
20 |
+
{
|
21 |
+
include_once dirname(__FILE__) . "/browser.php";
|
22 |
+
}
|
23 |
if (!function_exists('wphp_get_default_setting'))
|
24 |
{
|
25 |
function wphp_get_default_setting($section = '', $name = "")
|
39 |
return $section ? ($name ? @$settings[$section][$name] : @$settings[$section]) : $default;
|
40 |
}
|
41 |
}
|
42 |
+
/**
|
43 |
+
* Get system info
|
44 |
+
*
|
45 |
+
* @since 2.0
|
46 |
+
* @access public
|
47 |
+
* @global object $wpdb Used to query the database using the WordPress Database API
|
48 |
+
* @return string $return A string containing the info to output
|
49 |
+
*/
|
50 |
+
|
51 |
+
function scb_systems_info($sep="\n")
|
52 |
+
{
|
53 |
+
global $wpdb;
|
54 |
+
|
55 |
+
if (!class_exists('Browser'))
|
56 |
+
{
|
57 |
+
require_once 'browser.php';
|
58 |
+
}
|
59 |
+
|
60 |
+
$browser = new Browser();
|
61 |
+
|
62 |
+
// Get theme info
|
63 |
+
if (get_bloginfo('version') < '3.4')
|
64 |
+
{
|
65 |
+
$theme_data = get_theme_data(get_stylesheet_directory() . '/style.css');
|
66 |
+
$theme = $theme_data['Name'] . ' ' . $theme_data['Version'];
|
67 |
+
}
|
68 |
+
else
|
69 |
+
{
|
70 |
+
$theme_data = wp_get_theme();
|
71 |
+
$theme = $theme_data->Name . ' ' . $theme_data->Version;
|
72 |
+
}
|
73 |
+
|
74 |
+
// Try to identify the hosting provider
|
75 |
+
$host = wphp_get_host();
|
76 |
+
|
77 |
+
$return = '### Begin System Info ###' . "$sep$sep";
|
78 |
+
|
79 |
+
// Start with the basics...
|
80 |
+
$return .= '-- Site Info' . "$sep$sep";
|
81 |
+
$return .= 'Site URL: ' . site_url() . "$sep";
|
82 |
+
$return .= 'Home URL: ' . home_url() . "$sep";
|
83 |
+
$return .= 'Multisite: ' . (is_multisite() ? 'Yes' : 'No') . "$sep";
|
84 |
+
|
85 |
+
$return = apply_filters('scb_sysinfo_after_site_info', $return);
|
86 |
+
|
87 |
+
// Can we determine the site's host?
|
88 |
+
if ($host)
|
89 |
+
{
|
90 |
+
$return .= "$sep" . '-- Hosting Provider' . "$sep$sep";
|
91 |
+
$return .= 'Host: ' . $host . "$sep";
|
92 |
+
|
93 |
+
$return = apply_filters('scb_sysinfo_after_host_info', $return);
|
94 |
+
}
|
95 |
+
|
96 |
+
// The local users' browser information, handled by the Browser class
|
97 |
+
$return .= "$sep" . '-- User Browser' . "$sep$sep";
|
98 |
+
$return .= $browser;
|
99 |
+
|
100 |
+
$return = apply_filters('scb_sysinfo_after_user_browser', $return);
|
101 |
+
|
102 |
+
// WordPress configuration
|
103 |
+
$return .= "$sep" . '-- WordPress Configuration' . "$sep$sep";
|
104 |
+
$return .= 'Version: ' . get_bloginfo('version') . "$sep";
|
105 |
+
$return .= 'Language: ' . (defined('WPLANG') && WPLANG ? WPLANG : 'en_US') . "$sep";
|
106 |
+
$return .= 'Permalink Structure: ' . (get_option('permalink_structure') ? get_option('permalink_structure') : 'Default') . "$sep";
|
107 |
+
$return .= 'Active Theme: ' . $theme . "$sep";
|
108 |
+
$return .= 'Show On Front: ' . get_option('show_on_front') . "$sep";
|
109 |
+
|
110 |
+
// Only show page specs if frontpage is set to 'page'
|
111 |
+
if (get_option('show_on_front') == 'page')
|
112 |
+
{
|
113 |
+
$front_page_id = get_option('page_on_front');
|
114 |
+
$blog_page_id = get_option('page_for_posts');
|
115 |
+
|
116 |
+
$return .= 'Page On Front: ' . ($front_page_id != 0 ? get_the_title($front_page_id) . ' (#' . $front_page_id . ')' : 'Unset') . "$sep";
|
117 |
+
$return .= 'Page For Posts: ' . ($blog_page_id != 0 ? get_the_title($blog_page_id) . ' (#' . $blog_page_id . ')' : 'Unset') . "$sep";
|
118 |
+
}
|
119 |
+
|
120 |
+
// Make sure wp_remote_post() is working
|
121 |
+
$request['cmd'] = '_notify-validate';
|
122 |
+
|
123 |
+
$params = array(
|
124 |
+
'sslverify' => false,
|
125 |
+
'timeout' => 60,
|
126 |
+
'user-agent' => 'SCB/' . WPHP_VER,
|
127 |
+
'body' => $request,
|
128 |
+
);
|
129 |
+
|
130 |
+
$response = wp_remote_post('https://www.paypal.com/cgi-bin/webscr', $params);
|
131 |
+
|
132 |
+
if (!is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300)
|
133 |
+
{
|
134 |
+
$WP_REMOTE_POST = 'wp_remote_post() works';
|
135 |
+
}
|
136 |
+
else
|
137 |
+
{
|
138 |
+
$WP_REMOTE_POST = 'wp_remote_post() does not work';
|
139 |
+
}
|
140 |
+
|
141 |
+
$return .= 'Remote Post: ' . $WP_REMOTE_POST . "$sep";
|
142 |
+
$return .= 'Table Prefix: ' . 'Length: ' . strlen($wpdb->prefix) . ' Status: ' . (strlen($wpdb->prefix) > 16 ? 'ERROR: Too long' : 'Acceptable') . "$sep";
|
143 |
+
$return .= 'WP_DEBUG: ' . (defined('WP_DEBUG') ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set') . "$sep";
|
144 |
+
$return .= 'Memory Limit: ' . WP_MEMORY_LIMIT . "$sep";
|
145 |
+
$return .= 'Registered Post Types: ' . implode(', ', scb_custom_post_types('names')) . "$sep";
|
146 |
+
|
147 |
+
$return = apply_filters('scb_sysinfo_after_wordpress_config', $return);
|
148 |
+
|
149 |
+
// EDD configuration
|
150 |
+
|
151 |
+
$return = apply_filters('scb_sysinfo_after_plugin_config', $return);
|
152 |
+
|
153 |
+
// Must-use plugins
|
154 |
+
if ( ! function_exists( 'get_plugins' ) ) {
|
155 |
+
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
156 |
+
}
|
157 |
+
$muplugins = function_exists('get_mu_plugins')?get_mu_plugins():array();
|
158 |
+
if (count($muplugins > 0))
|
159 |
+
{
|
160 |
+
$return .= "$sep" . '-- Must-Use Plugins' . "$sep$sep";
|
161 |
+
|
162 |
+
foreach ($muplugins as $plugin => $plugin_data)
|
163 |
+
{
|
164 |
+
$return .= $plugin_data['Name'] . ': ' . $plugin_data['Version'] . "$sep";
|
165 |
+
}
|
166 |
+
|
167 |
+
$return = apply_filters('scb_sysinfo_after_wordpress_mu_plugins', $return);
|
168 |
+
}
|
169 |
+
|
170 |
+
// WordPress active plugins
|
171 |
+
$return .= "$sep" . '-- WordPress Active Plugins' . "$sep$sep";
|
172 |
+
|
173 |
+
$plugins = get_plugins();
|
174 |
+
$active_plugins = get_option('active_plugins', array());
|
175 |
+
|
176 |
+
foreach ($plugins as $plugin_path => $plugin)
|
177 |
+
{
|
178 |
+
if (!in_array($plugin_path, $active_plugins))
|
179 |
+
{
|
180 |
+
continue;
|
181 |
+
}
|
182 |
+
|
183 |
+
$return .= $plugin['Name'] . ': ' . $plugin['Version'] . "$sep";
|
184 |
+
}
|
185 |
+
|
186 |
+
$return = apply_filters('scb_sysinfo_after_wordpress_plugins', $return);
|
187 |
+
|
188 |
+
// WordPress inactive plugins
|
189 |
+
$return .= "$sep" . '-- WordPress Inactive Plugins' . "$sep$sep";
|
190 |
+
|
191 |
+
foreach ($plugins as $plugin_path => $plugin)
|
192 |
+
{
|
193 |
+
if (in_array($plugin_path, $active_plugins))
|
194 |
+
{
|
195 |
+
continue;
|
196 |
+
}
|
197 |
+
|
198 |
+
$return .= $plugin['Name'] . ': ' . $plugin['Version'] . "$sep";
|
199 |
+
}
|
200 |
+
|
201 |
+
$return = apply_filters('scb_sysinfo_after_wordpress_plugins_inactive', $return);
|
202 |
+
|
203 |
+
if (is_multisite())
|
204 |
+
{
|
205 |
+
// WordPress Multisite active plugins
|
206 |
+
$return .= "$sep" . '-- Network Active Plugins' . "$sep$sep";
|
207 |
+
|
208 |
+
$plugins = wp_get_active_network_plugins();
|
209 |
+
$active_plugins = get_site_option('active_sitewide_plugins', array());
|
210 |
+
|
211 |
+
foreach ($plugins as $plugin_path)
|
212 |
+
{
|
213 |
+
$plugin_base = plugin_basename($plugin_path);
|
214 |
+
|
215 |
+
if (!array_key_exists($plugin_base, $active_plugins))
|
216 |
+
{
|
217 |
+
continue;
|
218 |
+
}
|
219 |
+
|
220 |
+
$plugin = get_plugin_data($plugin_path);
|
221 |
+
$return .= $plugin['Name'] . ': ' . $plugin['Version'] . "$sep";
|
222 |
+
}
|
223 |
+
|
224 |
+
$return = apply_filters('scb_sysinfo_after_wordpress_ms_plugins', $return);
|
225 |
+
}
|
226 |
+
|
227 |
+
// Server configuration (really just versioning)
|
228 |
+
$return .= "$sep" . '-- Webserver Configuration' . "$sep$sep";
|
229 |
+
$return .= 'PHP Version: ' . PHP_VERSION . "$sep";
|
230 |
+
$return .= 'MySQL Version: ' . $wpdb->db_version() . "$sep";
|
231 |
+
$return .= 'Webserver Info: ' . $_SERVER['SERVER_SOFTWARE'] . "$sep";
|
232 |
+
|
233 |
+
$return = apply_filters('scb_sysinfo_after_webserver_config', $return);
|
234 |
+
|
235 |
+
// PHP configs... now we're getting to the important stuff
|
236 |
+
$return .= "$sep" . '-- PHP Configuration' . "$sep$sep";
|
237 |
+
$return .= 'Safe Mode: ' . (ini_get('safe_mode') ? 'Enabled' : 'Disabled' . "$sep");
|
238 |
+
$return .= 'Memory Limit: ' . ini_get('memory_limit') . "$sep";
|
239 |
+
$return .= 'Upload Max Size: ' . ini_get('upload_max_filesize') . "$sep";
|
240 |
+
$return .= 'Post Max Size: ' . ini_get('post_max_size') . "$sep";
|
241 |
+
$return .= 'Upload Max Filesize: ' . ini_get('upload_max_filesize') . "$sep";
|
242 |
+
$return .= 'Time Limit: ' . ini_get('max_execution_time') . "$sep";
|
243 |
+
$return .= 'Max Input Vars: ' . ini_get('max_input_vars') . "$sep";
|
244 |
+
$return .= 'Display Errors: ' . (ini_get('display_errors') ? 'On (' . ini_get('display_errors') . ')' : 'N/A') . "$sep";
|
245 |
+
|
246 |
+
$return = apply_filters('scb_sysinfo_after_php_config', $return);
|
247 |
+
|
248 |
+
// PHP extensions and such
|
249 |
+
$return .= "$sep" . '-- PHP Extensions' . "$sep$sep";
|
250 |
+
$return .= 'cURL: ' . (function_exists('curl_init') ? 'Supported' : 'Not Supported') . "$sep";
|
251 |
+
$return .= 'fsockopen: ' . (function_exists('fsockopen') ? 'Supported' : 'Not Supported') . "$sep";
|
252 |
+
$return .= 'SOAP Client: ' . (class_exists('SoapClient') ? 'Installed' : 'Not Installed') . "$sep";
|
253 |
+
$return .= 'Suhosin: ' . (extension_loaded('suhosin') ? 'Installed' : 'Not Installed') . "$sep";
|
254 |
+
|
255 |
+
$return = apply_filters('scb_sysinfo_after_php_ext', $return);
|
256 |
+
|
257 |
+
// Session stuff
|
258 |
+
$return .= "$sep" . '-- Session Configuration' . "$sep$sep";
|
259 |
+
|
260 |
+
$return .= 'Session: ' . (isset($_SESSION) ? 'Enabled' : 'Disabled') . "$sep";
|
261 |
+
|
262 |
+
// The rest of this is only relevant is session is enabled
|
263 |
+
if (isset($_SESSION))
|
264 |
+
{
|
265 |
+
$return .= 'Session Name: ' . esc_html(ini_get('session.name')) . "$sep";
|
266 |
+
$return .= 'Cookie Path: ' . esc_html(ini_get('session.cookie_path')) . "$sep";
|
267 |
+
$return .= 'Save Path: ' . esc_html(ini_get('session.save_path')) . "$sep";
|
268 |
+
$return .= 'Use Cookies: ' . (ini_get('session.use_cookies') ? 'On' : 'Off') . "$sep";
|
269 |
+
$return .= 'Use Only Cookies: ' . (ini_get('session.use_only_cookies') ? 'On' : 'Off') . "$sep";
|
270 |
+
}
|
271 |
+
|
272 |
+
$return = apply_filters('scb_sysinfo_after_session_config', $return);
|
273 |
+
|
274 |
+
$return .= "$sep" . '### End System Info ###';
|
275 |
+
|
276 |
+
return $return;
|
277 |
+
}
|
admin/settings/browser.php
ADDED
@@ -0,0 +1,1102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// Exit if accessed directly
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Modified to remove var
|
7 |
+
* Chris Christoff on 12/26/2012
|
8 |
+
* Changes: Changes vars to publics
|
9 |
+
*
|
10 |
+
* Modified to work for EDD by
|
11 |
+
* Chris Christoff on 12/23/2012
|
12 |
+
* Changes: Removed the browser string return and added spacing. Also removed return HTML formatting.
|
13 |
+
*
|
14 |
+
* Modified to add formatted User Agent string for EDD System Info by
|
15 |
+
* Chris Christoff on 12/23/2012
|
16 |
+
* Changes: Split user string and add formatting so we can print a nicely
|
17 |
+
* formatted user agent string on the EDD System Info
|
18 |
+
*
|
19 |
+
* File: Browser.php
|
20 |
+
* Author: Chris Schuld (http://chrisschuld.com/)
|
21 |
+
* Last Modified: August 20th, 2010
|
22 |
+
*
|
23 |
+
* @version 1.9
|
24 |
+
* @package PegasusPHP
|
25 |
+
*
|
26 |
+
* Copyright (C) 2008-2010 Chris Schuld (chris@chrisschuld.com)
|
27 |
+
*
|
28 |
+
* This program is free software; you can redistribute it and/or
|
29 |
+
* modify it under the terms of the GNU General Public License as
|
30 |
+
* published by the Free Software Foundation; either version 2 of
|
31 |
+
* the License, or (at your option) any later version.
|
32 |
+
*
|
33 |
+
* This program is distributed in the hope that it will be useful,
|
34 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
35 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
36 |
+
* GNU General Public License for more details at:
|
37 |
+
* http://www.gnu.org/copyleft/gpl.html
|
38 |
+
*
|
39 |
+
*
|
40 |
+
* Typical Usage:
|
41 |
+
*
|
42 |
+
* $browser = new Browser();
|
43 |
+
* if( $browser->getBrowser() == Browser::BROWSER_FIREFOX && $browser->getVersion() >= 2 ) {
|
44 |
+
* echo 'You have FireFox version 2 or greater';
|
45 |
+
* }
|
46 |
+
*
|
47 |
+
* User Agents Sampled from: http://www.useragentstring.com/
|
48 |
+
*
|
49 |
+
* This implementation is based on the original work from Gary White
|
50 |
+
* http://apptools.com/phptools/browser/
|
51 |
+
*
|
52 |
+
* UPDATES:
|
53 |
+
*
|
54 |
+
* 2010-08-20 (v1.9):
|
55 |
+
* + Added MSN Explorer Browser (legacy)
|
56 |
+
* + Added Bing/MSN Robot (Thanks Rob MacDonald)
|
57 |
+
* + Added the Android Platform (PLATFORM_ANDROID)
|
58 |
+
* + Fixed issue with Android 1.6/2.2 (Thanks Tom Hirashima)
|
59 |
+
*
|
60 |
+
* 2010-04-27 (v1.8):
|
61 |
+
* + Added iPad Support
|
62 |
+
*
|
63 |
+
* 2010-03-07 (v1.7):
|
64 |
+
* + *MAJOR* Rebuild (preg_match and other "slow" routine removal(s))
|
65 |
+
* + Almost allof Gary's original code has been replaced
|
66 |
+
* + Large PHPUNIT testing environment created to validate new releases and additions
|
67 |
+
* + Added FreeBSD Platform
|
68 |
+
* + Added OpenBSD Platform
|
69 |
+
* + Added NetBSD Platform
|
70 |
+
* + Added SunOS Platform
|
71 |
+
* + Added OpenSolaris Platform
|
72 |
+
* + Added support of the Iceweazel Browser
|
73 |
+
* + Added isChromeFrame() call to check if chromeframe is in use
|
74 |
+
* + Moved the Opera check in front of the Firefox check due to legacy Opera User Agents
|
75 |
+
* + Added the __toString() method (Thanks Deano)
|
76 |
+
*
|
77 |
+
* 2009-11-15:
|
78 |
+
* + Updated the checkes for Firefox
|
79 |
+
* + Added the NOKIA platform
|
80 |
+
* + Added Checks for the NOKIA brower(s)
|
81 |
+
*
|
82 |
+
* 2009-11-08:
|
83 |
+
* + PHP 5.3 Support
|
84 |
+
* + Added support for BlackBerry OS and BlackBerry browser
|
85 |
+
* + Added support for the Opera Mini browser
|
86 |
+
* + Added additional documenation
|
87 |
+
* + Added support for isRobot() and isMobile()
|
88 |
+
* + Added support for Opera version 10
|
89 |
+
* + Added support for deprecated Netscape Navigator version 9
|
90 |
+
* + Added support for IceCat
|
91 |
+
* + Added support for Shiretoko
|
92 |
+
*
|
93 |
+
* 2010-04-27 (v1.8):
|
94 |
+
* + Added iPad Support
|
95 |
+
*
|
96 |
+
* 2009-08-18:
|
97 |
+
* + Updated to support PHP 5.3 - removed all deprecated function calls
|
98 |
+
* + Updated to remove all double quotes (") -- converted to single quotes (')
|
99 |
+
*
|
100 |
+
* 2009-04-27:
|
101 |
+
* + Updated the IE check to remove a typo and bug (thanks John)
|
102 |
+
*
|
103 |
+
* 2009-04-22:
|
104 |
+
* + Added detection for GoogleBot
|
105 |
+
* + Added detection for the W3C Validator.
|
106 |
+
* + Added detection for Yahoo! Slurp
|
107 |
+
*
|
108 |
+
* 2009-03-14:
|
109 |
+
* + Added detection for iPods.
|
110 |
+
* + Added Platform detection for iPhones
|
111 |
+
* + Added Platform detection for iPods
|
112 |
+
*
|
113 |
+
* 2009-02-16: (Rick Hale)
|
114 |
+
* + Added version detection for Android phones.
|
115 |
+
*
|
116 |
+
* 2008-12-09:
|
117 |
+
* + Removed unused constant
|
118 |
+
*
|
119 |
+
* 2008-11-07:
|
120 |
+
* + Added Google's Chrome to the detection list
|
121 |
+
* + Added isBrowser(string) to the list of functions special thanks to
|
122 |
+
* Daniel 'mavrick' Lang for the function concept (http://mavrick.id.au)
|
123 |
+
*
|
124 |
+
*
|
125 |
+
* Gary White noted: "Since browser detection is so unreliable, I am
|
126 |
+
* no longer maintaining this script. You are free to use and or
|
127 |
+
* modify/update it as you want, however the author assumes no
|
128 |
+
* responsibility for the accuracy of the detected values."
|
129 |
+
*
|
130 |
+
* Anyone experienced with Gary's script might be interested in these notes:
|
131 |
+
*
|
132 |
+
* Added class constants
|
133 |
+
* Added detection and version detection for Google's Chrome
|
134 |
+
* Updated the version detection for Amaya
|
135 |
+
* Updated the version detection for Firefox
|
136 |
+
* Updated the version detection for Lynx
|
137 |
+
* Updated the version detection for WebTV
|
138 |
+
* Updated the version detection for NetPositive
|
139 |
+
* Updated the version detection for IE
|
140 |
+
* Updated the version detection for OmniWeb
|
141 |
+
* Updated the version detection for iCab
|
142 |
+
* Updated the version detection for Safari
|
143 |
+
* Updated Safari to remove mobile devices (iPhone)
|
144 |
+
* Added detection for iPhone
|
145 |
+
* Added detection for robots
|
146 |
+
* Added detection for mobile devices
|
147 |
+
* Added detection for BlackBerry
|
148 |
+
* Removed Netscape checks (matches heavily with firefox & mozilla)
|
149 |
+
*
|
150 |
+
*/
|
151 |
+
|
152 |
+
class Browser {
|
153 |
+
public $_agent = '';
|
154 |
+
public $_browser_name = '';
|
155 |
+
public $_version = '';
|
156 |
+
public $_platform = '';
|
157 |
+
public $_os = '';
|
158 |
+
public $_is_aol = false;
|
159 |
+
public $_is_mobile = false;
|
160 |
+
public $_is_robot = false;
|
161 |
+
public $_aol_version = '';
|
162 |
+
|
163 |
+
public $BROWSER_UNKNOWN = 'unknown';
|
164 |
+
public $VERSION_UNKNOWN = 'unknown';
|
165 |
+
|
166 |
+
public $BROWSER_OPERA = 'Opera'; // Http://www.opera.com/
|
167 |
+
public $BROWSER_OPERA_MINI = 'Opera Mini'; // Http://www.opera.com/mini/
|
168 |
+
public $BROWSER_WEBTV = 'WebTV'; // Http://www.webtv.net/pc/
|
169 |
+
public $BROWSER_IE = 'Internet Explorer'; // Http://www.microsoft.com/ie/
|
170 |
+
public $BROWSER_POCKET_IE = 'Pocket Internet Explorer'; // Http://en.wikipedia.org/wiki/Internet_Explorer_Mobile
|
171 |
+
public $BROWSER_KONQUEROR = 'Konqueror'; // Http://www.konqueror.org/
|
172 |
+
public $BROWSER_ICAB = 'iCab'; // Http://www.icab.de/
|
173 |
+
public $BROWSER_OMNIWEB = 'OmniWeb'; // Http://www.omnigroup.com/applications/omniweb/
|
174 |
+
public $BROWSER_FIREBIRD = 'Firebird'; // Http://www.ibphoenix.com/
|
175 |
+
public $BROWSER_FIREFOX = 'Firefox'; // Http://www.mozilla.com/en-US/firefox/firefox.html
|
176 |
+
public $BROWSER_ICEWEASEL = 'Iceweasel'; // Http://www.geticeweasel.org/
|
177 |
+
public $BROWSER_SHIRETOKO = 'Shiretoko'; // Http://wiki.mozilla.org/Projects/shiretoko
|
178 |
+
public $BROWSER_MOZILLA = 'Mozilla'; // Http://www.mozilla.com/en-US/
|
179 |
+
public $BROWSER_AMAYA = 'Amaya'; // Http://www.w3.org/Amaya/
|
180 |
+
public $BROWSER_LYNX = 'Lynx'; // Http://en.wikipedia.org/wiki/Lynx
|
181 |
+
public $BROWSER_SAFARI = 'Safari'; // Http://apple.com
|
182 |
+
public $BROWSER_IPHONE = 'iPhone'; // Http://apple.com
|
183 |
+
public $BROWSER_IPOD = 'iPod'; // Http://apple.com
|
184 |
+
public $BROWSER_IPAD = 'iPad'; // Http://apple.com
|
185 |
+
public $BROWSER_CHROME = 'Chrome'; // Http://www.google.com/chrome
|
186 |
+
public $BROWSER_ANDROID = 'Android'; // Http://www.android.com/
|
187 |
+
public $BROWSER_GOOGLEBOT = 'GoogleBot'; // Http://en.wikipedia.org/wiki/Googlebot
|
188 |
+
public $BROWSER_SLURP = 'Yahoo! Slurp'; // Http://en.wikipedia.org/wiki/Yahoo!_Slurp
|
189 |
+
public $BROWSER_W3CVALIDATOR = 'W3C Validator'; // Http://validator.w3.org/
|
190 |
+
public $BROWSER_BLACKBERRY = 'BlackBerry'; // Http://www.blackberry.com/
|
191 |
+
public $BROWSER_ICECAT = 'IceCat'; // Http://en.wikipedia.org/wiki/GNU_IceCat
|
192 |
+
public $BROWSER_NOKIA_S60 = 'Nokia S60 OSS Browser'; // Http://en.wikipedia.org/wiki/Web_Browser_for_S60
|
193 |
+
public $BROWSER_NOKIA = 'Nokia Browser'; // * all other WAP-based browsers on the Nokia Platform
|
194 |
+
public $BROWSER_MSN = 'MSN Browser'; // Http://explorer.msn.com/
|
195 |
+
public $BROWSER_MSNBOT = 'MSN Bot'; // Http://search.msn.com/msnbot.htm
|
196 |
+
// Http://en.wikipedia.org/wiki/Msnbot (used for Bing as well)
|
197 |
+
|
198 |
+
public $BROWSER_NETSCAPE_NAVIGATOR = 'Netscape Navigator'; // Http://browser.netscape.com/ (DEPRECATED)
|
199 |
+
public $BROWSER_GALEON = 'Galeon'; // Http://galeon.sourceforge.net/ (DEPRECATED)
|
200 |
+
public $BROWSER_NETPOSITIVE = 'NetPositive'; // Http://en.wikipedia.org/wiki/NetPositive (DEPRECATED)
|
201 |
+
public $BROWSER_PHOENIX = 'Phoenix'; // Http://en.wikipedia.org/wiki/History_of_Mozilla_Firefox (DEPRECATED)
|
202 |
+
|
203 |
+
public $PLATFORM_UNKNOWN = 'unknown';
|
204 |
+
public $PLATFORM_WINDOWS = 'Windows';
|
205 |
+
public $PLATFORM_WINDOWS_CE = 'Windows CE';
|
206 |
+
public $PLATFORM_APPLE = 'Apple';
|
207 |
+
public $PLATFORM_LINUX = 'Linux';
|
208 |
+
public $PLATFORM_OS2 = 'OS/2';
|
209 |
+
public $PLATFORM_BEOS = 'BeOS';
|
210 |
+
public $PLATFORM_IPHONE = 'iPhone';
|
211 |
+
public $PLATFORM_IPOD = 'iPod';
|
212 |
+
public $PLATFORM_IPAD = 'iPad';
|
213 |
+
public $PLATFORM_BLACKBERRY = 'BlackBerry';
|
214 |
+
public $PLATFORM_NOKIA = 'Nokia';
|
215 |
+
public $PLATFORM_FREEBSD = 'FreeBSD';
|
216 |
+
public $PLATFORM_OPENBSD = 'OpenBSD';
|
217 |
+
public $PLATFORM_NETBSD = 'NetBSD';
|
218 |
+
public $PLATFORM_SUNOS = 'SunOS';
|
219 |
+
public $PLATFORM_OPENSOLARIS = 'OpenSolaris';
|
220 |
+
public $PLATFORM_ANDROID = 'Android';
|
221 |
+
|
222 |
+
public $OPERATING_SYSTEM_UNKNOWN = 'unknown';
|
223 |
+
|
224 |
+
function __construct( $useragent="" ) {
|
225 |
+
$this->reset();
|
226 |
+
if ( $useragent != "" ) {
|
227 |
+
$this->setUserAgent( $useragent );
|
228 |
+
} else {
|
229 |
+
$this->determine();
|
230 |
+
}
|
231 |
+
}
|
232 |
+
|
233 |
+
/**
|
234 |
+
* Reset all properties
|
235 |
+
*/
|
236 |
+
function reset() {
|
237 |
+
$this->_agent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : "";
|
238 |
+
$this->_browser_name = $this->BROWSER_UNKNOWN;
|
239 |
+
$this->_version = $this->VERSION_UNKNOWN;
|
240 |
+
$this->_platform = $this->PLATFORM_UNKNOWN;
|
241 |
+
$this->_os = $this->OPERATING_SYSTEM_UNKNOWN;
|
242 |
+
$this->_is_aol = false;
|
243 |
+
$this->_is_mobile = false;
|
244 |
+
$this->_is_robot = false;
|
245 |
+
$this->_aol_version = $this->VERSION_UNKNOWN;
|
246 |
+
}
|
247 |
+
|
248 |
+
/**
|
249 |
+
* Check to see if the specific browser is valid
|
250 |
+
*
|
251 |
+
* @param string $browserName
|
252 |
+
* @return True if the browser is the specified browser
|
253 |
+
*/
|
254 |
+
function isBrowser( $browserName ) { return 0 == strcasecmp( $this->_browser_name, trim( $browserName ) ); }
|
255 |
+
|
256 |
+
/**
|
257 |
+
* The name of the browser. All return types are from the class contants
|
258 |
+
*
|
259 |
+
* @return string Name of the browser
|
260 |
+
*/
|
261 |
+
function getBrowser() { return $this->_browser_name; }
|
262 |
+
/**
|
263 |
+
* Set the name of the browser
|
264 |
+
*
|
265 |
+
* @param unknown $browser The name of the Browser
|
266 |
+
*/
|
267 |
+
function setBrowser( $browser ) { return $this->_browser_name = $browser; }
|
268 |
+
/**
|
269 |
+
* The name of the platform. All return types are from the class contants
|
270 |
+
*
|
271 |
+
* @return string Name of the browser
|
272 |
+
*/
|
273 |
+
function getPlatform() { return $this->_platform; }
|
274 |
+
/**
|
275 |
+
* Set the name of the platform
|
276 |
+
*
|
277 |
+
* @param unknown $platform The name of the Platform
|
278 |
+
*/
|
279 |
+
function setPlatform( $platform ) { return $this->_platform = $platform; }
|
280 |
+
/**
|
281 |
+
* The version of the browser.
|
282 |
+
*
|
283 |
+
* @return string Version of the browser (will only contain alpha-numeric characters and a period)
|
284 |
+
*/
|
285 |
+
function getVersion() { return $this->_version; }
|
286 |
+
/**
|
287 |
+
* Set the version of the browser
|
288 |
+
*
|
289 |
+
* @param unknown $version The version of the Browser
|
290 |
+
*/
|
291 |
+
function setVersion( $version ) { $this->_version = preg_replace( '/[^0-9,.,a-z,A-Z-]/', '', $version ); }
|
292 |
+
/**
|
293 |
+
* The version of AOL.
|
294 |
+
*
|
295 |
+
* @return string Version of AOL (will only contain alpha-numeric characters and a period)
|
296 |
+
*/
|
297 |
+
function getAolVersion() { return $this->_aol_version; }
|
298 |
+
/**
|
299 |
+
* Set the version of AOL
|
300 |
+
*
|
301 |
+
* @param unknown $version The version of AOL
|
302 |
+
*/
|
303 |
+
function setAolVersion( $version ) { $this->_aol_version = preg_replace( '/[^0-9,.,a-z,A-Z]/', '', $version ); }
|
304 |
+
/**
|
305 |
+
* Is the browser from AOL?
|
306 |
+
*
|
307 |
+
* @return boolean True if the browser is from AOL otherwise false
|
308 |
+
*/
|
309 |
+
function isAol() { return $this->_is_aol; }
|
310 |
+
/**
|
311 |
+
* Is the browser from a mobile device?
|
312 |
+
*
|
313 |
+
* @return boolean True if the browser is from a mobile device otherwise false
|
314 |
+
*/
|
315 |
+
function isMobile() { return $this->_is_mobile; }
|
316 |
+
/**
|
317 |
+
* Is the browser from a robot (ex Slurp,GoogleBot)?
|
318 |
+
*
|
319 |
+
* @return boolean True if the browser is from a robot otherwise false
|
320 |
+
*/
|
321 |
+
function isRobot() { return $this->_is_robot; }
|
322 |
+
/**
|
323 |
+
* Set the browser to be from AOL
|
324 |
+
*
|
325 |
+
* @param unknown $isAol
|
326 |
+
*/
|
327 |
+
function setAol( $isAol ) { $this->_is_aol = $isAol; }
|
328 |
+
/**
|
329 |
+
* Set the Browser to be mobile
|
330 |
+
*
|
331 |
+
* @param boolean $value is the browser a mobile brower or not
|
332 |
+
*/
|
333 |
+
function setMobile( $value=true ) { $this->_is_mobile = $value; }
|
334 |
+
/**
|
335 |
+
* Set the Browser to be a robot
|
336 |
+
*
|
337 |
+
* @param boolean $value is the browser a robot or not
|
338 |
+
*/
|
339 |
+
function setRobot( $value=true ) { $this->_is_robot = $value; }
|
340 |
+
/**
|
341 |
+
* Get the user agent value in use to determine the browser
|
342 |
+
*
|
343 |
+
* @return string The user agent from the HTTP header
|
344 |
+
*/
|
345 |
+
function getUserAgent() { return $this->_agent; }
|
346 |
+
/**
|
347 |
+
* Set the user agent value (the construction will use the HTTP header value - this will overwrite it)
|
348 |
+
*
|
349 |
+
* @param unknown $agent_string The value for the User Agent
|
350 |
+
*/
|
351 |
+
function setUserAgent( $agent_string ) {
|
352 |
+
$this->reset();
|
353 |
+
$this->_agent = $agent_string;
|
354 |
+
$this->determine();
|
355 |
+
}
|
356 |
+
/**
|
357 |
+
* Used to determine if the browser is actually "chromeframe"
|
358 |
+
*
|
359 |
+
* @since 1.7
|
360 |
+
* @return boolean True if the browser is using chromeframe
|
361 |
+
*/
|
362 |
+
function isChromeFrame() {
|
363 |
+
return strpos( $this->_agent, "chromeframe" ) !== false;
|
364 |
+
}
|
365 |
+
/**
|
366 |
+
* Returns a formatted string with a summary of the details of the browser.
|
367 |
+
*
|
368 |
+
* @return string formatted string with a summary of the browser
|
369 |
+
*/
|
370 |
+
function __toString() {
|
371 |
+
$text1 = $this->getUserAgent(); //grabs the UA (user agent) string
|
372 |
+
$UAline1 = substr( $text1, 0, 32 ); //the first line we print should only be the first 32 characters of the UA string
|
373 |
+
$text2 = $this->getUserAgent();//now we grab it again and save it to a string
|
374 |
+
$towrapUA = str_replace( $UAline1, '', $text2 );//the rest of the printoff (other than first line) is equivolent
|
375 |
+
// To the whole string minus the part we printed off. IE
|
376 |
+
// User Agent: thefirst32charactersfromUAline1
|
377 |
+
// the rest of it is now stored in
|
378 |
+
// $text2 to be printed off
|
379 |
+
// But we need to add spaces before each line that is split other than line 1
|
380 |
+
$space = '';
|
381 |
+
for ( $i = 0; $i < 25; $i++ ) {
|
382 |
+
$space .= ' ';
|
383 |
+
}
|
384 |
+
// Now we split the remaining string of UA ($text2) into lines that are prefixed by spaces for formatting
|
385 |
+
$wordwrapped = chunk_split( $towrapUA, 32, "\n $space" );
|
386 |
+
return "Platform: {$this->getPlatform()} \n".
|
387 |
+
"Browser Name: {$this->getBrowser()} \n" .
|
388 |
+
"Browser Version: {$this->getVersion()} \n" .
|
389 |
+
"User Agent String: $UAline1 \n\t\t\t " .
|
390 |
+
"$wordwrapped";
|
391 |
+
}
|
392 |
+
/**
|
393 |
+
* Protected routine to calculate and determine what the browser is in use (including platform)
|
394 |
+
*/
|
395 |
+
function determine() {
|
396 |
+
$this->checkPlatform();
|
397 |
+
$this->checkBrowsers();
|
398 |
+
$this->checkForAol();
|
399 |
+
}
|
400 |
+
/**
|
401 |
+
* Protected routine to determine the browser type
|
402 |
+
*
|
403 |
+
* @return boolean True if the browser was detected otherwise false
|
404 |
+
*/
|
405 |
+
function checkBrowsers() {
|
406 |
+
return (
|
407 |
+
// Well-known, well-used
|
408 |
+
// Special Notes:
|
409 |
+
// (1) Opera must be checked before FireFox due to the odd
|
410 |
+
// user agents used in some older versions of Opera
|
411 |
+
// (2) WebTV is strapped onto Internet Explorer so we must
|
412 |
+
// check for WebTV before IE
|
413 |
+
// (3) (deprecated) Galeon is based on Firefox and needs to be
|
414 |
+
// tested before Firefox is tested
|
415 |
+
// (4) OmniWeb is based on Safari so OmniWeb check must occur
|
416 |
+
// before Safari
|
417 |
+
// (5) Netscape 9+ is based on Firefox so Netscape checks
|
418 |
+
// before FireFox are necessary
|
419 |
+
$this->checkBrowserWebTv() ||
|
420 |
+
$this->checkBrowserInternetExplorer() ||
|
421 |
+
$this->checkBrowserOpera() ||
|
422 |
+
$this->checkBrowserGaleon() ||
|
423 |
+
$this->checkBrowserNetscapeNavigator9Plus() ||
|
424 |
+
$this->checkBrowserFirefox() ||
|
425 |
+
$this->checkBrowserChrome() ||
|
426 |
+
$this->checkBrowserOmniWeb() ||
|
427 |
+
|
428 |
+
// Common mobile
|
429 |
+
$this->checkBrowserAndroid() ||
|
430 |
+
$this->checkBrowseriPad() ||
|
431 |
+
$this->checkBrowseriPod() ||
|
432 |
+
$this->checkBrowseriPhone() ||
|
433 |
+
$this->checkBrowserBlackBerry() ||
|
434 |
+
$this->checkBrowserNokia() ||
|
435 |
+
|
436 |
+
// Common bots
|
437 |
+
$this->checkBrowserGoogleBot() ||
|
438 |
+
$this->checkBrowserMSNBot() ||
|
439 |
+
$this->checkBrowserSlurp() ||
|
440 |
+
|
441 |
+
// WebKit base check (post mobile and others)
|
442 |
+
$this->checkBrowserSafari() ||
|
443 |
+
|
444 |
+
// Everyone else
|
445 |
+
$this->checkBrowserNetPositive() ||
|
446 |
+
$this->checkBrowserFirebird() ||
|
447 |
+
$this->checkBrowserKonqueror() ||
|
448 |
+
$this->checkBrowserIcab() ||
|
449 |
+
$this->checkBrowserPhoenix() ||
|
450 |
+
$this->checkBrowserAmaya() ||
|
451 |
+
$this->checkBrowserLynx() ||
|
452 |
+
|
453 |
+
$this->checkBrowserShiretoko() ||
|
454 |
+
$this->checkBrowserIceCat() ||
|
455 |
+
$this->checkBrowserW3CValidator() ||
|
456 |
+
$this->checkBrowserMozilla() /* Mozilla is such an open standard that you must check it last */
|
457 |
+
);
|
458 |
+
}
|
459 |
+
|
460 |
+
/**
|
461 |
+
* Determine if the user is using a BlackBerry (last updated 1.7)
|
462 |
+
*
|
463 |
+
* @return boolean True if the browser is the BlackBerry browser otherwise false
|
464 |
+
*/
|
465 |
+
function checkBrowserBlackBerry() {
|
466 |
+
if ( stripos( $this->_agent, 'blackberry' ) !== false ) {
|
467 |
+
$aresult = explode( "/", stristr( $this->_agent, "BlackBerry" ) );
|
468 |
+
$aversion = explode( ' ', $aresult[1] );
|
469 |
+
$this->setVersion( $aversion[0] );
|
470 |
+
$this->_browser_name = $this->BROWSER_BLACKBERRY;
|
471 |
+
$this->setMobile( true );
|
472 |
+
return true;
|
473 |
+
}
|
474 |
+
return false;
|
475 |
+
}
|
476 |
+
|
477 |
+
/**
|
478 |
+
* Determine if the user is using an AOL User Agent (last updated 1.7)
|
479 |
+
*
|
480 |
+
* @return boolean True if the browser is from AOL otherwise false
|
481 |
+
*/
|
482 |
+
function checkForAol() {
|
483 |
+
$this->setAol( false );
|
484 |
+
$this->setAolVersion( $this->VERSION_UNKNOWN );
|
485 |
+
|
486 |
+
if ( stripos( $this->_agent, 'aol' ) !== false ) {
|
487 |
+
$aversion = explode( ' ', stristr( $this->_agent, 'AOL' ) );
|
488 |
+
$this->setAol( true );
|
489 |
+
$this->setAolVersion( preg_replace( '/[^0-9\.a-z]/i', '', $aversion[1] ) );
|
490 |
+
return true;
|
491 |
+
}
|
492 |
+
return false;
|
493 |
+
}
|
494 |
+
|
495 |
+
/**
|
496 |
+
* Determine if the browser is the GoogleBot or not (last updated 1.7)
|
497 |
+
*
|
498 |
+
* @return boolean True if the browser is the GoogletBot otherwise false
|
499 |
+
*/
|
500 |
+
function checkBrowserGoogleBot() {
|
501 |
+
if ( stripos( $this->_agent, 'googlebot' ) !== false ) {
|
502 |
+
$aresult = explode( '/', stristr( $this->_agent, 'googlebot' ) );
|
503 |
+
$aversion = explode( ' ', $aresult[1] );
|
504 |
+
$this->setVersion( str_replace( ';', '', $aversion[0] ) );
|
505 |
+
$this->_browser_name = $this->BROWSER_GOOGLEBOT;
|
506 |
+
$this->setRobot( true );
|
507 |
+
return true;
|
508 |
+
}
|
509 |
+
return false;
|
510 |
+
}
|
511 |
+
|
512 |
+
/**
|
513 |
+
* Determine if the browser is the MSNBot or not (last updated 1.9)
|
514 |
+
*
|
515 |
+
* @return boolean True if the browser is the MSNBot otherwise false
|
516 |
+
*/
|
517 |
+
function checkBrowserMSNBot() {
|
518 |
+
if ( stripos( $this->_agent, "msnbot" ) !== false ) {
|
519 |
+
$aresult = explode( "/", stristr( $this->_agent, "msnbot" ) );
|
520 |
+
$aversion = explode( " ", $aresult[1] );
|
521 |
+
$this->setVersion( str_replace( ";", "", $aversion[0] ) );
|
522 |
+
$this->_browser_name = $this->BROWSER_MSNBOT;
|
523 |
+
$this->setRobot( true );
|
524 |
+
return true;
|
525 |
+
}
|
526 |
+
return false;
|
527 |
+
}
|
528 |
+
|
529 |
+
/**
|
530 |
+
* Determine if the browser is the W3C Validator or not (last updated 1.7)
|
531 |
+
*
|
532 |
+
* @return boolean True if the browser is the W3C Validator otherwise false
|
533 |
+
*/
|
534 |
+
function checkBrowserW3CValidator() {
|
535 |
+
if ( stripos( $this->_agent, 'W3C-checklink' ) !== false ) {
|
536 |
+
$aresult = explode( '/', stristr( $this->_agent, 'W3C-checklink' ) );
|
537 |
+
$aversion = explode( ' ', $aresult[1] );
|
538 |
+
$this->setVersion( $aversion[0] );
|
539 |
+
$this->_browser_name = $this->BROWSER_W3CVALIDATOR;
|
540 |
+
return true;
|
541 |
+
} else if ( stripos( $this->_agent, 'W3C_Validator' ) !== false ) {
|
542 |
+
// Some of the Validator versions do not delineate w/ a slash - add it back in
|
543 |
+
$ua = str_replace( "W3C_Validator ", "W3C_Validator/", $this->_agent );
|
544 |
+
$aresult = explode( '/', stristr( $ua, 'W3C_Validator' ) );
|
545 |
+
$aversion = explode( ' ', $aresult[1] );
|
546 |
+
$this->setVersion( $aversion[0] );
|
547 |
+
$this->_browser_name = $this->BROWSER_W3CVALIDATOR;
|
548 |
+
return true;
|
549 |
+
}
|
550 |
+
return false;
|
551 |
+
}
|
552 |
+
|
553 |
+
/**
|
554 |
+
* Determine if the browser is the Yahoo! Slurp Robot or not (last updated 1.7)
|
555 |
+
*
|
556 |
+
* @return boolean True if the browser is the Yahoo! Slurp Robot otherwise false
|
557 |
+
*/
|
558 |
+
function checkBrowserSlurp() {
|
559 |
+
if ( stripos( $this->_agent, 'slurp' ) !== false ) {
|
560 |
+
$aresult = explode( '/', stristr( $this->_agent, 'Slurp' ) );
|
561 |
+
$aversion = explode( ' ', $aresult[1] );
|
562 |
+
$this->setVersion( $aversion[0] );
|
563 |
+
$this->_browser_name = $this->BROWSER_SLURP;
|
564 |
+
$this->setRobot( true );
|
565 |
+
$this->setMobile( false );
|
566 |
+
return true;
|
567 |
+
}
|
568 |
+
return false;
|
569 |
+
}
|
570 |
+
|
571 |
+
/**
|
572 |
+
* Determine if the browser is Internet Explorer or not (last updated 1.7)
|
573 |
+
*
|
574 |
+
* @return boolean True if the browser is Internet Explorer otherwise false
|
575 |
+
*/
|
576 |
+
function checkBrowserInternetExplorer() {
|
577 |
+
|
578 |
+
// Test for v1 - v1.5 IE
|
579 |
+
if ( stripos( $this->_agent, 'microsoft internet explorer' ) !== false ) {
|
580 |
+
$this->setBrowser( $this->BROWSER_IE );
|
581 |
+
$this->setVersion( '1.0' );
|
582 |
+
$aresult = stristr( $this->_agent, '/' );
|
583 |
+
if ( preg_match( '/308|425|426|474|0b1/i', $aresult ) ) {
|
584 |
+
$this->setVersion( '1.5' );
|
585 |
+
}
|
586 |
+
return true;
|
587 |
+
}
|
588 |
+
// Test for versions > 1.5
|
589 |
+
else if ( stripos( $this->_agent, 'msie' ) !== false && stripos( $this->_agent, 'opera' ) === false ) {
|
590 |
+
// See if the browser is the odd MSN Explorer
|
591 |
+
if ( stripos( $this->_agent, 'msnb' ) !== false ) {
|
592 |
+
$aresult = explode( ' ', stristr( str_replace( ';', '; ', $this->_agent ), 'MSN' ) );
|
593 |
+
$this->setBrowser( $this->BROWSER_MSN );
|
594 |
+
$this->setVersion( str_replace( array( '(', ')', ';' ), '', $aresult[1] ) );
|
595 |
+
return true;
|
596 |
+
}
|
597 |
+
$aresult = explode( ' ', stristr( str_replace( ';', '; ', $this->_agent ), 'msie' ) );
|
598 |
+
$this->setBrowser( $this->BROWSER_IE );
|
599 |
+
$this->setVersion( str_replace( array( '(', ')', ';' ), '', $aresult[1] ) );
|
600 |
+
return true;
|
601 |
+
}
|
602 |
+
// Test for Pocket IE
|
603 |
+
else if ( stripos( $this->_agent, 'mspie' ) !== false || stripos( $this->_agent, 'pocket' ) !== false ) {
|
604 |
+
$aresult = explode( ' ', stristr( $this->_agent, 'mspie' ) );
|
605 |
+
$this->setPlatform( $this->PLATFORM_WINDOWS_CE );
|
606 |
+
$this->setBrowser( $this->BROWSER_POCKET_IE );
|
607 |
+
$this->setMobile( true );
|
608 |
+
|
609 |
+
if ( stripos( $this->_agent, 'mspie' ) !== false ) {
|
610 |
+
$this->setVersion( $aresult[1] );
|
611 |
+
} else {
|
612 |
+
$aversion = explode( '/', $this->_agent );
|
613 |
+
$this->setVersion( $aversion[1] );
|
614 |
+
}
|
615 |
+
return true;
|
616 |
+
}
|
617 |
+
return false;
|
618 |
+
}
|
619 |
+
|
620 |
+
/**
|
621 |
+
* Determine if the browser is Opera or not (last updated 1.7)
|
622 |
+
*
|
623 |
+
* @return boolean True if the browser is Opera otherwise false
|
624 |
+
*/
|
625 |
+
function checkBrowserOpera() {
|
626 |
+
if ( stripos( $this->_agent, 'opera mini' ) !== false ) {
|
627 |
+
$resultant = stristr( $this->_agent, 'opera mini' );
|
628 |
+
if ( preg_match( '/\//', $resultant ) ) {
|
629 |
+
$aresult = explode( '/', $resultant );
|
630 |
+
$aversion = explode( ' ', $aresult[1] );
|
631 |
+
$this->setVersion( $aversion[0] );
|
632 |
+
} else {
|
633 |
+
$aversion = explode( ' ', stristr( $resultant, 'opera mini' ) );
|
634 |
+
$this->setVersion( $aversion[1] );
|
635 |
+
}
|
636 |
+
$this->_browser_name = $this->BROWSER_OPERA_MINI;
|
637 |
+
$this->setMobile( true );
|
638 |
+
return true;
|
639 |
+
} else if ( stripos( $this->_agent, 'opera' ) !== false ) {
|
640 |
+
$resultant = stristr( $this->_agent, 'opera' );
|
641 |
+
if ( preg_match( '/Version\/(10.*)$/', $resultant, $matches ) ) {
|
642 |
+
$this->setVersion( $matches[1] );
|
643 |
+
} else if ( preg_match( '/\//', $resultant ) ) {
|
644 |
+
$aresult = explode( '/', str_replace( "(", " ", $resultant ) );
|
645 |
+
$aversion = explode( ' ', $aresult[1] );
|
646 |
+
$this->setVersion( $aversion[0] );
|
647 |
+
} else {
|
648 |
+
$aversion = explode( ' ', stristr( $resultant, 'opera' ) );
|
649 |
+
$this->setVersion( isset( $aversion[1] )?$aversion[1]:"" );
|
650 |
+
}
|
651 |
+
$this->_browser_name = $this->BROWSER_OPERA;
|
652 |
+
return true;
|
653 |
+
}
|
654 |
+
return false;
|
655 |
+
}
|
656 |
+
|
657 |
+
/**
|
658 |
+
* Determine if the browser is Chrome or not (last updated 1.7)
|
659 |
+
*
|
660 |
+
* @return boolean True if the browser is Chrome otherwise false
|
661 |
+
*/
|
662 |
+
function checkBrowserChrome() {
|
663 |
+
if ( stripos( $this->_agent, 'Chrome' ) !== false ) {
|
664 |
+
$aresult = explode( '/', stristr( $this->_agent, 'Chrome' ) );
|
665 |
+
$aversion = explode( ' ', $aresult[1] );
|
666 |
+
$this->setVersion( $aversion[0] );
|
667 |
+
$this->setBrowser( $this->BROWSER_CHROME );
|
668 |
+
return true;
|
669 |
+
}
|
670 |
+
return false;
|
671 |
+
}
|
672 |
+
|
673 |
+
|
674 |
+
/**
|
675 |
+
* Determine if the browser is WebTv or not (last updated 1.7)
|
676 |
+
*
|
677 |
+
* @return boolean True if the browser is WebTv otherwise false
|
678 |
+
*/
|
679 |
+
function checkBrowserWebTv() {
|
680 |
+
if ( stripos( $this->_agent, 'webtv' ) !== false ) {
|
681 |
+
$aresult = explode( '/', stristr( $this->_agent, 'webtv' ) );
|
682 |
+
$aversion = explode( ' ', $aresult[1] );
|
683 |
+
$this->setVersion( $aversion[0] );
|
684 |
+
$this->setBrowser( $this->BROWSER_WEBTV );
|
685 |
+
return true;
|
686 |
+
}
|
687 |
+
return false;
|
688 |
+
}
|
689 |
+
|
690 |
+
/**
|
691 |
+
* Determine if the browser is NetPositive or not (last updated 1.7)
|
692 |
+
*
|
693 |
+
* @return boolean True if the browser is NetPositive otherwise false
|
694 |
+
*/
|
695 |
+
function checkBrowserNetPositive() {
|
696 |
+
if ( stripos( $this->_agent, 'NetPositive' ) !== false ) {
|
697 |
+
$aresult = explode( '/', stristr( $this->_agent, 'NetPositive' ) );
|
698 |
+
$aversion = explode( ' ', $aresult[1] );
|
699 |
+
$this->setVersion( str_replace( array( '(', ')', ';' ), '', $aversion[0] ) );
|
700 |
+
$this->setBrowser( $this->BROWSER_NETPOSITIVE );
|
701 |
+
return true;
|
702 |
+
}
|
703 |
+
return false;
|
704 |
+
}
|
705 |
+
|
706 |
+
/**
|
707 |
+
* Determine if the browser is Galeon or not (last updated 1.7)
|
708 |
+
*
|
709 |
+
* @return boolean True if the browser is Galeon otherwise false
|
710 |
+
*/
|
711 |
+
function checkBrowserGaleon() {
|
712 |
+
if ( stripos( $this->_agent, 'galeon' ) !== false ) {
|
713 |
+
$aresult = explode( ' ', stristr( $this->_agent, 'galeon' ) );
|
714 |
+
$aversion = explode( '/', $aresult[0] );
|
715 |
+
$this->setVersion( $aversion[1] );
|
716 |
+
$this->setBrowser( $this->BROWSER_GALEON );
|
717 |
+
return true;
|
718 |
+
}
|
719 |
+
return false;
|
720 |
+
}
|
721 |
+
|
722 |
+
/**
|
723 |
+
* Determine if the browser is Konqueror or not (last updated 1.7)
|
724 |
+
*
|
725 |
+
* @return boolean True if the browser is Konqueror otherwise false
|
726 |
+
*/
|
727 |
+
function checkBrowserKonqueror() {
|
728 |
+
if ( stripos( $this->_agent, 'Konqueror' ) !== false ) {
|
729 |
+
$aresult = explode( ' ', stristr( $this->_agent, 'Konqueror' ) );
|
730 |
+
$aversion = explode( '/', $aresult[0] );
|
731 |
+
$this->setVersion( $aversion[1] );
|
732 |
+
$this->setBrowser( $this->BROWSER_KONQUEROR );
|
733 |
+
return true;
|
734 |
+
}
|
735 |
+
return false;
|
736 |
+
}
|
737 |
+
|
738 |
+
/**
|
739 |
+
* Determine if the browser is iCab or not (last updated 1.7)
|
740 |
+
*
|
741 |
+
* @return boolean True if the browser is iCab otherwise false
|
742 |
+
*/
|
743 |
+
function checkBrowserIcab() {
|
744 |
+
if ( stripos( $this->_agent, 'icab' ) !== false ) {
|
745 |
+
$aversion = explode( ' ', stristr( str_replace( '/', ' ', $this->_agent ), 'icab' ) );
|
746 |
+
$this->setVersion( $aversion[1] );
|
747 |
+
$this->setBrowser( $this->BROWSER_ICAB );
|
748 |
+
return true;
|
749 |
+
}
|
750 |
+
return false;
|
751 |
+
}
|
752 |
+
|
753 |
+
/**
|
754 |
+
* Determine if the browser is OmniWeb or not (last updated 1.7)
|
755 |
+
*
|
756 |
+
* @return boolean True if the browser is OmniWeb otherwise false
|
757 |
+
*/
|
758 |
+
function checkBrowserOmniWeb() {
|
759 |
+
if ( stripos( $this->_agent, 'omniweb' ) !== false ) {
|
760 |
+
$aresult = explode( '/', stristr( $this->_agent, 'omniweb' ) );
|
761 |
+
$aversion = explode( ' ', isset( $aresult[1] )?$aresult[1]:"" );
|
762 |
+
$this->setVersion( $aversion[0] );
|
763 |
+
$this->setBrowser( $this->BROWSER_OMNIWEB );
|
764 |
+
return true;
|
765 |
+
}
|
766 |
+
return false;
|
767 |
+
}
|
768 |
+
|
769 |
+
/**
|
770 |
+
* Determine if the browser is Phoenix or not (last updated 1.7)
|
771 |
+
*
|
772 |
+
* @return boolean True if the browser is Phoenix otherwise false
|
773 |
+
*/
|
774 |
+
function checkBrowserPhoenix() {
|
775 |
+
if ( stripos( $this->_agent, 'Phoenix' ) !== false ) {
|
776 |
+
$aversion = explode( '/', stristr( $this->_agent, 'Phoenix' ) );
|
777 |
+
$this->setVersion( $aversion[1] );
|
778 |
+
$this->setBrowser( $this->BROWSER_PHOENIX );
|
779 |
+
return true;
|
780 |
+
}
|
781 |
+
return false;
|
782 |
+
}
|
783 |
+
|
784 |
+
/**
|
785 |
+
* Determine if the browser is Firebird or not (last updated 1.7)
|
786 |
+
*
|
787 |
+
* @return boolean True if the browser is Firebird otherwise false
|
788 |
+
*/
|
789 |
+
function checkBrowserFirebird() {
|
790 |
+
if ( stripos( $this->_agent, 'Firebird' ) !== false ) {
|
791 |
+
$aversion = explode( '/', stristr( $this->_agent, 'Firebird' ) );
|
792 |
+
$this->setVersion( $aversion[1] );
|
793 |
+
$this->setBrowser( $this->BROWSER_FIREBIRD );
|
794 |
+
return true;
|
795 |
+
}
|
796 |
+
return false;
|
797 |
+
}
|
798 |
+
|
799 |
+
/**
|
800 |
+
* Determine if the browser is Netscape Navigator 9+ or not (last updated 1.7)
|
801 |
+
* NOTE: (http://browser.netscape.com/ - Official support ended on March 1st, 2008)
|
802 |
+
*
|
803 |
+
* @return boolean True if the browser is Netscape Navigator 9+ otherwise false
|
804 |
+
*/
|
805 |
+
function checkBrowserNetscapeNavigator9Plus() {
|
806 |
+
if ( stripos( $this->_agent, 'Firefox' ) !== false && preg_match( '/Navigator\/([^ ]*)/i', $this->_agent, $matches ) ) {
|
807 |
+
$this->setVersion( $matches[1] );
|
808 |
+
$this->setBrowser( $this->BROWSER_NETSCAPE_NAVIGATOR );
|
809 |
+
return true;
|
810 |
+
} else if ( stripos( $this->_agent, 'Firefox' ) === false && preg_match( '/Netscape6?\/([^ ]*)/i', $this->_agent, $matches ) ) {
|
811 |
+
$this->setVersion( $matches[1] );
|
812 |
+
$this->setBrowser( $this->BROWSER_NETSCAPE_NAVIGATOR );
|
813 |
+
return true;
|
814 |
+
}
|
815 |
+
return false;
|
816 |
+
}
|
817 |
+
|
818 |
+
/**
|
819 |
+
* Determine if the browser is Shiretoko or not (https://wiki.mozilla.org/Projects/shiretoko) (last updated 1.7)
|
820 |
+
*
|
821 |
+
* @return boolean True if the browser is Shiretoko otherwise false
|
822 |
+
*/
|
823 |
+
function checkBrowserShiretoko() {
|
824 |
+
if ( stripos( $this->_agent, 'Mozilla' ) !== false && preg_match( '/Shiretoko\/([^ ]*)/i', $this->_agent, $matches ) ) {
|
825 |
+
$this->setVersion( $matches[1] );
|
826 |
+
$this->setBrowser( $this->BROWSER_SHIRETOKO );
|
827 |
+
return true;
|
828 |
+
}
|
829 |
+
return false;
|
830 |
+
}
|
831 |
+
|
832 |
+
/**
|
833 |
+
* Determine if the browser is Ice Cat or not (http://en.wikipedia.org/wiki/GNU_IceCat) (last updated 1.7)
|
834 |
+
*
|
835 |
+
* @return boolean True if the browser is Ice Cat otherwise false
|
836 |
+
*/
|
837 |
+
function checkBrowserIceCat() {
|
838 |
+
if ( stripos( $this->_agent, 'Mozilla' ) !== false && preg_match( '/IceCat\/([^ ]*)/i', $this->_agent, $matches ) ) {
|
839 |
+
$this->setVersion( $matches[1] );
|
840 |
+
$this->setBrowser( $this->BROWSER_ICECAT );
|
841 |
+
return true;
|
842 |
+
}
|
843 |
+
return false;
|
844 |
+
}
|
845 |
+
|
846 |
+
/**
|
847 |
+
* Determine if the browser is Nokia or not (last updated 1.7)
|
848 |
+
*
|
849 |
+
* @return boolean True if the browser is Nokia otherwise false
|
850 |
+
*/
|
851 |
+
function checkBrowserNokia() {
|
852 |
+
if ( preg_match( "/Nokia([^\/]+)\/([^ SP]+)/i", $this->_agent, $matches ) ) {
|
853 |
+
$this->setVersion( $matches[2] );
|
854 |
+
if ( stripos( $this->_agent, 'Series60' ) !== false || strpos( $this->_agent, 'S60' ) !== false ) {
|
855 |
+
$this->setBrowser( $this->BROWSER_NOKIA_S60 );
|
856 |
+
} else {
|
857 |
+
$this->setBrowser( $this->BROWSER_NOKIA );
|
858 |
+
}
|
859 |
+
$this->setMobile( true );
|
860 |
+
return true;
|
861 |
+
}
|
862 |
+
return false;
|
863 |
+
}
|
864 |
+
|
865 |
+
/**
|
866 |
+
* Determine if the browser is Firefox or not (last updated 1.7)
|
867 |
+
*
|
868 |
+
* @return boolean True if the browser is Firefox otherwise false
|
869 |
+
*/
|
870 |
+
function checkBrowserFirefox() {
|
871 |
+
if ( stripos( $this->_agent, 'safari' ) === false ) {
|
872 |
+
if ( preg_match( "/Firefox[\/ \(]([^ ;\)]+)/i", $this->_agent, $matches ) ) {
|
873 |
+
$this->setVersion( $matches[1] );
|
874 |
+
$this->setBrowser( $this->BROWSER_FIREFOX );
|
875 |
+
return true;
|
876 |
+
} else if ( preg_match( "/Firefox$/i", $this->_agent, $matches ) ) {
|
877 |
+
$this->setVersion( "" );
|
878 |
+
$this->setBrowser( $this->BROWSER_FIREFOX );
|
879 |
+
return true;
|
880 |
+
}
|
881 |
+
}
|
882 |
+
return false;
|
883 |
+
}
|
884 |
+
|
885 |
+
/**
|
886 |
+
* Determine if the browser is Firefox or not (last updated 1.7)
|
887 |
+
*
|
888 |
+
* @return boolean True if the browser is Firefox otherwise false
|
889 |
+
*/
|
890 |
+
function checkBrowserIceweasel() {
|
891 |
+
if ( stripos( $this->_agent, 'Iceweasel' ) !== false ) {
|
892 |
+
$aresult = explode( '/', stristr( $this->_agent, 'Iceweasel' ) );
|
893 |
+
$aversion = explode( ' ', $aresult[1] );
|
894 |
+
$this->setVersion( $aversion[0] );
|
895 |
+
$this->setBrowser( $this->BROWSER_ICEWEASEL );
|
896 |
+
return true;
|
897 |
+
}
|
898 |
+
return false;
|
899 |
+
}
|
900 |
+
/**
|
901 |
+
* Determine if the browser is Mozilla or not (last updated 1.7)
|
902 |
+
*
|
903 |
+
* @return boolean True if the browser is Mozilla otherwise false
|
904 |
+
*/
|
905 |
+
function checkBrowserMozilla() {
|
906 |
+
if ( stripos( $this->_agent, 'mozilla' ) !== false && preg_match( '/rv:[0-9].[0-9][a-b]?/i', $this->_agent ) && stripos( $this->_agent, 'netscape' ) === false ) {
|
907 |
+
$aversion = explode( ' ', stristr( $this->_agent, 'rv:' ) );
|
908 |
+
preg_match( '/rv:[0-9].[0-9][a-b]?/i', $this->_agent, $aversion );
|
909 |
+
$this->setVersion( str_replace( 'rv:', '', $aversion[0] ) );
|
910 |
+
$this->setBrowser( $this->BROWSER_MOZILLA );
|
911 |
+
return true;
|
912 |
+
} else if ( stripos( $this->_agent, 'mozilla' ) !== false && preg_match( '/rv:[0-9]\.[0-9]/i', $this->_agent ) && stripos( $this->_agent, 'netscape' ) === false ) {
|
913 |
+
$aversion = explode( '', stristr( $this->_agent, 'rv:' ) );
|
914 |
+
$this->setVersion( str_replace( 'rv:', '', $aversion[0] ) );
|
915 |
+
$this->setBrowser( $this->BROWSER_MOZILLA );
|
916 |
+
return true;
|
917 |
+
} else if ( stripos( $this->_agent, 'mozilla' ) !== false && preg_match( '/mozilla\/([^ ]*)/i', $this->_agent, $matches ) && stripos( $this->_agent, 'netscape' ) === false ) {
|
918 |
+
$this->setVersion( $matches[1] );
|
919 |
+
$this->setBrowser( $this->BROWSER_MOZILLA );
|
920 |
+
return true;
|
921 |
+
}
|
922 |
+
return false;
|
923 |
+
}
|
924 |
+
|
925 |
+
/**
|
926 |
+
* Determine if the browser is Lynx or not (last updated 1.7)
|
927 |
+
*
|
928 |
+
* @return boolean True if the browser is Lynx otherwise false
|
929 |
+
*/
|
930 |
+
function checkBrowserLynx() {
|
931 |
+
if ( stripos( $this->_agent, 'lynx' ) !== false ) {
|
932 |
+
$aresult = explode( '/', stristr( $this->_agent, 'Lynx' ) );
|
933 |
+
$aversion = explode( ' ', ( isset( $aresult[1] )?$aresult[1]:"" ) );
|
934 |
+
$this->setVersion( $aversion[0] );
|
935 |
+
$this->setBrowser( $this->BROWSER_LYNX );
|
936 |
+
return true;
|
937 |
+
}
|
938 |
+
return false;
|
939 |
+
}
|
940 |
+
|
941 |
+
/**
|
942 |
+
* Determine if the browser is Amaya or not (last updated 1.7)
|
943 |
+
*
|
944 |
+
* @return boolean True if the browser is Amaya otherwise false
|
945 |
+
*/
|
946 |
+
function checkBrowserAmaya() {
|
947 |
+
if ( stripos( $this->_agent, 'amaya' ) !== false ) {
|
948 |
+
$aresult = explode( '/', stristr( $this->_agent, 'Amaya' ) );
|
949 |
+
$aversion = explode( ' ', $aresult[1] );
|
950 |
+
$this->setVersion( $aversion[0] );
|
951 |
+
$this->setBrowser( $this->BROWSER_AMAYA );
|
952 |
+
return true;
|
953 |
+
}
|
954 |
+
return false;
|
955 |
+
}
|
956 |
+
|
957 |
+
/**
|
958 |
+
* Determine if the browser is Safari or not (last updated 1.7)
|
959 |
+
*
|
960 |
+
* @return boolean True if the browser is Safari otherwise false
|
961 |
+
*/
|
962 |
+
function checkBrowserSafari() {
|
963 |
+
if ( stripos( $this->_agent, 'Safari' ) !== false && stripos( $this->_agent, 'iPhone' ) === false && stripos( $this->_agent, 'iPod' ) === false ) {
|
964 |
+
$aresult = explode( '/', stristr( $this->_agent, 'Version' ) );
|
965 |
+
if ( isset( $aresult[1] ) ) {
|
966 |
+
$aversion = explode( ' ', $aresult[1] );
|
967 |
+
$this->setVersion( $aversion[0] );
|
968 |
+
} else {
|
969 |
+
$this->setVersion( $this->VERSION_UNKNOWN );
|
970 |
+
}
|
971 |
+
$this->setBrowser( $this->BROWSER_SAFARI );
|
972 |
+
return true;
|
973 |
+
}
|
974 |
+
return false;
|
975 |
+
}
|
976 |
+
|
977 |
+
/**
|
978 |
+
* Determine if the browser is iPhone or not (last updated 1.7)
|
979 |
+
*
|
980 |
+
* @return boolean True if the browser is iPhone otherwise false
|
981 |
+
*/
|
982 |
+
function checkBrowseriPhone() {
|
983 |
+
if ( stripos( $this->_agent, 'iPhone' ) !== false ) {
|
984 |
+
$aresult = explode( '/', stristr( $this->_agent, 'Version' ) );
|
985 |
+
if ( isset( $aresult[1] ) ) {
|
986 |
+
$aversion = explode( ' ', $aresult[1] );
|
987 |
+
$this->setVersion( $aversion[0] );
|
988 |
+
} else {
|
989 |
+
$this->setVersion( $this->VERSION_UNKNOWN );
|
990 |
+
}
|
991 |
+
$this->setMobile( true );
|
992 |
+
$this->setBrowser( $this->BROWSER_IPHONE );
|
993 |
+
return true;
|
994 |
+
}
|
995 |
+
return false;
|
996 |
+
}
|
997 |
+
|
998 |
+
/**
|
999 |
+
* Determine if the browser is iPod or not (last updated 1.7)
|
1000 |
+
*
|
1001 |
+
* @return boolean True if the browser is iPod otherwise false
|
1002 |
+
*/
|
1003 |
+
function checkBrowseriPad() {
|
1004 |
+
if ( stripos( $this->_agent, 'iPad' ) !== false ) {
|
1005 |
+
$aresult = explode( '/', stristr( $this->_agent, 'Version' ) );
|
1006 |
+
if ( isset( $aresult[1] ) ) {
|
1007 |
+
$aversion = explode( ' ', $aresult[1] );
|
1008 |
+
$this->setVersion( $aversion[0] );
|
1009 |
+
} else {
|
1010 |
+
$this->setVersion( $this->VERSION_UNKNOWN );
|
1011 |
+
}
|
1012 |
+
$this->setMobile( true );
|
1013 |
+
$this->setBrowser( $this->BROWSER_IPAD );
|
1014 |
+
return true;
|
1015 |
+
}
|
1016 |
+
return false;
|
1017 |
+
}
|
1018 |
+
|
1019 |
+
/**
|
1020 |
+
* Determine if the browser is iPod or not (last updated 1.7)
|
1021 |
+
*
|
1022 |
+
* @return boolean True if the browser is iPod otherwise false
|
1023 |
+
*/
|
1024 |
+
function checkBrowseriPod() {
|
1025 |
+
if ( stripos( $this->_agent, 'iPod' ) !== false ) {
|
1026 |
+
$aresult = explode( '/', stristr( $this->_agent, 'Version' ) );
|
1027 |
+
if ( isset( $aresult[1] ) ) {
|
1028 |
+
$aversion = explode( ' ', $aresult[1] );
|
1029 |
+
$this->setVersion( $aversion[0] );
|
1030 |
+
} else {
|
1031 |
+
$this->setVersion( $this->VERSION_UNKNOWN );
|
1032 |
+
}
|
1033 |
+
$this->setMobile( true );
|
1034 |
+
$this->setBrowser( $this->BROWSER_IPOD );
|
1035 |
+
return true;
|
1036 |
+
}
|
1037 |
+
return false;
|
1038 |
+
}
|
1039 |
+
|
1040 |
+
/**
|
1041 |
+
* Determine if the browser is Android or not (last updated 1.7)
|
1042 |
+
*
|
1043 |
+
* @return boolean True if the browser is Android otherwise false
|
1044 |
+
*/
|
1045 |
+
function checkBrowserAndroid() {
|
1046 |
+
if ( stripos( $this->_agent, 'Android' ) !== false ) {
|
1047 |
+
$aresult = explode( ' ', stristr( $this->_agent, 'Android' ) );
|
1048 |
+
if ( isset( $aresult[1] ) ) {
|
1049 |
+
$aversion = explode( ' ', $aresult[1] );
|
1050 |
+
$this->setVersion( $aversion[0] );
|
1051 |
+
} else {
|
1052 |
+
$this->setVersion( $this->VERSION_UNKNOWN );
|
1053 |
+
}
|
1054 |
+
$this->setMobile( true );
|
1055 |
+
$this->setBrowser( $this->BROWSER_ANDROID );
|
1056 |
+
return true;
|
1057 |
+
}
|
1058 |
+
return false;
|
1059 |
+
}
|
1060 |
+
|
1061 |
+
/**
|
1062 |
+
* Determine the user's platform (last updated 1.7)
|
1063 |
+
*/
|
1064 |
+
function checkPlatform() {
|
1065 |
+
if ( stripos( $this->_agent, 'windows' ) !== false ) {
|
1066 |
+
$this->_platform = $this->PLATFORM_WINDOWS;
|
1067 |
+
} else if ( stripos( $this->_agent, 'iPad' ) !== false ) {
|
1068 |
+
$this->_platform = $this->PLATFORM_IPAD;
|
1069 |
+
} else if ( stripos( $this->_agent, 'iPod' ) !== false ) {
|
1070 |
+
$this->_platform = $this->PLATFORM_IPOD;
|
1071 |
+
} else if ( stripos( $this->_agent, 'iPhone' ) !== false ) {
|
1072 |
+
$this->_platform = $this->PLATFORM_IPHONE;
|
1073 |
+
} elseif ( stripos( $this->_agent, 'mac' ) !== false ) {
|
1074 |
+
$this->_platform = $this->PLATFORM_APPLE;
|
1075 |
+
} elseif ( stripos( $this->_agent, 'android' ) !== false ) {
|
1076 |
+
$this->_platform = $this->PLATFORM_ANDROID;
|
1077 |
+
} elseif ( stripos( $this->_agent, 'linux' ) !== false ) {
|
1078 |
+
$this->_platform = $this->PLATFORM_LINUX;
|
1079 |
+
} else if ( stripos( $this->_agent, 'Nokia' ) !== false ) {
|
1080 |
+
$this->_platform = $this->PLATFORM_NOKIA;
|
1081 |
+
} else if ( stripos( $this->_agent, 'BlackBerry' ) !== false ) {
|
1082 |
+
$this->_platform = $this->PLATFORM_BLACKBERRY;
|
1083 |
+
} elseif ( stripos( $this->_agent, 'FreeBSD' ) !== false ) {
|
1084 |
+
$this->_platform = $this->PLATFORM_FREEBSD;
|
1085 |
+
} elseif ( stripos( $this->_agent, 'OpenBSD' ) !== false ) {
|
1086 |
+
$this->_platform = $this->PLATFORM_OPENBSD;
|
1087 |
+
} elseif ( stripos( $this->_agent, 'NetBSD' ) !== false ) {
|
1088 |
+
$this->_platform = $this->PLATFORM_NETBSD;
|
1089 |
+
} elseif ( stripos( $this->_agent, 'OpenSolaris' ) !== false ) {
|
1090 |
+
$this->_platform = $this->PLATFORM_OPENSOLARIS;
|
1091 |
+
} elseif ( stripos( $this->_agent, 'SunOS' ) !== false ) {
|
1092 |
+
$this->_platform = $this->PLATFORM_SUNOS;
|
1093 |
+
} elseif ( stripos( $this->_agent, 'OS\/2' ) !== false ) {
|
1094 |
+
$this->_platform = $this->PLATFORM_OS2;
|
1095 |
+
} elseif ( stripos( $this->_agent, 'BeOS' ) !== false ) {
|
1096 |
+
$this->_platform = $this->PLATFORM_BEOS;
|
1097 |
+
} elseif ( stripos( $this->_agent, 'win' ) !== false ) {
|
1098 |
+
$this->_platform = $this->PLATFORM_WINDOWS;
|
1099 |
+
}
|
1100 |
+
|
1101 |
+
}
|
1102 |
+
}
|
admin/settings/class_settings.php
CHANGED
@@ -2,25 +2,49 @@
|
|
2 |
|
3 |
if (!class_exists('wphp_settings'))
|
4 |
{
|
|
|
5 |
class wphp_settings
|
6 |
{
|
7 |
-
private $pages, $settings_api, $asignment_fields =
|
|
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
}
|
25 |
public function api()
|
26 |
{
|
@@ -38,7 +62,7 @@ if (!class_exists('wphp_settings'))
|
|
38 |
}
|
39 |
public function register_tab($tabs)
|
40 |
{
|
41 |
-
$tabs = is_array($tabs) && isset($tabs[0]) ? $tabs :
|
42 |
|
43 |
foreach ($tabs as $item => $tab)
|
44 |
{
|
@@ -53,7 +77,13 @@ if (!class_exists('wphp_settings'))
|
|
53 |
}
|
54 |
else
|
55 |
{
|
56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
}
|
58 |
}
|
59 |
return $tabs;
|
@@ -62,15 +92,15 @@ if (!class_exists('wphp_settings'))
|
|
62 |
{
|
63 |
if (!$this->pages)
|
64 |
{
|
65 |
-
$pages = get_pages(
|
66 |
-
'sort_column'
|
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 :
|
74 |
foreach ($settings as $key => $setting)
|
75 |
{
|
76 |
$settings[$key]['type'] = 'select';
|
@@ -82,8 +112,8 @@ if (!class_exists('wphp_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 :
|
87 |
|
88 |
foreach ($settings as $item => $setting)
|
89 |
{
|
@@ -92,7 +122,7 @@ if (!class_exists('wphp_settings'))
|
|
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] :
|
96 |
|
97 |
if ($key !== false)
|
98 |
{
|
@@ -112,7 +142,7 @@ if (!class_exists('wphp_settings'))
|
|
112 |
else
|
113 |
{
|
114 |
$this->settings[$tab] = array_merge(
|
115 |
-
is_array(@$this->settings[$tab]) ? $this->settings[$tab] :
|
116 |
}
|
117 |
|
118 |
return $setting_temp;
|
@@ -120,51 +150,69 @@ if (!class_exists('wphp_settings'))
|
|
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 |
-
$
|
|
|
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('
|
145 |
{
|
|
|
|
|
146 |
|
147 |
-
|
148 |
-
|
149 |
-
$
|
150 |
$license['type'],
|
151 |
$license['name'],
|
152 |
null,
|
153 |
-
['
|
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('
|
166 |
{
|
167 |
-
$obj_license =
|
168 |
|
169 |
if (!is_null($obj_license))
|
170 |
{
|
@@ -173,42 +221,91 @@ if (!class_exists('wphp_settings'))
|
|
173 |
$license_info = $obj_license->extendedInfo();
|
174 |
}
|
175 |
}
|
176 |
-
|
177 |
-
$status
|
178 |
|
179 |
$value = esc_attr($this->settings_api->get_option($args['id'], $args['section'], $args['std']));
|
180 |
-
|
181 |
-
$
|
182 |
-
$
|
|
|
|
|
|
|
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="
|
|
|
|
|
|
|
|
|
|
|
186 |
|
187 |
-
|
|
|
|
|
|
|
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 |
-
$
|
203 |
-
|
204 |
-
'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
205 |
);
|
206 |
|
207 |
-
$this->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
208 |
|
209 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
210 |
|
211 |
}
|
|
|
212 |
/**
|
213 |
* Returns all the settings fields
|
214 |
*
|
@@ -217,8 +314,10 @@ if (!class_exists('wphp_settings'))
|
|
217 |
public function get_settings_fields()
|
218 |
{
|
219 |
|
220 |
-
$this->settings
|
221 |
-
$this->settings[$this->
|
|
|
|
|
222 |
$this->settings[$this->asignment_section['id']] = $this->asignment_fields;
|
223 |
|
224 |
return $this->settings;
|
@@ -226,13 +325,44 @@ if (!class_exists('wphp_settings'))
|
|
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 |
*
|
@@ -253,45 +383,64 @@ if (!class_exists('wphp_settings'))
|
|
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 |
-
|
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 |
-
$
|
|
|
|
|
|
|
274 |
|
275 |
-
|
|
|
|
|
276 |
{
|
277 |
-
$
|
278 |
}
|
279 |
-
|
280 |
{
|
281 |
-
$
|
282 |
}
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
287 |
|
288 |
-
|
289 |
|
290 |
-
|
291 |
-
$response['lic_btn'] = ($response['lic_status'] ? 'Deactivate' : 'Activate');
|
292 |
|
293 |
-
|
|
|
|
|
|
|
|
|
294 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
295 |
wp_send_json($response);
|
296 |
}
|
297 |
public function script()
|
@@ -320,47 +469,71 @@ if (!class_exists('wphp_settings'))
|
|
320 |
}
|
321 |
.chosen-container .search-field {
|
322 |
float: none!important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
323 |
}
|
324 |
</style>
|
325 |
|
326 |
<script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
327 |
jQuery(document).ready(function($)
|
|
|
328 |
{
|
329 |
-
|
|
|
|
|
|
|
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 |
-
$('#
|
339 |
-
$('#
|
340 |
-
$('#
|
341 |
$.post(ajaxurl, data, function(response)
|
342 |
{
|
343 |
if (!response.status)
|
344 |
{
|
345 |
showModalMsg(wphp_texts.error, response.error,
|
346 |
{});
|
347 |
-
$('#
|
348 |
-
$('#
|
349 |
}
|
350 |
else
|
351 |
{
|
352 |
-
$('#
|
353 |
-
$('#
|
354 |
-
$('#
|
355 |
-
$('#
|
356 |
}
|
357 |
-
$('#
|
358 |
-
$('#
|
359 |
}).fail(function(xhr, err)
|
360 |
{
|
361 |
id = $(this)[0].data.split('&')[1].split("=")[1];
|
362 |
-
$('#
|
363 |
-
$('#
|
364 |
showModalMsg(wphp_texts.error, formatErrorMessage(xhr, err));
|
365 |
})
|
366 |
});
|
@@ -386,8 +559,6 @@ if (!class_exists('wphp_settings'))
|
|
386 |
|
387 |
}
|
388 |
|
389 |
-
|
390 |
-
|
391 |
}
|
392 |
|
393 |
}
|
2 |
|
3 |
if (!class_exists('wphp_settings'))
|
4 |
{
|
5 |
+
|
6 |
class wphp_settings
|
7 |
{
|
8 |
+
private $pages, $settings_api, $asignment_fields = array(), $license_fields = array(), $asignment_section,
|
9 |
+
$core_section, $tabs = array()
|
10 |
|
11 |
+
, $settings = array(), $info_section, $info_fields, $all_tabs;
|
12 |
+
private $options;
|
13 |
private static $instance;
|
14 |
public $test;
|
15 |
+
public static function instance($options = array())
|
16 |
{
|
17 |
if (!self::$instance)
|
18 |
{
|
19 |
+
self::$instance = new wphp_settings($options);
|
20 |
|
21 |
}
|
22 |
return self::$instance;
|
23 |
}
|
24 |
+
public function __construct($options = array())
|
25 |
+
{
|
26 |
+
$this->options = $options;
|
27 |
+
$this->setup();
|
28 |
+
add_action('scb_download_sysinfo', array($this, 'tools_sysinfo_download'));
|
29 |
+
|
30 |
+
}
|
31 |
+
public function options($name = null)
|
32 |
{
|
33 |
+
if (!is_null($name))
|
34 |
+
{
|
35 |
+
if (isset($this->options[$name]))
|
36 |
+
{
|
37 |
+
return $this->options[$name];
|
38 |
+
}
|
39 |
+
else
|
40 |
+
{
|
41 |
+
return '';
|
42 |
+
}
|
43 |
+
}
|
44 |
+
else
|
45 |
+
{
|
46 |
+
return $this->options;
|
47 |
+
}
|
48 |
}
|
49 |
public function api()
|
50 |
{
|
62 |
}
|
63 |
public function register_tab($tabs)
|
64 |
{
|
65 |
+
$tabs = is_array($tabs) && isset($tabs[0]) ? $tabs : array($tabs);
|
66 |
|
67 |
foreach ($tabs as $item => $tab)
|
68 |
{
|
77 |
}
|
78 |
else
|
79 |
{
|
80 |
+
|
81 |
+
$tab['title'] = isset($tab['title']) ? $tab['title'] : '';
|
82 |
+
$tab['label'] = isset($tab['label']) ? $tab['label'] : '';
|
83 |
+
$tab['label'] = $tab['label'] ? $tab['label'] : $tab['title'];
|
84 |
+
$tab['label'] = $tab['label'] ? $tab['label'] : $tab['id'];
|
85 |
+
$tab['options'] = isset($tab['options']) ? $tab['options'] : array();
|
86 |
+
$this->tabs[$tab['id']] = array('id' => $tab['id'], 'title' => $tab['title'], 'label' => $tab['label'], 'options' => $tab['options']);
|
87 |
}
|
88 |
}
|
89 |
return $tabs;
|
92 |
{
|
93 |
if (!$this->pages)
|
94 |
{
|
95 |
+
$pages = get_pages(array('sort_order' => 'desc',
|
96 |
+
'sort_column' => 'post_date'));
|
97 |
foreach ($pages as $page)
|
98 |
{
|
99 |
$this->pages[$page->ID] = $page->post_title . "(" . $page->ID . ")";
|
100 |
|
101 |
}
|
102 |
}
|
103 |
+
$settings = is_array($settings) && isset($settings[0]) ? $settings : array($settings);
|
104 |
foreach ($settings as $key => $setting)
|
105 |
{
|
106 |
$settings[$key]['type'] = 'select';
|
112 |
}
|
113 |
public function register_setting_field($tab, $settings, $return = false)
|
114 |
{
|
115 |
+
$setting_temp = array();
|
116 |
+
$settings = is_array($settings) && isset($settings[0]) ? $settings : array($settings);
|
117 |
|
118 |
foreach ($settings as $item => $setting)
|
119 |
{
|
122 |
unset($settings[$item]);
|
123 |
continue;
|
124 |
}
|
125 |
+
$key = array_search($setting['name'], array_column(isset($this->settings[$tab]) && is_array($this->settings[$tab]) ? $this->settings[$tab] : array(), 'name'));
|
126 |
|
127 |
if ($key !== false)
|
128 |
{
|
142 |
else
|
143 |
{
|
144 |
$this->settings[$tab] = array_merge(
|
145 |
+
isset($this->settings[$tab]) && is_array(@$this->settings[$tab]) ? $this->settings[$tab] : array(), $setting_temp);
|
146 |
}
|
147 |
|
148 |
return $setting_temp;
|
150 |
public function init()
|
151 |
{
|
152 |
global $wpmovies_var;
|
153 |
+
$licenses = array();
|
154 |
+
$this->license_fields = array();
|
|
|
155 |
|
156 |
$licenses = apply_filters('scb_license_items', $licenses);
|
|
|
157 |
foreach ($licenses as $license)
|
158 |
{
|
159 |
|
160 |
+
$license['options'] = isset($license['options']) ? $license['options'] : array();
|
161 |
+
$this->license_fields[$license['id']] = array(
|
162 |
'name' => $license['id'],
|
163 |
'label' => $license['label'],
|
164 |
'desc' => 'dd',
|
165 |
'type' => 'text',
|
166 |
'default' => '',
|
167 |
+
'options' => isset($license['options']) ? $license['options'] : array(),
|
168 |
'callback' => array($this, 'callback_license_text_box'),
|
169 |
'sanitize_callback' => function ()
|
170 |
{
|
171 |
return '';
|
172 |
},
|
173 |
);
|
174 |
+
if (function_exists('scb_license_manager'))
|
175 |
{
|
176 |
+
$license['options']['license_file'] = isset($license['file']) ? $license['file'] : null;
|
177 |
+
$license['options']['license_folder'] = isset($license['folder']) ? $license['folder'] : null;
|
178 |
|
179 |
+
scb_license_manager()->add(
|
180 |
+
$license['id'],
|
181 |
+
isset($license['options']['store_url']) ? $license['options']['store_url'] : null,
|
182 |
$license['type'],
|
183 |
$license['name'],
|
184 |
null,
|
185 |
+
$license['options']
|
186 |
);
|
187 |
|
188 |
}
|
189 |
}
|
190 |
|
191 |
}
|
192 |
+
public function callback_info_page()
|
193 |
+
{
|
194 |
+
|
195 |
+
$info = scb_systems_info();
|
196 |
+
echo ('<textarea readonly="readonly" onclick="this.focus(); this.select()" id="system-info-textarea" name="scb-sysinfo">' . $info . "</textarea>");
|
197 |
+
|
198 |
+
}
|
199 |
+
|
200 |
+
public function callback_support_page()
|
201 |
+
{
|
202 |
+
|
203 |
+
echo ("support");
|
204 |
+
|
205 |
+
}
|
206 |
+
|
207 |
public function callback_license_text_box($args)
|
208 |
{
|
209 |
+
|
210 |
$license_key = '';
|
211 |
$license_info = '';
|
212 |
|
213 |
+
if (function_exists('scb_license_manager'))
|
214 |
{
|
215 |
+
$obj_license = scb_get_license($args['id']);
|
216 |
|
217 |
if (!is_null($obj_license))
|
218 |
{
|
221 |
$license_info = $obj_license->extendedInfo();
|
222 |
}
|
223 |
}
|
224 |
+
$license_info['license'] = isset($license_info['license']) ? $license_info['license'] : 'unknown';
|
225 |
+
$status = @$license_info['license'] == 'valid' ? 1 : 0;
|
226 |
|
227 |
$value = esc_attr($this->settings_api->get_option($args['id'], $args['section'], $args['std']));
|
228 |
+
// p_d( $value );
|
229 |
+
$size = isset($args['size']) && !is_null($args['size']) ? $args['size'] : 'regular';
|
230 |
+
$type = isset($args['type']) ? $args['type'] : 'text';
|
231 |
+
|
232 |
+
$key_input_id = '#scb_lic_txt_' . $args['id'];
|
233 |
+
$html = sprintf('<input type="%1$s" class="%2$s-text" id="scb_lic_txt_%4$s" name="%3$s[%4$s]" value="%5$s" />',
|
234 |
$type, $size, $args['section'], $args['id'], $license_key);
|
235 |
|
236 |
+
$html .= sprintf('<input data-key="%1$s" data-status="%2$s" data-id="%3$s" id="scb_lic_btn_%3$s" value="%4$s" type="submit" class="scb_lic_class button" name="license_action" >', $key_input_id, $status, $args['id'], ($status ? 'Deactivate' : 'Activate'));
|
237 |
+
$license_info['license_info'] = isset($license_info['license_info']) ? $license_info['license_info'] : '';
|
238 |
+
$license_info['error_info'] = isset($license_info['error_info']) ? $license_info['error_info'] : '';
|
239 |
+
$html .= sprintf('<p class="license_status %2$s" id="scb_lic_status_%1$s" >%3$s</p>', $args['id'], ($status ? 'license_status_valid' : 'license_status_invalid'), $license_info['license_info'] . ($license_info['error_info'] ? " -" . $license_info['error_info'] . " " : ''));
|
240 |
+
|
241 |
+
$license_text = $obj_license->options('license_text');
|
242 |
|
243 |
+
if (isset($license_text[$license_info['license']]))
|
244 |
+
{
|
245 |
+
$html .= "<p>" . $license_text[$license_info['license']] . "</p>";
|
246 |
+
}
|
247 |
|
248 |
echo $html;
|
249 |
}
|
250 |
public function admin_init()
|
251 |
{
|
252 |
//set the settings
|
253 |
+
|
254 |
$this->settings_api->set_sections($this->get_settings_sections());
|
255 |
$this->settings_api->set_fields($this->get_settings_fields());
|
256 |
//initialize settings
|
257 |
$this->settings_api->admin_init();
|
258 |
+
|
259 |
+
if (isset($_POST['option_page']) && isset($this->all_tabs[$_POST['option_page']]) && isset($this->all_tabs[@$_POST['option_page']]['options']['form']['pre_handler']) && is_callable($this->all_tabs[@$_POST['option_page']]['options']['form']['pre_handler']))
|
260 |
+
{
|
261 |
+
$ret = call_user_func_array($this->all_tabs[$_POST['option_page']]['options']['form']['pre_handler'], [$_POST]);
|
262 |
+
}
|
263 |
}
|
264 |
|
265 |
public function get_settings_sections()
|
266 |
{
|
267 |
+
$th = $this;
|
268 |
+
$this->core_sections['license'] = array(
|
269 |
+
'id' => 'scb_lic',
|
270 |
+
'title' => __('Licenses', 'scb_plugin'),
|
271 |
+
'options' => array('no_submit' => true),
|
272 |
+
|
273 |
+
);
|
274 |
+
|
275 |
+
$this->core_sections['info'] = array(
|
276 |
+
'id' => 'scb_info',
|
277 |
+
'title' => __('System Info', 'scb_plugin'),
|
278 |
+
'callback' => array($this, 'callback_info_page'),
|
279 |
+
'options' => array(
|
280 |
+
'no_submit' => false,
|
281 |
+
'button' => array('text' => 'Download Systme info file'),
|
282 |
+
'form' => array('pre_handler' => function () use ($th)
|
283 |
+
{
|
284 |
+
do_action('scb_download_sysinfo', $th->options['id'] . "_sysinfo.txt");
|
285 |
+
}),
|
286 |
+
),
|
287 |
);
|
288 |
|
289 |
+
$this->core_sections['support'] = array(
|
290 |
+
'id' => 'scb_support',
|
291 |
+
'label' => __('Support', 'scb_plugin'),
|
292 |
+
'callback' => is_callable($this->options('support_callback')) ? $this->options('support_callback') : array($this, 'callback_support_page'),
|
293 |
+
'options' => array(
|
294 |
+
'no_submit' => true,
|
295 |
+
),
|
296 |
+
);
|
297 |
|
298 |
+
$this->tabs = apply_filters('scb_setting_tabs', $this->tabs);
|
299 |
+
$this->all_tabs = array_merge(
|
300 |
+
array('scb_lic' => $this->core_sections['license']),
|
301 |
+
$this->tabs,
|
302 |
+
array('scb_info' => $this->core_sections['info']),
|
303 |
+
array('scb_support' => $this->core_sections['support'])
|
304 |
+
);
|
305 |
+
return $this->all_tabs;
|
306 |
|
307 |
}
|
308 |
+
|
309 |
/**
|
310 |
* Returns all the settings fields
|
311 |
*
|
314 |
public function get_settings_fields()
|
315 |
{
|
316 |
|
317 |
+
$this->settings = apply_filters('scb_setting_fields', $this->settings);
|
318 |
+
$this->settings[$this->core_sections['license']['id']] = $this->license_fields;
|
319 |
+
// $this->settings[$this->core_sections['info']['id']] = $this->info_fields;
|
320 |
+
|
321 |
$this->settings[$this->asignment_section['id']] = $this->asignment_fields;
|
322 |
|
323 |
return $this->settings;
|
325 |
}
|
326 |
public function plugin_page()
|
327 |
{
|
328 |
+
//p_n($_POST);
|
329 |
+
//p_d($this->all_tabs);
|
330 |
+
if (isset($_POST['option_page']) && isset($this->all_tabs[$_POST['option_page']]) && is_callable($this->all_tabs[$_POST['option_page']]['options']['form']['post_handler']))
|
331 |
+
{
|
332 |
+
$ret = call_user_func_array($this->all_tabs[$_POST['option_page']]['options']['form']['post_handler'], [$_POST]);
|
333 |
+
}
|
334 |
echo '<div class="wrap">';
|
335 |
$this->settings_api->show_navigation();
|
336 |
+
settings_errors(null, false, true);
|
337 |
+
$this->settings_api->show_forms("options.php", $this->options);
|
338 |
$this->script();
|
339 |
echo '</div>';
|
340 |
}
|
341 |
+
|
342 |
+
/**
|
343 |
+
* Generates a System Info download file
|
344 |
+
*
|
345 |
+
* @since 2.0
|
346 |
+
* @return void
|
347 |
+
*/
|
348 |
+
|
349 |
+
public function tools_sysinfo_download($filename)
|
350 |
+
{
|
351 |
+
|
352 |
+
if (!current_user_can('manage_options'))
|
353 |
+
{
|
354 |
+
return;
|
355 |
+
}
|
356 |
+
@ob_end_clean();
|
357 |
+
nocache_headers();
|
358 |
+
|
359 |
+
header('Content-Type: text/plain');
|
360 |
+
header('Content-Disposition: attachment; filename="' . $filename . '"');
|
361 |
+
|
362 |
+
// die( wp_strip_all_tags($_POST['scb-sysinfo']);
|
363 |
+
die(wp_strip_all_tags($_POST['scb-sysinfo']));
|
364 |
+
}
|
365 |
+
|
366 |
/**
|
367 |
* Get all the pages
|
368 |
*
|
383 |
}
|
384 |
public function manage_license()
|
385 |
{
|
|
|
|
|
|
|
|
|
386 |
|
387 |
+
try
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
388 |
{
|
389 |
+
$response['status'] = 0;
|
390 |
+
$response['error'] = 'Unknown Error';
|
391 |
+
$response['lic_id'] = @$_REQUEST['id'];
|
392 |
+
$response['lic_key'] = @$_REQUEST['key'];
|
393 |
|
394 |
+
$obj_license = scb_get_license($response['lic_id']);
|
395 |
+
|
396 |
+
if (!$obj_license)
|
397 |
{
|
398 |
+
$response['error'] = 'Invalid Plugin Or theme(1)';
|
399 |
}
|
400 |
+
elseif (!$response['lic_key'])
|
401 |
{
|
402 |
+
$response['error'] = 'Invalid Plugin Or theme(2)';
|
403 |
}
|
404 |
+
else
|
405 |
+
{
|
406 |
+
$obj_license->set_license_key($response['lic_key']);
|
407 |
+
|
408 |
+
if (@$_REQUEST['status'])
|
409 |
+
{
|
410 |
+
$obj_license->deactivate_license();
|
411 |
+
}
|
412 |
+
else
|
413 |
+
{
|
414 |
+
$obj_license->activate_license();
|
415 |
+
}
|
416 |
+
$response['error'] = "";
|
417 |
+
$response['status'] = 1;
|
418 |
+
$license_info = $obj_license->extendedInfo();
|
419 |
|
420 |
+
$license_info['license'] = isset($license_info['license']) ? $license_info['license'] : 'unknown';
|
421 |
|
422 |
+
$response['lic_status'] = $license_info['license'] == 'valid' ? 1 : 0;
|
|
|
423 |
|
424 |
+
$license_info = $obj_license->extendedInfo();
|
425 |
+
|
426 |
+
$response['lic_msg'][] = $license_info['license_info'] . ($license_info['error_info'] ? " -" . $license_info['error_info'] . " " : '');
|
427 |
+
|
428 |
+
$license_text = $obj_license->options('license_text');
|
429 |
|
430 |
+
if (isset($license_text[$license_info['license']]))
|
431 |
+
{
|
432 |
+
$response['lic_msg'][] = "<br/>" . $license_text[$license_info['license']];
|
433 |
+
}
|
434 |
+
$response['lic_msg'] = implode("\n", $response['lic_msg']);
|
435 |
+
$response['lic_btn'] = ($response['lic_status'] ? 'Deactivate' : 'Activate');
|
436 |
+
|
437 |
+
}
|
438 |
+
}
|
439 |
+
catch (Exception $e)
|
440 |
+
{
|
441 |
+
$response['status'] = 0;
|
442 |
+
$response['error'] = $e->getMessage();
|
443 |
+
}
|
444 |
wp_send_json($response);
|
445 |
}
|
446 |
public function script()
|
469 |
}
|
470 |
.chosen-container .search-field {
|
471 |
float: none!important;
|
472 |
+
|
473 |
+
}
|
474 |
+
#system-info-textarea {
|
475 |
+
background: 0 0;
|
476 |
+
font-family: Menlo,Monaco,monospace;
|
477 |
+
display: block;
|
478 |
+
overflow: auto;
|
479 |
+
white-space: pre;
|
480 |
+
width: 100%;
|
481 |
+
height: 400px;
|
482 |
}
|
483 |
</style>
|
484 |
|
485 |
<script>
|
486 |
+
var scb_setting_tabs_options={};
|
487 |
+
<?php foreach ($this->all_tabs as $tab_id => $tab)
|
488 |
+
{
|
489 |
+
if (isset($tab['options']) && is_array($tab['options']) && count($tab['options']))
|
490 |
+
{
|
491 |
+
echo ("scb_setting_tabs_options['$tab_id'] = " . json_encode($tab['options']) . "\n");
|
492 |
+
}
|
493 |
+
}
|
494 |
+
// (isset($tab['options'])?json_encode($tab)?'')
|
495 |
+
?>
|
496 |
jQuery(document).ready(function($)
|
497 |
+
|
498 |
{
|
499 |
+
|
500 |
+
|
501 |
+
|
502 |
+
$('.scb_lic_class').on('click', function(event)
|
503 |
{
|
504 |
event.preventDefault();
|
505 |
var data = {
|
506 |
action: 'manage_license',
|
507 |
id: $(this).data('id'),
|
508 |
+
key: $($(this).data('key')).val(),
|
509 |
status: $(this).data('status'),
|
510 |
};
|
511 |
+
$('#scb_lic_btn_' + $(this).data('id')).data('label', $('#scb_lic_btn_' + $(this).data('id')).val());
|
512 |
+
$('#scb_lic_btn_' + $(this).data('id')).val('Please Wait..');
|
513 |
+
$('#scb_lic_btn_' + $(this).data('id')).attr('disabled', true);
|
514 |
$.post(ajaxurl, data, function(response)
|
515 |
{
|
516 |
if (!response.status)
|
517 |
{
|
518 |
showModalMsg(wphp_texts.error, response.error,
|
519 |
{});
|
520 |
+
$('#scb_lic_btn_' + response.lic_id).val($('#scb_lic_btn_' + response.lic_id).data('label'));
|
521 |
+
$('#scb_lic_btn_' + response.lic_id).attr('disabled', false)
|
522 |
}
|
523 |
else
|
524 |
{
|
525 |
+
$('#scb_lic_txt_' + response.lic_id).data('status', response.lic_status);
|
526 |
+
$('#scb_lic_btn_' + response.lic_id).val(response.lic_btn);
|
527 |
+
$('#scb_lic_btn_' + response.lic_id).attr('disabled', false);
|
528 |
+
$('#scb_lic_status_' + response.lic_id).html(response.lic_msg);
|
529 |
}
|
530 |
+
$('#scb_lic_status_' + response.lic_id).removeClass().addClass("license_status " + (response.lic_status ? 'license_status_valid' : 'license_status_invalid'));
|
531 |
+
$('#scb_lic_btn_' + response.lic_id).data('status', response.lic_status);
|
532 |
}).fail(function(xhr, err)
|
533 |
{
|
534 |
id = $(this)[0].data.split('&')[1].split("=")[1];
|
535 |
+
$('#scb_lic_btn_' + id).val($('#scb_lic_btn_' + id).data('label'));
|
536 |
+
$('#scb_lic_btn_' + id).attr('disabled', false)
|
537 |
showModalMsg(wphp_texts.error, formatErrorMessage(xhr, err));
|
538 |
})
|
539 |
});
|
559 |
|
560 |
}
|
561 |
|
|
|
|
|
562 |
}
|
563 |
|
564 |
}
|
admin/settings/class_settingsAPI.php
CHANGED
@@ -510,6 +510,7 @@ if (!class_exists('wphp_settingsAPI'))
|
|
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 |
|
@@ -523,15 +524,20 @@ if (!class_exists('wphp_settingsAPI'))
|
|
523 |
*
|
524 |
* This function displays every sections in a different form
|
525 |
*/
|
526 |
-
public function
|
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']);
|
@@ -539,10 +545,13 @@ do_action('wsa_form_top_' . $form['id'], $form);
|
|
539 |
do_settings_sections($form['id']);
|
540 |
|
541 |
do_action('wsa_form_bottom_' . $form['id'], $form);
|
542 |
-
|
543 |
-
|
544 |
-
|
|
|
|
|
545 |
</div>
|
|
|
546 |
<?php do_action('wsa_form_last_' . $form['id'], $form);?>
|
547 |
</form>
|
548 |
</div>
|
@@ -562,7 +571,11 @@ $this->script();
|
|
562 |
{
|
563 |
?>
|
564 |
<script>
|
|
|
|
|
|
|
565 |
jQuery(document).ready(function($) {
|
|
|
566 |
//Initiate Color Picker
|
567 |
$('.wp-color-picker-field').wpColorPicker();
|
568 |
|
510 |
|
511 |
foreach ($this->settings_sections as $tab)
|
512 |
{
|
513 |
+
p_n($tab);
|
514 |
$html .= sprintf('<a href="#%1$s" class="nav-tab" id="%1$s-tab">%2$s</a>', $tab['id'], $tab['title']);
|
515 |
}
|
516 |
|
524 |
*
|
525 |
* This function displays every sections in a different form
|
526 |
*/
|
527 |
+
public function show_forms1($page = "options.php",$options=array())
|
528 |
{
|
529 |
?>
|
530 |
<div class="metabox-holder">
|
531 |
<?php foreach ($this->settings_sections as $form)
|
532 |
{
|
533 |
+
$button['type'] = isset($form['options']['button']['type']) ? $form['options']['button']['type'] : 'primary';
|
534 |
+
$button['text'] = isset($form['options']['button']['text']) ? $form['options']['button']['text'] : null;
|
535 |
+
$button['name'] = isset($form['options']['button']['name']) ? $form['options']['button']['name'] : null;
|
536 |
+
|
537 |
+
|
538 |
?>
|
539 |
<div id="<?php echo $form['id']; ?>" class="group" style="display: none;">
|
540 |
+
<form method="post" action="<?php echo (isset($form['options']['form']['page']) ? $form['options']['form']['page'] : $page); ?>">
|
541 |
<?php
|
542 |
do_action('wsa_form_top_' . $form['id'], $form);
|
543 |
settings_fields($form['id']);
|
545 |
do_settings_sections($form['id']);
|
546 |
|
547 |
do_action('wsa_form_bottom_' . $form['id'], $form);
|
548 |
+
if (!(isset($form['options']['no_submit']) && $form['options']['no_submit']))
|
549 |
+
{
|
550 |
+
?>
|
551 |
+
<div style="padding-left: 10px" class="scb_tab_submit_div">
|
552 |
+
<?php submit_button($button['text'], $button['type'], $button['name']);?>
|
553 |
</div>
|
554 |
+
<?php }?>
|
555 |
<?php do_action('wsa_form_last_' . $form['id'], $form);?>
|
556 |
</form>
|
557 |
</div>
|
571 |
{
|
572 |
?>
|
573 |
<script>
|
574 |
+
|
575 |
+
|
576 |
+
|
577 |
jQuery(document).ready(function($) {
|
578 |
+
|
579 |
//Initiate Color Picker
|
580 |
$('.wp-color-picker-field').wpColorPicker();
|
581 |
|
admin/settings/class_settingsAPICustom.php
CHANGED
@@ -41,12 +41,17 @@ if (!class_exists('wphp_settingsAPICustom'))
|
|
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']))
|
@@ -66,6 +71,7 @@ if (!class_exists('wphp_settingsAPICustom'))
|
|
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);
|
@@ -86,10 +92,11 @@ if (!class_exists('wphp_settingsAPICustom'))
|
|
86 |
}
|
87 |
public function callback_yesno($args)
|
88 |
{
|
89 |
-
|
|
|
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 |
{
|
@@ -114,7 +121,7 @@ if (!class_exists('wphp_settingsAPICustom'))
|
|
114 |
{
|
115 |
$value = esc_attr($value);
|
116 |
}
|
117 |
-
$value = is_array($value) ? $value :
|
118 |
$size = isset($args['multiple']) ? '' : (isset($args['size']) && !is_null($args['size']) ? $args['size'] : 'regular');
|
119 |
if (isset($args['class']))
|
120 |
{
|
@@ -127,7 +134,7 @@ if (!class_exists('wphp_settingsAPICustom'))
|
|
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);
|
@@ -203,17 +210,73 @@ if (!class_exists('wphp_settingsAPICustom'))
|
|
203 |
}
|
204 |
public function show_navigation()
|
205 |
{
|
206 |
-
$html
|
|
|
|
|
|
|
|
|
|
|
207 |
|
208 |
foreach ($this->settings_sections as $tab)
|
209 |
{
|
210 |
-
|
|
|
211 |
}
|
212 |
|
213 |
$html .= '</h2>';
|
214 |
|
215 |
echo $html;
|
216 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
217 |
public function get_field_description($args)
|
218 |
{
|
219 |
if (!empty($args['desc']))
|
41 |
$callback = null;
|
42 |
}
|
43 |
|
44 |
+
add_settings_section($section['id'], isset($section['title'])?$section['title']:'', $callback, $section['id']);
|
45 |
}
|
46 |
+
|
47 |
//register settings fields
|
48 |
foreach ($this->settings_fields as $section => $field)
|
49 |
{
|
50 |
+
if (!is_array($field) || !count($field))
|
51 |
+
{
|
52 |
+
continue;
|
53 |
+
}
|
54 |
+
|
55 |
foreach ($field as $option)
|
56 |
{
|
57 |
if (!isset($option['name']) || !isset($option['label']))
|
71 |
'std' => isset($option['default']) ? $option['default'] : '',
|
72 |
'sanitize_callback' => isset($option['sanitize_callback']) ? $option['sanitize_callback'] : '',
|
73 |
'type' => $type,
|
74 |
+
|
75 |
);
|
76 |
$args = array_merge($option, $args);
|
77 |
$callable = isset($option['callback']) && (is_callable($option['callback']) || is_array($option['callback'])) ? $option['callback'] : array($this, 'callback_' . $type);
|
92 |
}
|
93 |
public function callback_yesno($args)
|
94 |
{
|
95 |
+
|
96 |
+
$args['options'] = array('1' => 'Yes', '0' => 'No');
|
97 |
$value = esc_attr($this->get_option($args['id'], $args['section'], $args['std']));
|
98 |
$size = isset($args['size']) && !is_null($args['size']) ? $args['size'] : 'regular';
|
99 |
+
$html = sprintf('<select class="%1$s" name="%2$s[%3$s]" id="%2$s[%3$s]" %4$s>', $size, $args['section'], $args['id'],isset($args['disabled'])?$args['disabled']:'');
|
100 |
|
101 |
foreach ($args['options'] as $key => $label)
|
102 |
{
|
121 |
{
|
122 |
$value = esc_attr($value);
|
123 |
}
|
124 |
+
$value = is_array($value) ? $value : array($value);
|
125 |
$size = isset($args['multiple']) ? '' : (isset($args['size']) && !is_null($args['size']) ? $args['size'] : 'regular');
|
126 |
if (isset($args['class']))
|
127 |
{
|
134 |
$extra = '';
|
135 |
if (is_array($label))
|
136 |
{
|
137 |
+
$extra = isset($label['extra'])?$label['extra']:'';
|
138 |
$label = @$label['text'];
|
139 |
}
|
140 |
$html .= sprintf('<option %s value="%s"%s>%s</option>', $extra, $key, in_array($key, $value) ? 'selected' : '', $label);
|
210 |
}
|
211 |
public function show_navigation()
|
212 |
{
|
213 |
+
$html='';
|
214 |
+
if(wphp_settings::instance()->options('page_title'))
|
215 |
+
{
|
216 |
+
$html="<h1>".wphp_settings::instance()->options('page_title')."</h1>";
|
217 |
+
}
|
218 |
+
$html .= '<h2 class="nav-tab-wrapper scb-set-nav">';
|
219 |
|
220 |
foreach ($this->settings_sections as $tab)
|
221 |
{
|
222 |
+
|
223 |
+
$html .= sprintf('<a href="#%1$s" class="nav-tab" id="%1$s-tab" data-tab-id="%1$s">%2$s</a>', $tab['id'], (!empty($tab['label']) ? $tab['label'] : $tab['title']));
|
224 |
}
|
225 |
|
226 |
$html .= '</h2>';
|
227 |
|
228 |
echo $html;
|
229 |
}
|
230 |
+
/**
|
231 |
+
* Show the section settings forms
|
232 |
+
*
|
233 |
+
* This function displays every sections in a different form
|
234 |
+
*/
|
235 |
+
public function show_forms($page = "options.php", $options = array())
|
236 |
+
{
|
237 |
+
?>
|
238 |
+
<div class="metabox-holder">
|
239 |
+
<?php
|
240 |
+
foreach ($this->settings_sections as $form)
|
241 |
+
{
|
242 |
+
$button['type'] = isset($form['options']['button']['type']) ? $form['options']['button']['type'] : 'primary';
|
243 |
+
$button['text'] = isset($form['options']['button']['text']) ? $form['options']['button']['text'] : null;
|
244 |
+
$button['name'] = isset($form['options']['button']['name']) ? $form['options']['button']['name'] : null;
|
245 |
+
if (isset($form['options']['form']['page']))
|
246 |
+
{
|
247 |
+
$page = $form['options']['form']['page'];
|
248 |
+
}
|
249 |
+
elseif (isset($form['options']['form']['handler']) && is_callable($form['options']['form']['handler']))
|
250 |
+
{
|
251 |
+
$page = 'options-general.php?page=' . $options['setting_page_name'];
|
252 |
+
}
|
253 |
+
|
254 |
+
?>
|
255 |
+
<div id="<?php echo $form['id']; ?>" class="group" style="display: none;">
|
256 |
+
<form method="post" action="<?php echo ($page); ?>">
|
257 |
+
<?php
|
258 |
+
do_action('wsa_form_top_' . $form['id'], $form);
|
259 |
+
settings_fields($form['id']);
|
260 |
+
|
261 |
+
do_settings_sections($form['id']);
|
262 |
+
|
263 |
+
do_action('wsa_form_bottom_' . $form['id'], $form);
|
264 |
+
if (!(isset($form['options']['no_submit']) && $form['options']['no_submit']))
|
265 |
+
{
|
266 |
+
?>
|
267 |
+
<div style="padding-left: 10px" class="scb_tab_submit_div">
|
268 |
+
<?php submit_button($button['text'], $button['type'], $button['name']);?>
|
269 |
+
</div>
|
270 |
+
<?php }?>
|
271 |
+
<?php do_action('wsa_form_last_' . $form['id'], $form);?>
|
272 |
+
</form>
|
273 |
+
</div>
|
274 |
+
<?php }?>
|
275 |
+
<?php do_action('wsa_global_footer', $form);?>
|
276 |
+
</div>
|
277 |
+
<?php
|
278 |
+
$this->script();
|
279 |
+
}
|
280 |
public function get_field_description($args)
|
281 |
{
|
282 |
if (!empty($args['desc']))
|
includes/class-wp-hide-post-activator.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Fired during plugin activation
|
5 |
*
|
6 |
* @link http://scriptburn.com
|
7 |
-
* @since
|
8 |
*
|
9 |
* @package wp_hide_post
|
10 |
* @subpackage wp_hide_post/includes
|
@@ -15,7 +15,7 @@
|
|
15 |
*
|
16 |
* This class defines all code necessary to run during the plugin's activation.
|
17 |
*
|
18 |
-
* @since
|
19 |
* @package wp_hide_post
|
20 |
* @subpackage wp_hide_post/includes
|
21 |
* @author ScriptBurn <support@scriptburn.com>
|
@@ -30,78 +30,20 @@ class wp_hide_post_Activator
|
|
30 |
*
|
31 |
* @since 1.2.2
|
32 |
*/
|
33 |
-
public
|
34 |
{
|
35 |
-
|
36 |
-
|
37 |
-
}
|
38 |
|
39 |
-
|
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 |
-
|
63 |
}
|
|
|
64 |
|
65 |
-
|
66 |
-
$
|
67 |
-
|
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 |
/**
|
@@ -130,4 +72,5 @@ class wp_hide_post_Activator
|
|
130 |
}
|
131 |
|
132 |
}
|
|
|
133 |
}
|
4 |
* Fired during plugin activation
|
5 |
*
|
6 |
* @link http://scriptburn.com
|
7 |
+
* @since 2.0
|
8 |
*
|
9 |
* @package wp_hide_post
|
10 |
* @subpackage wp_hide_post/includes
|
15 |
*
|
16 |
* This class defines all code necessary to run during the plugin's activation.
|
17 |
*
|
18 |
+
* @since 2.0
|
19 |
* @package wp_hide_post
|
20 |
* @subpackage wp_hide_post/includes
|
21 |
* @author ScriptBurn <support@scriptburn.com>
|
30 |
*
|
31 |
* @since 1.2.2
|
32 |
*/
|
33 |
+
public function activate()
|
34 |
{
|
35 |
+
delete_transient('wphp_notices_footer');
|
36 |
+
delete_transient('wphp_notices_widget');
|
|
|
37 |
|
38 |
+
if(!get_option('wphp_support_hash'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
{
|
40 |
+
add_option('wphp_support_hash',base64_encode(wp_generate_password(32,true,false)));
|
41 |
}
|
42 |
+
$this->remove_wp_low_profiler();
|
43 |
|
44 |
+
require_once WPHP_PLUGIN_DIR . 'admin/class-wp-hide-post-dbupdate.php';
|
45 |
+
$db_updater = new wp_hide_post_DB_Update();
|
46 |
+
$db_updater->update_to_ver_2();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
}
|
48 |
|
49 |
/**
|
72 |
}
|
73 |
|
74 |
}
|
75 |
+
|
76 |
}
|
includes/class-wp-hide-post-deactivator.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Fired during plugin deactivation
|
5 |
*
|
6 |
* @link http://scriptburn.com
|
7 |
-
* @since
|
8 |
*
|
9 |
* @package wp_hide_post
|
10 |
* @subpackage wp_hide_post/includes
|
@@ -15,7 +15,7 @@
|
|
15 |
*
|
16 |
* This class defines all code necessary to run during the plugin's deactivation.
|
17 |
*
|
18 |
-
* @since
|
19 |
* @package wp_hide_post
|
20 |
* @subpackage wp_hide_post/includes
|
21 |
* @author ScriptBurn <support@scriptburn.com>
|
4 |
* Fired during plugin deactivation
|
5 |
*
|
6 |
* @link http://scriptburn.com
|
7 |
+
* @since 2.0
|
8 |
*
|
9 |
* @package wp_hide_post
|
10 |
* @subpackage wp_hide_post/includes
|
15 |
*
|
16 |
* This class defines all code necessary to run during the plugin's deactivation.
|
17 |
*
|
18 |
+
* @since 2.0
|
19 |
* @package wp_hide_post
|
20 |
* @subpackage wp_hide_post/includes
|
21 |
* @author ScriptBurn <support@scriptburn.com>
|
includes/class-wp-hide-post-i18n.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
* so that it is ready for translation.
|
8 |
*
|
9 |
* @link http://scriptburn.com
|
10 |
-
* @since
|
11 |
*
|
12 |
* @package wp_hide_post
|
13 |
* @subpackage wp_hide_post/includes
|
@@ -19,7 +19,7 @@
|
|
19 |
* Loads and defines the internationalization files for this plugin
|
20 |
* so that it is ready for translation.
|
21 |
*
|
22 |
-
* @since
|
23 |
* @package wp_hide_post
|
24 |
* @subpackage wp_hide_post/includes
|
25 |
* @author ScriptBurn <support@scriptburn.com>
|
7 |
* so that it is ready for translation.
|
8 |
*
|
9 |
* @link http://scriptburn.com
|
10 |
+
* @since 2.0
|
11 |
*
|
12 |
* @package wp_hide_post
|
13 |
* @subpackage wp_hide_post/includes
|
19 |
* Loads and defines the internationalization files for this plugin
|
20 |
* so that it is ready for translation.
|
21 |
*
|
22 |
+
* @since 2.0
|
23 |
* @package wp_hide_post
|
24 |
* @subpackage wp_hide_post/includes
|
25 |
* @author ScriptBurn <support@scriptburn.com>
|
includes/class-wp-hide-post-loader.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Register all actions and filters for the plugin
|
5 |
*
|
6 |
* @link http://scriptburn.com
|
7 |
-
* @since
|
8 |
*
|
9 |
* @package wp_hide_post
|
10 |
* @subpackage wp_hide_post/includes
|
4 |
* Register all actions and filters for the plugin
|
5 |
*
|
6 |
* @link http://scriptburn.com
|
7 |
+
* @since 2.0
|
8 |
*
|
9 |
* @package wp_hide_post
|
10 |
* @subpackage wp_hide_post/includes
|
includes/class-wp-hide-post.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
* public-facing side of the site and the admin area.
|
8 |
*
|
9 |
* @link http://scriptburn.com
|
10 |
-
* @since
|
11 |
*
|
12 |
* @package wp_hide_post
|
13 |
* @subpackage wp_hide_post/includes
|
@@ -22,7 +22,7 @@
|
|
22 |
* Also maintains the unique identifier of this plugin as well as the current
|
23 |
* version of the plugin.
|
24 |
*
|
25 |
-
* @since
|
26 |
* @package wp_hide_post
|
27 |
* @subpackage wp_hide_post/includes
|
28 |
* @author ScriptBurn <support@scriptburn.com>
|
@@ -76,14 +76,10 @@ class wp_hide_post
|
|
76 |
private static $instance;
|
77 |
private $plugin_admin;
|
78 |
|
79 |
-
const
|
80 |
-
const
|
81 |
-
|
82 |
-
|
83 |
-
const title = '';
|
84 |
-
const dir = '';
|
85 |
-
const url = '';
|
86 |
-
const file = '';
|
87 |
|
88 |
/**
|
89 |
* Define the core functionality of the plugin.
|
@@ -111,6 +107,11 @@ class wp_hide_post
|
|
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();
|
@@ -172,11 +173,9 @@ class wp_hide_post
|
|
172 |
|
173 |
require_once WPHP_PLUGIN_DIR . 'admin/settings/autoload.php';
|
174 |
require_once WPHP_PLUGIN_DIR . 'admin/conditions.php';
|
|
|
175 |
|
176 |
-
$this->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()
|
@@ -214,6 +213,8 @@ class wp_hide_post
|
|
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');
|
@@ -231,12 +232,13 @@ class wp_hide_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 |
-
|
237 |
-
|
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
|
@@ -262,7 +264,7 @@ class wp_hide_post
|
|
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, '
|
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
|
@@ -271,8 +273,28 @@ class wp_hide_post
|
|
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 |
/**
|
@@ -292,20 +314,20 @@ class wp_hide_post
|
|
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 |
-
|
304 |
|
305 |
// only for testing purpose , Enables hidepost enabled post type to appear everywhere
|
306 |
if (wphp_is_demo())
|
307 |
{
|
308 |
-
|
|
|
309 |
|
310 |
}
|
311 |
// used to add join clause to remove next and previous rel link of post from single page
|
@@ -342,6 +364,19 @@ class wp_hide_post
|
|
342 |
|
343 |
public function info($name)
|
344 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
345 |
return defined('static::' . $name) ? constant('self::' . $name) : '';
|
346 |
}
|
347 |
/**
|
@@ -363,22 +398,85 @@ class wp_hide_post
|
|
363 |
*/
|
364 |
public function get_version()
|
365 |
{
|
366 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
367 |
}
|
368 |
public function init()
|
369 |
{
|
370 |
-
$this->settingManager = wphp_settings::instance(
|
371 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
372 |
}
|
373 |
public function define_globals()
|
374 |
{
|
375 |
|
376 |
-
$this->dir =
|
377 |
-
$this->url =
|
378 |
|
379 |
-
$this->title = __('WP Hide Post', '
|
380 |
-
$this->file =
|
381 |
-
$this->basename =
|
382 |
}
|
383 |
}
|
384 |
function wp_hide_post()
|
7 |
* public-facing side of the site and the admin area.
|
8 |
*
|
9 |
* @link http://scriptburn.com
|
10 |
+
* @since 2.0
|
11 |
*
|
12 |
* @package wp_hide_post
|
13 |
* @subpackage wp_hide_post/includes
|
22 |
* Also maintains the unique identifier of this plugin as well as the current
|
23 |
* version of the plugin.
|
24 |
*
|
25 |
+
* @since 2.0
|
26 |
* @package wp_hide_post
|
27 |
* @subpackage wp_hide_post/includes
|
28 |
* @author ScriptBurn <support@scriptburn.com>
|
76 |
private static $instance;
|
77 |
private $plugin_admin;
|
78 |
|
79 |
+
const id = 'wp-hide-post-pro';
|
80 |
+
const name = 'WP Hide Post Pro';
|
81 |
+
|
82 |
+
private $info;
|
|
|
|
|
|
|
|
|
83 |
|
84 |
/**
|
85 |
* Define the core functionality of the plugin.
|
107 |
$this->define_globals();
|
108 |
$this->load_dependencies();
|
109 |
$this->init();
|
110 |
+
|
111 |
+
$this->plugin_admin = new wp_hide_post_Admin(
|
112 |
+
$this->get_wp_hide_post(),
|
113 |
+
$this->get_version(), $this->license());
|
114 |
+
|
115 |
$this->set_locale();
|
116 |
$this->define_admin_hooks();
|
117 |
$this->define_public_hooks();
|
173 |
|
174 |
require_once WPHP_PLUGIN_DIR . 'admin/settings/autoload.php';
|
175 |
require_once WPHP_PLUGIN_DIR . 'admin/conditions.php';
|
176 |
+
require_once WPHP_PLUGIN_DIR . 'admin/plugin/autoload.php';
|
177 |
|
178 |
+
$this->loader = new wp_hide_post_Loader();
|
|
|
|
|
|
|
179 |
|
180 |
}
|
181 |
public function settingManager()
|
213 |
*/
|
214 |
private function define_admin_hooks()
|
215 |
{
|
216 |
+
$this->loader->add_filter('scb_license_items', $this->plugin_admin, 'register_plugin', 10);
|
217 |
+
$this->loader->add_action('init', $this->plugin_admin, 'register_setting_page');
|
218 |
|
219 |
//add our styles
|
220 |
$this->loader->add_action('admin_enqueue_scripts', $this->plugin_admin, 'enqueue_styles');
|
232 |
$this->loader->add_action('delete_post', $this->plugin_admin, 'delete_post');
|
233 |
|
234 |
$this->loader->add_action('add_meta_boxes', $this->plugin_admin, 'add_meta_boxes');
|
|
|
235 |
$this->loader->add_action('admin_menu', $this->plugin_admin, 'admin_menu');
|
236 |
+
if (wphp_is_demo())
|
237 |
+
{
|
238 |
+
$this->loader->add_filter('init', $this->plugin_admin, 'create_post_type', 10);
|
239 |
+
}
|
240 |
// loop through all allowed post types as saved in setting section of the plugin where we this plugin can work
|
241 |
+
|
242 |
foreach ($this->plugin_admin->allowedPostTypes() as $post_type)
|
243 |
{
|
244 |
// add our custom column to posts list
|
264 |
$this->loader->add_action('quick_edit_custom_box', $this->plugin_admin, 'display_custom_quickedit', 10, 2);
|
265 |
|
266 |
//render our bulk edit box
|
267 |
+
$this->loader->add_action('bulk_edit_custom_box', $this->plugin_admin, 'display_custom_bulkedit', 10, 2);
|
268 |
|
269 |
// print our available visibility type items in footer js
|
270 |
// which we will use when sending our data to server in bulk edit save
|
273 |
//Save bulk edit data
|
274 |
$this->loader->add_action('wp_ajax_save_bulk_edit_data', $this->plugin_admin, 'save_bulk_edit_data');
|
275 |
|
276 |
+
//Our custom action to add fotter message in widget
|
277 |
$this->loader->add_action('wsa_global_footer', $this->plugin_admin, 'wsa_footer');
|
278 |
|
279 |
+
//Check if we need to update database
|
280 |
+
$this->loader->add_action('plugins_loaded', $this->plugin_admin, 'maybe_update', 1);
|
281 |
+
|
282 |
+
//returns system info data for support reques
|
283 |
+
add_action('plugins_loaded', function ()
|
284 |
+
{
|
285 |
+
if (isset($_REQUEST['support_info']))
|
286 |
+
{
|
287 |
+
if (isset($_REQUEST['hash']) && get_option('wphp_support_hash') == $_REQUEST['hash'])
|
288 |
+
{
|
289 |
+
echo (scb_systems_info("</br>"));
|
290 |
+
}
|
291 |
+
|
292 |
+
wp_die();
|
293 |
+
}
|
294 |
+
}, 1);
|
295 |
+
|
296 |
+
//$theme_item = new SCB_Item_Helper($this->store, $this->item_file_name, $this->get_license_key(), $this->item_type);
|
297 |
+
|
298 |
}
|
299 |
|
300 |
/**
|
314 |
|
315 |
$this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_styles');
|
316 |
$this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_scripts');
|
|
|
317 |
|
318 |
//add where clauss in main filter query
|
319 |
+
$this->loader->add_filter('posts_where_paged', $plugin_public, 'query_posts_where', 10, 2);
|
320 |
|
321 |
//add join clauss in main filter query
|
322 |
$this->loader->add_filter('posts_join_paged', $plugin_public, 'query_posts_join', 10, 2);
|
323 |
|
324 |
+
$this->loader->add_filter('widget_posts_args', $plugin_public, 'widget_posts_args');
|
325 |
|
326 |
// only for testing purpose , Enables hidepost enabled post type to appear everywhere
|
327 |
if (wphp_is_demo())
|
328 |
{
|
329 |
+
|
330 |
+
//$this->loader->add_action('pre_get_posts', $plugin_public, 'test_enable_allposts_everywhere');
|
331 |
|
332 |
}
|
333 |
// used to add join clause to remove next and previous rel link of post from single page
|
364 |
|
365 |
public function info($name)
|
366 |
{
|
367 |
+
if (defined('static::' . $name))
|
368 |
+
{
|
369 |
+
return constant('self::' . $name);
|
370 |
+
}
|
371 |
+
elseif (isset($this->info[$name]))
|
372 |
+
{
|
373 |
+
return $this->info[$name];
|
374 |
+
}
|
375 |
+
else
|
376 |
+
{
|
377 |
+
return "";
|
378 |
+
|
379 |
+
}
|
380 |
return defined('static::' . $name) ? constant('self::' . $name) : '';
|
381 |
}
|
382 |
/**
|
398 |
*/
|
399 |
public function get_version()
|
400 |
{
|
401 |
+
return WPHP_VER;
|
402 |
+
}
|
403 |
+
|
404 |
+
public function setting_menu_page()
|
405 |
+
{
|
406 |
+
return $this->get_wp_hide_post() . '_settings_api';
|
407 |
+
}
|
408 |
+
public function license()
|
409 |
+
{
|
410 |
+
return SCB_LicenseManager::getInstance()->item($this->info('id'));
|
411 |
}
|
412 |
public function init()
|
413 |
{
|
414 |
+
$this->settingManager = wphp_settings::instance(array
|
415 |
+
(
|
416 |
+
'id' => $this->info('id'),
|
417 |
+
'page_title' => $this->info('title') . " settings",
|
418 |
+
'setting_page_name' => $this->setting_menu_page(),
|
419 |
+
'support_callback' => function ()
|
420 |
+
{
|
421 |
+
$obj_license = scb_get_license($this->info('id'));
|
422 |
+
$info = array();
|
423 |
+
$info['price'] = "0";
|
424 |
+
if (is_object($obj_license))
|
425 |
+
{
|
426 |
+
$info = $obj_license->extendedInfo();
|
427 |
+
$info['key'] = $obj_license->get_license_key();
|
428 |
+
|
429 |
+
}
|
430 |
+
|
431 |
+
$output = array();
|
432 |
+
$info['price'] = 1;
|
433 |
+
if ($info['price'] > 0)
|
434 |
+
{
|
435 |
+
$output[] = '<h2>For WP hide post Pro users</h2>';
|
436 |
+
if ($info['key'] && $info['license'] == 'valid')
|
437 |
+
{
|
438 |
+
$subject = ("WP hide post Pro Support Request");
|
439 |
+
$body = "";
|
440 |
+
$body .= "License:" . $info['key'] . "%0D%0A%0D%0A";
|
441 |
+
$body .= 'Systems Info:' . home_url() . "?support_info" . "%0D%0A%0D%0A";
|
442 |
+
$body .= 'Hash:' . get_option('wphp_support_hash') . "%0D%0A%0D%0A%0D%0A%0D%0A";
|
443 |
+
$body .= "Enter your message here ";
|
444 |
+
$output[] = sprintf('<a href="mailto:support@scriptburn.com?subject=%1$s&body=%2$s">Click here </a>', $subject, $body);
|
445 |
+
}
|
446 |
+
else
|
447 |
+
{
|
448 |
+
$output[] = "Sorry you don't have WP hide post Pro license";
|
449 |
+
}
|
450 |
+
$output[] = '<h2>For WP hide post Lite users</h2>';
|
451 |
+
}
|
452 |
+
$output[] = 'Please submit your questions <a target="_blank" href="https://github.com/scriptburn/wp-hide-post">Here</a>';
|
453 |
+
echo (implode("\n", $output));
|
454 |
+
},
|
455 |
+
));
|
456 |
+
|
457 |
+
scb_license_manager()->add(
|
458 |
+
$this->info('id'),
|
459 |
+
null,
|
460 |
+
'plugin',
|
461 |
+
$this->info('name'),
|
462 |
+
null,
|
463 |
+
array(
|
464 |
+
'license_text' => array('invalid' => 'Get your WP Hide Post Pro license from here <a href="http://scriptburn.com/wphp" target="_blank">here</a>'),
|
465 |
+
'store_url' => "http://scriptburn.com",
|
466 |
+
'file' => $this->info('file'),
|
467 |
+
|
468 |
+
)
|
469 |
+
);
|
470 |
}
|
471 |
public function define_globals()
|
472 |
{
|
473 |
|
474 |
+
$this->info['dir'] = WPHP_PLUGIN_DIR;
|
475 |
+
$this->info['url'] = WPHP_PLUGIN_URL;
|
476 |
|
477 |
+
$this->info['title'] = __('WP Hide Post', 'scb_plugin');
|
478 |
+
$this->info['file'] = WPHP_PLUGIN_FILE;
|
479 |
+
$this->info['basename'] = plugin_basename($this->info['file']);
|
480 |
}
|
481 |
}
|
482 |
function wp_hide_post()
|
includes/helpers.php
CHANGED
@@ -137,45 +137,38 @@ if (!function_exists('wphp_allowed_post_types'))
|
|
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 (
|
160 |
{
|
161 |
-
|
|
|
162 |
}
|
163 |
-
|
164 |
-
if (!defined('WPHP_DEBUG'))
|
165 |
{
|
166 |
-
|
|
|
167 |
}
|
168 |
-
|
169 |
-
if (!defined('WPHP_META_VALUE_PREFIX'))
|
170 |
{
|
171 |
-
|
|
|
172 |
}
|
173 |
-
|
174 |
{
|
175 |
-
|
|
|
176 |
}
|
|
|
177 |
}
|
178 |
}
|
|
|
179 |
if (!function_exists('wphp_'))
|
180 |
{
|
181 |
function wphp_($text)
|
@@ -187,6 +180,7 @@ if (!function_exists('wphp_is_demo'))
|
|
187 |
{
|
188 |
function wphp_is_demo()
|
189 |
{
|
|
|
190 |
return $_SERVER['HTTP_HOST'] == 'wphidepost.loc';
|
191 |
}
|
192 |
}
|
@@ -259,3 +253,189 @@ if (!function_exists('wphp_visibility_types'))
|
|
259 |
}
|
260 |
}
|
261 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
}
|
138 |
if (!function_exists('wphp_is_applicable'))
|
139 |
{
|
140 |
+
function wphp_is_applicable($item_type, $wp_query = null)
|
141 |
{
|
142 |
+
|
143 |
$types = array_flip(wphp_allowed_post_types());
|
144 |
unset($types['page']);
|
145 |
|
146 |
$types = array_flip($types);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
|
148 |
+
if (wphp_is_post_sidebar($wp_query))
|
149 |
{
|
150 |
+
//p_n(__LINE__);
|
151 |
+
return true;
|
152 |
}
|
153 |
+
elseif (is_admin() || is_singular())
|
|
|
154 |
{
|
155 |
+
//p_n(__LINE__);
|
156 |
+
return false;
|
157 |
}
|
158 |
+
elseif (in_array($item_type, $types) || $item_type == 'page')
|
|
|
159 |
{
|
160 |
+
// p_n(__LINE__);
|
161 |
+
return true;
|
162 |
}
|
163 |
+
else
|
164 |
{
|
165 |
+
// p_n(__LINE__);
|
166 |
+
return false;
|
167 |
}
|
168 |
+
|
169 |
}
|
170 |
}
|
171 |
+
|
172 |
if (!function_exists('wphp_'))
|
173 |
{
|
174 |
function wphp_($text)
|
180 |
{
|
181 |
function wphp_is_demo()
|
182 |
{
|
183 |
+
|
184 |
return $_SERVER['HTTP_HOST'] == 'wphidepost.loc';
|
185 |
}
|
186 |
}
|
253 |
}
|
254 |
}
|
255 |
}
|
256 |
+
|
257 |
+
if (!function_exists('array_column'))
|
258 |
+
{
|
259 |
+
/**
|
260 |
+
* Returns the values from a single column of the input array, identified by
|
261 |
+
* the $columnKey.
|
262 |
+
*
|
263 |
+
* Optionally, you may provide an $indexKey to index the values in the returned
|
264 |
+
* array by the values from the $indexKey column in the input array.
|
265 |
+
*
|
266 |
+
* @param array $input A multi-dimensional array (record set) from which to pull
|
267 |
+
* a column of values.
|
268 |
+
* @param mixed $columnKey The column of values to return. This value may be the
|
269 |
+
* integer key of the column you wish to retrieve, or it
|
270 |
+
* may be the string key name for an associative array.
|
271 |
+
* @param mixed $indexKey (Optional.) The column to use as the index/keys for
|
272 |
+
* the returned array. This value may be the integer key
|
273 |
+
* of the column, or it may be the string key name.
|
274 |
+
* @return array
|
275 |
+
*/
|
276 |
+
function array_column($input = null, $columnKey = null, $indexKey = null)
|
277 |
+
{
|
278 |
+
// Using func_get_args() in order to check for proper number of
|
279 |
+
// parameters and trigger errors exactly as the built-in array_column()
|
280 |
+
// does in PHP 5.5.
|
281 |
+
$argc = func_num_args();
|
282 |
+
$params = func_get_args();
|
283 |
+
if ($argc < 2)
|
284 |
+
{
|
285 |
+
trigger_error("array_column() expects at least 2 parameters, {$argc} given", E_USER_WARNING);
|
286 |
+
return null;
|
287 |
+
}
|
288 |
+
if (!is_array($params[0]))
|
289 |
+
{
|
290 |
+
trigger_error(
|
291 |
+
'array_column() expects parameter 1 to be array, ' . gettype($params[0]) . ' given',
|
292 |
+
E_USER_WARNING
|
293 |
+
);
|
294 |
+
return null;
|
295 |
+
}
|
296 |
+
if (!is_int($params[1])
|
297 |
+
&& !is_float($params[1])
|
298 |
+
&& !is_string($params[1])
|
299 |
+
&& $params[1] !== null
|
300 |
+
&& !(is_object($params[1]) && method_exists($params[1], '__toString'))
|
301 |
+
)
|
302 |
+
{
|
303 |
+
trigger_error('array_column(): The column key should be either a string or an integer', E_USER_WARNING);
|
304 |
+
return false;
|
305 |
+
}
|
306 |
+
if (isset($params[2])
|
307 |
+
&& !is_int($params[2])
|
308 |
+
&& !is_float($params[2])
|
309 |
+
&& !is_string($params[2])
|
310 |
+
&& !(is_object($params[2]) && method_exists($params[2], '__toString'))
|
311 |
+
)
|
312 |
+
{
|
313 |
+
trigger_error('array_column(): The index key should be either a string or an integer', E_USER_WARNING);
|
314 |
+
return false;
|
315 |
+
}
|
316 |
+
$paramsInput = $params[0];
|
317 |
+
$paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null;
|
318 |
+
$paramsIndexKey = null;
|
319 |
+
if (isset($params[2]))
|
320 |
+
{
|
321 |
+
if (is_float($params[2]) || is_int($params[2]))
|
322 |
+
{
|
323 |
+
$paramsIndexKey = (int) $params[2];
|
324 |
+
}
|
325 |
+
else
|
326 |
+
{
|
327 |
+
$paramsIndexKey = (string) $params[2];
|
328 |
+
}
|
329 |
+
}
|
330 |
+
$resultArray = array();
|
331 |
+
foreach ($paramsInput as $row)
|
332 |
+
{
|
333 |
+
$key = $value = null;
|
334 |
+
$keySet = $valueSet = false;
|
335 |
+
if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row))
|
336 |
+
{
|
337 |
+
$keySet = true;
|
338 |
+
$key = (string) $row[$paramsIndexKey];
|
339 |
+
}
|
340 |
+
if ($paramsColumnKey === null)
|
341 |
+
{
|
342 |
+
$valueSet = true;
|
343 |
+
$value = $row;
|
344 |
+
}
|
345 |
+
elseif (is_array($row) && array_key_exists($paramsColumnKey, $row))
|
346 |
+
{
|
347 |
+
$valueSet = true;
|
348 |
+
$value = $row[$paramsColumnKey];
|
349 |
+
}
|
350 |
+
if ($valueSet)
|
351 |
+
{
|
352 |
+
if ($keySet)
|
353 |
+
{
|
354 |
+
$resultArray[$key] = $value;
|
355 |
+
}
|
356 |
+
else
|
357 |
+
{
|
358 |
+
$resultArray[] = $value;
|
359 |
+
}
|
360 |
+
}
|
361 |
+
}
|
362 |
+
return $resultArray;
|
363 |
+
}
|
364 |
+
}
|
365 |
+
|
366 |
+
function wphp_get_host()
|
367 |
+
{
|
368 |
+
$host = false;
|
369 |
+
|
370 |
+
if (defined('WPE_APIKEY'))
|
371 |
+
{
|
372 |
+
$host = 'WP Engine';
|
373 |
+
}
|
374 |
+
elseif (defined('PAGELYBIN'))
|
375 |
+
{
|
376 |
+
$host = 'Pagely';
|
377 |
+
}
|
378 |
+
elseif (DB_HOST == 'localhost:/tmp/mysql5.sock')
|
379 |
+
{
|
380 |
+
$host = 'ICDSoft';
|
381 |
+
}
|
382 |
+
elseif (DB_HOST == 'mysqlv5')
|
383 |
+
{
|
384 |
+
$host = 'NetworkSolutions';
|
385 |
+
}
|
386 |
+
elseif (strpos(DB_HOST, 'ipagemysql.com') !== false)
|
387 |
+
{
|
388 |
+
$host = 'iPage';
|
389 |
+
}
|
390 |
+
elseif (strpos(DB_HOST, 'ipowermysql.com') !== false)
|
391 |
+
{
|
392 |
+
$host = 'IPower';
|
393 |
+
}
|
394 |
+
elseif (strpos(DB_HOST, '.gridserver.com') !== false)
|
395 |
+
{
|
396 |
+
$host = 'MediaTemple Grid';
|
397 |
+
}
|
398 |
+
elseif (strpos(DB_HOST, '.pair.com') !== false)
|
399 |
+
{
|
400 |
+
$host = 'pair Networks';
|
401 |
+
}
|
402 |
+
elseif (strpos(DB_HOST, '.stabletransit.com') !== false)
|
403 |
+
{
|
404 |
+
$host = 'Rackspace Cloud';
|
405 |
+
}
|
406 |
+
elseif (strpos(DB_HOST, '.sysfix.eu') !== false)
|
407 |
+
{
|
408 |
+
$host = 'SysFix.eu Power Hosting';
|
409 |
+
}
|
410 |
+
elseif (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false)
|
411 |
+
{
|
412 |
+
$host = 'Flywheel';
|
413 |
+
}
|
414 |
+
else
|
415 |
+
{
|
416 |
+
// Adding a general fallback for data gathering
|
417 |
+
$host = 'DBH: ' . DB_HOST . ', SRV: ' . $_SERVER['SERVER_NAME'];
|
418 |
+
}
|
419 |
+
|
420 |
+
return $host;
|
421 |
+
}
|
422 |
+
|
423 |
+
function scb_custom_post_types($output = 'objects')
|
424 |
+
{
|
425 |
+
|
426 |
+
$args = array(
|
427 |
+
'public' => true,
|
428 |
+
'_builtin' => true,
|
429 |
+
);
|
430 |
+
|
431 |
+
$operator = 'or'; // 'and' or 'or'
|
432 |
+
|
433 |
+
$types = (array) get_post_types($args, $output, $operator);
|
434 |
+
unset($types['revision']);
|
435 |
+
unset($types['nav_menu_item']);
|
436 |
+
unset($types['attachment']);
|
437 |
+
|
438 |
+
|
439 |
+
return empty($types) || !is_array($types) ? array() : $types;
|
440 |
+
|
441 |
+
}
|
public/class-wp-hide-post-public.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* The public-facing functionality of the plugin.
|
5 |
*
|
6 |
* @link http://scriptburn.com
|
7 |
-
* @since
|
8 |
*
|
9 |
* @package wp_hide_post
|
10 |
* @subpackage wp_hide_post/public
|
@@ -76,7 +76,7 @@ class wp_hide_post_Public
|
|
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 |
|
@@ -166,7 +166,6 @@ class wp_hide_post_Public
|
|
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";
|
@@ -178,13 +177,17 @@ class wp_hide_post_Public
|
|
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;
|
@@ -194,40 +197,75 @@ class wp_hide_post_Public
|
|
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($
|
203 |
{
|
204 |
-
|
|
|
205 |
{
|
206 |
-
$
|
207 |
}
|
208 |
-
$
|
209 |
-
|
210 |
-
|
211 |
-
$join .= '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
221 |
foreach ($visibility_types as $visibility_type => $detail)
|
222 |
{
|
223 |
-
|
224 |
-
|
225 |
-
|
|
|
|
|
|
|
|
|
|
|
226 |
if (!empty($detail['condition_callback']))
|
227 |
{
|
228 |
$callbacks[] = $detail['condition_callback'];
|
229 |
}
|
230 |
-
|
|
|
|
|
|
|
|
|
231 |
|
232 |
foreach ($callbacks as $callback)
|
233 |
{
|
@@ -236,8 +274,9 @@ class wp_hide_post_Public
|
|
236 |
|
237 |
if (is_callable($callback))
|
238 |
{
|
239 |
-
|
240 |
-
|
|
|
241 |
if ($ret)
|
242 |
{
|
243 |
$keys[] = sprintf('%1$s%2$s', WPHP_META_VALUE_PREFIX, $condition);
|
@@ -250,12 +289,17 @@ class wp_hide_post_Public
|
|
250 |
|
251 |
if (!count($keys))
|
252 |
{
|
253 |
-
|
|
|
254 |
}
|
255 |
else
|
256 |
{
|
257 |
-
$
|
|
|
|
|
|
|
258 |
}
|
|
|
259 |
}
|
260 |
foreach ($post_joins as $post_type => $joins)
|
261 |
{
|
@@ -263,7 +307,7 @@ class wp_hide_post_Public
|
|
263 |
}
|
264 |
|
265 |
$join .= implode(" OR ", $post_joins) . ")";
|
266 |
-
|
267 |
return $join;
|
268 |
}
|
269 |
/**
|
@@ -273,195 +317,36 @@ class wp_hide_post_Public
|
|
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 |
-
|
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 |
-
$
|
|
|
|
|
|
|
465 |
return $join;
|
466 |
}
|
467 |
public function test_enable_allposts_everywhere($query)
|
4 |
* The public-facing functionality of the plugin.
|
5 |
*
|
6 |
* @link http://scriptburn.com
|
7 |
+
* @since 2.0
|
8 |
*
|
9 |
* @package wp_hide_post
|
10 |
* @subpackage wp_hide_post/public
|
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 |
|
166 |
public function query_posts_where_rel_exclude($where)
|
167 |
{
|
168 |
// filter posts on one of the three kinds of contexts: front, category, feed
|
|
|
169 |
$where .= ' AND ' . WPHP_TABLE_NAME . '.post_id IS NULL ';
|
170 |
|
171 |
//echo "\n<!-- WPHP: ".$where." -->\n";
|
177 |
* @param $where
|
178 |
* @return unknown_type
|
179 |
*/
|
180 |
+
public function query_posts_where($where, &$wp_query = null)
|
181 |
{
|
182 |
+
|
183 |
p_l("called: wphp_query_posts_where");
|
184 |
+
|
185 |
// filter posts on one of the three kinds of contexts: front, category, feed
|
186 |
+
if (wphp_is_applicable('post', $wp_query) && wphp_is_applicable('page', $wp_query))
|
187 |
{
|
188 |
+
// $where .= ' AND ' . WPHP_TABLE_NAME . '.post_id IS NULL ';
|
189 |
+
$where .= ' AND c.post_id IS NULL ';
|
190 |
+
|
191 |
}
|
192 |
//echo "\n<!-- WPHP: ".$where." -->\n";
|
193 |
return $where;
|
197 |
// is being called from recent posts widget
|
198 |
public function widget_posts_args($posts_args)
|
199 |
{
|
200 |
+
// p_n("in widget_posts_args");
|
201 |
$posts_args['wphp_inside_recent_post_sidebar'] = 1;
|
202 |
|
203 |
return $posts_args;
|
204 |
}
|
205 |
|
206 |
+
private function get_exclude_join($params)
|
207 |
{
|
208 |
+
|
209 |
+
if (empty($params['table']))
|
210 |
{
|
211 |
+
$params['table'] = WP_POSTS_TABLE_NAME;
|
212 |
}
|
213 |
+
$params['wp_query'] = isset($params['wp_query']) ? $params['wp_query'] : null;
|
214 |
+
$params['from_rel_query'] = isset($params['from_rel_query']) ? $params['from_rel_query'] : null;
|
215 |
+
$join = "";
|
216 |
+
// $join .= ' -' . WPHP_TABLE_NAME . ' wphptbl ON ' . WP_POSTS_TABLE_NAME . ".ID = wphptbl.post_id and wphptbl.meta_key like '" . WPHP_META_VALUE_PREFIX . "%'";
|
217 |
+
//p_n($join);
|
218 |
+
//p_d(stripos( "JOIN " . WPHP_TABLE_NAME,$join),1);
|
219 |
+
$alias = "c";
|
220 |
+
if (stripos($join, "JOIN " . WPHP_TABLE_NAME) === false)
|
221 |
+
{
|
222 |
+
$join .= ' LEFT JOIN ' . WPHP_TABLE_NAME . " $alias ON " . $params['table'] . ".ID = " . $alias . ".post_id ";
|
223 |
+
}
|
224 |
+
$join .= " and " . $alias . ".meta_key like '" . WPHP_META_VALUE_PREFIX . "%' and (";
|
225 |
// filter posts
|
226 |
$can_display = null;
|
227 |
+
$keys = array();
|
228 |
$visibility_types_data['post'] = wp_hide_post()->pluginAdmin()->get_visibility_types('post');
|
229 |
$visibility_types_data['page'] = wp_hide_post()->pluginAdmin()->get_visibility_types('page');
|
230 |
+
$post_joins = array();
|
231 |
+
|
232 |
+
$args = $params;
|
233 |
+
$sidebar = wphp_is_post_sidebar($params['wp_query']);
|
234 |
+
|
235 |
foreach ($visibility_types_data as $post_type => $visibility_types)
|
236 |
{
|
237 |
+
if ($post_type == 'page')
|
238 |
+
{
|
239 |
+
$post_joins[$post_type][] = $params['table'] . '.' . "post_type='page'";
|
240 |
+
|
241 |
+
}
|
242 |
+
else
|
243 |
+
{
|
244 |
+
$post_joins[$post_type][] = $params['table'] . '.' . wphp_allowed_post_types(true);
|
245 |
+
}
|
246 |
+
if ($post_type == 'page' && is_search())
|
247 |
+
{
|
248 |
+
// $keys[] = '_wplp_page_search';
|
249 |
+
}
|
250 |
foreach ($visibility_types as $visibility_type => $detail)
|
251 |
{
|
252 |
+
|
253 |
+
if ($sidebar && $visibility_type != 'post_recent')
|
254 |
+
{
|
255 |
+
continue;
|
256 |
+
}
|
257 |
+
$condition = !empty($detail['condition']) ? $detail['condition'] : $visibility_type;
|
258 |
+
$callbacks = array();
|
259 |
+
|
260 |
if (!empty($detail['condition_callback']))
|
261 |
{
|
262 |
$callbacks[] = $detail['condition_callback'];
|
263 |
}
|
264 |
+
else
|
265 |
+
{
|
266 |
+
// p_n('wphp_is_' . $condition . "_" . $post_type);
|
267 |
+
$callbacks[] = 'wphp_is_' . $condition . "_" . $post_type;
|
268 |
+
}
|
269 |
|
270 |
foreach ($callbacks as $callback)
|
271 |
{
|
274 |
|
275 |
if (is_callable($callback))
|
276 |
{
|
277 |
+
|
278 |
+
$ret = call_user_func_array($callback, array(($args)));
|
279 |
+
|
280 |
if ($ret)
|
281 |
{
|
282 |
$keys[] = sprintf('%1$s%2$s', WPHP_META_VALUE_PREFIX, $condition);
|
289 |
|
290 |
if (!count($keys))
|
291 |
{
|
292 |
+
|
293 |
+
$post_joins[$post_type][] = sprintf($alias . '.meta_key not like "%1$s"', WPHP_META_VALUE_PREFIX);
|
294 |
}
|
295 |
else
|
296 |
{
|
297 |
+
$pre = "";
|
298 |
+
|
299 |
+
$post_joins[$post_type][] = sprintf("(" . $alias . '.meta_key in ( %1$s) %2$s)', "'" . implode("','", $keys) . "'", ' ' . $pre);
|
300 |
+
|
301 |
}
|
302 |
+
|
303 |
}
|
304 |
foreach ($post_joins as $post_type => $joins)
|
305 |
{
|
307 |
}
|
308 |
|
309 |
$join .= implode(" OR ", $post_joins) . ")";
|
310 |
+
//p_n($join);
|
311 |
return $join;
|
312 |
}
|
313 |
/**
|
317 |
*/
|
318 |
public function query_posts_join($join, &$wp_query)
|
319 |
{
|
|
|
|
|
320 |
|
321 |
if (isset($wp_query->query['wphp_inside_recent_post_sidebar']))
|
322 |
{
|
323 |
//p_n($wp_query);
|
324 |
}
|
325 |
|
326 |
+
// p_n("called: wphp_query_posts_join");
|
327 |
+
if (wphp_is_applicable('post', $wp_query) && wphp_is_applicable('page', $wp_query))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
328 |
{
|
|
|
|
|
329 |
|
|
|
|
|
|
|
330 |
if (!$join)
|
331 |
{
|
332 |
$join = '';
|
333 |
}
|
334 |
+
$params = array('table' => WP_POSTS_TABLE_NAME, 'wp_query' => $wp_query);
|
335 |
+
$join .= $this->get_exclude_join($params);
|
336 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
337 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
338 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
339 |
return $join;
|
340 |
}
|
341 |
|
342 |
public function post_excluded_terms_join_rel($join)
|
343 |
{
|
344 |
+
// p_n("post_excluded_terms_join_rel");
|
345 |
//SELECT p.ID FROM scbposts AS p (join) WHERE p.post_date < '2016-07-25 12:58:19' AND p.post_type = 'post' AND ( p.post_status = 'publish' OR p.post_status = 'private' ) ORDER BY p.post_date DESC LIMIT 1
|
346 |
+
$params = array('table' => 'p', 'wp_query' => null, 'from_rel_query' => true);
|
347 |
+
|
348 |
+
$join .= ' LEFT JOIN ' . WPHP_TABLE_NAME . ' ON ' . $params['table'] . ".ID = " . WPHP_TABLE_NAME . ".post_id and " . WPHP_TABLE_NAME . ".meta_key ='" . WPHP_META_VALUE_PREFIX . "post_recent'";
|
349 |
+
|
350 |
return $join;
|
351 |
}
|
352 |
public function test_enable_allposts_everywhere($query)
|
public/partials/wp-hide-post-public-display.php
CHANGED
@@ -6,11 +6,10 @@
|
|
6 |
* This file is used to markup the public-facing aspects of the plugin.
|
7 |
*
|
8 |
* @link http://scriptburn.com
|
9 |
-
* @since
|
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. -->
|
6 |
* This file is used to markup the public-facing aspects of the plugin.
|
7 |
*
|
8 |
* @link http://scriptburn.com
|
9 |
+
* @since 2.0
|
10 |
*
|
11 |
* @package wp_hide_post
|
12 |
* @subpackage wp_hide_post/public/partials
|
13 |
*/
|
14 |
?>
|
15 |
|
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: scriptburn
|
|
3 |
Donate link: http://scriptburn.com/wp-hide-post/
|
4 |
Tags: SEO,hide,show,visbility,privacy,customization,sitemap,filter
|
5 |
Requires at least: 2.6
|
6 |
-
Tested up to: 4.
|
7 |
-
Stable tag: 2.0.
|
8 |
License: GPLv2
|
9 |
|
10 |
Control the visibility of items on your blog by making posts/pages hidden on some parts , while still visible in other parts and search engines.
|
@@ -111,6 +111,17 @@ Ditto. It will be deleted. If you had any existing data (if you had it active be
|
|
111 |
|
112 |
== Changelog ==
|
113 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
= 2.0.2 =
|
115 |
*Release Date - 12 August 2016*
|
116 |
|
3 |
Donate link: http://scriptburn.com/wp-hide-post/
|
4 |
Tags: SEO,hide,show,visbility,privacy,customization,sitemap,filter
|
5 |
Requires at least: 2.6
|
6 |
+
Tested up to: 4.8
|
7 |
+
Stable tag: 2.0.4
|
8 |
License: GPLv2
|
9 |
|
10 |
Control the visibility of items on your blog by making posts/pages hidden on some parts , while still visible in other parts and search engines.
|
111 |
|
112 |
== Changelog ==
|
113 |
|
114 |
+
= 2.0.4 =
|
115 |
+
*Release Date - 30 July 2017*
|
116 |
+
|
117 |
+
*Fix: An issue that prevented system info file download
|
118 |
+
|
119 |
+
= 2.0.3 =
|
120 |
+
*Release Date - 12 August 2016*
|
121 |
+
|
122 |
+
* Fixed "Check All" not working in Bulk edit page
|
123 |
+
* Added a function array_column for wordpress install which are running < PHP5.5.5
|
124 |
+
|
125 |
= 2.0.2 =
|
126 |
*Release Date - 12 August 2016*
|
127 |
|
uninstall.php
CHANGED
@@ -20,7 +20,7 @@
|
|
20 |
* https://github.com/tommcfarlin/WordPress-Plugin-Boilerplate/pull/123#issuecomment-28541913
|
21 |
*
|
22 |
* @link http://scriptburn.com
|
23 |
-
* @since
|
24 |
*
|
25 |
* @package wp_hide_post
|
26 |
*/
|
20 |
* https://github.com/tommcfarlin/WordPress-Plugin-Boilerplate/pull/123#issuecomment-28541913
|
21 |
*
|
22 |
* @link http://scriptburn.com
|
23 |
+
* @since 2.0
|
24 |
*
|
25 |
* @package wp_hide_post
|
26 |
*/
|
wp-hide-post.php
CHANGED
@@ -16,7 +16,7 @@
|
|
16 |
* Plugin Name: WP Hide Post
|
17 |
* Plugin URI: http://scriptburn.com/wp-hide-post
|
18 |
* Description: Control the visibility of items on your blog by making posts/pages hidden on some parts , while still visible in other parts and search engines.
|
19 |
-
* Version: 2.0.
|
20 |
* Author: scriptburn.com
|
21 |
* Author URI: http://www.scriptburn.com
|
22 |
* License: GPL-2.0+
|
@@ -30,7 +30,40 @@ if (!defined('WPINC'))
|
|
30 |
{
|
31 |
die;
|
32 |
}
|
|
|
|
|
|
|
|
|
33 |
define('WPHP_PLUGIN_DIR', __DIR__ . "/");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
/**
|
35 |
* The code that runs during plugin activation.
|
36 |
* This action is documented in includes/class-wp-hide-post-activator.php
|
@@ -38,8 +71,8 @@ define('WPHP_PLUGIN_DIR', __DIR__ . "/");
|
|
38 |
function activate_wp_hide_post()
|
39 |
{
|
40 |
require_once plugin_dir_path(__FILE__) . 'includes/class-wp-hide-post-activator.php';
|
41 |
-
$wphp=new wp_hide_post_Activator();
|
42 |
-
|
43 |
}
|
44 |
|
45 |
/**
|
@@ -49,7 +82,7 @@ function activate_wp_hide_post()
|
|
49 |
function deactivate_wp_hide_post()
|
50 |
{
|
51 |
require_once plugin_dir_path(__FILE__) . 'includes/class-wp-hide-post-deactivator.php';
|
52 |
-
|
53 |
$wphp->deactivate();
|
54 |
}
|
55 |
|
@@ -74,7 +107,7 @@ require plugin_dir_path(__FILE__) . 'includes/class-wp-hide-post.php';
|
|
74 |
function run_wp_hide_post()
|
75 |
{
|
76 |
|
77 |
-
$plugin =
|
78 |
$plugin->run();
|
79 |
|
80 |
}
|
16 |
* Plugin Name: WP Hide Post
|
17 |
* Plugin URI: http://scriptburn.com/wp-hide-post
|
18 |
* Description: Control the visibility of items on your blog by making posts/pages hidden on some parts , while still visible in other parts and search engines.
|
19 |
+
* Version: 2.0.4
|
20 |
* Author: scriptburn.com
|
21 |
* Author URI: http://www.scriptburn.com
|
22 |
* License: GPL-2.0+
|
30 |
{
|
31 |
die;
|
32 |
}
|
33 |
+
global $table_prefix;
|
34 |
+
define('WPHP_VER', "2.0.4");
|
35 |
+
define('WPHP_DB_VER', "2");
|
36 |
+
|
37 |
define('WPHP_PLUGIN_DIR', __DIR__ . "/");
|
38 |
+
define('WPHP_PLUGIN_FILE',__FILE__);
|
39 |
+
|
40 |
+
define('WPHP_PLUGIN_URL',plugin_dir_url(WPHP_PLUGIN_FILE));
|
41 |
+
|
42 |
+
|
43 |
+
if (!defined('WPHP_TABLE_NAME'))
|
44 |
+
{
|
45 |
+
define('WPHP_TABLE_NAME', "${table_prefix}postmeta");
|
46 |
+
}
|
47 |
+
|
48 |
+
if (!defined('WP_POSTS_TABLE_NAME'))
|
49 |
+
{
|
50 |
+
define('WP_POSTS_TABLE_NAME', "${table_prefix}posts");
|
51 |
+
}
|
52 |
+
|
53 |
+
if (!defined('WPHP_DEBUG'))
|
54 |
+
{
|
55 |
+
define('WPHP_DEBUG', defined('WP_DEBUG') && WP_DEBUG ? 1 : 0);
|
56 |
+
}
|
57 |
+
|
58 |
+
if (!defined('WPHP_META_VALUE_PREFIX'))
|
59 |
+
{
|
60 |
+
define('WPHP_META_VALUE_PREFIX', '_wplp_');
|
61 |
+
}
|
62 |
+
if (!defined('WPHP_VISIBILITY_NAME'))
|
63 |
+
{
|
64 |
+
define('WPHP_VISIBILITY_NAME', 'wphp_visibility_type');
|
65 |
+
}
|
66 |
+
|
67 |
/**
|
68 |
* The code that runs during plugin activation.
|
69 |
* This action is documented in includes/class-wp-hide-post-activator.php
|
71 |
function activate_wp_hide_post()
|
72 |
{
|
73 |
require_once plugin_dir_path(__FILE__) . 'includes/class-wp-hide-post-activator.php';
|
74 |
+
$wphp = new wp_hide_post_Activator();
|
75 |
+
$wphp->activate();
|
76 |
}
|
77 |
|
78 |
/**
|
82 |
function deactivate_wp_hide_post()
|
83 |
{
|
84 |
require_once plugin_dir_path(__FILE__) . 'includes/class-wp-hide-post-deactivator.php';
|
85 |
+
$wphp = new wp_hide_post_Deactivator();
|
86 |
$wphp->deactivate();
|
87 |
}
|
88 |
|
107 |
function run_wp_hide_post()
|
108 |
{
|
109 |
|
110 |
+
$plugin = wp_hide_post::getInstance() ;
|
111 |
$plugin->run();
|
112 |
|
113 |
}
|