| @@ -9,8 +9,9 @@ | ||
| 9 | 9 | use ABlocks\Classes\AssetsGenerator; |
| 10 | 10 | use ABlocks\Classes\RegisterScripts; |
| 11 | 11 | use ABlocks\Classes\GlobalCssGenerator; |
| 12 | 12 | use ABlocks\Classes\GlobalClasses; |
| 13 | +use ABlocks\Classes\AtomicStyles; | |
| 13 | 14 | use ABlocks\Classes\FontLoadLocally; |
| 14 | 15 | use ABlocks\Admin\Menu; |
| 15 | 16 | use ABlocks\Helper; |
| 16 | 17 | |
| @@ -215,8 +216,11 @@ | ||
| 215 | 216 | 'academy_lms' => Helper::is_active_academy(), |
| 216 | 217 | 'storeengine' => Helper::is_active_storeengine(), |
| 217 | 218 | 'wp_map_block' => Helper::is_active_wp_map_block(), |
| 218 | 219 | 'easy_content_manager' => Helper::is_active_easy_content_manager(), |
| 220 | + 'zencommunity' => Helper::is_active_zencommunity(), | |
| 221 | + 'gemboards' => Helper::is_active_gemboards(), | |
| 222 | + 'quizpress' => Helper::is_active_quizpress(), | |
| 219 | 223 | ] |
| 220 | 224 | ); |
| 221 | 225 | return apply_filters( |
| 222 | 226 | 'ablocks/assets/dashboard_scripts_data', |
| @@ -878,12 +882,17 @@ | ||
| 878 | 882 | */ |
| 879 | 883 | public static function build_revision() { |
| 880 | 884 | $stamp = get_option( self::BUILD_OPTION ); |
| 881 | 885 | |
| 886 | + // The compiler's output revision is part of the key, so an emission | |
| 887 | + // change stales every baked page even without a version bump. See | |
| 888 | + // AtomicStyles::OUTPUT_REVISION. | |
| 889 | + $build = ABLOCKS_VERSION . '+' . AtomicStyles::OUTPUT_REVISION; | |
| 890 | + | |
| 882 | 891 | if ( |
| 883 | 892 | is_array( $stamp ) && |
| 884 | 893 | isset( $stamp['version'], $stamp['time'] ) && |
| 885 | - ABLOCKS_VERSION === $stamp['version'] | |
| 894 | + $build === $stamp['version'] | |
| 886 | 895 | ) { |
| 887 | 896 | return (int) $stamp['time']; |
| 888 | 897 | } |
| 889 | 898 | |
| @@ -890,9 +899,9 @@ | ||
| 890 | 899 | $now = time(); |
| 891 | 900 | update_option( |
| 892 | 901 | self::BUILD_OPTION, |
| 893 | 902 | [ |
| 894 | - 'version' => ABLOCKS_VERSION, | |
| 903 | + 'version' => $build, | |
| 895 | 904 | 'time' => $now, |
| 896 | 905 | ], |
| 897 | 906 | true |
| 898 | 907 | ); |
| @@ -902,17 +911,39 @@ | ||
| 902 | 911 | |
| 903 | 912 | public function set_current_page_template_part( $content, $block ) { |
| 904 | 913 | if ( ! isset( $block['blockName'] ) && is_array( $block ) ) { |
| 905 | 914 | foreach ( $block as $block_item ) { |
| 906 | - if ( ! empty( $block_item['blockName'] ) && strpos( $block_item['blockName'], 'ablocks/' ) !== false ) { | |
| 915 | + if ( $this->is_page_asset_block( $block_item ) ) { | |
| 907 | 916 | $this->current_page_blocks[] = $block_item; |
| 908 | 917 | } |
| 909 | 918 | } |
| 910 | 919 | } |
| 911 | - if ( ! empty( $block['blockName'] ) && strpos( $block['blockName'], 'ablocks/' ) !== false ) { | |
| 920 | + if ( $this->is_page_asset_block( $block ) ) { | |
| 912 | 921 | $this->current_page_blocks[] = $block; |
| 913 | 922 | } |
| 914 | 923 | return $content; |
| 924 | + } | |
| 925 | + | |
| 926 | + /** | |
| 927 | + * Whether a top-level block contributes to the page's generated assets. | |
| 928 | + * | |
| 929 | + * A synced pattern counts too: AssetsGenerator::recursive_block_parser() | |
| 930 | + * already expands its reference. Collecting only `ablocks/*` names left a | |
| 931 | + * page whose content is just a pattern with no combined CSS/JS at all — so a | |
| 932 | + * Loop Filter placed from a pattern rendered unstyled and did nothing when | |
| 933 | + * clicked. | |
| 934 | + * | |
| 935 | + * @param mixed $block Parsed block. | |
| 936 | + * @return bool | |
| 937 | + */ | |
| 938 | + private function is_page_asset_block( $block ) { | |
| 939 | + if ( ! is_array( $block ) || empty( $block['blockName'] ) ) { | |
| 940 | + return false; | |
| 941 | + } | |
| 942 | + if ( 'core/block' === $block['blockName'] ) { | |
| 943 | + return ! empty( $block['attrs']['ref'] ); | |
| 944 | + } | |
| 945 | + return strpos( $block['blockName'], 'ablocks/' ) !== false; | |
| 915 | 946 | } |
| 916 | 947 | |
| 917 | 948 | public function set_theme_builder_locations( $args ) { |
| 918 | 949 | $this->theme_builder_locations = $args; |