-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimeline-module-for-divi.php
134 lines (112 loc) · 5.12 KB
/
timeline-module-for-divi.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
/*
Plugin Name: Timeline Module For Divi
Plugin URI: https://cooltimeline.com/divi
Description: A timeline module for Divi
Version: 1.0.3
Author: CoolPlugins
Author URI: https://coolplugins.net
License: GPL2
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: timeline-module-for-divi
Domain Path: /languages
Timeline Module For Divi is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
any later version.
Timeline Module For Divi is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Timeline Module For Divi. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
define('TMDIVI_V', '1.0.3');
define('TMDIVI_DIR', plugin_dir_path(__FILE__));
define('TMDIVI_URL', plugin_dir_url(__FILE__));
define('TMDIVI_MODULE_URL', plugin_dir_url(__FILE__) . 'includes/modules');
define('TMDIVI_MODULE_DIR', plugin_dir_path(__FILE__) . 'includes/modules');
register_activation_hook( __FILE__, array( 'TMDIVI_Timeline_Module_For_Divi', 'tmdivi_activate_plugin' ) );
class TMDIVI_Timeline_Module_For_Divi {
public function __construct() {
self::includes();
add_action('divi_extensions_init', array($this, 'initialize_extension'));
add_action( 'admin_init', array( $this, 'is_divi_theme_exist' ) );
add_action('wp_loaded', array($this, 'load_child_items'));
add_action( 'wp_enqueue_scripts', array($this,'d5_extension_example_module_enqueue_frontend_scripts') );
}
public function d5_extension_example_module_enqueue_frontend_scripts() {
$plugin_dir_url = TMDIVI_URL;
wp_register_script( 'd5-timeline-line-filling', "{$plugin_dir_url}assets/js/tm_divi_vertical.min.js", array(), '1.0.0' );
wp_enqueue_style( 'd5-timeline-style', "{$plugin_dir_url}styles/style.min.css", array(), '1.0.0' );
}
public function is_divi_theme_exist(){
if (!self::is_theme_activate('Divi')) {
// Divi theme is not activated, display admin notice
add_action('admin_notices', array($this, 'admin_notice_missing_divi_theme'));
}
if ( is_admin() ) {
require_once TMDIVI_DIR . 'admin/feedback/admin-feedback-form.php';
}
}
/**
* Initializes the extension.
*/
public function initialize_extension() {
require_once TMDIVI_DIR . '/includes/TimelineModuleForDivi.php';
}
public static function includes(){
require_once TMDIVI_DIR . '/divi-5/divi-5.php';
new Divi5_Visual_Builder_Assets();
require_once TMDIVI_MODULE_DIR . '/assets-loader.php';
new TMDIVI_AssetsLoader();
}
public static function is_theme_activate($target){
$theme = wp_get_theme();
if ($theme->name == $target || stripos($theme->parent_theme, $target) !== false) {
return true;
}
if (apply_filters('divi_ghoster_ghosted_theme', '') == $target) {
return true;
}
return false;
}
public function admin_notice_missing_divi_theme(){
$message = esc_html__(
'Timeline Module For Divi requires Divi (Theme) to be installed and activated.',
'timeline-module-for-divi'
);
printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', esc_html( $message ) );
deactivate_plugins(__FILE__);
}
public function load_child_items()
{
require_once TMDIVI_MODULE_DIR . '/default-data-helper.php';
if (!function_exists('et_fb_process_shortcode') || !class_exists(TMDIVI_DefaultDataHelper::class)) {
return;
}
$data_helpers = new TMDIVI_DefaultDataHelper();
$this->registerFiltersAndActions($data_helpers);
}
private function registerFiltersAndActions(TMDIVI_DefaultDataHelper $data_helpers)
{
add_filter('et_fb_backend_helpers', [$data_helpers, 'default_items_helpers'], 11);
add_filter('et_fb_get_asset_helpers', [$data_helpers, 'asset_helpers'], 11);
$enqueueScriptsCallback = function () use ($data_helpers) {
wp_localize_script('et-frontend-builder', 'DCLBuilderBackend', $data_helpers->default_items_helpers());
};
add_action('wp_enqueue_scripts', $enqueueScriptsCallback);
add_action('admin_enqueue_scripts', $enqueueScriptsCallback);
}
public static function tmdivi_activate_plugin() {
update_option( 'tmdivi-v', TMDIVI_V );
update_option( 'tmdivi-type', 'free' );
update_option( 'tmdivi-installDate', gmdate( 'Y-m-d h:i:s' ) );
update_option( 'tmdivi-defaultPlugin', true );
if ( ! get_option( 'tmdivi-Boxes-ratingDiv' ) ) {
update_option( 'tmdivi-Boxes-ratingDiv', 'no' ); // Update rating div
}
}
}
new TMDIVI_Timeline_Module_For_Divi();