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