PluginProbe
Content Blocks Builder – Create blocks, repeater blocks with carousel, grid, popup layouts / trunk
Content Blocks Builder – Create blocks, repeater blocks with carousel, grid, popup layouts vtrunk
2.8.14 2.8.13 2.8.12 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.8.0 2.8.1 2.8.10 2.8.11 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.8.9 trunk 1.0.1 1.0.2 1.1.0 1.1.1 All 147 releases
← All changes | includes/patterns.php +36 -14 2.7.8trunk View file →
@@ -88,9 +88,9 @@
88 88 // Handle save post.
89 89 add_action( 'save_post_' . $this->post_type, [ $this, 'save_post' ], 10, 2 );
90 90
91 91 // Clear the transient cache on upgraded.
92 - add_action( 'cbb_version_upgraded', [ $this, 'clear_transient_cache' ] );
92 + add_action( 'cbb/version_upgraded', [ $this, 'clear_transient_cache' ] );
93 93
94 94 // Force to remove custom fields.
95 95 add_action( 'add_meta_boxes', [ $this, 'remove_meta_boxes' ] );
96 96 }
@@ -217,20 +217,22 @@
217 217
218 218 $this->register_meta(
219 219 'boldblocks_pattern_disabled_inserter',
220 220 [
221 - 'type' => 'boolean',
222 - 'default' => false,
221 + 'type' => 'boolean',
222 + 'sanitize_callback' => 'rest_sanitize_boolean',
223 + 'default' => false,
223 224 ]
224 225 );
225 226
226 227 // Setting fields.
228 + // phpcs:disable PluginCheck.CodeAnalysis.SettingSanitization.register_settingDynamic
227 229 register_setting(
228 - 'boldblocks',
229 - 'boldblocks_pattern_categories',
230 + 'cbb',
231 + 'cbb_pattern_categories',
230 232 [
231 - 'type' => 'array',
232 - 'show_in_rest' => array(
233 + 'type' => 'array',
234 + 'show_in_rest' => array(
233 235 'schema' => array(
234 236 'items' => array(
235 237 'type' => 'object',
236 238 'properties' => array(
@@ -243,15 +245,34 @@
243 245 ),
244 246 ),
245 247 ),
246 248 ),
247 - 'default' => [],
249 + 'sanitize_callback' => function( $value ) {
250 + if ( ! is_array( $value ) ) {
251 + return [];
252 + }
253 +
254 + $categories = [];
255 + foreach ( $value as $category ) {
256 + if ( ! is_array( $category ) ) {
257 + continue;
258 + }
259 +
260 + $categories[] = [
261 + 'name' => sanitize_text_field( $category['name'] ?? '' ),
262 + 'label' => sanitize_text_field( $category['label'] ?? '' ),
263 + ];
264 + }
265 +
266 + return $categories;
267 + },
268 + 'default' => [],
248 269 ]
249 270 );
250 271
251 272 register_setting(
252 - 'boldblocks',
253 - 'boldblocks_pattern_categories_all_label',
273 + 'cbb',
274 + 'cbb_pattern_categories_all_label',
254 275 [
255 276 'type' => 'string',
256 277 'show_in_rest' => true,
257 278 'default' => __( 'All patterns by CBB', 'content-blocks-builder' ),
@@ -256,8 +277,9 @@
256 277 'show_in_rest' => true,
257 278 'default' => __( 'All patterns by CBB', 'content-blocks-builder' ),
258 279 ]
259 280 );
281 + // phpcs:enable PluginCheck.CodeAnalysis.SettingSanitization.register_settingDynamic
260 282 }
261 283
262 284 /**
263 285 * Register meta field
@@ -310,9 +332,9 @@
310 332 * @return void
311 333 */
312 334 public function register_patterns() {
313 335 // Register custom categories.
314 - $pattern_categories = get_option( 'boldblocks_pattern_categories', [] );
336 + $pattern_categories = get_option( 'cbb_pattern_categories', [] );
315 337 if ( is_array( $pattern_categories ) ) {
316 338 foreach ( $pattern_categories as $category ) {
317 339 if ( ! empty( $category['name'] ) && ! empty( $category['label'] ) ) {
318 340 if ( ! \WP_Block_Pattern_Categories_Registry::get_instance()->is_registered( $category['name'] ) ) {
@@ -321,10 +343,10 @@
321 343 }
322 344 }
323 345 }
324 346
325 - // Register a custom category for patterns made by BoldBlocks.
326 - register_block_pattern_category( 'boldblocks', [ 'label' => get_option( 'boldblocks_pattern_categories_all_label', _x( 'All patterns by CBB', 'Block pattern category', 'content-blocks-builder' ) ) ] );
347 + // Register a custom category for patterns made by CBB.
348 + register_block_pattern_category( 'cbb', [ 'label' => get_option( 'cbb_pattern_categories_all_label', _x( 'All patterns by CBB', 'CBB block pattern category', 'content-blocks-builder' ) ) ] );
327 349
328 350 if ( apply_filters( 'boldblocks_load_patterns', true ) ) {
329 351 // Query all patterns.
330 352 $pattern_posts = $this->get_all_custom_patterns();
@@ -414,9 +436,9 @@
414 436 },
415 437 $categories
416 438 );
417 439 }
418 - $categories[] = 'boldblocks';
440 + $categories[] = 'cbb';
419 441
420 442 $pattern_settings = [
421 443 'title' => wp_strip_all_tags( $pattern_post->post_title ),
422 444 'content' => $pattern_post->post_content,