PluginProbe
Toggle Content / 1.0.2
Toggle Content v1.0.2
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.2, at toggle-content.php

64 lines 1.7 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.2
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 require_once __DIR__ . '/includes/font-loader.php';
18 require_once __DIR__ . '/includes/post-meta.php';
19
20 function create_block_toggle_content_block_init() {
21 $dir = dirname( __FILE__ );
22
23 $script_asset_path = "$dir/build/index.asset.php";
24 if ( ! file_exists( $script_asset_path ) ) {
25 throw new Error(
26 'You need to run `npm start` or `npm run build` for the "block/toggle-content" block first.'
27 );
28 }
29
30 $index_js = 'build/index.js';
31 $script_asset = require( $script_asset_path );
32 wp_register_script(
33 'create-block-toggle-content-block-editor',
34 plugins_url( $index_js, __FILE__ ),
35 $script_asset['dependencies'],
36 $script_asset['version']
37 );
38
39 $style_css = 'build/style-index.css';
40 wp_register_style(
41 'create-block-toggle-content-block',
42 plugins_url( $style_css, __FILE__ ),
43 array(),
44 filemtime( "$dir/$style_css" )
45 );
46
47 $frontend_js = "src/frontend.js";
48 wp_enqueue_script(
49 'essential-blocks-toggle-content-frontend',
50 plugins_url($frontend_js, __FILE__),
51 array( "jquery","wp-editor"),
52 true
53 );
54
55 if( ! WP_Block_Type_Registry::get_instance()->is_registered( 'essential-blocks/toggle-content' ) ) {
56 register_block_type( 'block/toggle-content', array(
57 'editor_script' => 'create-block-toggle-content-block-editor',
58 'style' => 'create-block-toggle-content-block',
59 ) );
60 }
61 }
62
63 add_action( 'init', 'create_block_toggle_content_block_init' );
64