/bws_menu/bws_functions.php

  1. <?php 
  2. /** 
  3. * General functions for BestWebSoft plugins 
  4. */ 
  5.  
  6. require( dirname( __FILE__ ) . '/deprecated.php' ); 
  7.  
  8. /** 
  9. * Function to add 'bestwebsoft' slug for BWS_Menu MO file if BWS_Menu loaded from theme. 
  10. * 
  11. * @since 1.9.7 
  12. */ 
  13. if ( ! function_exists ( 'bws_get_mofile' ) ) { 
  14. function bws_get_mofile( $mofile, $domain ) { 
  15. if ( 'bestwebsoft' == $domain ) { 
  16. $locale = get_locale(); 
  17. return str_replace( $locale, "bestwebsoft-{$locale}", $mofile ); 
  18.  
  19. return $mofile; 
  20.  
  21. /** Internationalization, first(!) */ 
  22. if ( isset( $bws_menu_source ) && 'themes' == $bws_menu_source ) { 
  23. add_filter( 'load_textdomain_mofile', 'bws_get_mofile', 10, 2 ); 
  24. load_theme_textdomain( 'bestwebsoft', get_stylesheet_directory() . '/inc/bws_menu/languages' ); 
  25. remove_filter( 'load_textdomain_mofile', 'bws_get_mofile' ); 
  26. } else { 
  27. load_plugin_textdomain( 'bestwebsoft', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); 
  28.  
  29. /** 
  30. * Function to getting url to current BWS_Menu. 
  31. * 
  32. * @since 1.9.7 
  33. */ 
  34. if ( ! function_exists ( 'bws_menu_url' ) ) { 
  35. if ( ! isset( $bws_menu_source ) || 'plugins' == $bws_menu_source ) { 
  36. function bws_menu_url( $path = '' ) { 
  37. return plugins_url( $path, __FILE__ ); 
  38. } else { 
  39. function bws_menu_url( $path = '' ) { 
  40. $bws_menu_current_dir = str_replace( '\\', '/', dirname( __FILE__ ) ); 
  41. $bws_menu_abspath = str_replace( '\\', '/', ABSPATH ); 
  42. $bws_menu_current_url = site_url( str_replace( $bws_menu_abspath, '', $bws_menu_current_dir ) ); 
  43.  
  44. return sprintf( '%s/%s', $bws_menu_current_url, $path ); 
  45.  
  46. /** 
  47. * Function check if plugin is compatible with current WP version 
  48. * @return void 
  49. */ 
  50. if ( ! function_exists ( 'bws_wp_min_version_check' ) ) { 
  51. function bws_wp_min_version_check( $plugin_basename, $plugin_info, $require_wp, $min_wp = false ) { 
  52. global $wp_version, $bws_versions_notice_array; 
  53. if ( false == $min_wp ) 
  54. $min_wp = $require_wp; 
  55. if ( version_compare( $wp_version, $min_wp, "<" ) ) { 
  56. include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); 
  57. if ( is_plugin_active( $plugin_basename ) ) { 
  58. deactivate_plugins( $plugin_basename ); 
  59. $admin_url = ( function_exists( 'get_admin_url' ) ) ? get_admin_url( null, 'plugins.php' ) : esc_url( '/wp-admin/plugins.php' ); 
  60. wp_die( 
  61. sprintf( 
  62. "<strong>%s</strong> %s <strong>WordPress %s</strong> %s <br /><br />%s <a href='%s'>%s</a>.",  
  63. $plugin_info['Name'],  
  64. __( 'requires', 'bestwebsoft' ),  
  65. $require_wp,  
  66. __( 'or higher, that is why it has been deactivated! Please upgrade WordPress and try again.', 'bestwebsoft' ),  
  67. __( 'Back to the WordPress', 'bestwebsoft' ),  
  68. $admin_url,  
  69. __( 'Plugins page', 'bestwebsoft' ) 
  70. ); 
  71. } elseif ( version_compare( $wp_version, $require_wp, "<" ) ) { 
  72. $bws_versions_notice_array[] = array( 'name' => $plugin_info['Name'], 'version' => $require_wp ); 
  73.  
  74. if ( ! function_exists( 'bws_plugin_reviews_block' ) ) { 
  75. function bws_plugin_reviews_block( $plugin_name, $plugin_slug ) { ?> 
  76. <div class="bws-plugin-reviews"> 
  77. <div class="bws-plugin-reviews-rate"> 
  78. <?php _e( 'Like the plugin?', 'bestwebsoft' ); ?> 
  79. <a href="http://wordpress.org/support/view/plugin-reviews/<?php echo $plugin_slug; ?>?filter=5" target="_blank" title="<?php echo $plugin_name; ?> reviews"> 
  80. <?php _e( 'Rate it', 'bestwebsoft' ); ?>  
  81. <span class="dashicons dashicons-star-filled"></span> 
  82. <span class="dashicons dashicons-star-filled"></span> 
  83. <span class="dashicons dashicons-star-filled"></span> 
  84. <span class="dashicons dashicons-star-filled"></span> 
  85. <span class="dashicons dashicons-star-filled"></span> 
  86. </a> 
  87. </div> 
  88. <div class="bws-plugin-reviews-support"> 
  89. <?php _e( 'Need help?', 'bestwebsoft' ); ?> 
  90. <a href="https://support.bestwebsoft.com"><?php _e( 'Visit Help Center', 'bestwebsoft' ); ?></a> 
  91. </div> 
  92. <div class="bws-plugin-reviews-donate"> 
  93. <?php _e( 'Want to support the plugin?', 'bestwebsoft' ); ?> 
  94. <a href="https://bestwebsoft.com/donate/"><?php _e( 'Donate', 'bestwebsoft' ); ?></a> 
  95. </div> 
  96. </div> 
  97. <?php } 
  98.  
  99. if ( ! function_exists ( 'bws_plugin_update_row' ) ) { 
  100. function bws_plugin_update_row( $plugin_key, $link_slug = false, $free_plugin_name = false ) { 
  101. global $bstwbsftwppdtplgns_options, $wp_version; 
  102. $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); 
  103. if ( isset( $bstwbsftwppdtplgns_options['wrong_license_key'][ $plugin_key ] ) ) { 
  104. $explode_plugin_key = explode( '/', $plugin_key ); 
  105. $class = ( $wp_version >= 4.6 ) ? 'active' : ''; 
  106. $style = ( $wp_version < 4.6 ) ? ' style="background-color: #FFEBE8;border-color: #CC0000;"' : ''; 
  107. $div_class = ( $wp_version >= 4.6 ) ? ' notice inline notice-warning notice-alt' : ''; 
  108. echo '<tr class="bws-plugin-update-tr plugin-update-tr ' . $class . '" id="' . $explode_plugin_key[0] . '-update" data-slug="' . $explode_plugin_key[0] . '" data-plugin="' . $plugin_key . '"> 
  109. <td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"> 
  110. <div class="update-message' . $div_class . '"' . $style . '>'; 
  111. if ( $wp_version >= 4.6 ) 
  112. echo '<p>'; 
  113. echo '<strong>' . __( 'WARNING: Illegal use notification', 'bestwebsoft' ) . '.</strong> ' . __( 'You can use one license of the Pro plugin for one domain only. Please check and edit your license or domain if necessary using you 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">' . __( 'Learn More', 'bestwebsoft' ) . '</a>'; 
  114. if ( $wp_version >= 4.6 ) 
  115. echo '</p>'; 
  116. echo '</div> 
  117. </td> 
  118. </tr>'; 
  119. } elseif ( isset( $bstwbsftwppdtplgns_options['time_out'][ $plugin_key ] ) && strtotime( $bstwbsftwppdtplgns_options['time_out'][ $plugin_key ] ) < strtotime( date("m/d/Y") ) ) { 
  120. $explode_plugin_key = explode( '/', $plugin_key ); 
  121. $class = ( $wp_version >= 4.6 ) ? 'active' : ''; 
  122. $style = ( $wp_version < 4.6 ) ? ' style="color: #8C0000;"' : ''; 
  123. $div_class = ( $wp_version >= 4.6 ) ? ' notice inline notice-warning notice-alt' : ''; 
  124. echo '<tr class="bws-plugin-update-tr plugin-update-tr ' . $class . '" id="' . $explode_plugin_key[0] . '-update" data-slug="' . $explode_plugin_key[0] . '" data-plugin="' . $plugin_key . '"> 
  125. <td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"> 
  126. <div class="update-message' . $div_class . '"' . $style . '>'; 
  127. if ( $wp_version >= 4.6 ) 
  128. echo '<p>'; 
  129. if ( isset( $bstwbsftwppdtplgns_options['trial'][ $plugin_key ] ) && $link_slug != false ) { 
  130. echo __( '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/' . $link_slug .'/">https://bestwebsoft.com/products/wordpress/plugins/' . $link_slug . '/</a>'; 
  131. } else { 
  132. echo __( '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">' . __( "Learn more", 'bestwebsoft' ) . '</a>'; 
  133. if ( $wp_version >= 4.6 ) 
  134. echo '</p>'; 
  135. echo '</div> 
  136. </td> 
  137. </tr>'; 
  138. } elseif ( isset( $bstwbsftwppdtplgns_options['trial'][ $plugin_key ] ) ) { 
  139. $explode_plugin_key = explode( '/', $plugin_key ); 
  140. $class = ( $wp_version >= 4.6 ) ? 'active' : ''; 
  141. $style = ( $wp_version < 4.6 ) ? ' style="color: #8C0000;"' : ''; 
  142. $div_class = ( $wp_version >= 4.6 ) ? ' notice inline notice-warning notice-alt' : ''; 
  143. echo '<tr class="bws-plugin-update-tr plugin-update-tr ' . $class . '" id="' . $explode_plugin_key[0] . '-update" data-slug="' . $explode_plugin_key[0] . '" data-plugin="' . $plugin_key . '"> 
  144. <td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"> 
  145. <div class="update-message' . $div_class . '"' . $style . '>'; 
  146. if ( $wp_version >= 4.6 ) 
  147. echo '<p>'; 
  148. if ( $free_plugin_name != false ) { 
  149. echo sprintf( __( 'Notice: You are using the Pro Trial license of %s plugin.', 'bestwebsoft' ), $free_plugin_name ); 
  150. } else { 
  151. _e( 'Notice: You are using the Pro Trial license of plugin.', 'bestwebsoft' ); 
  152. if ( isset( $bstwbsftwppdtplgns_options['time_out'][ $plugin_key ] ) ) 
  153. echo ' ' . __( "The Pro Trial license will expire on", 'bestwebsoft' ) . ' ' . $bstwbsftwppdtplgns_options['time_out'][ $plugin_key ] . '.'; 
  154. if ( $wp_version >= 4.6 ) 
  155. echo '</p>'; 
  156. echo '</div> 
  157. </td> 
  158. </tr>'; 
  159.  
  160. if ( ! function_exists( 'bws_admin_notices' ) ) { 
  161. function bws_admin_notices() { 
  162. global $bws_versions_notice_array, $bws_plugin_banner_to_settings, $bstwbsftwppdtplgns_options; 
  163.  
  164. /** versions notice */ 
  165. if ( ! empty( $bws_versions_notice_array ) ) { 
  166. foreach ( $bws_versions_notice_array as $key => $value ) { ?> 
  167. <div class="update-nag"><?php 
  168. echo sprintf( 
  169. "<strong>%s</strong> %s <strong>WordPress %s</strong> %s",  
  170. $value['name'],  
  171. __( 'requires', 'bestwebsoft' ),  
  172. $value['version'],  
  173. __( 'or higher! We do not guarantee that our plugin will work correctly. Please upgrade to WordPress latest version.', 'bestwebsoft' ) 
  174. ); 
  175. ?></div> 
  176. <?php } 
  177.  
  178. /** banner_to_settings notice */ 
  179. if ( ! empty( $bws_plugin_banner_to_settings ) ) { 
  180. if ( 1 == count( $bws_plugin_banner_to_settings ) ) { ?> 
  181. <div class="updated" style="padding: 0; margin: 0; border: none; background: none;"> 
  182. <div class="bws_banner_on_plugin_page bws_banner_to_settings"> 
  183. <div class="icon"> 
  184. <img title="" src="<?php echo esc_attr( $bws_plugin_banner_to_settings[0]['banner_url'] ); ?>" alt="" /> 
  185. </div> 
  186. <div class="text"> 
  187. <strong><?php printf( __( 'Thank you for installing %s plugin!', 'bestwebsoft' ), $bws_plugin_banner_to_settings[0]['plugin_info']['Name'] ); ?> </strong><br /> 
  188. <?php _e( "Let's get started", 'bestwebsoft' ); ?>: 
  189. <a href="<?php echo $bws_plugin_banner_to_settings[0]['settings_url']; ?>"><?php _e( 'Settings', 'bestwebsoft' ); ?></a> 
  190. <?php if ( false != $bws_plugin_banner_to_settings[0]['post_type_url'] ) { ?> 
  191. <?php _e( 'or', 'bestwebsoft' ); ?> 
  192. <a href="<?php echo $bws_plugin_banner_to_settings[0]['post_type_url']; ?>"><?php _e( 'Add New', 'bestwebsoft' ); ?></a> 
  193. <?php } ?> 
  194. </div> 
  195. <form action="" method="post"> 
  196. <button class="notice-dismiss bws_hide_settings_notice" title="<?php _e( 'Close notice', 'bestwebsoft' ); ?>"></button> 
  197. <input type="hidden" name="bws_hide_settings_notice_<?php echo $bws_plugin_banner_to_settings[0]['plugin_options_name']; ?>" value="hide" /> 
  198. <?php wp_nonce_field( plugin_basename( __FILE__ ), 'bws_settings_nonce_name' ); ?> 
  199. </form> 
  200. </div> 
  201. </div> 
  202. <?php } else { ?> 
  203. <div class="updated" style="padding: 0; margin: 0; border: none; background: none;"> 
  204. <div class="bws_banner_on_plugin_page bws_banner_to_settings_joint"> 
  205. <form action="" method="post"> 
  206. <button class="notice-dismiss bws_hide_settings_notice" title="<?php _e( 'Close notice', 'bestwebsoft' ); ?>"></button> 
  207. <div class="bws-text"> 
  208. <div class="icon"> 
  209. <span class="dashicons dashicons-admin-plugins"></span> 
  210. </div> 
  211. <strong><?php _e( 'Thank you for installing plugins by BestWebSoft!', 'bestwebsoft' ); ?></strong> 
  212. <div class="hide-if-no-js bws-more-links"> 
  213. <a href="#" class="bws-more"><?php _e( 'More Details', 'bestwebsoft' ); ?></a> 
  214. <a href="#" class="bws-less hidden"><?php _e( 'Less Details', 'bestwebsoft' ); ?></a> 
  215. </div> 
  216. <?php wp_nonce_field( plugin_basename( __FILE__ ), 'bws_settings_nonce_name' ); ?> 
  217. <div class="clear"></div> 
  218. </div> 
  219. <div class="bws-details hide-if-js"> 
  220. <?php foreach ( $bws_plugin_banner_to_settings as $value ) { ?> 
  221. <div> 
  222. <strong><?php echo str_replace( ' by BestWebSoft', '', $value['plugin_info']['Name'] ); ?></strong> <a href="<?php echo $value['settings_url']; ?>"><?php _e( 'Settings', 'bestwebsoft' ); ?></a> 
  223. <?php if ( false != $value['post_type_url'] ) { ?> 
  224.  | <a target="_blank" href="<?php echo $value['post_type_url']; ?>"><?php _e( 'Add New', 'bestwebsoft' ); ?></a> 
  225. <?php } ?> 
  226. <input type="hidden" name="bws_hide_settings_notice_<?php echo $value['plugin_options_name']; ?>" value="hide" /> 
  227. </div> 
  228. <?php } ?> 
  229. </div> 
  230. </div> 
  231. </form> 
  232. </div> 
  233. <?php } 
  234.  
  235. /** 
  236. * show notices about deprecated_function 
  237. * @since 1.9.8 
  238. */ 
  239. if ( ! empty( $bstwbsftwppdtplgns_options['deprecated_function'] ) ) { ?> 
  240. <div class="update-nag"> 
  241. <strong><?php _e( 'Deprecated function(-s) is used on the site here:', 'bestwebsoft' ); ?></strong>  
  242. <?php $i = 1;  
  243. foreach ( $bstwbsftwppdtplgns_options['deprecated_function'] as $function_name => $attr ) { 
  244. if ( 1 != $i ) 
  245. echo ' , '; 
  246. if ( ! empty( $attr['product-name'] ) ) { 
  247. echo $attr['product-name']; 
  248. } elseif ( ! empty( $attr['file'] ) ) { 
  249. echo $attr['file']; 
  250. unset( $bstwbsftwppdtplgns_options['deprecated_function'][ $function_name ] ); 
  251. $i++; 
  252. } ?>. 
  253. <br/> 
  254. <?php _e( 'This function(-s) will be removed over time. Please update the product(-s).', 'bestwebsoft' ); ?>  
  255. </div>  
  256. <?php if ( is_multisite() ) 
  257. update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); 
  258. else 
  259. update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); 
  260.  
  261. if ( ! function_exists( 'bws_plugin_banner' ) ) { 
  262. function bws_plugin_banner( $plugin_info, $this_banner_prefix, $link_slug, $link_key, $link_pn, $banner_url_or_slug ) { 
  263. global $wp_version, $bstwbsftwppdtplgns_cookie_add, $bstwbsftwppdtplgns_banner_array; 
  264.  
  265. if ( empty( $bstwbsftwppdtplgns_banner_array ) ) { 
  266. if ( ! function_exists( 'bws_get_banner_array' ) ) 
  267. require_once( dirname( __FILE__ ) . '/bws_menu.php' ); 
  268. bws_get_banner_array(); 
  269.  
  270. if ( false == strrpos( $banner_url_or_slug, '/' ) ) { 
  271. $banner_url_or_slug = '//ps.w.org/' . $banner_url_or_slug . '/assets/icon-128x128.png'; 
  272.  
  273. if ( ! function_exists( 'is_plugin_active' ) ) 
  274. require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); 
  275.  
  276. $all_plugins = get_plugins(); 
  277.  
  278. $this_banner = $this_banner_prefix . '_hide_banner_on_plugin_page'; 
  279. foreach ( $bstwbsftwppdtplgns_banner_array as $key => $value ) { 
  280. if ( $this_banner == $value[0] ) { 
  281. if ( ! isset( $bstwbsftwppdtplgns_cookie_add ) ) { 
  282. echo '<script type="text/javascript" src="' . bws_menu_url( 'js/c_o_o_k_i_e.js' ) . '"></script>'; 
  283. $bstwbsftwppdtplgns_cookie_add = true; 
  284. } ?> 
  285. <script type="text/javascript"> 
  286. (function($) { 
  287. $(document).ready( function() { 
  288. var hide_message = $.cookie( '<?php echo $this_banner_prefix; ?>_hide_banner_on_plugin_page' ); 
  289. if ( hide_message == "true" ) { 
  290. $( ".<?php echo $this_banner_prefix; ?>_message" ).css( "display", "none" ); 
  291. } else { 
  292. $( ".<?php echo $this_banner_prefix; ?>_message" ).css( "display", "block" ); 
  293. }; 
  294. $( ".<?php echo $this_banner_prefix; ?>_close_icon" ).click( function() { 
  295. $( ".<?php echo $this_banner_prefix; ?>_message" ).css( "display", "none" ); 
  296. $.cookie( "<?php echo $this_banner_prefix; ?>_hide_banner_on_plugin_page", "true", { expires: 32 } ); 
  297. }); 
  298. }); 
  299. })(jQuery); 
  300. </script> 
  301. <div class="updated" style="padding: 0; margin: 0; border: none; background: none;"> 
  302. <div class="<?php echo $this_banner_prefix; ?>_message bws_banner_on_plugin_page bws_go_pro_banner" style="display: none;"> 
  303. <button class="<?php echo $this_banner_prefix; ?>_close_icon close_icon notice-dismiss bws_hide_settings_notice" title="<?php _e( 'Close notice', 'bestwebsoft' ); ?>"></button> 
  304. <div class="icon"> 
  305. <img title="" src="<?php echo esc_attr( $banner_url_or_slug ); ?>" alt="" /> 
  306. </div> 
  307. <div class="text"><?php 
  308. _e( 'It*s time to upgrade your', 'bestwebsoft' ); ?> <strong><?php echo $plugin_info['Name']; ?> plugin</strong> <?php _e( 'to', 'bestwebsoft' ); ?> <strong>Pro</strong> <?php _e( 'version!', 'bestwebsoft' ); ?><br /> 
  309. <span><?php _e( 'Extend standard plugin functionality with new great options.', 'bestwebsoft' ); ?></span> 
  310. </div> 
  311. <div class="button_div"> 
  312. <a class="button" target="_blank" href="https://bestwebsoft.com/products/wordpress/plugins/<?php echo $link_slug; ?>/?k=<?php echo $link_key; ?>&pn=<?php echo $link_pn; ?>&v=<?php echo $plugin_info["Version"]; ?>&wp_v=<?php echo $wp_version; ?>"><?php _e( 'Learn More', 'bestwebsoft' ); ?></a> 
  313. </div> 
  314. </div> 
  315. </div> 
  316. <?php break; 
  317. if ( isset( $all_plugins[ $value[1] ] ) && $all_plugins[ $value[1] ]["Version"] >= $value[2] && is_plugin_active( $value[1] ) && ! isset( $_COOKIE[ $value[0] ] ) ) { 
  318. break; 
  319.  
  320. if ( ! function_exists ( 'bws_plugin_banner_timeout' ) ) { 
  321. function bws_plugin_banner_timeout( $plugin_key, $plugin_prefix, $plugin_name, $banner_url = false ) { 
  322. global $bstwbsftwppdtplgns_options, $bstwbsftwppdtplgns_cookie_add; 
  323. if ( isset( $bstwbsftwppdtplgns_options['time_out'][ $plugin_key ] ) && ( strtotime( $bstwbsftwppdtplgns_options['time_out'][ $plugin_key ] ) < strtotime( date("m/d/Y") . '+1 month' ) ) && ( strtotime( $bstwbsftwppdtplgns_options['time_out'][ $plugin_key ] ) > strtotime( date("m/d/Y") ) ) ) { 
  324. if ( ! isset( $bstwbsftwppdtplgns_cookie_add ) ) { 
  325. echo '<script type="text/javascript" src="' . bws_menu_url( 'js/c_o_o_k_i_e.js' ) . '"></script>'; 
  326. $bstwbsftwppdtplgns_cookie_add = true; 
  327. } ?> 
  328. <script type="text/javascript"> 
  329. (function($) { 
  330. $(document).ready( function() { 
  331. var hide_message = $.cookie( "<?php echo $plugin_prefix; ?>_timeout_hide_banner_on_plugin_page" ); 
  332. if ( hide_message == "true" ) { 
  333. $( ".<?php echo $plugin_prefix; ?>_message_timeout" ).css( "display", "none" ); 
  334. } else { 
  335. $( ".<?php echo $plugin_prefix; ?>_message_timeout" ).css( "display", "block" ); 
  336. $( ".<?php echo $plugin_prefix; ?>_close_icon" ).click( function() { 
  337. $( ".<?php echo $plugin_prefix; ?>_message_timeout" ).css( "display", "none" ); 
  338. $.cookie( "<?php echo $plugin_prefix; ?>_timeout_hide_banner_on_plugin_page", "true", { expires: 30 } ); 
  339. }); 
  340. }); 
  341. })(jQuery); 
  342. </script> 
  343. <div class="updated" style="padding: 0; margin: 0; border: none; background: none;"> 
  344. <div class="<?php echo $plugin_prefix; ?>_message_timeout bws_banner_on_plugin_page bws_banner_timeout" style="display:none;"> 
  345. <button class="<?php echo $plugin_prefix; ?>_close_icon close_icon notice-dismiss bws_hide_settings_notice" title="<?php _e( 'Close notice', 'bestwebsoft' ); ?>"></button> 
  346. <div class="icon"> 
  347. <img title="" src="<?php echo $banner_url; ?>" alt="" /> 
  348. </div> 
  349. <div class="text"><?php printf( __( "Your license key for %s expires on %s and you won't be granted TOP-PRIORITY SUPPORT or UPDATES.", 'bestwebsoft' ), '<strong>' . $plugin_name . '</strong>', $bstwbsftwppdtplgns_options['time_out'][ $plugin_key ] ); ?> <a target="_new" href="https://support.bestwebsoft.com/entries/53487136"><?php _e( "Learn more", 'bestwebsoft' ); ?></a></div> 
  350. </div> 
  351. </div> 
  352. <?php } 
  353.  
  354. if ( ! function_exists( 'bws_plugin_banner_to_settings' ) ) { 
  355. function bws_plugin_banner_to_settings( $plugin_info, $plugin_options_name, $banner_url_or_slug, $settings_url, $post_type_url = false ) { 
  356. global $wp_version, $bws_plugin_banner_to_settings; 
  357.  
  358. $is_network_admin = is_network_admin(); 
  359.  
  360. $plugin_options = $is_network_admin ? get_site_option( $plugin_options_name ) : get_option( $plugin_options_name ); 
  361.  
  362. if ( isset( $plugin_options['display_settings_notice'] ) && 0 == $plugin_options['display_settings_notice'] ) 
  363. return; 
  364.  
  365. if ( isset( $_POST['bws_hide_settings_notice_' . $plugin_options_name ] ) && check_admin_referer( plugin_basename( __FILE__ ), 'bws_settings_nonce_name' ) ) { 
  366. $plugin_options['display_settings_notice'] = 0; 
  367. if ( $is_network_admin ) 
  368. update_site_option( $plugin_options_name, $plugin_options ); 
  369. else 
  370. update_option( $plugin_options_name, $plugin_options ); 
  371. return; 
  372.  
  373. if ( false == strrpos( $banner_url_or_slug, '/' ) ) { 
  374. $banner_url_or_slug = '//ps.w.org/' . $banner_url_or_slug . '/assets/icon-128x128.png'; 
  375.  
  376. $bws_plugin_banner_to_settings[] = array( 
  377. 'plugin_info' => $plugin_info,  
  378. 'plugin_options_name' => $plugin_options_name,  
  379. 'banner_url' => $banner_url_or_slug,  
  380. 'settings_url' => $settings_url,  
  381. 'post_type_url' => $post_type_url 
  382. ); 
  383.  
  384. if ( ! function_exists( 'bws_plugin_suggest_feature_banner' ) ) { 
  385. function bws_plugin_suggest_feature_banner( $plugin_info, $plugin_options_name, $banner_url_or_slug ) { 
  386. global $wp_version; 
  387.  
  388. $is_network_admin = is_network_admin(); 
  389.  
  390. $plugin_options = $is_network_admin ? get_site_option( $plugin_options_name ) : get_option( $plugin_options_name ); 
  391.  
  392. if ( isset( $plugin_options['display_suggest_feature_banner'] ) && 0 == $plugin_options['display_suggest_feature_banner'] ) 
  393. return; 
  394.  
  395. if ( ! isset( $plugin_options['first_install'] ) ) { 
  396. $plugin_options['first_install'] = strtotime( "now" ); 
  397. $update_option = $return = true; 
  398. } elseif ( strtotime( '-2 week' ) < $plugin_options['first_install'] ) { 
  399. $return = true; 
  400.  
  401. if ( ! isset( $plugin_options['go_settings_counter'] ) ) { 
  402. $plugin_options['go_settings_counter'] = 1; 
  403. $update_option = $return = true; 
  404. } elseif ( 20 > $plugin_options['go_settings_counter'] ) { 
  405. $plugin_options['go_settings_counter'] = $plugin_options['go_settings_counter'] + 1; 
  406. $update_option = $return = true; 
  407.  
  408. if ( isset( $update_option ) ) { 
  409. if ( $is_network_admin ) 
  410. update_site_option( $plugin_options_name, $plugin_options ); 
  411. else 
  412. update_option( $plugin_options_name, $plugin_options ); 
  413.  
  414. if ( isset( $return ) ) 
  415. return; 
  416.  
  417. if ( isset( $_POST['bws_hide_suggest_feature_banner_' . $plugin_options_name ] ) && check_admin_referer( $plugin_info['Name'], 'bws_settings_nonce_name' ) ) { 
  418. $plugin_options['display_suggest_feature_banner'] = 0; 
  419. if ( $is_network_admin ) 
  420. update_site_option( $plugin_options_name, $plugin_options ); 
  421. else 
  422. update_option( $plugin_options_name, $plugin_options ); 
  423. return; 
  424.  
  425. if ( false == strrpos( $banner_url_or_slug, '/' ) ) { 
  426. $banner_url_or_slug = '//ps.w.org/' . $banner_url_or_slug . '/assets/icon-128x128.png'; 
  427. } ?> 
  428. <div class="updated" style="padding: 0; margin: 0; border: none; background: none;"> 
  429. <div class="bws_banner_on_plugin_page bws_suggest_feature_banner"> 
  430. <div class="icon"> 
  431. <img title="" src="<?php echo esc_attr( $banner_url_or_slug ); ?>" alt="" /> 
  432. </div> 
  433. <div class="text"> 
  434. <strong><?php printf( __( 'Thank you for choosing %s plugin!', 'bestwebsoft' ), $plugin_info['Name'] ); ?></strong><br /> 
  435. <?php _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' ); ?> 
  436. <a target="_blank" href="https://support.bestwebsoft.com/hc/en-us/requests/new"><?php _e( 'Suggest a Feature', 'bestwebsoft' ); ?></a> 
  437. </div> 
  438. <form action="" method="post"> 
  439. <button class="notice-dismiss bws_hide_settings_notice" title="<?php _e( 'Close notice', 'bestwebsoft' ); ?>"></button> 
  440. <input type="hidden" name="bws_hide_suggest_feature_banner_<?php echo $plugin_options_name; ?>" value="hide" /> 
  441. <?php wp_nonce_field( $plugin_info['Name'], 'bws_settings_nonce_name' ); ?> 
  442. </form> 
  443. </div> 
  444. </div> 
  445. <?php } 
  446.  
  447. if ( ! function_exists( 'bws_show_settings_notice' ) ) { 
  448. function bws_show_settings_notice() { ?> 
  449. <div id="bws_save_settings_notice" class="updated fade below-h2" style="display:none;"> 
  450. <p> 
  451. <strong><?php _e( 'Notice', 'bestwebsoft' ); ?></strong>: <?php _e( "The plugin's settings have been changed.", 'bestwebsoft' ); ?> 
  452. <a class="bws_save_anchor" href="#bws-submit-button"><?php _e( 'Save Changes', 'bestwebsoft' ); ?></a> 
  453. </p> 
  454. </div> 
  455. <?php } 
  456.  
  457. if ( ! function_exists( 'bws_hide_premium_options' ) ) { 
  458. function bws_hide_premium_options( $options ) { 
  459. if ( ! isset( $options['hide_premium_options'] ) || ! is_array( $options['hide_premium_options'] ) ) 
  460. $options['hide_premium_options'] = array(); 
  461.  
  462. $options['hide_premium_options'][] = get_current_user_id(); 
  463.  
  464. return array( 
  465. 'message' => __( 'You can always look at premium options by checking the "Pro Options" in the "Misc" tab.', 'bestwebsoft' ),  
  466. 'options' => $options ); 
  467.  
  468. if ( ! function_exists( 'bws_hide_premium_options_check' ) ) { 
  469. function bws_hide_premium_options_check( $options ) { 
  470. if ( ! empty( $options['hide_premium_options'] ) && in_array( get_current_user_id(), $options['hide_premium_options'] ) ) 
  471. return true; 
  472. else 
  473. return false; 
  474.  
  475. if ( ! function_exists ( 'bws_plugins_admin_init' ) ) { 
  476. function bws_plugins_admin_init() { 
  477. if ( isset( $_GET['bws_activate_plugin'] ) && check_admin_referer( 'bws_activate_plugin' . $_GET['bws_activate_plugin'] ) ) { 
  478.  
  479. $plugin = isset( $_GET['bws_activate_plugin'] ) ? $_GET['bws_activate_plugin'] : ''; 
  480. $result = activate_plugin( $plugin, '', is_network_admin() ); 
  481. if ( is_wp_error( $result ) ) { 
  482. if ( 'unexpected_output' == $result->get_error_code() ) { 
  483. $redirect = self_admin_url( 'admin.php?page=bws_panel&error=true&charsout=' . strlen( $result->get_error_data() ) . '&plugin=' . $plugin ); 
  484. wp_redirect( add_query_arg( '_error_nonce', wp_create_nonce( 'plugin-activation-error_' . $plugin ), $redirect ) ); 
  485. exit(); 
  486. } else { 
  487. wp_die( $result ); 
  488.  
  489. if ( ! is_network_admin() ) { 
  490. $recent = (array) get_option( 'recently_activated' ); 
  491. unset( $recent[ $plugin ] ); 
  492. update_option( 'recently_activated', $recent ); 
  493. } else { 
  494. $recent = (array) get_site_option( 'recently_activated' ); 
  495. unset( $recent[ $plugin ] ); 
  496. update_site_option( 'recently_activated', $recent ); 
  497. wp_redirect( self_admin_url( 'admin.php?page=bws_panel&activate=true' ) ); 
  498. exit(); 
  499.  
  500. if ( isset( $_GET['page'] ) && $_GET['page'] == 'bws_panel' ) { 
  501. if ( ! session_id() ) 
  502. @session_start(); 
  503.  
  504. bws_add_editor_buttons(); 
  505.  
  506. if ( ! function_exists ( 'bws_admin_enqueue_scripts' ) ) { 
  507. function bws_admin_enqueue_scripts() { 
  508. global $wp_scripts; 
  509.  
  510. $jquery_version = isset( $wp_scripts->registered['jquery-ui-core']->ver ) ? $wp_scripts->registered['jquery-ui-core']->ver : '1.12.1'; 
  511.  
  512. wp_enqueue_style( 'jquery-ui-style', '//code.jquery.com/ui/' . $jquery_version . '/themes/smoothness/jquery-ui.min.css', array(), $jquery_version ); 
  513. wp_enqueue_style( 'bws-admin-css', bws_menu_url( 'css/general_style.css' ) ); 
  514. wp_enqueue_script( 'bws-admin-scripts', bws_menu_url( 'js/general_script.js' ), array( 'jquery', 'jquery-ui-tooltip' ) ); 
  515.  
  516. if ( isset( $_GET['page'] ) && ( in_array( $_GET['page'], array( 'bws_panel', 'bws_themes', 'bws_system_status' ) ) || strpos( $_GET['page'], '-bws-panel' ) ) ) { 
  517. wp_enqueue_style( 'bws_menu_style', bws_menu_url( 'css/style.css' ) ); 
  518. wp_enqueue_script( 'bws_menu_script', bws_menu_url( 'js/bws_menu.js' ) ); 
  519. wp_enqueue_script( 'theme-install' ); 
  520. add_thickbox(); 
  521. wp_enqueue_script( 'plugin-install' ); 
  522.  
  523. /** 
  524. * add styles and scripts for Bws_Settings_Tabs 
  525. * 
  526. * @since 1.9.8 
  527. */ 
  528. if ( ! function_exists( 'bws_enqueue_settings_scripts' ) ) { 
  529. function bws_enqueue_settings_scripts() { 
  530. wp_enqueue_script( 'jquery-ui-resizable' ); 
  531. wp_enqueue_script( 'jquery-ui-tabs' ); 
  532.  
  533. if ( ! function_exists ( 'bws_plugins_admin_head' ) ) { 
  534. function bws_plugins_admin_head() { 
  535. global $bws_shortcode_list, $wp_version, $post_type; 
  536. if ( isset( $_GET['page'] ) && $_GET['page'] == "bws_panel" ) { ?> 
  537. <noscript> 
  538. <style type="text/css"> 
  539. .bws_product_button { 
  540. display: inline-block; 
  541. </style> 
  542. </noscript> 
  543. <?php } 
  544. if ( 4.2 > $wp_version ) { ?> 
  545. <style type="text/css"> 
  546. .bws_hide_settings_notice,  
  547. .bws_hide_premium_options { 
  548. width: 11px; 
  549. height: 11px; 
  550. border: none; 
  551. background: url("<?php echo bws_menu_url( 'images/close_banner.png' ); ?>") no-repeat center center; 
  552. box-shadow: none; 
  553. float: right; 
  554. margin: 8px; 
  555. .bws_hide_settings_notice:hover,  
  556. .bws_hide_premium_options:hover { 
  557. cursor: pointer; 
  558. .bws_hide_premium_options { 
  559. position: relative; 
  560. </style> 
  561. <?php } 
  562. if ( ! empty( $bws_shortcode_list ) ) { ?> 
  563. <!-- TinyMCE Shortcode Plugin --> 
  564. <script type='text/javascript'> 
  565. var bws_shortcode_button = { 
  566. 'label': '<?php esc_attr_e( "Add BWS Shortcode", "bestwebsoft" ); ?>',  
  567. 'title': '<?php esc_attr_e( "Add BWS Plugins Shortcode", "bestwebsoft" ); ?>',  
  568. 'function_name': [ 
  569. <?php foreach ( $bws_shortcode_list as $key => $value ) { 
  570. if ( isset( $value['js_function'] ) ) 
  571. echo "'" . $value['js_function'] . "', "; 
  572. } ?> 
  573. ],  
  574. 'wp_version' : '<?php echo $wp_version; ?>' 
  575. }; 
  576. </script> 
  577. <!-- TinyMCE Shortcode Plugin --> 
  578. <?php if ( isset( $post_type ) && in_array( $post_type, array( 'post', 'page' ) ) ) { 
  579. $tooltip_args = array( 
  580. 'tooltip_id' => 'bws_shortcode_button_tooltip',  
  581. 'css_selector' => '.mce-bws_shortcode_button',  
  582. 'actions' => array( 
  583. 'click' => false,  
  584. 'onload' => true 
  585. ),  
  586. 'content' => '<h3>' . __( 'Add shortcode', 'bestwebsoft' ) . '</h3><p>' . __( "Add BestWebSoft plugins' shortcodes using this button.", 'bestwebsoft' ) . '</p>',  
  587. 'position' => array( 
  588. 'edge' => 'right' 
  589. ),  
  590. 'set_timeout' => 2000 
  591. ); 
  592. if ( $wp_version < '3.9' ) 
  593. $tooltip_args['css_selector'] = '.mce_add_bws_shortcode'; 
  594. bws_add_tooltip_in_admin( $tooltip_args ); 
  595.  
  596. if ( ! function_exists ( 'bws_plugins_include_codemirror' ) ) { 
  597. function bws_plugins_include_codemirror() { 
  598. wp_enqueue_style( 'codemirror.css', bws_menu_url( 'css/codemirror.css' ) ); 
  599. wp_enqueue_script( 'codemirror.js', bws_menu_url( 'js/codemirror.js' ), array( 'jquery' ) ); 
  600.  
  601. /** 
  602. * Tooltip block 
  603. */ 
  604. if ( ! function_exists( 'bws_add_tooltip_in_admin' ) ) { 
  605. function bws_add_tooltip_in_admin( $tooltip_args = array() ) { 
  606. new BWS_admin_tooltip( $tooltip_args ); 
  607.  
  608. if ( ! class_exists( 'BWS_admin_tooltip' ) ) { 
  609. class BWS_admin_tooltip { 
  610. private $tooltip_args; 
  611.  
  612. public function __construct( $tooltip_args ) { 
  613. global $wp_version; 
  614. if ( 3.3 > $wp_version ) 
  615. return; 
  616. /** Default arguments */ 
  617. $tooltip_args_default = array( 
  618. 'tooltip_id' => false,  
  619. 'css_selector' => false,  
  620. 'actions' => array( 
  621. 'click' => true,  
  622. 'onload' => false,  
  623. ),  
  624. 'buttons' => array( 
  625. 'close' => array( 
  626. 'type' => 'dismiss',  
  627. 'text' => __( 'Close', 'bestwebsoft' ),  
  628. ),  
  629. ),  
  630. 'position' => array( 
  631. 'edge' => 'top',  
  632. 'align' => 'center',  
  633. 'pos-left' => 0,  
  634. 'pos-top' => 0,  
  635. 'zindex' => 10000 
  636. ),  
  637. 'set_timeout' => 0 
  638. ); 
  639. $tooltip_args = array_merge( $tooltip_args_default, $tooltip_args ); 
  640. /** Check that our merged array has default values */ 
  641. foreach ( $tooltip_args_default as $arg_key => $arg_value ) { 
  642. if ( is_array( $arg_value ) ) { 
  643. foreach ( $arg_value as $key => $value) { 
  644. if ( ! isset( $tooltip_args[ $arg_key ][ $key ] ) ) { 
  645. $tooltip_args[ $arg_key ][ $key ] = $tooltip_args_default[ $arg_key ][ $key ]; 
  646. /** Check if tooltip is dismissed */ 
  647. if ( true === $tooltip_args['actions']['onload'] ) { 
  648. if ( in_array( $tooltip_args['tooltip_id'], array_filter( explode( ', ', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ) ) ) ) { 
  649. $tooltip_args['actions']['onload'] = false; 
  650. /** Check entered data */ 
  651. if ( false === $tooltip_args['tooltip_id'] || false === $tooltip_args['css_selector'] || ( false === $tooltip_args['actions']['click'] && false === $tooltip_args['actions']['onload'] ) ) { 
  652. /** if not enough data to output a tooltip or both actions (click, onload) are false */ 
  653. return; 
  654. } else { 
  655. /** check position */ 
  656. if ( ! in_array( $tooltip_args['position']['edge'], array( 'left', 'right', 'top', 'bottom' ) ) ) { 
  657. $tooltip_args['position']['edge'] = 'top'; 
  658. if ( ! in_array( $tooltip_args['position']['align'], array( 'top', 'bottom', 'left', 'right', 'center', ) ) ) { 
  659. $tooltip_args['position']['align'] = 'center'; 
  660. /** fix position */ 
  661. switch ( $tooltip_args['position']['edge'] ) { 
  662. case 'left': 
  663. case 'right': 
  664. switch ( $tooltip_args['position']['align'] ) { 
  665. case 'top': 
  666. case 'bottom': 
  667. $tooltip_args['position']['align'] = 'center'; 
  668. break; 
  669. break; 
  670. case 'top': 
  671. case 'bottom': 
  672. if ( $tooltip_args['position']['align'] == 'left' ) { 
  673. $tooltip_args['position']['pos-left'] -= 65; 
  674. break; 
  675. $this->tooltip_args = $tooltip_args; 
  676. /** add styles and scripts */ 
  677. wp_enqueue_style( 'wp-pointer' ); 
  678. wp_enqueue_script( 'wp-pointer' ); 
  679. /** add script that displays our tooltip */ 
  680. add_action( 'admin_print_footer_scripts', array( $this, 'add_scripts' ) ); 
  681.  
  682. /** 
  683. * Display tooltip 
  684. */ 
  685. public function add_scripts() { 
  686. global $bstwbsftwppdtplgns_tooltip_script_add; 
  687. if ( ! isset( $bstwbsftwppdtplgns_tooltip_script_add ) ) { 
  688. echo '<script type="text/javascript" src="' . bws_menu_url( 'js/bws_tooltip.js' ) . '"></script>'; 
  689. $bstwbsftwppdtplgns_tooltip_script_add = true; 
  690. $tooltip_args = $this->tooltip_args; ?> 
  691. <script type="text/javascript"> 
  692. (function($) { 
  693. $(document).ready( function() { 
  694. $.bwsTooltip( <?php echo json_encode( $tooltip_args ); ?> ); 
  695. }) 
  696. })(jQuery); 
  697. </script> 
  698. <?php } 
  699.  
  700. if ( ! function_exists ( 'bws_form_restore_default_confirm' ) ) { 
  701. function bws_form_restore_default_confirm( $plugin_basename ) { ?> 
  702. <div> 
  703. <p><?php _e( 'Are you sure you want to restore default settings?', 'bestwebsoft' ) ?></p> 
  704. <form method="post" action=""> 
  705. <p> 
  706. <button class="button button-primary" name="bws_restore_confirm"><?php _e( 'Yes, restore all settings', 'bestwebsoft' ) ?></button> 
  707. <button class="button" name="bws_restore_deny"><?php _e( 'No, go back to the settings page', 'bestwebsoft' ) ?></button> 
  708. <?php wp_nonce_field( $plugin_basename, 'bws_settings_nonce_name' ); ?> 
  709. </p> 
  710. </form> 
  711. </div> 
  712. <?php } 
  713.  
  714. /** shortcode */ 
  715. if ( ! function_exists( 'bws_add_editor_buttons' ) ) { 
  716. function bws_add_editor_buttons() { 
  717. global $bws_shortcode_list, $wp_version; 
  718. if ( $wp_version < '3.3' ) 
  719. return; 
  720. if ( ! empty( $bws_shortcode_list ) && current_user_can( 'edit_posts' ) && current_user_can( 'edit_pages' ) ) { 
  721. add_filter( 'mce_external_plugins', 'bws_add_buttons' ); 
  722. add_filter( 'mce_buttons', 'bws_register_buttons' ); 
  723.  
  724. if ( ! function_exists( 'bws_add_buttons' ) ) { 
  725. function bws_add_buttons( $plugin_array ) { 
  726. $plugin_array['add_bws_shortcode'] = bws_menu_url( 'js/shortcode-button.js' ); 
  727. return $plugin_array; 
  728.  
  729. if ( ! function_exists( 'bws_register_buttons' ) ) { 
  730. function bws_register_buttons( $buttons ) { 
  731. array_push( $buttons, 'add_bws_shortcode' ); /** dropcap', 'recentposts */ 
  732. return $buttons; 
  733.  
  734. /** Generate inline content for the popup window when the "bws shortcode" button is clicked */ 
  735. if ( ! function_exists( 'bws_shortcode_media_button_popup' ) ) { 
  736. function bws_shortcode_media_button_popup() { 
  737. global $bws_shortcode_list, $wp_version; 
  738. if ( $wp_version < '3.3' ) 
  739. return; 
  740.  
  741. if ( ! empty( $bws_shortcode_list ) ) { ?> 
  742. <div id="bws_shortcode_popup" style="display:none;"> 
  743. <div id="bws_shortcode_popup_block"> 
  744. <div id="bws_shortcode_select_plugin"> 
  745. <h4><?php _e( 'Plugin', 'bestwebsoft' ); ?></h4> 
  746. <select name="bws_shortcode_select" id="bws_shortcode_select"> 
  747. <?php foreach ( $bws_shortcode_list as $key => $value ) { ?> 
  748. <option value="<?php echo $key; ?>"><?php echo $value['name']; ?></option> 
  749. <?php } ?> 
  750. </select> 
  751. </div> 
  752. <div class="clear"></div> 
  753. <div id="bws_shortcode_content"> 
  754. <h4><?php _e( 'Shortcode settings', 'bestwebsoft' ); ?></h4> 
  755. <?php echo apply_filters( 'bws_shortcode_button_content', '' ); ?> 
  756. </div> 
  757. <div class="clear"></div> 
  758. <div id="bws_shortcode_content_bottom"> 
  759. <p><?php _e( 'The shortcode will be inserted', 'bestwebsoft' ); ?></p> 
  760. <div id="bws_shortcode_block"><div id="bws_shortcode_display"></div></div> 
  761. </div> 
  762. <?php if ( $wp_version < '3.9' ) { ?> 
  763. <p> 
  764. <button class="button-primary primary bws_shortcode_insert"><?php _e( 'Insert', 'bestwebsoft' ); ?></button> 
  765. </p> 
  766. <?php } ?> 
  767. </div> 
  768. </div> 
  769. <?php } 
  770. if ( $wp_version < '3.9' ) { ?> 
  771. <script type="text/javascript"> 
  772. (function($) { 
  773. $( '.bws_shortcode_insert' ).on( 'click', function() { 
  774. var shortcode = $( '#TB_ajaxContent #bws_shortcode_display' ).text(); 
  775. if ( '' != shortcode ) { 
  776. /* insert shortcode to tinymce */ 
  777. if ( !tinyMCE.activeEditor || tinyMCE.activeEditor.isHidden() ) { 
  778. $( 'textarea#content' ).val( shortcode ); 
  779. } else { 
  780. tinyMCE.execCommand( 'mceInsertContent', false, shortcode ); 
  781. /* close the thickbox after adding shortcode to editor */ 
  782. self.parent.tb_remove(); 
  783. }); 
  784. })(jQuery); 
  785. </script> 
  786. <?php } 
  787.  
  788. /**  
  789. * output shortcode in a special block 
  790. * @since 1.9.8 
  791. */ 
  792. if ( ! function_exists( 'bws_shortcode_output' ) ) { 
  793. function bws_shortcode_output( $shortcode ) { ?> 
  794. <span class="bws_shortcode_output"><input type="text" onfocus="this.select();" readonly="readonly" value="<?php echo $shortcode; ?>" class="large-text bws_no_bind_notice"></span> 
  795. <?php } 
  796.  
  797. /**  
  798. * output tooltip 
  799. * @since 1.9.8 
  800. */ 
  801. if ( ! function_exists( 'bws_add_help_box' ) ) { 
  802. function bws_add_help_box( $content, $class = '' ) { 
  803. return '<span class="bws_help_box dashicons dashicons-editor-help ' . $class . ' hide-if-no-js"> 
  804. <span class="bws_hidden_help_text">' . $content . '</span> 
  805. </span>'; 
  806.  
  807. /** add help tab */ 
  808. if ( ! function_exists( 'bws_help_tab' ) ) { 
  809. function bws_help_tab( $screen, $args ) { 
  810. $url = ( ! empty( $args['section'] ) ) ? 'https://support.bestwebsoft.com/hc/en-us/sections/' . $args['section'] : 'https://support.bestwebsoft.com/'; 
  811.  
  812. $content = '<p><a href="' . $url . '" target="_blank">' . __( 'Visit Help Center', 'bestwebsoft' ) . '</a></p>'; 
  813.  
  814. $screen->add_help_tab( 
  815. array( 
  816. 'id' => $args['id'] . '_help_tab',  
  817. 'title' => __( 'FAQ', 'bestwebsoft' ),  
  818. 'content' => $content 
  819. ); 
  820.  
  821. $screen->set_help_sidebar( 
  822. '<p><strong>' . __( 'For more information:', 'bestwebsoft' ) . '</strong></p>' . 
  823. '<p><a href="https://drive.google.com/folderview?id=0B5l8lO-CaKt9VGh0a09vUjNFNjA&usp=sharing#list" target="_blank">' . __( 'Documentation', 'bestwebsoft' ) . '</a></p>' . 
  824. '<p><a href="http://www.youtube.com/user/bestwebsoft/playlists?flow=grid&sort=da&view=1" target="_blank">' . __( 'Video Instructions', 'bestwebsoft' ) . '</a></p>' . 
  825. '<p><a href="https://support.bestwebsoft.com/hc/en-us/requests/new" target="_blank">' . __( 'Submit a Request', 'bestwebsoft' ) . '</a></p>' 
  826. ); 
  827.  
  828. if ( ! function_exists( 'bws_enqueue_custom_code_css_js' ) ) { 
  829. function bws_enqueue_custom_code_css_js() { 
  830. global $bstwbsftwppdtplgns_options; 
  831.  
  832. if ( ! isset( $bstwbsftwppdtplgns_options ) ) 
  833. $bstwbsftwppdtplgns_options = ( function_exists( 'is_multisite' ) && is_multisite() ) ? get_site_option( 'bstwbsftwppdtplgns_options' ) : get_option( 'bstwbsftwppdtplgns_options' ); 
  834.  
  835. if ( ! empty( $bstwbsftwppdtplgns_options['custom_code'] ) ) { 
  836. $is_multisite = is_multisite(); 
  837. if ( $is_multisite ) 
  838. $blog_id = get_current_blog_id(); 
  839.  
  840. if ( ! $is_multisite && ! empty( $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.css'] ) ) 
  841. wp_enqueue_style( 'bws-custom-style', $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.css'] ); 
  842. elseif ( $is_multisite && ! empty( $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.css'] ) ) 
  843. wp_enqueue_style( 'bws-custom-style', $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.css'] ); 
  844.  
  845. if ( ! $is_multisite && ! empty( $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.js'] ) ) 
  846. wp_enqueue_script( 'bws-custom-style', $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.js'] ); 
  847. elseif ( $is_multisite && ! empty( $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.js'] ) ) 
  848. wp_enqueue_script( 'bws-custom-style', $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.js'] ); 
  849.  
  850. if ( ! function_exists( 'bws_enqueue_custom_code_php' ) ) { 
  851. function bws_enqueue_custom_code_php() { 
  852. if ( is_admin() ) 
  853. return; 
  854.  
  855. global $bstwbsftwppdtplgns_options; 
  856.  
  857. if ( ! isset( $bstwbsftwppdtplgns_options ) ) 
  858. $bstwbsftwppdtplgns_options = ( function_exists( 'is_multisite' ) && is_multisite() ) ? get_site_option( 'bstwbsftwppdtplgns_options' ) : get_option( 'bstwbsftwppdtplgns_options' ); 
  859.  
  860. if ( ! empty( $bstwbsftwppdtplgns_options['custom_code'] ) ) { 
  861.  
  862. $is_multisite = is_multisite(); 
  863. if ( $is_multisite ) 
  864. $blog_id = get_current_blog_id(); 
  865.  
  866. if ( ! $is_multisite && ! empty( $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.php'] ) ) { 
  867. if ( file_exists( $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.php'] ) ) { 
  868. if ( ! defined( 'BWS_GLOBAL' ) ) 
  869. define( 'BWS_GLOBAL', true ); 
  870. require_once( $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.php'] ); 
  871. } else { 
  872. unset( $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.php'] ); 
  873. if ( $is_multisite ) 
  874. update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); 
  875. else 
  876. update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); 
  877. } elseif ( $is_multisite && ! empty( $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.php'] ) ) { 
  878. if ( file_exists( $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.php'] ) ) { 
  879. if ( ! defined( 'BWS_GLOBAL' ) ) 
  880. define( 'BWS_GLOBAL', true ); 
  881. require_once( $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.php'] ); 
  882. } else { 
  883. unset( $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.php'] ); 
  884. if ( $is_multisite ) 
  885. update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); 
  886. else 
  887. update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); 
  888.  
  889. if ( ! function_exists( 'bws_delete_plugin' ) ) { 
  890. function bws_delete_plugin( $basename ) { 
  891. global $bstwbsftwppdtplgns_options; 
  892.  
  893. $is_multisite = is_multisite(); 
  894. if ( $is_multisite ) 
  895. $blog_id = get_current_blog_id(); 
  896.  
  897. if ( ! isset( $bstwbsftwppdtplgns_options ) ) 
  898. $bstwbsftwppdtplgns_options = ( $is_multisite ) ? get_site_option( 'bstwbsftwppdtplgns_options' ) : get_option( 'bstwbsftwppdtplgns_options' ); 
  899.  
  900. /** remove bws_menu versions */ 
  901. unset( $bstwbsftwppdtplgns_options['bws_menu']['version'][ $basename ] ); 
  902. /** remove track usage data */ 
  903. if ( isset( $bstwbsftwppdtplgns_options['bws_menu']['track_usage']['products'][ $basename ] ) ) 
  904. unset( $bstwbsftwppdtplgns_options['bws_menu']['track_usage']['products'][ $basename ] ); 
  905. /** if empty ['bws_menu']['version'] - there is no other bws plugins - delete all */ 
  906. if ( empty( $bstwbsftwppdtplgns_options['bws_menu']['version'] ) ) { 
  907. /** remove options */ 
  908. if ( $is_multisite ) 
  909. delete_site_option( 'bstwbsftwppdtplgns_options' ); 
  910. else 
  911. delete_option( 'bstwbsftwppdtplgns_options' ); 
  912.  
  913. /** remove custom_code */ 
  914. if ( $is_multisite ) { 
  915. global $wpdb; 
  916. $old_blog = $wpdb->blogid; 
  917. /** Get all blog ids */ 
  918. $blogids = $wpdb->get_col( "SELECT `blog_id` FROM $wpdb->blogs" ); 
  919. foreach ( $blogids as $blog_id ) { 
  920. switch_to_blog( $blog_id ); 
  921. $upload_dir = wp_upload_dir(); 
  922. $folder = $upload_dir['basedir'] . '/bws-custom-code'; 
  923. if ( file_exists( $folder ) && is_dir( $folder ) ) { 
  924. array_map( 'unlink', glob( "$folder/*" ) ); 
  925. rmdir( $folder ); 
  926. switch_to_blog( $old_blog ); 
  927. } else { 
  928. $upload_dir = wp_upload_dir(); 
  929. $folder = $upload_dir['basedir'] . '/bws-custom-code'; 
  930. if ( file_exists( $folder ) && is_dir( $folder ) ) { 
  931. array_map( 'unlink', glob( "$folder/*" ) ); 
  932. rmdir( $folder ); 
  933.  
  934. add_action( 'admin_init', 'bws_plugins_admin_init' ); 
  935. add_action( 'admin_enqueue_scripts', 'bws_admin_enqueue_scripts' ); 
  936. add_action( 'admin_head', 'bws_plugins_admin_head' ); 
  937. add_action( 'admin_footer', 'bws_shortcode_media_button_popup' ); 
  938.  
  939. add_action( 'admin_notices', 'bws_admin_notices', 30 ); 
  940.  
  941. add_action( 'wp_enqueue_scripts', 'bws_enqueue_custom_code_css_js', 20 ); 
  942.  
  943. bws_enqueue_custom_code_php(); 
.