| @@ -1,4 +1,4 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * @version 1.0 |
| 4 | 4 | * @package Booking Calendar |
| @@ -9,11 +9,12 @@ | ||
| 9 | 9 | * @link https://wpbookingcalendar.com/ |
| 10 | 10 | * @email info@wpbookingcalendar.com |
| 11 | 11 | * |
| 12 | 12 | * @modified 2023-12-27 |
| 13 | + * @file: ../includes/publish/wpbc-publish-shortcode.php | |
| 13 | 14 | */ |
| 14 | 15 | |
| 15 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly //FixIn: 9.8.15.5 | |
| 16 | +if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly // FixIn: 9.8.15.5. | |
| 16 | 17 | |
| 17 | 18 | |
| 18 | 19 | /** |
| 19 | 20 | * Get prepared (for WP Blocks) shortcode of booking form for inserting into the post or page |
| @@ -50,17 +51,21 @@ | ||
| 50 | 51 | * @return false|void |
| 51 | 52 | */ |
| 52 | 53 | function wpbc_check_for_submit__page_resource_publish( $page_name ) { |
| 53 | 54 | |
| 54 | - if ( 'resources' !== $page_name ) { | |
| 55 | + if ( | |
| 56 | + ( 'resources' !== $page_name ) | |
| 57 | + // && ( 'wpbc-ajx_booking_setup_wizard' !== $page_name ) | |
| 58 | + ){ | |
| 55 | 59 | return false; |
| 56 | 60 | } |
| 57 | 61 | |
| 58 | 62 | // Check $_POST |
| 59 | 63 | |
| 64 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 60 | 65 | if ( ( isset( $_POST['action'] ) ) && ( 'wpbc_page_resource_publish' === $_POST['action'] ) ) { |
| 61 | 66 | |
| 62 | - if ( wpbc_is_this_demo() ) { | |
| 67 | + if ( wpbc_is_booking_form_publishing_restricted() ) { | |
| 63 | 68 | wpbc_show_notice__for_page_resource_publish( 'This operation is restricted in the demo version.', 'warning' ); |
| 64 | 69 | return; |
| 65 | 70 | } |
| 66 | 71 | |
| @@ -68,18 +73,20 @@ | ||
| 68 | 73 | |
| 69 | 74 | $add_shortcode_result_arr = false; |
| 70 | 75 | |
| 71 | 76 | // CREATE NEW PAGE |
| 72 | - if( | |
| 73 | - ( 'create' === $_POST['wpbc_page_resource_publish_what'] ) | |
| 77 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated | |
| 78 | + if ( ( 'create' === $_POST['wpbc_page_resource_publish_what'] ) | |
| 74 | 79 | && ( ! empty($_POST['create_page_for_resource_publish'] ) ) |
| 75 | 80 | && ( ! empty($_POST['wpbc_page_resource_publish_resource_id'] ) ) |
| 76 | 81 | ){ |
| 77 | - $shortcode_resource_id = intval( $_POST['wpbc_page_resource_publish_resource_id'] ); | |
| 78 | - $page_name = $_POST['create_page_for_resource_publish']; | |
| 82 | + $shortcode_resource_id = intval( $_POST['wpbc_page_resource_publish_resource_id'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 83 | + $page_name = sanitize_text_field( wp_unslash( $_POST['create_page_for_resource_publish'] ) ); /* phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing */ /* FixIn: sanitize_unslash */ | |
| 79 | 84 | |
| 85 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 80 | 86 | if ( ! empty( $_POST['wpbc_page_resource_publish_resource_shortcode'] ) ) { |
| 81 | 87 | //$insert_shortcode = WPBC_Settings_API::validate_textarea_post_static( 'wpbc_page_resource_publish_resource_shortcode' ); |
| 88 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 82 | 89 | $insert_shortcode = wp_kses( trim( stripslashes( $_POST[ 'wpbc_page_resource_publish_resource_shortcode' ] ) ), |
| 83 | 90 | array_merge( array( // 'iframe' => array( 'src' => true, 'style' => true, 'id' => true, 'class' => true ) |
| 84 | 91 | // , 'script' => array( 'type' => true ) // Allow JS |
| 85 | 92 | ), |
| @@ -104,15 +111,15 @@ | ||
| 104 | 111 | ) ); |
| 105 | 112 | } |
| 106 | 113 | |
| 107 | 114 | // ADD TO EXIST PAGE |
| 108 | - if( | |
| 109 | - ( 'edit' === $_POST['wpbc_page_resource_publish_what'] ) | |
| 115 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated | |
| 116 | + if ( ( 'edit' === $_POST['wpbc_page_resource_publish_what'] ) | |
| 110 | 117 | && ( ! empty($_POST['select_page_for_resource_publish'] ) ) |
| 111 | 118 | && ( ! empty($_POST['wpbc_page_resource_publish_resource_id'] ) ) |
| 112 | 119 | ){ |
| 113 | - $shortcode_resource_id = intval( $_POST['wpbc_page_resource_publish_resource_id'] ); | |
| 114 | - $page_id = intval( $_POST['select_page_for_resource_publish'] ); | |
| 120 | + $shortcode_resource_id = intval( $_POST['wpbc_page_resource_publish_resource_id'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 121 | + $page_id = intval( $_POST['select_page_for_resource_publish'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 115 | 122 | |
| 116 | 123 | // Add shortcode to specific Page with POST ID |
| 117 | 124 | $check_exist_shortcode_arr = array( |
| 118 | 125 | '[booking resource_id=' . $shortcode_resource_id . ' ', |
| @@ -124,10 +131,12 @@ | ||
| 124 | 131 | $check_exist_shortcode_arr[] = '[booking]'; |
| 125 | 132 | } |
| 126 | 133 | |
| 127 | 134 | |
| 135 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 128 | 136 | if ( ! empty( $_POST['wpbc_page_resource_publish_resource_shortcode'] ) ) { |
| 129 | 137 | //$insert_shortcode = WPBC_Settings_API::validate_textarea_post_static( 'wpbc_page_resource_publish_resource_shortcode' ); |
| 138 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 130 | 139 | $insert_shortcode = wp_kses( trim( stripslashes( $_POST[ 'wpbc_page_resource_publish_resource_shortcode' ] ) ), |
| 131 | 140 | array_merge( array( // 'iframe' => array( 'src' => true, 'style' => true, 'id' => true, 'class' => true ) |
| 132 | 141 | // , 'script' => array( 'type' => true ) // Allow JS |
| 133 | 142 | ), |
| @@ -164,17 +173,19 @@ | ||
| 164 | 173 | // . ' ' . '<a href="' . esc_url( wpbc_make_link_absolute( $relative_post_url ) ) . '">' . $post_title . '</a>' |
| 165 | 174 | ); |
| 166 | 175 | |
| 167 | 176 | } elseif ( false === $add_shortcode_result_arr ) { |
| 168 | - wpbc_show_notice__for_page_resource_publish( 'Error: You may not have chosen the correct page name.', 'warning' ); | |
| 177 | + wpbc_show_notice__for_page_resource_publish( 'Error: You may not have chosen the correct page name.', 'error' ); | |
| 169 | 178 | wpbc_show_notice__for_page_resource_publish( |
| 170 | - sprintf( __('Find more information at the %sFAQ page%s','booking'), | |
| 179 | + /* translators: 1: ... */ | |
| 180 | + sprintf( __( 'Find more information at the %1$sFAQ page%2$s', 'booking' ), | |
| 171 | 181 | '<a href="https://wpbookingcalendar.com/faq/#shortcodes">', '</a>' |
| 172 | 182 | ), 'info'); |
| 173 | 183 | }else { |
| 174 | - wpbc_show_notice__for_page_resource_publish( $add_shortcode_result_arr['message'], 'warning' ); | |
| 184 | + wpbc_show_notice__for_page_resource_publish( $add_shortcode_result_arr['message'], 'error' ); | |
| 175 | 185 | wpbc_show_notice__for_page_resource_publish( |
| 176 | - sprintf( __('Find more information at the %sFAQ page%s','booking'), | |
| 186 | + /* translators: 1: ... */ | |
| 187 | + sprintf( __( 'Find more information at the %1$sFAQ page%2$s', 'booking' ), | |
| 177 | 188 | '<a href="https://wpbookingcalendar.com/faq/#shortcodes">', '</a>' |
| 178 | 189 | ), 'info'); |
| 179 | 190 | } |
| 180 | 191 | |
| @@ -179,16 +190,35 @@ | ||
| 179 | 190 | } |
| 180 | 191 | |
| 181 | 192 | } |
| 182 | 193 | } |
| 183 | -add_action( 'wpbc_hook_settings_page_before_content_table', 'wpbc_check_for_submit__page_resource_publish' ,10, 1); | |
| 184 | - | |
| 185 | - | |
| 186 | -function wpbc_show_notice__for_page_resource_publish( $message, $message_type='success'){ | |
| 187 | - ?> | |
| 188 | - <div class="wpbc-settings-notice notice-<?php echo $message_type ?>" style="text-align:left;font-size: 1rem;margin-top:20px;"> | |
| 189 | - <strong><?php echo ( ( 'error' == $message_type ) ? ( __('Error' ,'booking') . '! ' ) : '' ); ?></strong> <?php | |
| 190 | - echo $message; | |
| 194 | +add_action( 'wpbc_hook_settings_page_before_content_table', 'wpbc_check_for_submit__page_resource_publish' ,10, 1); | |
| 195 | + | |
| 196 | +/** | |
| 197 | + * Render feedback from the Booking Resource publishing workflow. | |
| 198 | + * | |
| 199 | + * The shared publisher is also used outside the Resources catalog, so catalog | |
| 200 | + * spacing is applied only while the new catalog renderer owns the request. | |
| 201 | + * | |
| 202 | + * @param string $message Escaped or deliberately prepared notice markup. | |
| 203 | + * @param string $message_type Notice type used by the Booking Calendar notice styles. | |
| 204 | + * | |
| 205 | + * @return void | |
| 206 | + */ | |
| 207 | +function wpbc_show_notice__for_page_resource_publish( $message, $message_type = 'success' ) { | |
| 208 | + $notice_style = 'text-align:left;font-size:1rem;margin-top:20px;'; | |
| 209 | + | |
| 210 | + if ( function_exists( 'wpbc_catalog_booking_resources_is_page' ) && wpbc_catalog_booking_resources_is_page() ) { | |
| 211 | + $notice_style = 'text-align:left;font-size:1rem;margin:0 0 40px;'; | |
| 212 | + } | |
| 213 | + ?> | |
| 214 | + <div class="wpbc-settings-notice notice-<?php echo esc_attr( $message_type ); ?>" style="<?php echo esc_attr( $notice_style ); ?>"> | |
| 215 | + <strong><?php | |
| 216 | + if ( ( 'error' == $message_type ) ) { | |
| 217 | + echo esc_html__( 'Error', 'booking' ) . '! '; | |
| 218 | + } ?></strong> <?php | |
| 219 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 220 | + echo $message; | |
| 191 | 221 | ?> |
| 192 | 222 | </div> |
| 193 | 223 | <?php |
| 194 | 224 | } |
| @@ -196,9 +226,16 @@ | ||
| 196 | 226 | |
| 197 | 227 | /** Publish Layout - Modal Window structure */ |
| 198 | 228 | function wpbc_write_content_for_modal__page_resource_publish( $page_name ) { |
| 199 | 229 | |
| 200 | - if ( 'resources' !== $page_name ) { return false; } | |
| 230 | + if ( | |
| 231 | + ( 'resources' !== $page_name ) && | |
| 232 | + ( 'wpbc-ajx_booking_setup_wizard' !== $page_name ) && | |
| 233 | + ( ! wpbc_is_builder_booking_form_page() ) | |
| 234 | + // && ( 'wpbc-ajx_booking' !== $page_name ) // FixIn: 10.6.6.2. | |
| 235 | + ){ | |
| 236 | + return false; | |
| 237 | + } | |
| 201 | 238 | |
| 202 | 239 | ?><span class="wpdevelop"><?php |
| 203 | 240 | |
| 204 | 241 | ?><div id="wpbc_modal__resource_publish" class="modal wpbc_popup_modal" tabindex="-1" role="dialog"> |
| @@ -254,14 +291,14 @@ | ||
| 254 | 291 | <div class="modal-dialog modal-lg0"> |
| 255 | 292 | <div class="modal-content"> |
| 256 | 293 | <div class="modal-header"> |
| 257 | 294 | <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> |
| 258 | - <h4 class="modal-title"><?php _e( 'Insert into page' ); ?></h4> | |
| 295 | + <h4 class="modal-title"><?php esc_html_e( 'Insert into page', 'booking' ); ?></h4> | |
| 259 | 296 | </div> |
| 260 | 297 | <div class="modal-body"> |
| 261 | 298 | <div id="wpbc_content_for_js_resource_publish"> |
| 262 | 299 | <?php |
| 263 | - if ( wpbc_is_this_demo() ) { | |
| 300 | + if ( wpbc_is_booking_form_publishing_restricted() ) { | |
| 264 | 301 | wpbc_show_notice__for_page_resource_publish( 'In the demo versions such operation is not allowed.', 'warning' ); |
| 265 | 302 | } else { |
| 266 | 303 | ?> |
| 267 | 304 | <form method="post" action=""> |
| @@ -272,9 +309,9 @@ | ||
| 272 | 309 | <?php |
| 273 | 310 | wp_nonce_field( 'set_resource_publish_check' ); |
| 274 | 311 | ?> |
| 275 | 312 | <div class="wpbc_publish_wizard_steps wpbc_publish_wizard_step_1"> |
| 276 | - <div class="wpbc_publish_wizard_inner_header"><?php _e('Choose whether to embed your booking form in an existing page or create a new one.', 'booking'); ?></div> | |
| 313 | + <div class="wpbc_publish_wizard_inner_header"><?php esc_html_e('Choose whether to embed your booking form in an existing page or create a new one.', 'booking'); ?></div> | |
| 277 | 314 | <div class="wpbc_publish_wizard_steps__buttons"> |
| 278 | 315 | <a href="javascript:void(0)" class="button button-secondary" |
| 279 | 316 | onclick="javascript:jQuery( '.wpbc_publish_wizard_steps').hide(); |
| 280 | 317 | jQuery( '.wpbc_publish_wizard_step_2').show(); |
| @@ -280,9 +317,9 @@ | ||
| 280 | 317 | jQuery( '.wpbc_publish_wizard_step_2').show(); |
| 281 | 318 | jQuery( '#wpbc_modal__resource_publish .modal-footer').show(); |
| 282 | 319 | jQuery( '#wpbc_page_resource_publish_resource_shortcode' ).val( jQuery( '#booking_resource_shortcode_' + jQuery( '#wpbc_page_resource_publish_resource_id' ).val() ).val() ); |
| 283 | 320 | jQuery( '#wpbc_page_resource_publish_what' ).val( 'edit' );" |
| 284 | - ><?php _e('Embed in Existing Page','booking') ?></a> | |
| 321 | + ><?php esc_html_e('Embed in Existing Page', 'booking' ); ?></a> | |
| 285 | 322 | <a href="javascript:void(0)" class="button button-secondary" |
| 286 | 323 | onclick="javascript:jQuery( '.wpbc_publish_wizard_steps').hide(); |
| 287 | 324 | jQuery( '.wpbc_publish_wizard_step_3').show(); |
| 288 | 325 | jQuery( '#wpbc_modal__resource_publish .modal-footer').show(); |
| @@ -287,36 +324,35 @@ | ||
| 287 | 324 | jQuery( '.wpbc_publish_wizard_step_3').show(); |
| 288 | 325 | jQuery( '#wpbc_modal__resource_publish .modal-footer').show(); |
| 289 | 326 | jQuery( '#wpbc_page_resource_publish_resource_shortcode' ).val( jQuery( '#booking_resource_shortcode_' + jQuery( '#wpbc_page_resource_publish_resource_id' ).val() ).val() ); |
| 290 | 327 | jQuery( '#wpbc_page_resource_publish_what' ).val( 'create' );" |
| 291 | - ><?php _e('Create New Page','booking') ?></a> | |
| 328 | + ><?php esc_html_e('Create New Page','booking'); ?></a> | |
| 292 | 329 | </div> |
| 293 | 330 | </div> |
| 294 | 331 | <div class="wpbc_publish_wizard_steps wpbc_publish_wizard_step_2"> |
| 295 | - <div class="wpbc_publish_wizard_inner_header"><?php _e('Select the page where you want to embed your booking form.', 'booking'); ?></div> | |
| 332 | + <div class="wpbc_publish_wizard_inner_header"><?php esc_html_e('Select the page where you want to embed your booking form.', 'booking'); ?></div> | |
| 296 | 333 | <div class="wpbc_publish_wizard_steps__inputs"> |
| 297 | 334 | <?php |
| 298 | 335 | wp_dropdown_pages( |
| 299 | 336 | array( |
| 300 | 337 | 'name' => 'select_page_for_resource_publish', |
| 301 | - 'show_option_none' => __( '— Select —' ), | |
| 338 | + 'show_option_none' => '— ' . esc_html__( 'Select', 'booking' ) . ' —', | |
| 302 | 339 | 'option_none_value' => '0', |
| 303 | 340 | 'selected' => 0,//$privacy_policy_page_id, |
| 304 | 341 | 'post_status' => array( 'draft', 'publish' ), |
| 305 | 342 | ) |
| 306 | 343 | ); |
| 307 | - submit_button( __( 'Use This Page' ), 'primary', 'submit', false, array( 'id' => 'set-page' ) ); | |
| 344 | + submit_button( __( 'Use This Page', 'booking' ), 'primary', 'submit', false, array( 'id' => 'set-page' ) ); | |
| 308 | 345 | ?> |
| 309 | 346 | </div> |
| 310 | 347 | </div> |
| 311 | 348 | <div class="wpbc_publish_wizard_steps wpbc_publish_wizard_step_3"> |
| 312 | - <div class="wpbc_publish_wizard_inner_header"><?php _e('Provide a name for your new page.', 'booking'); ?></div> | |
| 349 | + <div class="wpbc_publish_wizard_inner_header"><?php esc_html_e('Provide a name for your new page.', 'booking'); ?></div> | |
| 313 | 350 | <div class="wpbc_publish_wizard_steps__inputs"> |
| 314 | 351 | <input id="create_page_for_resource_publish" name="create_page_for_resource_publish" type="text" value="" |
| 315 | 352 | placeholder="<?php echo esc_attr( __( 'Enter Page Name', 'booking' ) ); ?>"/> |
| 316 | 353 | <?php |
| 317 | - | |
| 318 | - submit_button( __( 'Create Page' ), 'primary', 'submit', false, array( 'id' => 'set-page' ) ); | |
| 354 | + submit_button( __( 'Create Page', 'booking' ), 'primary', 'submit', false, array( 'id' => 'set-page' ) ); | |
| 319 | 355 | ?> |
| 320 | 356 | </div> |
| 321 | 357 | </div> |
| 322 | 358 | </form> |
| @@ -323,15 +359,15 @@ | ||
| 323 | 359 | <?php } ?> |
| 324 | 360 | </div> |
| 325 | 361 | </div> |
| 326 | 362 | <div class="modal-footer"> |
| 327 | - <!--a href="javascript:void(0)" class="button button-secondary" data-dismiss="modal"><?php _e('Close' ,'booking'); ?></a--> | |
| 363 | + <!--a href="javascript:void(0)" class="button button-secondary" data-dismiss="modal"><?php esc_html_e('Close' ,'booking'); ?></a--> | |
| 328 | 364 | <a id="wpbc_modal__go_back_button" class="button button-secondary" |
| 329 | 365 | href="javascript:void(0);" |
| 330 | 366 | onclick="javascript:jQuery( '.wpbc_publish_wizard_steps').hide(); |
| 331 | 367 | jQuery( '.wpbc_publish_wizard_step_1').show(); |
| 332 | 368 | jQuery( '#wpbc_modal__resource_publish .modal-footer').hide();" |
| 333 | - ><i class="menu_icon icon-1x wpbc_icn_keyboard_arrow_left"></i> <?php _e('Go Back' ,'booking'); ?></a> | |
| 369 | + ><i class="menu_icon icon-1x wpbc_icn_keyboard_arrow_left"></i> <?php esc_html_e('Go Back' ,'booking'); ?></a> | |
| 334 | 370 | </div> |
| 335 | 371 | </div><!-- /.modal-content --> |
| 336 | 372 | </div><!-- /.modal-dialog --> |
| 337 | 373 | </div><!-- /.modal --> |