-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcountdown-pro-block.php
103 lines (90 loc) · 2.82 KB
/
countdown-pro-block.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
/**
* Plugin Name: Countdown Pro for Gutenberg
* Plugin URI: https://plugins.wpali.com
* Author: Ali Khallad
* Author URI: https://wpali.com
* Version: 1.0.1
* Description: The ultimate countdown block for Gutenberg, that help adding countdown functionality to your content easily.
* Text Domain: cpfg
*
* @package CPFG
*/
// If this file is called directly, abort.
if (!defined('WPINC')) {
die;
}
// Only load if Gutenberg is available.
if (!function_exists('register_block_type')) {
return;
}
// Define the plugin's version
define('CPFG_VERSION', '1.0.1');
/**
* Enqueue back end Javascript and CSS on editor level
*
* @since 1.0.0
*/
add_action('enqueue_block_editor_assets', 'cpfg_editor_block_assets');
function cpfg_editor_block_assets()
{
// Define path for the js and css files
$editor_js = '/assets/js/blocks.editor.js';
$editor_css = '/assets/css/editor.css';
// Enqueue the bundled block JS file
wp_enqueue_script(
'cpfg-block-editor-js',
plugins_url($editor_js, __FILE__),
array('wp-i18n', 'wp-element', 'wp-blocks', 'wp-components', 'wp-editor'),
filemtime(plugin_dir_path(__FILE__) . $editor_js)
);
// Enqueue optional editor only styles
wp_enqueue_style(
'cpfg-block-editor-css',
plugins_url($editor_css, __FILE__),
[],
filemtime(plugin_dir_path(__FILE__) . $editor_css)
);
if (function_exists('wp_set_script_translations')) {
wp_set_script_translations('cpfg-block-editor-js', 'cpfg', plugin_dir_path(__FILE__) . 'languages');
}
}
/**
* Enqueue front end and editor Javascript and CSS
*
* @since 1.0.0
*/
add_action('enqueue_block_assets', 'cpfg_block_assets');
function cpfg_block_assets()
{
// Define path for the js and css files
$block_js = '/assets/js/blocks.js';
$block_css = '/assets/css/style-frontend.css';
// Enqueue the bundled block JS file
wp_enqueue_script(
'cpfg-block-js',
plugins_url($block_js, __FILE__),
array('wp-i18n', 'wp-element', 'wp-blocks', 'wp-components', 'wp-api', 'wp-editor'),
filemtime(plugin_dir_path(__FILE__) . $block_js)
);
// Enqueue frontend and editor block styles
wp_enqueue_style(
'cpfg-block-css',
plugins_url($block_css, __FILE__),
null,
filemtime(plugin_dir_path(__FILE__) . $block_css)
);
if (function_exists('wp_set_script_translations')) {
wp_set_script_translations('cpfg-block-js', 'cpfg', plugin_dir_path(__FILE__) . 'languages');
}
}
/**
* Load translation files
*
* @since 1.0.0
*/
add_action('init', 'cpfg_init');
function cpfg_init()
{
load_plugin_textdomain('cpfg', false, plugin_dir_path(__FILE__) . 'languages');
}