PluginProbe
Toggle Content / 1.0.1
Toggle Content v1.0.1
trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.8 1.3.0
toggle-content / toggle-content.php

toggle-content.php in Toggle Content 1.0.1, at toggle-content.php

68 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: Toggle Content
4 * Plugin URI: https://essential-blocks.com
5 * Description: Toggle Content block for Gutenberg
6 * Author: WPDeveloper
7 * Author URI: https://wpdeveloper.net
8 * Version: 1.0.1
9 * License: GPL3+
10 * License URI: http://www.gnu.org/licenses/gpl-3.0.txt
11 * Text Domain: toggle-content
12 *
13 * @package toggle-content
14 */
15
16
17 if( ! class_exists('EB_Font_Loader') ) {
18 require_once __DIR__ . '/includes/font-loader.php';
19 }
20 if( ! class_exists('EB_Post_Meta') ) {
21 require_once __DIR__ . '/includes/post-meta.php';
22 }
23
24 function create_block_toggle_content_block_init() {
25 $dir = dirname( __FILE__ );
26
27 $script_asset_path = "$dir/build/index.asset.php";
28 if ( ! file_exists( $script_asset_path ) ) {
29 throw new Error(
30 'You need to run `npm start` or `npm run build` for the "block/toggle-content" block first.'
31 );
32 }
33
34 $index_js = 'build/index.js';
35 $script_asset = require( $script_asset_path );
36 wp_register_script(
37 'create-block-toggle-content-block-editor',
38 plugins_url( $index_js, __FILE__ ),
39 $script_asset['dependencies'],
40 $script_asset['version']
41 );
42
43 $style_css = 'build/style-index.css';
44 wp_register_style(
45 'create-block-toggle-content-block',
46 plugins_url( $style_css, __FILE__ ),
47 array(),
48 filemtime( "$dir/$style_css" )
49 );
50
51 $frontend_js = "src/frontend.js";
52 wp_enqueue_script(
53 'essential-blocks-toggle-content-frontend',
54 plugins_url($frontend_js, __FILE__),
55 array( "jquery","wp-editor"),
56 true
57 );
58
59 if( ! WP_Block_Type_Registry::get_instance()->is_registered( 'essential-blocks/toggle-content' ) ) {
60 register_block_type( 'block/toggle-content', array(
61 'editor_script' => 'create-block-toggle-content-block-editor',
62 'style' => 'create-block-toggle-content-block',
63 ) );
64 }
65 }
66
67 add_action( 'init', 'create_block_toggle_content_block_init' );
68