PluginProbe
Events Block / 1.0.8
Events Block v1.0.8
1.0.9 trunk 1.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.5.1 1.0.5.2 1.0.6 1.0.7 1.0.8
events-block / events-block.php

events-block.php in Events Block 1.0.8, at events-block.php

88 lines 3.5 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: Events Block
5 * Description: Events Gutenberg Block to Create Events Grid In Block Editor.
6 * Author: Cool Plugins
7 * Author URI: https://coolplugins.net/
8 * Version: 1.0.8
9 * License: GPLv2 or later
10 * Text Domain: events-block
11 */
12 defined('ABSPATH') || exit;
13 define('EVENTS_BLOCK_VERSION', '1.0.8');
14 define('EVENTS_BLOCK_FILE', __FILE__);
15 define('EVENTS_BLOCK_PATH', plugin_dir_path(__FILE__));
16 define('EVENTS_BLOCK_URL', plugin_dir_url(__FILE__));
17 define('EVENTS_BLOCK_FEEDBACK_API', 'https://feedback.coolplugins.net/');
18
19
20
21 final class EVTB_Events_Block
22 {
23 private static $instance = null;
24 public static function get_instance()
25 {
26 if (! isset(self::$instance)) self::$instance = new self();
27 return self::$instance;
28 }
29 private function __construct()
30 {
31
32 register_activation_hook(EVENTS_BLOCK_FILE, array($this, 'evtb_plugin_activate'));
33 add_action('init', array($this, 'init'));
34 add_action('enqueue_block_editor_assets', array($this, 'editor_assets'));
35 add_action('wp_enqueue_scripts', array($this, 'frontend_assets'));
36 add_action('plugins_loaded', array($this, 'evtb_load_admin_files'));
37 }
38 /**
39 * Plugin Activation Hook
40 * Saves plugin version and install dates
41 */
42 public function evtb_plugin_activate()
43 {
44
45 update_option('evtb_version', EVENTS_BLOCK_VERSION);
46 update_option('evtb_activation_time', gmdate('Y-m-d h:i:s'));
47 update_option('evtb_ratingDiv', 'no');
48
49 if (!get_option('evtb_initial_save_version')) {
50 add_option('evtb_initial_save_version', EVENTS_BLOCK_VERSION);
51 }
52 if (!get_option('evtb_install_date')) {
53 add_option('evtb_install_date', gmdate('Y-m-d h:i:s'));
54 }
55 }
56
57 public function init()
58 {
59 $asset = file_exists(EVENTS_BLOCK_PATH . 'build/index.asset.php') ? require EVENTS_BLOCK_PATH . 'build/index.asset.php' : array('dependencies' => array(), 'version' => EVENTS_BLOCK_VERSION);
60 wp_register_script('evtb-events-blocks', EVENTS_BLOCK_URL . 'build/index.js', $asset['dependencies'], $asset['version'], true);
61 wp_localize_script('evtb-events-blocks', 'evtbPluginData', array('pluginUrl' => EVENTS_BLOCK_URL, 'images' => array('crazyDJ' => EVENTS_BLOCK_URL . 'assets/images/crazy-DJ-experience-santa-cruz.webp', 'rockBand' => EVENTS_BLOCK_URL . 'assets/images/cute-girls-rock-band-performance.webp', 'foodDistribution' => EVENTS_BLOCK_URL . 'assets/images/free-food-distribution-at-mumbai.webp')));
62 wp_register_style('evtb-events-editor', EVENTS_BLOCK_URL . 'editor.css', array(), EVENTS_BLOCK_VERSION);
63 wp_register_style('evtb-events-style', EVENTS_BLOCK_URL . 'style.css', array(), EVENTS_BLOCK_VERSION);
64 if (is_dir(EVENTS_BLOCK_PATH . 'blocks/')) {
65 foreach (glob(EVENTS_BLOCK_PATH . 'blocks/*/block.json') as $block) register_block_type(dirname($block));
66 }
67 }
68 public function editor_assets()
69 {
70 wp_enqueue_style('evtb-icons', EVENTS_BLOCK_URL . 'assets/css/evtb-icons.css', array(), EVENTS_BLOCK_VERSION);
71 }
72 public function frontend_assets()
73 {
74 wp_enqueue_style('evtb-icons', EVENTS_BLOCK_URL . 'assets/css/evtb-icons.css', array(), EVENTS_BLOCK_VERSION);
75 wp_enqueue_script('evtb-frontend', EVENTS_BLOCK_URL . 'assets/js/frontend.js', array(), EVENTS_BLOCK_VERSION, true);
76 }
77
78 public function evtb_load_admin_files() {
79 if (is_admin()) {
80 require_once EVENTS_BLOCK_PATH . 'admin/feedback/admin-feedback-form.php';
81 require_once EVENTS_BLOCK_PATH . 'admin/feedback-notice/evtb-feedback-notice.php';
82
83 new evtbFeedbackNotice();
84 }
85 }
86 }
87 EVTB_Events_Block::get_instance();
88