93 $admin_url, |
77 $admin_url, |
94 __( 'Plugins page', 'bestwebsoft' ) |
78 __( 'Plugins page', 'bestwebsoft' ) |
95 ) |
79 ) |
96 ); |
80 ); |
97 } |
81 } |
|
82 } elseif ( version_compare( $wp_version, $require_wp, "<" ) ) { |
|
83 $bws_versions_notice_array[] = array( 'name' => $plugin_info['Name'], 'version' => $require_wp ); |
|
84 } |
|
85 } |
|
86 } |
|
87 |
|
88 if ( ! function_exists( 'bws_plugin_reviews_block' ) ) { |
|
89 function bws_plugin_reviews_block( $plugin_name, $plugin_slug ) { ?> |
|
90 <div class="bws-plugin-reviews"> |
|
91 <div class="bws-plugin-reviews-rate"> |
|
92 <?php _e( 'Like the plugin?', 'bestwebsoft' ); ?> |
|
93 <a href="https://wordpress.org/support/view/plugin-reviews/<?php echo esc_attr( $plugin_slug ); ?>?filter=5" target="_blank" title="<?php printf( __( '%s reviews', 'bestwebsoft' ), sanitize_text_field( $plugin_name ) ); ?>"> |
|
94 <?php _e( 'Rate it', 'bestwebsoft' ); ?> |
|
95 <span class="dashicons dashicons-star-filled"></span> |
|
96 <span class="dashicons dashicons-star-filled"></span> |
|
97 <span class="dashicons dashicons-star-filled"></span> |
|
98 <span class="dashicons dashicons-star-filled"></span> |
|
99 <span class="dashicons dashicons-star-filled"></span> |
|
100 </a> |
|
101 </div> |
|
102 <div class="bws-plugin-reviews-support"> |
|
103 <?php _e( 'Need help?', 'bestwebsoft' ); ?> |
|
104 <a href="https://support.bestwebsoft.com"><?php _e( 'Visit Help Center', 'bestwebsoft' ); ?></a> |
|
105 </div> |
|
106 <div class="bws-plugin-reviews-donate"> |
|
107 <?php _e( 'Want to support the plugin?', 'bestwebsoft' ); ?> |
|
108 <a href="https://bestwebsoft.com/donate/"><?php _e( 'Donate', 'bestwebsoft' ); ?></a> |
|
109 </div> |
|
110 </div> |
|
111 <?php } |
|
112 } |
|
113 |
|
114 if ( ! function_exists ( 'bws_plugin_update_row' ) ) { |
|
115 function bws_plugin_update_row( $plugin_key, $link_slug = false, $free_plugin_name = false ) { |
|
116 global $bstwbsftwppdtplgns_options, $wp_version; |
|
117 $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
|
118 if ( isset( $bstwbsftwppdtplgns_options['wrong_license_key'][ $plugin_key ] ) ) { |
|
119 $explode_plugin_key = explode( '/', $plugin_key ); |
|
120 $class = ( $wp_version >= 4.6 ) ? 'active' : ''; |
|
121 $style = ( $wp_version < 4.6 ) ? ' style="background-color: #FFEBE8;border-color: #CC0000;"' : ''; |
|
122 $div_class = ( $wp_version >= 4.6 ) ? ' notice inline notice-warning notice-alt' : ''; |
|
123 echo '<tr class="bws-plugin-update-tr plugin-update-tr ' . $class . '" id="' . esc_attr( $explode_plugin_key[0] ) . '-update" data-slug="' . esc_attr( $explode_plugin_key[0] ) . '" data-plugin="' . esc_attr( $plugin_key ) . '"> |
|
124 <td colspan="' . esc_attr( $wp_list_table->get_column_count() ) . '" class="plugin-update colspanchange"> |
|
125 <div class="update-message' . $div_class . '"' . $style . '>'; |
|
126 if ( $wp_version >= 4.6 ) |
|
127 echo '<p>'; |
|
128 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 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">' . __( 'Learn More', 'bestwebsoft' ) . '</a>'; |
|
129 if ( $wp_version >= 4.6 ) |
|
130 echo '</p>'; |
|
131 echo '</div> |
|
132 </td> |
|
133 </tr>'; |
|
134 } elseif ( isset( $bstwbsftwppdtplgns_options['time_out'][ $plugin_key ] ) && strtotime( $bstwbsftwppdtplgns_options['time_out'][ $plugin_key ] ) < strtotime( date("m/d/Y") ) ) { |
|
135 $explode_plugin_key = explode( '/', $plugin_key ); |
|
136 $class = ( $wp_version >= 4.6 ) ? 'active' : ''; |
|
137 $style = ( $wp_version < 4.6 ) ? ' style="color: #8C0000;"' : ''; |
|
138 $div_class = ( $wp_version >= 4.6 ) ? ' notice inline notice-warning notice-alt' : ''; |
|
139 echo '<tr class="bws-plugin-update-tr plugin-update-tr ' . $class . '" id="' . esc_attr( $explode_plugin_key[0] ) . '-update" data-slug="' . esc_attr( $explode_plugin_key[0] ) . '" data-plugin="' . esc_attr( $plugin_key ) . '"> |
|
140 <td colspan="' . esc_attr( $wp_list_table->get_column_count() ) . '" class="plugin-update colspanchange"> |
|
141 <div class="update-message' . $div_class . '"' . $style . '>'; |
|
142 if ( $wp_version >= 4.6 ) |
|
143 echo '<p>'; |
|
144 if ( isset( $bstwbsftwppdtplgns_options['trial'][ $plugin_key ] ) && $link_slug != false ) { |
|
145 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/' . esc_attr( $link_slug ) . '/">https://bestwebsoft.com/products/wordpress/plugins/' . esc_attr( $link_slug ) . '/</a>'; |
|
146 } else { |
|
147 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>'; |
|
148 } |
|
149 if ( $wp_version >= 4.6 ) |
|
150 echo '</p>'; |
|
151 echo '</div> |
|
152 </td> |
|
153 </tr>'; |
|
154 } elseif ( isset( $bstwbsftwppdtplgns_options['trial'][ $plugin_key ] ) ) { |
|
155 $explode_plugin_key = explode( '/', $plugin_key ); |
|
156 $class = ( $wp_version >= 4.6 ) ? 'active' : ''; |
|
157 $style = ( $wp_version < 4.6 ) ? ' style="color: #8C0000;"' : ''; |
|
158 $div_class = ( $wp_version >= 4.6 ) ? ' notice inline notice-warning notice-alt' : ''; |
|
159 echo '<tr class="bws-plugin-update-tr plugin-update-tr ' . $class . '" id="' . esc_attr( $explode_plugin_key[0] ) . '-update" data-slug="' . esc_attr( $explode_plugin_key[0] ) . '" data-plugin="' . esc_attr( $plugin_key ) . '"> |
|
160 <td colspan="' . esc_attr( $wp_list_table->get_column_count() ) . '" class="plugin-update colspanchange"> |
|
161 <div class="update-message' . $div_class . '"' . $style . '>'; |
|
162 if ( $wp_version >= 4.6 ) |
|
163 echo '<p>'; |
|
164 if ( $free_plugin_name != false ) { |
|
165 printf( __( 'Notice: You are using the Pro Trial license of %s plugin.', 'bestwebsoft' ), $free_plugin_name ); |
|
166 } else { |
|
167 _e( 'Notice: You are using the Pro Trial license of plugin.', 'bestwebsoft' ); |
|
168 } |
|
169 if ( isset( $bstwbsftwppdtplgns_options['time_out'][ $plugin_key ] ) ) |
|
170 echo ' ' . __( 'The Pro Trial license will expire on', 'bestwebsoft' ) . ' ' . $bstwbsftwppdtplgns_options['time_out'][ $plugin_key ] . '.'; |
|
171 if ( $wp_version >= 4.6 ) |
|
172 echo '</p>'; |
|
173 echo '</div> |
|
174 </td> |
|
175 </tr>'; |
|
176 } |
|
177 } |
|
178 } |
|
179 |
|
180 if ( ! function_exists( 'bws_admin_notices' ) ) { |
|
181 function bws_admin_notices() { |
|
182 global $bws_versions_notice_array, $bws_plugin_banner_to_settings, $bstwbsftwppdtplgns_options; |
|
183 |
|
184 /* versions notice */ |
|
185 if ( ! empty( $bws_versions_notice_array ) ) { |
|
186 foreach ( $bws_versions_notice_array as $key => $value ) { ?> |
|
187 <div class="update-nag"> |
|
188 <?php printf( |
|
189 "<strong>%s</strong> %s <strong>WordPress %s</strong> %s", |
|
190 $value['name'], |
|
191 __( 'requires', 'bestwebsoft' ), |
|
192 $value['version'], |
|
193 __( 'or higher! We do not guarantee that our plugin will work correctly. Please upgrade to WordPress latest version.', 'bestwebsoft' ) |
|
194 ); ?> |
|
195 </div> |
|
196 <?php } |
|
197 } |
|
198 |
|
199 /* banner_to_settings notice */ |
|
200 if ( ! empty( $bws_plugin_banner_to_settings ) ) { |
|
201 if ( 1 == count( $bws_plugin_banner_to_settings ) ) { ?> |
|
202 <div class="updated" style="padding: 0; margin: 0; border: none; background: none;"> |
|
203 <div class="bws_banner_on_plugin_page bws_banner_to_settings"> |
|
204 <div class="icon"> |
|
205 <img title="" src="<?php echo esc_attr( $bws_plugin_banner_to_settings[0]['banner_url'] ); ?>" alt="" /> |
|
206 </div> |
|
207 <div class="text"> |
|
208 <strong><?php printf( __( 'Thank you for installing %s plugin!', 'bestwebsoft' ), $bws_plugin_banner_to_settings[0]['plugin_info']['Name'] ); ?></strong> |
|
209 <br /> |
|
210 <?php _e( "Let's get started", 'bestwebsoft' ); ?>: |
|
211 <a href="<?php echo esc_url( self_admin_url( $bws_plugin_banner_to_settings[0]['settings_url'] ) ); ?>"><?php _e( 'Settings', 'bestwebsoft' ); ?></a> |
|
212 <?php if ( false != $bws_plugin_banner_to_settings[0]['post_type_url'] ) { ?> |
|
213 <?php _e( 'or', 'bestwebsoft' ); ?> |
|
214 <a href="<?php echo esc_url( self_admin_url( $bws_plugin_banner_to_settings[0]['post_type_url'] ) ); ?>"><?php _e( 'Add New', 'bestwebsoft' ); ?></a> |
|
215 <?php } ?> |
|
216 </div> |
|
217 <form action="" method="post"> |
|
218 <button class="notice-dismiss bws_hide_settings_notice" title="<?php _e( 'Close notice', 'bestwebsoft' ); ?>"></button> |
|
219 <input type="hidden" name="bws_hide_settings_notice_<?php echo $bws_plugin_banner_to_settings[0]['plugin_options_name']; ?>" value="hide" /> |
|
220 <?php wp_nonce_field( plugin_basename( __FILE__ ), 'bws_settings_nonce_name' ); ?> |
|
221 </form> |
|
222 </div> |
|
223 </div> |
|
224 <?php } else { ?> |
|
225 <div class="updated" style="padding: 0; margin: 0; border: none; background: none;"> |
|
226 <div class="bws_banner_on_plugin_page bws_banner_to_settings_joint"> |
|
227 <form action="" method="post"> |
|
228 <button class="notice-dismiss bws_hide_settings_notice" title="<?php _e( 'Close notice', 'bestwebsoft' ); ?>"></button> |
|
229 <div class="bws-text"> |
|
230 <div class="icon"> |
|
231 <span class="dashicons dashicons-admin-plugins"></span> |
|
232 </div> |
|
233 <strong><?php _e( 'Thank you for installing plugins by BestWebSoft!', 'bestwebsoft' ); ?></strong> |
|
234 <div class="hide-if-no-js bws-more-links"> |
|
235 <a href="#" class="bws-more"><?php _e( 'More Details', 'bestwebsoft' ); ?></a> |
|
236 <a href="#" class="bws-less hidden"><?php _e( 'Less Details', 'bestwebsoft' ); ?></a> |
|
237 </div> |
|
238 <?php wp_nonce_field( plugin_basename( __FILE__ ), 'bws_settings_nonce_name' ); ?> |
|
239 <div class="clear"></div> |
|
240 </div> |
|
241 <div class="bws-details hide-if-js"> |
|
242 <?php foreach ( $bws_plugin_banner_to_settings as $value ) { ?> |
|
243 <div> |
|
244 <strong><?php echo str_replace( ' by BestWebSoft', '', $value['plugin_info']['Name'] ); ?></strong> <a href="<?php echo esc_url( self_admin_url( $value['settings_url'] ) ); ?>"><?php _e( 'Settings', 'bestwebsoft' ); ?></a> |
|
245 <?php if ( false != $value['post_type_url'] ) { ?> |
|
246  | <a target="_blank" href="<?php echo esc_url( self_admin_url( $value['post_type_url'] ) ); ?>"><?php _e( 'Add New', 'bestwebsoft' ); ?></a> |
|
247 <?php } ?> |
|
248 <input type="hidden" name="bws_hide_settings_notice_<?php echo $value['plugin_options_name']; ?>" value="hide" /> |
|
249 </div> |
|
250 <?php } ?> |
|
251 </div> |
|
252 </div> |
|
253 </form> |
|
254 </div> |
|
255 <?php } |
|
256 } |
|
257 |
|
258 /** |
|
259 * show notices about deprecated_function |
|
260 * @since 1.9.8 |
|
261 */ |
|
262 if ( ! empty( $bstwbsftwppdtplgns_options['deprecated_function'] ) ) { ?> |
|
263 <div class="update-nag"> |
|
264 <strong><?php _e( 'Deprecated function(-s) is used on the site here:', 'bestwebsoft' ); ?></strong> |
|
265 <?php $i = 1; |
|
266 foreach ( $bstwbsftwppdtplgns_options['deprecated_function'] as $function_name => $attr ) { |
|
267 if ( 1 != $i ) |
|
268 echo ' ,'; |
|
269 if ( ! empty( $attr['product-name'] ) ) { |
|
270 echo $attr['product-name']; |
|
271 } elseif ( ! empty( $attr['file'] ) ) { |
|
272 echo $attr['file']; |
|
273 } |
|
274 unset( $bstwbsftwppdtplgns_options['deprecated_function'][ $function_name ] ); |
|
275 $i++; |
|
276 } ?>. |
|
277 <br/> |
|
278 <?php _e( 'This function(-s) will be removed over time. Please update the product(-s).', 'bestwebsoft' ); ?> |
|
279 </div> |
|
280 <?php if ( is_multisite() ) |
|
281 update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
|
282 else |
|
283 update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
98 } |
284 } |
99 } |
285 } |
100 } |
286 } |
101 |
287 |
102 if ( ! function_exists( 'bws_plugin_banner' ) ) { |
288 if ( ! function_exists( 'bws_plugin_banner' ) ) { |
103 function bws_plugin_banner( $plugin_info, $this_banner_prefix, $link_slug, $link_key, $link_pn, $banner_url_or_slug ) { |
289 function bws_plugin_banner( $plugin_info, $this_banner_prefix, $link_slug, $link_key, $link_pn, $banner_url_or_slug ) { |
104 global $wp_version, $bstwbsftwppdtplgns_cookie_add, $bstwbsftwppdtplgns_banner_array; |
290 global $wp_version, $bstwbsftwppdtplgns_cookie_add, $bstwbsftwppdtplgns_banner_array; |
105 |
291 |
106 if ( empty( $bstwbsftwppdtplgns_banner_array ) ) { |
292 if ( empty( $bstwbsftwppdtplgns_banner_array ) ) { |
107 if ( ! function_exists( 'bws_get_banner_array' ) ) |
293 if ( ! function_exists( 'bws_get_banner_array' ) ) |
108 require_once( dirname( __FILE__ ) . '/bws_menu.php' ); |
294 require_once( dirname( __FILE__ ) . '/bws_menu.php' ); |
109 bws_get_banner_array(); |
295 bws_get_banner_array(); |
110 } |
296 } |
163 } |
349 } |
164 } |
350 } |
165 } |
351 } |
166 } |
352 } |
167 |
353 |
168 if ( ! function_exists( 'bws_plugin_reviews_block' ) ) { |
|
169 function bws_plugin_reviews_block( $plugin_name, $plugin_slug ) { ?> |
|
170 <div class="bws-plugin-reviews"> |
|
171 <div class="bws-plugin-reviews-rate"> |
|
172 <?php _e( 'If you enjoy our plugin, please give it 5 stars on WordPress', 'bestwebsoft' ); ?>: |
|
173 <a href="http://wordpress.org/support/view/plugin-reviews/<?php echo $plugin_slug; ?>" target="_blank" title="<?php echo $plugin_name; ?> reviews"><?php _e( 'Rate the plugin', 'bestwebsoft' ); ?></a> |
|
174 </div> |
|
175 <div class="bws-plugin-reviews-support"> |
|
176 <?php _e( 'If there is something wrong about it, please contact us', 'bestwebsoft' ); ?>: |
|
177 <a href="http://support.bestwebsoft.com">http://support.bestwebsoft.com</a> |
|
178 </div> |
|
179 </div> |
|
180 <?php } |
|
181 } |
|
182 |
|
183 if ( ! function_exists( 'bws_go_pro_tab_check' ) ) { |
|
184 function bws_go_pro_tab_check( $plugin_basename ) { |
|
185 global $wp_version, $bstwbsftwppdtplgns_options; |
|
186 $result = array(); |
|
187 |
|
188 $bws_license_key = ( isset( $_POST['bws_license_key'] ) ) ? stripslashes( esc_html( trim( $_POST['bws_license_key'] ) ) ) : ""; |
|
189 |
|
190 if ( isset( $_POST['bws_license_submit'] ) && check_admin_referer( $plugin_basename, 'bws_license_nonce_name' ) ) { |
|
191 if ( '' != $bws_license_key ) { |
|
192 if ( strlen( $bws_license_key ) != 18 ) { |
|
193 $result['error'] = __( "Wrong license key", 'bestwebsoft' ); |
|
194 } else { |
|
195 $bws_license_plugin = stripslashes( esc_html( $_POST['bws_license_plugin'] ) ); |
|
196 if ( isset( $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['count'] ) && $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['time'] > ( time() - (24 * 60 * 60) ) ) { |
|
197 $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['count'] = $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['count'] + 1; |
|
198 } else { |
|
199 $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['count'] = 1; |
|
200 $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['time'] = time(); |
|
201 } |
|
202 |
|
203 /* download Pro */ |
|
204 if ( ! function_exists( 'get_plugins' ) ) |
|
205 require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
206 |
|
207 $all_plugins = get_plugins(); |
|
208 |
|
209 if ( ! array_key_exists( $bws_license_plugin, $all_plugins ) ) { |
|
210 $current = get_site_transient( 'update_plugins' ); |
|
211 if ( is_array( $all_plugins ) && !empty( $all_plugins ) && isset( $current ) && is_array( $current->response ) ) { |
|
212 $to_send = array(); |
|
213 $to_send["plugins"][ $bws_license_plugin ] = array(); |
|
214 $to_send["plugins"][ $bws_license_plugin ]["bws_license_key"] = $bws_license_key; |
|
215 $to_send["plugins"][ $bws_license_plugin ]["bws_illegal_client"] = true; |
|
216 $options = array( |
|
217 'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3 ), |
|
218 'body' => array( 'plugins' => serialize( $to_send ) ), |
|
219 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) ); |
|
220 $raw_response = wp_remote_post( 'http://bestwebsoft.com/wp-content/plugins/paid-products/plugins/update-check/1.0/', $options ); |
|
221 |
|
222 if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) ) { |
|
223 $result['error'] = __( "Something went wrong. Please try again later. If the error appears again, please contact us", 'bestwebsoft' ) . ' <a href="http://support.bestwebsoft.com">BestWebSoft</a>. ' . __( "We are sorry for inconvenience.", 'bestwebsoft' ); |
|
224 } else { |
|
225 $response = maybe_unserialize( wp_remote_retrieve_body( $raw_response ) ); |
|
226 if ( is_array( $response ) && !empty( $response ) ) { |
|
227 foreach ( $response as $key => $value ) { |
|
228 if ( "wrong_license_key" == $value->package ) { |
|
229 $result['error'] = __( "Wrong license key", 'bestwebsoft' ); |
|
230 } elseif ( "wrong_domain" == $value->package ) { |
|
231 $result['error'] = __( "This license key is bind to another site", 'bestwebsoft' ); |
|
232 } elseif ( "you_are_banned" == $value->package ) { |
|
233 $result['error'] = __( "Unfortunately, you have exceeded the number of available tries per day. Please, upload the plugin manually.", 'bestwebsoft' ); |
|
234 } elseif ( "time_out" == $value->package ) { |
|
235 $result['error'] = __( "Unfortunately, Your license has expired. To continue getting top-priority support and plugin updates you should extend it in your", 'bestwebsoft' ) . ' <a href="http://bestwebsoft.com/wp-admin/admin.php?page=bws_plugins_client_area">Client area</a>'; |
|
236 } elseif ( "duplicate_domen_for_trial" == $value->package ) { |
|
237 $result['error'] = __( "Unfortunately, the PRO licence was already installed to this domain. The PRO Trial license can be installed only once.", 'bestwebsoft' ); |
|
238 } |
|
239 } |
|
240 if ( empty( $result['error'] ) ) { |
|
241 $bstwbsftwppdtplgns_options[ $bws_license_plugin ] = $bws_license_key; |
|
242 |
|
243 $url = 'http://bestwebsoft.com/wp-content/plugins/paid-products/plugins/downloads/?bws_first_download=' . $bws_license_plugin . '&bws_license_key=' . $bws_license_key . '&download_from=5'; |
|
244 $uploadDir = wp_upload_dir(); |
|
245 $zip_name = explode( '/', $bws_license_plugin ); |
|
246 $received_content = file_get_contents( $url ); |
|
247 if ( ! $received_content ) { |
|
248 $result['error'] = __( "Failed to download the zip archive. Please, upload the plugin manually", 'bestwebsoft' ); |
|
249 } else { |
|
250 if ( is_writable( $uploadDir["path"] ) ) { |
|
251 $file_put_contents = $uploadDir["path"] . "/" . $zip_name[0] . ".zip"; |
|
252 if ( file_put_contents( $file_put_contents, $received_content ) ) { |
|
253 @chmod( $file_put_contents, octdec( 755 ) ); |
|
254 if ( class_exists( 'ZipArchive' ) ) { |
|
255 $zip = new ZipArchive(); |
|
256 if ( $zip->open( $file_put_contents ) === TRUE ) { |
|
257 $zip->extractTo( WP_PLUGIN_DIR ); |
|
258 $zip->close(); |
|
259 } else { |
|
260 $result['error'] = __( "Failed to open the zip archive. Please, upload the plugin manually", 'bestwebsoft' ); |
|
261 } |
|
262 } elseif ( class_exists( 'Phar' ) ) { |
|
263 $phar = new PharData( $file_put_contents ); |
|
264 $phar->extractTo( WP_PLUGIN_DIR ); |
|
265 } else { |
|
266 $result['error'] = __( "Your server does not support either ZipArchive or Phar. Please, upload the plugin manually", 'bestwebsoft' ); |
|
267 } |
|
268 @unlink( $file_put_contents ); |
|
269 } else { |
|
270 $result['error'] = __( "Failed to download the zip archive. Please, upload the plugin manually", 'bestwebsoft' ); |
|
271 } |
|
272 } else { |
|
273 $result['error'] = __( "UploadDir is not writable. Please, upload the plugin manually", 'bestwebsoft' ); |
|
274 } |
|
275 } |
|
276 |
|
277 /* activate Pro */ |
|
278 if ( file_exists( WP_PLUGIN_DIR . '/' . $zip_name[0] ) ) { |
|
279 if ( is_multisite() && is_plugin_active_for_network( plugin_basename( __FILE__ ) ) ) { |
|
280 /* if multisite and free plugin is network activated */ |
|
281 $active_plugins = get_site_option( 'active_sitewide_plugins' ); |
|
282 $active_plugins[ $bws_license_plugin ] = time(); |
|
283 update_site_option( 'active_sitewide_plugins', $active_plugins ); |
|
284 } else { |
|
285 /* activate on a single blog */ |
|
286 $active_plugins = get_option( 'active_plugins' ); |
|
287 array_push( $active_plugins, $bws_license_plugin ); |
|
288 update_option( 'active_plugins', $active_plugins ); |
|
289 } |
|
290 $result['pro_plugin_is_activated'] = true; |
|
291 } elseif ( empty( $result['error'] ) ) { |
|
292 $result['error'] = __( "Failed to download the zip archive. Please, upload the plugin manually", 'bestwebsoft' ); |
|
293 } |
|
294 } |
|
295 } else { |
|
296 $result['error'] = __( "Something went wrong. Try again later or upload the plugin manually. We are sorry for inconvenience.", 'bestwebsoft' ); |
|
297 } |
|
298 } |
|
299 } |
|
300 } else { |
|
301 $bstwbsftwppdtplgns_options[ $bws_license_plugin ] = $bws_license_key; |
|
302 /* activate Pro */ |
|
303 if ( ! is_plugin_active( $bws_license_plugin ) ) { |
|
304 if ( is_multisite() && is_plugin_active_for_network( plugin_basename( __FILE__ ) ) ) { |
|
305 /* if multisite and free plugin is network activated */ |
|
306 $network_wide = true; |
|
307 } else { |
|
308 /* activate on a single blog */ |
|
309 $network_wide = false; |
|
310 } |
|
311 activate_plugin( $bws_license_plugin, NULL, $network_wide ); |
|
312 $result['pro_plugin_is_activated'] = true; |
|
313 } |
|
314 } |
|
315 if ( is_multisite() ) |
|
316 update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
|
317 else |
|
318 update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
|
319 } |
|
320 } else { |
|
321 $result['error'] = __( "Please, enter Your license key", 'bestwebsoft' ); |
|
322 } |
|
323 } |
|
324 return $result; |
|
325 } |
|
326 } |
|
327 |
|
328 if ( ! function_exists( 'bws_go_pro_tab' ) ) { |
|
329 function bws_go_pro_tab( $plugin_info, $plugin_basename, $page, $pro_page, $bws_license_plugin, $link_slug, $link_key, $link_pn, $pro_plugin_is_activated = false, $trial_days_number = false ) { |
|
330 global $wp_version, $bstwbsftwppdtplgns_options; |
|
331 $bws_license_key = ( isset( $_POST['bws_license_key'] ) ) ? stripslashes( esc_html( trim( $_POST['bws_license_key'] ) ) ) : ""; |
|
332 if ( $pro_plugin_is_activated ) { ?> |
|
333 <script type="text/javascript"> |
|
334 window.setTimeout( function() { |
|
335 window.location.href = 'admin.php?page=<?php echo $pro_page; ?>'; |
|
336 }, 5000 ); |
|
337 </script> |
|
338 <p><?php _e( "Congratulations! The PRO version of the plugin is successfully download and activated.", 'bestwebsoft' ); ?></p> |
|
339 <p> |
|
340 <?php _e( "Please, go to", 'bestwebsoft' ); ?> <a href="admin.php?page=<?php echo $pro_page; ?>"><?php _e( 'the setting page', 'bestwebsoft' ); ?></a> |
|
341 (<?php _e( "You will be redirected automatically in 5 seconds.", 'bestwebsoft' ); ?>) |
|
342 </p> |
|
343 <?php } else { ?> |
|
344 <form method="post" action="admin.php?page=<?php echo $page; ?>&action=go_pro"> |
|
345 <p> |
|
346 <?php _e( 'You can download and activate', 'bestwebsoft' ); ?> |
|
347 <a href="http://bestwebsoft.com/products/<?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; ?>" target="_blank" title="<?php echo $plugin_info["Name"]; ?> Pro">PRO</a> |
|
348 <?php _e( 'version of this plugin by entering Your license key.', 'bestwebsoft' ); ?><br /> |
|
349 <span class="bws_info"> |
|
350 <?php _e( 'You can find your license key on your personal page Client area, by clicking on the link', 'bestwebsoft' ); ?> |
|
351 <a href="http://bestwebsoft.com/wp-login.php">http://bestwebsoft.com/wp-login.php</a> |
|
352 <?php _e( '(your username is the email you specify when purchasing the product).', 'bestwebsoft' ); ?> |
|
353 </span> |
|
354 </p> |
|
355 <?php if ( $trial_days_number !== false ) |
|
356 $trial_days_number = __( 'or', 'bestwebsoft' ) . ' <a href="http://bestwebsoft.com/products/' . $link_slug . '/trial/" target="_blank">' . sprintf( __( 'Start Your Free %s-Day Trial Now', 'bestwebsoft' ), $trial_days_number ) . '</a>'; |
|
357 if ( isset( $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['count'] ) && |
|
358 '5' < $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['count'] && |
|
359 $bstwbsftwppdtplgns_options['go_pro'][ $bws_license_plugin ]['time'] > ( time() - ( 24 * 60 * 60 ) ) ) { ?> |
|
360 <p> |
|
361 <input disabled="disabled" type="text" name="bws_license_key" value="<?php echo $bws_license_key; ?>" /> |
|
362 <input disabled="disabled" type="submit" class="button-primary" value="<?php _e( 'Activate', 'bestwebsoft' ); ?>" /> |
|
363 <?php if ( $trial_days_number !== false ) echo $trial_days_number; ?> |
|
364 </p> |
|
365 <p><?php _e( "Unfortunately, you have exceeded the number of available tries per day. Please, upload the plugin manually.", 'bestwebsoft' ); ?></p> |
|
366 <?php } else { ?> |
|
367 <p> |
|
368 <input type="text" name="bws_license_key" value="<?php echo $bws_license_key; ?>" /> |
|
369 <input type="hidden" name="bws_license_plugin" value="<?php echo $bws_license_plugin; ?>" /> |
|
370 <input type="hidden" name="bws_license_submit" value="submit" /> |
|
371 <input type="submit" class="button-primary" value="<?php _e( 'Activate', 'bestwebsoft' ); ?>" /> |
|
372 <?php if ( $trial_days_number !== false ) echo $trial_days_number; |
|
373 wp_nonce_field( $plugin_basename, 'bws_license_nonce_name' ); ?> |
|
374 </p> |
|
375 <?php } ?> |
|
376 </form> |
|
377 <?php } |
|
378 } |
|
379 } |
|
380 |
|
381 if ( ! function_exists( 'bws_go_pro_from_trial_tab' ) ) { |
|
382 function bws_go_pro_from_trial_tab( $plugin_info, $plugin_basename, $page, $link_slug, $link_key, $link_pn, $trial_license_is_set = true ) { |
|
383 global $wp_version, $bstwbsftwppdtplgns_options; |
|
384 $bws_license_key = ( isset( $_POST['bws_license_key'] ) ) ? stripslashes( esc_html( trim( $_POST['bws_license_key'] ) ) ) : ""; |
|
385 if ( $trial_license_is_set ) { ?> |
|
386 <form method="post" action="admin.php?page=<?php echo $page; ?>&action=go_pro"> |
|
387 <p> |
|
388 <?php echo sprintf( __( 'In order to continue using the plugin it is necessary to buy a %s license.', 'bestwebsoft' ), '<a href="http://bestwebsoft.com/products/' . $link_slug . '/?k=' . $link_key . '&pn=' . $link_pn . '&v=' . $plugin_info["Version"] . '&wp_v=' . $wp_version .'" target="_blank" title="' . $plugin_info["Name"] . '">PRO</a>' ) . ' '; |
|
389 _e( 'After that you can activate it by entering your license key.', 'bestwebsoft' ); ?><br /> |
|
390 <span class="bws_info"> |
|
391 <?php _e( 'You can find your license key on your personal page Client area, by clicking on the link', 'bestwebsoft' ); ?> |
|
392 <a href="http://bestwebsoft.com/wp-login.php">http://bestwebsoft.com/wp-login.php</a> |
|
393 <?php _e( '(your username is the email you specify when purchasing the product).', 'bestwebsoft' ); ?> |
|
394 </span> |
|
395 </p> |
|
396 <?php if ( isset( $bstwbsftwppdtplgns_options['go_pro'][ $plugin_basename ]['count'] ) && |
|
397 '5' < $bstwbsftwppdtplgns_options['go_pro'][ $plugin_basename ]['count'] && |
|
398 $bstwbsftwppdtplgns_options['go_pro'][ $plugin_basename ]['time'] > ( time() - ( 24 * 60 * 60 ) ) ) { ?> |
|
399 <p> |
|
400 <input disabled="disabled" type="text" name="bws_license_key" value="" /> |
|
401 <input disabled="disabled" type="submit" class="button-primary" value="<?php _e( 'Activate', 'bestwebsoft' ); ?>" /> |
|
402 </p> |
|
403 <p><?php _e( "Unfortunately, you have exceeded the number of available tries per day.", 'bestwebsoft' ); ?></p> |
|
404 <?php } else { ?> |
|
405 <p> |
|
406 <input type="text" name="bws_license_key" value="" /> |
|
407 <input type="hidden" name="bws_license_plugin" value="<?php echo $plugin_basename; ?>" /> |
|
408 <input type="hidden" name="bws_license_submit" value="submit" /> |
|
409 <input type="submit" class="button-primary" value="<?php _e( 'Activate', 'bestwebsoft' ); ?>" /> |
|
410 <?php wp_nonce_field( $plugin_basename, 'bws_license_nonce_name' ); ?> |
|
411 </p> |
|
412 <?php } ?> |
|
413 </form> |
|
414 <?php } else { ?> |
|
415 <script type="text/javascript"> |
|
416 window.setTimeout( function() { |
|
417 window.location.href = 'admin.php?page=<?php echo $page; ?>'; |
|
418 }, 5000 ); |
|
419 </script> |
|
420 <p><?php _e( "Congratulations! The PRO license of the plugin is successfully activated.", 'bestwebsoft' ); ?></p> |
|
421 <p> |
|
422 <?php _e( "Please, go to", 'bestwebsoft' ); ?> <a href="admin.php?page=<?php echo $page; ?>"><?php _e( 'the setting page', 'bestwebsoft' ); ?></a> |
|
423 (<?php _e( "You will be redirected automatically in 5 seconds.", 'bestwebsoft' ); ?>) |
|
424 </p> |
|
425 <?php } |
|
426 } |
|
427 } |
|
428 |
|
429 if ( ! function_exists( 'bws_check_pro_license' ) ) { |
|
430 function bws_check_pro_license( $plugin_basename, $trial_plugin = false ) { |
|
431 global $wp_version, $bstwbsftwppdtplgns_options; |
|
432 $result = array(); |
|
433 |
|
434 if ( isset( $_POST['bws_license_submit'] ) && check_admin_referer( $plugin_basename, 'bws_license_nonce_name' ) ) { |
|
435 $license_key = isset( $_POST['bws_license_key'] ) ? stripslashes( esc_html( trim( $_POST['bws_license_key'] ) ) ) : ''; |
|
436 |
|
437 if ( '' != $license_key ) { |
|
438 if ( ! function_exists( 'get_plugins' ) ) |
|
439 require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
440 $plugins_all = get_plugins(); |
|
441 $current = get_site_transient( 'update_plugins' ); |
|
442 |
|
443 if ( is_array( $plugins_all ) && !empty( $plugins_all ) && isset( $current ) && is_array( $current->response ) ) { |
|
444 $to_send = array(); |
|
445 $to_send["plugins"][ $plugin_basename ] = $plugins_all[ $plugin_basename ]; |
|
446 $to_send["plugins"][ $plugin_basename ]["bws_license_key"] = $license_key; |
|
447 $to_send["plugins"][ $plugin_basename ]["bws_illegal_client"] = true; |
|
448 $options = array( |
|
449 'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3), |
|
450 'body' => array( 'plugins' => serialize( $to_send ) ), |
|
451 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) |
|
452 ); |
|
453 $raw_response = wp_remote_post( 'http://bestwebsoft.com/wp-content/plugins/paid-products/plugins/update-check/1.0/', $options ); |
|
454 if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) ) { |
|
455 $result['error'] = __( 'Something went wrong. Please try again later. If the error appears again, please contact us', 'bestwebsoft' ) . ' <a href=http://support.bestwebsoft.com>BestWebSoft</a>. ' . __( 'We are sorry for inconvenience.', 'bestwebsoft' ); |
|
456 } else { |
|
457 $response = maybe_unserialize( wp_remote_retrieve_body( $raw_response ) ); |
|
458 if ( is_array( $response ) && !empty( $response ) ) { |
|
459 foreach ( $response as $key => $value ) { |
|
460 if ( "wrong_license_key" == $value->package ) { |
|
461 $result['error'] = __( 'Wrong license key.', 'bestwebsoft' ); |
|
462 } else if ( "wrong_domain" == $value->package ) { |
|
463 $result['error'] = __( 'This license key is bind to another site.', 'bestwebsoft' ); |
|
464 } else if ( "time_out" == $value->package ) { |
|
465 $result['message'] = __( 'This license key is valid, but Your license has expired. If you want to update our plugin in future, you should extend the license.', 'bestwebsoft' ); |
|
466 } elseif ( "you_are_banned" == $value->package ) { |
|
467 $result['error'] = __( "Unfortunately, you have exceeded the number of available tries.", 'bestwebsoft' ); |
|
468 } elseif ( "duplicate_domen_for_trial" == $value->package ) { |
|
469 $result['error'] = __( "Unfortunately, the PRO Trial licence was already installed to this domain. The PRO Trial license can be installed only once.", 'bestwebsoft' ); |
|
470 } |
|
471 if ( empty( $result['message'] ) && empty( $result['error'] ) ) { |
|
472 if ( isset( $value->trial ) ) |
|
473 $result['message'] = __( 'The PRO Trial license key is valid.', 'bestwebsoft' ); |
|
474 else |
|
475 $result['message'] = __( 'The license key is valid.', 'bestwebsoft' ); |
|
476 |
|
477 if ( isset( $value->time_out ) && $value->time_out != '' ) |
|
478 $result['message'] .= ' ' . __( 'Your license will expire on', 'bestwebsoft' ) . ' ' . $value->time_out . '.'; |
|
479 |
|
480 if ( isset( $value->trial ) && $trial_plugin != false ) |
|
481 $result['message'] .= ' ' . sprintf( __( 'In order to continue using the plugin it is necessary to buy a %s license.', 'bestwebsoft' ), '<a href="http://bestwebsoft.com/products/' . $trial_plugin['link_slug'] . '/?k=' . $trial_plugin['link_key'] . '&pn=' . $trial_plugin['link_pn'] . '&v=' . $trial_plugin['plugin_info']['Version'] . '&wp_v=' . $wp_version . '" target="_blank" title="' . $trial_plugin['plugin_info']['Name'] . '">PRO</a>' ); |
|
482 |
|
483 if ( isset( $value->trial ) ) { |
|
484 $bstwbsftwppdtplgns_options['trial'][ $plugin_basename ] = 1; |
|
485 } else { |
|
486 unset( $bstwbsftwppdtplgns_options['trial'][ $plugin_basename ] ); |
|
487 } |
|
488 } |
|
489 if ( empty( $result['error'] ) ) { |
|
490 if ( $bstwbsftwppdtplgns_options[ $plugin_basename ] != $license_key ) { |
|
491 $bstwbsftwppdtplgns_options[ $plugin_basename ] = $license_key; |
|
492 $bstwbsftwppdtplgns_options['time_out'][ $plugin_basename ] = $value->time_out; |
|
493 if ( is_multisite() ) |
|
494 update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
|
495 else |
|
496 update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
|
497 $file = @fopen( dirname( dirname( __FILE__ ) ) . "/license_key.txt" , "w+" ); |
|
498 if ( $file ) { |
|
499 @fwrite( $file, $license_key ); |
|
500 @fclose( $file ); |
|
501 } |
|
502 } |
|
503 } |
|
504 } |
|
505 } else { |
|
506 $result['error'] = __( 'Something went wrong. Please try again later. If the error appears again, please contact us', 'bestwebsoft' ) . ' <a href=http://support.bestwebsoft.com>BestWebSoft</a>. ' . __( 'We are sorry for inconvenience.', 'bestwebsoft' ); |
|
507 } |
|
508 } |
|
509 } |
|
510 } else { |
|
511 $result['error'] = __( 'Please, enter your license key', 'bestwebsoft' ); |
|
512 } |
|
513 } |
|
514 return $result; |
|
515 } |
|
516 } |
|
517 |
|
518 if ( ! function_exists ( 'bws_check_pro_license_form' ) ) { |
|
519 function bws_check_pro_license_form( $plugin_basename, $page ) { |
|
520 global $bstwbsftwppdtplgns_options; |
|
521 $license_key = ( isset( $bstwbsftwppdtplgns_options[ $plugin_basename ] ) ) ? $bstwbsftwppdtplgns_options[ $plugin_basename ] : ''; ?> |
|
522 <div class="clear"></div> |
|
523 <form method="post" action="admin.php?page=<?php echo $page; ?>"> |
|
524 <p><?php echo _e( 'If needed you can check if the license key is correct or reenter it in the field below. You can find your license key on your personal page - Client area - on our website', 'bestwebsoft' ) . ' <a href="http://bestwebsoft.com/wp-login.php">http://bestwebsoft.com/wp-login.php</a> ' . __( '(your username is the email you specify when purchasing the product). If necessary, please submit "Lost your password?" request.', 'bestwebsoft' ); ?></p> |
|
525 <p> |
|
526 <input type="text" name="bws_license_key" value="<?php echo $license_key; ?>" /> |
|
527 <input type="hidden" name="bws_license_submit" value="submit" /> |
|
528 <input type="submit" class="button-primary" value="<?php _e( 'Check license key', 'bestwebsoft' ) ?>" /> |
|
529 <?php wp_nonce_field( $plugin_basename, 'bws_license_nonce_name' ); ?> |
|
530 </p> |
|
531 </form> |
|
532 <?php } |
|
533 } |
|
534 |
|
535 if ( ! function_exists ( 'bws_plugin_update_row' ) ) { |
|
536 function bws_plugin_update_row( $plugin_key, $link_slug = false, $free_plugin_name = false ) { |
|
537 global $bstwbsftwppdtplgns_options; |
|
538 $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
|
539 if ( isset( $bstwbsftwppdtplgns_options['wrong_license_key'][ $plugin_key ] ) ) { |
|
540 echo '<tr class="plugin-update-tr"> |
|
541 <td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"> |
|
542 <div class="update-message" style="background-color: #FFEBE8; border-color: #CC0000;"><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="http://support.bestwebsoft.com/hc/en-us/articles/204240089">' . __( 'Learn More', 'bestwebsoft' ) . '</a></div> |
|
543 </td> |
|
544 </tr>'; |
|
545 } elseif ( isset( $bstwbsftwppdtplgns_options['time_out'][ $plugin_key ] ) && strtotime( $bstwbsftwppdtplgns_options['time_out'][ $plugin_key ] ) < strtotime( date("m/d/Y") ) ) { |
|
546 echo '<tr class="plugin-update-tr"> |
|
547 <td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"> |
|
548 <div class="update-message" style="color: #8C0000;">'; |
|
549 if ( isset( $bstwbsftwppdtplgns_options['trial'][ $plugin_key ] ) && $link_slug != false ) { |
|
550 echo __( 'Notice: Your PRO Trial license has expired. To continue using the plugin you should buy a PRO license', 'bestwebsoft' ) . ' - <a href="http://bestwebsoft.com/products/' . $link_slug .'/">http://bestwebsoft.com/products/' . $link_slug . '/</a>'; |
|
551 } else { |
|
552 echo __( 'Your license has expired. To continue getting top-priority support and plugin updates you should extend it.', 'bestwebsoft' ) . ' <a target="_new" href="http://support.bestwebsoft.com/entries/53487136">' . __( "Learn more", 'bestwebsoft' ) . '</a>'; |
|
553 } |
|
554 echo '</div> |
|
555 </td> |
|
556 </tr>'; |
|
557 } elseif ( isset( $bstwbsftwppdtplgns_options['trial'][ $plugin_key ] ) ) { |
|
558 echo '<tr class="plugin-update-tr"> |
|
559 <td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"> |
|
560 <div class="update-message" style="color: #8C0000;">'; |
|
561 if ( $free_plugin_name != false ) { |
|
562 echo sprintf( __( 'Notice: You are using the PRO Trial license of %s plugin.', 'bestwebsoft' ), $free_plugin_name ); |
|
563 } else { |
|
564 _e( 'Notice: You are using the PRO Trial license of plugin.', 'bestwebsoft' ); |
|
565 } |
|
566 if ( isset( $bstwbsftwppdtplgns_options['time_out'][ $plugin_key ] ) ) |
|
567 echo ' ' . __( "The PRO Trial license will expire on", 'bestwebsoft' ) . ' ' . $bstwbsftwppdtplgns_options['time_out'][ $plugin_key ] . '.'; |
|
568 echo '</div> |
|
569 </td> |
|
570 </tr>'; |
|
571 } |
|
572 } |
|
573 } |
|
574 |
|
575 if ( ! function_exists ( 'bws_plugin_banner_timeout' ) ) { |
354 if ( ! function_exists ( 'bws_plugin_banner_timeout' ) ) { |
576 function bws_plugin_banner_timeout( $plugin_key, $plugin_prefix, $plugin_name, $banner_url = false ) { |
355 function bws_plugin_banner_timeout( $plugin_key, $plugin_prefix, $plugin_name, $banner_url_or_slug = false ) { |
577 global $bstwbsftwppdtplgns_options, $bstwbsftwppdtplgns_cookie_add; |
356 global $bstwbsftwppdtplgns_options, $bstwbsftwppdtplgns_cookie_add; |
578 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") ) ) ) { |
357 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") ) ) ) { |
|
358 |
|
359 if ( $banner_url_or_slug && false == strrpos( $banner_url_or_slug, '/' ) ) { |
|
360 $banner_url_or_slug = '//ps.w.org/' . $banner_url_or_slug . '/assets/icon-128x128.png'; |
|
361 } |
|
362 |
579 if ( ! isset( $bstwbsftwppdtplgns_cookie_add ) ) { |
363 if ( ! isset( $bstwbsftwppdtplgns_cookie_add ) ) { |
580 echo '<script type="text/javascript" src="' . plugins_url( 'js/c_o_o_k_i_e.js', __FILE__ ) . '"></script>'; |
364 echo '<script type="text/javascript" src="' . bws_menu_url( 'js/c_o_o_k_i_e.js' ) . '"></script>'; |
581 $bstwbsftwppdtplgns_cookie_add = true; |
365 $bstwbsftwppdtplgns_cookie_add = true; |
582 } ?> |
366 } ?> |
583 <script type="text/javascript"> |
367 <script type="text/javascript"> |
584 (function($) { |
368 (function($) { |
585 $(document).ready( function() { |
369 $(document).ready( function() { |
586 var hide_message = $.cookie( "<?php echo $plugin_prefix; ?>_timeout_hide_banner_on_plugin_page" ); |
370 var hide_message = $.cookie( "<?php echo $plugin_prefix; ?>_timeout_hide_banner_on_plugin_page" ); |
587 if ( hide_message == "true" ) { |
371 if ( hide_message == "true" ) { |
588 $( ".<?php echo $plugin_prefix; ?>_message" ).css( "display", "none" ); |
372 $( ".<?php echo $plugin_prefix; ?>_message_timeout" ).css( "display", "none" ); |
589 } else { |
373 } else { |
590 $( ".<?php echo $plugin_prefix; ?>_message" ).css( "display", "block" ); |
374 $( ".<?php echo $plugin_prefix; ?>_message_timeout" ).css( "display", "block" ); |
591 } |
375 } |
592 $( ".<?php echo $plugin_prefix; ?>_close_icon" ).click( function() { |
376 $( ".<?php echo $plugin_prefix; ?>_close_icon" ).click( function() { |
593 $( ".<?php echo $plugin_prefix; ?>_message" ).css( "display", "none" ); |
377 $( ".<?php echo $plugin_prefix; ?>_message_timeout" ).css( "display", "none" ); |
594 $.cookie( "<?php echo $plugin_prefix; ?>_timeout_hide_banner_on_plugin_page", "true", { expires: 30 } ); |
378 $.cookie( "<?php echo $plugin_prefix; ?>_timeout_hide_banner_on_plugin_page", "true", { expires: 30 } ); |
595 }); |
379 }); |
596 }); |
380 }); |
597 })(jQuery); |
381 })(jQuery); |
598 </script> |
382 </script> |
599 <div class="updated" style="padding: 0; margin: 0; border: none; background: none;"> |
383 <div class="updated" style="padding: 0; margin: 0; border: none; background: none;"> |
600 <div class="<?php echo $plugin_prefix; ?>_message bws_banner_on_plugin_page" style="display:none;"> |
384 <div class="<?php echo $plugin_prefix; ?>_message_timeout bws_banner_on_plugin_page bws_banner_timeout" style="display:none;"> |
601 <img class="<?php echo $plugin_prefix; ?>_close_icon close_icon" title="" src="<?php echo plugins_url( 'images/close_banner.png', __FILE__ ); ?>" alt=""/> |
385 <button class="<?php echo $plugin_prefix; ?>_close_icon close_icon notice-dismiss bws_hide_settings_notice" title="<?php _e( 'Close notice', 'bestwebsoft' ); ?>"></button> |
602 <div class="icon"> |
386 <div class="icon"> |
603 <img title="" src="<?php echo $banner_url; ?>" alt="" /> |
387 <img title="" src="<?php echo esc_attr( $banner_url_or_slug ); ?>" alt="" /> |
604 </div> |
388 </div> |
605 <div class="text"><?php _e( "You license for", 'bestwebsoft' ); ?> <strong><?php echo $plugin_name; ?></strong> <?php echo __( "expires on", 'bestwebsoft' ) . ' ' . $bstwbsftwppdtplgns_options['time_out'][ $plugin_key ] . ' ' . __( "and you won't be granted TOP-PRIORITY SUPPORT or UPDATES.", 'bestwebsoft' ); ?> <a target="_new" href="http://support.bestwebsoft.com/entries/53487136"><?php _e( "Learn more", 'bestwebsoft' ); ?></a></div> |
389 <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> |
606 </div> |
390 </div> |
607 </div> |
391 </div> |
608 <?php } |
392 <?php } |
609 } |
393 } |
610 } |
394 } |
611 |
395 |
612 if ( ! function_exists ( 'bws_plugin_init' ) ) { |
396 if ( ! function_exists( 'bws_plugin_banner_to_settings' ) ) { |
613 function bws_plugin_init() { |
397 function bws_plugin_banner_to_settings( $plugin_info, $plugin_options_name, $banner_url_or_slug, $settings_url, $post_type_url = false ) { |
614 /* Internationalization, first(!) */ |
398 global $bws_plugin_banner_to_settings; |
615 load_plugin_textdomain( 'bestwebsoft', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); |
399 |
616 } |
400 $is_network_admin = is_network_admin(); |
617 } |
401 |
618 |
402 $plugin_options = $is_network_admin ? get_site_option( $plugin_options_name ) : get_option( $plugin_options_name ); |
619 if ( ! function_exists ( 'bws_admin_add_scripts' ) ) { |
403 |
620 function bws_admin_add_scripts() { |
404 if ( isset( $plugin_options['display_settings_notice'] ) && 0 == $plugin_options['display_settings_notice'] ) |
621 global $wp_version; |
405 return; |
622 if ( $wp_version < 3.8 ) |
406 |
623 wp_enqueue_style( 'bws-admin-style', plugins_url( 'css/general_style_wp_before_3.8.css', __FILE__ ) ); |
407 if ( isset( $_POST['bws_hide_settings_notice_' . $plugin_options_name ] ) && check_admin_referer( plugin_basename( __FILE__ ), 'bws_settings_nonce_name' ) ) { |
|
408 $plugin_options['display_settings_notice'] = 0; |
|
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 return; |
|
414 } |
|
415 |
|
416 if ( false == strrpos( $banner_url_or_slug, '/' ) ) { |
|
417 $banner_url_or_slug = '//ps.w.org/' . $banner_url_or_slug . '/assets/icon-128x128.png'; |
|
418 } |
|
419 |
|
420 $bws_plugin_banner_to_settings[] = array( |
|
421 'plugin_info' => $plugin_info, |
|
422 'plugin_options_name' => $plugin_options_name, |
|
423 'banner_url' => $banner_url_or_slug, |
|
424 'settings_url' => $settings_url, |
|
425 'post_type_url' => $post_type_url |
|
426 ); |
|
427 } |
|
428 } |
|
429 |
|
430 if ( ! function_exists( 'bws_plugin_suggest_feature_banner' ) ) { |
|
431 function bws_plugin_suggest_feature_banner( $plugin_info, $plugin_options_name, $banner_url_or_slug ) { |
|
432 $is_network_admin = is_network_admin(); |
|
433 |
|
434 $plugin_options = $is_network_admin ? get_site_option( $plugin_options_name ) : get_option( $plugin_options_name ); |
|
435 |
|
436 if ( isset( $plugin_options['display_suggest_feature_banner'] ) && 0 == $plugin_options['display_suggest_feature_banner'] ) |
|
437 return; |
|
438 |
|
439 if ( ! isset( $plugin_options['first_install'] ) ) { |
|
440 $plugin_options['first_install'] = strtotime( "now" ); |
|
441 $update_option = $return = true; |
|
442 } elseif ( strtotime( '-2 week' ) < $plugin_options['first_install'] ) { |
|
443 $return = true; |
|
444 } |
|
445 |
|
446 if ( ! isset( $plugin_options['go_settings_counter'] ) ) { |
|
447 $plugin_options['go_settings_counter'] = 1; |
|
448 $update_option = $return = true; |
|
449 } elseif ( 20 > $plugin_options['go_settings_counter'] ) { |
|
450 $plugin_options['go_settings_counter'] = $plugin_options['go_settings_counter'] + 1; |
|
451 $update_option = $return = true; |
|
452 } |
|
453 |
|
454 if ( isset( $update_option ) ) { |
|
455 if ( $is_network_admin ) |
|
456 update_site_option( $plugin_options_name, $plugin_options ); |
|
457 else |
|
458 update_option( $plugin_options_name, $plugin_options ); |
|
459 } |
|
460 |
|
461 if ( isset( $return ) ) |
|
462 return; |
|
463 |
|
464 if ( isset( $_POST['bws_hide_suggest_feature_banner_' . $plugin_options_name ] ) && check_admin_referer( $plugin_info['Name'], 'bws_settings_nonce_name' ) ) { |
|
465 $plugin_options['display_suggest_feature_banner'] = 0; |
|
466 if ( $is_network_admin ) |
|
467 update_site_option( $plugin_options_name, $plugin_options ); |
|
468 else |
|
469 update_option( $plugin_options_name, $plugin_options ); |
|
470 return; |
|
471 } |
|
472 |
|
473 if ( false == strrpos( $banner_url_or_slug, '/' ) ) { |
|
474 $banner_url_or_slug = '//ps.w.org/' . $banner_url_or_slug . '/assets/icon-128x128.png'; |
|
475 } ?> |
|
476 <div class="updated" style="padding: 0; margin: 0; border: none; background: none;"> |
|
477 <div class="bws_banner_on_plugin_page bws_suggest_feature_banner"> |
|
478 <div class="icon"> |
|
479 <img title="" src="<?php echo esc_attr( $banner_url_or_slug ); ?>" alt="" /> |
|
480 </div> |
|
481 <div class="text"> |
|
482 <strong><?php printf( __( 'Thank you for choosing %s plugin!', 'bestwebsoft' ), $plugin_info['Name'] ); ?></strong><br /> |
|
483 <?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' ); ?> |
|
484 <a target="_blank" href="https://support.bestwebsoft.com/hc/en-us/requests/new"><?php _e( 'Suggest a Feature', 'bestwebsoft' ); ?></a> |
|
485 </div> |
|
486 <form action="" method="post"> |
|
487 <button class="notice-dismiss bws_hide_settings_notice" title="<?php _e( 'Close notice', 'bestwebsoft' ); ?>"></button> |
|
488 <input type="hidden" name="bws_hide_suggest_feature_banner_<?php echo $plugin_options_name; ?>" value="hide" /> |
|
489 <?php wp_nonce_field( $plugin_info['Name'], 'bws_settings_nonce_name' ); ?> |
|
490 </form> |
|
491 </div> |
|
492 </div> |
|
493 <?php } |
|
494 } |
|
495 |
|
496 if ( ! function_exists( 'bws_show_settings_notice' ) ) { |
|
497 function bws_show_settings_notice() { ?> |
|
498 <div id="bws_save_settings_notice" class="updated fade below-h2" style="display:none;"> |
|
499 <p> |
|
500 <strong><?php _e( 'Notice', 'bestwebsoft' ); ?></strong>: <?php _e( "The plugin's settings have been changed.", 'bestwebsoft' ); ?> |
|
501 <a class="bws_save_anchor" href="#bws-submit-button"><?php _e( 'Save Changes', 'bestwebsoft' ); ?></a> |
|
502 </p> |
|
503 </div> |
|
504 <?php } |
|
505 } |
|
506 |
|
507 if ( ! function_exists( 'bws_hide_premium_options' ) ) { |
|
508 function bws_hide_premium_options( $options ) { |
|
509 if ( ! isset( $options['hide_premium_options'] ) || ! is_array( $options['hide_premium_options'] ) ) |
|
510 $options['hide_premium_options'] = array(); |
|
511 |
|
512 $options['hide_premium_options'][] = get_current_user_id(); |
|
513 |
|
514 return array( |
|
515 'message' => __( 'You can always look at premium options by checking the "Pro Options" in the "Misc" tab.', 'bestwebsoft' ), |
|
516 'options' => $options ); |
|
517 } |
|
518 } |
|
519 |
|
520 if ( ! function_exists( 'bws_hide_premium_options_check' ) ) { |
|
521 function bws_hide_premium_options_check( $options ) { |
|
522 if ( ! empty( $options['hide_premium_options'] ) && in_array( get_current_user_id(), $options['hide_premium_options'] ) ) |
|
523 return true; |
624 else |
524 else |
625 wp_enqueue_style( 'bws-admin-style', plugins_url( 'css/general_style.css', __FILE__ ) ); |
525 return false; |
626 |
526 } |
627 if ( isset( $_GET['page'] ) && $_GET['page'] == "bws_plugins" ) { |
527 } |
628 wp_enqueue_style( 'bws_menu_style', plugins_url( 'css/style.css', __FILE__ ) ); |
528 |
629 wp_enqueue_script( 'bws_menu_script', plugins_url( 'js/bws_menu.js' , __FILE__ ) ); |
529 if ( ! function_exists ( 'bws_plugins_admin_init' ) ) { |
630 if ( $wp_version >= '3.8' ) |
530 function bws_plugins_admin_init() { |
631 wp_enqueue_script( 'theme-install' ); |
531 if ( isset( $_GET['bws_activate_plugin'] ) && check_admin_referer( 'bws_activate_plugin' . $_GET['bws_activate_plugin'] ) ) { |
632 elseif ( $wp_version >= '3.4' ) |
532 |
633 wp_enqueue_script( 'theme' ); |
533 $plugin = isset( $_GET['bws_activate_plugin'] ) ? sanitize_text_field( $_GET['bws_activate_plugin'] ) : ''; |
634 } |
534 $result = activate_plugin( $plugin, '', is_network_admin() ); |
635 } |
535 if ( is_wp_error( $result ) ) { |
636 } |
536 if ( 'unexpected_output' == $result->get_error_code() ) { |
637 |
537 $redirect = self_admin_url( 'admin.php?page=bws_panel&error=true&charsout=' . strlen( $result->get_error_data() ) . '&plugin=' . $plugin ); |
638 if ( ! function_exists ( 'bws_admin_head' ) ) { |
538 wp_redirect( add_query_arg( '_error_nonce', wp_create_nonce( 'plugin-activation-error_' . $plugin ), $redirect ) ); |
639 function bws_admin_head() { |
539 exit(); |
640 if ( isset( $_GET['page'] ) && $_GET['page'] == "bws_plugins" ) { ?> |
540 } else { |
|
541 wp_die( $result ); |
|
542 } |
|
543 } |
|
544 |
|
545 if ( ! is_network_admin() ) { |
|
546 $recent = (array) get_option( 'recently_activated' ); |
|
547 unset( $recent[ $plugin ] ); |
|
548 update_option( 'recently_activated', $recent ); |
|
549 } else { |
|
550 $recent = (array) get_site_option( 'recently_activated' ); |
|
551 unset( $recent[ $plugin ] ); |
|
552 update_site_option( 'recently_activated', $recent ); |
|
553 } |
|
554 /** |
|
555 * @deprecated 1.9.8 (15.12.2016) |
|
556 */ |
|
557 $is_main_page = in_array( $_GET['page'], array( 'bws_panel', 'bws_themes', 'bws_system_status' ) ); |
|
558 $page = esc_attr( $_GET['page'] ); |
|
559 $tab = isset( $_GET['tab'] ) ? esc_attr( $_GET['tab'] ) : ''; |
|
560 |
|
561 if ( $is_main_page ) |
|
562 $current_page = 'admin.php?page=' . $page; |
|
563 else |
|
564 $current_page = isset( $_GET['tab'] ) ? 'admin.php?page=' . $page . '&tab=' . $tab : 'admin.php?page=' . $page; |
|
565 /*end deprecated */ |
|
566 |
|
567 wp_redirect( self_admin_url( $current_page . '&activate=true' ) ); |
|
568 exit(); |
|
569 } |
|
570 |
|
571 if ( isset( $_GET['page'] ) && ( $_GET['page'] == 'bws_panel' || strpos( $_GET['page'], '-bws-panel' ) ) ) { |
|
572 if ( ! session_id() ) |
|
573 @session_start(); |
|
574 } |
|
575 |
|
576 bws_add_editor_buttons(); |
|
577 } |
|
578 } |
|
579 |
|
580 if ( ! function_exists ( 'bws_admin_enqueue_scripts' ) ) { |
|
581 function bws_admin_enqueue_scripts() { |
|
582 global $wp_scripts, $hook_suffix; |
|
583 |
|
584 $jquery_version = isset( $wp_scripts->registered['jquery-ui-core']->ver ) ? $wp_scripts->registered['jquery-ui-core']->ver : '1.12.1'; |
|
585 |
|
586 wp_enqueue_style( 'jquery-ui-style', '//code.jquery.com/ui/' . $jquery_version . '/themes/smoothness/jquery-ui.min.css', array(), $jquery_version ); |
|
587 wp_enqueue_style( 'bws-admin-css', bws_menu_url( 'css/general_style.css' ) ); |
|
588 wp_enqueue_script( 'bws-admin-scripts', bws_menu_url( 'js/general_script.js' ), array( 'jquery', 'jquery-ui-tooltip' ) ); |
|
589 |
|
590 if ( isset( $_GET['page'] ) && ( in_array( $_GET['page'], array( 'bws_panel', 'bws_themes', 'bws_system_status' ) ) || strpos( $_GET['page'], '-bws-panel' ) ) ) { |
|
591 wp_enqueue_style( 'bws_menu_style', bws_menu_url( 'css/style.css' ) ); |
|
592 wp_enqueue_script( 'bws_menu_script', bws_menu_url( 'js/bws_menu.js' ) ); |
|
593 wp_enqueue_script( 'theme-install' ); |
|
594 add_thickbox(); |
|
595 wp_enqueue_script( 'plugin-install' ); |
|
596 } |
|
597 |
|
598 if ( 'plugins.php' == $hook_suffix && ! defined( 'DOING_AJAX' ) ) { |
|
599 wp_enqueue_style( 'bws-modal-css', bws_menu_url( 'css/modal.css' ) ); |
|
600 } |
|
601 } |
|
602 } |
|
603 |
|
604 /** |
|
605 * add styles and scripts for Bws_Settings_Tabs |
|
606 * |
|
607 * @since 1.9.8 |
|
608 */ |
|
609 if ( ! function_exists( 'bws_enqueue_settings_scripts' ) ) { |
|
610 function bws_enqueue_settings_scripts() { |
|
611 wp_enqueue_script( 'jquery-ui-resizable' ); |
|
612 wp_enqueue_script( 'jquery-ui-tabs' ); |
|
613 } |
|
614 } |
|
615 |
|
616 if ( ! function_exists ( 'bws_plugins_admin_head' ) ) { |
|
617 function bws_plugins_admin_head() { |
|
618 global $bws_shortcode_list, $wp_version, $post_type; |
|
619 if ( isset( $_GET['page'] ) && $_GET['page'] == "bws_panel" ) { ?> |
641 <noscript> |
620 <noscript> |
642 <style type="text/css"> |
621 <style type="text/css"> |
643 .bws_product_button { |
622 .bws_product_button { |
644 display: inline-block; |
623 display: inline-block; |
645 } |
624 } |
646 </style> |
625 </style> |
647 </noscript> |
626 </noscript> |
648 <?php } |
627 <?php } |
649 } |
628 if ( 4.2 > $wp_version ) { ?> |
|
629 <style type="text/css"> |
|
630 .bws_hide_settings_notice, |
|
631 .bws_hide_premium_options { |
|
632 width: 11px; |
|
633 height: 11px; |
|
634 border: none; |
|
635 background: url("<?php echo bws_menu_url( 'images/close_banner.png' ); ?>") no-repeat center center; |
|
636 box-shadow: none; |
|
637 float: right; |
|
638 margin: 8px; |
|
639 } |
|
640 .bws_hide_settings_notice:hover, |
|
641 .bws_hide_premium_options:hover { |
|
642 cursor: pointer; |
|
643 } |
|
644 .bws_hide_premium_options { |
|
645 position: relative; |
|
646 } |
|
647 </style> |
|
648 <?php } |
|
649 if ( ! empty( $bws_shortcode_list ) ) { ?> |
|
650 <!-- TinyMCE Shortcode Plugin --> |
|
651 <script type='text/javascript'> |
|
652 var bws_shortcode_button = { |
|
653 'label': '<?php esc_attr_e( "Add BWS Shortcode", "bestwebsoft" ); ?>', |
|
654 'title': '<?php esc_attr_e( "Add BWS Plugins Shortcode", "bestwebsoft" ); ?>', |
|
655 'function_name': [ |
|
656 <?php foreach ( $bws_shortcode_list as $key => $value ) { |
|
657 if ( isset( $value['js_function'] ) ) |
|
658 echo "'" . $value['js_function'] . "',"; |
|
659 } ?> |
|
660 ], |
|
661 'wp_version' : '<?php echo $wp_version; ?>' |
|
662 }; |
|
663 </script> |
|
664 <!-- TinyMCE Shortcode Plugin --> |
|
665 <?php if ( isset( $post_type ) && in_array( $post_type, array( 'post', 'page' ) ) ) { |
|
666 $tooltip_args = array( |
|
667 'tooltip_id' => 'bws_shortcode_button_tooltip', |
|
668 'css_selector' => '.mce-bws_shortcode_button', |
|
669 'actions' => array( |
|
670 'click' => false, |
|
671 'onload' => true |
|
672 ), |
|
673 'content' => '<h3>' . __( 'Add shortcode', 'bestwebsoft' ) . '</h3><p>' . __( "Add BestWebSoft plugins' shortcodes using this button.", 'bestwebsoft' ) . '</p>', |
|
674 'position' => array( |
|
675 'edge' => 'right' |
|
676 ), |
|
677 'set_timeout' => 2000 |
|
678 ); |
|
679 bws_add_tooltip_in_admin( $tooltip_args ); |
|
680 } |
|
681 } |
|
682 } |
|
683 } |
|
684 |
|
685 if ( ! function_exists ( 'bws_plugins_admin_footer' ) ) { |
|
686 function bws_plugins_admin_footer() { |
|
687 global $hook_suffix; |
|
688 |
|
689 bws_shortcode_media_button_popup(); |
|
690 |
|
691 if ( 'plugins.php' == $hook_suffix && ! defined( 'DOING_AJAX' ) ) { |
|
692 bws_add_deactivation_feedback_dialog_box(); |
|
693 } |
|
694 } |
|
695 } |
|
696 |
|
697 if ( ! function_exists ( 'bws_plugins_include_codemirror' ) ) { |
|
698 function bws_plugins_include_codemirror() { |
|
699 wp_enqueue_style( 'codemirror.css', bws_menu_url( 'css/codemirror.css' ) ); |
|
700 wp_enqueue_script( 'codemirror.js', bws_menu_url( 'js/codemirror.js' ), array( 'jquery' ) ); |
|
701 } |
650 } |
702 } |
651 |
703 |
652 /** |
704 /** |
653 * Tooltip block |
705 * Tooltip block |
654 */ |
706 */ |
763 </script> |
813 </script> |
764 <?php } |
814 <?php } |
765 } |
815 } |
766 } |
816 } |
767 |
817 |
768 add_action( 'admin_init', 'bws_plugin_init' ); |
818 if ( ! function_exists ( 'bws_form_restore_default_confirm' ) ) { |
769 add_action( 'admin_enqueue_scripts', 'bws_admin_add_scripts' ); |
819 function bws_form_restore_default_confirm( $plugin_basename ) { ?> |
770 add_action( 'admin_head', 'bws_admin_head' ); |
820 <div> |
|
821 <p><?php _e( 'Are you sure you want to restore default settings?', 'bestwebsoft' ) ?></p> |
|
822 <form method="post" action=""> |
|
823 <p> |
|
824 <button class="button button-primary" name="bws_restore_confirm"><?php _e( 'Yes, restore all settings', 'bestwebsoft' ) ?></button> |
|
825 <button class="button" name="bws_restore_deny"><?php _e( 'No, go back to the settings page', 'bestwebsoft' ) ?></button> |
|
826 <?php wp_nonce_field( $plugin_basename, 'bws_settings_nonce_name' ); ?> |
|
827 </p> |
|
828 </form> |
|
829 </div> |
|
830 <?php } |
|
831 } |
|
832 |
|
833 /* shortcode */ |
|
834 if ( ! function_exists( 'bws_add_editor_buttons' ) ) { |
|
835 function bws_add_editor_buttons() { |
|
836 global $bws_shortcode_list; |
|
837 if ( ! empty( $bws_shortcode_list ) && current_user_can( 'edit_posts' ) && current_user_can( 'edit_pages' ) ) { |
|
838 add_filter( 'mce_external_plugins', 'bws_add_buttons' ); |
|
839 add_filter( 'mce_buttons', 'bws_register_buttons' ); |
|
840 } |
|
841 } |
|
842 } |
|
843 |
|
844 if ( ! function_exists( 'bws_add_buttons' ) ){ |
|
845 function bws_add_buttons( $plugin_array ) { |
|
846 $plugin_array['add_bws_shortcode'] = bws_menu_url( 'js/shortcode-button.js' ); |
|
847 return $plugin_array; |
|
848 } |
|
849 } |
|
850 |
|
851 if ( ! function_exists( 'bws_register_buttons' ) ) { |
|
852 function bws_register_buttons( $buttons ) { |
|
853 array_push( $buttons, 'add_bws_shortcode' ); /* dropcap', 'recentposts */ |
|
854 return $buttons; |
|
855 } |
|
856 } |
|
857 |
|
858 /* Generate inline content for the popup window when the "bws shortcode" button is clicked */ |
|
859 if ( ! function_exists( 'bws_shortcode_media_button_popup' ) ) { |
|
860 function bws_shortcode_media_button_popup() { |
|
861 global $bws_shortcode_list, $wp_version; |
|
862 |
|
863 if ( ! empty( $bws_shortcode_list ) ) { ?> |
|
864 <div id="bws_shortcode_popup" style="display:none;"> |
|
865 <div id="bws_shortcode_popup_block"> |
|
866 <div id="bws_shortcode_select_plugin"> |
|
867 <h4><?php _e( 'Plugin', 'bestwebsoft' ); ?></h4> |
|
868 <select name="bws_shortcode_select" id="bws_shortcode_select"> |
|
869 <?php foreach ( $bws_shortcode_list as $key => $value ) { ?> |
|
870 <option value="<?php echo esc_attr( $key ); ?>"><?php echo $value['name']; ?></option> |
|
871 <?php } ?> |
|
872 </select> |
|
873 </div> |
|
874 <div class="clear"></div> |
|
875 <div id="bws_shortcode_content"> |
|
876 <h4><?php _e( 'Shortcode settings', 'bestwebsoft' ); ?></h4> |
|
877 <?php echo apply_filters( 'bws_shortcode_button_content', '' ); ?> |
|
878 </div> |
|
879 <div class="clear"></div> |
|
880 <div id="bws_shortcode_content_bottom"> |
|
881 <p><?php _e( 'The shortcode will be inserted', 'bestwebsoft' ); ?></p> |
|
882 <div id="bws_shortcode_block"><div id="bws_shortcode_display"></div></div> |
|
883 </div> |
|
884 </div> |
|
885 </div> |
|
886 <?php } |
|
887 } |
|
888 } |
|
889 |
|
890 /** |
|
891 * output shortcode in a special block |
|
892 * @since 1.9.8 |
|
893 */ |
|
894 if ( ! function_exists( 'bws_shortcode_output' ) ) { |
|
895 function bws_shortcode_output( $shortcode ) { ?> |
|
896 <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> |
|
897 <?php } |
|
898 } |
|
899 |
|
900 /** |
|
901 * output tooltip |
|
902 * @since 1.9.8 |
|
903 * @param string $content - HTML content for the tooltip |
|
904 * @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. |
|
905 */ |
|
906 if ( ! function_exists( 'bws_add_help_box' ) ) { |
|
907 function bws_add_help_box( $content, $class = '' ) { |
|
908 return '<span class="bws_help_box dashicons dashicons-editor-help ' . $class . ' hide-if-no-js"> |
|
909 <span class="bws_hidden_help_text">' . $content . '</span> |
|
910 </span>'; |
|
911 } |
|
912 } |
|
913 |
|
914 /* add help tab */ |
|
915 if ( ! function_exists( 'bws_help_tab' ) ) { |
|
916 function bws_help_tab( $screen, $args ) { |
|
917 $url = ( ! empty( $args['section'] ) ) ? 'https://support.bestwebsoft.com/hc/en-us/sections/' . $args['section'] : 'https://support.bestwebsoft.com/'; |
|
918 |
|
919 $content = '<p><a href="' . esc_url( $url ) . '" target="_blank">' . __( 'Visit Help Center', 'bestwebsoft' ) . '</a></p>'; |
|
920 |
|
921 $screen->add_help_tab( |
|
922 array( |
|
923 'id' => $args['id'] . '_help_tab', |
|
924 'title' => __( 'FAQ', 'bestwebsoft' ), |
|
925 'content' => $content |
|
926 ) |
|
927 ); |
|
928 |
|
929 $screen->set_help_sidebar( |
|
930 '<p><strong>' . __( 'For more information:', 'bestwebsoft' ) . '</strong></p>' . |
|
931 '<p><a href="https://drive.google.com/folderview?id=0B5l8lO-CaKt9VGh0a09vUjNFNjA&usp=sharing#list" target="_blank">' . __( 'Documentation', 'bestwebsoft' ) . '</a></p>' . |
|
932 '<p><a href="http://www.youtube.com/user/bestwebsoft/playlists?flow=grid&sort=da&view=1" target="_blank">' . __( 'Video Instructions', 'bestwebsoft' ) . '</a></p>' . |
|
933 '<p><a href="https://support.bestwebsoft.com/hc/en-us/requests/new" target="_blank">' . __( 'Submit a Request', 'bestwebsoft' ) . '</a></p>' |
|
934 ); |
|
935 } |
|
936 } |
|
937 |
|
938 if ( ! function_exists( 'bws_enqueue_custom_code_css_js' ) ) { |
|
939 function bws_enqueue_custom_code_css_js() { |
|
940 global $bstwbsftwppdtplgns_options; |
|
941 |
|
942 if ( ! isset( $bstwbsftwppdtplgns_options ) ) |
|
943 $bstwbsftwppdtplgns_options = ( function_exists( 'is_multisite' ) && is_multisite() ) ? get_site_option( 'bstwbsftwppdtplgns_options' ) : get_option( 'bstwbsftwppdtplgns_options' ); |
|
944 |
|
945 if ( ! empty( $bstwbsftwppdtplgns_options['custom_code'] ) ) { |
|
946 $is_multisite = is_multisite(); |
|
947 if ( $is_multisite ) |
|
948 $blog_id = get_current_blog_id(); |
|
949 |
|
950 if ( ! $is_multisite && ! empty( $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.css'] ) ) |
|
951 wp_enqueue_style( 'bws-custom-style', $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.css'] ); |
|
952 elseif ( $is_multisite && ! empty( $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.css'] ) ) |
|
953 wp_enqueue_style( 'bws-custom-style', $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.css'] ); |
|
954 |
|
955 if ( ! $is_multisite && ! empty( $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.js'] ) ) |
|
956 wp_enqueue_script( 'bws-custom-style', $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.js'] ); |
|
957 elseif ( $is_multisite && ! empty( $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.js'] ) ) |
|
958 wp_enqueue_script( 'bws-custom-style', $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.js'] ); |
|
959 } |
|
960 } |
|
961 } |
|
962 |
|
963 if ( ! function_exists( 'bws_enqueue_custom_code_php' ) ) { |
|
964 function bws_enqueue_custom_code_php() { |
|
965 if ( is_admin() ) |
|
966 return; |
|
967 |
|
968 global $bstwbsftwppdtplgns_options; |
|
969 |
|
970 if ( ! isset( $bstwbsftwppdtplgns_options ) ) |
|
971 $bstwbsftwppdtplgns_options = ( function_exists( 'is_multisite' ) && is_multisite() ) ? get_site_option( 'bstwbsftwppdtplgns_options' ) : get_option( 'bstwbsftwppdtplgns_options' ); |
|
972 |
|
973 if ( ! empty( $bstwbsftwppdtplgns_options['custom_code'] ) ) { |
|
974 |
|
975 $is_multisite = is_multisite(); |
|
976 if ( $is_multisite ) |
|
977 $blog_id = get_current_blog_id(); |
|
978 |
|
979 if ( ! $is_multisite && ! empty( $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.php'] ) ) { |
|
980 if ( file_exists( $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.php'] ) ) { |
|
981 if ( ! defined( 'BWS_GLOBAL' ) ) |
|
982 define( 'BWS_GLOBAL', true ); |
|
983 require_once( $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.php'] ); |
|
984 } else { |
|
985 unset( $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.php'] ); |
|
986 if ( $is_multisite ) |
|
987 update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
|
988 else |
|
989 update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
|
990 } |
|
991 } elseif ( $is_multisite && ! empty( $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.php'] ) ) { |
|
992 if ( file_exists( $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.php'] ) ) { |
|
993 if ( ! defined( 'BWS_GLOBAL' ) ) |
|
994 define( 'BWS_GLOBAL', true ); |
|
995 require_once( $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.php'] ); |
|
996 } else { |
|
997 unset( $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.php'] ); |
|
998 if ( $is_multisite ) |
|
999 update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
|
1000 else |
|
1001 update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
|
1002 } |
|
1003 } |
|
1004 } |
|
1005 } |
|
1006 } |
|
1007 |
|
1008 if ( ! function_exists( 'bws_delete_plugin' ) ) { |
|
1009 function bws_delete_plugin( $basename ) { |
|
1010 global $bstwbsftwppdtplgns_options; |
|
1011 |
|
1012 $is_multisite = is_multisite(); |
|
1013 if ( $is_multisite ) |
|
1014 $blog_id = get_current_blog_id(); |
|
1015 |
|
1016 if ( ! isset( $bstwbsftwppdtplgns_options ) ) |
|
1017 $bstwbsftwppdtplgns_options = ( $is_multisite ) ? get_site_option( 'bstwbsftwppdtplgns_options' ) : get_option( 'bstwbsftwppdtplgns_options' ); |
|
1018 |
|
1019 /* remove bws_menu versions */ |
|
1020 unset( $bstwbsftwppdtplgns_options['bws_menu']['version'][ $basename ] ); |
|
1021 /* remove track usage data */ |
|
1022 if ( isset( $bstwbsftwppdtplgns_options['bws_menu']['track_usage']['products'][ $basename ] ) ) |
|
1023 unset( $bstwbsftwppdtplgns_options['bws_menu']['track_usage']['products'][ $basename ] ); |
|
1024 /* if empty ['bws_menu']['version'] - there is no other bws plugins - delete all */ |
|
1025 if ( empty( $bstwbsftwppdtplgns_options['bws_menu']['version'] ) ) { |
|
1026 /* remove options */ |
|
1027 if ( $is_multisite ) |
|
1028 delete_site_option( 'bstwbsftwppdtplgns_options' ); |
|
1029 else |
|
1030 delete_option( 'bstwbsftwppdtplgns_options' ); |
|
1031 |
|
1032 /* remove custom_code */ |
|
1033 if ( $is_multisite ) { |
|
1034 global $wpdb; |
|
1035 $old_blog = $wpdb->blogid; |
|
1036 /* Get all blog ids */ |
|
1037 $blogids = $wpdb->get_col( "SELECT `blog_id` FROM $wpdb->blogs" ); |
|
1038 foreach ( $blogids as $blog_id ) { |
|
1039 switch_to_blog( $blog_id ); |
|
1040 $upload_dir = wp_upload_dir(); |
|
1041 $folder = $upload_dir['basedir'] . '/bws-custom-code'; |
|
1042 if ( file_exists( $folder ) && is_dir( $folder ) ) { |
|
1043 array_map( 'unlink', glob( "$folder/*" ) ); |
|
1044 rmdir( $folder ); |
|
1045 } |
|
1046 } |
|
1047 switch_to_blog( $old_blog ); |
|
1048 } else { |
|
1049 $upload_dir = wp_upload_dir(); |
|
1050 $folder = $upload_dir['basedir'] . '/bws-custom-code'; |
|
1051 if ( file_exists( $folder ) && is_dir( $folder ) ) { |
|
1052 array_map( 'unlink', glob( "$folder/*" ) ); |
|
1053 rmdir( $folder ); |
|
1054 } |
|
1055 } |
|
1056 } |
|
1057 } |
|
1058 } |
|
1059 |
|
1060 add_action( 'admin_init', 'bws_plugins_admin_init' ); |
|
1061 add_action( 'admin_enqueue_scripts', 'bws_admin_enqueue_scripts' ); |
|
1062 add_action( 'admin_head', 'bws_plugins_admin_head' ); |
|
1063 add_action( 'admin_footer','bws_plugins_admin_footer' ); |
|
1064 |
|
1065 add_action( 'admin_notices', 'bws_admin_notices', 30 ); |
|
1066 |
|
1067 add_action( 'wp_enqueue_scripts', 'bws_enqueue_custom_code_css_js', 20 ); |
|
1068 |
|
1069 bws_enqueue_custom_code_php(); |