@@ -555,8 +543,8 @@
* @deprecated 1.9.8 (15.12.2016)
*/
$is_main_page = in_array( $_GET['page'], array( 'bws_panel', 'bws_themes', 'bws_system_status' ) );
- $page = esc_attr( $_GET['page'] );
- $tab = isset( $_GET['tab'] ) ? esc_attr( $_GET['tab'] ) : '';
+ $page = wp_unslash( $_GET['page'] );
+ $tab = isset( $_GET['tab'] ) ? wp_unslash( $_GET['tab'] ) : '';
if ( $is_main_page )
$current_page = 'admin.php?page=' . $page;
@@ -564,7 +552,7 @@
$current_page = isset( $_GET['tab'] ) ? 'admin.php?page=' . $page . '&tab=' . $tab : 'admin.php?page=' . $page;
/*end deprecated */
- wp_redirect( self_admin_url( $current_page . '&activate=true' ) );
+ wp_redirect( self_admin_url( esc_url( $current_page . '&activate=true' ) ) );
exit();
}
@@ -579,11 +567,13 @@
if ( ! function_exists ( 'bws_admin_enqueue_scripts' ) ) {
function bws_admin_enqueue_scripts() {
- global $wp_scripts, $hook_suffix;
+ global $wp_scripts, $hook_suffix,
+ $post_type,
+ $bws_plugin_banner_go_pro, $bws_plugin_banner_timeout, $bstwbsftwppdtplgns_banner_array,
+ $bws_shortcode_list;
- $jquery_version = isset( $wp_scripts->registered['jquery-ui-core']->ver ) ? $wp_scripts->registered['jquery-ui-core']->ver : '1.12.1';
-
- wp_enqueue_style( 'jquery-ui-style', '//code.jquery.com/ui/' . $jquery_version . '/themes/smoothness/jquery-ui.min.css', array(), $jquery_version );
+ $jquery_ui_version = isset( $wp_scripts->registered['jquery-ui-core']->ver ) ? $wp_scripts->registered['jquery-ui-core']->ver : '1.12.1';
+ wp_enqueue_style( 'jquery-ui-style', bws_menu_url( 'css/jquery-ui-styles/' . $jquery_ui_version . '/jquery-ui.css' ) );
wp_enqueue_style( 'bws-admin-css', bws_menu_url( 'css/general_style.css' ) );
wp_enqueue_script( 'bws-admin-scripts', bws_menu_url( 'js/general_script.js' ), array( 'jquery', 'jquery-ui-tooltip' ) );
@@ -595,8 +585,105 @@
wp_enqueue_script( 'plugin-install' );
}
- if ( 'plugins.php' == $hook_suffix && ! defined( 'DOING_AJAX' ) ) {
- wp_enqueue_style( 'bws-modal-css', bws_menu_url( 'css/modal.css' ) );
+ if ( 'plugins.php' == $hook_suffix ) {
+ if ( ! empty( $bws_plugin_banner_go_pro ) || ! empty( $bws_plugin_banner_timeout ) ) {
+ wp_enqueue_script( 'bws_menu_cookie', bws_menu_url( 'js/c_o_o_k_i_e.js' ) );
+
+ if ( ! empty( $bws_plugin_banner_go_pro ) ) {
+
+ foreach ( $bstwbsftwppdtplgns_banner_array as $value ) {
+ if ( isset( $bws_plugin_banner_go_pro[ $value[0] ] ) && ! isset( $_COOKIE[ $value[0] ] ) ) {
+ $prefix = $bws_plugin_banner_go_pro[ $value[0] ]['prefix'];
+
+ $script = "(function($) {
+ $(document).ready( function() {
+ var hide_message = $.cookie( '" . $prefix . "_hide_banner_on_plugin_page' );
+ if ( hide_message == 'true' ) {
+ $( '." . $prefix . "_message' ).css( 'display', 'none' );
+ } else {
+ $( '." . $prefix . "_message' ).css( 'display', 'block' );
+ };
+ $( '." . $prefix . "_close_icon' ).click( function() {
+ $( '." . $prefix . "_message' ).css( 'display', 'none' );
+ $.cookie( '" . $prefix . "_hide_banner_on_plugin_page', 'true', { expires: 32, secure: true } );
+ });
+ });
+ })(jQuery);";
+
+ wp_register_script( $prefix . '_hide_banner_on_plugin_page', '' );
+ wp_enqueue_script( $prefix . '_hide_banner_on_plugin_page' );
+ wp_add_inline_script( $prefix . '_hide_banner_on_plugin_page', sprintf( $script ) );
+ break;
+ }
+ }
+ }
+
+ if ( ! empty( $bws_plugin_banner_timeout ) ) {
+ $script = '(function($) {
+ $(document).ready( function() {';
+
+ foreach ( $bws_plugin_banner_timeout as $banner_value ) {
+ $script .= "var hide_message = $.cookie( '" . $banner_value['prefix'] . "_timeout_hide_banner_on_plugin_page' );
+ if ( hide_message == 'true' ) {
+ $( '." . $banner_value['prefix'] . "_message_timeout' ).css( 'display', 'none' );
+ } else {
+ $( '." . $banner_value['prefix'] . "_message_timeout' ).css( 'display', 'block' );
+ }
+ $( '." . $banner_value['prefix'] . "_close_icon' ).click( function() {
+ $( '." . $banner_value['prefix'] . "_message_timeout' ).css( 'display', 'none' );
+ $.cookie( '" . $banner_value['prefix'] . "_timeout_hide_banner_on_plugin_page', 'true', { expires: 30, secure: true } );
+ });";
+ }
+
+ $script .= "});
+ })(jQuery);";
+
+ wp_register_script( 'plugin_banner_timeout_hide', '' );
+ wp_enqueue_script( 'plugin_banner_timeout_hide' );
+ wp_add_inline_script( 'plugin_banner_timeout_hide', sprintf( $script ) );
+ }
+ }
+
+ if ( ! defined( 'DOING_AJAX' ) ) {
+ wp_enqueue_style( 'bws-modal-css', bws_menu_url( 'css/modal.css' ) );
+
+ bws_add_deactivation_feedback_dialog_box();
+ }
+ }
+
+ if ( ! empty( $bws_shortcode_list ) ) {
+ /* TinyMCE Shortcode Plugin */
+ $script = "var bws_shortcode_button = {
+ 'label': '" . esc_attr__( "Add BWS Shortcode", "bestwebsoft" ) . "',
+ 'title': '" . esc_attr__( "Add BWS Plugins Shortcode", "bestwebsoft" ) . "',
+ 'function_name': [";
+ foreach ( $bws_shortcode_list as $value ) {
+ if ( isset( $value['js_function'] ) )
+ $script .= "'" . $value['js_function'] . "',";
+ }
+ $script .= "]
+ };";
+ wp_register_script( 'bws_shortcode_button', '' );
+ wp_enqueue_script( 'bws_shortcode_button' );
+ wp_add_inline_script( 'bws_shortcode_button', sprintf( $script ) );
+
+ /* TinyMCE Shortcode Plugin */
+ if ( isset( $post_type ) && in_array( $post_type, array( 'post', 'page' ) ) ) {
+ $tooltip_args = array(
+ 'tooltip_id' => 'bws_shortcode_button_tooltip',
+ 'css_selector' => '.mce-bws_shortcode_button',
+ 'actions' => array(
+ 'click' => false,
+ 'onload' => true
+ ),
+ 'content' => '
' . __( 'Add shortcode', 'bestwebsoft' ) . '
' . __( "Add BestWebSoft plugins' shortcodes using this button.", 'bestwebsoft' ) . '
',
+ 'position' => array(
+ 'edge' => 'right'
+ ),
+ 'set_timeout' => 2000
+ );
+ bws_add_tooltip_in_admin( $tooltip_args );
+ }
}
}
}
@@ -615,7 +702,6 @@
if ( ! function_exists ( 'bws_plugins_admin_head' ) ) {
function bws_plugins_admin_head() {
- global $bws_shortcode_list, $wp_version, $post_type;
if ( isset( $_GET['page'] ) && $_GET['page'] == "bws_panel" ) { ?>
$wp_version ) { ?>
-
-
-
-
-
- 'bws_shortcode_button_tooltip',
- 'css_selector' => '.mce-bws_shortcode_button',
- 'actions' => array(
- 'click' => false,
- 'onload' => true
- ),
- 'content' => '
' . __( 'Add shortcode', 'bestwebsoft' ) . '
' . __( "Add BestWebSoft plugins' shortcodes using this button.", 'bestwebsoft' ) . '
',
- 'position' => array(
- 'edge' => 'right'
- ),
- 'set_timeout' => 2000
- );
- bws_add_tooltip_in_admin( $tooltip_args );
- }
- }
}
}
if ( ! function_exists ( 'bws_plugins_admin_footer' ) ) {
function bws_plugins_admin_footer() {
- global $hook_suffix;
-
bws_shortcode_media_button_popup();
-
- if ( 'plugins.php' == $hook_suffix && ! defined( 'DOING_AJAX' ) ) {
- bws_add_deactivation_feedback_dialog_box();
- }
}
}
if ( ! function_exists ( 'bws_plugins_include_codemirror' ) ) {
function bws_plugins_include_codemirror() {
- wp_enqueue_style( 'codemirror.css', bws_menu_url( 'css/codemirror.css' ) );
- wp_enqueue_script( 'codemirror.js', bws_menu_url( 'js/codemirror.js' ), array( 'jquery' ) );
+ global $wp_version;
+ if ( version_compare( $wp_version, '4.9.0', '>=' ) ) {
+ wp_enqueue_style( 'wp-codemirror' );
+ wp_enqueue_script( 'wp-codemirror' );
+ } else {
+ wp_enqueue_style( 'codemirror.css', bws_menu_url( 'css/codemirror.css' ) );
+ wp_enqueue_script( 'codemirror.js', bws_menu_url( 'js/codemirror.js' ), array( 'jquery' ) );
+ }
+
}
}
@@ -715,6 +748,8 @@
private $tooltip_args;
public function __construct( $tooltip_args ) {
+ global $bstwbsftwppdtplgns_tooltip_script_add;
+
/* Default arguments */
$tooltip_args_default = array(
'tooltip_id' => false,
@@ -791,27 +826,21 @@
wp_enqueue_style( 'wp-pointer' );
wp_enqueue_script( 'wp-pointer' );
/* add script that displays our tooltip */
- add_action( 'admin_print_footer_scripts', array( $this, 'add_scripts' ) );
- }
-
- /**
- * Display tooltip
- */
- public function add_scripts() {
- global $bstwbsftwppdtplgns_tooltip_script_add;
if ( ! isset( $bstwbsftwppdtplgns_tooltip_script_add ) ) {
- echo '';
+ wp_enqueue_script( 'bws-tooltip-script', bws_menu_url( 'js/bws_tooltip.js' ) );
$bstwbsftwppdtplgns_tooltip_script_add = true;
}
- $tooltip_args = $this->tooltip_args; ?>
-
- tooltip_args['tooltip_id'], '' );
+ wp_enqueue_script( 'bws-tooltip-script-single-' . $this->tooltip_args['tooltip_id'] );
+ wp_add_inline_script( 'bws-tooltip-script-single-' . $this->tooltip_args['tooltip_id'], sprintf( $script ) );
+ }
}
}
@@ -858,7 +887,7 @@
/* Generate inline content for the popup window when the "bws shortcode" button is clicked */
if ( ! function_exists( 'bws_shortcode_media_button_popup' ) ) {
function bws_shortcode_media_button_popup() {
- global $bws_shortcode_list, $wp_version;
+ global $bws_shortcode_list;
if ( ! empty( $bws_shortcode_list ) ) { ?>