wp/wp-content/plugins/portfolio/bws_menu/bws_functions.php
changeset 16 a86126ab1dd4
parent 12 d8a8807227e4
child 19 3d72ae0968f4
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
   177 	}
   177 	}
   178 }
   178 }
   179 
   179 
   180 if ( ! function_exists( 'bws_admin_notices' ) ) {
   180 if ( ! function_exists( 'bws_admin_notices' ) ) {
   181 	function bws_admin_notices() {
   181 	function bws_admin_notices() {
   182 		global $bws_versions_notice_array, $bws_plugin_banner_to_settings, $bstwbsftwppdtplgns_options;
   182 		global $bws_versions_notice_array, $bws_plugin_banner_to_settings, $bstwbsftwppdtplgns_options, $bws_plugin_banner_go_pro, $bstwbsftwppdtplgns_banner_array, $bws_plugin_banner_timeout;
       
   183 
       
   184 		/* bws_plugin_banner_go_pro */
       
   185 		if ( ! empty( $bws_plugin_banner_go_pro ) ) {
       
   186 			/* get $bws_plugins */
       
   187 			require( dirname( __FILE__ ) . '/product_list.php' );
       
   188 			
       
   189 			foreach ( $bstwbsftwppdtplgns_banner_array as $value ) {
       
   190 				if ( isset( $bws_plugin_banner_go_pro[ $value[0] ] ) && ! isset( $_COOKIE[ $value[0] ] ) ) {
       
   191 
       
   192 					if ( isset( $bws_plugins[ $value[1] ]['pro_version'] ) && is_plugin_active( $bws_plugins[ $value[1] ]['pro_version'] ) ) {
       
   193 						continue;
       
   194 					}
       
   195 
       
   196 					$single_banner_value = $bws_plugin_banner_go_pro[ $value[0] ]; ?>
       
   197 					<div class="updated" style="padding: 0; margin: 0; border: none; background: none;">
       
   198 						<div class="<?php echo $single_banner_value['prefix']; ?>_message bws_banner_on_plugin_page bws_go_pro_banner" style="display: none;">
       
   199 							<button class="<?php echo $single_banner_value['prefix']; ?>_close_icon close_icon notice-dismiss bws_hide_settings_notice" title="<?php _e( 'Close notice', 'bestwebsoft' ); ?>"></button>
       
   200 							<div class="icon">
       
   201 								<img title="" src="<?php echo esc_attr( $single_banner_value['banner_url'] ); ?>" alt="" />
       
   202 							</div>
       
   203 							<div class="text">
       
   204 								<?php _e( 'It’s time to upgrade your', 'bestwebsoft' ); ?> <strong><?php echo $single_banner_value['plugin_info']['Name']; ?> plugin</strong> <?php _e( 'to', 'bestwebsoft' ); ?> <strong>Pro</strong> <?php _e( 'version!', 'bestwebsoft' ); ?><br />
       
   205 								<span><?php _e( 'Extend standard plugin functionality with new great options.', 'bestwebsoft' ); ?></span>
       
   206 							</div>
       
   207 							<div class="button_div">
       
   208 								<a class="button" target="_blank" href="<?php echo $single_banner_value['bws_link']; ?>"><?php _e( 'Learn More', 'bestwebsoft' ); ?></a>
       
   209 							</div>
       
   210 						</div>
       
   211 					</div>
       
   212 					<?php break;
       
   213 				}
       
   214 			}
       
   215 		}
       
   216 
       
   217 		/* $bws_plugin_banner_timeout */
       
   218 		if ( ! empty( $bws_plugin_banner_timeout ) ) {
       
   219 			foreach ( $bws_plugin_banner_timeout as $banner_value ) { ?>
       
   220 				<div class="updated" style="padding: 0; margin: 0; border: none; background: none;">
       
   221 					<div class="<?php echo $banner_value['prefix']; ?>_message_timeout bws_banner_on_plugin_page bws_banner_timeout" style="display:none;">
       
   222 						<button class="<?php echo $banner_value['prefix']; ?>_close_icon close_icon notice-dismiss bws_hide_settings_notice" title="<?php _e( 'Close notice', 'bestwebsoft' ); ?>"></button>
       
   223 						<div class="icon">
       
   224 							<img title="" src="<?php echo esc_attr( $banner_value['banner_url'] ); ?>" alt="" />
       
   225 						</div>
       
   226 						<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>' . $banner_value['plugin_name'] . '</strong>', $bstwbsftwppdtplgns_options['time_out'][ $banner_value['plugin_key'] ] ); ?> <a target="_new" href="https://support.bestwebsoft.com/entries/53487136"><?php _e( "Learn more", 'bestwebsoft' ); ?></a></div>
       
   227 					</div>
       
   228 				</div>
       
   229 			<?php }
       
   230 		}
   183 
   231 
   184 		/*  versions notice */
   232 		/*  versions notice */
   185 		if ( ! empty( $bws_versions_notice_array ) ) {
   233 		if ( ! empty( $bws_versions_notice_array ) ) {
   186 			foreach ( $bws_versions_notice_array as $key => $value ) { ?>
   234 			foreach ( $bws_versions_notice_array as $key => $value ) { ?>
   187 				<div class="update-nag">
   235 				<div class="update-nag">
   283 				update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options );
   331 				update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options );
   284 		}
   332 		}
   285 	}
   333 	}
   286 }
   334 }
   287 
   335 
   288 if ( ! function_exists( 'bws_plugin_banner' ) ) {
   336 if ( ! function_exists( 'bws_plugin_banner_go_pro' ) ) {
   289 	function bws_plugin_banner( $plugin_info, $this_banner_prefix, $link_slug, $link_key, $link_pn, $banner_url_or_slug ) {
   337 	function bws_plugin_banner_go_pro( $plugin_options, $plugin_info, $this_banner_prefix, $bws_link_slug, $link_key, $link_pn, $banner_url_or_slug ) {
   290 		global $wp_version, $bstwbsftwppdtplgns_cookie_add, $bstwbsftwppdtplgns_banner_array;
   338 		global $bws_plugin_banner_go_pro, $wp_version, $bstwbsftwppdtplgns_banner_array;
       
   339 
       
   340 		if ( ! isset( $plugin_options['first_install'] ) || strtotime( '-1 week' ) < $plugin_options['first_install'] )
       
   341 			return;
       
   342 
       
   343 		$bws_link = esc_url( 'https://bestwebsoft.com/products/wordpress/plugins/' . $bws_link_slug . '/?k=' . $link_key . '&pn=' . $link_pn . '&v=' . $plugin_info["Version"] . '&wp_v=' . $wp_version );
       
   344 
       
   345 		if ( false == strrpos( $banner_url_or_slug, '/' ) ) {
       
   346 			$banner_url_or_slug = '//ps.w.org/' . $banner_url_or_slug . '/assets/icon-256x256.png';
       
   347 		}
       
   348 
       
   349 		$bws_plugin_banner_go_pro[ $this_banner_prefix . '_hide_banner_on_plugin_page' ] = array(
       
   350 			'plugin_info'	=> $plugin_info,
       
   351 			'prefix'		=> $this_banner_prefix,
       
   352 			'bws_link'		=> $bws_link,
       
   353 			'banner_url'	=> $banner_url_or_slug
       
   354 		);
   291 
   355 
   292 		if ( empty( $bstwbsftwppdtplgns_banner_array ) ) {
   356 		if ( empty( $bstwbsftwppdtplgns_banner_array ) ) {
   293 			if ( ! function_exists( 'bws_get_banner_array' ) )
   357 			if ( ! function_exists( 'bws_get_banner_array' ) )
   294 				require_once( dirname( __FILE__ ) . '/bws_menu.php' );
   358 				require_once( dirname( __FILE__ ) . '/bws_menu.php' );
   295 			bws_get_banner_array();
   359 			bws_get_banner_array();
   296 		}
   360 		}
   297 
   361 	}
   298 		if ( false == strrpos( $banner_url_or_slug, '/' ) ) {
   362 }
   299 			$banner_url_or_slug = '//ps.w.org/' . $banner_url_or_slug . '/assets/icon-128x128.png';
   363 
   300 		}
   364 if ( ! function_exists( 'bws_add_plugin_banner_timeout' ) ) {
   301 
   365 	function bws_add_plugin_banner_timeout( $plugin_key, $plugin_prefix, $plugin_name, $banner_url_or_slug ) {
   302 		if ( ! function_exists( 'is_plugin_active' ) )
   366 		global $bws_plugin_banner_timeout;
   303 			require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
   367 
   304 
   368 		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") ) ) ) {			
   305 		$all_plugins = get_plugins();
   369 
   306 
   370 			if ( false == strrpos( $banner_url_or_slug, '/' ) ) {
   307 		$this_banner = $this_banner_prefix . '_hide_banner_on_plugin_page';
   371 				$banner_url_or_slug = '//ps.w.org/' . $banner_url_or_slug . '/assets/icon-256x256.png';
   308 		foreach ( $bstwbsftwppdtplgns_banner_array as $key => $value ) {
   372 			}
   309 			if ( $this_banner == $value[0] ) {
   373 
   310 				if ( ! isset( $bstwbsftwppdtplgns_cookie_add ) ) {
   374 			$bws_plugin_banner_timeout[] = array(
   311 					echo '<script type="text/javascript" src="' . bws_menu_url( 'js/c_o_o_k_i_e.js' ) . '"></script>';
   375 				'plugin_key'	=> $plugin_key,
   312 					$bstwbsftwppdtplgns_cookie_add = true;
   376 				'prefix'		=> $plugin_prefix,
   313 				} ?>
   377 				'plugin_name'	=> $plugin_name,
   314 				<script type="text/javascript">
   378 				'banner_url'	=> $banner_url_or_slug
   315 					(function($) {
   379 			);
   316 						$(document).ready( function() {
   380 		}
   317 							var hide_message = $.cookie( '<?php echo $this_banner_prefix; ?>_hide_banner_on_plugin_page' );
       
   318 							if ( hide_message == "true" ) {
       
   319 								$( ".<?php echo $this_banner_prefix; ?>_message" ).css( "display", "none" );
       
   320 							} else {
       
   321 								$( ".<?php echo $this_banner_prefix; ?>_message" ).css( "display", "block" );
       
   322 							};
       
   323 							$( ".<?php echo $this_banner_prefix; ?>_close_icon" ).click( function() {
       
   324 								$( ".<?php echo $this_banner_prefix; ?>_message" ).css( "display", "none" );
       
   325 								$.cookie( "<?php echo $this_banner_prefix; ?>_hide_banner_on_plugin_page", "true", { expires: 32 } );
       
   326 							});
       
   327 						});
       
   328 					})(jQuery);
       
   329 				</script>
       
   330 				<div class="updated" style="padding: 0; margin: 0; border: none; background: none;">
       
   331 					<div class="<?php echo $this_banner_prefix; ?>_message bws_banner_on_plugin_page bws_go_pro_banner" style="display: none;">
       
   332 						<button class="<?php echo $this_banner_prefix; ?>_close_icon close_icon notice-dismiss bws_hide_settings_notice" title="<?php _e( 'Close notice', 'bestwebsoft' ); ?>"></button>
       
   333 						<div class="icon">
       
   334 							<img title="" src="<?php echo esc_attr( $banner_url_or_slug ); ?>" alt="" />
       
   335 						</div>
       
   336 						<div class="text">
       
   337 							<?php _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 />
       
   338 							<span><?php _e( 'Extend standard plugin functionality with new great options.', 'bestwebsoft' ); ?></span>
       
   339 						</div>
       
   340 						<div class="button_div">
       
   341 							<a class="button" target="_blank" href="<?php echo esc_url( 'https://bestwebsoft.com/products/wordpress/plugins/' . $link_slug . '/?k=' . $link_key . '&pn=' . $link_pn . '&v=' . $plugin_info["Version"] . '&wp_v=' . $wp_version ); ?>"><?php _e( 'Learn More', 'bestwebsoft' ); ?></a>
       
   342 						</div>
       
   343 					</div>
       
   344 				</div>
       
   345 				<?php break;
       
   346 			}
       
   347 			if ( isset( $all_plugins[ $value[1] ] ) && $all_plugins[ $value[1] ]["Version"] >= $value[2] && is_plugin_active( $value[1] ) && ! isset( $_COOKIE[ $value[0] ] ) ) {
       
   348 				break;
       
   349 			}
       
   350 		}
       
   351 	}
       
   352 }
       
   353 
       
   354 if ( ! function_exists ( 'bws_plugin_banner_timeout' ) ) {
       
   355 	function bws_plugin_banner_timeout( $plugin_key, $plugin_prefix, $plugin_name, $banner_url_or_slug = false ) {
       
   356 		global $bstwbsftwppdtplgns_options, $bstwbsftwppdtplgns_cookie_add;
       
   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 
       
   363 			if ( ! isset( $bstwbsftwppdtplgns_cookie_add ) ) {
       
   364 				echo '<script type="text/javascript" src="' . bws_menu_url( 'js/c_o_o_k_i_e.js' ) . '"></script>';
       
   365 				$bstwbsftwppdtplgns_cookie_add = true;
       
   366 			} ?>
       
   367 			<script type="text/javascript">
       
   368 				(function($) {
       
   369 					$(document).ready( function() {
       
   370 						var hide_message = $.cookie( "<?php echo $plugin_prefix; ?>_timeout_hide_banner_on_plugin_page" );
       
   371 						if ( hide_message == "true" ) {
       
   372 							$( ".<?php echo $plugin_prefix; ?>_message_timeout" ).css( "display", "none" );
       
   373 						} else {
       
   374 							$( ".<?php echo $plugin_prefix; ?>_message_timeout" ).css( "display", "block" );
       
   375 						}
       
   376 						$( ".<?php echo $plugin_prefix; ?>_close_icon" ).click( function() {
       
   377 							$( ".<?php echo $plugin_prefix; ?>_message_timeout" ).css( "display", "none" );
       
   378 							$.cookie( "<?php echo $plugin_prefix; ?>_timeout_hide_banner_on_plugin_page", "true", { expires: 30 } );
       
   379 						});
       
   380 					});
       
   381 				})(jQuery);
       
   382 			</script>
       
   383 			<div class="updated" style="padding: 0; margin: 0; border: none; background: none;">
       
   384 				<div class="<?php echo $plugin_prefix; ?>_message_timeout bws_banner_on_plugin_page bws_banner_timeout" style="display:none;">
       
   385 					<button class="<?php echo $plugin_prefix; ?>_close_icon close_icon notice-dismiss bws_hide_settings_notice" title="<?php _e( 'Close notice', 'bestwebsoft' ); ?>"></button>
       
   386 					<div class="icon">
       
   387 						<img title="" src="<?php echo esc_attr( $banner_url_or_slug ); ?>" alt="" />
       
   388 					</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>
       
   390 				</div>
       
   391 			</div>
       
   392 		<?php }
       
   393 	}
   381 	}
   394 }
   382 }
   395 
   383 
   396 if ( ! function_exists( 'bws_plugin_banner_to_settings' ) ) {
   384 if ( ! function_exists( 'bws_plugin_banner_to_settings' ) ) {
   397 	function bws_plugin_banner_to_settings( $plugin_info, $plugin_options_name, $banner_url_or_slug, $settings_url, $post_type_url = false ) {
   385 	function bws_plugin_banner_to_settings( $plugin_info, $plugin_options_name, $banner_url_or_slug, $settings_url, $post_type_url = false ) {
   412 				update_option( $plugin_options_name, $plugin_options );
   400 				update_option( $plugin_options_name, $plugin_options );
   413 			return;
   401 			return;
   414 		}
   402 		}
   415 
   403 
   416 		if ( false == strrpos( $banner_url_or_slug, '/' ) ) {
   404 		if ( false == strrpos( $banner_url_or_slug, '/' ) ) {
   417 			$banner_url_or_slug = '//ps.w.org/' . $banner_url_or_slug . '/assets/icon-128x128.png';
   405 			$banner_url_or_slug = '//ps.w.org/' . $banner_url_or_slug . '/assets/icon-256x256.png';
   418 		}
   406 		}
   419 
   407 
   420 		$bws_plugin_banner_to_settings[] = array(
   408 		$bws_plugin_banner_to_settings[] = array(
   421 			'plugin_info'			=> $plugin_info,
   409 			'plugin_info'			=> $plugin_info,
   422 			'plugin_options_name'	=> $plugin_options_name,
   410 			'plugin_options_name'	=> $plugin_options_name,
   469 				update_option( $plugin_options_name, $plugin_options );
   457 				update_option( $plugin_options_name, $plugin_options );
   470 			return;
   458 			return;
   471 		}
   459 		}
   472 
   460 
   473 		if ( false == strrpos( $banner_url_or_slug, '/' ) ) {
   461 		if ( false == strrpos( $banner_url_or_slug, '/' ) ) {
   474 			$banner_url_or_slug = '//ps.w.org/' . $banner_url_or_slug . '/assets/icon-128x128.png';
   462 			$banner_url_or_slug = '//ps.w.org/' . $banner_url_or_slug . '/assets/icon-256x256.png';
   475 		} ?>
   463 		} ?>
   476 		<div class="updated" style="padding: 0; margin: 0; border: none; background: none;">
   464 		<div class="updated" style="padding: 0; margin: 0; border: none; background: none;">
   477 			<div class="bws_banner_on_plugin_page bws_suggest_feature_banner">
   465 			<div class="bws_banner_on_plugin_page bws_suggest_feature_banner">
   478 				<div class="icon">
   466 				<div class="icon">
   479 					<img title="" src="<?php echo esc_attr( $banner_url_or_slug ); ?>" alt="" />
   467 					<img title="" src="<?php echo esc_attr( $banner_url_or_slug ); ?>" alt="" />
   553 			}
   541 			}
   554 			/**
   542 			/**
   555 			* @deprecated 1.9.8 (15.12.2016)
   543 			* @deprecated 1.9.8 (15.12.2016)
   556 			*/
   544 			*/
   557 			$is_main_page = in_array( $_GET['page'], array( 'bws_panel', 'bws_themes', 'bws_system_status' ) );
   545 			$is_main_page = in_array( $_GET['page'], array( 'bws_panel', 'bws_themes', 'bws_system_status' ) );
   558 			$page = esc_attr( $_GET['page'] );
   546 			$page = wp_unslash( $_GET['page'] );
   559 			$tab = isset( $_GET['tab'] ) ? esc_attr( $_GET['tab'] ) : '';
   547 			$tab = isset( $_GET['tab'] ) ? wp_unslash( $_GET['tab'] ) : '';
   560 
   548 
   561 			if ( $is_main_page )
   549 			if ( $is_main_page )
   562 				$current_page = 'admin.php?page=' . $page;
   550 				$current_page = 'admin.php?page=' . $page;
   563 			else
   551 			else
   564 				$current_page = isset( $_GET['tab'] ) ? 'admin.php?page=' . $page . '&tab=' . $tab : 'admin.php?page=' . $page;
   552 				$current_page = isset( $_GET['tab'] ) ? 'admin.php?page=' . $page . '&tab=' . $tab : 'admin.php?page=' . $page;
   565 			/*end deprecated */
   553 			/*end deprecated */
   566 
   554 
   567 			wp_redirect( self_admin_url( $current_page . '&activate=true' ) );
   555 			wp_redirect( self_admin_url( esc_url( $current_page . '&activate=true' ) ) );
   568 			exit();
   556 			exit();
   569 		}
   557 		}
   570 
   558 
   571 		if ( isset( $_GET['page'] ) && ( $_GET['page'] == 'bws_panel' || strpos( $_GET['page'], '-bws-panel' ) ) ) {
   559 		if ( isset( $_GET['page'] ) && ( $_GET['page'] == 'bws_panel' || strpos( $_GET['page'], '-bws-panel' ) ) ) {
   572 			if ( ! session_id() )
   560 			if ( ! session_id() )
   577 	}
   565 	}
   578 }
   566 }
   579 
   567 
   580 if ( ! function_exists ( 'bws_admin_enqueue_scripts' ) ) {
   568 if ( ! function_exists ( 'bws_admin_enqueue_scripts' ) ) {
   581 	function bws_admin_enqueue_scripts() {
   569 	function bws_admin_enqueue_scripts() {
   582 		global $wp_scripts, $hook_suffix;
   570 		global $wp_scripts, $hook_suffix,
   583 
   571 			$post_type,
   584 		$jquery_version = isset( $wp_scripts->registered['jquery-ui-core']->ver ) ? $wp_scripts->registered['jquery-ui-core']->ver : '1.12.1';
   572 			$bws_plugin_banner_go_pro, $bws_plugin_banner_timeout, $bstwbsftwppdtplgns_banner_array,
   585 
   573 			$bws_shortcode_list;
   586 		wp_enqueue_style( 'jquery-ui-style', '//code.jquery.com/ui/' . $jquery_version . '/themes/smoothness/jquery-ui.min.css', array(), $jquery_version );
   574 
       
   575 		$jquery_ui_version = isset( $wp_scripts->registered['jquery-ui-core']->ver ) ? $wp_scripts->registered['jquery-ui-core']->ver : '1.12.1';
       
   576 		wp_enqueue_style( 'jquery-ui-style', bws_menu_url( 'css/jquery-ui-styles/' . $jquery_ui_version . '/jquery-ui.css' ) );
   587 		wp_enqueue_style( 'bws-admin-css', bws_menu_url( 'css/general_style.css' ) );
   577 		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' ) );
   578 		wp_enqueue_script( 'bws-admin-scripts', bws_menu_url( 'js/general_script.js' ), array( 'jquery', 'jquery-ui-tooltip' ) );
   589 
   579 
   590 		if ( isset( $_GET['page'] ) && ( in_array( $_GET['page'], array( 'bws_panel', 'bws_themes', 'bws_system_status' ) ) || strpos( $_GET['page'], '-bws-panel' ) ) ) {
   580 		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' ) );
   581 			wp_enqueue_style( 'bws_menu_style', bws_menu_url( 'css/style.css' ) );
   593 			wp_enqueue_script( 'theme-install' );
   583 			wp_enqueue_script( 'theme-install' );
   594 			add_thickbox();
   584 			add_thickbox();
   595 			wp_enqueue_script( 'plugin-install' );
   585 			wp_enqueue_script( 'plugin-install' );
   596 		}
   586 		}
   597 
   587 
   598 		if ( 'plugins.php' == $hook_suffix && ! defined( 'DOING_AJAX' ) ) {
   588 		if ( 'plugins.php' == $hook_suffix ) {
   599 			wp_enqueue_style( 'bws-modal-css', bws_menu_url( 'css/modal.css' ) );
   589 			if ( ! empty( $bws_plugin_banner_go_pro ) || ! empty( $bws_plugin_banner_timeout ) ) {
   600 		}
   590 				wp_enqueue_script( 'bws_menu_cookie', bws_menu_url( 'js/c_o_o_k_i_e.js' ) );
   601 	}
   591 
   602 }
   592 				if ( ! empty( $bws_plugin_banner_go_pro ) ) {
   603 
   593 
   604 /**
   594 					foreach ( $bstwbsftwppdtplgns_banner_array as $value ) {
   605 * add styles and scripts for Bws_Settings_Tabs
   595 						if ( isset( $bws_plugin_banner_go_pro[ $value[0] ] ) && ! isset( $_COOKIE[ $value[0] ] ) ) {
   606 *
   596 							$prefix = $bws_plugin_banner_go_pro[ $value[0] ]['prefix'];
   607 * @since 1.9.8
   597 
   608 */
   598 							$script = "(function($) {
   609 if ( ! function_exists( 'bws_enqueue_settings_scripts' ) ) {
   599 								$(document).ready( function() {
   610 	function bws_enqueue_settings_scripts() {
   600 									var hide_message = $.cookie( '" . $prefix . "_hide_banner_on_plugin_page' );
   611 		wp_enqueue_script( 'jquery-ui-resizable' );
   601 									if ( hide_message == 'true' ) {
   612 		wp_enqueue_script( 'jquery-ui-tabs' );
   602 										$( '." . $prefix . "_message' ).css( 'display', 'none' );
   613 	}
   603 									} else {
   614 }
   604 										$( '." . $prefix . "_message' ).css( 'display', 'block' );
   615 
   605 									};
   616 if ( ! function_exists ( 'bws_plugins_admin_head' ) ) {
   606 									$( '." . $prefix . "_close_icon' ).click( function() {
   617 	function bws_plugins_admin_head() {
   607 										$( '." . $prefix . "_message' ).css( 'display', 'none' );
   618 		global $bws_shortcode_list, $wp_version, $post_type;
   608 										$.cookie( '" . $prefix . "_hide_banner_on_plugin_page', 'true', { expires: 32, secure: true } );
   619 		if ( isset( $_GET['page'] ) && $_GET['page'] == "bws_panel" ) { ?>
   609 									});
   620 			<noscript>
   610 								});
   621 				<style type="text/css">
   611 							})(jQuery);";
   622 					.bws_product_button {
   612 
   623 						display: inline-block;
   613 							wp_register_script( $prefix . '_hide_banner_on_plugin_page', '' );
       
   614 							wp_enqueue_script( $prefix . '_hide_banner_on_plugin_page' );
       
   615 							wp_add_inline_script( $prefix . '_hide_banner_on_plugin_page', sprintf( $script ) );
       
   616 							break;
       
   617 						}
   624 					}
   618 					}
   625 				</style>
   619 				}
   626 			</noscript>
   620 
   627 		<?php }
   621 				if ( ! empty( $bws_plugin_banner_timeout ) ) {
   628 		if ( 4.2 > $wp_version ) { ?>
   622 					$script = '(function($) {
   629 			<style type="text/css">
   623 							$(document).ready( function() {';
   630 				.bws_hide_settings_notice,
   624 
   631 				.bws_hide_premium_options {
   625 					foreach ( $bws_plugin_banner_timeout as $banner_value ) {
   632 					width: 11px;
   626 						$script .= "var hide_message = $.cookie( '" . $banner_value['prefix'] . "_timeout_hide_banner_on_plugin_page' );
   633 					height: 11px;
   627 							if ( hide_message == 'true' ) {
   634 					border: none;
   628 								$( '." . $banner_value['prefix'] . "_message_timeout' ).css( 'display', 'none' );
   635 					background: url("<?php echo bws_menu_url( 'images/close_banner.png' ); ?>") no-repeat center center;
   629 							} else {
   636 					box-shadow: none;
   630 								$( '." . $banner_value['prefix'] . "_message_timeout' ).css( 'display', 'block' );
   637 					float: right;
   631 							}
   638 					margin: 8px;
   632 							$( '." . $banner_value['prefix'] . "_close_icon' ).click( function() {
   639 				}
   633 								$( '." . $banner_value['prefix'] . "_message_timeout' ).css( 'display', 'none' );
   640 				.bws_hide_settings_notice:hover,
   634 								$.cookie( '" . $banner_value['prefix'] . "_timeout_hide_banner_on_plugin_page', 'true', { expires: 30, secure: true } );
   641 				.bws_hide_premium_options:hover {
   635 							});";
   642 					cursor: pointer;
   636 					}
   643 				}
   637 
   644 				.bws_hide_premium_options {
   638 					$script .= "});
   645 					position: relative;
   639 						})(jQuery);";
   646 				}
   640 
   647 			</style>
   641 					wp_register_script( 'plugin_banner_timeout_hide', '' );
   648 		<?php }
   642 					wp_enqueue_script( 'plugin_banner_timeout_hide' );
   649 		if ( ! empty( $bws_shortcode_list ) ) { ?>
   643 					wp_add_inline_script( 'plugin_banner_timeout_hide', sprintf( $script ) );
   650 			<!-- TinyMCE Shortcode Plugin -->
   644 				}
   651 			<script type='text/javascript'>
   645 			}
   652 				var bws_shortcode_button = {
   646 
   653 					'label': '<?php esc_attr_e( "Add BWS Shortcode", "bestwebsoft" ); ?>',
   647 			if ( ! defined( 'DOING_AJAX' ) ) {
   654 					'title': '<?php esc_attr_e( "Add BWS Plugins Shortcode", "bestwebsoft" ); ?>',
   648 				wp_enqueue_style( 'bws-modal-css', bws_menu_url( 'css/modal.css' ) );
   655 					'function_name': [
   649 
   656 						<?php foreach ( $bws_shortcode_list as $key => $value ) {
   650 				bws_add_deactivation_feedback_dialog_box();
       
   651 			}
       
   652 		}
       
   653 
       
   654 		if ( ! empty( $bws_shortcode_list ) ) {
       
   655 			/* TinyMCE Shortcode Plugin */
       
   656 			$script = "var bws_shortcode_button = {
       
   657 					'label': '" . esc_attr__( "Add BWS Shortcode", "bestwebsoft" ) . "',
       
   658 					'title': '" . esc_attr__( "Add BWS Plugins Shortcode", "bestwebsoft" ) . "',
       
   659 					'function_name': [";
       
   660 						foreach ( $bws_shortcode_list as $value ) {
   657 							if ( isset( $value['js_function'] ) )
   661 							if ( isset( $value['js_function'] ) )
   658 								echo "'" . $value['js_function'] . "',";
   662 								$script .= "'" . $value['js_function'] . "',";
   659 						} ?>
   663 						}
   660 					],
   664 					$script .= "]
   661 					'wp_version' : '<?php echo $wp_version; ?>'
   665 				};";
   662 				};
   666 			wp_register_script( 'bws_shortcode_button', '' );
   663 			</script>
   667 			wp_enqueue_script( 'bws_shortcode_button' );
   664 			<!-- TinyMCE Shortcode Plugin -->
   668 			wp_add_inline_script( 'bws_shortcode_button', sprintf( $script ) );
   665 			<?php if ( isset( $post_type ) && in_array( $post_type, array( 'post', 'page' ) ) ) {
   669 
       
   670 			/* TinyMCE Shortcode Plugin */
       
   671 			if ( isset( $post_type ) && in_array( $post_type, array( 'post', 'page' ) ) ) {
   666 				$tooltip_args = array(
   672 				$tooltip_args = array(
   667 					'tooltip_id'	=> 'bws_shortcode_button_tooltip',
   673 					'tooltip_id'	=> 'bws_shortcode_button_tooltip',
   668 					'css_selector' 	=> '.mce-bws_shortcode_button',
   674 					'css_selector' 	=> '.mce-bws_shortcode_button',
   669 					'actions' 		=> array(
   675 					'actions' 		=> array(
   670 						'click' 	=> false,
   676 						'click' 	=> false,
   677 					'set_timeout' => 2000
   683 					'set_timeout' => 2000
   678 				);
   684 				);
   679 				bws_add_tooltip_in_admin( $tooltip_args );
   685 				bws_add_tooltip_in_admin( $tooltip_args );
   680 			}
   686 			}
   681 		}
   687 		}
       
   688 	}
       
   689 }
       
   690 
       
   691 /**
       
   692 * add styles and scripts for Bws_Settings_Tabs
       
   693 *
       
   694 * @since 1.9.8
       
   695 */
       
   696 if ( ! function_exists( 'bws_enqueue_settings_scripts' ) ) {
       
   697 	function bws_enqueue_settings_scripts() {
       
   698 		wp_enqueue_script( 'jquery-ui-resizable' );
       
   699 		wp_enqueue_script( 'jquery-ui-tabs' );
       
   700 	}
       
   701 }
       
   702 
       
   703 if ( ! function_exists ( 'bws_plugins_admin_head' ) ) {
       
   704 	function bws_plugins_admin_head() {
       
   705 		if ( isset( $_GET['page'] ) && $_GET['page'] == "bws_panel" ) { ?>
       
   706 			<noscript>
       
   707 				<style type="text/css">
       
   708 					.bws_product_button {
       
   709 						display: inline-block;
       
   710 					}
       
   711 				</style>
       
   712 			</noscript>
       
   713 		<?php }
   682     }
   714     }
   683 }
   715 }
   684 
   716 
   685 if ( ! function_exists ( 'bws_plugins_admin_footer' ) ) {
   717 if ( ! function_exists ( 'bws_plugins_admin_footer' ) ) {
   686 	function bws_plugins_admin_footer() {
   718 	function bws_plugins_admin_footer() {
   687 		global $hook_suffix;
       
   688 
       
   689 		bws_shortcode_media_button_popup();
   719 		bws_shortcode_media_button_popup();
   690 
       
   691 		if ( 'plugins.php' == $hook_suffix && ! defined( 'DOING_AJAX' ) ) {
       
   692 			bws_add_deactivation_feedback_dialog_box();
       
   693 		}
       
   694 	}
   720 	}
   695 }
   721 }
   696 
   722 
   697 if ( ! function_exists ( 'bws_plugins_include_codemirror' ) ) {
   723 if ( ! function_exists ( 'bws_plugins_include_codemirror' ) ) {
   698 	function bws_plugins_include_codemirror() {
   724 	function bws_plugins_include_codemirror() {
   699 		wp_enqueue_style( 'codemirror.css', bws_menu_url( 'css/codemirror.css' ) );
   725 		global $wp_version;
   700 		wp_enqueue_script( 'codemirror.js', bws_menu_url( 'js/codemirror.js' ), array( 'jquery' ) );
   726 		if ( version_compare( $wp_version, '4.9.0',  '>=' ) ) {
       
   727 			wp_enqueue_style( 'wp-codemirror' );
       
   728 			wp_enqueue_script( 'wp-codemirror' );
       
   729         } else {
       
   730 			wp_enqueue_style( 'codemirror.css', bws_menu_url( 'css/codemirror.css' ) );
       
   731 			wp_enqueue_script( 'codemirror.js', bws_menu_url( 'js/codemirror.js' ), array( 'jquery' ) );
       
   732         }
       
   733 
   701     }
   734     }
   702 }
   735 }
   703 
   736 
   704 /**
   737 /**
   705  * Tooltip block
   738  * Tooltip block
   713 if ( ! class_exists( 'BWS_admin_tooltip' ) ) {
   746 if ( ! class_exists( 'BWS_admin_tooltip' ) ) {
   714 	class BWS_admin_tooltip {
   747 	class BWS_admin_tooltip {
   715 		private $tooltip_args;
   748 		private $tooltip_args;
   716 
   749 
   717 		public function __construct( $tooltip_args ) {
   750 		public function __construct( $tooltip_args ) {
       
   751 			global $bstwbsftwppdtplgns_tooltip_script_add;
       
   752 
   718 			/* Default arguments */
   753 			/* Default arguments */
   719 			$tooltip_args_default = array(
   754 			$tooltip_args_default = array(
   720 				'tooltip_id'	=> false,
   755 				'tooltip_id'	=> false,
   721 				'css_selector' 	=> false,
   756 				'css_selector' 	=> false,
   722 				'actions' 		=> array(
   757 				'actions' 		=> array(
   789 			$this->tooltip_args = $tooltip_args;
   824 			$this->tooltip_args = $tooltip_args;
   790 			/* add styles and scripts */
   825 			/* add styles and scripts */
   791 			wp_enqueue_style( 'wp-pointer' );
   826 			wp_enqueue_style( 'wp-pointer' );
   792 			wp_enqueue_script( 'wp-pointer' );
   827 			wp_enqueue_script( 'wp-pointer' );
   793 			/* add script that displays our tooltip */
   828 			/* add script that displays our tooltip */
   794 			add_action( 'admin_print_footer_scripts', array( $this, 'add_scripts' ) );
       
   795 		}
       
   796 
       
   797 		/**
       
   798 		 * Display tooltip
       
   799 		 */
       
   800 		public function add_scripts() {
       
   801 			global $bstwbsftwppdtplgns_tooltip_script_add;
       
   802 			if ( ! isset( $bstwbsftwppdtplgns_tooltip_script_add ) ) {
   829 			if ( ! isset( $bstwbsftwppdtplgns_tooltip_script_add ) ) {
   803 				echo '<script type="text/javascript" src="' . bws_menu_url( 'js/bws_tooltip.js' ) . '"></script>';
   830 				wp_enqueue_script( 'bws-tooltip-script', bws_menu_url( 'js/bws_tooltip.js' ) );
   804 				$bstwbsftwppdtplgns_tooltip_script_add = true;
   831 				$bstwbsftwppdtplgns_tooltip_script_add = true;
   805 			}
   832 			}
   806 			$tooltip_args = $this->tooltip_args; ?>
   833 			$tooltip_args = $this->tooltip_args;
   807 			<script type="text/javascript">
   834 
   808 				(function($) {
   835 			$script = "(function($) {
   809 					$(document).ready( function() {
   836 					$(document).ready( function() {
   810 						$.bwsTooltip( <?php echo json_encode( $tooltip_args ); ?> );
   837 						$.bwsTooltip( " . json_encode( $tooltip_args ) . " );
   811 					})
   838 					})
   812 				})(jQuery);
   839 				})(jQuery);";
   813 			</script>
   840 			wp_register_script( 'bws-tooltip-script-single-' . $this->tooltip_args['tooltip_id'], '' );
   814 		<?php }
   841 			wp_enqueue_script( 'bws-tooltip-script-single-' . $this->tooltip_args['tooltip_id'] );
       
   842 			wp_add_inline_script( 'bws-tooltip-script-single-' . $this->tooltip_args['tooltip_id'], sprintf( $script ) );
       
   843 		}
   815 	}
   844 	}
   816 }
   845 }
   817 
   846 
   818 if ( ! function_exists ( 'bws_form_restore_default_confirm' ) ) {
   847 if ( ! function_exists ( 'bws_form_restore_default_confirm' ) ) {
   819 	function bws_form_restore_default_confirm( $plugin_basename ) { ?>
   848 	function bws_form_restore_default_confirm( $plugin_basename ) { ?>
   856 }
   885 }
   857 
   886 
   858 /* Generate inline content for the popup window when the "bws shortcode" button is clicked */
   887 /* Generate inline content for the popup window when the "bws shortcode" button is clicked */
   859 if ( ! function_exists( 'bws_shortcode_media_button_popup' ) ) {
   888 if ( ! function_exists( 'bws_shortcode_media_button_popup' ) ) {
   860 	function bws_shortcode_media_button_popup() {
   889 	function bws_shortcode_media_button_popup() {
   861 		global $bws_shortcode_list, $wp_version;
   890 		global $bws_shortcode_list;
   862 
   891 
   863 		if ( ! empty( $bws_shortcode_list ) ) { ?>
   892 		if ( ! empty( $bws_shortcode_list ) ) { ?>
   864 			<div id="bws_shortcode_popup" style="display:none;">
   893 			<div id="bws_shortcode_popup" style="display:none;">
   865 				<div id="bws_shortcode_popup_block">
   894 				<div id="bws_shortcode_popup_block">
   866 					<div id="bws_shortcode_select_plugin">
   895 					<div id="bws_shortcode_select_plugin">
   927 		);
   956 		);
   928 
   957 
   929 		$screen->set_help_sidebar(
   958 		$screen->set_help_sidebar(
   930 			'<p><strong>' . __( 'For more information:', 'bestwebsoft' ) . '</strong></p>' .
   959 			'<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>' .
   960 			'<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>' .
   961 			'<p><a href="https://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>'
   962 			'<p><a href="https://support.bestwebsoft.com/hc/en-us/requests/new" target="_blank">' . __( 'Submit a Request', 'bestwebsoft' ) . '</a></p>'
   934 		);
   963 		);
   935 	}
   964 	}
   936 }
   965 }
   937 
   966