PluginProbe
PDF & Print by BestWebSoft – WordPress Posts and Pages PDF Generator Plugin / 2.4.2
PDF & Print by BestWebSoft – WordPress Posts and Pages PDF Generator Plugin v2.4.2
trunk 1.5 1.6 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.7.7 1.7.8 1.7.9 1.8.0 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9.0 1.9.1 All 71 releases
pdf-print / bws_menu / bws_functions.php

bws_functions.php in PDF & Print by BestWebSoft – WordPress Posts and Pages PDF Generator Plugin 2.4.2, at bws_menu/bws_functions.php

1,591 lines 61.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package BWS Menu
4 * @version 2.4.3
5 * Main functions
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit;
10 }
11
12 /**
13 * General functions for BestWebSoft plugins
14 */
15 require dirname( __FILE__ ) . '/deprecated.php';
16 require_once dirname( __FILE__ ) . '/deactivation-form.php';
17
18
19 if ( ! function_exists( 'bws_get_mofile' ) ) {
20 /**
21 * Function to add 'bestwebsoft' slug for BWS_Menu MO file if BWS_Menu loaded from theme.
22 *
23 * @since 1.9.7
24 * @param string $mofile Mo file name.
25 * @param string $domain Domain name.
26 */
27 function bws_get_mofile( $mofile, $domain ) {
28 if ( 'bestwebsoft' === $domain ) {
29 $locale = get_locale();
30 return str_replace( $locale, "bestwebsoft-{$locale}", $mofile );
31 }
32
33 return $mofile;
34 }
35 }
36
37 /**
38 * Internationalization, first(!)
39 *
40 * @since 1.9.7
41 */
42 if ( isset( $bws_menu_source ) && 'themes' === $bws_menu_source ) {
43 add_filter( 'load_textdomain_mofile', 'bws_get_mofile', 10, 2 );
44 load_theme_textdomain( 'bestwebsoft', get_stylesheet_directory() . '/inc/bws_menu/languages' );
45 remove_filter( 'load_textdomain_mofile', 'bws_get_mofile' );
46 } else {
47 load_plugin_textdomain( 'bestwebsoft', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
48 }
49
50 if ( ! function_exists( 'bws_menu_url' ) ) {
51 /**
52 * Function to getting url to current BWS_Menu.
53 *
54 * @since 1.9.7
55 * @param string $path Plugin path.
56 */
57 if ( ! isset( $bws_menu_source ) || 'plugins' === $bws_menu_source ) {
58 function bws_menu_url( $path = '' ) {
59 return plugins_url( $path, __FILE__ );
60 }
61 } else {
62 function bws_menu_url( $path = '' ) {
63 $bws_menu_current_dir = str_replace( '\\', '/', dirname( __FILE__ ) );
64 $bws_menu_abspath = str_replace( '\\', '/', ABSPATH );
65 $bws_menu_current_url = site_url( str_replace( $bws_menu_abspath, '', $bws_menu_current_dir ) );
66
67 return sprintf( '%s/%s', $bws_menu_current_url, $path );
68 }
69 }
70 }
71
72 if ( ! function_exists( 'bws_wp_min_version_check' ) ) {
73 /**
74 * Function check if plugin is compatible with current WP version
75 *
76 * @param string $plugin_basename Plugin basename.
77 * @param array $plugin_info Plugin info.
78 * @param string $require_wp Wp version.
79 * @param string $min_wp (Optional) Flag for min WP version.
80 */
81 function bws_wp_min_version_check( $plugin_basename, $plugin_info, $require_wp, $min_wp = false ) {
82 global $wp_version, $bws_versions_notice_array;
83 if ( false === $min_wp ) {
84 $min_wp = $require_wp;
85 }
86 if ( version_compare( $wp_version, $min_wp, '<' ) ) {
87 include_once ABSPATH . 'wp-admin/includes/plugin.php';
88 if ( is_plugin_active( $plugin_basename ) ) {
89 deactivate_plugins( $plugin_basename );
90 $admin_url = ( function_exists( 'get_admin_url' ) ) ? get_admin_url( null, 'plugins.php' ) : esc_url( '/wp-admin/plugins.php' );
91 wp_die(
92 sprintf(
93 "<strong>%s</strong> %s <strong>WordPress %s</strong> %s <br /><br />%s <a href='%s'>%s</a>.",
94 esc_html( $plugin_info['Name'] ),
95 esc_html__( 'requires', 'bestwebsoft' ),
96 esc_html( $require_wp ),
97 esc_html__( 'or higher, that is why it has been deactivated! Please upgrade WordPress and try again.', 'bestwebsoft' ),
98 esc_html__( 'Back to the WordPress', 'bestwebsoft' ),
99 esc_url( $admin_url ),
100 esc_html__( 'Plugins page', 'bestwebsoft' )
101 )
102 );
103 }
104 } elseif ( version_compare( $wp_version, $require_wp, '<' ) ) {
105 $bws_versions_notice_array[] = array(
106 'name' => $plugin_info['Name'],
107 'version' => $require_wp,
108 );
109 }
110 }
111 }
112
113 if ( ! function_exists( 'bws_plugin_reviews_block' ) ) {
114 /**
115 * Function display review block
116 *
117 * @param string $plugin_name Plugin name.
118 * @param string $plugin_slug Plugin slug.
119 * @echo string
120 */
121 function bws_plugin_reviews_block( $plugin_name, $plugin_slug ) { ?>
122 <div class="bws-plugin-reviews">
123 <div class="bws-plugin-reviews-rate">
124 <?php esc_html_e( 'Like the plugin?', 'bestwebsoft' ); ?>
125 <a href="https://wordpress.org/support/view/plugin-reviews/<?php echo esc_attr( $plugin_slug ); ?>?filter=5" target="_blank" title="<?php printf( esc_html__( '%s reviews', 'bestwebsoft' ), esc_html( sanitize_text_field( $plugin_name ) ) ); ?>">
126 <?php esc_html_e( 'Rate it', 'bestwebsoft' ); ?>
127 <span class="dashicons dashicons-star-filled"></span>
128 <span class="dashicons dashicons-star-filled"></span>
129 <span class="dashicons dashicons-star-filled"></span>
130 <span class="dashicons dashicons-star-filled"></span>
131 <span class="dashicons dashicons-star-filled"></span>
132 </a>
133 </div>
134 <div class="bws-plugin-reviews-support">
135 <?php esc_html_e( 'Need help?', 'bestwebsoft' ); ?>
136 <a href="https://support.bestwebsoft.com"><?php esc_html_e( 'Visit Help Center', 'bestwebsoft' ); ?></a>
137 </div>
138 <div class="bws-plugin-reviews-donate">
139 <?php esc_html_e( 'Want to support the plugin?', 'bestwebsoft' ); ?>
140 <a href="https://bestwebsoft.com/donate/"><?php esc_html_e( 'Donate', 'bestwebsoft' ); ?></a>
141 </div>
142 </div>
143 <?php
144 }
145 }
146
147 if ( ! function_exists( 'bws_plugin_update_row' ) ) {
148 /**
149 * Function display license notification
150 *
151 * @param string $plugin_key Plugin key.
152 * @param string $link_slug (Optional) Link slug.
153 * @param string $free_plugin_name (Optional) Free version plugin name.
154 * @echo string
155 */
156 function bws_plugin_update_row( $plugin_key, $link_slug = false, $free_plugin_name = false ) {
157 global $bstwbsftwppdtplgns_options, $wp_version;
158 $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
159 if ( isset( $bstwbsftwppdtplgns_options['wrong_license_key'][ $plugin_key ] ) ) {
160 $explode_plugin_key = explode( '/', $plugin_key );
161 $class = ( $wp_version >= 4.6 ) ? 'active' : '';
162 $style = ( $wp_version < 4.6 ) ? ' style="background-color: #FFEBE8;border-color: #CC0000;"' : '';
163 $div_class = ( $wp_version >= 4.6 ) ? ' notice inline notice-warning notice-alt' : '';
164 echo '<tr class="bws-plugin-update-tr plugin-update-tr ' . esc_attr( $class ) . '" id="' . esc_attr( $explode_plugin_key[0] ) . '-update" data-slug="' . esc_attr( $explode_plugin_key[0] ) . '" data-plugin="' . esc_attr( $plugin_key ) . '">
165 <td colspan="' . esc_attr( $wp_list_table->get_column_count() ) . '" class="plugin-update colspanchange">
166 <div class="update-message' . esc_attr( $div_class ) . '"' . wp_kses_post( $style ) . '>';
167 if ( $wp_version >= 4.6 ) {
168 echo '<p>';
169 }
170 echo '<strong>' . esc_html__( 'WARNING: Illegal use notification', 'bestwebsoft' ) . '.</strong> ' . esc_html__( 'You can use one license of the Pro plugin for one domain only. Please check and edit your license or domain if necessary using your personal Client Area. We strongly recommend you to solve the problem within 24 hours, otherwise the Pro plugin will be deactivated.', 'bestwebsoft' ) . ' <a target="_blank" href="https://support.bestwebsoft.com/hc/en-us/articles/204240089">' . esc_html__( 'Learn More', 'bestwebsoft' ) . '</a>';
171 if ( $wp_version >= 4.6 ) {
172 echo '</p>';
173 }
174 echo '</div>
175 </td>
176 </tr>';
177 } elseif ( isset( $bstwbsftwppdtplgns_options['time_out'][ $plugin_key ] ) && strtotime( $bstwbsftwppdtplgns_options['time_out'][ $plugin_key ] ) < strtotime( gmdate( 'm/d/Y' ) ) ) {
178 $explode_plugin_key = explode( '/', $plugin_key );
179 $class = ( $wp_version >= 4.6 ) ? 'active' : '';
180 $style = ( $wp_version < 4.6 ) ? ' style="color: #8C0000;"' : '';
181 $div_class = ( $wp_version >= 4.6 ) ? ' notice inline notice-warning notice-alt' : '';
182 echo '<tr class="bws-plugin-update-tr plugin-update-tr ' . esc_attr( $class ) . '" id="' . esc_attr( $explode_plugin_key[0] ) . '-update" data-slug="' . esc_attr( $explode_plugin_key[0] ) . '" data-plugin="' . esc_attr( $plugin_key ) . '">
183 <td colspan="' . esc_attr( $wp_list_table->get_column_count() ) . '" class="plugin-update colspanchange">
184 <div class="update-message' . esc_attr( $div_class ) . '"' . wp_kses_post( $style ) . '>';
185 if ( $wp_version >= 4.6 ) {
186 echo '<p>';
187 }
188 if ( isset( $bstwbsftwppdtplgns_options['trial'][ $plugin_key ] ) && false !== $link_slug ) {
189 echo esc_html__( 'Notice: Your Pro Trial license has expired. To continue using the plugin, you should buy a Pro license', 'bestwebsoft' ) . ' - <a href="https://bestwebsoft.com/products/wordpress/plugins/' . esc_attr( $link_slug ) . '/">https://bestwebsoft.com/products/wordpress/plugins/' . esc_attr( $link_slug ) . '/</a>';
190 } else {
191 echo esc_html__( 'Your license has expired. To continue getting top-priority support and plugin updates, you should extend it.', 'bestwebsoft' ) . ' <a target="_new" href="https://support.bestwebsoft.com/entries/53487136">' . esc_html__( 'Learn more', 'bestwebsoft' ) . '</a>';
192 }
193 if ( $wp_version >= 4.6 ) {
194 echo '</p>';
195 }
196 echo '</div>
197 </td>
198 </tr>';
199 } elseif ( isset( $bstwbsftwppdtplgns_options['trial'][ $plugin_key ] ) ) {
200 $explode_plugin_key = explode( '/', $plugin_key );
201 $class = ( $wp_version >= 4.6 ) ? 'active' : '';
202 $style = ( $wp_version < 4.6 ) ? ' style="color: #8C0000;"' : '';
203 $div_class = ( $wp_version >= 4.6 ) ? ' notice inline notice-warning notice-alt' : '';
204 echo '<tr class="bws-plugin-update-tr plugin-update-tr ' . esc_attr( $class ) . '" id="' . esc_attr( $explode_plugin_key[0] ) . '-update" data-slug="' . esc_attr( $explode_plugin_key[0] ) . '" data-plugin="' . esc_attr( $plugin_key ) . '">
205 <td colspan="' . esc_attr( $wp_list_table->get_column_count() ) . '" class="plugin-update colspanchange">
206 <div class="update-message' . esc_attr( $div_class ) . '"' . wp_kses_post( $style ) . '>';
207 if ( $wp_version >= 4.6 ) {
208 echo '<p>';
209 }
210 if ( false !== $free_plugin_name ) {
211 printf( esc_html__( 'Notice: You are using the Pro Trial license of %s plugin.', 'bestwebsoft' ), esc_html( $free_plugin_name ) );
212 } else {
213 esc_html_e( 'Notice: You are using the Pro Trial license of plugin.', 'bestwebsoft' );
214 }
215 if ( isset( $bstwbsftwppdtplgns_options['time_out'][ $plugin_key ] ) ) {
216 echo ' ' . esc_html__( 'The Pro Trial license will expire on', 'bestwebsoft' ) . ' ' . esc_html( $bstwbsftwppdtplgns_options['time_out'][ $plugin_key ] ) . '.';
217 }
218 if ( $wp_version >= 4.6 ) {
219 echo '</p>';
220 }
221 echo '</div>
222 </td>
223 </tr>';
224 }
225 }
226 }
227
228 if ( ! function_exists( 'bws_admin_notices' ) ) {
229 /**
230 * Function display admin notices
231 *
232 * @echo string
233 */
234 function bws_admin_notices() {
235 global $bws_versions_notice_array, $bws_plugin_banner_to_settings, $bstwbsftwppdtplgns_options, $bws_plugin_banner_go_pro, $bstwbsftwppdtplgns_banner_array, $bws_plugin_banner_timeout, $bws_plugin_banner_to_promo;
236
237 /* bws_plugin_banner_go_pro */
238 if ( ! empty( $bws_plugin_banner_go_pro ) ) {
239 /* get $bws_plugins */
240 require dirname( __FILE__ ) . '/product_list.php';
241
242 foreach ( $bstwbsftwppdtplgns_banner_array as $value ) {
243 if ( isset( $bws_plugin_banner_go_pro[ $value[0] ] ) && ! isset( $_COOKIE[ $value[0] ] ) ) {
244
245 if ( isset( $bws_plugins[ $value[1] ]['pro_version'] ) && is_plugin_active( $bws_plugins[ $value[1] ]['pro_version'] ) ) {
246 continue;
247 }
248
249 $single_banner_value = $bws_plugin_banner_go_pro[ $value[0] ];
250 ?>
251 <div class="updated" style="padding: 0; margin: 0; border: none; background: none;">
252 <div class="<?php echo esc_attr( $single_banner_value['prefix'] ); ?>_message bws_banner_on_plugin_page bws_go_pro_banner" style="display: none;">
253 <button class="<?php echo esc_attr( $single_banner_value['prefix'] ); ?>_close_icon close_icon notice-dismiss bws_hide_settings_notice" title="<?php esc_html_e( 'Close notice', 'bestwebsoft' ); ?>"></button>
254 <div class="icon">
255 <img title="" src="<?php echo esc_attr( $single_banner_value['banner_url'] ); ?>" alt="" />
256 </div>
257 <div class="text">
258 <?php esc_html_e( 'It’s time to upgrade your', 'bestwebsoft' ); ?> <strong><?php echo esc_html( $single_banner_value['plugin_info']['Name'] ); ?> plugin</strong> <?php esc_html_e( 'to', 'bestwebsoft' ); ?> <strong>Pro</strong> <?php esc_html_e( 'version!', 'bestwebsoft' ); ?><br />
259 <span><?php esc_html_e( 'Extend standard plugin functionality with new great options.', 'bestwebsoft' ); ?></span>
260 </div>
261 <div class="button_div">
262 <a class="button" target="_blank" href="<?php echo esc_url( $single_banner_value['bws_link'] ); ?>"><?php esc_html_e( 'Learn More', 'bestwebsoft' ); ?></a>
263 </div>
264 </div>
265 </div>
266 <?php
267 break;
268 }
269 }
270 }
271
272 /* $bws_plugin_banner_timeout */
273 if ( ! empty( $bws_plugin_banner_timeout ) ) {
274 foreach ( $bws_plugin_banner_timeout as $banner_value ) {
275 ?>
276 <div class="updated" style="padding: 0; margin: 0; border: none; background: none;">
277 <div class="<?php echo esc_attr( $banner_value['prefix'] ); ?>_message_timeout bws_banner_on_plugin_page bws_banner_timeout" style="display:none;">
278 <button class="<?php echo esc_attr( $banner_value['prefix'] ); ?>_close_icon close_icon notice-dismiss bws_hide_settings_notice" title="<?php esc_html_e( 'Close notice', 'bestwebsoft' ); ?>"></button>
279 <div class="icon">
280 <img title="" src="<?php echo esc_url( $banner_value['banner_url'] ); ?>" alt="" />
281 </div>
282 <div class="text"><?php printf( esc_html__( "Your license key for %1\$s expires on %2\$s and you won't be granted TOP-PRIORITY SUPPORT or UPDATES.", 'bestwebsoft' ), '<strong>' . esc_html( $banner_value['plugin_name'] ) . '</strong>', esc_html( $bstwbsftwppdtplgns_options['time_out'][ $banner_value['plugin_key'] ] ) ); ?> <a target="_new" href="https://support.bestwebsoft.com/entries/53487136"><?php esc_html_e( 'Learn more', 'bestwebsoft' ); ?></a></div>
283 </div>
284 </div>
285 <?php
286 }
287 }
288
289 /* versions notice */
290 if ( ! empty( $bws_versions_notice_array ) ) {
291 foreach ( $bws_versions_notice_array as $key => $value ) {
292 ?>
293 <div class="update-nag">
294 <?php
295 printf(
296 '<strong>%s</strong> %s <strong>WordPress %s</strong> %s',
297 esc_html( $value['name'] ),
298 esc_html__( 'requires', 'bestwebsoft' ),
299 esc_html( $value['version'] ),
300 esc_html__( 'or higher! We do not guarantee that our plugin will work correctly. Please upgrade to WordPress latest version.', 'bestwebsoft' )
301 );
302 ?>
303 </div>
304 <?php
305 }
306 }
307
308 /* banner_to_settings notice */
309 if ( ! empty( $bws_plugin_banner_to_settings ) ) {
310 if ( 1 === count( $bws_plugin_banner_to_settings ) ) {
311 ?>
312 <div class="updated" style="padding: 0; margin: 0; border: none; background: none;">
313 <div class="bws_banner_on_plugin_page bws_banner_to_settings">
314 <div class="icon">
315 <img title="" src="<?php echo esc_url( $bws_plugin_banner_to_settings[0]['banner_url'] ); ?>" alt="" />
316 </div>
317 <div class="text">
318 <strong><?php printf( esc_html__( 'Thank you for installing %s plugin!', 'bestwebsoft' ), esc_html( $bws_plugin_banner_to_settings[0]['plugin_info']['Name'] ) ); ?></strong>
319 <br />
320 <?php esc_html_e( "Let's get started", 'bestwebsoft' ); ?>:
321 <a href="<?php echo esc_url( self_admin_url( $bws_plugin_banner_to_settings[0]['settings_url'] ) ); ?>"><?php esc_html_e( 'Settings', 'bestwebsoft' ); ?></a>
322 <?php if ( false !== $bws_plugin_banner_to_settings[0]['post_type_url'] ) { ?>
323 <?php esc_html_e( 'or', 'bestwebsoft' ); ?>
324 <a href="<?php echo esc_url( self_admin_url( $bws_plugin_banner_to_settings[0]['post_type_url'] ) ); ?>"><?php esc_html_e( 'Add New', 'bestwebsoft' ); ?></a>
325 <?php } ?>
326 </div>
327 <form action="" method="post">
328 <button class="notice-dismiss bws_hide_settings_notice" title="<?php esc_html_e( 'Close notice', 'bestwebsoft' ); ?>"></button>
329 <input type="hidden" name="bws_hide_settings_notice_<?php echo esc_html( $bws_plugin_banner_to_settings[0]['plugin_options_name'] ); ?>" value="hide" />
330 <?php wp_nonce_field( plugin_basename( __FILE__ ), 'bws_settings_nonce_name' ); ?>
331 </form>
332 </div>
333 </div>
334 <?php } else { ?>
335 <div class="updated" style="padding: 0; margin: 0; border: none; background: none;">
336 <div class="bws_banner_on_plugin_page bws_banner_to_settings_joint">
337 <form action="" method="post">
338 <button class="notice-dismiss bws_hide_settings_notice" title="<?php esc_html_e( 'Close notice', 'bestwebsoft' ); ?>"></button>
339 <div class="bws-text">
340 <div class="icon">
341 <span class="dashicons dashicons-admin-plugins"></span>
342 </div>
343 <strong><?php esc_html_e( 'Thank you for installing plugins by BestWebSoft!', 'bestwebsoft' ); ?></strong>
344 <div class="hide-if-no-js bws-more-links">
345 <a href="#" class="bws-more"><?php esc_html_e( 'More Details', 'bestwebsoft' ); ?></a>
346 <a href="#" class="bws-less hidden"><?php esc_html_e( 'Less Details', 'bestwebsoft' ); ?></a>
347 </div>
348 <?php wp_nonce_field( plugin_basename( __FILE__ ), 'bws_settings_nonce_name' ); ?>
349 <div class="clear"></div>
350 </div>
351 <div class="bws-details hide-if-js">
352 <?php foreach ( $bws_plugin_banner_to_settings as $value ) { ?>
353 <div>
354 <strong><?php echo esc_html( str_replace( ' by BestWebSoft', '', $value['plugin_info']['Name'] ) ); ?></strong>&ensp;<a href="<?php echo esc_url( self_admin_url( $value['settings_url'] ) ); ?>"><?php esc_html_e( 'Settings', 'bestwebsoft' ); ?></a>
355 <?php if ( false !== $value['post_type_url'] ) { ?>
356 &ensp;|&ensp;<a target="_blank" href="<?php echo esc_url( self_admin_url( $value['post_type_url'] ) ); ?>"><?php esc_html_e( 'Add New', 'bestwebsoft' ); ?></a>
357 <?php } ?>
358 <input type="hidden" name="bws_hide_settings_notice_<?php echo esc_html( $value['plugin_options_name'] ); ?>" value="hide" />
359 </div>
360 <?php } ?>
361 </div>
362 </div>
363 </form>
364 </div>
365 <?php
366 }
367 }
368
369 /* banner_to_setting_promo */
370 if ( ! empty( $bws_plugin_banner_to_promo ) ) {
371 $key = rand( 0, count( $bws_plugin_banner_to_promo ) - 1 );
372 ?>
373 <div class="updated" style="padding: 0; margin: 0; border: none; background: none;">
374 <div class="bws_banner_on_plugin_page bws_banner_to_settings">
375 <div class="icon">
376 <img title="" src="<?php echo esc_url( $bws_plugin_banner_to_promo[$key]['banner_url'] ); ?>" alt="" />
377 </div>
378 <div class="text">
379 <strong><?php echo esc_html( $bws_plugin_banner_to_promo[$key]['message'][0] ); ?></strong>
380 <br />
381 <?php echo esc_html( $bws_plugin_banner_to_promo[$key]['message'][1] ); ?>
382 </div>
383 <div class="button_div">
384 <a class="button" href="<?php echo esc_url( self_admin_url( $bws_plugin_banner_to_promo[$key]['settings_url'] ) ); ?>"><?php esc_html_e( 'Go to Settings', 'bestwebsoft' ); ?></a>
385 </div>
386 <form action="" method="post">
387 <button class="notice-dismiss bws_hide_promo_notice" title="<?php esc_html_e( 'Close notice', 'bestwebsoft' ); ?>"></button>
388 <input type="hidden" name="bws_hide_settings_promo_notice_<?php echo esc_html( $bws_plugin_banner_to_promo[$key]['plugin_options_name'] ); ?>" value="hide" />
389 <?php wp_nonce_field( plugin_basename( __FILE__ ), 'bws_settings_nonce_name' ); ?>
390 </form>
391 </div>
392 </div>
393 <?php
394 }
395
396 /**
397 * Show notices about deprecated_function
398 *
399 * @since 1.9.8
400 */
401 if ( ! empty( $bstwbsftwppdtplgns_options['deprecated_function'] ) ) {
402 ?>
403 <div class="update-nag">
404 <strong><?php esc_html_e( 'Deprecated function(-s) is used on the site here:', 'bestwebsoft' ); ?></strong>
405 <?php
406 $i = 1;
407 foreach ( $bstwbsftwppdtplgns_options['deprecated_function'] as $function_name => $attr ) {
408 if ( 1 !== $i ) {
409 echo ' ,';
410 }
411 if ( ! empty( $attr['product-name'] ) ) {
412 echo esc_html( $attr['product-name'] );
413 } elseif ( ! empty( $attr['file'] ) ) {
414 echo esc_url( $attr['file'] );
415 }
416 unset( $bstwbsftwppdtplgns_options['deprecated_function'][ $function_name ] );
417 $i++;
418 }
419 ?>
420 .
421 <br/>
422 <?php esc_html_e( 'This function(-s) will be removed over time. Please update the product(-s).', 'bestwebsoft' ); ?>
423 </div>
424 <?php
425 if ( is_multisite() ) {
426 update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options );
427 } else {
428 update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options );
429 }
430 }
431 }
432 }
433
434 if ( ! function_exists( 'bws_plugin_banner_go_pro' ) ) {
435 /**
436 * Function display banner
437 *
438 * @param array $plugin_options Plugin options array.
439 * @param array $plugin_info Plugin info array.
440 * @param string $this_banner_prefix Banner prefix.
441 * @param string $bws_link_slug Slug for link.
442 * @param string $link_key Key for plugin.
443 * @param string $link_pn PN for plugin.
444 * @param string $banner_url_or_slug Url or slug for icon.
445 * @return array
446 */
447 function bws_plugin_banner_go_pro( $plugin_options, $plugin_info, $this_banner_prefix, $bws_link_slug, $link_key, $link_pn, $banner_url_or_slug ) {
448 global $bws_plugin_banner_go_pro, $wp_version, $bstwbsftwppdtplgns_banner_array;
449
450 if ( ! isset( $plugin_options['first_install'] ) || strtotime( '-1 week' ) < $plugin_options['first_install'] ) {
451 return;
452 }
453
454 $bws_link = esc_url( 'https://bestwebsoft.com/products/wordpress/plugins/' . $bws_link_slug . '/?k=' . $link_key . '&pn=' . $link_pn . '&v=' . $plugin_info['Version'] . '&wp_v=' . $wp_version );
455
456 if ( false === strrpos( $banner_url_or_slug, '/' ) ) {
457 $banner_url_or_slug = '//ps.w.org/' . $banner_url_or_slug . '/assets/icon-256x256.gif';
458 }
459
460 $bws_plugin_banner_go_pro[ $this_banner_prefix . '_hide_banner_on_plugin_page' ] = array(
461 'plugin_info' => $plugin_info,
462 'prefix' => $this_banner_prefix,
463 'bws_link' => $bws_link,
464 'banner_url' => $banner_url_or_slug,
465 );
466
467 if ( empty( $bstwbsftwppdtplgns_banner_array ) ) {
468 if ( ! function_exists( 'bws_get_banner_array' ) ) {
469 require_once dirname( __FILE__ ) . '/bws_menu.php';
470 }
471 bws_get_banner_array();
472 }
473 }
474 }
475
476 if ( ! function_exists( 'bws_add_plugin_banner_timeout' ) ) {
477 /**
478 * Function update banner params
479 *
480 * @param string $plugin_key Plugin key.
481 * @param string $plugin_prefix Plugin prefix.
482 * @param string $plugin_name Plugin name.
483 * @param string $banner_url_or_slug Url or slug for icon.
484 */
485 function bws_add_plugin_banner_timeout( $plugin_key, $plugin_prefix, $plugin_name, $banner_url_or_slug ) {
486 global $bws_plugin_banner_timeout;
487
488 if ( isset( $bstwbsftwppdtplgns_options['time_out'][ $plugin_key ] ) && ( strtotime( $bstwbsftwppdtplgns_options['time_out'][ $plugin_key ] ) < strtotime( gmdate( 'm/d/Y' ) . '+1 month' ) ) && ( strtotime( $bstwbsftwppdtplgns_options['time_out'][ $plugin_key ] ) > strtotime( gmdate( 'm/d/Y' ) ) ) ) {
489
490 if ( false === strrpos( $banner_url_or_slug, '/' ) ) {
491 $banner_url_or_slug = '//ps.w.org/' . $banner_url_or_slug . '/assets/icon-256x256.gif';
492 }
493
494 $bws_plugin_banner_timeout[] = array(
495 'plugin_key' => $plugin_key,
496 'prefix' => $plugin_prefix,
497 'plugin_name' => $plugin_name,
498 'banner_url' => $banner_url_or_slug,
499 );
500 }
501 }
502 }
503
504 if ( ! function_exists( 'bws_plugin_banner_to_settings' ) ) {
505 /**
506 * Function settings for banner
507 *
508 * @param array $plugin_info Plugin info.
509 * @param array $plugin_options_name Plugin option name.
510 * @param array $banner_url_or_slug Url or slug for icon.
511 * @param array $settings_url Url for settings.
512 * @param array $post_type_url (Optional) Url for banner.
513 * @return global array
514 */
515 function bws_plugin_banner_to_settings( $plugin_info, $plugin_options_name, $banner_url_or_slug, $settings_url, $post_type_url = false ) {
516 global $bws_plugin_banner_to_settings;
517
518 $is_network_admin = is_network_admin();
519
520 $plugin_options = $is_network_admin ? get_site_option( $plugin_options_name ) : get_option( $plugin_options_name );
521
522 if ( isset( $plugin_options['display_settings_notice'] ) && 0 === $plugin_options['display_settings_notice'] ) {
523 return;
524 }
525
526 if ( isset( $_POST[ 'bws_hide_settings_notice_' . $plugin_options_name ] ) && check_admin_referer( plugin_basename( __FILE__ ), 'bws_settings_nonce_name' ) ) {
527 $plugin_options['display_settings_notice'] = 0;
528 if ( $is_network_admin ) {
529 update_site_option( $plugin_options_name, $plugin_options );
530 } else {
531 update_option( $plugin_options_name, $plugin_options );
532 }
533 return;
534 }
535
536 if ( false === strrpos( $banner_url_or_slug, '/' ) ) {
537 $banner_url_or_slug = '//ps.w.org/' . $banner_url_or_slug . '/assets/icon-256x256.gif';
538 }
539
540 $bws_plugin_banner_to_settings[] = array(
541 'plugin_info' => $plugin_info,
542 'plugin_options_name' => $plugin_options_name,
543 'banner_url' => $banner_url_or_slug,
544 'settings_url' => $settings_url,
545 'post_type_url' => $post_type_url,
546 );
547 }
548 }
549
550 if ( ! function_exists( 'bws_plugin_banner_to_promo' ) ) {
551 /**
552 * Function settings for banner
553 *
554 * @param array $plugin_info Plugin info.
555 * @param array $plugin_options_name Plugin option name.
556 * @param array $banner_url_or_slug Url or slug for icon.
557 * @param array $settings_url Url for settings.
558 * @param array $post_type_url (Optional) Url for banner.
559 * @return global array
560 */
561 function bws_plugin_banner_to_promo( $plugin_info, $plugin_options_name, $banner_url_or_slug, $settings_url, $message = array(), $post_type_url = false ) {
562 global $bws_plugin_banner_to_promo;
563
564 $is_network_admin = is_network_admin();
565
566 $plugin_options = $is_network_admin ? get_site_option( $plugin_options_name ) : get_option( $plugin_options_name );
567
568 if ( isset( $plugin_options['display_promo_time'] ) && $plugin_options['display_promo_time'] + 604800000 < time() ) {
569 $plugin_options['display_promo_notice'] = 1;
570 if ( $is_network_admin ) {
571 update_site_option( $plugin_options_name, $plugin_options );
572 } else {
573 update_option( $plugin_options_name, $plugin_options );
574 }
575 }
576
577 if ( isset( $plugin_options['display_promo_notice'] ) && 0 === $plugin_options['display_promo_notice'] ) {
578 return;
579 }
580
581 if ( isset( $_POST[ 'bws_hide_settings_promo_notice_' . $plugin_options_name ] ) && check_admin_referer( plugin_basename( __FILE__ ), 'bws_settings_nonce_name' ) ) {
582 $plugin_options['display_promo_notice'] = 0;
583 $plugin_options['display_promo_time'] = time();
584 if ( $is_network_admin ) {
585 update_site_option( $plugin_options_name, $plugin_options );
586 } else {
587 update_option( $plugin_options_name, $plugin_options );
588 }
589 return;
590 }
591
592 if ( false === strrpos( $banner_url_or_slug, '/' ) ) {
593 $banner_url_or_slug = '//ps.w.org/' . $banner_url_or_slug . '/assets/icon-256x256.gif';
594 }
595
596 $bws_plugin_banner_to_promo[] = array(
597 'plugin_info' => $plugin_info,
598 'plugin_options_name' => $plugin_options_name,
599 'banner_url' => $banner_url_or_slug,
600 'settings_url' => $settings_url,
601 'message' => $message,
602 'post_type_url' => $post_type_url,
603 );
604 }
605 }
606
607 if ( ! function_exists( 'bws_plugin_suggest_feature_banner' ) ) {
608 /**
609 * Function display for feature banner
610 *
611 * @param array $plugin_info Plugin info.
612 * @param array $plugin_options_name Plugin option name.
613 * @param array $banner_url_or_slug Url or slug for icon.
614 * @echo string
615 */
616 function bws_plugin_suggest_feature_banner( $plugin_info, $plugin_options_name, $banner_url_or_slug ) {
617 $is_network_admin = is_network_admin();
618
619 $plugin_options = $is_network_admin ? get_site_option( $plugin_options_name ) : get_option( $plugin_options_name );
620
621 if ( isset( $plugin_options['display_suggest_feature_banner'] ) && 0 === $plugin_options['display_suggest_feature_banner'] ) {
622 return;
623 }
624
625 if ( ! isset( $plugin_options['first_install'] ) ) {
626 $plugin_options['first_install'] = strtotime( 'now' );
627 $update_option = true;
628 $return = true;
629 } elseif ( strtotime( '-2 week' ) < $plugin_options['first_install'] ) {
630 $return = true;
631 }
632
633 if ( ! isset( $plugin_options['go_settings_counter'] ) ) {
634 $plugin_options['go_settings_counter'] = 1;
635 $update_option = true;
636 $return = true;
637 } elseif ( 20 > $plugin_options['go_settings_counter'] ) {
638 $plugin_options['go_settings_counter'] = $plugin_options['go_settings_counter'] + 1;
639 $update_option = true;
640 $return = true;
641 }
642
643 if ( isset( $update_option ) ) {
644 if ( $is_network_admin ) {
645 update_site_option( $plugin_options_name, $plugin_options );
646 } else {
647 update_option( $plugin_options_name, $plugin_options );
648 }
649 }
650
651 if ( isset( $return ) ) {
652 return;
653 }
654
655 if ( isset( $_POST[ 'bws_hide_suggest_feature_banner_' . $plugin_options_name ] ) && check_admin_referer( $plugin_info['Name'], 'bws_settings_nonce_name' ) ) {
656 $plugin_options['display_suggest_feature_banner'] = 0;
657 if ( $is_network_admin ) {
658 update_site_option( $plugin_options_name, $plugin_options );
659 } else {
660 update_option( $plugin_options_name, $plugin_options );
661 }
662 return;
663 }
664
665 if ( false === strrpos( $banner_url_or_slug, '/' ) ) {
666 $banner_url_or_slug = '//ps.w.org/' . $banner_url_or_slug . '/assets/icon-256x256.gif';
667 }
668 ?>
669 <div class="updated" style="padding: 0; margin: 0; border: none; background: none;">
670 <div class="bws_banner_on_plugin_page bws_suggest_feature_banner">
671 <div class="icon">
672 <img title="" src="<?php echo esc_url( $banner_url_or_slug ); ?>" alt="" />
673 </div>
674 <div class="text">
675 <strong><?php printf( esc_html__( 'Thank you for choosing %s plugin!', 'bestwebsoft' ), esc_html( $plugin_info['Name'] ) ); ?></strong><br />
676 <?php esc_html_e( "If you have a feature, suggestion or idea you'd like to see in the plugin, we'd love to hear about it!", 'bestwebsoft' ); ?>
677 <a target="_blank" href="https://support.bestwebsoft.com/hc/en-us/requests/new"><?php esc_html_e( 'Suggest a Feature', 'bestwebsoft' ); ?></a>
678 </div>
679 <form action="" method="post">
680 <button class="notice-dismiss bws_hide_settings_notice" title="<?php esc_html_e( 'Close notice', 'bestwebsoft' ); ?>"></button>
681 <input type="hidden" name="bws_hide_suggest_feature_banner_<?php echo esc_html( $plugin_options_name ); ?>" value="hide" />
682 <?php wp_nonce_field( $plugin_info['Name'], 'bws_settings_nonce_name' ); ?>
683 </form>
684 </div>
685 </div>
686 <?php
687 }
688 }
689
690 if ( ! function_exists( 'bws_plugin_promo_banner' ) ) {
691 /**
692 * Function display for feature banner
693 *
694 * @param array $plugin_info Plugin info.
695 * @param array $plugin_options_name Plugin option name.
696 * @param array $banner_url_or_slug Url or slug for icon.
697 * @echo string
698 */
699 function bws_plugin_promo_banner( $plugin_info, $plugin_options_name, $banner_url_or_slug, $plugin_url ) {
700 $is_network_admin = is_network_admin();
701
702 $promo_plugins = array( 'google-captcha', 'contact-form-plugin', 'pdf-print' );
703
704 $plugin_options = $is_network_admin ? get_site_option( $plugin_options_name ) : get_option( $plugin_options_name );
705
706 if ( in_array( $banner_url_or_slug, $promo_plugins ) ) {
707 if ( isset( $plugin_options['display_promo_banner_time'] ) && $plugin_options['display_promo_banner_time'] + 604800000 < time() ) {
708 $plugin_options['display_promo_banner'] = 1;
709 if ( $is_network_admin ) {
710 update_site_option( $plugin_options_name, $plugin_options );
711 } else {
712 update_option( $plugin_options_name, $plugin_options );
713 }
714 }
715 if ( isset( $plugin_options['display_promo_banner'] ) && 0 === $plugin_options['display_promo_banner'] ) {
716 return;
717 }
718
719 if ( isset( $_POST[ 'bws_hide_promo_banner_' . $plugin_options_name ] ) && check_admin_referer( $plugin_info['Name'], 'bws_settings_nonce_name' ) ) {
720 $plugin_options['display_promo_banner'] = 0;
721 $plugin_options['display_promo_banner_time'] = time();
722 if ( $is_network_admin ) {
723 update_site_option( $plugin_options_name, $plugin_options );
724 } else {
725 update_option( $plugin_options_name, $plugin_options );
726 }
727 return;
728 }
729 ?>
730 <div style="padding: 0; margin: 0; border: none; background: none; position: relative;">
731 <div class="bws_banner_on_plugin_page bws_promo_banner">
732 <div class="promo-banner-left">
733 <div class="promo-banner-upgrade"><?php esc_html_e( 'Upgrade to pro', 'bestwebsoft' ); ?></div>
734 <div class="promo-banner-off"><?php esc_html_e( '30% OFF', 'bestwebsoft' ); ?></div>
735 </div>
736 <div class="promo-banner-text">
737 <div class="promo-banner-text-top"><?php esc_html_e( 'Get exclusive Pro features and premium support.', 'bestwebsoft' ); ?></div>
738 <div class="promo-banner-text-bottom"><?php printf( '%s <span>%s</span> %s', esc_html__( 'Use', 'bestwebsoft' ), esc_html__( 'UPGRADE', 'bestwebsoft' ), esc_html__( 'promo code for instant savings!', 'bestwebsoft' ) ); ?></div>
739 </div>
740 <div class="promo-banner-get-pro"><?php esc_html_e( 'Get PRO NOW', 'bestwebsoft' ); ?></div>
741 </div>
742 <a href="<?php echo esc_url( $plugin_url ); ?>" class="promo-banner-link"></a>
743 <form action="" method="post">
744 <button class="notice-dismiss bws_hide_settings_notice bws_hide_promo_notice" title="Close notice"></button>
745 <input type="hidden" name="bws_hide_promo_banner_gglcptch_options" value="hide">
746 <?php wp_nonce_field( $plugin_info['Name'], 'bws_settings_nonce_name' ); ?>
747 </form>
748 </div>
749 <?php
750 }
751 }
752 }
753
754 if ( ! function_exists( 'bws_affiliate_postbox' ) ) {
755 /**
756 * Function display affiliate postbox
757 *
758 * @echo string
759 */
760 function bws_affiliate_postbox() {
761
762 $dismissed = get_user_meta( get_current_user_id(), '_bws_affiliate_postbox_dismissed', true );
763
764 if ( ! empty( $dismissed ) && strtotime( '-3 month' ) < $dismissed ) {
765 return;
766 }
767
768 if ( isset( $_POST['bws_hide_affiliate_banner'] ) && check_admin_referer( 'bws_affiliate_postbox', 'bws_settings_nonce_name' ) ) {
769 update_user_meta( get_current_user_id(), '_bws_affiliate_postbox_dismissed', strtotime( 'now' ) );
770 return;
771 }
772
773 $bws_link = esc_url( 'https://bestwebsoft.com/affiliate/?utm_source=plugin&utm_medium=settings&utm_campaign=affiliate_program' );
774 ?>
775 <div id="bws-affiliate-postbox" class="postbox">
776 <form action="" method="post">
777 <button class="notice-dismiss bws_hide_settings_notice" title="<?php esc_html_e( 'Close notice', 'bestwebsoft' ); ?>"></button>
778 <input type="hidden" name="bws_hide_affiliate_banner" value="hide" />
779 <?php wp_nonce_field( 'bws_affiliate_postbox', 'bws_settings_nonce_name' ); ?>
780 </form>
781 <p>BESTWEBSOFT</p>
782 <h3><?php esc_html_e( 'Affiliate Program', 'bestwebsoft' ); ?></h3>
783 <div class="bws-affiliate-get"><?php printf( esc_html__( 'Get %s', 'bestwebsoft' ), '20%' ); ?></div>
784 <div><?php esc_html_e( 'from each BestWebSoft plugin and theme sale you refer', 'bestwebsoft' ); ?></div>
785 <div class="bws-row">
786 <div class="bws-cell">
787 <img src="<?php echo esc_url( bws_menu_url( 'images/join-icon.svg' ) ); ?>" alt="" />
788 <div><?php esc_html_e( 'Join affiliate program', 'bestwebsoft' ); ?></div>
789 </div>
790 <div class="bws-cell">
791 <img src="<?php echo esc_url( bws_menu_url( 'images/promote-icon.svg' ) ); ?>" alt="" />
792 <div><?php esc_html_e( 'Promote and sell products', 'bestwebsoft' ); ?></div>
793 </div>
794 <div class="bws-cell">
795 <img src="<?php echo esc_url( bws_menu_url( 'images/earn-icon.svg' ) ); ?>" alt="" />
796 <div><?php esc_html_e( 'Get commission!', 'bestwebsoft' ); ?></div>
797 </div>
798 </div>
799 <div class="clear"></div>
800 <p>
801 <a class="button" href="<?php echo esc_url( $bws_link ); ?>" target="_blank"><?php esc_html_e( 'Start Now', 'bestwebsoft' ); ?></a>
802 </p>
803 </div>
804 <?php
805 }
806 }
807
808 if ( ! function_exists( 'bws_show_settings_notice' ) ) {
809 /**
810 * Function display settings notice
811 *
812 * @echo string
813 */
814 function bws_show_settings_notice() {
815 ?>
816 <div id="bws_save_settings_notice" class="updated fade below-h2" style="display:none;">
817 <p>
818 <strong><?php esc_html_e( 'Notice', 'bestwebsoft' ); ?></strong>: <?php esc_html_e( "The plugin's settings have been changed.", 'bestwebsoft' ); ?>
819 <a class="bws_save_anchor" href="#bws-submit-button"><?php esc_html_e( 'Save Changes', 'bestwebsoft' ); ?></a>
820 </p>
821 </div>
822 <?php
823 }
824 }
825
826 if ( ! function_exists( 'bws_hide_premium_options' ) ) {
827 /**
828 * Function for hide premium options
829 *
830 * @param array $options Plugin options.
831 * @echo string
832 */
833 function bws_hide_premium_options( $options ) {
834 if ( ! isset( $options['hide_premium_options'] ) || ! is_array( $options['hide_premium_options'] ) ) {
835 $options['hide_premium_options'] = array();
836 }
837
838 $options['hide_premium_options'][] = get_current_user_id();
839
840 return array(
841 'message' => esc_html__( 'You can always look at premium options by checking the "Pro Options" in the "Misc" tab.', 'bestwebsoft' ),
842 'options' => $options,
843 );
844 }
845 }
846
847 if ( ! function_exists( 'bws_hide_premium_options_check' ) ) {
848 /**
849 * Function for check checkbox for hide premium options
850 *
851 * @param array $options Plugin options.
852 * @return bool
853 */
854 function bws_hide_premium_options_check( $options ) {
855 if ( ! empty( $options['hide_premium_options'] ) && in_array( get_current_user_id(), $options['hide_premium_options'] ) ) {
856 return true;
857 } else {
858 return false;
859 }
860 }
861 }
862
863 if ( ! function_exists( 'bws_plugins_admin_init' ) ) {
864 /**
865 * Function init fir dashboard
866 */
867 function bws_plugins_admin_init() {
868 $page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : '';
869 if ( isset( $_GET['bws_activate_plugin'] ) && check_admin_referer( 'bws_activate_plugin' . sanitize_text_field( wp_unslash( $_GET['bws_activate_plugin'] ) ) ) ) {
870
871 $plugin = isset( $_GET['bws_activate_plugin'] ) ? sanitize_text_field( wp_unslash( $_GET['bws_activate_plugin'] ) ) : '';
872 $result = activate_plugin( $plugin, '', is_network_admin() );
873 if ( is_wp_error( $result ) ) {
874 if ( 'unexpected_output' === $result->get_error_code() ) {
875 $redirect = self_admin_url( 'admin.php?page=bws_panel&error=true&charsout=' . strlen( $result->get_error_data() ) . '&plugin=' . $plugin );
876 wp_safe_redirect( add_query_arg( '_error_nonce', wp_create_nonce( 'plugin-activation-error_' . $plugin ), $redirect ) );
877 exit();
878 } else {
879 wp_die( esc_html( $result ) );
880 }
881 }
882
883 if ( ! is_network_admin() ) {
884 $recent = (array) get_option( 'recently_activated' );
885 unset( $recent[ $plugin ] );
886 update_option( 'recently_activated', $recent );
887 } else {
888 $recent = (array) get_site_option( 'recently_activated' );
889 unset( $recent[ $plugin ] );
890 update_site_option( 'recently_activated', $recent );
891 }
892 /**
893 * @deprecated 1.9.8 (15.12.2016)
894 */
895 $is_main_page = in_array( $page, array( 'bws_panel', 'bws_themes', 'bws_system_status' ) );
896 $tab = isset( $_GET['tab'] ) ? sanitize_text_field( wp_unslash( $_GET['tab'] ) ) : '';
897
898 if ( $is_main_page ) {
899 $current_page = 'admin.php?page=' . $page;
900 } else {
901 $current_page = isset( $_GET['tab'] ) ? 'admin.php?page=' . $page . '&tab=' . $tab : 'admin.php?page=' . $page;
902 }
903 /*end deprecated */
904
905 wp_safe_redirect( self_admin_url( esc_url( $current_page . '&activate=true' ) ) );
906 exit();
907 }
908
909 if ( 'bws_panel' === $page || strpos( $page, '-bws-panel' ) ) {
910 if ( ! session_id() ) {
911 @session_start();
912 }
913 }
914
915 bws_add_editor_buttons();
916 }
917 }
918
919 if ( ! function_exists( 'bws_admin_enqueue_scripts' ) ) {
920 /**
921 * Function add scripts ans syles for dashboard
922 */
923 function bws_admin_enqueue_scripts() {
924 global $wp_scripts,
925 $hook_suffix,
926 $post_type,
927 $bws_plugin_banner_go_pro, $bws_plugin_banner_timeout, $bstwbsftwppdtplgns_banner_array,
928 $bws_shortcode_list,
929 $wp_filesystem,
930 $bws_plugins,
931 $pagenow;
932
933 $page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : '';
934
935 wp_enqueue_style( 'bws-admin-css', bws_menu_url( 'css/general_style.css' ), array(), '2.4.2' );
936 wp_enqueue_script( 'bws-admin-scripts', bws_menu_url( 'js/general_script.js' ), array( 'jquery', 'jquery-ui-tooltip' ) );
937
938 $plugin_dir = explode( '/', plugin_basename( __FILE__ ) )[0];
939 $plugin_file = array_keys( get_plugins( "/$plugin_dir" ) )[0];
940
941 $include_jquery_ui = false;
942 if ( ! empty( $bws_plugins ) ) {
943 $admin_page_free = $pagenow . '?page=' . str_replace( '-pro', '', $page );
944
945 foreach ( $bws_plugins as $bws_plugin ) {
946 if ( $admin_page_free === $bws_plugin['settings'] ) {
947 $include_jquery_ui = true;
948 break;
949 }
950 }
951 }
952
953 if ( in_array( $page, array( 'bws_panel', 'bws_themes', 'bws_system_status', $plugin_file ) ) || $include_jquery_ui || strpos( $page, '-bws-panel' ) ) {
954 $jquery_ui_version = isset( $wp_scripts->registered['jquery-ui-core']->ver ) ? $wp_scripts->registered['jquery-ui-core']->ver : '1.12.1';
955 WP_Filesystem();
956 if ( ! $wp_filesystem->exists( dirname( __FILE__ ) . '/css/jquery-ui-styles/' . $jquery_ui_version . '/' ) ) {
957 $jquery_ui_version = '1.12.1';
958 }
959 wp_enqueue_style( 'jquery-ui-style', bws_menu_url( 'css/jquery-ui-styles/' . $jquery_ui_version . '/jquery-ui.css', array(), $jquery_ui_version ) );
960 wp_enqueue_style( 'bws_menu_style', bws_menu_url( 'css/style.css' ), array(), '2.4.2' );
961 wp_enqueue_script( 'bws_menu_script', bws_menu_url( 'js/bws_menu.js' ), array(), '2.4.2', true );
962 wp_enqueue_script( 'theme-install' );
963 add_thickbox();
964 wp_enqueue_script( 'plugin-install' );
965 }
966
967 if ( 'plugins.php' === $hook_suffix ) {
968 if ( ! empty( $bws_plugin_banner_go_pro ) || ! empty( $bws_plugin_banner_timeout ) ) {
969 wp_enqueue_script( 'bws_menu_cookie', bws_menu_url( 'js/c_o_o_k_i_e.js' ) );
970
971 if ( ! empty( $bws_plugin_banner_go_pro ) ) {
972
973 foreach ( $bstwbsftwppdtplgns_banner_array as $value ) {
974 if ( isset( $bws_plugin_banner_go_pro[ $value[0] ] ) && ! isset( $_COOKIE[ $value[0] ] ) ) {
975 $prefix = $bws_plugin_banner_go_pro[ $value[0] ]['prefix'];
976
977 $script = "(function($) {
978 $(document).ready( function() {
979 var hide_message = $.cookie( '" . $prefix . "_hide_banner_on_plugin_page' );
980 if ( hide_message === 'true' ) {
981 $( '." . $prefix . "_message' ).css( 'display', 'none' );
982 } else {
983 $( '." . $prefix . "_message' ).css( 'display', 'block' );
984 };
985 $( '." . $prefix . "_close_icon' ).click( function() {
986 $( '." . $prefix . "_message' ).css( 'display', 'none' );
987 $.cookie( '" . $prefix . "_hide_banner_on_plugin_page', 'true', { expires: 32, secure: true } );
988 });
989 });
990 })(jQuery);";
991
992 wp_register_script( $prefix . '_hide_banner_on_plugin_page', '' );
993 wp_enqueue_script( $prefix . '_hide_banner_on_plugin_page' );
994 wp_add_inline_script( $prefix . '_hide_banner_on_plugin_page', sprintf( $script ) );
995 break;
996 }
997 }
998 }
999
1000 if ( ! empty( $bws_plugin_banner_timeout ) ) {
1001 $script = '(function($) {
1002 $(document).ready( function() {';
1003
1004 foreach ( $bws_plugin_banner_timeout as $banner_value ) {
1005 $script .= "var hide_message = $.cookie( '" . $banner_value['prefix'] . "_timeout_hide_banner_on_plugin_page' );
1006 if ( hide_message === 'true' ) {
1007 $( '." . $banner_value['prefix'] . "_message_timeout' ).css( 'display', 'none' );
1008 } else {
1009 $( '." . $banner_value['prefix'] . "_message_timeout' ).css( 'display', 'block' );
1010 }
1011 $( '." . $banner_value['prefix'] . "_close_icon' ).click( function() {
1012 $( '." . $banner_value['prefix'] . "_message_timeout' ).css( 'display', 'none' );
1013 $.cookie( '" . $banner_value['prefix'] . "_timeout_hide_banner_on_plugin_page', 'true', { expires: 30, secure: true } );
1014 });";
1015 }
1016
1017 $script .= '});
1018 })(jQuery);';
1019
1020 wp_register_script( 'plugin_banner_timeout_hide', '' );
1021 wp_enqueue_script( 'plugin_banner_timeout_hide' );
1022 wp_add_inline_script( 'plugin_banner_timeout_hide', sprintf( $script ) );
1023 }
1024 }
1025
1026 if ( ! defined( 'DOING_AJAX' ) ) {
1027 wp_enqueue_style( 'bws-modal-css', bws_menu_url( 'css/modal.css' ) );
1028
1029 bws_add_deactivation_feedback_dialog_box();
1030 }
1031 }
1032
1033 if ( 'multilanguage-languages.php' === $page ) {
1034 wp_enqueue_style( 'bws-modal-css', bws_menu_url( 'css/modal.css' ) );
1035 }
1036
1037 if ( ! empty( $bws_shortcode_list ) ) {
1038 /* TinyMCE Shortcode Plugin */
1039 $script = "var bws_shortcode_button = {
1040 'label': '" . esc_attr__( 'Add BWS Shortcode', 'bestwebsoft' ) . "',
1041 'title': '" . esc_attr__( 'Add BWS Plugins Shortcode', 'bestwebsoft' ) . "',
1042 'function_name': [";
1043 foreach ( $bws_shortcode_list as $value ) {
1044 if ( isset( $value['js_function'] ) ) {
1045 $script .= "'" . $value['js_function'] . "',";
1046 }
1047 }
1048 $script .= ']
1049 };';
1050 wp_register_script( 'bws_shortcode_button', '' );
1051 wp_enqueue_script( 'bws_shortcode_button' );
1052 wp_add_inline_script( 'bws_shortcode_button', sprintf( $script ) );
1053
1054 /* TinyMCE Shortcode Plugin */
1055 if ( isset( $post_type ) && in_array( $post_type, array( 'post', 'page' ) ) ) {
1056 $tooltip_args = array(
1057 'tooltip_id' => 'bws_shortcode_button_tooltip',
1058 'css_selector' => '.mce-bws_shortcode_button',
1059 'actions' => array(
1060 'click' => false,
1061 'onload' => true,
1062 ),
1063 'content' => '<h3>' . esc_html__( 'Add shortcode', 'bestwebsoft' ) . '</h3><p>' . esc_html__( "Add BestWebSoft plugins' shortcodes using this button.", 'bestwebsoft' ) . '</p>',
1064 'position' => array(
1065 'edge' => 'right',
1066 ),
1067 'set_timeout' => 2000,
1068 );
1069 bws_add_tooltip_in_admin( $tooltip_args );
1070 }
1071 }
1072 }
1073 }
1074
1075 if ( ! function_exists( 'bws_enqueue_settings_scripts' ) ) {
1076 /**
1077 * Add styles and scripts for Bws_Settings_Tabs
1078 *
1079 * @since 1.9.8
1080 */
1081 function bws_enqueue_settings_scripts() {
1082 wp_enqueue_script( 'jquery-ui-resizable' );
1083 wp_enqueue_script( 'jquery-ui-tabs' );
1084 wp_enqueue_style( 'bws-modal-css', bws_menu_url( 'css/modal.css' ), array(), '2.4.2' );
1085 }
1086 }
1087
1088 if ( ! function_exists( 'bws_plugins_admin_head' ) ) {
1089 /**
1090 * Function add syles into admin head
1091 *
1092 * @since 1.9.8
1093 */
1094 function bws_plugins_admin_head() {
1095 $page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : '';
1096
1097 if ( 'bws_panel' === $page ) {
1098 ?>
1099 <noscript>
1100 <style type="text/css">
1101 .bws_product_button {
1102 display: inline-block;
1103 }
1104 </style>
1105 </noscript>
1106 <?php
1107 }
1108 }
1109 }
1110
1111 if ( ! function_exists( 'bws_plugins_admin_footer' ) ) {
1112 /**
1113 * Function add syles into admin footer
1114 *
1115 * @since 1.9.8
1116 */
1117 function bws_plugins_admin_footer() {
1118 $screen = get_current_screen();
1119 if ( 'edit' === $screen->parent_base ) {
1120 bws_shortcode_media_button_popup();
1121 }
1122 }
1123 }
1124
1125 if ( ! function_exists( 'bws_plugins_include_codemirror' ) ) {
1126 /**
1127 * Function add style and scripts for older version
1128 *
1129 * @since 1.9.8
1130 */
1131 function bws_plugins_include_codemirror() {
1132 global $wp_version;
1133 if ( version_compare( $wp_version, '4.9.0', '>=' ) ) {
1134 wp_enqueue_style( 'wp-codemirror' );
1135 wp_enqueue_script( 'wp-codemirror' );
1136 }
1137 }
1138 }
1139
1140 if ( ! function_exists( 'bws_add_tooltip_in_admin' ) ) {
1141 /**
1142 * Tooltip block
1143 *
1144 * @param array $tooltip_args Args for tooltip.
1145 */
1146 function bws_add_tooltip_in_admin( $tooltip_args = array() ) {
1147 new BWS_Admin_Tooltip( $tooltip_args );
1148 }
1149 }
1150
1151 if ( ! class_exists( 'BWS_Admin_Tooltip' ) ) {
1152 /**
1153 * Class for Tooltip
1154 *
1155 * @since 1.9.8
1156 */
1157 class BWS_Admin_Tooltip {
1158 private $tooltip_args;
1159
1160 /**
1161 * Tooltip construct
1162 *
1163 * @param array $tooltip_args Args for tooltip.
1164 */
1165 public function __construct( $tooltip_args ) {
1166 global $bstwbsftwppdtplgns_tooltip_script_add;
1167
1168 /* Default arguments */
1169 $tooltip_args_default = array(
1170 'tooltip_id' => false,
1171 'css_selector' => false,
1172 'actions' => array(
1173 'click' => true,
1174 'onload' => false,
1175 ),
1176 'buttons' => array(
1177 'close' => array(
1178 'type' => 'dismiss',
1179 'text' => esc_html__( 'Close', 'bestwebsoft' ),
1180 ),
1181 ),
1182 'position' => array(
1183 'edge' => 'top',
1184 'align' => 'center',
1185 'pos-left' => 0,
1186 'pos-top' => 0,
1187 'zindex' => 10000,
1188 ),
1189 'set_timeout' => 0,
1190 );
1191 $tooltip_args = array_merge( $tooltip_args_default, $tooltip_args );
1192 /* Check that our merged array has default values */
1193 foreach ( $tooltip_args_default as $arg_key => $arg_value ) {
1194 if ( is_array( $arg_value ) ) {
1195 foreach ( $arg_value as $key => $value ) {
1196 if ( ! isset( $tooltip_args[ $arg_key ][ $key ] ) ) {
1197 $tooltip_args[ $arg_key ][ $key ] = $tooltip_args_default[ $arg_key ][ $key ];
1198 }
1199 }
1200 }
1201 }
1202 /* Check if tooltip is dismissed */
1203 if ( true === $tooltip_args['actions']['onload'] ) {
1204 if ( in_array( $tooltip_args['tooltip_id'], array_filter( explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ) ) ) ) {
1205 $tooltip_args['actions']['onload'] = false;
1206 }
1207 }
1208 /* Check entered data */
1209 if ( false === $tooltip_args['tooltip_id'] || false === $tooltip_args['css_selector'] || ( false === $tooltip_args['actions']['click'] && false === $tooltip_args['actions']['onload'] ) ) {
1210 /* if not enough data to output a tooltip or both actions (click, onload) are false */
1211 return;
1212 } else {
1213 /* check position */
1214 if ( ! in_array( $tooltip_args['position']['edge'], array( 'left', 'right', 'top', 'bottom' ) ) ) {
1215 $tooltip_args['position']['edge'] = 'top';
1216 }
1217 if ( ! in_array( $tooltip_args['position']['align'], array( 'top', 'bottom', 'left', 'right', 'center' ) ) ) {
1218 $tooltip_args['position']['align'] = 'center';
1219 }
1220 }
1221 /* fix position */
1222 switch ( $tooltip_args['position']['edge'] ) {
1223 case 'left':
1224 case 'right':
1225 switch ( $tooltip_args['position']['align'] ) {
1226 case 'top':
1227 case 'bottom':
1228 $tooltip_args['position']['align'] = 'center';
1229 break;
1230 }
1231 break;
1232 case 'top':
1233 case 'bottom':
1234 if ( 'left' === $tooltip_args['position']['align'] ) {
1235 $tooltip_args['position']['pos-left'] -= 65;
1236 }
1237 break;
1238 }
1239 $this->tooltip_args = $tooltip_args;
1240 /* add styles and scripts */
1241 wp_enqueue_style( 'wp-pointer' );
1242 wp_enqueue_script( 'wp-pointer' );
1243 /* add script that displays our tooltip */
1244 if ( ! isset( $bstwbsftwppdtplgns_tooltip_script_add ) ) {
1245 wp_enqueue_script( 'bws-tooltip-script', bws_menu_url( 'js/bws_tooltip.js' ), array(), '2.4.2' );
1246 $bstwbsftwppdtplgns_tooltip_script_add = true;
1247 }
1248 $tooltip_args = $this->tooltip_args;
1249
1250 $script = '(function($) {
1251 $(document).ready( function() {
1252 $.bwsTooltip( ' . wp_json_encode( $tooltip_args ) . ' );
1253 })
1254 })(jQuery);';
1255 wp_register_script( 'bws-tooltip-script-single-' . $this->tooltip_args['tooltip_id'], '' );
1256 wp_enqueue_script( 'bws-tooltip-script-single-' . $this->tooltip_args['tooltip_id'] );
1257 wp_add_inline_script( 'bws-tooltip-script-single-' . $this->tooltip_args['tooltip_id'], sprintf( $script ) );
1258 }
1259 }
1260 }
1261
1262 if ( ! function_exists( 'bws_form_restore_default_confirm' ) ) {
1263 /**
1264 * Function display confirm
1265 *
1266 * @since 1.9.8
1267 * @param string $plugin_basename Plugin basename.
1268 */
1269 function bws_form_restore_default_confirm( $plugin_basename ) {
1270 ?>
1271 <div>
1272 <p><?php esc_html_e( 'Are you sure you want to restore default settings?', 'bestwebsoft' ); ?></p>
1273 <form method="post" action="">
1274 <p>
1275 <button class="button button-primary" name="bws_restore_confirm"><?php esc_html_e( 'Yes, restore all settings', 'bestwebsoft' ); ?></button>
1276 <button class="button" name="bws_restore_deny"><?php esc_html_e( 'No, go back to the settings page', 'bestwebsoft' ); ?></button>
1277 <?php wp_nonce_field( $plugin_basename, 'bws_settings_nonce_name' ); ?>
1278 </p>
1279 </form>
1280 </div>
1281 <?php
1282 }
1283 }
1284
1285 if ( ! function_exists( 'bws_add_editor_buttons' ) ) {
1286 /**
1287 * Function for shortcode
1288 *
1289 * @since 1.9.8
1290 */
1291 function bws_add_editor_buttons() {
1292 global $bws_shortcode_list;
1293 if ( ! empty( $bws_shortcode_list ) && current_user_can( 'edit_posts' ) && current_user_can( 'edit_pages' ) ) {
1294 add_filter( 'mce_external_plugins', 'bws_add_buttons' );
1295 add_filter( 'mce_buttons', 'bws_register_buttons' );
1296 }
1297 }
1298 }
1299
1300 if ( ! function_exists( 'bws_add_buttons' ) ) {
1301 /**
1302 * Function add button for editor
1303 *
1304 * @since 1.9.8
1305 * @param array $plugin_array Editor scripts.
1306 */
1307 function bws_add_buttons( $plugin_array ) {
1308 $plugin_array['add_bws_shortcode'] = bws_menu_url( 'js/shortcode-button.js' );
1309 return $plugin_array;
1310 }
1311 }
1312
1313 if ( ! function_exists( 'bws_register_buttons' ) ) {
1314 /**
1315 * Function register button for editor
1316 *
1317 * @since 1.9.8
1318 * @param array $buttons Editor buttons.
1319 */
1320 function bws_register_buttons( $buttons ) {
1321 array_push( $buttons, 'add_bws_shortcode' ); /* dropcap', 'recentposts */
1322 return $buttons;
1323 }
1324 }
1325
1326 if ( ! function_exists( 'bws_shortcode_media_button_popup' ) ) {
1327 /**
1328 * Function Generate inline content for the popup window when the "bws shortcode" button is clicked
1329 *
1330 * @since 1.9.8
1331 */
1332 function bws_shortcode_media_button_popup() {
1333 global $bws_shortcode_list;
1334
1335 if ( ! empty( $bws_shortcode_list ) ) {
1336 ?>
1337 <div id="bws_shortcode_popup" style="display:none;">
1338 <div id="bws_shortcode_popup_block">
1339 <div id="bws_shortcode_select_plugin">
1340 <h4><?php esc_html_e( 'Plugin', 'bestwebsoft' ); ?></h4>
1341 <select name="bws_shortcode_select" id="bws_shortcode_select">
1342 <?php foreach ( $bws_shortcode_list as $key => $value ) { ?>
1343 <option value="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $value['name'] ); ?></option>
1344 <?php } ?>
1345 </select>
1346 </div>
1347 <div class="clear"></div>
1348 <div id="bws_shortcode_content">
1349 <h4><?php esc_html_e( 'Shortcode settings', 'bestwebsoft' ); ?></h4>
1350 <?php
1351 $ws_shortcode_button_content = apply_filters( 'bws_shortcode_button_content', '' );
1352 if ( ! empty( $ws_shortcode_button_content ) ) {
1353 echo wp_kses_post( $ws_shortcode_button_content );
1354 }
1355 ?>
1356 </div>
1357 <div class="clear"></div>
1358 <div id="bws_shortcode_content_bottom">
1359 <p><?php esc_html_e( 'The shortcode will be inserted', 'bestwebsoft' ); ?></p>
1360 <div id="bws_shortcode_block"><div id="bws_shortcode_display"></div></div>
1361 </div>
1362 </div>
1363 </div>
1364 <?php
1365 }
1366 }
1367 }
1368
1369 if ( ! function_exists( 'bws_shortcode_output' ) ) {
1370 /**
1371 * Output shortcode in a special block
1372 *
1373 * @since 1.9.8
1374 * @param string $shortcode Shortcode string.
1375 */
1376 function bws_shortcode_output( $shortcode ) {
1377 ?>
1378 <span class="bws_shortcode_output"><input type="text" onfocus="this.select();" readonly="readonly" value="<?php echo esc_attr( $shortcode ); ?>" class="large-text bws_no_bind_notice"></span>
1379 <?php
1380 }
1381 }
1382
1383 if ( ! function_exists( 'bws_add_help_box' ) ) {
1384 /**
1385 * Output tooltip
1386 *
1387 * @since 1.9.8
1388 * @param string $content HTML content for the tooltip.
1389 * @param string $class Can be standart "bws-hide-for-mobile" (tooltip will be hidden in 782px) and "bws-auto-width" (need for img) or some custom class.
1390 */
1391 function bws_add_help_box( $content, $class = '' ) {
1392 return '<span class="bws_help_box dashicons dashicons-editor-help ' . $class . ' hide-if-no-js">
1393 <span class="bws_hidden_help_text">' . $content . '</span>
1394 </span>';
1395 }
1396 }
1397
1398 if ( ! function_exists( 'bws_help_tab' ) ) {
1399 /**
1400 * Function add help tab
1401 *
1402 * @since 1.9.8
1403 * @param string $screen Screen name.
1404 * @param array $args Args for screen.
1405 */
1406 function bws_help_tab( $screen, $args ) {
1407 $url = ( ! empty( $args['section'] ) ) ? 'https://support.bestwebsoft.com/hc/en-us/sections/' . $args['section'] : 'https://support.bestwebsoft.com/';
1408
1409 $content = '<p><a href="' . esc_url( $url ) . '" target="_blank">' . __( 'Visit Help Center', 'bestwebsoft' ) . '</a></p>';
1410
1411 $screen->add_help_tab(
1412 array(
1413 'id' => $args['id'] . '_help_tab',
1414 'title' => esc_html__( 'FAQ', 'bestwebsoft' ),
1415 'content' => wp_kses_post( $content ),
1416 )
1417 );
1418
1419 $screen->set_help_sidebar(
1420 '<p><strong>' . esc_html__( 'For more information:', 'bestwebsoft' ) . '</strong></p>' .
1421 '<p><a href="https://bestwebsoft.com/documentation/" target="_blank">' . esc_html__( 'Documentation', 'bestwebsoft' ) . '</a></p>' .
1422 '<p><a href="https://www.youtube.com/user/bestwebsoft/playlists?flow=grid&sort=da&view=1" target="_blank">' . esc_html__( 'Video Instructions', 'bestwebsoft' ) . '</a></p>' .
1423 '<p><a href="https://support.bestwebsoft.com/hc/en-us/requests/new" target="_blank">' . esc_html__( 'Submit a Request', 'bestwebsoft' ) . '</a></p>'
1424 );
1425 }
1426 }
1427
1428 if ( ! function_exists( 'bws_enqueue_custom_code_css_js' ) ) {
1429 /**
1430 * Function add css and js
1431 *
1432 * @since 1.9.8
1433 */
1434 function bws_enqueue_custom_code_css_js() {
1435 global $bstwbsftwppdtplgns_options;
1436
1437 if ( ! isset( $bstwbsftwppdtplgns_options ) ) {
1438 $bstwbsftwppdtplgns_options = ( function_exists( 'is_multisite' ) && is_multisite() ) ? get_site_option( 'bstwbsftwppdtplgns_options' ) : get_option( 'bstwbsftwppdtplgns_options' );
1439 }
1440
1441 if ( ! empty( $bstwbsftwppdtplgns_options['custom_code'] ) ) {
1442 $is_multisite = is_multisite();
1443 if ( $is_multisite ) {
1444 $blog_id = get_current_blog_id();
1445 }
1446
1447 if ( ! $is_multisite && ! empty( $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.css'] ) ) {
1448 wp_enqueue_style( 'bws-custom-style', $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.css'], array(), '2.4.2' );
1449 } elseif ( $is_multisite && ! empty( $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.css'] ) ) {
1450 wp_enqueue_style( 'bws-custom-style', $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.css'], array(), '2.4.2' );
1451 }
1452
1453 if ( ! $is_multisite && ! empty( $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.js'] ) ) {
1454 wp_enqueue_script( 'bws-custom-style', $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.js'], array(), '2.4.2' );
1455 } elseif ( $is_multisite && ! empty( $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.js'] ) ) {
1456 wp_enqueue_script( 'bws-custom-style', $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.js'], array(), '2.4.2' );
1457 }
1458 }
1459 }
1460 }
1461
1462 if ( ! function_exists( 'bws_enqueue_custom_code_php' ) ) {
1463 /**
1464 * Function add custom php code
1465 *
1466 * @since 1.9.8
1467 */
1468 function bws_enqueue_custom_code_php() {
1469 if ( is_admin() ) {
1470 return;
1471 }
1472
1473 global $bstwbsftwppdtplgns_options;
1474
1475 if ( ! isset( $bstwbsftwppdtplgns_options ) ) {
1476 $bstwbsftwppdtplgns_options = ( function_exists( 'is_multisite' ) && is_multisite() ) ? get_site_option( 'bstwbsftwppdtplgns_options' ) : get_option( 'bstwbsftwppdtplgns_options' );
1477 }
1478
1479 if ( ! empty( $bstwbsftwppdtplgns_options['custom_code'] ) ) {
1480
1481 $is_multisite = is_multisite();
1482 if ( $is_multisite ) {
1483 $blog_id = get_current_blog_id();
1484 }
1485
1486 if ( ! $is_multisite && ! empty( $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.php'] ) ) {
1487 if ( file_exists( $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.php'] ) ) {
1488 if ( ! defined( 'BWS_GLOBAL' ) ) {
1489 define( 'BWS_GLOBAL', true );
1490 }
1491 require_once $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.php'];
1492 } else {
1493 unset( $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.php'] );
1494 if ( $is_multisite ) {
1495 update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options );
1496 } else {
1497 update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options );
1498 }
1499 }
1500 } elseif ( $is_multisite && ! empty( $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.php'] ) ) {
1501 if ( file_exists( $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.php'] ) ) {
1502 if ( ! defined( 'BWS_GLOBAL' ) ) {
1503 define( 'BWS_GLOBAL', true );
1504 }
1505 require_once $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.php'];
1506 } else {
1507 unset( $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.php'] );
1508 if ( $is_multisite ) {
1509 update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options );
1510 } else {
1511 update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options );
1512 }
1513 }
1514 }
1515 }
1516 }
1517 }
1518
1519 if ( ! function_exists( 'bws_delete_plugin' ) ) {
1520 /**
1521 * Function delete plugin
1522 *
1523 * @since 1.9.8
1524 * @param string $basename Plugin basename.
1525 */
1526 function bws_delete_plugin( $basename ) {
1527 global $bstwbsftwppdtplgns_options;
1528
1529 $is_multisite = is_multisite();
1530 if ( $is_multisite ) {
1531 $blog_id = get_current_blog_id();
1532 }
1533
1534 if ( ! isset( $bstwbsftwppdtplgns_options ) ) {
1535 $bstwbsftwppdtplgns_options = ( $is_multisite ) ? get_site_option( 'bstwbsftwppdtplgns_options' ) : get_option( 'bstwbsftwppdtplgns_options' );
1536 }
1537
1538 /* remove bws_menu versions */
1539 unset( $bstwbsftwppdtplgns_options['bws_menu']['version'][ $basename ] );
1540 /* remove track usage data */
1541 if ( isset( $bstwbsftwppdtplgns_options['bws_menu']['track_usage']['products'][ $basename ] ) ) {
1542 unset( $bstwbsftwppdtplgns_options['bws_menu']['track_usage']['products'][ $basename ] );
1543 }
1544 /* if empty ['bws_menu']['version'] - there is no other bws plugins - delete all */
1545 if ( empty( $bstwbsftwppdtplgns_options['bws_menu']['version'] ) ) {
1546 /* remove options */
1547 if ( $is_multisite ) {
1548 delete_site_option( 'bstwbsftwppdtplgns_options' );
1549 } else {
1550 delete_option( 'bstwbsftwppdtplgns_options' );
1551 }
1552
1553 /* remove custom_code */
1554 if ( $is_multisite ) {
1555 global $wpdb;
1556 $old_blog = $wpdb->blogid;
1557 /* Get all blog ids */
1558 $blogids = $wpdb->get_col( "SELECT `blog_id` FROM $wpdb->blogs" );
1559 foreach ( $blogids as $blog_id ) {
1560 switch_to_blog( $blog_id );
1561 $upload_dir = wp_upload_dir();
1562 $folder = $upload_dir['basedir'] . '/bws-custom-code';
1563 if ( file_exists( $folder ) && is_dir( $folder ) ) {
1564 array_map( 'unlink', glob( "$folder/*" ) );
1565 rmdir( $folder );
1566 }
1567 }
1568 switch_to_blog( $old_blog );
1569 } else {
1570 $upload_dir = wp_upload_dir();
1571 $folder = $upload_dir['basedir'] . '/bws-custom-code';
1572 if ( file_exists( $folder ) && is_dir( $folder ) ) {
1573 array_map( 'unlink', glob( "$folder/*" ) );
1574 rmdir( $folder );
1575 }
1576 }
1577 }
1578 }
1579 }
1580
1581 add_action( 'admin_init', 'bws_plugins_admin_init' );
1582 add_action( 'admin_enqueue_scripts', 'bws_admin_enqueue_scripts' );
1583 add_action( 'admin_head', 'bws_plugins_admin_head' );
1584 add_action( 'admin_footer', 'bws_plugins_admin_footer' );
1585
1586 add_action( 'admin_notices', 'bws_admin_notices', 30 );
1587
1588 add_action( 'wp_enqueue_scripts', 'bws_enqueue_custom_code_css_js', 20 );
1589
1590 bws_enqueue_custom_code_php();
1591