| @@ -1,95 +1,94 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * @version 1.1 | |
| 4 | - * @package Any | |
| 3 | + * @version 1.1 | |
| 4 | + * @package Any | |
| 5 | 5 | * @category Dubug info showing |
| 6 | - * @author wpdevelop | |
| 6 | + * @author wpdevelop | |
| 7 | 7 | * |
| 8 | 8 | * @web-site https://wpbookingcalendar.com/ |
| 9 | - * @email info@wpbookingcalendar.com | |
| 10 | - * | |
| 9 | + * @email info@wpbookingcalendar.com | |
| 10 | + * | |
| 11 | 11 | * @modified 09.09.2015 |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly | |
| 14 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 15 | + exit; // Exit if accessed directly . | |
| 16 | +} | |
| 15 | 17 | |
| 18 | +// --------------------------------------------------------------------------------------------------------------------- | |
| 19 | +// D e b u g f u n c t i o n s | |
| 20 | +// --------------------------------------------------------------------------------------------------------------------- | |
| 16 | 21 | |
| 17 | - | |
| 18 | -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 19 | -// D e b u g f u n c t i o n s /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 20 | -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 21 | - | |
| 22 | 22 | /* |
| 23 | 23 | * Show values of the arguments list |
| 24 | 24 | */ |
| 25 | -if (!function_exists ('debuge')) { | |
| 26 | - function debuge() { | |
| 27 | - $numargs = func_num_args(); | |
| 28 | - $var = func_get_args(); | |
| 29 | - $makeexit = is_bool( $var[count($var)-1] ) ? $var[ count($var) - 1 ]:false; | |
| 30 | - echo "<div><pre class='prettyprint linenums'>"; //FixIn: 8.8.3.11 | |
| 31 | - foreach ( $var as $ind => $item ) { | |
| 25 | +if ( ! function_exists( 'debuge' ) ) { | |
| 26 | + function debuge() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound | |
| 27 | + $numargs = func_num_args(); | |
| 28 | + $var = func_get_args(); | |
| 29 | + $makeexit = is_bool( $var[ count( $var ) - 1 ] ) ? $var[ count( $var ) - 1 ] : false; | |
| 30 | + echo "<div><pre class='prettyprint linenums'>"; // FixIn: 8.8.3.11. | |
| 31 | + foreach ( $var as $ind => $item ) { | |
| 32 | 32 | |
| 33 | - echo "\n<strong> [$ind] " . gettype( $item ) . "</strong>\n"; | |
| 33 | + echo "\n<strong> [" . esc_html( $ind ) . '] ' . esc_html( gettype( $item ) ) . "</strong>\n"; | |
| 34 | 34 | |
| 35 | - if ( 'string' === gettype( $item ) ) { | |
| 36 | - echo( htmlentities( $item ) ); | |
| 37 | - } else { | |
| 38 | - print_r( $item ); | |
| 39 | - } | |
| 40 | - } | |
| 41 | - echo "</pre></div>"; | |
| 42 | - echo '<script type="text/javascript"> jQuery(".ajax_respond_insert, .ajax_respond").show(); </script>'; | |
| 43 | - if ( $makeexit ) { | |
| 44 | - echo '<div style="font-size:18px;float:right;">' . get_num_queries(). '/' . timer_stop(0, 3) . 'qps</div>'; | |
| 45 | - exit; | |
| 46 | - } | |
| 47 | - } | |
| 35 | + if ( 'string' === gettype( $item ) ) { | |
| 36 | + echo( htmlentities( $item ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 37 | + } else { | |
| 38 | + print_r( $item ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r | |
| 39 | + } | |
| 40 | + } | |
| 41 | + echo '</pre></div>'; | |
| 42 | + echo '<script type="text/javascript"> jQuery(".ajax_respond_insert, .ajax_respond").show(); </script>'; | |
| 43 | + if ( $makeexit ) { | |
| 44 | + echo '<div style="font-size:18px;float:right;">' . esc_html( get_num_queries() ) . '/' . esc_html( timer_stop( 0, 3 ) ) . 'qps</div>'; | |
| 45 | + exit; | |
| 46 | + } | |
| 47 | + } | |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | |
| 51 | - | |
| 52 | 51 | /* |
| 53 | 52 | * Show debug info for Visitors. This function used for showing debug info for visitors at the website. |
| 54 | 53 | * if first parameter is 'clear', second parameter it's how many mesages (DIV elements) to show in exist view. Negative value, calculate DIV elements from bottom. |
| 55 | 54 | * Example: show_debug( 'clear', -3 ); - show 3 last DIV elements. |
| 56 | 55 | */ |
| 57 | -if (!function_exists ('show_debug')) { | |
| 58 | - //FixIn: 8.8.3.18 | |
| 59 | - function show_debug() { | |
| 60 | -//TODO: 2023-09-19 13:42 Need to remake it relative to new 'create_booking.php' functionality. We can not simply echo here !!!! | |
| 61 | - if ( is_admin() && ( defined( 'DOING_AJAX' ) ) && ( DOING_AJAX ) ) { | |
| 62 | - }else { | |
| 56 | +if ( ! function_exists( 'show_debug' ) ) { | |
| 57 | + // FixIn: 8.8.3.18. | |
| 58 | + function show_debug() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound | |
| 59 | + //TODO: 2023-09-19 13:42 Need to remake it relative to new 'create_booking.php' functionality. We can not simply echo here !!!! | |
| 60 | + if ( is_admin() && ( defined( 'DOING_AJAX' ) ) && ( DOING_AJAX ) ) { | |
| 61 | + } else { | |
| 63 | 62 | return; |
| 64 | 63 | } |
| 65 | 64 | |
| 66 | - //$numargs = func_num_args(); | |
| 67 | - $var = func_get_args(); | |
| 65 | + $var = func_get_args(); | |
| 68 | 66 | |
| 69 | - if ( 'clear' === $var[0] ) { | |
| 70 | - echo '<script type="text/javascript"> | |
| 67 | + if ( 'clear' === $var[0] ) { | |
| 68 | + echo '<script type="text/javascript"> | |
| 71 | 69 | jQuery(".ajax_respond_insert div").hide(); |
| 72 | - jQuery(".ajax_respond_insert div").slice( '.$var[1].' ).show(); | |
| 70 | + jQuery(".ajax_respond_insert div").slice( ' . esc_js( $var[1] ) . ' ).show(); | |
| 73 | 71 | </script>'; |
| 74 | - } | |
| 72 | + } | |
| 75 | 73 | |
| 76 | - $milliseconds = round(microtime(true) * 1000); | |
| 74 | + $milliseconds = round( microtime( true ) * 1000 ); | |
| 77 | 75 | |
| 78 | - echo "<div class='wpbc_debug wpbc_debug_{$milliseconds}'><pre class='prettyprint linenums'>"; | |
| 79 | - foreach ( $var as $ind => $item ) { | |
| 80 | - echo "\n"; | |
| 76 | + echo "<div class='wpbc_debug wpbc_debug_" . esc_attr( $milliseconds ) . "'><pre class='prettyprint linenums'>"; | |
| 77 | + foreach ( $var as $ind => $item ) { | |
| 78 | + echo "\n"; | |
| 81 | 79 | |
| 82 | - if ( 'string' === gettype( $item ) ) { | |
| 83 | - echo( htmlentities( $item ) ); | |
| 84 | - } else { | |
| 85 | - print_r( $item ); | |
| 86 | - } | |
| 87 | - } | |
| 88 | - echo "</pre></div>"; | |
| 89 | - echo '<script type="text/javascript"> jQuery(".ajax_respond_insert, .ajax_respond").show(); </script>'; | |
| 90 | - echo '<script type="text/javascript"> if ( jQuery(".ajax_respond_insert").length == 0 ) {jQuery(".wpbc_debug_'.$milliseconds.'").hide()}; </script>'; | |
| 91 | - } | |
| 80 | + if ( 'string' === gettype( $item ) ) { | |
| 81 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 82 | + echo( htmlentities( $item ) ); | |
| 83 | + } else { | |
| 84 | + print_r( $item ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r | |
| 85 | + } | |
| 86 | + } | |
| 87 | + echo "</pre></div>"; | |
| 88 | + echo '<script type="text/javascript"> jQuery(".ajax_respond_insert, .ajax_respond").show(); </script>'; | |
| 89 | + echo '<script type="text/javascript"> if ( jQuery(".ajax_respond_insert").length == 0 ) {jQuery(".wpbc_debug_' . esc_js( $milliseconds ) . '").hide()}; </script>'; | |
| 90 | + } | |
| 92 | 91 | } |
| 93 | 92 | |
| 94 | 93 | |
| 95 | 94 | /* |
| @@ -94,170 +93,169 @@ | ||
| 94 | 93 | |
| 95 | 94 | /* |
| 96 | 95 | * Show Speed of the execution and number of queries. |
| 97 | 96 | */ |
| 98 | -if (!function_exists ('debuge_speed')) { | |
| 99 | - function debuge_speed() { | |
| 100 | - echo '<div style="font-size:18px;float:right;">' . get_num_queries(). '/' . timer_stop(0, 3) . 'qps</div>'; | |
| 101 | - } | |
| 97 | +if ( ! function_exists( 'debuge_speed' ) ) { | |
| 98 | + function debuge_speed() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound | |
| 99 | + echo '<div style="font-size:18px;float:right;">' . esc_html( get_num_queries() ) . '/' . esc_html( timer_stop( 0, 3 ) ) . 'qps</div>'; | |
| 100 | + } | |
| 102 | 101 | } |
| 103 | 102 | |
| 104 | 103 | /** |
| 105 | - * Show error info | |
| 104 | + * Show error info | |
| 106 | 105 | */ |
| 107 | -if (!function_exists ('debuge_error')) { | |
| 108 | - function debuge_error( $msg , $file_name='', $line_num=''){ | |
| 109 | - echo get_debuge_error( $msg , $file_name , $line_num ); | |
| 110 | - } | |
| 106 | +if ( ! function_exists( 'debuge_error' ) ) { | |
| 107 | + function debuge_error( $msg, $file_name = '', $line_num = '' ) { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound | |
| 108 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 109 | + echo get_debuge_error( $msg, $file_name, $line_num ); | |
| 110 | + } | |
| 111 | 111 | } |
| 112 | -if (!function_exists ('get_debuge_error')) { | |
| 113 | - function get_debuge_error( $msg , $file_name='', $line_num=''){ | |
| 112 | +if ( ! function_exists( 'get_debuge_error' ) ) { | |
| 113 | + function get_debuge_error( $msg, $file_name = '', $line_num = '' ) { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound | |
| 114 | 114 | |
| 115 | - return wpbc_get_debuge_error( $msg , $file_name, $line_num ); | |
| 116 | - } | |
| 115 | + return wpbc_get_debuge_error( $msg, $file_name, $line_num ); | |
| 116 | + } | |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | |
| 120 | -function wpbc_get_debuge_error( $msg , $file_name='', $line_num=''){ | |
| 120 | +function wpbc_get_debuge_error( $msg, $file_name = '', $line_num = '' ) { | |
| 121 | 121 | |
| 122 | - $ver_num = ( ! defined('WPDEV_BK_VERSION') ) ? '' : '|V:' . WPDEV_BK_VERSION ; | |
| 122 | + $ver_num = ( ! defined( 'WPDEV_BK_VERSION' ) ) ? '' : '|V:' . WPDEV_BK_VERSION; | |
| 123 | 123 | |
| 124 | 124 | $last_db_error = ''; |
| 125 | 125 | global $EZSQL_ERROR; |
| 126 | 126 | |
| 127 | 127 | if ( |
| 128 | - ( ! empty( $EZSQL_ERROR ) ) | |
| 129 | - && ( is_array( $EZSQL_ERROR ) ) | |
| 130 | - && ( isset( $EZSQL_ERROR[ ( count( $EZSQL_ERROR ) - 1 ) ] ) ) | |
| 131 | - ){ | |
| 128 | + ( ! empty( $EZSQL_ERROR ) ) && ( is_array( $EZSQL_ERROR ) ) && ( isset( $EZSQL_ERROR[ ( count( $EZSQL_ERROR ) - 1 ) ] ) ) ) { | |
| 132 | 129 | |
| 133 | - $last_db_error2 = $EZSQL_ERROR[ (count($EZSQL_ERROR)-1)]; | |
| 130 | + $last_db_error2 = $EZSQL_ERROR[ ( count( $EZSQL_ERROR ) - 1 ) ]; | |
| 134 | 131 | |
| 135 | - if ( (isset($last_db_error2['query'])) && (isset($last_db_error2['error_str'])) ) { | |
| 132 | + if ( ( isset( $last_db_error2['query'] ) ) && ( isset( $last_db_error2['error_str'] ) ) ) { | |
| 136 | 133 | |
| 137 | 134 | $str = str_replace( array( '"', "'" ), '', $last_db_error2['error_str'] ); |
| 138 | 135 | $query = str_replace( array( '"', "'" ), '', $last_db_error2['query'] ); |
| 139 | 136 | |
| 140 | - $str = htmlspecialchars( $str, ENT_QUOTES ); | |
| 141 | - $query = htmlspecialchars( $query , ENT_QUOTES ); | |
| 137 | + $str = htmlspecialchars( $str, ENT_QUOTES ); | |
| 138 | + $query = htmlspecialchars( $query, ENT_QUOTES ); | |
| 142 | 139 | |
| 143 | - $last_db_error = $str ; | |
| 144 | - $last_db_error .= '::<span style="color:#300;">'.$query.'</span>'; | |
| 140 | + $last_db_error = $str; | |
| 141 | + $last_db_error .= '::<span style="color:#300;">' . $query . '</span>'; | |
| 145 | 142 | } |
| 146 | 143 | } |
| 147 | - return $msg . '<br /><span style="font-size:11px;"> [' | |
| 148 | - . 'F:' . str_replace( dirname( $file_name ) , '' , $file_name ) | |
| 149 | - . '| L:' . $line_num | |
| 150 | - . $ver_num | |
| 151 | - . '| DB:' . $last_db_error | |
| 152 | - . '] </span>' ; | |
| 144 | + | |
| 145 | + return $msg . '<br /><span style="font-size:11px;"> [F:' . str_replace( dirname( $file_name ), '', $file_name ) . '| L:' . $line_num . $ver_num . '| DB:' . $last_db_error . '] </span>'; | |
| 153 | 146 | } |
| 154 | 147 | |
| 155 | 148 | |
| 156 | 149 | // Usage: if ( function_exists ('wpbc_check_post_key_max_number')) { wpbc_check_post_key_max_number(); } |
| 157 | -if ( ! function_exists ('wpbc_check_post_key_max_number')) { | |
| 158 | - function wpbc_check_post_key_max_number() { | |
| 159 | - | |
| 160 | - /* | |
| 161 | - $post_max_totalname_length = intval( ( ini_get( 'suhosin.post.max_totalname_length' ) ) ? ini_get( 'suhosin.post.max_totalname_length' ) : '9999999' ); | |
| 162 | - $request_max_totalname_length = intval( ( ini_get( 'suhosin.request.max_totalname_length' ) ) ? ini_get( 'suhosin.request.max_totalname_length' ) : '9999999' ); | |
| 163 | - $post_max_name_length = intval( ( ini_get( 'suhosin.post.max_name_length' ) ) ? ini_get( 'suhosin.post.max_name_length' ) : '9999999' ); | |
| 164 | - $request_max_varname_length = intval( ( ini_get( 'suhosin.request.max_varname_length' ) ) ? ini_get( 'suhosin.request.max_varname_length' ) : '9999999' ); | |
| 165 | - */ | |
| 166 | - $php_ini_vars = array( | |
| 167 | - 'suhosin.post.max_totalname_length' | |
| 168 | - , 'suhosin.request.max_totalname_length' | |
| 169 | - , 'suhosin.post.max_name_length' | |
| 170 | - , 'suhosin.request.max_varname_length' | |
| 171 | - ); | |
| 172 | - | |
| 173 | - foreach ( $_POST as $key_name => $post_value ) { | |
| 174 | - | |
| 175 | - $key_length = strlen( $key_name ); | |
| 176 | - | |
| 177 | - foreach ( $php_ini_vars as $php_ini_var ) { | |
| 178 | - | |
| 179 | - $php_ini_var_length = intval( ( ini_get( $php_ini_var ) ) ? ini_get( $php_ini_var ) : '9999999' ); | |
| 180 | - | |
| 181 | - if ( $key_length > $php_ini_var_length ) { | |
| 182 | - | |
| 183 | - wpbc_show_message_in_settings( 'Your php.ini configuration limited to ' | |
| 184 | - . '<strong> '. $php_ini_var . ' = ' . $php_ini_var_length . '</strong>.' | |
| 185 | - . ' ' | |
| 186 | - . 'Plugin require at least ' . ( intval( $key_length ) + 1 ). ', ' | |
| 187 | - . 'for saving option: ' . '<strong>'. $key_name . '</strong>' | |
| 188 | - , 'error' | |
| 189 | - , __('Error' ,'booking') . '.' ); | |
| 190 | - | |
| 191 | - } | |
| 192 | - } | |
| 193 | - } | |
| 194 | - } | |
| 150 | +if ( ! function_exists( 'wpbc_check_post_key_max_number' ) ) { | |
| 151 | + function wpbc_check_post_key_max_number() { | |
| 152 | + | |
| 153 | + /* | |
| 154 | + $post_max_totalname_length = intval( ( ini_get( 'suhosin.post.max_totalname_length' ) ) ? ini_get( 'suhosin.post.max_totalname_length' ) : '9999999' ); | |
| 155 | + $request_max_totalname_length = intval( ( ini_get( 'suhosin.request.max_totalname_length' ) ) ? ini_get( 'suhosin.request.max_totalname_length' ) : '9999999' ); | |
| 156 | + $post_max_name_length = intval( ( ini_get( 'suhosin.post.max_name_length' ) ) ? ini_get( 'suhosin.post.max_name_length' ) : '9999999' ); | |
| 157 | + $request_max_varname_length = intval( ( ini_get( 'suhosin.request.max_varname_length' ) ) ? ini_get( 'suhosin.request.max_varname_length' ) : '9999999' ); | |
| 158 | + */ | |
| 159 | + $php_ini_vars = array( | |
| 160 | + 'suhosin.post.max_totalname_length', 'suhosin.request.max_totalname_length', 'suhosin.post.max_name_length', | |
| 161 | + 'suhosin.request.max_varname_length', | |
| 162 | + ); | |
| 163 | + // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 164 | + foreach ( $_POST as $key_name => $post_value ) { | |
| 165 | + | |
| 166 | + $key_length = strlen( $key_name ); | |
| 167 | + | |
| 168 | + foreach ( $php_ini_vars as $php_ini_var ) { | |
| 169 | + | |
| 170 | + $php_ini_var_length = intval( ( ini_get( $php_ini_var ) ) ? ini_get( $php_ini_var ) : '9999999' ); | |
| 171 | + | |
| 172 | + if ( $key_length > $php_ini_var_length ) { | |
| 173 | + | |
| 174 | + wpbc_show_message_in_settings( 'Your php.ini configuration limited to <strong> ' . $php_ini_var . ' = ' . $php_ini_var_length . '</strong>. ' . | |
| 175 | + 'Plugin require at least ' . ( intval( $key_length ) + 1 ) . ', ' . | |
| 176 | + 'for saving option: <strong>' . $key_name . '</strong>', | |
| 177 | + 'error', __( 'Error', 'booking' ) . '.' ); | |
| 178 | + } | |
| 179 | + } | |
| 180 | + } | |
| 181 | + } | |
| 195 | 182 | } |
| 196 | 183 | |
| 197 | 184 | |
| 198 | 185 | /** |
| 199 | - * Show System debug log for Beta features. | |
| 200 | - * | |
| 186 | + * Show System debug log for Beta features. | |
| 187 | + * | |
| 201 | 188 | * @param mixed $show_debug_info |
| 202 | - * | |
| 189 | + * | |
| 203 | 190 | * Example of usage: |
| 204 | - * | |
| 205 | - $is_show_debug_info = ( ( get_bk_option( 'booking_is_show_system_debug_log' ) == 'On' ) ? true : false ); | |
| 206 | - if ( $is_show_debug_info ) | |
| 207 | - add_action( 'wpbc_show_debug', 'wpbc_start_showing_debug', 10, 1 ); | |
| 208 | - ... | |
| 209 | - //- | |
| 210 | - do_action( 'wpbc_show_debug', array( 'after import' , $ics_array) ); | |
| 211 | - ... | |
| 212 | - if ( $is_show_debug_info ) | |
| 213 | - remove_action( 'wpbc_show_debug', 'wpbc_start_showing_debug', 10 ); | |
| 191 | + * | |
| 192 | + * $is_show_debug_info = ( ( get_bk_option( 'booking_is_show_system_debug_log' ) == 'On' ) ? true : false ); | |
| 193 | + * if ( $is_show_debug_info ) | |
| 194 | + * add_action( 'wpbc_show_debug', 'wpbc_start_showing_debug', 10, 1 ); | |
| 195 | + * ... | |
| 196 | + * //- | |
| 197 | + * do_action( 'wpbc_show_debug', array( 'after import' , $ics_array) ); | |
| 198 | + * ... | |
| 199 | + * if ( $is_show_debug_info ) | |
| 200 | + * remove_action( 'wpbc_show_debug', 'wpbc_start_showing_debug', 10 ); | |
| 214 | 201 | */ |
| 215 | -function wpbc_start_showing_debug( $show_debug_info ) { //FixIn: 7.2.1.15 | |
| 216 | - | |
| 217 | - // Make first item as header - bold | |
| 218 | - if ( is_array( $show_debug_info ) ) | |
| 202 | +function wpbc_start_showing_debug( $show_debug_info ) { | |
| 203 | + | |
| 204 | + // FixIn: 7.2.1.15. | |
| 205 | + | |
| 206 | + // Make first item as header - bold. | |
| 207 | + if ( is_array( $show_debug_info ) ) { | |
| 219 | 208 | $show_debug_info[0] = '<strong>' . $show_debug_info[0] . '</strong>'; |
| 220 | - | |
| 221 | - // Get evrything in human redable view | |
| 222 | - $show_debug_info = print_r ( $show_debug_info, true ); | |
| 209 | + } | |
| 223 | 210 | |
| 224 | - // Remove unnecesary new lines | |
| 211 | + // Get evrything in human redable view. | |
| 212 | + $show_debug_info = print_r( $show_debug_info, true ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r | |
| 213 | + | |
| 214 | + // Remove unnecesary new lines. | |
| 225 | 215 | $show_debug_info = preg_replace( '/Array[\n\r\s]*\(/', 'array(', $show_debug_info ); |
| 226 | 216 | $show_debug_info = preg_replace( '/\)\n/', ")", $show_debug_info ); |
| 227 | - | |
| 228 | - // Show | |
| 217 | + | |
| 218 | + // Show. | |
| 229 | 219 | echo "<div><pre class='prettyprint linenums'>"; |
| 230 | - | |
| 220 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 231 | 221 | echo( $show_debug_info ); |
| 232 | - | |
| 233 | - echo "</pre></div>"; | |
| 234 | - | |
| 222 | + | |
| 223 | + echo '</pre></div>'; | |
| 224 | + | |
| 235 | 225 | echo '<hr/>'; |
| 236 | - | |
| 237 | - // For system debug log in Ajax request show it | |
| 238 | - ?><script type="text/javascript"> jQuery( '.wpbc_system_info_log' ).show(); </script><?php | |
| 226 | + | |
| 227 | + // For system debug log in Ajax request show it. | |
| 228 | + ?> | |
| 229 | + <script type="text/javascript"> jQuery('.wpbc_system_info_log').show(); </script> | |
| 230 | + <?php | |
| 239 | 231 | } |
| 240 | - | |
| 241 | - | |
| 232 | + | |
| 233 | + | |
| 242 | 234 | /** |
| 243 | - * Show Top Notice in Admin panel by writing in-line JS | |
| 244 | - * | |
| 235 | + * Show Top Notice in Admin panel by writing in-line JS | |
| 236 | + * | |
| 245 | 237 | * @param string $message |
| 246 | - * @param string $message_type - (default notice) notice | error | warning | info | success | |
| 247 | - * @param int $seconds_to_show - (default 3000) - delay in microseconds | |
| 248 | - * @param bool $is_append - (default true) - append notice instead of replacing | |
| 238 | + * @param string $message_type - (default notice) notice | error | warning | info | success | |
| 239 | + * @param int $seconds_to_show - (default 3000) - delay in microseconds | |
| 240 | + * @param bool $is_append - (default true) - append notice instead of replacing | |
| 249 | 241 | */ |
| 250 | 242 | function wpbc_admin_show_top_notice( $message, $message_type = 'info', $seconds_to_show = 3000, $is_append = true ) { |
| 251 | 243 | |
| 252 | - if ( ! is_admin() ) return; | |
| 253 | - | |
| 254 | - // Show Notice in Admin header | |
| 255 | - ?><script type="text/javascript"> | |
| 256 | - wpbc_admin_show_message( '<?php echo html_entity_decode( esc_js( $message ), ENT_QUOTES ); ?>' | |
| 257 | - , '<?php echo $message_type; ?>' | |
| 258 | - , <?php echo intval( $seconds_to_show ); ?> | |
| 259 | - , <?php echo ( $is_append ? 'true' : 'false' ); ?> | |
| 260 | - ); | |
| 261 | - </script><?php | |
| 244 | + if ( ! is_admin() ) { | |
| 245 | + return; | |
| 246 | + } | |
| 247 | + | |
| 248 | + // Show Notice in Admin header. | |
| 249 | + ?> | |
| 250 | + <script type="text/javascript"> | |
| 251 | + wpbc_admin_show_message('<?php | |
| 252 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 253 | + echo html_entity_decode( esc_js( $message ), ENT_QUOTES ); ?>' | |
| 254 | + , '<?php echo esc_attr( $message_type ); ?>' | |
| 255 | + , <?php echo intval( $seconds_to_show ); ?> | |
| 256 | + , <?php echo( $is_append ? 'true' : 'false' ); ?> | |
| 257 | + ); | |
| 258 | + </script> | |
| 259 | + <?php | |
| 262 | 260 | } |
| 263 | 261 | add_action( 'wpbc_admin_show_top_notice', 'wpbc_admin_show_top_notice', 10, 3 ); |