Plugin Directory

Changeset 3447696


Ignore:
Timestamp:
01/27/2026 09:52:53 AM (2 months ago)
Author:
valentingrenier
Message:

Version 1.2.0 - Minor release

  • Added support for dynamic blocks
Location:
simple-block-animations/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • simple-block-animations/trunk/includes/class-blocks.php

    r3447636 r3447696  
    3535        }
    3636
    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(
    4045            ' data-animation="%s"',
    4146            esc_attr( $animation_type )
    4247        );
     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        );
    4355
    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            },
    48100            $block_content,
    49101            1
  • simple-block-animations/trunk/readme.txt

    r3447674 r3447696  
    55Tested up to: 6.9
    66Requires PHP: 7.4
    7 Stable tag: 1.1.2
     7Stable tag: 1.2.0
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    7171== Changelog ==
    7272
     73= 1.2.0 =
     74- Added support for dynamic blocks
     75
     76
    7377= 1.1.2 =
    7478- Added support for all block types
  • simple-block-animations/trunk/simple-block-animations.php

    r3447674 r3447696  
    55 * Plugin URI: https://github.com/valentin-grenier/simple-animations-for-gutenberg
    66 * Description: Easily add animations to your Gutenberg blocks without coding.
    7  * Version: 1.1.2
     7 * Version: 1.2.0
    88 * Requires at least:
    99 * Requires PHP:
     
    2222}
    2323
    24 define( 'SIMPBLAN_VERSION', '1.1.2' );
     24define( 'SIMPBLAN_VERSION', '1.2.0' );
    2525define( 'SIMPBLAN_PATH', plugin_dir_path( __FILE__ ) );
    2626define( 'SIMPBLAN_URL', plugin_dir_url( __FILE__ ) );
Note: See TracChangeset for help on using the changeset viewer.