PluginProbe
Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar / 2.1.21
Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar v2.1.21
2.1.22 2.1.21 2.1.20 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 trunk 1.1 2.0 2.0.1 2.0.10.2 2.0.11 2.0.12 2.0.13 2.0.14 2.0.15 2.0.16 2.0.17 2.0.18 2.0.2 2.0.20 2.0.21 All 56 releases
← All changes | core/wpbm-shortcodes.php +47 -0 2.1.9 → 2.1.21 View file →
@@ -27,8 +27,10 @@
27 27 if ( ( function_exists( 'wpbc_is_on_edit_page' ) ) && ( wpbc_is_on_edit_page() ) ) {
28 28 return wpbc_get_preview_for_shortcode( 'booking-manager-import', $attr ); //FixIn: 9.9.0.39
29 29 }
30 30
31 + if ( wpbm_block_shortcodes_if_unpublished() ) { return ''; } // FixIn: 2.1.15.1.
32 +
31 33 ob_start();
32 34
33 35 $import_status = wpbm_ics_import_start( $attr );
34 36
@@ -72,8 +74,10 @@
72 74 if ( ( function_exists( 'wpbc_is_on_edit_page' ) ) && ( wpbc_is_on_edit_page() ) ) {
73 75 return wpbc_get_preview_for_shortcode( 'booking-manager-listing', $attr ); //FixIn: 9.9.0.39
74 76 }
75 77
78 + if ( wpbm_block_shortcodes_if_unpublished() ) { return ''; } // FixIn: 2.1.15.1.
79 +
76 80 $listing = wpbm_ics_get_listing( $attr );
77 81
78 82 return $listing;
79 83
@@ -89,8 +93,10 @@
89 93 if ( ( function_exists( 'wpbc_is_on_edit_page' ) ) && ( wpbc_is_on_edit_page() ) ) {
90 94 return wpbc_get_preview_for_shortcode( 'booking-manager-delete', $attr ); //FixIn: 9.9.0.39
91 95 }
92 96
97 + if ( wpbm_block_shortcodes_if_unpublished() ) { return ''; } // FixIn: 2.1.15.1.
98 +
93 99 ob_start();
94 100
95 101 if ( ! isset( $attr['resource_id'] ) ) {
96 102 $attr['resource_id'] = 1;
@@ -142,4 +148,45 @@
142 148
143 149 return '';
144 150 }
145 151 add_shortcode( 'booking-manager-delete', 'wpbm_ics_delete_shortcode' );
152 +
153 +
154 +/**
155 + * Return true if shortcode should NOT run for the current post context.
156 + * Allowed statuses are filterable via 'wpbm_shortcode_allowed_statuses' (default: ['publish']).
157 + *
158 + * @return bool
159 + */
160 +function wpbm_block_shortcodes_if_unpublished() {
161 +
162 + // FixIn: 2.1.15.1.
163 + $post = get_post();
164 + if ( ! $post ) {
165 + return true; // no post context -> suppress.
166 + }
167 +
168 + // e.g. add 'private'.
169 + $allowed_statuses = apply_filters( 'wpbm_shortcode_allowed_statuses', array( 'publish' ) );
170 +
171 + // Do not execute the shortcode.
172 + if ( ! in_array( $post->post_status, $allowed_statuses, true ) ) {
173 + return true;
174 + }
175 +
176 + // Optional: allow front-end preview for editors.
177 + /*
178 + if ( is_preview() && current_user_can( 'edit_post', $post->ID ) ) {
179 + return false; // allow
180 + }
181 + */
182 +
183 + // Optional: suppress in REST/admin universally.
184 + /*
185 + if ( is_admin() || ( defined( 'REST_REQUEST' ) && REST_REQUEST ) ) {
186 + return true;
187 + }
188 + */
189 +
190 + // Execute the shortcode normally.
191 + return false;
192 +}