| @@ -751,8 +751,9 @@ | ||
| 751 | 751 | 'supports' => [ |
| 752 | 752 | 'cbb' => true, |
| 753 | 753 | 'layout' => true, |
| 754 | 754 | 'migrateClass' => ! empty( $args['migrateClass'] ) ? ( isset( $args['id'] ) ? 'wp-block-boldblocks-custom' : 'wp-block-boldblocks-custom-parent' ) : '', |
| 755 | + 'CSSClasses' => $args['className'] ?? '', | |
| 755 | 756 | ], |
| 756 | 757 | 'uses_context' => [ 'postId', 'postType', 'cbb/block-overrides' ], |
| 757 | 758 | ]; |
| 758 | 759 | |
| @@ -1403,9 +1404,9 @@ | ||
| 1403 | 1404 | } |
| 1404 | 1405 | |
| 1405 | 1406 | $block_name = sprintf( 'boldblocks/%s', $this->sanitize_block_name( $item->post_name ) ); |
| 1406 | 1407 | $block_version = get_post_meta( $item->ID, 'boldblocks_block_version', true ); |
| 1407 | - $migrateClass = version_compare( $block_version, '2.7.14', '<=' ); | |
| 1408 | + $migrate_class = version_compare( $block_version, '2.7.14', '<=' ); | |
| 1408 | 1409 | |
| 1409 | 1410 | $block_args = [ |
| 1410 | 1411 | 'id' => $item->ID, |
| 1411 | 1412 | 'name' => $block_name, |
| @@ -1422,9 +1423,9 @@ | ||
| 1422 | 1423 | 'enableCustomAttributes' => (bool) get_post_meta( $item->ID, 'boldblocks_enable_custom_attributes', true ), |
| 1423 | 1424 | ], |
| 1424 | 1425 | 'enableVariationPicker' => (bool) get_post_meta( $item->ID, 'boldblocks_enable_variation_picker', true ), |
| 1425 | 1426 | 'blockVersion' => $block_version, |
| 1426 | - 'migrateClass' => $migrateClass, | |
| 1427 | + 'migrateClass' => $migrate_class, | |
| 1427 | 1428 | 'dependentBlocks' => get_post_meta( $item->ID, 'boldblocks_block_dependent_blocks', true ), |
| 1428 | 1429 | 'hideOnFrontend' => $hide_on_frontend, |
| 1429 | 1430 | 'isTransformable' => $is_transformable, |
| 1430 | 1431 | 'isHidden' => $is_hidden, |
| @@ -1468,9 +1469,9 @@ | ||
| 1468 | 1469 | 'custom_styles' => $this->refine_custom_scripts( $block_custom_styles, 'CSS', $parent_block_name, $block_name ), |
| 1469 | 1470 | 'hideOnFrontend' => $hide_on_frontend, |
| 1470 | 1471 | 'blockParent' => $block_parent, |
| 1471 | 1472 | 'blockAncestor' => $block_ancestor, |
| 1472 | - 'migrateClass' => $migrateClass, | |
| 1473 | + 'migrateClass' => $migrate_class, | |
| 1473 | 1474 | |
| 1474 | 1475 | ]; |
| 1475 | 1476 | |
| 1476 | 1477 | if ( $keywords ) { |
| @@ -1845,9 +1846,9 @@ | ||
| 1845 | 1846 | } |
| 1846 | 1847 | |
| 1847 | 1848 | if ( $block_instance->block_type->supports['cbb'] ?? false ) { |
| 1848 | 1849 | $GLOBALS['boldblocks_frontend_loaded'] = true; |
| 1849 | - } elseif ( $this->is_enqueue_frontend_script_for_non_cbb_blocks( $block, $block_instance ) ) { | |
| 1850 | + } elseif ( $this->is_enqueue_frontend_script_for_animations( $block ) || $this->is_enqueue_frontend_script_for_sticky_blocks( $block ) ) { | |
| 1850 | 1851 | wp_enqueue_script( $this->custom_blocks_frontend_handle ); |
| 1851 | 1852 | wp_enqueue_style( $this->custom_blocks_handle ); |
| 1852 | 1853 | |
| 1853 | 1854 | $GLOBALS['boldblocks_frontend_loaded'] = true; |
| @@ -1856,15 +1857,14 @@ | ||
| 1856 | 1857 | return $block_content; |
| 1857 | 1858 | } |
| 1858 | 1859 | |
| 1859 | 1860 | /** |
| 1860 | - * Whether to load the frontend scripts for non-cbb blocks. | |
| 1861 | + * Whether to load the frontend scripts for non-cbb sticky blocks. | |
| 1861 | 1862 | * |
| 1862 | - * @param array $block | |
| 1863 | - * @param WP_Block $block_instance | |
| 1863 | + * @param array $block | |
| 1864 | 1864 | * @return boolean |
| 1865 | 1865 | */ |
| 1866 | - private function is_enqueue_frontend_script_for_non_cbb_blocks( $block, $block_instance ) { | |
| 1866 | + private function is_enqueue_frontend_script_for_sticky_blocks( $block ) { | |
| 1867 | 1867 | $block_names = $this->the_plugin_instance->get_component( CustomStyle::class )->non_cbb_blocks; |
| 1868 | 1868 | if ( ! in_array( $block['blockName'] ?? '', $block_names, true ) ) { |
| 1869 | 1869 | return false; |
| 1870 | 1870 | } |
| @@ -1874,8 +1874,18 @@ | ||
| 1874 | 1874 | return true; |
| 1875 | 1875 | } |
| 1876 | 1876 | |
| 1877 | 1877 | return false; |
| 1878 | + } | |
| 1879 | + | |
| 1880 | + /** | |
| 1881 | + * Whether to load the frontend scripts for non-cbb animation blocks. | |
| 1882 | + * | |
| 1883 | + * @param array $block | |
| 1884 | + * @return boolean | |
| 1885 | + */ | |
| 1886 | + private function is_enqueue_frontend_script_for_animations( $block ) { | |
| 1887 | + return ! empty( $block['attrs']['boldblocks']['animations'] ) && in_array( $block['blockName'] ?? '', $this->get_animated_blocks(), true ); | |
| 1878 | 1888 | } |
| 1879 | 1889 | |
| 1880 | 1890 | /** |
| 1881 | 1891 | * Enqueue frontend scripts for carousel layout in the query loop block |