PluginProbe
Toggle Content / 1.2.8
Toggle Content v1.2.8
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.2.8, at toggle-content.php

114 lines 3.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Plugin Name: Toggle Content
5 * Plugin URI: https://essential-blocks.com
6 * Description: Toggle Content block for Gutenberg
7 * Author: WPDeveloper
8 * Author URI: https://wpdeveloper.net
9 * Version: 1.2.8
10 * License: GPL3+
11 * License URI: http://www.gnu.org/licenses/gpl-3.0.txt
12 * Text Domain: toggle-content
13 *
14 * @package toggle-content
15 */
16
17 /**
18 * Registers all block assets so that they can be enqueued through the block editor
19 * in the corresponding context.
20 *
21 * @see https://developer.wordpress.org/block-editor/tutorials/block-tutorial/applying-styles-with-stylesheets/
22 */
23
24 define( 'TOGGLE_CONTENT_VERSION', "1.2.8" );
25 define( 'TOGGLE_CONTENT_ADMIN_URL', plugin_dir_url( __FILE__ ) );
26 define( 'TOGGLE_CONTENT_ADMIN_PATH', dirname( __FILE__ ) );
27
28 require_once __DIR__ . '/includes/font-loader.php';
29 require_once __DIR__ . '/includes/post-meta.php';
30 require_once __DIR__ . '/includes/helpers.php';
31 require_once __DIR__ . '/lib/style-handler/style-handler.php';
32
33 function create_block_toggle_content_block_init() {
34
35 $script_asset_path = TOGGLE_CONTENT_ADMIN_PATH . "/dist/index.asset.php";
36 if ( ! file_exists( $script_asset_path ) ) {
37 throw new Error(
38 'You need to run `npm start` or `npm run build` for the "toggle-content/toggle-content" block first.'
39 );
40 }
41 $script_asset = require $script_asset_path;
42 $all_dependencies = array_merge( $script_asset['dependencies'], [
43 'wp-blocks',
44 'wp-i18n',
45 'wp-element',
46 'wp-block-editor',
47 'toggle-content-controls-util',
48 'essential-blocks-eb-animation'
49 ] );
50
51 $index_js = TOGGLE_CONTENT_ADMIN_URL . 'dist/index.js';
52 wp_register_script(
53 'create-block-toggle-content-block-editor',
54 $index_js,
55 $all_dependencies,
56 $script_asset['version'],
57 true
58 );
59
60 $load_animation_js = TOGGLE_CONTENT_ADMIN_URL . 'assets/js/eb-animation-load.js';
61 wp_register_script(
62 'essential-blocks-eb-animation',
63 $load_animation_js,
64 [],
65 TOGGLE_CONTENT_VERSION,
66 true
67 );
68
69 $animate_css = TOGGLE_CONTENT_ADMIN_URL . 'assets/css/animate.min.css';
70 wp_register_style(
71 'essential-blocks-animation',
72 $animate_css,
73 [],
74 TOGGLE_CONTENT_VERSION
75 );
76
77 $style_css = TOGGLE_CONTENT_ADMIN_URL . 'dist/style.css';
78 wp_register_style(
79 'create-block-toggle-content-block-editor-css',
80 $style_css,
81 [ 'essential-blocks-animation' ],
82 TOGGLE_CONTENT_VERSION,
83 "all"
84 );
85
86 $frontend_js = TOGGLE_CONTENT_ADMIN_URL . 'dist/frontend/index.js';
87 wp_register_script(
88 'essential-blocks-toggle-content-frontend',
89 $frontend_js,
90 [ 'essential-blocks-eb-animation' ],
91 TOGGLE_CONTENT_VERSION,
92 true
93 );
94
95 if ( ! WP_Block_Type_Registry::get_instance()->is_registered( 'essential-blocks/countdown' ) ) {
96 register_block_type(
97 Toggle_Content_Helper::get_block_register_path( "toggle-content/toggle-content", TOGGLE_CONTENT_ADMIN_PATH ),
98 [
99 'editor_script' => 'create-block-toggle-content-block-editor',
100 'editor_style' => 'create-block-toggle-content-block-editor-css',
101 'render_callback' => function ( $attributes, $content ) {
102 if ( ! is_admin() ) {
103 wp_enqueue_script( 'essential-blocks-toggle-content-frontend' );
104 wp_enqueue_style( 'create-block-toggle-content-block-editor-css' );
105 }
106 return $content;
107 }
108 ]
109 );
110 }
111 }
112
113 add_action( 'init', 'create_block_toggle_content_block_init', 99 );
114