diff -r 3d4e9c994f10 -r a86126ab1dd4 wp/wp-content/plugins/portfolio/bws_menu/bws_functions.php --- a/wp/wp-content/plugins/portfolio/bws_menu/bws_functions.php Tue Oct 22 16:11:46 2019 +0200 +++ b/wp/wp-content/plugins/portfolio/bws_menu/bws_functions.php Tue Dec 15 13:49:49 2020 +0100 @@ -179,7 +179,55 @@ if ( ! function_exists( 'bws_admin_notices' ) ) { function bws_admin_notices() { - global $bws_versions_notice_array, $bws_plugin_banner_to_settings, $bstwbsftwppdtplgns_options; + global $bws_versions_notice_array, $bws_plugin_banner_to_settings, $bstwbsftwppdtplgns_options, $bws_plugin_banner_go_pro, $bstwbsftwppdtplgns_banner_array, $bws_plugin_banner_timeout; + + /* bws_plugin_banner_go_pro */ + if ( ! empty( $bws_plugin_banner_go_pro ) ) { + /* get $bws_plugins */ + require( dirname( __FILE__ ) . '/product_list.php' ); + + foreach ( $bstwbsftwppdtplgns_banner_array as $value ) { + if ( isset( $bws_plugin_banner_go_pro[ $value[0] ] ) && ! isset( $_COOKIE[ $value[0] ] ) ) { + + if ( isset( $bws_plugins[ $value[1] ]['pro_version'] ) && is_plugin_active( $bws_plugins[ $value[1] ]['pro_version'] ) ) { + continue; + } + + $single_banner_value = $bws_plugin_banner_go_pro[ $value[0] ]; ?> +
+ +
+ +
+ +
+ $plugin_info, + 'prefix' => $this_banner_prefix, + 'bws_link' => $bws_link, + 'banner_url' => $banner_url_or_slug + ); if ( empty( $bstwbsftwppdtplgns_banner_array ) ) { if ( ! function_exists( 'bws_get_banner_array' ) ) require_once( dirname( __FILE__ ) . '/bws_menu.php' ); bws_get_banner_array(); } - - if ( false == strrpos( $banner_url_or_slug, '/' ) ) { - $banner_url_or_slug = '//ps.w.org/' . $banner_url_or_slug . '/assets/icon-128x128.png'; - } - - if ( ! function_exists( 'is_plugin_active' ) ) - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); - - $all_plugins = get_plugins(); - - $this_banner = $this_banner_prefix . '_hide_banner_on_plugin_page'; - foreach ( $bstwbsftwppdtplgns_banner_array as $key => $value ) { - if ( $this_banner == $value[0] ) { - if ( ! isset( $bstwbsftwppdtplgns_cookie_add ) ) { - echo ''; - $bstwbsftwppdtplgns_cookie_add = true; - } ?> - -
- -
- = $value[2] && is_plugin_active( $value[1] ) && ! isset( $_COOKIE[ $value[0] ] ) ) { - break; - } - } } } -if ( ! function_exists ( 'bws_plugin_banner_timeout' ) ) { - function bws_plugin_banner_timeout( $plugin_key, $plugin_prefix, $plugin_name, $banner_url_or_slug = false ) { - global $bstwbsftwppdtplgns_options, $bstwbsftwppdtplgns_cookie_add; - 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") ) ) ) { +if ( ! function_exists( 'bws_add_plugin_banner_timeout' ) ) { + function bws_add_plugin_banner_timeout( $plugin_key, $plugin_prefix, $plugin_name, $banner_url_or_slug ) { + global $bws_plugin_banner_timeout; - if ( $banner_url_or_slug && false == strrpos( $banner_url_or_slug, '/' ) ) { - $banner_url_or_slug = '//ps.w.org/' . $banner_url_or_slug . '/assets/icon-128x128.png'; + 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") ) ) ) { + + if ( false == strrpos( $banner_url_or_slug, '/' ) ) { + $banner_url_or_slug = '//ps.w.org/' . $banner_url_or_slug . '/assets/icon-256x256.png'; } - if ( ! isset( $bstwbsftwppdtplgns_cookie_add ) ) { - echo ''; - $bstwbsftwppdtplgns_cookie_add = true; - } ?> - -
- -
- $plugin_key, + 'prefix' => $plugin_prefix, + 'plugin_name' => $plugin_name, + 'banner_url' => $banner_url_or_slug + ); + } } } @@ -414,7 +402,7 @@ } if ( false == strrpos( $banner_url_or_slug, '/' ) ) { - $banner_url_or_slug = '//ps.w.org/' . $banner_url_or_slug . '/assets/icon-128x128.png'; + $banner_url_or_slug = '//ps.w.org/' . $banner_url_or_slug . '/assets/icon-256x256.png'; } $bws_plugin_banner_to_settings[] = array( @@ -471,7 +459,7 @@ } if ( false == strrpos( $banner_url_or_slug, '/' ) ) { - $banner_url_or_slug = '//ps.w.org/' . $banner_url_or_slug . '/assets/icon-128x128.png'; + $banner_url_or_slug = '//ps.w.org/' . $banner_url_or_slug . '/assets/icon-256x256.png'; } ?>
@@ -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 ) ) { ?>