Changeset 3447696
- Timestamp:
- 01/27/2026 09:52:53 AM (2 months ago)
- Location:
- simple-block-animations/trunk
- Files:
-
- 3 edited
-
includes/class-blocks.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
-
simple-block-animations.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
simple-block-animations/trunk/includes/class-blocks.php
r3447636 r3447696 35 35 } 36 36 37 // Add data attributes for JS 38 $animation_type = $block['attrs']['animationType'] ?? 'fade-in'; 39 $data_attr = sprintf( 37 // Get animation attributes 38 $animation_type = $block['attrs']['animationType'] ?? 'fade-in'; 39 $animation_duration = $block['attrs']['animationDuration'] ?? 0.6; 40 $animation_delay = $block['attrs']['animationDelay'] ?? 0; 41 42 // Build animation class and data attributes 43 $animation_class = 'animate-' . esc_attr( $animation_type ); 44 $data_attr = sprintf( 40 45 ' data-animation="%s"', 41 46 esc_attr( $animation_type ) 42 47 ); 48 49 // Build inline styles for animation 50 $inline_style = sprintf( 51 '--animation-duration:%ss;--animation-delay:%ss;', 52 esc_attr( $animation_duration ), 53 esc_attr( $animation_delay ) 54 ); 43 55 44 // Insert data attribute into opening tag 45 $block_content = preg_replace( 46 '/^(<[a-z][a-z0-9]*)/i', 47 '$1' . $data_attr, 56 // Check if block content has an opening tag 57 if ( empty( trim( $block_content ) ) ) { 58 return $block_content; 59 } 60 61 // Insert class, style, and data attribute into opening tag 62 $block_content = preg_replace_callback( 63 '/^(<[a-z][a-z0-9]*)((?:\s+[^>]*)?)(>)/i', 64 function ( $matches ) use ( $animation_class, $data_attr, $inline_style ) { 65 $tag = $matches[1]; 66 $attributes = $matches[2]; 67 $close = $matches[3]; 68 69 // Add animation class 70 if ( preg_match( '/class=["\']([^"\']*)["\']/', $attributes ) ) { 71 // Class attribute exists, append to it 72 $attributes = preg_replace( 73 '/class=["\']([^"\']*)["\']/', 74 'class="$1 ' . $animation_class . '"', 75 $attributes 76 ); 77 } else { 78 // No class attribute, add it 79 $attributes .= ' class="' . $animation_class . '"'; 80 } 81 82 // Add or append to style attribute 83 if ( preg_match( '/style=["\']([^"\']*)["\']/', $attributes ) ) { 84 // Style attribute exists, append to it 85 $attributes = preg_replace( 86 '/style=["\']([^"\']*)["\']/', 87 'style="$1' . $inline_style . '"', 88 $attributes 89 ); 90 } else { 91 // No style attribute, add it 92 $attributes .= ' style="' . $inline_style . '"'; 93 } 94 95 // Add data attribute 96 $attributes .= $data_attr; 97 98 return $tag . $attributes . $close; 99 }, 48 100 $block_content, 49 101 1 -
simple-block-animations/trunk/readme.txt
r3447674 r3447696 5 5 Tested up to: 6.9 6 6 Requires PHP: 7.4 7 Stable tag: 1. 1.27 Stable tag: 1.2.0 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 71 71 == Changelog == 72 72 73 = 1.2.0 = 74 - Added support for dynamic blocks 75 76 73 77 = 1.1.2 = 74 78 - Added support for all block types -
simple-block-animations/trunk/simple-block-animations.php
r3447674 r3447696 5 5 * Plugin URI: https://github.com/valentin-grenier/simple-animations-for-gutenberg 6 6 * Description: Easily add animations to your Gutenberg blocks without coding. 7 * Version: 1. 1.27 * Version: 1.2.0 8 8 * Requires at least: 9 9 * Requires PHP: … … 22 22 } 23 23 24 define( 'SIMPBLAN_VERSION', '1. 1.2' );24 define( 'SIMPBLAN_VERSION', '1.2.0' ); 25 25 define( 'SIMPBLAN_PATH', plugin_dir_path( __FILE__ ) ); 26 26 define( 'SIMPBLAN_URL', plugin_dir_url( __FILE__ ) );
Note: See TracChangeset
for help on using the changeset viewer.