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

119 lines 3.2 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.2
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 /**
19 * Registers all block assets so that they can be enqueued through the block editor
20 * in the corresponding context.
21 *
22 * @see https://developer.wordpress.org/block-editor/tutorials/block-tutorial/applying-styles-with-stylesheets/
23 */
24
25
26 define('TOGGLE_CONTENT_VERSION', "1.2.2");
27 define('TOGGLE_CONTENT_ADMIN_URL', plugin_dir_url(__FILE__));
28 define('TOGGLE_CONTENT_ADMIN_PATH', dirname(__FILE__));
29
30 require_once __DIR__ . '/includes/font-loader.php';
31 require_once __DIR__ . '/includes/post-meta.php';
32 require_once __DIR__ . '/includes/helpers.php';
33 require_once __DIR__ . '/lib/style-handler/style-handler.php';
34
35 function create_block_toggle_content_block_init()
36 {
37
38 $script_asset_path = TOGGLE_CONTENT_ADMIN_PATH . "/dist/index.asset.php";
39 if (!file_exists($script_asset_path)) {
40 throw new Error(
41 'You need to run `npm start` or `npm run build` for the "toggle-content/toggle-content" block first.'
42 );
43 }
44 $script_asset = require($script_asset_path);
45 $all_dependencies = array_merge($script_asset['dependencies'], array(
46 'wp-blocks',
47 'wp-i18n',
48 'wp-element',
49 'wp-block-editor',
50 'toggle-content-controls-util',
51 'essential-blocks-eb-animation'
52 ));
53
54 $index_js = TOGGLE_CONTENT_ADMIN_URL . 'dist/index.js';
55 wp_register_script(
56 'create-block-toggle-content-block-editor',
57 $index_js,
58 $all_dependencies,
59 $script_asset['version'],
60 true
61 );
62
63 $load_animation_js = TOGGLE_CONTENT_ADMIN_URL . 'assets/js/eb-animation-load.js';
64 wp_register_script(
65 'essential-blocks-eb-animation',
66 $load_animation_js,
67 array(),
68 TOGGLE_CONTENT_VERSION,
69 true
70 );
71
72 $animate_css = TOGGLE_CONTENT_ADMIN_URL . 'assets/css/animate.min.css';
73 wp_register_style(
74 'essential-blocks-animation',
75 $animate_css,
76 array(),
77 TOGGLE_CONTENT_VERSION
78 );
79
80
81 $style_css = TOGGLE_CONTENT_ADMIN_URL . 'dist/style.css';
82 wp_register_style(
83 'create-block-toggle-content-block-editor-css',
84 $style_css,
85 array('essential-blocks-animation'),
86 TOGGLE_CONTENT_VERSION,
87 "all"
88 );
89
90
91 $frontend_js = TOGGLE_CONTENT_ADMIN_URL . 'dist/frontend/index.js';
92 wp_register_script(
93 'essential-blocks-toggle-content-frontend',
94 $frontend_js,
95 array('essential-blocks-eb-animation'),
96 TOGGLE_CONTENT_VERSION,
97 true
98 );
99
100 if (!WP_Block_Type_Registry::get_instance()->is_registered('essential-blocks/countdown')) {
101 register_block_type(
102 Toggle_Content_Helper::get_block_register_path("toggle-content/toggle-content", TOGGLE_CONTENT_ADMIN_PATH),
103 array(
104 'editor_script' => 'create-block-toggle-content-block-editor',
105 'editor_style' => 'create-block-toggle-content-block-editor-css',
106 'render_callback' => function ($attributes, $content) {
107 if (!is_admin()) {
108 wp_enqueue_script('essential-blocks-toggle-content-frontend');
109 wp_enqueue_style('create-block-toggle-content-block-editor-css');
110 }
111 return $content;
112 }
113 )
114 );
115 }
116 }
117
118 add_action('init', 'create_block_toggle_content_block_init', 99);
119