-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevents-calendar-templates.php
372 lines (319 loc) · 14.2 KB
/
events-calendar-templates.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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
<?php
/*
Plugin Name:Events Shortcodes For The Events Calendar
Plugin URI:https://eventscalendaraddons.com/plugin/events-shortcodes-pro/?utm_source=ect_plugin&utm_medium=inside&utm_campaign=get_pro&utm_content=plugin_uri
Description:<a href="http://wordpress.org/plugins/the-events-calendar/">📅 The Events Calendar Addon</a> - Shortcodes to show The Events Calendar plugin events list on any page or post in different layouts.
Version:2.3.1
Requires at least: 4.5
Tested up to:6.2
Requires PHP:5.6
Stable tag:trunk
Author:Cool Plugins
Author URI:https://coolplugins.net/about-us/?utm_source=ect_plugin&utm_medium=inside&utm_campaign=coolplugins&utm_content=author_uri
License URI:https://www.gnu.org/licenses/gpl-2.0.html
Domain Path: /languages
Text Domain:ect
*/
if ( ! defined( 'ABSPATH' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
if ( ! defined( 'ECT_VERSION' ) ) {
define( 'ECT_VERSION', '2.3.1' );
}
/*** Defined constent for later use */
define( 'ECT_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
define( 'ECT_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
/*** EventsCalendarTemplates main class by CoolPlugins.net */
if ( ! class_exists( 'EventsCalendarTemplates' ) ) {
final class EventsCalendarTemplates {
/**
* The unique instance of the plugin.
*/
private static $instance;
/**
* Gets an instance of our plugin.
*/
public static function get_instance() {
if ( null === self::$instance ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Constructor.
*/
private function __construct() {
}
// register all hooks
public function registers() {
/*** Installation and uninstallation hooks */
register_activation_hook( __FILE__, array( 'EventsCalendarTemplates', 'activate' ) );
register_deactivation_hook( __FILE__, array( 'EventsCalendarTemplates', 'deactivate' ) );
add_action( 'admin_init', array( self::$instance, 'ect_settings_migration' ) );
add_action( 'admin_init', array( self::$instance, 'onInit' ) );
/*** Check The Event Calendar is installed or not */
add_action( 'plugins_loaded', array( self::$instance, 'ect_check_event_calender_installed' ) );
/*** Load required files */
add_action( 'plugins_loaded', array( self::$instance, 'ect_load_files' ) );
add_action( 'admin_enqueue_scripts', array( self::$instance, 'ect_tc_css' ) );
/*** Template Setting Page Link */
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( self::$instance, 'ect_template_settings_page' ) );
add_action( 'plugin_row_meta', array( self::$instance, 'ect_addMeta_Links' ), 10, 2 );
foreach ( array( 'post.php', 'post-new.php' ) as $hook ) {
add_action( "admin_head-$hook", array( self::$instance, 'ect_rest_url' ) );
}
/*** Include Gutenberg Block */
require_once ECT_PLUGIN_DIR . 'admin/gutenberg-block/ect-block.php';
/***Include Share Buttons*/
require_once ECT_PLUGIN_DIR . '/includes/ect-share-functions.php';
}
/*** Load required files */
public function ect_load_files() {
load_plugin_textdomain( 'ect', false, basename( dirname( __FILE__ ) ) . '/languages/' );
if ( class_exists( 'Tribe__Events__Main' ) or defined( 'Tribe__Events__Main::VERSION' ) ) {
if ( defined( 'WPB_VC_VERSION' ) ) {
require_once ECT_PLUGIN_DIR . 'admin/visual-composer/ect-class-vc.php';
}
}
if ( is_admin() ) {
/*** Plugin review notice file */
require_once ECT_PLUGIN_DIR . '/admin/notices/admin-notices.php';
require_once ECT_PLUGIN_DIR . 'admin/feedback/admin-feedback-form.php';
require_once __DIR__ . '/admin/events-addon-page/events-addon-page.php';
cool_plugins_events_addon_settings_page( 'the-events-calendar', 'cool-plugins-events-addon', '📅 Events Addons For The Events Calendar' );
require_once ECT_PLUGIN_DIR . 'admin/codestar-framework/codestar-framework.php';
require_once ECT_PLUGIN_DIR . 'admin/ect-codestar-settings.php';
$settings_panel = new ECTSettings();
}
/*** Include helpers functions*/
require_once ECT_PLUGIN_DIR . 'includes/ect-functions.php';
require_once ECT_PLUGIN_DIR . 'includes/events-shortcode.php';
EventsShortcode::registers();
require_once ECT_PLUGIN_DIR . 'admin/ect-event-shortcode.php';
}
public static function onInit() {
if ( version_compare( get_option( 'ect-v' ), '1.8', '<' ) ) {
ect_create_admin_notice(
array(
'id' => 'ect-free-setting-migration',
'message' => wp_kses_post( __( '<strong>Important Update</strong>:- <strong>Events Shortcodes & Templates</strong> plugin has integrated new settings panel. Please save your settings and check events views.', 'ect' ) ),
'review_interval' => 0,
)
);
}
if ( did_action( 'elementor/loaded' ) && ! class_exists( 'Events_Calendar_Addon' ) ) {
ect_create_admin_notice(
array(
'id' => 'ect-elementor-addon-notice',
'message' => wp_kses_post(
__(
'Hi! We checked that you are using <strong>Elementor Page Builder</strong>.
<br/>We suggest you to try "<a target="_blank" href="https://eventscalendaraddons.com/plugin/events-widgets-pro/?utm_source=ect_plugin&utm_medium=inside&utm_campaign=get_pro_ectbe&utm_content=elementor_notice"><strong>Events Widgets For Elementor</strong></a>," a new addon by <a target="_blank" href="https://coolplugins.net/?utm_source=ect_plugin&utm_medium=inside&utm_campaign=coolplugins&utm_content=elementor_notice">Cool Plugins</a>.
<br/>It enables you to display <strong>The Events Calendar</strong> plugin events in Elementor pages.',
'ect'
)
),
'review_interval' => 3,
'logo' => ECT_PLUGIN_URL . 'assets/images/icon-events-widgets.svg',
)
);
}
/*** Plugin review notice file */
ect_create_admin_notice(
array(
'id' => 'ect_review_box', // required and must be unique
'slug' => 'ect', // required in case of review box
'review' => true, // required and set to be true for review box
'review_url' => esc_url( 'https://wordpress.org/support/plugin/template-events-calendar/reviews/#new-post' ), // required
'plugin_name' => 'Events Shortcodes Addon', // required
'logo' => ECT_PLUGIN_URL . 'assets/images/icon-events-shortcodes.svg', // optional: it will display logo
'review_interval' => 3, // optional: this will display review notice
// after 5 days from the installation_time
// default is 3
)
);
}
public function shortcodes_submenu() {
add_submenu_page( 'cool-plugins-events-addon', 'Shortcodes & Template', '<strong>Shortcodes & Template</strong>', 'manage_options', 'admin.php?page=tribe_events-events-template-settings', false, 15 );
}
/*** Check The Events calender is installled or not. If user has not installed yet then show notice */
public function ect_check_event_calender_installed() {
if ( ! class_exists( 'Tribe__Events__Main' ) or ! defined( 'Tribe__Events__Main::VERSION' ) ) {
add_action( 'admin_notices', array( $this, 'Install_ECT_Notice' ) );
}
}
public function Install_ECT_Notice() {
if ( current_user_can( 'activate_plugins' ) ) {
printf(
'<div class="error CTEC_Msz"><p>' .
esc_html( __( '%1$s %2$s', 'ebec' ) ),
esc_html( __( 'In order to use this addon, Please first install the latest version of', 'ebec' ) ),
sprintf(
'<a href="%s">%s</a>',
esc_url( 'plugin-install.php?tab=plugin-information&plugin=the-events-calendar&TB_iframe=true' ),
esc_html( __( 'The Events Calendar', 'ebec' ) )
) . '</p></div>'
);
}
}
/*** Admin side shortcode generator style CSS */
public function ect_tc_css() {
$current_screen = get_current_screen();
$screen_name = isset( $current_screen->base ) ? esc_html( $current_screen->base ) : '';
if ( $screen_name == 'events-addons_page_tribe_events-events-template-settings' ) {
wp_enqueue_script( 'ectcsf-codemirror', ECT_PLUGIN_URL . 'assets/ect-codemirror/js/codemirror.min.js', array( 'csf' ), ECT_VERSION, true );
wp_enqueue_script( 'ectcsf-codemirror-loadmode', ECT_PLUGIN_URL . 'assets/ect-codemirror/js/loadmode.min.js', array( 'ectcsf-codemirror' ), ECT_VERSION, true );
wp_enqueue_script( 'ectcsf-html-mixed', ECT_PLUGIN_URL . 'assets/ect-codemirror/js/ect-html-mixed-min.js', array( 'ectcsf-codemirror' ), ECT_VERSION, true );
wp_enqueue_style( 'ectcsf-codemirror', ECT_PLUGIN_URL . 'assets/ect-codemirror/css/codemirror.min.css', array(), ECT_VERSION, 'all' );
}
wp_enqueue_style( 'sg-btn-css', plugins_url( 'assets/css/shortcode-generator.css', __FILE__ ) );
}
/*** Add links in plugin install list */
public function ect_template_settings_page( $links ) {
$links[] = '<a style="font-weight:bold" href="' . esc_url( get_admin_url( null, 'admin.php?page=tribe_events-events-template-settings' ) ) . '">Shortcodes Settings</a>';
// $links[] = '<a style="font-weight:bold" href="https://eventscalendartemplates.com/" target="_blank">View Demos</a>';
$plugin_visit_website = "https://eventscalendaraddons.com/plugin/events-shortcodes-pro/?utm_source=ect_plugin&utm_medium=inside&utm_campaign=get_pro&utm_content=plugins_list";
$links[] = '<a style="font-weight:bold" href="' . esc_url($plugin_visit_website) . '" target="_blank">' . __("Get Pro", "ect") . '</a>';
return $links;
}
/**
* Add meta links to the Plugins list page.
*
* @param array $links The current action links.
* @param string $file The plugin to see if we are on Event Single Page.
*
* @return array The modified action links array.
*/
public function ect_addMeta_Links( $links, $file){
if ( strpos( $file, basename(__FILE__) )) {
$ectanchor = esc_html__( 'Video Tutorials', 'ect' );
$ectvideourl = 'https://eventscalendaraddons.com/go/ect-video-tutorial/?utm_source=ect_plugin&utm_medium=inside&utm_campaign=video_tutorial&utm_content=plugins_list';
$links[] = '<a href="' . esc_url( $ectvideourl ) . '" target="_blank">' . $ectanchor . '</a>';
}
return $links;
}
// set settings on plugin activation
public static function activate() {
update_option( 'ect-v', ECT_VERSION );
update_option( 'ect-type', 'FREE' );
update_option( 'ect-free-installDate', date( 'Y-m-d h:i:s' ) );
update_option( 'ect-ratingDiv', 'no' );
}
public static function deactivate() {
delete_option( 'settings_migration_status' );
delete_option( 'ect-v' );
delete_option( 'ect-type' );
delete_option( 'ect-free-installDate' );
delete_option( 'ect-ratingDiv' );
}
public function ect_rest_url() {
?>
<!-- TinyMCE Shortcode Plugin -->
<script type='text/javascript'>
var ectRestUrl='<?php echo esc_url( get_rest_url( null, '/tribe/events/v1/' ) ); ?>'
</script>
<!-- TinyMCE Shortcode Plugin -->
<?php
}
/*
Old settings migration
*/
// old titan settings panel fields data
function get_titan_settings() {
$new_settings = array();
if ( get_option( 'ect_options' ) != false ) {
$titan_raw_data = get_option( 'ect_options' );
if ( is_serialized( $titan_raw_data ) ) {
$titan_settings = array_filter( maybe_unserialize( $titan_raw_data ) );
if ( is_array( $titan_settings ) ) {
foreach ( $titan_settings as $key => $val ) {
$new_settings[ $key ] = maybe_unserialize( $val );
}
}
}
return $new_settings;
} else {
return false;
}
}
function ect_settings_migration() {
if ( version_compare( get_option( 'ect-v' ), '1.8', '>' ) ) {
return;
}
if ( get_option( 'settings_migration_status' ) ) {
return;
}
$old_settings = $this->get_titan_settings();
if ( $old_settings == false ) {
return;
}
if ( is_array( $old_settings ) ) {
$req_settings = array(
'font-family',
'font-size',
'font-weight',
'font-style',
'line-height',
'letter-spacing',
'text-transform',
'color',
'font-type',
);
$webSafeFonts = array(
'Arial, Helvetica, sans-serif' => 'Arial',
'"Arial Black", Gadget, sans-serif' => 'Arial Black',
'"Comic Sans MS", cursive, sans-serif' => 'Comic Sans MS',
'"Courier New", Courier, monospace' => 'Courier New',
'Georgia, serif' => 'Geogia',
'Impact, Charcoal, sans-serif' => 'Impact',
'"Lucida Console", Monaco, monospace' => 'Lucida Console',
'"Lucida Sans Unicode", "Lucida Grande", sans-serif' => 'Lucida Sans Unicode',
'"Palatino Linotype", "Book Antiqua", Palatino, serif' => 'Palatino Linotype',
'Tahoma, Geneva, sans-serif' => 'Tahoma',
'"Times New Roman", Times, serif' => 'Times New Roman',
'"Trebuchet MS", Helvetica, sans-serif' => 'Trebuchet MS',
'Verdana, Geneva, sans-serif' => 'Verdana',
);
$old_font_arr = array_flip( $webSafeFonts );
$new_settings = array();
foreach ( $old_settings as $key => $field_val ) {
if ( is_array( $field_val ) ) {
foreach ( $field_val as $index => $val ) {
if ( in_array( $index, $req_settings ) ) {
if ( $index == 'font-type' ) {
$index = 'type';
} elseif ( $index == 'font-size' ) {
$val = str_replace( 'px', '', $val );
} elseif ( $index == 'line-height' ) {
$val = str_replace( 'em', '', $val );
} elseif ( $index == 'letter-spacing' ) {
$val = str_replace( 'em', '', $val );
} elseif ( $index == 'font-family' ) {
$found = array_search( $val, $old_font_arr );
$val = $found ? $found : $val;
}
$new_settings[ $key ][ $index ] = $val;
}
}
$new_settings[ $key ]['line_height_unit'] = 'em';
$new_settings[ $key ]['unit'] = 'px';
$new_settings[ $key ]['subset'] = '';
$new_settings[ $key ]['text-align'] = '';
$new_settings[ $key ]['font-variant'] = '';
} else {
$new_settings[ $key ] = $field_val;
}
}
update_option( 'ects_options', $new_settings );
update_option( 'settings_migration_status', 'done' );
delete_option( 'ect_options' );
}
}
}
}
/*** EventsCalendarTemplates main class - END */
/*** THANKS - CoolPlugins.net ) */
$ect = EventsCalendarTemplates::get_instance();
$ect->registers();