PluginProbe
Post Grid Gutenberg Blocks – PostX / 5.1.1
Post Grid Gutenberg Blocks – PostX v5.1.1
5.1.1 5.1.0 5.0.41 5.0.39 5.0.38 5.0.37 5.0.36 5.0.35 5.0.34 5.0.33 5.0.32 5.0.31 5.0.30 5.0.29 5.0.28 5.0.27 5.0.26 5.0.25 5.0.23 5.0.24 5.0.22 5.0.21 5.0.20 5.0.19 5.0.18 All 240 releases
← All changes | classes/Styles.php +86 -6 5.0.18 → 5.1.1 View file →
@@ -300,9 +300,9 @@
300 300 * @return STRING
301 301 */
302 302 public function disable_google_font_callback() {
303 303 if ( ! ( isset( $_REQUEST['wpnonce'] ) &&
304 - wp_verify_nonce( sanitize_key( wp_unslash( $_REQUEST['wpnonce'] ) ), 'ultp-nonce' ) )
304 + wp_verify_nonce( sanitize_key( wp_unslash( $_REQUEST['wpnonce'] ) ), 'ultp-admin-nonce' ) )
305 305 ) {
306 306 return;
307 307 }
308 308 if ( ! ultimate_post()->permission_check_for_restapi() ) {
@@ -415,9 +415,9 @@
415 415 $ultpPresetColors = get_option( 'ultpPresetColors', array() );
416 416
417 417 $rootCSS = ( isset( $ultpPresetColors['rootCSS'] ) && $ultpPresetColors['rootCSS'] ) ? $ultpPresetColors['rootCSS'] : ':root { --postx_preset_Base_1_color: #f4f4ff; --postx_preset_Base_2_color: #dddff8; --postx_preset_Base_3_color: #B4B4D6; --postx_preset_Primary_color: #3323f0; --postx_preset_Secondary_color: #4a5fff; --postx_preset_Tertiary_color: #FFFFFF; --postx_preset_Contrast_3_color: #545472; --postx_preset_Contrast_2_color: #262657; --postx_preset_Contrast_1_color: #10102e; --postx_preset_Over_Primary_color: #ffffff; }';
418 418 $savedDLMode = ( isset( $global['enableDark'] ) && $global['enableDark'] ) ? 'ultpdark' : 'ultplight';
419 - $localDLMode = isset( $_COOKIE['ultplocalDLMode'] ) ? $_COOKIE['ultplocalDLMode'] : $savedDLMode;
419 + $localDLMode = isset( $_COOKIE['ultplocalDLMode'] ) ? sanitize_key( wp_unslash( $_COOKIE['ultplocalDLMode'] ) ) : $savedDLMode;
420 420
421 421 if ( $localDLMode == 'ultplight' && $savedDLMode == 'ultpdark' ) {
422 422 $rootCSS = $this->handle_dark_light_color_switcher( $rootCSS );
423 423 } elseif ( $localDLMode == 'ultpdark' ) {
@@ -453,9 +453,9 @@
453 453 */
454 454 public function enqueue_postx_block_css() {
455 455 $this->postx_global_css_callback();
456 456 if ( apply_filters( 'postx_common_script', false ) ||
457 - isset( $_GET['et_fb'] ) // divi theme issue.
457 + isset( $_GET['et_fb'] ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only Divi editor detection (divi theme issue).
458 458 ) {
459 459 ultimate_post()->register_scripts_common();
460 460 }
461 461 if ( is_admin() ) {
@@ -462,8 +462,9 @@
462 462 return;
463 463 }
464 464 if ( wp_is_block_theme() ) {
465 465 $this->handle_old_fse_css();
466 + $this->handle_fse_template_parts_css();
466 467 }
467 468 $css = '';
468 469 $post_id = ultimate_post()->get_ID();
469 470 if ( isset($_GET['preview_id']) && isset($_GET['preview_nonce']) ) { // @codingStandardsIgnoreLine.
@@ -555,11 +556,17 @@
555 556 }
556 557 }
557 558 }
558 559 }
560 + /**
561 + * Whether the Mega Menu block renders. PostX Pro provides it; PostX alone does not.
562 + *
563 + * @param bool $render Whether to output the block. False by default.
564 + * @param array $block The block being rendered.
565 + */
559 566 if (
560 - $block['blockName'] == 'ultimate-post/mega-menu' &&
561 - ! ultimate_post()->is_lc_active()
567 + 'ultimate-post/mega-menu' === $block['blockName'] &&
568 + ! apply_filters( 'ultp_mega_menu_render', false, $block )
562 569 ) {
563 570 return '';
564 571 }
565 572 }
@@ -564,8 +571,31 @@
564 571 }
565 572 }
566 573 if ( ! is_admin() &&
567 574 isset( $block['blockName'] ) &&
575 + $block['blockName'] === 'core/block' &&
576 + ! empty( $block['attrs']['ref'] )
577 + ) {
578 + // Validate ref_id is a positive integer
579 + $ref_id = absint( $block['attrs']['ref'] );
580 + if ( $ref_id < 1 ) {
581 + return $block_content;
582 + }
583 +
584 + if ( get_post_type( $ref_id ) === 'wp_block' &&
585 + get_post_meta( $ref_id, '_ultp_active', true ) === 'yes'
586 + ) {
587 + do_action(
588 + 'ultp_enqueue_postx_block_css',
589 + array(
590 + 'post_id' => $ref_id,
591 + 'css' => '',
592 + )
593 + );
594 + }
595 + }
596 + if ( ! is_admin() &&
597 + isset( $block['blockName'] ) &&
568 598 strpos( $block['blockName'], 'ultimate-post/' ) === 0
569 599 && ! empty( $block['attrs']['currentPostId'] )
570 600 ) {
571 601 do_action(
@@ -613,11 +643,61 @@
613 643 }
614 644 }
615 645 if ( $css ) {
616 646 ultimate_post()->register_scripts_common();
617 - wp_register_style( "ultp-post-{$post_id}", false );
647 + wp_register_style( "ultp-post-{$post_id}", false, array(), ULTP_VER );
618 648 wp_enqueue_style( "ultp-post-{$post_id}" );
619 649 wp_add_inline_style( "ultp-post-{$post_id}", $css );
650 + }
651 + }
652 + }
653 +
654 + /**
655 + * Enqueue CSS for FSE template parts (header, footer, etc.) that contain PostX blocks.
656 + * Must run during wp_enqueue_scripts (before wp_head) so styles land in <head>.
657 + *
658 + * @since v.4.1.8
659 + * @return void
660 + */
661 + public function handle_fse_template_parts_css() {
662 + $parts = get_posts(
663 + array(
664 + 'post_type' => 'wp_template_part',
665 + 'meta_query' => array( // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query -- Finds the few template parts that use PostX blocks; sites have only a handful of wp_template_part posts.
666 + array(
667 + 'key' => '_ultp_active',
668 + 'value' => 'yes',
669 + ),
670 + ),
671 + 'posts_per_page' => -1,
672 + 'fields' => 'ids',
673 + )
674 + );
675 +
676 + if ( empty( $parts ) ) {
677 + return;
678 + }
679 +
680 + $upload_dir = wp_upload_dir();
681 + $dir = trailingslashit( $upload_dir['basedir'] ) . 'ultimate-post/';
682 +
683 + foreach ( $parts as $part_id ) {
684 + // Validate post ID is numeric
685 + $part_id = absint( $part_id );
686 + if ( $part_id < 1 ) {
687 + continue;
688 + }
689 +
690 + $css_file = $dir . "ultp-css-{$part_id}.css";
691 +
692 + if ( file_exists( $css_file ) ) {
693 + do_action(
694 + 'ultp_enqueue_postx_block_css',
695 + array(
696 + 'post_id' => $part_id,
697 + 'css' => '',
698 + )
699 + );
620 700 }
621 701 }
622 702 }
623 703