PluginProbe
Chart Block – Visualize Data with Bar, Line, Pie Charts / 1.1.3
Chart Block – Visualize Data with Bar, Line, Pie Charts v1.1.3
1.2.0 1.1.9 1.1.8 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7
chart-block / plugin.php

plugin.php in Chart Block – Visualize Data with Bar, Line, Pie Charts 1.1.3, at plugin.php

51 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Chart Block
4 * Description: Represent your data by symbols, such as bars, lines, or pie charts.
5 * Version: 1.1.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: chart-block
11 */
12
13 // ABS PATH
14 if ( !defined( 'ABSPATH' ) ) { exit; }
15
16 // Constant
17 define( 'BCHART_PLUGIN_VERSION', 'localhost' === $_SERVER['HTTP_HOST'] ? time() : '1.1.3' );
18 define( 'BCHART_ASSETS_DIR', plugin_dir_url( __FILE__ ) . 'assets/' );
19
20 // Chart Block
21 class BChartBlock{
22 function __construct(){
23 add_action( 'enqueue_block_assets', [$this, 'enqueueBlockAssets'] );
24 add_action( 'init', [$this, 'onInit'] );
25 }
26
27 function enqueueBlockAssets(){ wp_enqueue_script( 'chartJS', BCHART_ASSETS_DIR . 'js/chart.min.js', [], '3.5.1', true ); }
28
29 function onInit() {
30 wp_register_style( 'b-chart-chart-editor-style', plugins_url( 'dist/editor.css', __FILE__ ), [ 'wp-edit-blocks' ], BCHART_PLUGIN_VERSION ); // Backend Style
31 wp_register_style( 'b-chart-chart-style', plugins_url( 'dist/style.css', __FILE__ ), [ 'wp-editor' ], BCHART_PLUGIN_VERSION ); // Frontend Style
32
33 register_block_type( __DIR__, [
34 'editor_style' => 'b-chart-chart-editor-style',
35 'style' => 'b-chart-chart-style',
36 'render_callback' => [$this, 'render']
37 ] ); // Register Block
38
39 wp_set_script_translations( 'b-chart-chart-editor-script', 'chart-block', plugin_dir_path( __FILE__ ) . 'languages' ); // Translate
40 }
41
42 function render( $attributes ){
43 extract( $attributes );
44
45 ob_start(); ?>
46 <div class='wp-block-b-chart-chart <?php echo 'align' . esc_attr( $align ); ?>' id='bChart-<?php echo esc_attr( $cId ) ?>' data-attributes='<?php echo esc_attr( wp_json_encode( $attributes ) ); ?>'></div>
47
48 <?php return ob_get_clean();
49 } // Render
50 }
51 new BChartBlock;