PluginProbe
Button Block – Stylish buttons that get more clicks / 1.0.3
Button Block – Stylish buttons that get more clicks v1.0.3
1.2.6 1.2.5 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 All 28 releases
button-block / index.php

index.php in Button Block – Stylish buttons that get more clicks 1.0.3, at index.php

59 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Button Block
4 * Description: Implement multi-functional button
5 * Version: 1.0.3
6 * Author: bPlugins LLC
7 * Author URI: http://bplugins.com
8 * License: GPLv3
9 * License URI: https://www.gnu.org/licenses/gpl-3.0.txt
10 * Text Domain: button-block
11 */
12
13 // ABS PATH
14 if ( !defined( 'ABSPATH' ) ) { exit; }
15
16 // Constant
17 define( 'BTN_PLUGIN_VERSION', isset( $_SERVER['HTTP_HOST'] ) && 'localhost' === $_SERVER['HTTP_HOST'] ? time() : '1.0.3' );
18 define( 'BTN_ASSETS_DIR', plugin_dir_url( __FILE__ ) . 'assets/' );
19
20 // Button Block
21 class BTNButtonBlock{
22 function __construct(){
23 add_action( 'init', [$this, 'onInit'] );
24 add_action( 'enqueue_block_assets', [$this, 'enqueueBlockAssets'] );
25 }
26
27 function enqueueBlockAssets(){
28 wp_enqueue_style( 'fontAwesome', BTN_ASSETS_DIR . 'css/fontAwesome.min.css', [], '5.15.4' );
29 wp_enqueue_style( 'aos', BTN_ASSETS_DIR . 'css/aos.css', [], '3.0.0' );
30
31 wp_enqueue_script( 'aos', BTN_ASSETS_DIR . 'js/aos.js', [], '3.0.0', true );
32 }
33
34 function onInit() {
35 wp_register_style( 'btn-button-editor-style', plugins_url( 'dist/editor.css', __FILE__ ), [ 'wp-edit-blocks' ], BTN_PLUGIN_VERSION ); // Backend Style
36 wp_register_style( 'btn-button-style', plugins_url( 'dist/style.css', __FILE__ ), [], BTN_PLUGIN_VERSION ); // Frontend Style
37
38 register_block_type( __DIR__, [
39 'editor_style' => 'btn-button-editor-style',
40 'style' => 'btn-button-style',
41 'render_callback' => [$this, 'render']
42 ] ); // Register Block
43
44 wp_set_script_translations( 'btn-button-editor-script', 'button-block', plugin_dir_path( __FILE__ ) . 'languages' ); // Translate
45 }
46
47 function render( $attributes ){
48 extract( $attributes );
49
50 $className = $className ?? '';
51 $btnBlockClassName = 'wp-block-btn-button ' . $className . ' align' . $align;
52
53 ob_start(); ?>
54 <div class='<?php echo esc_attr( $btnBlockClassName ); ?>' id='btnButton-<?php echo esc_attr( $cId ) ?>' data-attributes='<?php echo esc_attr( wp_json_encode( $attributes ) ); ?>'></div>
55
56 <?php return ob_get_clean();
57 } // Render
58 }
59 new BTNButtonBlock;