| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Plugin Name: Typing Text |
| 5 |
* Description: Make Your Website Interactive With Typing Text Animation |
| 6 |
* Version: 1.2.4 |
| 7 |
* Author: WPDeveloper |
| 8 |
* Author URI: https://wpdeveloper.net |
| 9 |
* License: GPL-3.0-or-later |
| 10 |
* License URI: https://www.gnu.org/licenses/gpl-3.0.html |
| 11 |
* Text Domain: typing-text |
| 12 |
* |
| 13 |
* @package typing-text |
| 14 |
*/ |
| 15 |
|
| 16 |
/** |
| 17 |
* Registers all block assets so that they can be enqueued through the block editor |
| 18 |
* in the corresponding context. |
| 19 |
* |
| 20 |
* @see https://developer.wordpress.org/block-editor/tutorials/block-tutorial/applying-styles-with-stylesheets/ |
| 21 |
*/ |
| 22 |
|
| 23 |
require_once __DIR__ . '/includes/font-loader.php'; |
| 24 |
require_once __DIR__ . '/includes/post-meta.php'; |
| 25 |
require_once __DIR__ . '/includes/helpers.php'; |
| 26 |
require_once __DIR__ . '/lib/style-handler/style-handler.php'; |
| 27 |
|
| 28 |
function create_block_typing_text_block_init() { |
| 29 |
|
| 30 |
define( 'TYPING_TEXT_BLOCKS_VERSION', "1.2.4" ); |
| 31 |
define( 'TYPING_TEXT_BLOCKS_ADMIN_URL', plugin_dir_url( __FILE__ ) ); |
| 32 |
define( 'TYPING_TEXT_BLOCKS_ADMIN_PATH', dirname( __FILE__ ) ); |
| 33 |
|
| 34 |
$script_asset_path = TYPING_TEXT_BLOCKS_ADMIN_PATH . "/dist/index.asset.php"; |
| 35 |
if ( ! file_exists( $script_asset_path ) ) { |
| 36 |
throw new Error( |
| 37 |
'You need to run `npm start` or `npm run build` for the "typing-text/typing-text-block" block first.' |
| 38 |
); |
| 39 |
} |
| 40 |
$index_js = TYPING_TEXT_BLOCKS_ADMIN_URL . 'dist/index.js'; |
| 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 |
'typing-text-blocks-controls-util', |
| 48 |
'essential-blocks-eb-animation' |
| 49 |
] ); |
| 50 |
|
| 51 |
wp_register_script( |
| 52 |
'typing-text-block-editor-js', |
| 53 |
$index_js, |
| 54 |
$all_dependencies, |
| 55 |
$script_asset['version'] |
| 56 |
); |
| 57 |
|
| 58 |
$load_animation_js = TYPING_TEXT_BLOCKS_ADMIN_URL . 'assets/js/eb-animation-load.js'; |
| 59 |
wp_register_script( |
| 60 |
'essential-blocks-eb-animation', |
| 61 |
$load_animation_js, |
| 62 |
[], |
| 63 |
TYPING_TEXT_BLOCKS_VERSION, |
| 64 |
true |
| 65 |
); |
| 66 |
|
| 67 |
$animate_css = TYPING_TEXT_BLOCKS_ADMIN_URL . 'assets/css/animate.min.css'; |
| 68 |
wp_register_style( |
| 69 |
'essential-blocks-animation', |
| 70 |
$animate_css, |
| 71 |
[], |
| 72 |
TYPING_TEXT_BLOCKS_VERSION |
| 73 |
); |
| 74 |
|
| 75 |
$style_css = TYPING_TEXT_BLOCKS_ADMIN_URL . 'dist/style.css'; |
| 76 |
wp_register_style( |
| 77 |
'typing-text-block-frontend-style', |
| 78 |
$style_css, |
| 79 |
["essential-blocks-animation"], |
| 80 |
filemtime( TYPING_TEXT_BLOCKS_ADMIN_PATH . '/dist/style.css' ) |
| 81 |
); |
| 82 |
|
| 83 |
$typed_js = TYPING_TEXT_BLOCKS_ADMIN_URL . 'assets/js/typed.min.js'; |
| 84 |
wp_register_script( |
| 85 |
'typig-text-blocks-typedjs', |
| 86 |
$typed_js, |
| 87 |
["jquery"], |
| 88 |
true |
| 89 |
); |
| 90 |
|
| 91 |
$frontend_js_path = include_once dirname( __FILE__ ) . "/dist/frontend/index.asset.php"; |
| 92 |
$frontend_js = "dist/frontend/index.js"; |
| 93 |
wp_register_script( |
| 94 |
'eb-typing-text-frontend', |
| 95 |
plugins_url( $frontend_js, __FILE__ ), |
| 96 |
array_merge( ["typig-text-blocks-typedjs", "jquery", "essential-blocks-eb-animation"], $frontend_js_path['dependencies'] ), |
| 97 |
$frontend_js_path['version'], |
| 98 |
true |
| 99 |
); |
| 100 |
|
| 101 |
if ( ! WP_Block_Type_Registry::get_instance()->is_registered( 'essential-blocks/typing-text' ) ) { |
| 102 |
register_block_type( |
| 103 |
Typing_Text_Helper::get_block_register_path( 'typing-text/typing-text-block', TYPING_TEXT_BLOCKS_ADMIN_PATH ), |
| 104 |
[ |
| 105 |
'editor_script' => 'typing-text-block-editor-js', |
| 106 |
'style' => 'typing-text-block-frontend-style', |
| 107 |
'script' => 'eb-typing-text-frontend' |
| 108 |
] |
| 109 |
); |
| 110 |
} |
| 111 |
} |
| 112 |
|
| 113 |
add_action( 'init', 'create_block_typing_text_block_init', 99 ); |
| 114 |
|