author | ymh <ymh.work@gmail.com> |
Mon, 08 Sep 2025 19:44:41 +0200 | |
changeset 23 | 417f20492bf7 |
parent 21 | 48c4eec2b7e6 |
permissions | -rwxr-xr-x |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1 |
<?php |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
2 |
if ( ! defined( 'ABSPATH' ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
3 |
exit; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
4 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
5 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
6 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
7 |
* Displays the content on the plugin settings page |
19 | 8 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
9 |
* @package BestWebSoft |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
10 |
* @since 1.9.8 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
11 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
12 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
13 |
if ( ! class_exists( 'Bws_Settings_Tabs' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
14 |
class Bws_Settings_Tabs { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
15 |
private $tabs; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
16 |
private $pro_plugin_is_activated = false; |
19 | 17 |
private $custom_code_args = array(); |
18 |
private $bws_plugin_link = ''; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
19 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
20 |
public $plugin_basename; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
21 |
public $prefix; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
22 |
public $wp_slug; |
12 | 23 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
24 |
public $options; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
25 |
public $default_options; |
12 | 26 |
public $is_network_options; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
27 |
public $plugins_info = array(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
28 |
public $hide_pro_tabs = false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
29 |
public $demo_data; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
30 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
31 |
public $is_pro = false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
32 |
public $pro_page; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
33 |
public $bws_license_plugin; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
34 |
public $link_key; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
35 |
public $link_pn; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
36 |
public $is_trial = false; |
12 | 37 |
public $licenses; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
38 |
public $trial_days; |
12 | 39 |
public $bws_hide_pro_option_exist = true; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
40 |
|
19 | 41 |
public $forbid_view = false; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
42 |
public $change_permission_attr = ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
43 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
44 |
public $version; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
45 |
public $upload_dir; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
46 |
public $all_plugins; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
47 |
public $is_multisite; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
48 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
49 |
public $doc_link; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
50 |
public $doc_video_link; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
51 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
52 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
53 |
* Constructor. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
54 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
55 |
* The child class should call this constructor from its own constructor to override |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
56 |
* the default $args. |
19 | 57 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
58 |
* @access public |
12 | 59 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
60 |
* @param array|string $args |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
61 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
62 |
public function __construct( $args = array() ) { |
16 | 63 |
global $wp_version; |
64 |
||
19 | 65 |
$args = wp_parse_args( |
66 |
$args, |
|
67 |
array( |
|
68 |
'plugin_basename' => '', |
|
69 |
'prefix' => '', |
|
70 |
'plugins_info' => array(), |
|
71 |
'default_options' => array(), |
|
72 |
'options' => array(), |
|
73 |
'is_network_options' => false, |
|
74 |
'tabs' => array(), |
|
75 |
'doc_link' => '', |
|
76 |
'doc_video_link' => '', |
|
77 |
'wp_slug' => '', |
|
78 |
'demo_data' => false, |
|
79 |
/* if this is free version and pro exist */ |
|
80 |
'link_key' => '', |
|
81 |
'link_pn' => '', |
|
82 |
'trial_days' => false, |
|
83 |
'licenses' => array(), |
|
84 |
) |
|
85 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
86 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
87 |
$args['plugins_info']['Name'] = str_replace( ' by BestWebSoft', '', $args['plugins_info']['Name'] ); |
12 | 88 |
|
19 | 89 |
$this->plugin_basename = $args['plugin_basename']; |
90 |
$this->prefix = $args['prefix']; |
|
91 |
$this->plugins_info = $args['plugins_info']; |
|
92 |
$this->options = $args['options']; |
|
93 |
$this->default_options = $args['default_options']; |
|
94 |
$this->wp_slug = $args['wp_slug']; |
|
95 |
$this->demo_data = $args['demo_data']; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
96 |
|
19 | 97 |
$this->tabs = $args['tabs']; |
98 |
$this->is_network_options = $args['is_network_options']; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
99 |
|
19 | 100 |
$this->doc_link = $args['doc_link']; |
101 |
$this->doc_video_link = $args['doc_video_link']; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
102 |
|
19 | 103 |
$this->link_key = $args['link_key']; |
104 |
$this->link_pn = $args['link_pn']; |
|
105 |
$this->trial_days = $args['trial_days']; |
|
106 |
$this->licenses = $args['licenses']; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
107 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
108 |
$this->pro_page = ''; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
109 |
$this->bws_license_plugin = ''; |
16 | 110 |
/* get $bws_plugins */ |
19 | 111 |
require dirname( __FILE__ ) . '/product_list.php'; |
16 | 112 |
if ( isset( $bws_plugins[ $this->plugin_basename ] ) ) { |
113 |
if ( isset( $bws_plugins[ $this->plugin_basename ]['pro_settings'] ) ) { |
|
19 | 114 |
$this->pro_page = $bws_plugins[ $this->plugin_basename ]['pro_settings']; |
115 |
$this->bws_license_plugin = $bws_plugins[ $this->plugin_basename ]['pro_version']; |
|
116 |
} |
|
16 | 117 |
|
19 | 118 |
$this->bws_plugin_link = substr( $bws_plugins[ $this->plugin_basename ]['link'], 0, strpos( $bws_plugins[ $this->plugin_basename ]['link'], '?' ) ); |
16 | 119 |
|
19 | 120 |
if ( ! empty( $this->link_key ) && ! empty( $this->link_pn ) ) { |
121 |
$this->bws_plugin_link .= '?k=' . $this->link_key . '&pn=' . $this->link_pn . '&v=' . $this->plugins_info['Version'] . '&wp_v=' . $wp_version; |
|
122 |
} |
|
16 | 123 |
} |
124 |
||
125 |
$this->hide_pro_tabs = bws_hide_premium_options_check( $this->options ); |
|
19 | 126 |
$this->version = '1.0.0'; |
127 |
$this->is_multisite = is_multisite(); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
128 |
|
12 | 129 |
if ( empty( $this->pro_page ) && array_key_exists( 'license', $this->tabs ) ) { |
19 | 130 |
$this->is_pro = true; |
12 | 131 |
$this->licenses[ $this->plugins_info['TextDomain'] ] = array( |
132 |
'name' => $this->plugins_info['Name'], |
|
133 |
'slug' => $this->plugins_info['TextDomain'], |
|
19 | 134 |
'basename' => $this->plugin_basename, |
12 | 135 |
); |
136 |
} else { |
|
137 |
$this->licenses[ $this->plugins_info['TextDomain'] ] = array( |
|
19 | 138 |
'name' => $this->plugins_info['Name'], |
139 |
'slug' => $this->plugins_info['TextDomain'], |
|
140 |
'pro_slug' => substr( $this->bws_license_plugin, 0, stripos( $this->bws_license_plugin, '/' ) ), |
|
141 |
'basename' => $this->plugin_basename, |
|
142 |
'pro_basename' => $this->bws_license_plugin, |
|
12 | 143 |
); |
144 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
145 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
146 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
147 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
148 |
* Displays the content of the "Settings" on the plugin settings page |
19 | 149 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
150 |
* @access public |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
151 |
* @param void |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
152 |
* @return void |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
153 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
154 |
public function display_content() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
155 |
global $bstwbsftwppdtplgns_options; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
156 |
if ( array_key_exists( 'custom_code', $this->tabs ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
157 |
/* get args for `custom code` tab */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
158 |
$this->get_custom_code(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
159 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
160 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
161 |
$save_results = $this->save_all_tabs_options(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
162 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
163 |
$this->display_messages( $save_results ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
164 |
if ( isset( $_REQUEST['bws_restore_default'] ) && check_admin_referer( $this->plugin_basename, 'bws_nonce_name' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
165 |
bws_form_restore_default_confirm( $this->plugin_basename ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
166 |
} elseif ( isset( $_POST['bws_handle_demo'] ) && check_admin_referer( $this->plugin_basename, 'bws_nonce_name' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
167 |
$this->demo_data->bws_demo_confirm(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
168 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
169 |
bws_show_settings_notice(); ?> |
19 | 170 |
<form class="bws_form" method="post" action="" enctype="multipart/form-data"> |
171 |
<div id="poststuff"> |
|
172 |
<div id="post-body" class="metabox-holder columns-2"> |
|
173 |
<div id="post-body-content" style="position: relative;"> |
|
12 | 174 |
<?php $this->display_tabs(); ?> |
19 | 175 |
</div><!-- #post-body-content --> |
176 |
<div id="postbox-container-1" class="postbox-container"> |
|
177 |
<div class="meta-box-sortables ui-sortable"> |
|
178 |
<div id="submitdiv" class="postbox"> |
|
179 |
<h3 class="hndle"><?php esc_html_e( 'Information', 'bestwebsoft' ); ?></h3> |
|
180 |
<div class="inside"> |
|
181 |
<div class="submitbox" id="submitpost"> |
|
182 |
<div id="minor-publishing"> |
|
183 |
<div id="misc-publishing-actions"> |
|
184 |
<?php |
|
185 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
186 |
* Action - Display additional content for #misc-publishing-actions |
19 | 187 |
*/ |
188 |
do_action( __CLASS__ . '_information_postbox_top' ); |
|
189 |
?> |
|
190 |
<?php |
|
191 |
if ( $this->is_pro ) { |
|
16 | 192 |
if ( isset( $bstwbsftwppdtplgns_options['wrong_license_key'][ $this->plugin_basename ] ) || empty( $bstwbsftwppdtplgns_options['time_out'] ) || ! array_key_exists( $this->plugin_basename, $bstwbsftwppdtplgns_options['time_out'] ) ) { |
19 | 193 |
$license_type = 'Pro'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
194 |
$license_status = __( 'Inactive', 'bestwebsoft' ) . ' <a href="#' . $this->prefix . '_license_tab" class="bws_trigger_tab_click">' . __( 'Learn More', 'bestwebsoft' ) . '</a>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
195 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
196 |
$finish = strtotime( $bstwbsftwppdtplgns_options['time_out'][ $this->plugin_basename ] ); |
19 | 197 |
$today = strtotime( gmdate( 'm/d/Y' ) ); |
12 | 198 |
if ( isset( $bstwbsftwppdtplgns_options['trial'][ $this->plugin_basename ] ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
199 |
$license_type = 'Trial Pro'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
200 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
201 |
if ( $finish < $today ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
202 |
$license_status = __( 'Expired', 'bestwebsoft' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
203 |
} else { |
19 | 204 |
$daysleft = floor( ( $finish - $today ) / ( 60 * 60 * 24 ) ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
205 |
$license_status = sprintf( __( '%s day(-s) left', 'bestwebsoft' ), $daysleft ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
206 |
} |
12 | 207 |
$license_status .= '. <a target="_blank" href="' . esc_url( $this->plugins_info['PluginURI'] ) . '">' . __( 'Upgrade to Pro', 'bestwebsoft' ) . '</a>'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
208 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
209 |
$license_type = isset( $bstwbsftwppdtplgns_options['nonprofit'][ $this->plugin_basename ] ) ? 'Nonprofit Pro' : 'Pro'; |
16 | 210 |
if ( ! empty( $bstwbsftwppdtplgns_options['time_out'][ $this->plugin_basename ] ) && $finish < $today ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
211 |
$license_status = sprintf( __( 'Expired on %s', 'bestwebsoft' ), $bstwbsftwppdtplgns_options['time_out'][ $this->plugin_basename ] ) . '. <a target="_blank" href="https://support.bestwebsoft.com/entries/53487136">' . __( 'Renew Now', 'bestwebsoft' ) . '</a>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
212 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
213 |
$license_status = __( 'Active', 'bestwebsoft' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
214 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
215 |
} |
19 | 216 |
} |
217 |
?> |
|
218 |
<div class="misc-pub-section"> |
|
219 |
<strong><?php esc_html_e( 'License', 'bestwebsoft' ); ?>:</strong> <?php echo esc_attr( $license_type ); ?> |
|
220 |
</div> |
|
221 |
<div class="misc-pub-section"> |
|
222 |
<strong><?php esc_html_e( 'Status', 'bestwebsoft' ); ?>:</strong> <?php echo wp_kses_post( $license_status ); ?> |
|
223 |
</div><!-- .misc-pub-section --> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
224 |
<?php } ?> |
19 | 225 |
<div class="misc-pub-section"> |
226 |
<strong><?php esc_html_e( 'Version', 'bestwebsoft' ); ?>:</strong> <?php echo esc_attr( $this->plugins_info['Version'] ); ?> |
|
227 |
</div><!-- .misc-pub-section --> |
|
228 |
<?php |
|
229 |
/** |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
230 |
* Action - Display additional content for #misc-publishing-actions |
19 | 231 |
*/ |
232 |
do_action( __CLASS__ . '_information_postbox_bottom' ); |
|
233 |
?> |
|
234 |
</div> |
|
235 |
<div class="clear"></div> |
|
236 |
</div> |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
237 |
<div id="major-publishing-actions"> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
238 |
<div id="publishing-action"> |
19 | 239 |
<input type="hidden" name="<?php echo esc_attr( $this->prefix ); ?>_form_submit" value="submit" /> |
240 |
<input id="bws-submit-button" type="submit" class="button button-primary button-large" value="<?php esc_html_e( 'Save Changes', 'bestwebsoft' ); ?>" /> |
|
12 | 241 |
<?php wp_nonce_field( $this->plugin_basename, 'bws_nonce_name' ); ?> |
19 | 242 |
</div> |
243 |
<div class="clear"></div> |
|
244 |
</div> |
|
245 |
</div> |
|
246 |
</div> |
|
247 |
</div> |
|
248 |
<?php |
|
249 |
/** |
|
250 |
* Action - Display custom metabox |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
251 |
*/ |
19 | 252 |
do_action( __CLASS__ . '_display_metabox' ); |
253 |
||
254 |
if ( function_exists( 'bws_affiliate_postbox' ) ) { |
|
255 |
bws_affiliate_postbox(); |
|
256 |
} |
|
257 |
?> |
|
258 |
</div> |
|
259 |
</div> |
|
260 |
<div id="postbox-container-2" class="postbox-container"> |
|
261 |
<?php |
|
262 |
/** |
|
263 |
* Action - Display additional content for #postbox-container-2 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
264 |
*/ |
19 | 265 |
do_action( __CLASS__ . '_display_second_postbox' ); |
266 |
?> |
|
267 |
<div class="submit"> |
|
268 |
<input type="submit" class="button button-primary button-large" value="<?php esc_html_e( 'Save Changes', 'bestwebsoft' ); ?>" /> |
|
269 |
<?php wp_nonce_field( $this->plugin_basename, 'bws_nonce_name' ); ?> |
|
270 |
</div> |
|
271 |
<?php |
|
272 |
if ( ! empty( $this->wp_slug ) ) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
273 |
bws_plugin_reviews_block( $this->plugins_info['Name'], $this->wp_slug ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
274 |
} |
19 | 275 |
?> |
276 |
</div> |
|
277 |
</div> |
|
278 |
</form> |
|
279 |
</div> |
|
280 |
<?php |
|
281 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
282 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
283 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
284 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
285 |
* Displays the Tabs |
19 | 286 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
287 |
* @access public |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
288 |
* @param void |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
289 |
* @return void |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
290 |
*/ |
19 | 291 |
public function display_tabs() { |
292 |
?> |
|
293 |
<div id="bws_settings_tabs_wrapper"> |
|
294 |
<ul id="bws_settings_tabs"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
295 |
<?php $this->display_tabs_list(); ?> |
19 | 296 |
</ul> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
297 |
<?php $this->display_tabs_content(); ?> |
19 | 298 |
<div class="clear"></div> |
299 |
<input type="hidden" name="bws_active_tab" value="<?php |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
300 |
if ( isset( $_REQUEST['bws_active_tab'] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
301 |
echo esc_attr( sanitize_text_field( wp_unslash( $_REQUEST['bws_active_tab'] ) ) ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
302 |
} |
19 | 303 |
?>" /> |
304 |
</div> |
|
305 |
<?php |
|
306 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
307 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
308 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
309 |
* Displays the list of tabs |
19 | 310 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
311 |
* @access private |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
312 |
* @return void |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
313 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
314 |
private function display_tabs_list() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
315 |
foreach ( $this->tabs as $tab_slug => $data ) { |
19 | 316 |
if ( ! empty( $data['is_pro'] ) && $this->hide_pro_tabs ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
317 |
continue; |
19 | 318 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
319 |
$tab_class = 'bws-tab-' . $tab_slug; |
19 | 320 |
if ( ! empty( $data['is_pro'] ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
321 |
$tab_class .= ' bws_pro_tab'; |
19 | 322 |
} |
323 |
if ( ! empty( $data['class'] ) ) { |
|
324 |
$tab_class .= ' ' . $data['class']; |
|
325 |
} |
|
326 |
?> |
|
327 |
<li class="<?php echo esc_attr( $tab_class ); ?>" data-slug="<?php echo esc_attr( $tab_slug ); ?>"> |
|
328 |
<a href="#<?php echo esc_attr( $this->prefix ); ?>_<?php echo esc_attr( $tab_slug ); ?>_tab"> |
|
329 |
<span><?php echo esc_html( $data['label'] ); ?></span> |
|
330 |
</a> |
|
331 |
</li> |
|
332 |
<?php |
|
333 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
334 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
335 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
336 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
337 |
* Displays the content of tabs |
19 | 338 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
339 |
* @access private |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
340 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
341 |
public function display_tabs_content() { |
12 | 342 |
foreach ( $this->tabs as $tab_slug => $data ) { |
19 | 343 |
if ( ! empty( $data['is_pro'] ) && $this->hide_pro_tabs ) { |
344 |
continue; |
|
345 |
} |
|
346 |
?> |
|
347 |
<div class="bws_tab ui-tabs-panel ui-widget-content ui-corner-bottom" id="<?php echo esc_attr( $this->prefix . '_' . $tab_slug . '_tab' ); ?>" aria-labelledby="ui-id-2" role="tabpanel" aria-hidden="false" style="display: block;"> |
|
348 |
<?php |
|
349 |
$tab_slug = str_replace( '-', '_', $tab_slug ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
350 |
if ( method_exists( $this, 'tab_' . $tab_slug ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
351 |
call_user_func( array( $this, 'tab_' . $tab_slug ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
352 |
do_action_ref_array( __CLASS__ . '_after_tab_' . $tab_slug, array( &$this ) ); |
19 | 353 |
} |
354 |
?> |
|
355 |
</div> |
|
356 |
<?php |
|
357 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
358 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
359 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
360 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
361 |
* Save all options from all tabs and display errors\messages |
19 | 362 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
363 |
* @access public |
19 | 364 |
* @return array |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
365 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
366 |
public function save_all_tabs_options() { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
367 |
$message = ''; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
368 |
$notice = ''; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
369 |
$error = ''; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
370 |
/* Restore default settings */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
371 |
if ( isset( $_POST['bws_restore_confirm'] ) && check_admin_referer( $this->plugin_basename, 'bws_settings_nonce_name' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
372 |
$this->restore_options(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
373 |
$message = __( 'All plugin settings were restored.', 'bestwebsoft' ); |
12 | 374 |
/* Go Pro - check license key */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
375 |
} elseif ( isset( $_POST['bws_license_submit'] ) && check_admin_referer( $this->plugin_basename, 'bws_nonce_name' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
376 |
$result = $this->save_options_license_key(); |
19 | 377 |
if ( ! empty( $result['empty_field_error'] ) ) { |
12 | 378 |
$error = $result['empty_field_error']; |
19 | 379 |
} |
380 |
if ( ! empty( $result['error'] ) ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
381 |
$error = $result['error']; |
19 | 382 |
} |
383 |
if ( ! empty( $result['message'] ) ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
384 |
$message = $result['message']; |
19 | 385 |
} |
386 |
if ( ! empty( $result['notice'] ) ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
387 |
$notice = $result['notice']; |
19 | 388 |
} |
12 | 389 |
/* check demo data */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
390 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
391 |
$demo_result = ! empty( $this->demo_data ) ? $this->demo_data->bws_handle_demo_data() : false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
392 |
if ( false !== $demo_result ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
393 |
if ( ! empty( $demo_result ) && is_array( $demo_result ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
394 |
$error = $demo_result['error']; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
395 |
$message = $demo_result['done']; |
19 | 396 |
if ( ! empty( $demo_result['done'] ) && ! empty( $demo_result['options'] ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
397 |
$this->options = $demo_result['options']; |
19 | 398 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
399 |
} |
12 | 400 |
/* Save options */ |
19 | 401 |
} elseif ( ! isset( $_REQUEST['bws_restore_default'] ) && ! isset( $_POST['bws_handle_demo'] ) && isset( $_REQUEST[ $this->prefix . '_form_submit' ] ) && check_admin_referer( $this->plugin_basename, 'bws_nonce_name' ) ) { |
12 | 402 |
/* save tabs */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
403 |
$result = $this->save_options(); |
19 | 404 |
if ( ! empty( $result['error'] ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
405 |
$error = $result['error']; |
19 | 406 |
} |
407 |
if ( ! empty( $result['message'] ) ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
408 |
$message = $result['message']; |
19 | 409 |
} |
410 |
if ( ! empty( $result['notice'] ) ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
411 |
$notice = $result['notice']; |
19 | 412 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
413 |
|
19 | 414 |
if ( '' === $this->change_permission_attr ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
415 |
/* save `misc` tab */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
416 |
$result = $this->save_options_misc(); |
19 | 417 |
if ( ! empty( $result['notice'] ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
418 |
$notice .= $result['notice']; |
19 | 419 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
420 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
421 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
422 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
423 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
424 |
return compact( 'message', 'notice', 'error' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
425 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
426 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
427 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
428 |
* Display error\message\notice |
19 | 429 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
430 |
* @access public |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
431 |
* @param $save_results - array with error\message\notice |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
432 |
* @return void |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
433 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
434 |
public function display_messages( $save_results ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
435 |
/** |
19 | 436 |
* Action - Display custom error\message\notice |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
437 |
*/ |
19 | 438 |
do_action( __CLASS__ . '_display_custom_messages', $save_results ); |
439 |
?> |
|
440 |
<div class="updated fade inline" |
|
441 |
<?php |
|
442 |
if ( empty( $save_results['message'] ) ) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
443 |
echo 'style="display:none"'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
444 |
} |
19 | 445 |
?> |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
446 |
><p><strong><?php echo ! empty( $save_results['message'] ) ? wp_kses_post( $save_results['message'] ) : ''; ?></strong></p></div> |
19 | 447 |
<div class="updated bws-notice inline" |
448 |
<?php |
|
449 |
if ( empty( $save_results['notice'] ) ) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
450 |
echo 'style="display:none"'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
451 |
} |
19 | 452 |
?> |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
453 |
><p><strong><?php echo ! empty( $save_results['notice'] ) ? wp_kses_post( $save_results['notice'] ) : ''; ?></strong></p></div> |
19 | 454 |
<div class="error inline" |
455 |
<?php |
|
456 |
if ( empty( $save_results['error'] ) ) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
457 |
echo 'style="display:none"'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
458 |
} |
19 | 459 |
?> |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
460 |
><p><strong><?php echo ! empty( $save_results['error'] ) ? wp_kses_post( $save_results['error'] ) : ''; ?></strong></p></div> |
19 | 461 |
<?php |
462 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
463 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
464 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
465 |
* Save plugin options to the database |
19 | 466 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
467 |
* @access public |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
468 |
* @param ab |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
469 |
* @abstract |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
470 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
471 |
public function save_options() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
472 |
die( 'function Bws_Settings_Tabs::save_options() must be over-ridden in a sub-class.' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
473 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
474 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
475 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
476 |
* Get 'custom_code' status and content |
19 | 477 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
478 |
* @access private |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
479 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
480 |
private function get_custom_code() { |
19 | 481 |
global $bstwbsftwppdtplgns_options, $wp_filesystem; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
482 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
483 |
$this->custom_code_args = array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
484 |
'is_css_active' => false, |
19 | 485 |
'content_css' => '', |
486 |
'css_writeable' => false, |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
487 |
'is_php_active' => false, |
19 | 488 |
'content_php' => '', |
489 |
'php_writeable' => false, |
|
490 |
'is_js_active' => false, |
|
491 |
'content_js' => '', |
|
492 |
'js_writeable' => false, |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
493 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
494 |
|
19 | 495 |
if ( ! $this->upload_dir ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
496 |
$this->upload_dir = wp_upload_dir(); |
19 | 497 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
498 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
499 |
$folder = $this->upload_dir['basedir'] . '/bws-custom-code'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
500 |
|
19 | 501 |
if ( $this->is_multisite ) { |
502 |
$this->custom_code_args['blog_id'] = get_current_blog_id(); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
503 |
} |
12 | 504 |
|
19 | 505 |
WP_Filesystem(); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
506 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
507 |
foreach ( array( 'css', 'php', 'js' ) as $extension ) { |
19 | 508 |
$file = 'bws-custom-code.' . $extension; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
509 |
$real_file = $folder . '/' . $file; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
510 |
|
19 | 511 |
if ( $wp_filesystem->exists( $real_file ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
512 |
update_recently_edited( $real_file ); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
513 |
$this->custom_code_args[ "content_{$extension}" ] = $wp_filesystem->get_contents( $real_file ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
514 |
if ( ( $this->is_multisite && isset( $bstwbsftwppdtplgns_options['custom_code'][ $this->custom_code_args['blog_id'] ][ $file ] ) ) || |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
515 |
( ! $this->is_multisite && isset( $bstwbsftwppdtplgns_options['custom_code'][ $file ] ) ) ) { |
19 | 516 |
$this->custom_code_args[ "is_{$extension}_active" ] = true; |
517 |
} |
|
518 |
if ( is_writeable( $real_file ) ) { |
|
519 |
$this->custom_code_args[ "{$extension}_writeable" ] = true; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
520 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
521 |
} else { |
19 | 522 |
$this->custom_code_args[ "{$extension}_writeable" ] = true; |
523 |
if ( 'php' === $extension ) { |
|
524 |
$this->custom_code_args[ "content_{$extension}" ] = '<?php' . "\n" . "if ( ! defined( 'ABSPATH' ) ) exit;" . "\n" . "if ( ! defined( 'BWS_GLOBAL' ) ) exit;" . "\n\n" . '/* Start your code here */' . "\n"; |
|
525 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
526 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
527 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
528 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
529 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
530 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
531 |
* Display 'custom_code' tab |
19 | 532 |
* |
533 |
* @access private |
|
534 |
*/ |
|
535 |
private function tab_custom_code() { |
|
536 |
global $bstwbsftwppdtplgns_options, $wp_version; |
|
537 |
?> |
|
538 |
<h3 class="bws_tab_label"><?php esc_html_e( 'Custom Code', 'bestwebsoft' ); ?></h3> |
|
539 |
<?php |
|
540 |
$this->help_phrase(); |
|
541 |
$bws_hide_premium = bws_hide_premium_options_check( $bstwbsftwppdtplgns_options ); |
|
542 |
?> |
|
543 |
<hr> |
|
544 |
<h4><?php esc_html_e( 'The ability to add custom code is available in the Pro version. If the Pro version is not available please contact us via Help Center', 'bestwebsoft' ); ?> (<a href="<?php echo esc_url( 'https://support.bestwebsoft.com/hc/en-us/requests/new' ); ?>"><?php echo esc_url( 'https://support.bestwebsoft.com/hc/en-us/requests/new' ); ?></a>)</h4> |
|
545 |
<?php |
|
546 |
if ( ! $bws_hide_premium ) { |
|
547 |
?> |
|
548 |
<div class="bws_pro_version_bloc pdfprnt-pro-feature"> |
|
549 |
<div class="bws_pro_version_table_bloc"> |
|
550 |
<button type="submit" name="bws_hide_premium_options" class="notice-dismiss bws_hide_premium_options" title="Close"></button> |
|
551 |
<div class="bws_table_bg"></div> |
|
552 |
<div class="bws_pro_version"> |
|
553 |
<?php |
|
554 |
if ( ! current_user_can( 'edit_plugins' ) ) { |
|
555 |
echo '<p>' . esc_html__( 'You do not have sufficient permissions to edit plugins for this site.', 'bestwebsoft' ) . '</p>'; |
|
556 |
return; |
|
557 |
} |
|
558 |
||
559 |
$list = array( |
|
560 |
'css' => array( |
|
561 |
'description' => __( 'These styles will be added to the header on all pages of your site.', 'bestwebsoft' ), |
|
562 |
'learn_more_link' => 'https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Getting_started', |
|
563 |
), |
|
564 |
'php' => array( |
|
565 |
'description' => sprintf( __( 'This PHP code will be hooked to the %s Action and will be printed on front end only.', 'bestwebsoft' ), '<a href="https://codex.wordpress.org/Plugin_API/Action_Reference/init" target="_blank"><code>init</code></a>' ), |
|
566 |
'learn_more_link' => 'https://php.net/', |
|
567 |
), |
|
568 |
'js' => array( |
|
569 |
'description' => __( 'These code will be added to the header on all pages of your site.', 'bestwebsoft' ), |
|
570 |
'learn_more_link' => 'https://developer.mozilla.org/en-US/docs/Web/JavaScript', |
|
571 |
), |
|
572 |
); |
|
573 |
||
574 |
foreach ( $list as $extension => $extension_data ) { |
|
575 |
$name = 'js' === $extension ? 'JavaScript' : strtoupper( $extension ); |
|
576 |
?> |
|
577 |
<p><big> |
|
578 |
<strong><?php echo esc_html( $name ); ?></strong> |
|
579 |
<?php |
|
580 |
if ( ! $this->custom_code_args[ "{$extension}_writeable" ] ) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
581 |
echo '(' . esc_html__( 'Browsing', 'bestwebsoft' ) . ')'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
582 |
} |
19 | 583 |
?> |
584 |
</big> |
|
585 |
</p> |
|
586 |
<p class="bws_info"> |
|
587 |
<label> |
|
588 |
<input type="checkbox" value="1" |
|
589 |
<?php |
|
590 |
if ( $this->custom_code_args[ "is_{$extension}_active" ] ) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
591 |
echo 'checked'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
592 |
} |
19 | 593 |
?> |
594 |
/> |
|
595 |
<?php printf( esc_html__( 'Activate custom %s code.', 'bestwebsoft' ), esc_html( $name ) ); ?> |
|
596 |
</label> |
|
597 |
</p> |
|
598 |
<textarea cols="70" rows="25" id="bws_newcontent_<?php echo esc_attr( $extension ); ?>" disabled="disabled"><?php |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
599 |
if ( isset( $this->custom_code_args[ "content_{$extension}" ] ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
600 |
echo esc_html( stripslashes_deep( $this->custom_code_args[ "content_{$extension}" ] ) ); } |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
601 |
?></textarea> |
19 | 602 |
<p class="bws_info"> |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
603 |
<?php echo wp_kses_post( $extension_data['description'] ); ?> |
19 | 604 |
<br> |
605 |
<a href="<?php echo esc_url( $extension_data['learn_more_link'] ); ?>" target="_blank"> |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
606 |
<?php printf( esc_html__( 'Learn more about %s', 'bestwebsoft' ), esc_html( $name ) ); ?> |
19 | 607 |
</a> |
608 |
</p> |
|
609 |
<?php |
|
610 |
} |
|
611 |
?> |
|
612 |
</div> |
|
613 |
</div> |
|
614 |
<div class="bws_pro_version_tooltip"> |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
615 |
<a class="bws_button" href="<?php echo esc_url( $this->plugins_info['PluginURI'] ); ?>?k=<?php echo esc_attr( $this->link_key ); ?>&pn=<?php echo esc_attr( $this->link_pn ); ?>&v=<?php echo esc_attr( $this->plugins_info['Version'] ); ?>&wp_v=<?php echo esc_attr( $wp_version ); ?>" target="_blank" title="<?php echo esc_html( $this->plugins_info['Name'] ); ?>">Upgrade to Pro</a> |
19 | 616 |
<div class="clear"></div> |
617 |
</div> |
|
618 |
</div> |
|
619 |
<?php |
|
620 |
} else { |
|
621 |
?> |
|
622 |
<div class="bws_pro_version_tooltip"> |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
623 |
<a class="bws_button" href="<?php echo esc_url( $this->plugins_info['PluginURI'] ); ?>?k=<?php echo esc_attr( $this->link_key ); ?>&pn=<?php echo esc_attr( $this->link_pn ); ?>&v=<?php echo esc_attr( $this->plugins_info['Version'] ); ?>&wp_v=<?php echo esc_attr( $wp_version ); ?>" target="_blank" title="<?php echo esc_html( $this->plugins_info['Name'] ); ?>">Upgrade to Pro</a> |
19 | 624 |
<div class="clear"></div> |
625 |
</div> |
|
626 |
<?php |
|
627 |
} |
|
628 |
} |
|
629 |
||
630 |
/** |
|
631 |
* Display 'misc' tab |
|
632 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
633 |
* @access private |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
634 |
*/ |
19 | 635 |
private function tab_misc() { |
636 |
global $bstwbsftwppdtplgns_options; |
|
637 |
?> |
|
638 |
<h3 class="bws_tab_label"><?php esc_html_e( 'Miscellaneous Settings', 'bestwebsoft' ); ?></h3> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
639 |
<?php $this->help_phrase(); ?> |
19 | 640 |
<hr> |
641 |
<?php |
|
642 |
/** |
|
643 |
* Action - Display custom options on the Import / Export' tab |
|
644 |
*/ |
|
645 |
do_action( __CLASS__ . '_additional_misc_options' ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
646 |
|
19 | 647 |
if ( ! $this->forbid_view && ! empty( $this->change_permission_attr ) ) { |
648 |
?> |
|
649 |
<div class="error inline bws_visible"><p><strong><?php esc_html_e( 'Notice', 'bestwebsoft' ); ?>:</strong> <strong><?php printf( esc_html__( 'It is prohibited to change %1$s settings on this site in the %2$s network settings.', 'bestwebsoft' ), esc_html( $this->plugins_info['Name'] ), esc_html( $this->plugins_info['Name'] ) ); ?></strong></p></div> |
|
650 |
<?php |
|
651 |
} |
|
652 |
if ( $this->forbid_view ) { |
|
653 |
?> |
|
654 |
<div class="error inline bws_visible"><p><strong><?php esc_html_e( 'Notice', 'bestwebsoft' ); ?>:</strong> <strong><?php printf( esc_html__( 'It is prohibited to view %1$s settings on this site in the %2$s network settings.', 'bestwebsoft' ), esc_html( $this->plugins_info['Name'] ), esc_html( $this->plugins_info['Name'] ) ); ?></strong></p></div> |
|
655 |
<?php } else { ?> |
|
656 |
<table class="form-table"> |
|
657 |
<?php |
|
658 |
/** |
|
659 |
* Action - Display custom options on the 'misc' tab |
|
660 |
*/ |
|
661 |
do_action( __CLASS__ . '_additional_misc_options_affected' ); |
|
662 |
if ( ! empty( $this->pro_page ) && $this->bws_hide_pro_option_exist ) { |
|
663 |
?> |
|
664 |
<tr> |
|
665 |
<th scope="row"><?php esc_html_e( 'Pro Options', 'bestwebsoft' ); ?></th> |
|
666 |
<td> |
|
667 |
<label> |
|
668 |
<input <?php echo esc_attr( wp_kses_data( $this->change_permission_attr ) ); ?> name="bws_hide_premium_options_submit" type="checkbox" value="1" |
|
669 |
<?php |
|
670 |
if ( ! $this->hide_pro_tabs ) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
671 |
echo 'checked="checked "'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
672 |
} |
19 | 673 |
?> |
674 |
/> |
|
675 |
<span class="bws_info"><?php esc_html_e( 'Enable to display plugin Pro options.', 'bestwebsoft' ); ?></span> |
|
676 |
</label> |
|
677 |
</td> |
|
678 |
</tr> |
|
679 |
<?php } ?> |
|
680 |
<tr> |
|
681 |
<th scope="row"><?php esc_html_e( 'Track Usage', 'bestwebsoft' ); ?></th> |
|
682 |
<td> |
|
683 |
<label> |
|
684 |
<input <?php echo esc_attr( wp_kses_data( $this->change_permission_attr ) ); ?> name="bws_track_usage" type="checkbox" value="1" |
|
685 |
<?php |
|
686 |
if ( ! empty( $bstwbsftwppdtplgns_options['track_usage']['products'][ $this->plugin_basename ] ) ) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
687 |
echo 'checked="checked "'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
688 |
} |
19 | 689 |
?> |
690 |
/> |
|
691 |
<span class="bws_info"><?php esc_html_e( 'Enable to allow tracking plugin usage anonymously in order to make it better.', 'bestwebsoft' ); ?></span> |
|
692 |
</label> |
|
693 |
</td> |
|
694 |
</tr> |
|
695 |
<tr> |
|
696 |
<th scope="row"><?php esc_html_e( 'Default Settings', 'bestwebsoft' ); ?></th> |
|
697 |
<td> |
|
698 |
<input<?php echo esc_attr( wp_kses_data( $this->change_permission_attr ) ); ?> name="bws_restore_default" type="submit" class="button" value="<?php esc_html_e( 'Restore Settings', 'bestwebsoft' ); ?>" /> |
|
699 |
<div class="bws_info"><?php esc_html_e( 'This will restore plugin settings to defaults.', 'bestwebsoft' ); ?></div> |
|
700 |
</td> |
|
701 |
</tr> |
|
702 |
</table> |
|
703 |
<?php |
|
704 |
} |
|
705 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
706 |
|
19 | 707 |
/** |
708 |
* Display 'Import / Export' tab |
|
709 |
* |
|
710 |
* @access private |
|
711 |
*/ |
|
712 |
public function tab_import_export() { |
|
713 |
?> |
|
714 |
<h3 class="bws_tab_label"><?php esc_html_e( 'Import / Export', 'bestwebsoft' ); ?></h3> |
|
715 |
<?php $this->help_phrase(); ?> |
|
716 |
<hr> |
|
717 |
<?php |
|
718 |
/** |
|
719 |
* Action - Display custom options on the Import / Export' tab |
|
720 |
*/ |
|
721 |
do_action( __CLASS__ . '_additional_import_export_options' ); |
|
722 |
||
723 |
if ( ! $this->forbid_view && ! empty( $this->change_permission_attr ) ) { |
|
724 |
?> |
|
725 |
<div class="error inline bws_visible"><p><strong><?php esc_html_e( 'Notice', 'bestwebsoft' ); ?>:</strong> <strong><?php printf( esc_html__( 'It is prohibited to change %1$s settings on this site in the %2$s network settings.', 'bestwebsoft' ), esc_html( $this->plugins_info['Name'] ), esc_html( $this->plugins_info['Name'] ) ); ?></strong></p></div> |
|
726 |
<?php |
|
727 |
} |
|
728 |
if ( $this->forbid_view ) { |
|
729 |
?> |
|
730 |
<div class="error inline bws_visible"><p><strong><?php esc_html_e( 'Notice', 'bestwebsoft' ); ?>:</strong> <strong><?php printf( esc_html__( 'It is prohibited to view %1$s settings on this site in the %2$s network settings.', 'bestwebsoft' ), esc_html( $this->plugins_info['Name'] ), esc_html( $this->plugins_info['Name'] ) ); ?></strong></p></div> |
|
731 |
<?php } else { ?> |
|
732 |
<table class="form-table"> |
|
733 |
<?php |
|
734 |
/** |
|
735 |
* Action - Display custom options on the Import / Export' tab |
|
736 |
*/ |
|
737 |
do_action( __CLASS__ . '_additional_import_export_options_affected' ); |
|
738 |
?> |
|
739 |
</table> |
|
740 |
<?php |
|
741 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
742 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
743 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
744 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
745 |
* Save plugin options to the database |
19 | 746 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
747 |
* @access private |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
748 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
749 |
private function save_options_misc() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
750 |
global $bstwbsftwppdtplgns_options, $wp_version; |
16 | 751 |
$notice = ''; |
752 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
753 |
/* hide premium options */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
754 |
if ( ! empty( $this->pro_page ) ) { |
19 | 755 |
if ( isset( $_POST['bws_hide_premium_options'] ) && check_admin_referer( $this->plugin_basename, 'bws_nonce_name' ) ) { |
756 |
$hide_result = bws_hide_premium_options( $this->options ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
757 |
$this->hide_pro_tabs = true; |
19 | 758 |
$this->options = $hide_result['options']; |
759 |
if ( ! empty( $hide_result['message'] ) ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
760 |
$notice = $hide_result['message']; |
19 | 761 |
} |
762 |
if ( $this->is_network_options ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
763 |
update_site_option( $this->prefix . '_options', $this->options ); |
19 | 764 |
} else { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
765 |
update_option( $this->prefix . '_options', $this->options ); |
19 | 766 |
} |
767 |
} elseif ( isset( $_POST['bws_hide_premium_options_submit'] ) && check_admin_referer( $this->plugin_basename, 'bws_nonce_name' ) ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
768 |
if ( ! empty( $this->options['hide_premium_options'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
769 |
$key = array_search( get_current_user_id(), $this->options['hide_premium_options'] ); |
19 | 770 |
if ( false !== $key ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
771 |
unset( $this->options['hide_premium_options'][ $key ] ); |
19 | 772 |
} |
773 |
if ( $this->is_network_options ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
774 |
update_site_option( $this->prefix . '_options', $this->options ); |
19 | 775 |
} else { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
776 |
update_option( $this->prefix . '_options', $this->options ); |
19 | 777 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
778 |
} |
12 | 779 |
$this->hide_pro_tabs = false; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
780 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
781 |
if ( empty( $this->options['hide_premium_options'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
782 |
$this->options['hide_premium_options'][] = get_current_user_id(); |
19 | 783 |
if ( $this->is_network_options ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
784 |
update_site_option( $this->prefix . '_options', $this->options ); |
19 | 785 |
} else { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
786 |
update_option( $this->prefix . '_options', $this->options ); |
19 | 787 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
788 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
789 |
$this->hide_pro_tabs = true; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
790 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
791 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
792 |
/* Save 'Track Usage' option */ |
19 | 793 |
if ( isset( $_POST['bws_track_usage'] ) && check_admin_referer( $this->plugin_basename, 'bws_nonce_name' ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
794 |
if ( empty( $bstwbsftwppdtplgns_options['track_usage']['products'][ $this->plugin_basename ] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
795 |
$bstwbsftwppdtplgns_options['track_usage']['products'][ $this->plugin_basename ] = true; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
796 |
$track_usage = true; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
797 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
798 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
799 |
if ( ! empty( $bstwbsftwppdtplgns_options['track_usage']['products'][ $this->plugin_basename ] ) ) { |
19 | 800 |
unset( $bstwbsftwppdtplgns_options['track_usage']['products'][ $this->plugin_basename ] ); |
801 |
false; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
802 |
$track_usage = false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
803 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
804 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
805 |
if ( isset( $track_usage ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
806 |
$usage_id = ! empty( $bstwbsftwppdtplgns_options['track_usage']['usage_id'] ) ? $bstwbsftwppdtplgns_options['track_usage']['usage_id'] : false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
807 |
/* send data */ |
19 | 808 |
$options = array( |
809 |
'timeout' => 3, |
|
810 |
'body' => array( |
|
811 |
'url' => get_bloginfo( 'url' ), |
|
812 |
'wp_version' => $wp_version, |
|
813 |
'is_active' => $track_usage, |
|
814 |
'product' => $this->plugin_basename, |
|
815 |
'version' => $this->plugins_info['Version'], |
|
816 |
'usage_id' => $usage_id, |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
817 |
), |
19 | 818 |
'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ), |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
819 |
); |
16 | 820 |
$raw_response = wp_remote_post( 'https://bestwebsoft.com/wp-content/plugins/products-statistics/track-usage/', $options ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
821 |
|
19 | 822 |
if ( ! is_wp_error( $raw_response ) && 200 === intval( wp_remote_retrieve_response_code( $raw_response ) ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
823 |
$response = maybe_unserialize( wp_remote_retrieve_body( $raw_response ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
824 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
825 |
if ( is_array( $response ) && |
19 | 826 |
! empty( $response['usage_id'] ) && |
827 |
$response['usage_id'] !== $usage_id ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
828 |
$bstwbsftwppdtplgns_options['track_usage']['usage_id'] = $response['usage_id']; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
829 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
830 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
831 |
|
19 | 832 |
if ( $this->is_multisite ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
833 |
update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
19 | 834 |
} else { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
835 |
update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
19 | 836 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
837 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
838 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
839 |
return compact( 'notice' ); |
12 | 840 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
841 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
842 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
843 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
844 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
845 |
public function tab_license() { |
19 | 846 |
global $wp_version, $bstwbsftwppdtplgns_options; |
847 |
?> |
|
848 |
<h3 class="bws_tab_label"><?php esc_html_e( 'License Key', 'bestwebsoft' ); ?></h3> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
849 |
<?php $this->help_phrase(); ?> |
19 | 850 |
<hr> |
12 | 851 |
<?php |
16 | 852 |
foreach ( $this->licenses as $single_license ) { |
19 | 853 |
$pro_plugin_name = ( strpos( $single_license['name'], 'Pro' ) ) ? $single_license['name'] : $single_license['name'] . ' Pro'; |
854 |
if ( ! empty( $this->pro_page ) || ! empty( $single_license['pro_basename'] ) ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
855 |
|
12 | 856 |
if ( $this->pro_plugin_is_activated && ( empty( $single_license['pro_basename'] ) || isset( $this->bws_license_plugin ) ) ) { |
19 | 857 |
$url = 'https://bestwebsoft.com/wp-content/plugins/paid-products/plugins/downloads/?bws_first_download=' . $this->bws_license_plugin . '&bws_license_key=' . $bstwbsftwppdtplgns_options[ $this->bws_license_plugin ] . '&download_from=5'; |
858 |
?> |
|
16 | 859 |
<table class="form-table"> |
19 | 860 |
<tr> |
861 |
<th scope="row"><?php echo wp_kses_data( $pro_plugin_name ) . ' License'; ?></th> |
|
862 |
<td> |
|
863 |
<p> |
|
864 |
<strong><?php esc_html_e( 'Your Pro plugin is ready', 'bestwebsoft' ); ?></strong> |
|
16 | 865 |
<br> |
19 | 866 |
<?php esc_html_e( 'Your plugin has been zipped, and now is ready to download.', 'bestwebsoft' ); ?> |
16 | 867 |
</p> |
868 |
<p> |
|
19 | 869 |
<a class="button button-secondary" target="_parent" href="<?php echo esc_url( $url ); ?>"><?php esc_html_e( 'Download Now', 'bestwebsoft' ); ?></a> |
16 | 870 |
</p> |
871 |
<br> |
|
872 |
<p> |
|
19 | 873 |
<strong><?php esc_html_e( 'Need help installing the plugin?', 'bestwebsoft' ); ?></strong> |
16 | 874 |
<br> |
19 | 875 |
<a target="_blank" href="https://bestwebsoft.com/documentation/how-to-install-a-wordpress-product/how-to-install-a-wordpress-plugin/"><?php esc_html_e( 'How to install WordPress plugin from your admin Dashboard (ZIP archive)', 'bestwebsoft' ); ?></a> |
16 | 876 |
</p> |
877 |
<br> |
|
878 |
<p> |
|
19 | 879 |
<strong><?php esc_html_e( 'Get Started', 'bestwebsoft' ); ?></strong> |
16 | 880 |
<br> |
19 | 881 |
<a target="_blank" href="https://bestwebsoft.com/documentation/"><?php esc_html_e( 'Documentation', 'bestwebsoft' ); ?></a> |
16 | 882 |
<br> |
19 | 883 |
<a target="_blank" href="https://www.youtube.com/user/bestwebsoft"><?php esc_html_e( 'Video Instructions', 'bestwebsoft' ); ?></a> |
16 | 884 |
<br> |
19 | 885 |
<a target="_blank" href="https://support.bestwebsoft.com"><?php esc_html_e( 'Knowledge Base', 'bestwebsoft' ); ?></a> |
16 | 886 |
</p> |
19 | 887 |
</td> |
888 |
</tr> |
|
889 |
</table> |
|
890 |
<?php |
|
891 |
} else { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
892 |
$attr = ''; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
893 |
$license_key = ''; |
12 | 894 |
if ( isset( $bstwbsftwppdtplgns_options['go_pro'][ $this->bws_license_plugin ]['count'] ) && |
19 | 895 |
'5' < $bstwbsftwppdtplgns_options['go_pro'][ $this->bws_license_plugin ]['count'] && |
896 |
$bstwbsftwppdtplgns_options['go_pro'][ $this->bws_license_plugin ]['time'] > ( time() - ( 24 * 60 * 60 ) ) ) { |
|
12 | 897 |
$attr = 'disabled="disabled"'; |
19 | 898 |
} |
12 | 899 |
|
16 | 900 |
if ( ! empty( $single_license['pro_basename'] ) ) { |
12 | 901 |
$license_key = ! empty( $bstwbsftwppdtplgns_options[ $single_license['pro_basename'] ] ) ? $bstwbsftwppdtplgns_options[ $single_license['pro_basename'] ] : ''; |
19 | 902 |
} |
903 |
?> |
|
904 |
<table class="form-table"> |
|
905 |
<tr> |
|
906 |
<th scope="row"><?php echo esc_html( $pro_plugin_name ) . ' License'; ?></th> |
|
907 |
<td> |
|
908 |
<input <?php echo wp_kses_data( $attr ); ?> type="text" name="bws_license_key_<?php echo esc_attr( ( ! empty( $single_license['pro_slug'] ) ) ? $single_license['pro_slug'] : $single_license['slug'] ); ?>" value="<?php echo esc_attr( $license_key ); ?>" /> |
|
909 |
<input <?php echo wp_kses_data( $attr ); ?> type="hidden" name="bws_license_plugin_<?php echo esc_attr( ( ! empty( $single_license['pro_slug'] ) ) ? $single_license['pro_slug'] : $single_license['slug'] ); ?>" value="<?php echo esc_attr( ( ! empty( $single_license['pro_slug'] ) ) ? $single_license['pro_slug'] : $single_license['slug'] ); ?>" /> |
|
910 |
<input <?php echo wp_kses_data( $attr ); ?> type="submit" class="button button-secondary" name="bws_license_submit" value="<?php esc_html_e( 'Activate', 'bestwebsoft' ); ?>" /> |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
911 |
<input type="hidden" name="_wpnonce" value="<?php echo esc_attr( wp_create_nonce( 'bws_license_key_nonce' ) ); ?>" /> |
19 | 912 |
<div class="bws_info"> |
913 |
<?php printf( esc_html__( 'Enter your license key to activate %s and get premium plugin features.', 'bestwebsoft' ), '<a href="' . esc_url( $this->bws_plugin_link ) . '" target="_blank" title="' . esc_html( $pro_plugin_name ) . '">' . esc_html( $pro_plugin_name ) . '</a>' ); ?> |
|
914 |
</div> |
|
915 |
<?php if ( '' !== $attr ) { ?> |
|
916 |
<p><?php esc_html_e( 'Unfortunately, you have exceeded the number of available tries per day. Please, upload the plugin manually.', 'bestwebsoft' ); ?></p> |
|
917 |
<?php |
|
918 |
} |
|
919 |
if ( false !== $this->trial_days ) { |
|
920 |
echo '<p>' . esc_html__( 'or', 'bestwebsoft' ) . ' <a href="' . esc_url( $this->plugins_info['PluginURI'] . 'trial/?k=' . $this->link_key . '&pn=' . $this->link_pn . '&v=' . $this->plugins_info['Version'] . '&wp_v=' . $wp_version ) . '" target="_blank">' . sprintf( esc_html__( 'Start Your Free %s-Day Trial Now', 'bestwebsoft' ), esc_attr( $this->trial_days ) ) . '</a></p>'; |
|
921 |
} |
|
922 |
?> |
|
923 |
</td> |
|
924 |
</tr> |
|
925 |
</table> |
|
926 |
<?php |
|
927 |
} |
|
12 | 928 |
} else { |
929 |
global $bstwbsftwppdtplgns_options; |
|
19 | 930 |
$license_key = ( isset( $bstwbsftwppdtplgns_options[ $single_license['basename'] ] ) ) ? $bstwbsftwppdtplgns_options[ $single_license['basename'] ] : ''; |
931 |
?> |
|
932 |
<table class="form-table"> |
|
933 |
<tr> |
|
934 |
<th scope="row"><?php echo esc_html( $pro_plugin_name ) . ' License'; ?></th> |
|
935 |
<td> |
|
936 |
<input type="text" maxlength="100" name="bws_license_key_<?php echo esc_attr( $single_license['slug'] ); ?>" value="<?php echo esc_attr( $license_key ); ?>" /> |
|
937 |
<input type="submit" class="button button-secondary" name="bws_license_submit" value="<?php esc_html_e( 'Check license key', 'bestwebsoft' ); ?>" /> |
|
938 |
<div class="bws_info"> |
|
939 |
<?php esc_html_e( 'If necessary, you can check if the license key is correct or reenter it in the field below.', 'bestwebsoft' ); ?> |
|
940 |
</div> |
|
941 |
</td> |
|
942 |
</tr> |
|
943 |
</table> |
|
944 |
<?php |
|
945 |
} |
|
946 |
} |
|
947 |
?> |
|
948 |
<table class="form-table"> |
|
949 |
<tr> |
|
950 |
<th scope="row"><?php esc_html_e( 'Manage License Settings', 'bestwebsoft' ); ?></th> |
|
951 |
<td> |
|
952 |
<a class="button button-secondary" href="https://bestwebsoft.com/client-area" target="_blank"><?php esc_html_e( 'Login to Client Area', 'bestwebsoft' ); ?></a> |
|
953 |
<div class="bws_info"> |
|
954 |
<?php esc_html_e( 'Manage active licenses, download BWS products, and view your payment history using BestWebSoft Client Area.', 'bestwebsoft' ); ?> |
|
955 |
</div> |
|
956 |
</td> |
|
957 |
</tr> |
|
958 |
</table> |
|
959 |
<?php |
|
960 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
961 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
962 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
963 |
* Save plugin options to the database |
19 | 964 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
965 |
* @access private |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
966 |
* @param ab |
19 | 967 |
* @return array The Action results |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
968 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
969 |
private function save_options_license_key() { |
19 | 970 |
global $wp_version, $bstwbsftwppdtplgns_options, $wp_filesystem; |
12 | 971 |
/*$empty_field_error - added to avoid error when 1 field is empty while another field contains license key*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
972 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
973 |
$error = ''; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
974 |
$message = ''; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
975 |
$empty_field_error = ''; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
976 |
|
19 | 977 |
if ( ! isset( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ), 'bws_license_key_nonce' ) ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
978 |
die( esc_html__( 'Security check', 'bestwebsoft' ) ); |
19 | 979 |
} else { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
980 |
|
19 | 981 |
foreach ( $this->licenses as $single_license ) { |
982 |
$bws_license_key = ( isset( $_POST[ ( ! empty( $single_license['pro_slug'] ) ) ? 'bws_license_key_' . $single_license['pro_slug'] : 'bws_license_key_' . $single_license['slug'] ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ ( ! empty( $single_license['pro_slug'] ) ) ? 'bws_license_key_' . $single_license['pro_slug'] : 'bws_license_key_' . $single_license['slug'] ] ) ) : ''; |
|
983 |
if ( '' !== $bws_license_key ) { |
|
984 |
if ( strlen( $bws_license_key ) !== 18 ) { |
|
985 |
$error = __( 'Wrong license key', 'bestwebsoft' ); |
|
986 |
} else { |
|
987 |
/* CHECK license key */ |
|
988 |
if ( $this->is_pro && empty( $single_license['pro_basename'] ) ) { |
|
989 |
delete_transient( 'bws_plugins_update' ); |
|
990 |
if ( ! $this->all_plugins ) { |
|
991 |
if ( ! function_exists( 'get_plugins' ) ) { |
|
992 |
require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
993 |
} |
|
994 |
$this->all_plugins = get_plugins(); |
|
995 |
} |
|
996 |
$current = get_site_transient( 'update_plugins' ); |
|
12 | 997 |
|
19 | 998 |
if ( ! empty( $this->all_plugins ) && ! empty( $current ) && isset( $current->response ) && is_array( $current->response ) ) { |
999 |
$to_send = array(); |
|
1000 |
$to_send['plugins'][ $single_license['basename'] ] = $this->all_plugins[ $single_license['basename'] ]; |
|
1001 |
$to_send['plugins'][ $single_license['basename'] ]['bws_license_key'] = $bws_license_key; |
|
1002 |
$to_send['plugins'][ $single_license['basename'] ]['bws_illegal_client'] = true; |
|
1003 |
$options = array( |
|
12 | 1004 |
'timeout' => ( ( defined( 'DOING_CRON' ) && DOING_CRON ) ? 30 : 3 ), |
1005 |
'body' => array( 'plugins' => serialize( $to_send ) ), |
|
19 | 1006 |
'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ), |
12 | 1007 |
); |
16 | 1008 |
$raw_response = wp_remote_post( 'https://bestwebsoft.com/wp-content/plugins/paid-products/plugins/pro-license-check/1.0/', $options ); |
12 | 1009 |
|
19 | 1010 |
if ( is_wp_error( $raw_response ) || 200 !== intval( wp_remote_retrieve_response_code( $raw_response ) ) ) { |
1011 |
$error = __( 'Something went wrong. Please try again later. If the error appears again, please contact us', 'bestwebsoft' ) . ': <a href=https://support.bestwebsoft.com>BestWebSoft</a>. ' . __( 'We are sorry for inconvenience.', 'bestwebsoft' ); |
|
12 | 1012 |
} else { |
1013 |
$response = maybe_unserialize( wp_remote_retrieve_body( $raw_response ) ); |
|
1014 |
if ( is_array( $response ) && ! empty( $response ) ) { |
|
1015 |
foreach ( $response as $single_response ) { |
|
19 | 1016 |
if ( 'wrong_license_key' === $single_response->package ) { |
1017 |
$error = __( 'Wrong license key.', 'bestwebsoft' ); |
|
1018 |
} elseif ( 'wrong_domain' === $single_response->package ) { |
|
1019 |
$error = __( 'This license key is bound to another site.', 'bestwebsoft' ); |
|
1020 |
} elseif ( 'time_out' === $single_response->package ) { |
|
1021 |
$message = __( 'This license key is valid, but Your license has expired. If you want to update our plugin in future, you should extend the license.', 'bestwebsoft' ); |
|
1022 |
} elseif ( 'you_are_banned' === $single_response->package ) { |
|
1023 |
$error = __( 'Unfortunately, you have exceeded the number of available tries.', 'bestwebsoft' ); |
|
1024 |
} elseif ( 'duplicate_domen_for_trial' === $single_response->package ) { |
|
1025 |
$error = __( 'Unfortunately, the Pro Trial licence was already installed to this domain. The Pro Trial license can be installed only once.', 'bestwebsoft' ); |
|
1026 |
} |
|
1027 |
if ( empty( $error ) ) { |
|
1028 |
if ( empty( $message ) ) { |
|
1029 |
if ( isset( $single_response->trial ) ) { |
|
1030 |
$message = __( 'The Pro Trial license key is valid.', 'bestwebsoft' ); |
|
1031 |
} else { |
|
1032 |
$message = __( 'The license key is valid.', 'bestwebsoft' ); |
|
1033 |
} |
|
1034 |
||
1035 |
if ( ! empty( $single_response->time_out ) ) { |
|
1036 |
$message .= ' ' . __( 'Your license will expire on', 'bestwebsoft' ) . ' ' . $single_response->time_out . '.'; |
|
1037 |
} else { |
|
1038 |
/* lifetime */ |
|
1039 |
$single_response->time_out = null; |
|
1040 |
} |
|
1041 |
||
1042 |
if ( isset( $single_response->trial ) && $this->is_trial ) { |
|
1043 |
$message .= ' ' . sprintf( __( 'In order to continue using the plugin it is necessary to buy a %s license.', 'bestwebsoft' ), '<a href="' . esc_url( $this->plugins_info['PluginURI'] . '?k=' . $this->link_key . '&pn=' . $this->link_pn . '&v=' . $this->plugins_info['Version'] . '&wp_v=' . $wp_version ) . '" target="_blank" title="' . $this->plugins_info['Name'] . '">Pro</a>' ); |
|
1044 |
} |
|
1045 |
} |
|
1046 |
||
1047 |
if ( isset( $single_response->trial ) ) { |
|
1048 |
$bstwbsftwppdtplgns_options['trial'][ $single_license['basename'] ] = 1; |
|
1049 |
} else { |
|
1050 |
unset( $bstwbsftwppdtplgns_options['trial'][ $single_license['basename'] ] ); |
|
1051 |
} |
|
1052 |
||
1053 |
if ( isset( $single_response->nonprofit ) ) { |
|
1054 |
$bstwbsftwppdtplgns_options['nonprofit'][ $single_license['basename'] ] = 1; |
|
1055 |
} else { |
|
1056 |
unset( $bstwbsftwppdtplgns_options['nonprofit'][ $single_license['basename'] ] ); |
|
1057 |
} |
|
1058 |
||
1059 |
if ( ! isset( $bstwbsftwppdtplgns_options[ $single_license['basename'] ] ) || $bstwbsftwppdtplgns_options[ $single_license['basename'] ] !== $bws_license_key ) { |
|
1060 |
$bstwbsftwppdtplgns_options[ $single_license['basename'] ] = $bws_license_key; |
|
1061 |
||
1062 |
WP_Filesystem(); |
|
1063 |
if ( $wp_filesystem->put_contents( dirname( dirname( __FILE__ ) ) . '/license_key.txt', $bws_license_key, 0755 ) ) { |
|
1064 |
$update_option = true; |
|
1065 |
} |
|
1066 |
} |
|
1067 |
||
1068 |
if ( isset( $bstwbsftwppdtplgns_options['wrong_license_key'][ $single_license['basename'] ] ) ) { |
|
1069 |
unset( $bstwbsftwppdtplgns_options['wrong_license_key'][ $single_license['basename'] ] ); |
|
1070 |
$update_option = true; |
|
1071 |
} |
|
1072 |
||
1073 |
if ( ! isset( $bstwbsftwppdtplgns_options['time_out'][ $single_license['basename'] ] ) || $bstwbsftwppdtplgns_options['time_out'][ $single_license['basename'] ] !== $single_response->time_out ) { |
|
1074 |
$bstwbsftwppdtplgns_options['time_out'][ $single_license['basename'] ] = $single_response->time_out; |
|
1075 |
$update_option = true; |
|
1076 |
} |
|
1077 |
||
1078 |
if ( isset( $update_option ) ) { |
|
1079 |
if ( $this->is_multisite ) { |
|
1080 |
update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
|
1081 |
} else { |
|
1082 |
update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
|
1083 |
} |
|
1084 |
} |
|
12 | 1085 |
} |
1086 |
} |
|
1087 |
} else { |
|
19 | 1088 |
$error = __( 'Something went wrong. Please try again later. If the error appears again, please contact us', 'bestwebsoft' ) . ' <a href=https://support.bestwebsoft.com>BestWebSoft</a>. ' . __( 'We are sorry for inconvenience.', 'bestwebsoft' ); |
12 | 1089 |
} |
1090 |
} |
|
1091 |
} |
|
19 | 1092 |
/* Go Pro */ |
12 | 1093 |
} else { |
19 | 1094 |
$slug = ! empty( $single_license['pro_slug'] ) ? 'bws_license_plugin_' . $single_license['pro_slug'] : 'bws_license_plugin_' . $single_license['slug']; |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1095 |
|
19 | 1096 |
$bws_license_plugin = isset( $_POST[ $slug ] ) ? sanitize_text_field( wp_unslash( $_POST[ $slug ] ) ) : ''; |
1097 |
if ( isset( $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['count'] ) && $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['time'] > ( time() - ( 24 * 60 * 60 ) ) ) { |
|
1098 |
$bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['count'] = $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['count'] + 1; |
|
1099 |
} else { |
|
1100 |
$bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['count'] = 1; |
|
1101 |
$bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['time'] = time(); |
|
1102 |
} |
|
1103 |
||
1104 |
/* download Pro */ |
|
1105 |
if ( ! $this->all_plugins ) { |
|
1106 |
if ( ! function_exists( 'get_plugins' ) ) { |
|
1107 |
require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
12 | 1108 |
} |
19 | 1109 |
$this->all_plugins = get_plugins(); |
1110 |
} |
|
1111 |
||
1112 |
if ( ! array_key_exists( $bws_license_plugin, $this->all_plugins ) ) { |
|
1113 |
$current = get_site_transient( 'update_plugins' ); |
|
1114 |
if ( ! empty( $current ) && isset( $current->response ) && is_array( $current->response ) ) { |
|
1115 |
$to_send = array(); |
|
1116 |
$to_send['plugins'][ $bws_license_plugin ] = array(); |
|
1117 |
$to_send['plugins'][ $bws_license_plugin ]['bws_license_key'] = $bws_license_key; |
|
1118 |
$to_send['plugins'][ $bws_license_plugin ]['bws_illegal_client'] = true; |
|
1119 |
$options = array( |
|
1120 |
'timeout' => ( ( defined( 'DOING_CRON' ) && DOING_CRON ) ? 30 : 3 ), |
|
1121 |
'body' => array( 'plugins' => serialize( $to_send ) ), |
|
1122 |
'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ), |
|
1123 |
); |
|
1124 |
$raw_response = wp_remote_post( 'https://bestwebsoft.com/wp-content/plugins/paid-products/plugins/pro-license-check/1.0/', $options ); |
|
1125 |
||
1126 |
if ( is_wp_error( $raw_response ) || 200 !== intval( wp_remote_retrieve_response_code( $raw_response ) ) ) { |
|
1127 |
$error = __( 'Something went wrong. Please try again later. If the error appears again, please contact us', 'bestwebsoft' ) . ': <a href="https://support.bestwebsoft.com">BestWebSoft</a>. ' . __( 'We are sorry for inconvenience.', 'bestwebsoft' ); |
|
1128 |
} else { |
|
1129 |
$response = maybe_unserialize( wp_remote_retrieve_body( $raw_response ) ); |
|
1130 |
if ( is_array( $response ) && ! empty( $response ) ) { |
|
1131 |
foreach ( $response as $single_response ) { |
|
1132 |
if ( 'wrong_license_key' === $single_response->package ) { |
|
1133 |
$error = __( 'Wrong license key.', 'bestwebsoft' ); |
|
1134 |
} elseif ( 'wrong_domain' === $single_response->package ) { |
|
1135 |
$error = __( 'This license key is bound to another site.', 'bestwebsoft' ); |
|
1136 |
} elseif ( 'you_are_banned' === $single_response->package ) { |
|
1137 |
$error = __( 'Unfortunately, you have exceeded the number of available tries per day. Please, upload the plugin manually.', 'bestwebsoft' ); |
|
1138 |
} elseif ( 'time_out' === $single_response->package ) { |
|
1139 |
$error = sprintf( __( 'Unfortunately, Your license has expired. To continue getting top-priority support and plugin updates, you should extend it in your %s.', 'bestwebsoft' ), ' <a href="https://bestwebsoft.com/client-area">Client Area</a>' ); |
|
1140 |
} elseif ( 'duplicate_domen_for_trial' === $single_response->package ) { |
|
1141 |
$error = __( 'Unfortunately, the Pro licence was already installed to this domain. The Pro Trial license can be installed only once.', 'bestwebsoft' ); |
|
1142 |
} |
|
1143 |
} |
|
1144 |
if ( empty( $error ) ) { |
|
1145 |
$bws_license_plugin = ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename']; |
|
1146 |
||
1147 |
$bstwbsftwppdtplgns_options[ $bws_license_plugin ] = $bws_license_key; |
|
1148 |
$this->pro_plugin_is_activated = true; |
|
1149 |
} |
|
1150 |
} else { |
|
1151 |
$error = __( 'Something went wrong. Try again later or upload the plugin manually. We are sorry for inconvenience.', 'bestwebsoft' ); |
|
1152 |
} |
|
1153 |
} |
|
1154 |
} |
|
1155 |
} else { |
|
1156 |
$bstwbsftwppdtplgns_options[ $bws_license_plugin ] = $bws_license_key; |
|
1157 |
/* activate Pro */ |
|
1158 |
if ( ! is_plugin_active( $bws_license_plugin ) ) { |
|
1159 |
if ( $this->is_multisite && is_plugin_active_for_network( ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ) ) { |
|
1160 |
/* if multisite and free plugin is network activated */ |
|
1161 |
$network_wide = true; |
|
1162 |
} else { |
|
1163 |
/* activate on a single blog */ |
|
1164 |
$network_wide = false; |
|
1165 |
} |
|
1166 |
activate_plugin( $bws_license_plugin, null, $network_wide ); |
|
1167 |
$this->pro_plugin_is_activated = true; |
|
1168 |
} |
|
1169 |
} |
|
1170 |
/* add 'track_usage' for Pro version */ |
|
1171 |
if ( ! empty( $bstwbsftwppdtplgns_options['track_usage'][ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ] ) && |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1172 |
empty( $bstwbsftwppdtplgns_options['track_usage'][ $bws_license_plugin ] ) ) { |
19 | 1173 |
$bstwbsftwppdtplgns_options['track_usage'][ $bws_license_plugin ] = $bstwbsftwppdtplgns_options['track_usage'][ ( ! empty( $single_license['pro_basename'] ) ) ? $single_license['pro_basename'] : $single_license['basename'] ]; |
1174 |
} |
|
1175 |
||
1176 |
if ( $this->is_multisite ) { |
|
1177 |
update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
|
1178 |
} else { |
|
1179 |
update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
|
1180 |
} |
|
1181 |
||
1182 |
if ( $this->pro_plugin_is_activated ) { |
|
1183 |
delete_transient( 'bws_plugins_update' ); |
|
12 | 1184 |
} |
1185 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1186 |
} |
19 | 1187 |
} else { |
1188 |
$empty_field_error = __( 'Please, enter Your license key', 'bestwebsoft' ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1189 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1190 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1191 |
} |
12 | 1192 |
return compact( 'error', 'message', 'empty_field_error' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1193 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1194 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1195 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1196 |
* Display help phrase |
19 | 1197 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1198 |
* @access public |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1199 |
* @echo html The Action results |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1200 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1201 |
public function help_phrase() { |
19 | 1202 |
/*pls */ |
1203 |
echo '<div class="bws_tab_description">' . esc_html__( 'Need Help?', 'bestwebsoft' ) . ' '; |
|
1204 |
if ( '' !== $this->doc_link ) { |
|
1205 |
echo '<a href="' . esc_url( $this->doc_link ) . '" target="_blank">' . esc_html__( 'Read the Instruction', 'bestwebsoft' ); |
|
1206 |
} else { |
|
1207 |
echo '<a href="https://support.bestwebsoft.com/hc/en-us/" target="_blank">' . esc_html__( 'Visit Help Center', 'bestwebsoft' ); |
|
1208 |
} |
|
1209 |
if ( '' !== $this->doc_video_link ) { |
|
1210 |
echo '</a> ' . esc_html__( 'or', 'bestwebsoft' ) . ' <a href="' . esc_url( $this->doc_video_link ) . '" target="_blank">' . esc_html__( 'Watch the Video', 'bestwebsoft' ); |
|
1211 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1212 |
echo '</a></div>'; |
19 | 1213 |
/* pls*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1214 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1215 |
|
12 | 1216 |
public function bws_pro_block_links() { |
19 | 1217 |
global $wp_version; |
1218 |
?> |
|
1219 |
<div class="bws_pro_version_tooltip"> |
|
1220 |
<a class="bws_button" href="<?php echo esc_url( $this->plugins_info['PluginURI'] ); ?>?k=<?php echo esc_attr( $this->link_key ); ?>&pn=<?php echo esc_attr( $this->link_pn ); ?>&v=<?php echo esc_attr( $this->plugins_info['Version'] ); ?>&wp_v=<?php echo esc_attr( $wp_version ); ?>" target="_blank" title="<?php echo esc_html( $this->plugins_info['Name'] ); ?>"><?php esc_html_e( 'Upgrade to Pro', 'bestwebsoft' ); ?></a> |
|
1221 |
<?php if ( false !== $this->trial_days ) { ?> |
|
1222 |
<span class="bws_trial_info"> |
|
1223 |
<?php esc_html_e( 'or', 'bestwebsoft' ); ?> |
|
1224 |
<a href="<?php echo esc_url( $this->plugins_info['PluginURI'] . '?k=' . $this->link_key . '&pn=' . $this->link_pn . '&v=' . $this->plugins_info['Version'] . '&wp_v=' . $wp_version ); ?>" target="_blank" title="<?php echo esc_html( $this->plugins_info['Name'] ); ?>"><?php esc_html_e( 'Start Your Free Trial', 'bestwebsoft' ); ?></a> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1225 |
</span> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1226 |
<?php } ?> |
19 | 1227 |
<div class="clear"></div> |
1228 |
</div> |
|
1229 |
<?php |
|
1230 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1231 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1232 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1233 |
* Restore plugin options to defaults |
19 | 1234 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1235 |
* @access public |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1236 |
* @param void |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1237 |
* @return void |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1238 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1239 |
public function restore_options() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1240 |
unset( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1241 |
$this->default_options['first_install'], |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1242 |
$this->default_options['suggest_feature_banner'], |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1243 |
$this->default_options['display_settings_notice'] |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1244 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1245 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1246 |
* Filter - Change default_options array OR process custom functions |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1247 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1248 |
$this->options = apply_filters( __CLASS__ . '_additional_restore_options', $this->default_options ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1249 |
if ( $this->is_network_options ) { |
19 | 1250 |
$this->options['network_apply'] = 'default'; |
1251 |
$this->options['network_view'] = '1'; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1252 |
$this->options['network_change'] = '1'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1253 |
update_site_option( $this->prefix . '_options', $this->options ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1254 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1255 |
update_option( $this->prefix . '_options', $this->options ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1256 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1257 |
} |
19 | 1258 |
|
1259 |
public function add_request_feature() { |
|
1260 |
?> |
|
1261 |
<div id="bws_request_feature" class="widget-access-link"> |
|
1262 |
<button type="button" class="button" ><?php esc_html_e( 'Request a Feature', 'bestwebsoft' ); ?></button> |
|
1263 |
</div> |
|
1264 |
<?php |
|
1265 |
$modal_html = '<div class="bws-modal bws-modal-deactivation-feedback bws-modal-request-feature"> |
|
1266 |
<div class="bws-modal-dialog"> |
|
1267 |
<div class="bws-modal-body"> |
|
1268 |
<h2>' . sprintf( esc_html__( 'How can we improve %s?', 'bestwebsoft' ), $this->plugins_info['Name'] ) . '</h2> |
|
1269 |
<div class="bws-modal-panel active"> |
|
1270 |
<p>' . esc_html__( 'We look forward to hear your ideas.', 'bestwebsoft' ) . '</p> |
|
1271 |
<p> |
|
1272 |
<textarea placeholder="' . esc_html__( 'Describe your idea', 'bestwebsoft' ) . '..."></textarea> |
|
1273 |
</p> |
|
1274 |
<label class="bws-modal-anonymous-label"> |
|
1275 |
<input type="checkbox" /> ' . esc_html__( 'Send website data and allow to contact me back', 'bestwebsoft' ) . ' |
|
1276 |
</label> |
|
1277 |
</div> |
|
1278 |
</div> |
|
1279 |
<div class="bws-modal-footer"> |
|
1280 |
<a href="#" class="button disabled bws-modal-button button-primary">' . esc_html__( 'Submit', 'bestwebsoft' ) . '</a> |
|
1281 |
<span class="bws-modal-processing hidden">' . esc_html__( 'Processing', 'bestwebsoft' ) . '...</span> |
|
1282 |
<span class="bws-modal-thank-you hidden">' . esc_html__( 'Thank you!', 'bestwebsoft' ) . '</span> |
|
1283 |
<div class="clear"></div> |
|
1284 |
</div> |
|
1285 |
</div> |
|
1286 |
</div>'; |
|
1287 |
||
1288 |
$script = '(function($) { |
|
1289 |
var modalHtml = ' . wp_json_encode( $modal_html ) . ", |
|
1290 |
\$modal = $( modalHtml ); |
|
1291 |
|
|
1292 |
\$modal.appendTo( $( 'body' ) ); |
|
1293 |
||
1294 |
$( '#bws_request_feature .button' ).on( 'click', function() { |
|
1295 |
/* Display the dialog box.*/ |
|
1296 |
\$modal.addClass( 'active' ); |
|
1297 |
$( 'body' ).addClass( 'has-bws-modal' ); |
|
1298 |
}); |
|
1299 |
||
1300 |
\$modal.on( 'keypress', 'textarea', function( evt ) { |
|
1301 |
BwsModalEnableButton(); |
|
1302 |
}); |
|
1303 |
||
1304 |
\$modal.on( 'click', '.bws-modal-footer .button', function( evt ) { |
|
1305 |
evt.preventDefault(); |
|
1306 |
||
1307 |
if ( $( this ).hasClass( 'disabled' ) ) { |
|
1308 |
return; |
|
1309 |
} |
|
1310 |
var info = \$modal.find( 'textarea' ).val(); |
|
1311 |
||
1312 |
if ( info.length == 0 ) { |
|
1313 |
return; |
|
1314 |
} |
|
1315 |
||
1316 |
var _parent = $( this ).parents( '.bws-modal:first' ), |
|
1317 |
_this = $( this ); |
|
1318 |
||
1319 |
var is_anonymous = ( \$modal.find( '.bws-modal-anonymous-label' ).find( 'input' ).is( ':checked' ) ) ? 0 : 1; |
|
1320 |
||
1321 |
$.ajax({ |
|
1322 |
url : ajaxurl, |
|
1323 |
method : 'POST', |
|
1324 |
data : { |
|
1325 |
'Action' : 'bws_submit_request_feature_action', |
|
1326 |
'plugin' : '" . $this->plugin_basename . "', |
|
1327 |
'info' : info, |
|
1328 |
'is_anonymous' : is_anonymous, |
|
1329 |
'bws_ajax_nonce' : '" . wp_create_nonce( 'bws_ajax_nonce' ) . "' |
|
1330 |
}, |
|
1331 |
beforeSend: function() { |
|
1332 |
_parent.find( '.bws-modal-footer .bws-modal-button' ).hide(); |
|
1333 |
_parent.find( '.bws-modal-footer .bws-modal-processing' ).show(); |
|
1334 |
_parent.find( 'textarea, input' ).attr( 'disabled', 'disabled' ); |
|
1335 |
}, |
|
1336 |
complete : function( message ) { |
|
1337 |
_parent.find( '.bws-modal-footer .bws-modal-processing' ).hide(); |
|
1338 |
_parent.find( '.bws-modal-footer .bws-modal-thank-you' ).show(); |
|
1339 |
} |
|
1340 |
}); |
|
1341 |
}); |
|
1342 |
||
1343 |
/* If the user has clicked outside the window, cancel it. */ |
|
1344 |
\$modal.on( 'click', function( evt ) { |
|
1345 |
var \$target = $( evt.target ); |
|
1346 |
||
1347 |
/* If the user has clicked anywhere in the modal dialog, just return. */ |
|
1348 |
if ( \$target.hasClass( 'bws-modal-body' ) || \$target.hasClass( 'bws-modal-footer' ) ) { |
|
1349 |
return; |
|
1350 |
} |
|
1351 |
||
1352 |
/* If the user has not clicked the close button and the clicked element is inside the modal dialog, just return. */ |
|
1353 |
if ( ! \$target.hasClass( 'bws-modal-button-close' ) && ( \$target.parents( '.bws-modal-body' ).length > 0 || \$target.parents( '.bws-modal-footer' ).length > 0 ) ) { |
|
1354 |
return; |
|
1355 |
} |
|
1356 |
||
1357 |
/* Close the modal dialog */ |
|
1358 |
\$modal.removeClass( 'active' ); |
|
1359 |
$( 'body' ).removeClass( 'has-bws-modal' ); |
|
1360 |
||
1361 |
return false; |
|
1362 |
}); |
|
1363 |
||
1364 |
function BwsModalEnableButton() { |
|
1365 |
\$modal.find( '.bws-modal-button' ).removeClass( 'disabled' ).show(); |
|
1366 |
\$modal.find( '.bws-modal-processing' ).hide(); |
|
1367 |
} |
|
1368 |
||
1369 |
function BwsModalDisableButton() { |
|
1370 |
\$modal.find( '.bws-modal-button' ).addClass( 'disabled' ); |
|
1371 |
} |
|
1372 |
||
1373 |
function BwsModalShowPanel() { |
|
1374 |
\$modal.find( '.bws-modal-panel' ).addClass( 'active' ); |
|
1375 |
} |
|
1376 |
})(jQuery);"; |
|
1377 |
||
1378 |
/* add script in FOOTER */ |
|
1379 |
wp_register_script( 'bws-request-feature-dialog', '', array( 'jquery' ), '2.4.2', true ); |
|
1380 |
wp_enqueue_script( 'bws-request-feature-dialog' ); |
|
1381 |
wp_add_inline_script( 'bws-request-feature-dialog', sprintf( $script ) ); |
|
1382 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1383 |
} |
16 | 1384 |
} |
19 | 1385 |
|
1386 |
if ( ! function_exists( 'bws_submit_request_feature_action' ) ) { |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1387 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1388 |
* Called after the user has submitted his reason for deactivating the plugin. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1389 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1390 |
* @since 2.1.3 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1391 |
*/ |
19 | 1392 |
function bws_submit_request_feature_action() { |
1393 |
global $bstwbsftwppdtplgns_options, $wp_version, $bstwbsftwppdtplgns_active_plugins, $current_user; |
|
1394 |
||
1395 |
if ( isset( $_REQUEST['bws_ajax_nonce'] ) ) { |
|
1396 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1397 |
check_ajax_referer( 'bws_ajax_nonce', sanitize_text_field( wp_unslash( $_REQUEST['bws_ajax_nonce'] ) ) ); |
19 | 1398 |
|
1399 |
$basename = isset( $_REQUEST['plugin'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['plugin'] ) ) : ''; |
|
1400 |
$info = isset( $_REQUEST['info'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['info'] ) ) : ''; |
|
1401 |
||
1402 |
if ( empty( $info ) || empty( $basename ) ) { |
|
1403 |
exit; |
|
1404 |
} |
|
1405 |
||
1406 |
$info = substr( $info, 0, 255 ); |
|
1407 |
$is_anonymous = isset( $_REQUEST['is_anonymous'] ) && 1 === intval( $_REQUEST['is_anonymous'] ); |
|
1408 |
||
1409 |
$options = array( |
|
1410 |
'product' => $basename, |
|
1411 |
'info' => $info, |
|
1412 |
); |
|
1413 |
||
1414 |
if ( ! $is_anonymous ) { |
|
1415 |
if ( ! isset( $bstwbsftwppdtplgns_options ) ) { |
|
1416 |
$bstwbsftwppdtplgns_options = ( is_multisite() ) ? get_site_option( 'bstwbsftwppdtplgns_options' ) : get_option( 'bstwbsftwppdtplgns_options' ); |
|
1417 |
} |
|
1418 |
||
1419 |
if ( ! empty( $bstwbsftwppdtplgns_options['track_usage']['usage_id'] ) ) { |
|
1420 |
$options['usage_id'] = $bstwbsftwppdtplgns_options['track_usage']['usage_id']; |
|
1421 |
} else { |
|
1422 |
$options['usage_id'] = false; |
|
1423 |
$options['url'] = get_bloginfo( 'url' ); |
|
1424 |
$options['wp_version'] = $wp_version; |
|
1425 |
$options['is_active'] = false; |
|
1426 |
$options['version'] = $bstwbsftwppdtplgns_active_plugins[ $basename ]['Version']; |
|
1427 |
} |
|
1428 |
||
1429 |
$options['email'] = $current_user->data->user_email; |
|
1430 |
} |
|
1431 |
||
1432 |
/* send data */ |
|
1433 |
$raw_response = wp_remote_post( |
|
1434 |
'https://bestwebsoft.com/wp-content/plugins/products-statistics/request-feature/', |
|
1435 |
array( |
|
1436 |
'method' => 'POST', |
|
1437 |
'body' => $options, |
|
1438 |
'timeout' => 15, |
|
1439 |
) |
|
1440 |
); |
|
1441 |
||
1442 |
if ( ! is_wp_error( $raw_response ) && 200 === intval( wp_remote_retrieve_response_code( $raw_response ) ) ) { |
|
1443 |
if ( ! $is_anonymous ) { |
|
1444 |
$response = maybe_unserialize( wp_remote_retrieve_body( $raw_response ) ); |
|
1445 |
||
1446 |
if ( is_array( $response ) && ! empty( $response['usage_id'] ) && $response['usage_id'] !== $options['usage_id'] ) { |
|
1447 |
$bstwbsftwppdtplgns_options['track_usage']['usage_id'] = $response['usage_id']; |
|
1448 |
||
1449 |
if ( is_multisite() ) { |
|
1450 |
update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
|
1451 |
} else { |
|
1452 |
update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
|
1453 |
} |
|
1454 |
} |
|
1455 |
} |
|
1456 |
||
1457 |
echo 'done'; |
|
1458 |
} else { |
|
1459 |
echo wp_kses_data( $response->get_error_code() ) . ': ' . wp_kses_data( $response->get_error_message() ); |
|
1460 |
} |
|
1461 |
} |
|
1462 |
exit; |
|
1463 |
} |
|
1464 |
} |
|
1465 |
||
1466 |
add_action( 'wp_ajax_bws_submit_request_feature_action', 'bws_submit_request_feature_action' ); |