diff -r be944660c56a -r 3d72ae0968f4 wp/wp-content/plugins/portfolio/bws_menu/bws_functions.php
--- a/wp/wp-content/plugins/portfolio/bws_menu/bws_functions.php Wed Sep 21 18:19:35 2022 +0200
+++ b/wp/wp-content/plugins/portfolio/bws_menu/bws_functions.php Tue Sep 27 16:37:53 2022 +0200
@@ -1,19 +1,25 @@
%s %s WordPress %s %s
%s %s.",
- $plugin_info['Name'],
- __( 'requires', 'bestwebsoft' ),
- $require_wp,
- __( 'or higher, that is why it has been deactivated! Please upgrade WordPress and try again.', 'bestwebsoft' ),
- __( 'Back to the WordPress', 'bestwebsoft' ),
- $admin_url,
- __( 'Plugins page', 'bestwebsoft' )
+ esc_html( $plugin_info['Name'] ),
+ esc_html__( 'requires', 'bestwebsoft' ),
+ esc_html( $require_wp ),
+ esc_html__( 'or higher, that is why it has been deactivated! Please upgrade WordPress and try again.', 'bestwebsoft' ),
+ esc_html__( 'Back to the WordPress', 'bestwebsoft' ),
+ esc_url( $admin_url ),
+ esc_html__( 'Plugins page', 'bestwebsoft' )
)
);
}
- } elseif ( version_compare( $wp_version, $require_wp, "<" ) ) {
- $bws_versions_notice_array[] = array( 'name' => $plugin_info['Name'], 'version' => $require_wp );
+ } elseif ( version_compare( $wp_version, $require_wp, '<' ) ) {
+ $bws_versions_notice_array[] = array(
+ 'name' => $plugin_info['Name'],
+ 'version' => $require_wp,
+ );
}
}
}
+/**
+ * Function display review block
+ *
+ * @echo string
+ */
if ( ! function_exists( 'bws_plugin_reviews_block' ) ) {
function bws_plugin_reviews_block( $plugin_name, $plugin_slug ) { ?>
' . __( "Add BestWebSoft plugins' shortcodes using this button.", 'bestwebsoft' ) . '
', - 'position' => array( - 'edge' => 'right' + 'content' => '' . esc_html__( "Add BestWebSoft plugins' shortcodes using this button.", 'bestwebsoft' ) . '
', + 'position' => array( + 'edge' => 'right', ), - 'set_timeout' => 2000 + 'set_timeout' => 2000, ); bws_add_tooltip_in_admin( $tooltip_args ); } @@ -697,12 +875,21 @@ function bws_enqueue_settings_scripts() { wp_enqueue_script( 'jquery-ui-resizable' ); wp_enqueue_script( 'jquery-ui-tabs' ); + wp_enqueue_style( 'bws-modal-css', bws_menu_url( 'css/modal.css' ), array(), '2.4.2' ); } } -if ( ! function_exists ( 'bws_plugins_admin_head' ) ) { +/** + * Function add syles into admin head + * + * @since 1.9.8 + */ +if ( ! function_exists( 'bws_plugins_admin_head' ) ) { function bws_plugins_admin_head() { - if ( isset( $_GET['page'] ) && $_GET['page'] == "bws_panel" ) { ?> + $page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : ''; + + if ( $page === 'bws_panel' ) { + ?> - =' ) ) { + 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' ) ); - } + } else { + wp_enqueue_style( 'codemirror.css', bws_menu_url( 'css/codemirror.css' ), array(), '2.4.2' ); + wp_enqueue_script( 'codemirror.js', bws_menu_url( 'js/codemirror.js' ), array( 'jquery' ), '2.4.2' ); + } - } + } } /** @@ -739,12 +937,17 @@ */ if ( ! function_exists( 'bws_add_tooltip_in_admin' ) ) { function bws_add_tooltip_in_admin( $tooltip_args = array() ) { - new BWS_admin_tooltip( $tooltip_args ); + new BWS_Admin_Tooltip( $tooltip_args ); } } -if ( ! class_exists( 'BWS_admin_tooltip' ) ) { - class BWS_admin_tooltip { +/** + * Class for Tooltip + * + * @since 1.9.8 + */ +if ( ! class_exists( 'BWS_Admin_Tooltip' ) ) { + class BWS_Admin_Tooltip { private $tooltip_args; public function __construct( $tooltip_args ) { @@ -752,32 +955,32 @@ /* Default arguments */ $tooltip_args_default = array( - 'tooltip_id' => false, - 'css_selector' => false, - 'actions' => array( - 'click' => true, - 'onload' => false, + 'tooltip_id' => false, + 'css_selector' => false, + 'actions' => array( + 'click' => true, + 'onload' => false, ), - 'buttons' => array( - 'close' => array( + 'buttons' => array( + 'close' => array( 'type' => 'dismiss', - 'text' => __( 'Close', 'bestwebsoft' ), + 'text' => esc_html__( 'Close', 'bestwebsoft' ), ), ), - 'position' => array( - 'edge' => 'top', - 'align' => 'center', - 'pos-left' => 0, - 'pos-top' => 0, - 'zindex' => 10000 + 'position' => array( + 'edge' => 'top', + 'align' => 'center', + 'pos-left' => 0, + 'pos-top' => 0, + 'zindex' => 10000, ), - 'set_timeout' => 0 + 'set_timeout' => 0, ); - $tooltip_args = array_merge( $tooltip_args_default, $tooltip_args ); + $tooltip_args = array_merge( $tooltip_args_default, $tooltip_args ); /* Check that our merged array has default values */ foreach ( $tooltip_args_default as $arg_key => $arg_value ) { if ( is_array( $arg_value ) ) { - foreach ( $arg_value as $key => $value) { + foreach ( $arg_value as $key => $value ) { if ( ! isset( $tooltip_args[ $arg_key ][ $key ] ) ) { $tooltip_args[ $arg_key ][ $key ] = $tooltip_args_default[ $arg_key ][ $key ]; } @@ -796,10 +999,10 @@ return; } else { /* check position */ - if ( ! in_array( $tooltip_args['position']['edge'], array( 'left', 'right', 'top', 'bottom' ) ) ) { + if ( ! in_array( $tooltip_args['position']['edge'], array( 'left', 'right', 'top', 'bottom' ) ) ) { $tooltip_args['position']['edge'] = 'top'; } - if ( ! in_array( $tooltip_args['position']['align'], array( 'top', 'bottom', 'left', 'right', 'center', ) ) ) { + if ( ! in_array( $tooltip_args['position']['align'], array( 'top', 'bottom', 'left', 'right', 'center' ) ) ) { $tooltip_args['position']['align'] = 'center'; } } @@ -816,7 +1019,7 @@ break; case 'top': case 'bottom': - if ( $tooltip_args['position']['align'] == 'left' ) { + if ( 'left' === $tooltip_args['position']['align'] ) { $tooltip_args['position']['pos-left'] -= 65; } break; @@ -827,16 +1030,16 @@ wp_enqueue_script( 'wp-pointer' ); /* add script that displays our tooltip */ if ( ! isset( $bstwbsftwppdtplgns_tooltip_script_add ) ) { - wp_enqueue_script( 'bws-tooltip-script', bws_menu_url( 'js/bws_tooltip.js' ) ); + wp_enqueue_script( 'bws-tooltip-script', bws_menu_url( 'js/bws_tooltip.js' ), array(), '2.4.2' ); $bstwbsftwppdtplgns_tooltip_script_add = true; } $tooltip_args = $this->tooltip_args; - $script = "(function($) { + $script = '(function($) { $(document).ready( function() { - $.bwsTooltip( " . json_encode( $tooltip_args ) . " ); + $.bwsTooltip( ' . wp_json_encode( $tooltip_args ) . ' ); }) - })(jQuery);"; + })(jQuery);'; wp_register_script( 'bws-tooltip-script-single-' . $this->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 ) ); @@ -844,22 +1047,33 @@ } } -if ( ! function_exists ( 'bws_form_restore_default_confirm' ) ) { - function bws_form_restore_default_confirm( $plugin_basename ) { ?> +/** + * Function display confirm + * + * @since 1.9.8 + */ +if ( ! function_exists( 'bws_form_restore_default_confirm' ) ) { + function bws_form_restore_default_confirm( $plugin_basename ) { + ?>' . __( 'For more information:', 'bestwebsoft' ) . '
' . - '' . __( 'Documentation', 'bestwebsoft' ) . '
' . - '' . __( 'Video Instructions', 'bestwebsoft' ) . '
' . - '' . __( 'Submit a Request', 'bestwebsoft' ) . '
' + '' . esc_html__( 'For more information:', 'bestwebsoft' ) . '
' . + '' . esc_html__( 'Documentation', 'bestwebsoft' ) . '
' . + '' . + '' ); } } +/** + * Function add css and js + * + * @since 1.9.8 + */ if ( ! function_exists( 'bws_enqueue_custom_code_css_js' ) ) { function bws_enqueue_custom_code_css_js() { global $bstwbsftwppdtplgns_options; - if ( ! isset( $bstwbsftwppdtplgns_options ) ) + if ( ! isset( $bstwbsftwppdtplgns_options ) ) { $bstwbsftwppdtplgns_options = ( function_exists( 'is_multisite' ) && is_multisite() ) ? get_site_option( 'bstwbsftwppdtplgns_options' ) : get_option( 'bstwbsftwppdtplgns_options' ); + } if ( ! empty( $bstwbsftwppdtplgns_options['custom_code'] ) ) { $is_multisite = is_multisite(); - if ( $is_multisite ) + if ( $is_multisite ) { $blog_id = get_current_blog_id(); + } - if ( ! $is_multisite && ! empty( $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.css'] ) ) - wp_enqueue_style( 'bws-custom-style', $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.css'] ); - elseif ( $is_multisite && ! empty( $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.css'] ) ) - wp_enqueue_style( 'bws-custom-style', $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.css'] ); + if ( ! $is_multisite && ! empty( $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.css'] ) ) { + wp_enqueue_style( 'bws-custom-style', $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.css'], array(), '2.4.2' ); + } elseif ( $is_multisite && ! empty( $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.css'] ) ) { + wp_enqueue_style( 'bws-custom-style', $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.css'], array(), '2.4.2' ); + } - if ( ! $is_multisite && ! empty( $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.js'] ) ) - wp_enqueue_script( 'bws-custom-style', $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.js'] ); - elseif ( $is_multisite && ! empty( $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.js'] ) ) - wp_enqueue_script( 'bws-custom-style', $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.js'] ); + if ( ! $is_multisite && ! empty( $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.js'] ) ) { + wp_enqueue_script( 'bws-custom-style', $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.js'], array(), '2.4.2' ); + } elseif ( $is_multisite && ! empty( $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.js'] ) ) { + wp_enqueue_script( 'bws-custom-style', $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.js'], array(), '2.4.2' ); + } } } } +/** + * Function add custom php code + * + * @since 1.9.8 + */ if ( ! function_exists( 'bws_enqueue_custom_code_php' ) ) { function bws_enqueue_custom_code_php() { - if ( is_admin() ) + if ( is_admin() ) { return; + } global $bstwbsftwppdtplgns_options; - if ( ! isset( $bstwbsftwppdtplgns_options ) ) + if ( ! isset( $bstwbsftwppdtplgns_options ) ) { $bstwbsftwppdtplgns_options = ( function_exists( 'is_multisite' ) && is_multisite() ) ? get_site_option( 'bstwbsftwppdtplgns_options' ) : get_option( 'bstwbsftwppdtplgns_options' ); + } if ( ! empty( $bstwbsftwppdtplgns_options['custom_code'] ) ) { $is_multisite = is_multisite(); - if ( $is_multisite ) + if ( $is_multisite ) { $blog_id = get_current_blog_id(); + } if ( ! $is_multisite && ! empty( $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.php'] ) ) { if ( file_exists( $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.php'] ) ) { - if ( ! defined( 'BWS_GLOBAL' ) ) + if ( ! defined( 'BWS_GLOBAL' ) ) { define( 'BWS_GLOBAL', true ); - require_once( $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.php'] ); + } + require_once $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.php']; } else { unset( $bstwbsftwppdtplgns_options['custom_code']['bws-custom-code.php'] ); - if ( $is_multisite ) + if ( $is_multisite ) { update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); - else + } else { update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); + } } } elseif ( $is_multisite && ! empty( $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.php'] ) ) { if ( file_exists( $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.php'] ) ) { - if ( ! defined( 'BWS_GLOBAL' ) ) + if ( ! defined( 'BWS_GLOBAL' ) ) { define( 'BWS_GLOBAL', true ); - require_once( $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.php'] ); + } + require_once $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.php']; } else { unset( $bstwbsftwppdtplgns_options['custom_code'][ $blog_id ]['bws-custom-code.php'] ); - if ( $is_multisite ) + if ( $is_multisite ) { update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); - else + } else { update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); + } } } } } } +/** + * Function delete plugin + * + * @since 1.9.8 + */ if ( ! function_exists( 'bws_delete_plugin' ) ) { function bws_delete_plugin( $basename ) { global $bstwbsftwppdtplgns_options; $is_multisite = is_multisite(); - if ( $is_multisite ) + if ( $is_multisite ) { $blog_id = get_current_blog_id(); + } - if ( ! isset( $bstwbsftwppdtplgns_options ) ) + if ( ! isset( $bstwbsftwppdtplgns_options ) ) { $bstwbsftwppdtplgns_options = ( $is_multisite ) ? get_site_option( 'bstwbsftwppdtplgns_options' ) : get_option( 'bstwbsftwppdtplgns_options' ); + } /* remove bws_menu versions */ unset( $bstwbsftwppdtplgns_options['bws_menu']['version'][ $basename ] ); /* remove track usage data */ - if ( isset( $bstwbsftwppdtplgns_options['bws_menu']['track_usage']['products'][ $basename ] ) ) + if ( isset( $bstwbsftwppdtplgns_options['bws_menu']['track_usage']['products'][ $basename ] ) ) { unset( $bstwbsftwppdtplgns_options['bws_menu']['track_usage']['products'][ $basename ] ); + } /* if empty ['bws_menu']['version'] - there is no other bws plugins - delete all */ if ( empty( $bstwbsftwppdtplgns_options['bws_menu']['version'] ) ) { /* remove options */ - if ( $is_multisite ) + if ( $is_multisite ) { delete_site_option( 'bstwbsftwppdtplgns_options' ); - else + } else { delete_option( 'bstwbsftwppdtplgns_options' ); + } /* remove custom_code */ if ( $is_multisite ) { @@ -1067,7 +1335,7 @@ foreach ( $blogids as $blog_id ) { switch_to_blog( $blog_id ); $upload_dir = wp_upload_dir(); - $folder = $upload_dir['basedir'] . '/bws-custom-code'; + $folder = $upload_dir['basedir'] . '/bws-custom-code'; if ( file_exists( $folder ) && is_dir( $folder ) ) { array_map( 'unlink', glob( "$folder/*" ) ); rmdir( $folder ); @@ -1076,7 +1344,7 @@ switch_to_blog( $old_blog ); } else { $upload_dir = wp_upload_dir(); - $folder = $upload_dir['basedir'] . '/bws-custom-code'; + $folder = $upload_dir['basedir'] . '/bws-custom-code'; if ( file_exists( $folder ) && is_dir( $folder ) ) { array_map( 'unlink', glob( "$folder/*" ) ); rmdir( $folder ); @@ -1089,7 +1357,7 @@ add_action( 'admin_init', 'bws_plugins_admin_init' ); add_action( 'admin_enqueue_scripts', 'bws_admin_enqueue_scripts' ); add_action( 'admin_head', 'bws_plugins_admin_head' ); -add_action( 'admin_footer','bws_plugins_admin_footer' ); +add_action( 'admin_footer', 'bws_plugins_admin_footer' ); add_action( 'admin_notices', 'bws_admin_notices', 30 );