-
Notifications
You must be signed in to change notification settings - Fork 4
/
extensive-vc.php
260 lines (206 loc) · 7.24 KB
/
extensive-vc.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
<?php
/*
Plugin Name: Extensive VC Pack
Plugin URI: http://wprealize.com/
Author: Nenad Obradovic
Author URI: http://wprealize.com/introduced/
Version: 1.7.7
Description: WordPress plugin which allows you to add unique, flexible and fully responsive shortcodes. It is an addon for premium plugin WPBakery page builder Visual Composer.
Text Domain: extensive-vc
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( ! class_exists( 'Extensive_VC_Addon' ) ) {
class Extensive_VC_Addon {
/**
* Singleton class
*/
private static $instance;
/**
* Get the instance of Extensive_VC_Addon
*
* @return self
*/
public static function getInstance() {
if ( ! ( self::$instance instanceof self ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Cloning disabled
*/
private function __clone() {
}
/**
* Serialization disabled
*/
private function __sleep() {
}
/**
* De-serialization disabled
*/
private function __wakeup() {
}
/**
* Constructor
*/
private function __construct() {
include_once 'constants.php';
// Plugin activation hook
register_activation_hook( __FILE__, array( $this, 'initActivationHook' ) );
// Plugin init hook
add_action( 'plugins_loaded', array( $this, 'init' ) );
}
/**
* Init hooks on plugin activation
*/
function initActivationHook() {
if ( ! is_network_admin() ) {
set_transient( '_extensive_vc_admin_about_page_redirect', 1, 30 );
}
}
/**
* Init plugin
*/
function init() {
include_once 'load.php';
add_action( 'init', array( $this, 'setTextDomain' ) );
add_action( 'wp_enqueue_scripts', array( $this, 'enqueueStyles' ) );
add_action( 'wp_enqueue_scripts', array( $this, 'enqueueInlineStyles' ) );
add_action( 'admin_init', array( $this, 'enqueueAdminScripts' ) );
add_filter( 'plugin_action_links', array( $this, 'setPluginActionLinks' ), 10, 2 );
if ( ( is_multisite() && is_network_admin() ) || ! is_multisite() ) {
add_action( 'admin_init', array( $this, 'initAdminNotice' ) );
}
}
/**
* Register plugin text domain
*/
function setTextDomain() {
load_plugin_textdomain( 'extensive-vc', false, EXTENSIVE_VC_REL_PATH . '/languages' );
}
/**
* Enqueue plugin scripts
*/
function enqueueStyles() {
$evc_options = extensive_vc_get_global_options();
// Hook to enqueue additional scripts before main css
do_action( 'extensive_vc_enqueue_additional_scripts_before_main_css' );
// Enqueue main plugin css
wp_enqueue_style( 'extensive-vc-main-style', EXTENSIVE_VC_ASSETS_URL_PATH . '/css/main.min.css' );
// Enqueue ion icons font pack css
$is_icon_font_disabled = $evc_options->options->getOptionValueById( 'evc_disable_ionicons_font' );
if ( $is_icon_font_disabled !== 'yes' ) {
wp_enqueue_style( 'ionicons', EXTENSIVE_VC_ASSETS_URL_PATH . '/css/ion-icons/css/ionicons.min.css' );
}
// Enqueue core jquery script and 3rd part libraries
wp_enqueue_script( 'appear', EXTENSIVE_VC_ASSETS_URL_PATH . '/plugins/appear/jquery.appear.js', array( 'jquery' ), false, true );
// Hook to enqueue additional scripts before main js
do_action( 'extensive_vc_enqueue_additional_scripts_before_main_js' );
// Enqueue main plugin js
wp_enqueue_script( 'extensive-vc-main-script', EXTENSIVE_VC_ASSETS_URL_PATH . '/js/main.min.js', array( 'jquery' ), false, true );
// Extend main plugin js with additional variables
$evc_global_variables = array(
'adminAjaxUrl' => esc_url( admin_url( 'admin-ajax.php' ) ),
'sliderNavPrevArrow' => 'ion-ios-arrow-left',
'sliderNavNextArrow' => 'ion-ios-arrow-right'
);
$evc_global_variables = apply_filters( 'extensive_vc_filter_main_js_global_variables', $evc_global_variables );
wp_localize_script( 'extensive-vc-main-script', 'evcVars', array(
'global' => $evc_global_variables
) );
// Hook to enqueue additional scripts
do_action( 'extensive_vc_enqueue_additional_scripts' );
}
/**
* Print custom css style
*/
function enqueueInlineStyles() {
// Hook to add custom inline css style after main css
$style = apply_filters( 'extensive_vc_filter_main_custom_style', $style = '' );
if ( ! empty( $style ) ) {
wp_add_inline_style( 'extensive-vc-main-style', $style );
}
}
/**
* Enqueue plugin scripts for admin panel
*/
function enqueueAdminScripts() {
// Enqueue color picker plugin css and js files
wp_enqueue_style( 'wp-color-picker' );
wp_enqueue_script( 'wp-color-picker' );
// Enqueue main plugin admin css
wp_enqueue_style( 'extensive-vc-main-admin-style', EXTENSIVE_VC_ASSETS_URL_PATH . '/css/admin/main-admin.min.css' );
// Enqueue main plugin admin js
wp_enqueue_script( 'extensive-vc-main-admin-script', EXTENSIVE_VC_ASSETS_URL_PATH . '/js/admin/main-admin.js', array( 'jquery' ), false, true );
// Hook to enqueue additional scripts for admin panel
do_action( 'extensive_vc_enqueue_additional_admin_scripts' );
}
/**
* Add Settings link in plugin's page
*
* @param array $links
* @param string $file - path of main plugin file
*
* @return array
*/
public function setPluginActionLinks( $links, $file ) {
if ( plugin_basename( __FILE__ ) === $file ) {
$title = esc_html__( 'Extensive VC Settings', 'extensive-vc' );
$url = add_query_arg( array( 'page' => 'evc-admin-options-page' ), admin_url( 'admin.php' ) );
$label = esc_html__( 'Settings', 'extensive-vc' );
$link = '<a title="' . esc_attr( $title ) . '" href="' . esc_url( $url ) . '">' . $label . '</a>';
array_unshift( $links, $link );
}
return $links;
}
/**
* Display admin notices
*/
function initAdminNotice() {
if ( ! extensive_vc_is_visual_composer_installed() ) {
add_action( 'admin_notices', array( $this, 'adminNoticeWhenVisualComposerNotInstalled' ) );
}
}
/**
* Display admin notice error if Visual Composer plugin not installed
*
* @return html/string
*/
function adminNoticeWhenVisualComposerNotInstalled() {
echo sprintf( '<div class="notice notice-error evc-admin-notice evc-notice-vc-not-installed"><p>%s<strong>%s</strong>%s</p></div>',
esc_html__( 'The', 'extensive-vc' ),
esc_html__( ' Extensive Addons', 'extensive-vc' ),
esc_html__( ' plugin requires WPBakery page builder (formerly Visual Composer) plugin. Please installed/activated it.', 'extensive-vc' )
);
if ( function_exists( 'deactivate_plugins' ) ) {
deactivate_plugins( plugin_basename( __FILE__ ) );
}
}
}
}
Extensive_VC_Addon::getInstance();
if ( ! function_exists( 'extensive_vc_is_visual_composer_installed' ) ) {
/**
* Checks if WPBakery page builder plugin installed
*
* @return boolean
*/
function extensive_vc_is_visual_composer_installed() {
return class_exists( 'WPBakeryVisualComposerAbstract' );
}
}
if ( ! function_exists( 'extensive_vc_is_evc_installed' ) ) {
/**
* Checks if our plugin installed
*
* @return boolean
*/
function extensive_vc_is_evc_installed() {
return class_exists( 'Extensive_VC_Addon' );
}
}