Animations.php
8 months ago
Carousel.php
8 months ago
Counter.php
8 months ago
Gallery.php
8 months ago
Headline.php
8 months ago
InsertPost.php
8 months ago
ProductCategories.php
8 months ago
ReadingTime.php
8 months ago
StickyColumn.php
8 months ago
Testimonials.php
8 months ago
Headline.php
98 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Headline module for FrontBlocks (GenerateBlocks Headline enhancements). |
| 4 | * |
| 5 | * @package FrontBlocks |
| 6 | * @author Alex castellón <castellon@close.technology> |
| 7 | * @copyright 2025 Closemarketing |
| 8 | * @version 1.0.0 |
| 9 | */ |
| 10 | |
| 11 | namespace FrontBlocks\Frontend; |
| 12 | |
| 13 | defined( 'ABSPATH' ) || exit; |
| 14 | |
| 15 | /** |
| 16 | * Headline class. |
| 17 | * |
| 18 | * @since 1.1.0 |
| 19 | */ |
| 20 | class Headline { |
| 21 | /** |
| 22 | * Constructor. |
| 23 | */ |
| 24 | public function __construct() { |
| 25 | add_action( 'init', array( $this, 'register_assets' ) ); |
| 26 | add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_editor_assets' ) ); |
| 27 | add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_frontend_styles' ), 100 ); |
| 28 | add_filter( 'generateblocks_attr_headline', array( $this, 'add_line_class_attribute' ), 10 ); |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * Register block assets for backend editor. |
| 33 | * |
| 34 | * @return void |
| 35 | */ |
| 36 | public function register_assets() { |
| 37 | wp_register_script( |
| 38 | 'frontblocks-headline-editor', |
| 39 | FRBL_PLUGIN_URL . 'assets/headline/frontblocks-headline.js', |
| 40 | array( |
| 41 | 'wp-blocks', |
| 42 | 'wp-element', |
| 43 | 'wp-editor', |
| 44 | 'wp-components', |
| 45 | 'wp-compose', |
| 46 | 'wp-hooks', |
| 47 | 'wp-data', |
| 48 | ), |
| 49 | FRBL_VERSION, |
| 50 | true |
| 51 | ); |
| 52 | |
| 53 | wp_register_style( |
| 54 | 'frontblocks-headline-styles', |
| 55 | FRBL_PLUGIN_URL . 'assets/headline/frontblocks-headline.css', |
| 56 | array(), |
| 57 | FRBL_VERSION |
| 58 | ); |
| 59 | } |
| 60 | /** |
| 61 | * Editor assets |
| 62 | * |
| 63 | * @return void |
| 64 | */ |
| 65 | public function enqueue_editor_assets() { |
| 66 | wp_enqueue_script( 'frontblocks-headline-editor' ); |
| 67 | |
| 68 | // Set script translations for JavaScript. |
| 69 | wp_set_script_translations( |
| 70 | 'frontblocks-headline-editor', |
| 71 | 'frontblocks' |
| 72 | ); |
| 73 | |
| 74 | wp_enqueue_style( 'frontblocks-headline-styles' ); |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Enqueue frontend styles. |
| 79 | * |
| 80 | * @return void |
| 81 | */ |
| 82 | public function enqueue_frontend_styles() { |
| 83 | wp_enqueue_style( 'frontblocks-headline-styles' ); |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * Add line class attribute. |
| 88 | * |
| 89 | * @param array $attributes Attributes values for the block. |
| 90 | * Add line class attribute to headline block. |
| 91 | * |
| 92 | * @return array |
| 93 | */ |
| 94 | public function add_line_class_attribute( $attributes ) { |
| 95 | return $attributes; |
| 96 | } |
| 97 | } |
| 98 |