Version Description
Download this release
Release Info
Developer | borkweb |
Plugin | |
Version | 3.12.1 |
Comparing to | |
See all releases |
Code changes from version 3.12 to 3.12.1
- common/README.md +0 -2
- common/Tribe/Abstract_Deactivation.php +0 -71
- common/Tribe/Admin/Helpers.php +0 -161
- common/Tribe/Admin/Notice/Archive_Slug_Conflict.php +0 -75
- common/Tribe/Admin/Timezone_Settings.php +0 -100
- common/Tribe/Admin/Timezone_Updater.php +0 -227
- common/Tribe/App_Shop.php +0 -198
- common/Tribe/Asset/Factory.php +0 -57
- common/Tribe/Autoloader.php +0 -246
- common/Tribe/Cache.php +0 -126
- common/Tribe/Cache_Listener.php +0 -98
- common/Tribe/Capabilities.php +0 -119
- common/Tribe/Changelog_Reader.php +0 -53
- common/Tribe/Credits.php +0 -65
- common/Tribe/Date_Utils.php +0 -726
- common/Tribe/Deactivation.php +0 -49
- common/Tribe/Debug.php +0 -58
- common/Tribe/Field.php +0 -616
- common/Tribe/Main.php +0 -143
- common/Tribe/Notices.php +0 -76
- common/Tribe/Settings.php +0 -551
- common/Tribe/Settings_Manager.php +0 -348
- common/Tribe/Settings_Tab.php +0 -229
- common/Tribe/Support.php +0 -263
- common/Tribe/Template_Factory.php +0 -188
- common/Tribe/Template_Part_Cache.php +0 -123
- common/Tribe/Timezones.php +0 -304
- common/Tribe/Validate.php +0 -456
- common/Tribe/View_Helpers.php +0 -598
- common/admin-views/tribe-options-display.php +0 -227
- common/admin-views/tribe-options-general.php +0 -233
- common/admin-views/tribe-options-help.php +0 -356
- common/admin-views/tribe-options-licenses.php +0 -60
- common/admin-views/tribe-options-network.php +0 -35
- common/admin-views/tribe-options-timezones.php +0 -50
- common/deprecated/Tribe__Events__Abstract_Deactivation.php +0 -4
- common/deprecated/Tribe__Events__Admin__Helpers.php +0 -4
- common/deprecated/Tribe__Events__App_Shop.php +0 -4
- common/deprecated/Tribe__Events__Autoloader.php +0 -4
- common/deprecated/Tribe__Events__Cache.php +0 -4
- common/deprecated/Tribe__Events__Cache_Listener.php +0 -4
- common/deprecated/Tribe__Events__Capabilities.php +0 -4
- common/deprecated/Tribe__Events__Changelog_Reader.php +0 -4
- common/deprecated/Tribe__Events__Credits.php +0 -4
- common/deprecated/Tribe__Events__Date_Utils.php +0 -4
- common/deprecated/Tribe__Events__Deactivation.php +0 -4
- common/deprecated/Tribe__Events__Field.php +0 -4
- common/deprecated/Tribe__Events__Settings.php +0 -4
- common/deprecated/Tribe__Events__Settings_Tab.php +0 -4
- common/deprecated/Tribe__Events__Support.php +0 -4
- common/deprecated/Tribe__Events__Template_Factory.php +0 -4
- common/deprecated/Tribe__Events__Template_Part_Cache.php +0 -4
- common/deprecated/Tribe__Events__Validate.php +0 -4
- common/deprecated/Tribe__Events__View_Helpers.php +0 -4
- common/functions/template-tags/date.php +0 -142
- common/functions/template-tags/day.php +0 -1
- common/functions/template-tags/general.php +0 -384
- common/resources/images/modern-tribe.png +0 -0
- common/resources/images/modern-tribe@2x.png +0 -0
- common/resources/js/events-admin-timezone-updater.js +0 -57
- lang/{tribe-events-calendar-af.mo → the-events-calendar-af.mo} +0 -0
- lang/{tribe-events-calendar-af.po → the-events-calendar-af.po} +0 -0
- lang/{tribe-events-calendar-bg_BG.mo → the-events-calendar-bg_BG.mo} +0 -0
- lang/{tribe-events-calendar-bg_BG.po → the-events-calendar-bg_BG.po} +0 -0
- lang/{tribe-events-calendar-ca.mo → the-events-calendar-ca.mo} +0 -0
- lang/{tribe-events-calendar-ca.po → the-events-calendar-ca.po} +0 -0
- lang/the-events-calendar-cs_CZ.mo +0 -0
- lang/{tribe-events-calendar-cs_CZ.po → the-events-calendar-cs_CZ.po} +209 -209
- lang/the-events-calendar-da_DK.mo +0 -0
- lang/{tribe-events-calendar-da_DK.po → the-events-calendar-da_DK.po} +5 -5
- lang/the-events-calendar-de_DE.mo +0 -0
- lang/{tribe-events-calendar-de_DE.po → the-events-calendar-de_DE.po} +48 -48
- lang/{tribe-events-calendar-el.mo → the-events-calendar-el.mo} +0 -0
- lang/{tribe-events-calendar-el.po → the-events-calendar-el.po} +0 -0
- lang/{tribe-events-calendar-en_GB.mo → the-events-calendar-en_GB.mo} +0 -0
- lang/{tribe-events-calendar-en_GB.po → the-events-calendar-en_GB.po} +0 -0
- lang/the-events-calendar-es_ES.mo +0 -0
- lang/{tribe-events-calendar-es_ES.po → the-events-calendar-es_ES.po} +45 -45
- lang/{tribe-events-calendar-et.mo → the-events-calendar-et.mo} +0 -0
- lang/{tribe-events-calendar-et.po → the-events-calendar-et.po} +0 -0
- lang/{tribe-events-calendar-fi.mo → the-events-calendar-fi.mo} +0 -0
- lang/{tribe-events-calendar-fi.po → the-events-calendar-fi.po} +0 -0
- lang/{tribe-events-calendar-fr-ca.mo → the-events-calendar-fr-ca.mo} +0 -0
- lang/{tribe-events-calendar-fr-ca.po → the-events-calendar-fr-ca.po} +0 -0
- lang/the-events-calendar-fr_FR.mo +0 -0
- lang/{tribe-events-calendar-fr_FR.po → the-events-calendar-fr_FR.po} +37 -37
- lang/the-events-calendar-hu_HU.mo +0 -0
- lang/{tribe-events-calendar-hu_HU.po → the-events-calendar-hu_HU.po} +48 -48
- lang/{tribe-events-calendar-id_ID.mo → the-events-calendar-id_ID.mo} +0 -0
- lang/{tribe-events-calendar-id_ID.po → the-events-calendar-id_ID.po} +0 -0
- lang/{tribe-events-calendar-is_IS.mo → the-events-calendar-is_IS.mo} +0 -0
- lang/{tribe-events-calendar-is_IS.po → the-events-calendar-is_IS.po} +0 -0
- lang/{tribe-events-calendar-it_IT.mo → the-events-calendar-it_IT.mo} +0 -0
- lang/{tribe-events-calendar-it_IT.po → the-events-calendar-it_IT.po} +0 -0
- lang/the-events-calendar-lt_LT.mo +0 -0
- lang/{tribe-events-calendar-lt_LT.po → the-events-calendar-lt_LT.po} +18 -14
- lang/{tribe-events-calendar-lv.mo → the-events-calendar-lv.mo} +0 -0
- lang/{tribe-events-calendar-lv.po → the-events-calendar-lv.po} +0 -0
- lang/the-events-calendar-nb_NO.mo +0 -0
- lang/{tribe-events-calendar-nb_NO.po → the-events-calendar-nb_NO.po} +189 -185
- lang/the-events-calendar-nl_NL.mo +0 -0
- lang/{tribe-events-calendar-nl_NL.po → the-events-calendar-nl_NL.po} +46 -46
- lang/{tribe-events-calendar-pl_PL.mo → the-events-calendar-pl_PL.mo} +0 -0
- lang/{tribe-events-calendar-pl_PL.po → the-events-calendar-pl_PL.po} +0 -0
- lang/the-events-calendar-pt_BR.mo +0 -0
- lang/{tribe-events-calendar-pt_BR.po → the-events-calendar-pt_BR.po} +7 -7
- lang/{tribe-events-calendar-pt_PT.mo → the-events-calendar-pt_PT.mo} +0 -0
- lang/{tribe-events-calendar-pt_PT.po → the-events-calendar-pt_PT.po} +0 -0
- lang/{tribe-events-calendar-ro_RO.mo → the-events-calendar-ro_RO.mo} +0 -0
- lang/{tribe-events-calendar-ro_RO.po → the-events-calendar-ro_RO.po} +0 -0
- lang/{tribe-events-calendar-ru_RU.mo → the-events-calendar-ru_RU.mo} +0 -0
- lang/{tribe-events-calendar-ru_RU.po → the-events-calendar-ru_RU.po} +0 -0
- lang/the-events-calendar-sk_SK.mo +0 -0
- lang/{tribe-events-calendar-sk_SK.po → the-events-calendar-sk_SK.po} +7 -7
- lang/{tribe-events-calendar-sl_SI.mo → the-events-calendar-sl_SI.mo} +0 -0
- lang/{tribe-events-calendar-sl_SI.po → the-events-calendar-sl_SI.po} +0 -0
- lang/{tribe-events-calendar-sr_RS.mo → the-events-calendar-sr_RS.mo} +0 -0
- lang/{tribe-events-calendar-sr_RS.po → the-events-calendar-sr_RS.po} +0 -0
- lang/{tribe-events-calendar-sv_SE.mo → the-events-calendar-sv_SE.mo} +0 -0
- lang/{tribe-events-calendar-sv_SE.po → the-events-calendar-sv_SE.po} +0 -0
- lang/{tribe-events-calendar-tr_TR.mo → the-events-calendar-tr_TR.mo} +0 -0
- lang/{tribe-events-calendar-tr_TR.po → the-events-calendar-tr_TR.po} +0 -0
- lang/{tribe-events-calendar-uk.mo → the-events-calendar-uk.mo} +0 -0
- lang/{tribe-events-calendar-uk.po → the-events-calendar-uk.po} +0 -0
- lang/{tribe-events-calendar-zh_CN.mo → the-events-calendar-zh_CN.mo} +0 -0
- lang/{tribe-events-calendar-zh_CN.po → the-events-calendar-zh_CN.po} +0 -0
- lang/{tribe-events-calendar-zh_TW.mo → the-events-calendar-zh_TW.mo} +0 -0
- lang/{tribe-events-calendar-zh_TW.po → the-events-calendar-zh_TW.po} +5 -5
- lang/{tribe-events-calendar.pot → the-events-calendar.pot} +0 -0
- lang/tribe-events-calendar-cs_CZ.mo +0 -0
- lang/tribe-events-calendar-da_DK.mo +0 -0
- lang/tribe-events-calendar-de_DE.mo +0 -0
- lang/tribe-events-calendar-es_ES.mo +0 -0
- lang/tribe-events-calendar-fr_FR.mo +0 -0
- lang/tribe-events-calendar-hu_HU.mo +0 -0
- lang/tribe-events-calendar-lt_LT.mo +0 -0
- lang/tribe-events-calendar-nb_NO.mo +0 -0
- lang/tribe-events-calendar-nl_NL.mo +0 -0
- lang/tribe-events-calendar-pt_BR.mo +0 -0
- lang/tribe-events-calendar-sk_SK.mo +0 -0
- npm-debug.log +0 -19
- readme.txt +5 -1
- src/Tribe/API.php +2 -2
- src/Tribe/Activation_Page.php +2 -2
- src/Tribe/Admin/Notice/Archive_Slug_Conflict.php +8 -8
- src/Tribe/Admin/Organizer_Chooser_Meta_Box.php +3 -3
- src/Tribe/Admin/Timezone_Updater.php +4 -4
- src/Tribe/Admin_List.php +4 -4
- src/Tribe/Advanced_Functions/Register_Meta.php +8 -8
- src/Tribe/Amalgamator.php +1 -1
- src/Tribe/App_Shop.php +3 -3
- src/Tribe/Asset/Ajax_Calendar.php +1 -1
- src/Tribe/Changelog_Reader.php +1 -1
- src/Tribe/Cost_Utils.php +2 -2
- src/Tribe/Credits.php +2 -2
- src/Tribe/Field.php +4 -4
- src/Tribe/Importer/Admin_Page.php +8 -8
- src/Tribe/Importer/Column_Mapper.php +31 -31
- src/Tribe/Importer/File_Importer.php +5 -5
- src/Tribe/Importer/File_Uploader.php +2 -2
- src/Tribe/List_Widget.php +3 -3
- src/Tribe/Main.php +156 -156
- src/Tribe/Options_Exception.php +1 -1
- src/Tribe/PUE/Checker.php +11 -11
- src/Tribe/Post_Exception.php +1 -1
- src/Tribe/Rewrite.php +1 -1
- src/Tribe/Settings.php +13 -13
- src/Tribe/Settings_Tab.php +1 -1
- src/Tribe/Support.php +5 -5
- src/Tribe/Template/Day.php +6 -6
- src/Tribe/Template/Month.php +4 -4
- src/Tribe/Template/Single_Event.php +1 -1
- src/Tribe/Template_Factory.php +7 -7
- src/Tribe/Templates.php +2 -2
- src/Tribe/Tickets/Attendees_Table.php +17 -17
- src/Tribe/Tickets/Metabox.php +3 -3
- src/Tribe/Tickets/Tickets.php +2 -2
- src/Tribe/Tickets/Tickets_Pro.php +7 -7
- src/Tribe/Validate.php +25 -25
- src/Tribe/View_Helpers.php +295 -295
- src/Tribe/iCal.php +10 -10
- src/admin-views/admin-update-message.php +14 -14
- src/admin-views/admin-welcome-message.php +18 -18
- src/admin-views/app-shop.php +3 -3
- src/admin-views/event-sidebar-options.php +3 -3
- src/admin-views/events-meta-box.php +17 -17
- src/admin-views/new-organizer-meta-section.php +6 -6
- src/admin-views/organizer-meta-box.php +6 -6
- src/admin-views/tickets/attendees.php +21 -21
- src/admin-views/tickets/list.php +7 -7
- src/admin-views/tickets/meta-box.php +18 -18
- src/admin-views/tribe-options-display.php +42 -42
- src/admin-views/tribe-options-general.php +40 -40
- src/admin-views/tribe-options-help.php +45 -45
- src/admin-views/tribe-options-licenses.php +4 -4
- src/admin-views/tribe-options-network.php +3 -3
- src/admin-views/tribe-options-timezones.php +9 -9
- src/admin-views/venue-meta-box.php +14 -14
- src/admin-views/widget-admin-list.php +3 -3
- src/functions/advanced-functions/meta_registration.php +14 -14
- src/functions/template-tags/date.php +1 -1
- src/functions/template-tags/day.php +7 -7
- src/functions/template-tags/deprecated.php +1 -1
- src/functions/template-tags/general.php +8 -8
- src/functions/template-tags/google-map.php +2 -2
- src/functions/template-tags/loop.php +5 -5
- src/functions/template-tags/options.php +3 -3
- src/functions/template-tags/organizer.php +2 -2
- src/functions/template-tags/venue.php +3 -3
- src/io/csv/admin-views/columns.php +5 -5
- src/io/csv/admin-views/general.php +10 -10
- src/io/csv/admin-views/header.php +1 -1
- src/io/csv/admin-views/import.php +20 -20
- src/io/csv/admin-views/result.php +8 -8
- src/views/day/nav.php +1 -1
- src/views/day/single-event.php +1 -1
- src/views/list/nav.php +3 -3
- src/views/list/single-event.php +1 -1
- src/views/modules/bar.php +4 -4
- src/views/modules/meta/details.php +11 -11
- src/views/modules/meta/organizer.php +3 -3
- src/views/modules/meta/venue.php +3 -3
- src/views/month/nav.php +1 -1
- src/views/month/single-day.php +1 -1
- src/views/single-event.php +3 -3
- src/views/tickets/attendees-email.php +1 -1
- src/views/tickets/email.php +6 -6
- src/views/widgets/list-widget.php +2 -2
- the-events-calendar.php +2 -2
- vendor/bacon/bacon-string-utils/LICENSE +0 -22
- vendor/bacon/bacon-string-utils/Module.php +0 -52
- vendor/bacon/bacon-string-utils/README.md +0 -38
- vendor/bacon/bacon-string-utils/autoload_classmap.php +0 -7
- vendor/bacon/bacon-string-utils/autoload_function.php +0 -14
- vendor/bacon/bacon-string-utils/autoload_register.php +0 -2
- vendor/bacon/bacon-string-utils/bin/update-unidecoder-tables.php +0 -108
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/Filter/Slugify.php +0 -27
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/Slugifier.php +0 -89
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder.php +0 -92
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x000.php +0 -268
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x001.php +0 -268
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x002.php +0 -267
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x003.php +0 -267
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x004.php +0 -267
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x005.php +0 -267
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x006.php +0 -267
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x007.php +0 -267
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x009.php +0 -267
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x00a.php +0 -267
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x00b.php +0 -267
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x00c.php +0 -267
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x00d.php +0 -267
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x00e.php +0 -267
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x00f.php +0 -267
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x010.php +0 -267
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x011.php +0 -267
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x012.php +0 -268
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x013.php +0 -267
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x014.php +0 -268
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x015.php +0 -268
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x016.php +0 -267
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x017.php +0 -267
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x018.php +0 -267
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x01d.php +0 -267
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x01e.php +0 -267
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x01f.php +0 -267
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x020.php +0 -267
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x021.php +0 -267
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x022.php +0 -267
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x023.php +0 -267
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x024.php +0 -267
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x025.php +0 -267
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x026.php +0 -267
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x027.php +0 -267
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x028.php +0 -268
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x02c.php +0 -267
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x02e.php +0 -267
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x02f.php +0 -267
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x030.php +0 -267
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x031.php +0 -267
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x032.php +0 -267
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x033.php +0 -267
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x04d.php +0 -267
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x04e.php +0 -268
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x04f.php +0 -268
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x050.php +0 -268
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x051.php +0 -268
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x052.php +0 -268
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x053.php +0 -268
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x054.php +0 -268
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x055.php +0 -268
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x056.php +0 -268
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x057.php +0 -268
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x058.php +0 -268
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x059.php +0 -268
- vendor/bacon/bacon-string-utils/src/BaconStringUtils/UniDecoder/x05a.php +0 -242
common/README.md
DELETED
@@ -1,2 +0,0 @@
|
|
1 |
-
# tribe-common
|
2 |
-
Common classes and functions used in our plugins
|
|
|
|
common/Tribe/Abstract_Deactivation.php
DELETED
@@ -1,71 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
abstract class Tribe__Abstract_Deactivation {
|
4 |
-
protected $network = FALSE;
|
5 |
-
|
6 |
-
public function __construct( $network ) {
|
7 |
-
$this->network = (bool) $network;
|
8 |
-
}
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Tell WordPress to flush rewrite rules.
|
12 |
-
* Since our post types are already registered,
|
13 |
-
* we delete the option and let WP regenerate it
|
14 |
-
* on the next page load.
|
15 |
-
*/
|
16 |
-
protected function flush_rewrite_rules() {
|
17 |
-
delete_option( 'rewrite_rules' );
|
18 |
-
}
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Deactivate the plugin. This should not remove data.
|
22 |
-
* It's job is to remove run-time traces of the plugin.
|
23 |
-
*
|
24 |
-
* @return void
|
25 |
-
*/
|
26 |
-
public function deactivate() {
|
27 |
-
if ( is_multisite() && $this->network ) {
|
28 |
-
$this->multisite_deactivate();
|
29 |
-
} else {
|
30 |
-
$this->blog_deactivate();
|
31 |
-
}
|
32 |
-
}
|
33 |
-
|
34 |
-
/**
|
35 |
-
* Run the deactivation script on every blog for a multisite install
|
36 |
-
*
|
37 |
-
* @return void
|
38 |
-
*/
|
39 |
-
protected function multisite_deactivate() {
|
40 |
-
/** @var wpdb $wpdb */
|
41 |
-
global $wpdb;
|
42 |
-
$site = get_current_site();
|
43 |
-
$blog_ids = $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM {$wpdb->blogs} WHERE site_id=%d", $site->id ) );
|
44 |
-
$large = wp_is_large_network();
|
45 |
-
foreach ( $blog_ids as $blog ) {
|
46 |
-
set_time_limit( 30 );
|
47 |
-
switch_to_blog( $blog );
|
48 |
-
$large ? $this->short_blog_deactivate() : $this->blog_deactivate();
|
49 |
-
restore_current_blog();
|
50 |
-
}
|
51 |
-
}
|
52 |
-
|
53 |
-
/**
|
54 |
-
* The deactivation routine for a single blog
|
55 |
-
*
|
56 |
-
* @return void
|
57 |
-
*/
|
58 |
-
abstract protected function blog_deactivate();
|
59 |
-
|
60 |
-
|
61 |
-
/**
|
62 |
-
* An abridged version that is less DB intensive for use on large networks.
|
63 |
-
*
|
64 |
-
* @see wp_is_large_network() and the 'wp_is_large_network' filter
|
65 |
-
*
|
66 |
-
* @return void
|
67 |
-
*/
|
68 |
-
protected function short_blog_deactivate() {
|
69 |
-
$this->blog_deactivate();
|
70 |
-
}
|
71 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
common/Tribe/Admin/Helpers.php
DELETED
@@ -1,161 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
// Don't load directly
|
4 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
5 |
-
die( '-1' );
|
6 |
-
}
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Class with a few helpers for the Administration Pages
|
10 |
-
*/
|
11 |
-
class Tribe__Admin__Helpers {
|
12 |
-
/**
|
13 |
-
* Static Singleton Holder
|
14 |
-
* @var Tribe__Admin__Helpers|null
|
15 |
-
*/
|
16 |
-
protected static $instance;
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Static Singleton Factory Method
|
20 |
-
*
|
21 |
-
* @return Tribe__Admin__Helpers
|
22 |
-
*/
|
23 |
-
public static function instance() {
|
24 |
-
if ( ! isset( self::$instance ) ) {
|
25 |
-
$className = __CLASS__;
|
26 |
-
self::$instance = new $className;
|
27 |
-
}
|
28 |
-
|
29 |
-
return self::$instance;
|
30 |
-
}
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Matcher for Admin Pages related to Post Types
|
34 |
-
*
|
35 |
-
* @param string|array|null $id What will be checked to see if we return true or false
|
36 |
-
*
|
37 |
-
* @return boolean
|
38 |
-
*/
|
39 |
-
public function is_post_type_screen( $post_type = null ) {
|
40 |
-
global $current_screen;
|
41 |
-
|
42 |
-
// Not in the admin we don't even care
|
43 |
-
if ( ! is_admin() ) {
|
44 |
-
return false;
|
45 |
-
}
|
46 |
-
|
47 |
-
// Not doing AJAX
|
48 |
-
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
49 |
-
return false;
|
50 |
-
}
|
51 |
-
|
52 |
-
// Avoid Notices by checking the object type of WP_Screen
|
53 |
-
if ( ! ( $current_screen instanceof WP_Screen ) ) {
|
54 |
-
return false;
|
55 |
-
}
|
56 |
-
|
57 |
-
$defaults = array(
|
58 |
-
Tribe__Events__Main::POSTTYPE,
|
59 |
-
Tribe__Events__Main::VENUE_POST_TYPE,
|
60 |
-
Tribe__Events__Main::ORGANIZER_POST_TYPE,
|
61 |
-
);
|
62 |
-
|
63 |
-
// Match any Post Type form Tribe
|
64 |
-
if ( is_null( $post_type ) && in_array( $current_screen->post_type, $defaults ) ) {
|
65 |
-
return true;
|
66 |
-
}
|
67 |
-
|
68 |
-
// Match any of the post_types set
|
69 |
-
if ( ! is_scalar( $post_type ) && in_array( $current_screen->post_type, (array) $post_type ) ) {
|
70 |
-
return true;
|
71 |
-
}
|
72 |
-
|
73 |
-
// Match a specific Post Type
|
74 |
-
if ( $current_screen->post_type === $post_type ) {
|
75 |
-
return true;
|
76 |
-
}
|
77 |
-
|
78 |
-
return false;
|
79 |
-
}
|
80 |
-
|
81 |
-
/**
|
82 |
-
* Matcher for administration pages that are from Tribe the easier way
|
83 |
-
*
|
84 |
-
* @param string|array|null $id What will be checked to see if we return true or false
|
85 |
-
*
|
86 |
-
* @return boolean
|
87 |
-
*/
|
88 |
-
public function is_screen( $id = null ) {
|
89 |
-
global $current_screen;
|
90 |
-
|
91 |
-
// Not in the admin we don't even care
|
92 |
-
if ( ! is_admin() ) {
|
93 |
-
return false;
|
94 |
-
}
|
95 |
-
|
96 |
-
// Not doing AJAX
|
97 |
-
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
98 |
-
return false;
|
99 |
-
}
|
100 |
-
|
101 |
-
// Avoid Notices by checking the object type of WP_Screen
|
102 |
-
if ( ! ( $current_screen instanceof WP_Screen ) ) {
|
103 |
-
return false;
|
104 |
-
}
|
105 |
-
|
106 |
-
// Match any screen from Tribe
|
107 |
-
if ( is_null( $id ) && false !== strpos( $current_screen->id, 'tribe' ) ) {
|
108 |
-
return true;
|
109 |
-
}
|
110 |
-
|
111 |
-
// Match any of the pages set
|
112 |
-
if ( ! is_scalar( $id ) && in_array( $current_screen->id, (array) $id ) ) {
|
113 |
-
return true;
|
114 |
-
}
|
115 |
-
|
116 |
-
// Match a specific page
|
117 |
-
if ( $current_screen->id === $id ) {
|
118 |
-
return true;
|
119 |
-
}
|
120 |
-
|
121 |
-
return false;
|
122 |
-
}
|
123 |
-
|
124 |
-
/**
|
125 |
-
* Matcher for administration pages action
|
126 |
-
*
|
127 |
-
* @param string|array|null $action What will be checked to see if we return true or false
|
128 |
-
*
|
129 |
-
* @return boolean
|
130 |
-
*/
|
131 |
-
public function is_action( $action = null ) {
|
132 |
-
global $current_screen;
|
133 |
-
|
134 |
-
// Not in the admin we don't even care
|
135 |
-
if ( ! is_admin() ) {
|
136 |
-
return false;
|
137 |
-
}
|
138 |
-
|
139 |
-
// Not doing AJAX
|
140 |
-
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
141 |
-
return false;
|
142 |
-
}
|
143 |
-
|
144 |
-
// Avoid Notices by checking the object type of WP_Screen
|
145 |
-
if ( ! ( $current_screen instanceof WP_Screen ) ) {
|
146 |
-
return false;
|
147 |
-
}
|
148 |
-
|
149 |
-
// Match any of the pages set
|
150 |
-
if ( ! is_scalar( $action ) && in_array( $current_screen->action, (array) $action ) ) {
|
151 |
-
return true;
|
152 |
-
}
|
153 |
-
|
154 |
-
// Match a specific page
|
155 |
-
if ( $current_screen->action === $action ) {
|
156 |
-
return true;
|
157 |
-
}
|
158 |
-
|
159 |
-
return false;
|
160 |
-
}
|
161 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
common/Tribe/Admin/Notice/Archive_Slug_Conflict.php
DELETED
@@ -1,75 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Class Tribe__Admin__Notice__Archive_Slug_Conflict
|
6 |
-
*
|
7 |
-
* Takes care of adding an admin notice if a page with the `/events` slug has been created in the site.
|
8 |
-
*/
|
9 |
-
class Tribe__Admin__Notice__Archive_Slug_Conflict {
|
10 |
-
|
11 |
-
/**
|
12 |
-
* @var static
|
13 |
-
*/
|
14 |
-
protected static $instance;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* @var string The slug of The Events Calendar archive page.
|
18 |
-
*/
|
19 |
-
protected $archive_slug;
|
20 |
-
|
21 |
-
/**
|
22 |
-
* @var WP_Post The page post object.
|
23 |
-
*/
|
24 |
-
protected $page;
|
25 |
-
|
26 |
-
/**
|
27 |
-
* @return Tribe__Admin__Notice__Archive_Slug_Conflict
|
28 |
-
*/
|
29 |
-
public static function instance() {
|
30 |
-
if ( empty( self::$instance ) ) {
|
31 |
-
self::$instance = new self();
|
32 |
-
}
|
33 |
-
|
34 |
-
return self::$instance;
|
35 |
-
}
|
36 |
-
|
37 |
-
/**
|
38 |
-
* Hooks the action to show an admin notice if a page with the `/events` slug exists on the site.
|
39 |
-
*/
|
40 |
-
public function maybe_add_admin_notice() {
|
41 |
-
$this->archive_slug = Tribe__Settings_Manager::get_option( 'eventsSlug', 'events' );
|
42 |
-
$page = get_page_by_path( $this->archive_slug );
|
43 |
-
if ( ! $page || $page->post_status == 'trash' ) {
|
44 |
-
return;
|
45 |
-
}
|
46 |
-
$this->page = $page;
|
47 |
-
add_action( 'admin_notices', array( $this, 'notice' ) );
|
48 |
-
}
|
49 |
-
|
50 |
-
/**
|
51 |
-
* Echoes the admin notice to the page
|
52 |
-
*/
|
53 |
-
public function notice() {
|
54 |
-
|
55 |
-
// What's happening?
|
56 |
-
$page_title = apply_filters( 'the_title', $this->page->post_title );
|
57 |
-
$line_1 = __( sprintf( 'The page "%1$s" uses the "/%2$s" slug: the Events Calendar plugin will show its calendar in place of the page.', $page_title, $this->archive_slug ), 'tribe-common' );
|
58 |
-
|
59 |
-
// What the user can do
|
60 |
-
$page_edit_link = get_edit_post_link( $this->page->ID );
|
61 |
-
// $can_edit_page_link = sprintf( __( '<a href="%s">Edit the page slug</a>', 'tribe-common' ), $page_edit_link );
|
62 |
-
$can_edit_page_link = sprintf( __( '<a href="%s">Edit the page slug</a>', 'tribe-common' ), $page_edit_link );
|
63 |
-
$page_edit_link_string = current_user_can( 'edit_pages' ) ? $can_edit_page_link : __( 'Ask the site administrator to edit the page slug', 'tribe-common' );
|
64 |
-
|
65 |
-
$settings_cap = apply_filters( 'tribe_settings_req_cap', 'manage_options' );
|
66 |
-
$admin_slug = apply_filters( 'tribe_settings_admin_slug', 'tribe-common' );
|
67 |
-
$setting_page_link = admin_url( 'edit.php?post_type=' . Tribe__Events__Main::POSTTYPE . '&page=' . $admin_slug . '#tribe-field-singleEventSlug' );
|
68 |
-
$can_edit_settings_link = sprintf( __( '<a href="%s">edit The Events Calendar settings</a>.', 'tribe-common' ), $setting_page_link );
|
69 |
-
$events_settings_link_string = current_user_can( $settings_cap ) ? $can_edit_settings_link : __( ' ask the site administrator set a different Events URL slug.', 'tribe-common' );
|
70 |
-
|
71 |
-
$line_2 = __( sprintf( '%1$s or %2$s', $page_edit_link_string, $events_settings_link_string ), 'tribe-common' );
|
72 |
-
|
73 |
-
echo sprintf( '<div id="message" class="error"><p>%s</p><p>%s</p></div>', $line_1, $line_2 );
|
74 |
-
}
|
75 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
common/Tribe/Admin/Timezone_Settings.php
DELETED
@@ -1,100 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Manages the admin settings UI in relation to timezones.
|
4 |
-
*/
|
5 |
-
class Tribe__Admin__Timezone_Settings {
|
6 |
-
/**
|
7 |
-
* Sets up the display of timezone-related settings and listeners to deal with timezone-update
|
8 |
-
* requests (which are initiated from within the settings screen).
|
9 |
-
*/
|
10 |
-
public function __construct() {
|
11 |
-
$this->listen();
|
12 |
-
add_action( 'wp_ajax_tribe_timezone_update', array( $this, 'ajax_updater' ) );
|
13 |
-
add_filter( 'tribe_general_settings_tab_fields', array( $this, 'settings_ui' ) );
|
14 |
-
}
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Adds timezone settings to the *General* settings tab.
|
18 |
-
*
|
19 |
-
* When it is determined that timezone data still needs to be generated for one or more
|
20 |
-
* events then only the update tool will be exposed in this area, in all other cases this
|
21 |
-
* is not exposed and the ordinary timezone settings will be visible.
|
22 |
-
*
|
23 |
-
* @param array $general_settings
|
24 |
-
*
|
25 |
-
* @return array
|
26 |
-
*/
|
27 |
-
public function settings_ui( array $general_settings ) {
|
28 |
-
$updater = new Tribe__Admin__Timezone_Updater;
|
29 |
-
|
30 |
-
// Load all timezone settings
|
31 |
-
$timezone_settings = $this->get_settings_array();
|
32 |
-
|
33 |
-
// Remove unneeded options: until timezone data has been updated, users should only see the update
|
34 |
-
// button - after that point, they should see the "real" settings but not the update button
|
35 |
-
if ( $updater->update_needed() ) {
|
36 |
-
unset( $timezone_settings[ 'tribe_events_timezone_mode' ] );
|
37 |
-
unset( $timezone_settings[ 'tribe_events_timezones_show_zone' ] );
|
38 |
-
} else {
|
39 |
-
unset( $timezone_settings[ 'tribe_events_enable_timezones' ] );
|
40 |
-
}
|
41 |
-
|
42 |
-
// Add the new section just before the settings form is closed
|
43 |
-
return Tribe__Main::array_insert_before_key(
|
44 |
-
'tribe-form-content-end',
|
45 |
-
$general_settings,
|
46 |
-
$timezone_settings
|
47 |
-
);
|
48 |
-
}
|
49 |
-
|
50 |
-
/**
|
51 |
-
* Loads the timezone settings from an admin-view file and returns them as an array.
|
52 |
-
*
|
53 |
-
* @return array
|
54 |
-
*/
|
55 |
-
protected function get_settings_array() {
|
56 |
-
$plugin_path = Tribe__Main::instance()->plugin_path;
|
57 |
-
return (array) include $plugin_path . 'common/admin-views/tribe-options-timezones.php';
|
58 |
-
}
|
59 |
-
|
60 |
-
/**
|
61 |
-
* Accommodates timezone update requests.
|
62 |
-
*
|
63 |
-
* Usually, the result is that an initial batch of events will be updated and any
|
64 |
-
* remaining events will be dealt with by an "ajax loop" - however in the event
|
65 |
-
* of a JS conflict this could actually be called repeatedly (by the user simply
|
66 |
-
* clicking the "Update Timezone Data" button until it is cleared.
|
67 |
-
*/
|
68 |
-
protected function listen() {
|
69 |
-
// Sanity check
|
70 |
-
if ( ! isset( $_GET['_wpnonce'] ) || ! wp_verify_nonce( $_GET['_wpnonce'], 'timezone-settings' ) ) {
|
71 |
-
return;
|
72 |
-
}
|
73 |
-
|
74 |
-
// Update request?
|
75 |
-
if ( isset( $_GET['timezone-update'] ) ) {
|
76 |
-
$updater = new Tribe__Admin__Timezone_Updater;
|
77 |
-
$updater->init_update();
|
78 |
-
}
|
79 |
-
}
|
80 |
-
|
81 |
-
/**
|
82 |
-
* Facilitates updates of timezone data via an ajax loop.
|
83 |
-
*
|
84 |
-
* This approach helps to avoid potential timeout issues on sites with poor performance
|
85 |
-
* or large numbers of events, besides facilitating visual feedback as to progress.
|
86 |
-
*/
|
87 |
-
public function ajax_updater() {
|
88 |
-
if ( ! isset( $_POST['check'] ) || ! wp_verify_nonce( $_POST['check'], 'timezone-settings' ) ) {
|
89 |
-
return;
|
90 |
-
}
|
91 |
-
|
92 |
-
$updater = new Tribe__Admin__Timezone_Updater;
|
93 |
-
$updater->init_update();
|
94 |
-
|
95 |
-
wp_send_json( array(
|
96 |
-
'html' => $updater->notice_inner(),
|
97 |
-
'continue' => $updater->update_needed(),
|
98 |
-
) );
|
99 |
-
}
|
100 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
common/Tribe/Admin/Timezone_Updater.php
DELETED
@@ -1,227 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Tool for adding timezone data to events.
|
4 |
-
*
|
5 |
-
* The application for this is in transitioning any event data created in 3.11.x or
|
6 |
-
* earlier that hasn't since been updated, so that it becomes "timezone ready".
|
7 |
-
*/
|
8 |
-
class Tribe__Admin__Timezone_Updater {
|
9 |
-
/**
|
10 |
-
* A count of events in need of updating - used to determine the percentage
|
11 |
-
* of the task that has been completed.
|
12 |
-
*
|
13 |
-
* @var int
|
14 |
-
*/
|
15 |
-
protected $initial_count = 0;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Initializes the update process.
|
19 |
-
*
|
20 |
-
* Determines if events are still in need of an update and triggers an update of an
|
21 |
-
* initial batch of events if so.
|
22 |
-
*
|
23 |
-
* Once these are processed, notices are set to communicate the state of the update
|
24 |
-
* back to the user (which also serves as a vehicle for continuing the update via
|
25 |
-
* an ajax loop).
|
26 |
-
*/
|
27 |
-
public function init_update() {
|
28 |
-
if ( $this->update_needed() ) {
|
29 |
-
/**
|
30 |
-
* Provides an opportunity to change the maximum number of events that will be
|
31 |
-
* updated with timezone data in a single batch.
|
32 |
-
*
|
33 |
-
* @param int number of events to be processed in a single batch
|
34 |
-
*/
|
35 |
-
$batch_size = (int) apply_filters( 'tribe_events_timezone_updater_batch_size', 50 );
|
36 |
-
$this->initial_count = $this->count_ids();
|
37 |
-
$this->process( $batch_size );
|
38 |
-
}
|
39 |
-
|
40 |
-
$this->notice_setup();
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Setup an admin-notice based progress report along with supporting assets to facilitate
|
45 |
-
* an ajax loop for further processing where needed.
|
46 |
-
*/
|
47 |
-
protected function notice_setup() {
|
48 |
-
add_action( 'admin_notices', array( $this, 'notice_display' ) );
|
49 |
-
add_action( 'admin_enqueue_scripts', array( $this, 'notice_assets' ) );
|
50 |
-
}
|
51 |
-
|
52 |
-
/**
|
53 |
-
* Renders the admin notice.
|
54 |
-
*
|
55 |
-
* This effectively just wraps notice_inner() - which is independently called to build
|
56 |
-
* ajax responses.
|
57 |
-
*/
|
58 |
-
public function notice_display() {
|
59 |
-
$update = $this->notice_inner();
|
60 |
-
echo '<div class="tribe-events-timezone-update-msg updated updating"> ' . $update . ' </div>';
|
61 |
-
}
|
62 |
-
|
63 |
-
/**
|
64 |
-
* Provides a progress report relating to the status of the timezone data update process.
|
65 |
-
*
|
66 |
-
* @return string
|
67 |
-
*/
|
68 |
-
public function notice_inner() {
|
69 |
-
$remaining = $this->count_ids();
|
70 |
-
$spinner = ' <img src="' . get_admin_url( null, '/images/spinner.gif' ) . '">';
|
71 |
-
|
72 |
-
$progress = ( 0 < $remaining )
|
73 |
-
? $this->calculate_progress( $remaining )
|
74 |
-
: 100;
|
75 |
-
|
76 |
-
$update = $remaining
|
77 |
-
? __( 'Please wait while timezone data is added to your events.', 'tribe-common' )
|
78 |
-
: __( 'Update complete: timezone data has been added to all events in the database.', 'tribe-common' );
|
79 |
-
|
80 |
-
$update = "<p> $update </p>";
|
81 |
-
|
82 |
-
if ( 100 === $progress ) {
|
83 |
-
$spinner = '';
|
84 |
-
}
|
85 |
-
|
86 |
-
if ( $progress >= 0 ) {
|
87 |
-
$percent = sprintf( __( '%d%% complete', 'tribe-common' ), $progress );
|
88 |
-
$update .= '<div class="tribe-update-bar"> <div class="progress" title="' . $percent . '"> <div class="bar" style="width: ' . $progress . '%"></div> </div>' . $spinner . '</div>';
|
89 |
-
}
|
90 |
-
|
91 |
-
return $update;
|
92 |
-
}
|
93 |
-
|
94 |
-
/**
|
95 |
-
* Sets up the Javascript needed to facilitate the ajax loop on the frontend.
|
96 |
-
*/
|
97 |
-
public function notice_assets() {
|
98 |
-
$plugin = Tribe__Main::instance();
|
99 |
-
$script = trailingslashit( $plugin->plugin_url ) . 'common/resources/js/events-admin-timezone-updater.js';
|
100 |
-
$handle = 'tribe-events-ajax-timezone-update';
|
101 |
-
|
102 |
-
wp_enqueue_script( $handle, $script, array( 'jquery' ), false, true );
|
103 |
-
wp_localize_script( $handle, 'tribe_timezone_update', array(
|
104 |
-
'continue' => $this->update_needed(),
|
105 |
-
'failure_msg' => __( 'A problem stopped the timezone update process from completing. Please refresh and try again.', 'tribe-common' ),
|
106 |
-
'check' => wp_create_nonce( 'timezone-settings' ),
|
107 |
-
) );
|
108 |
-
}
|
109 |
-
|
110 |
-
/**
|
111 |
-
* Returns an integer representing the degree to which the update task has progressed
|
112 |
-
* as a percentage of events in need of updating.
|
113 |
-
*
|
114 |
-
* @param int $remaining
|
115 |
-
*
|
116 |
-
* @return int
|
117 |
-
*/
|
118 |
-
protected function calculate_progress( $remaining ) {
|
119 |
-
if ( $this->initial_count ) {
|
120 |
-
$percentage = ( $this->initial_count - $remaining ) / $this->initial_count;
|
121 |
-
return (int) ( $percentage * 100 );
|
122 |
-
}
|
123 |
-
|
124 |
-
return 0;
|
125 |
-
}
|
126 |
-
|
127 |
-
/**
|
128 |
-
* Updates the next batch of non-timezone ready events.
|
129 |
-
*
|
130 |
-
* @param int $batch_size (defaults to -1 meaning "update all")
|
131 |
-
*/
|
132 |
-
public function process( $batch_size = -1 ) {
|
133 |
-
$site_timezone = Tribe__Timezones::wp_timezone_string();
|
134 |
-
|
135 |
-
foreach ( $this->get_ids( $batch_size ) as $event_id ) {
|
136 |
-
$local_start_time = tribe_get_start_date( $event_id, true, Tribe__Date_Utils::DBDATETIMEFORMAT );
|
137 |
-
$utc_start_time = Tribe__Timezones::to_utc( $local_start_time, $site_timezone );
|
138 |
-
|
139 |
-
$local_end_time = tribe_get_end_date( $event_id, true, Tribe__Date_Utils::DBDATETIMEFORMAT );
|
140 |
-
$utc_end_time = Tribe__Timezones::to_utc( $local_end_time, $site_timezone );
|
141 |
-
|
142 |
-
// The abbreviation needs to be calculated per event as it can vary according to the actual date
|
143 |
-
$site_timezone_abbr = Tribe__Timezones::wp_timezone_abbr( $local_start_time );
|
144 |
-
|
145 |
-
update_post_meta( $event_id, '_EventTimezone', $site_timezone );
|
146 |
-
update_post_meta( $event_id, '_EventTimezoneAbbr', $site_timezone_abbr );
|
147 |
-
update_post_meta( $event_id, '_EventStartDateUTC', $utc_start_time );
|
148 |
-
update_post_meta( $event_id, '_EventEndDateUTC', $utc_end_time );
|
149 |
-
}
|
150 |
-
}
|
151 |
-
|
152 |
-
/**
|
153 |
-
* Return an array of event IDs for those events that still do not have
|
154 |
-
* timezone data.
|
155 |
-
*
|
156 |
-
* @param int $limit
|
157 |
-
*
|
158 |
-
* @return array
|
159 |
-
*/
|
160 |
-
public function get_ids( $limit = -1 ) {
|
161 |
-
return $this->find( $limit );
|
162 |
-
}
|
163 |
-
|
164 |
-
/**
|
165 |
-
* Get the number of events that still require timezone data.
|
166 |
-
*
|
167 |
-
* @return int
|
168 |
-
*/
|
169 |
-
public function count_ids() {
|
170 |
-
return $this->find( -1, true );
|
171 |
-
}
|
172 |
-
|
173 |
-
/**
|
174 |
-
* Indicates if there are still events that need to be updated
|
175 |
-
* with timezone data.
|
176 |
-
*
|
177 |
-
* @return bool
|
178 |
-
*/
|
179 |
-
public function update_needed() {
|
180 |
-
return (bool) $this->find( 1, true );
|
181 |
-
}
|
182 |
-
|
183 |
-
/**
|
184 |
-
* Utility function that can return either an array of IDs for all (or the specified
|
185 |
-
* number) of events without timezone data, or alternatively can return a count of
|
186 |
-
* those events.
|
187 |
-
*
|
188 |
-
* @param int $limit
|
189 |
-
* @param bool|false $count
|
190 |
-
*
|
191 |
-
* @return array|int
|
192 |
-
*/
|
193 |
-
protected function find( $limit = -1, $count = false ) {
|
194 |
-
global $wpdb;
|
195 |
-
|
196 |
-
// Form the limit clause if needed
|
197 |
-
$limit = ( (int) $limit > 0 )
|
198 |
-
? 'LIMIT ' . absint( $limit )
|
199 |
-
: '';
|
200 |
-
|
201 |
-
// Are we making a count or obtaining the actual IDs?
|
202 |
-
$requested_data = $count
|
203 |
-
? 'COUNT( DISTINCT( ID ) )'
|
204 |
-
: 'DISTINCT( ID )';
|
205 |
-
|
206 |
-
$query = "
|
207 |
-
-- Look for events not returned by the inner query
|
208 |
-
SELECT $requested_data
|
209 |
-
FROM $wpdb->posts
|
210 |
-
WHERE $wpdb->posts.post_type = %s
|
211 |
-
AND $wpdb->posts.post_status <> 'auto-draft'
|
212 |
-
AND ID NOT IN (
|
213 |
-
-- Find those posts that already have timezone meta data
|
214 |
-
SELECT DISTINCT ( post_id )
|
215 |
-
FROM $wpdb->postmeta
|
216 |
-
WHERE meta_key = '_EventTimezone'
|
217 |
-
)
|
218 |
-
$limit;
|
219 |
-
";
|
220 |
-
|
221 |
-
$prepared_query = $wpdb->prepare( $query, Tribe__Events__Main::POSTTYPE );
|
222 |
-
|
223 |
-
return $count
|
224 |
-
? (int) $wpdb->get_var( $prepared_query )
|
225 |
-
: (array) $wpdb->get_col( $prepared_query );
|
226 |
-
}
|
227 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
common/Tribe/App_Shop.php
DELETED
@@ -1,198 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
// don't load directly
|
4 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
5 |
-
die( '-1' );
|
6 |
-
}
|
7 |
-
|
8 |
-
if ( ! class_exists( 'Tribe__App_Shop' ) ) {
|
9 |
-
/**
|
10 |
-
* Class that handles the integration with our Shop App API
|
11 |
-
*/
|
12 |
-
class Tribe__App_Shop {
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Version of the data model
|
16 |
-
*/
|
17 |
-
const API_VERSION = '1.0';
|
18 |
-
/**
|
19 |
-
* URL of the API
|
20 |
-
*/
|
21 |
-
const API_ENDPOINT = 'http://tri.be/api/app-shop/';
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Base name for the transients key
|
25 |
-
*/
|
26 |
-
const CACHE_KEY_BASE = 'tribe-app-shop';
|
27 |
-
/**
|
28 |
-
* Duration of the transients, in seconds.
|
29 |
-
*/
|
30 |
-
const CACHE_EXPIRATION = 300; //5 min
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Slug of the WP admin menu item
|
34 |
-
*/
|
35 |
-
const MENU_SLUG = 'tribe-app-shop';
|
36 |
-
|
37 |
-
/**
|
38 |
-
* Singleton instance
|
39 |
-
*
|
40 |
-
* @var null or Tribe__App_Shop
|
41 |
-
*/
|
42 |
-
private static $instance = null;
|
43 |
-
/**
|
44 |
-
* The slug for the new admin page
|
45 |
-
*
|
46 |
-
* @var string
|
47 |
-
*/
|
48 |
-
private $admin_page = null;
|
49 |
-
|
50 |
-
|
51 |
-
/**
|
52 |
-
* Class constructor
|
53 |
-
*/
|
54 |
-
public function __construct() {
|
55 |
-
add_action( 'admin_menu', array( $this, 'add_menu_page' ), 100 );
|
56 |
-
add_action( 'wp_before_admin_bar_render', array( $this, 'add_toolbar_item' ), 20 );
|
57 |
-
}
|
58 |
-
|
59 |
-
/**
|
60 |
-
* Adds the page to the admin menu
|
61 |
-
*/
|
62 |
-
public function add_menu_page() {
|
63 |
-
$page_title = __( 'Event Add-Ons', 'tribe-common' );
|
64 |
-
$menu_title = __( 'Event Add-Ons', 'tribe-common' );
|
65 |
-
$capability = apply_filters( 'tribe_events_addon_page_capability', 'install_plugins' );
|
66 |
-
|
67 |
-
$where = 'edit.php?post_type=' . Tribe__Events__Main::POSTTYPE;
|
68 |
-
|
69 |
-
$this->admin_page = add_submenu_page(
|
70 |
-
$where, $page_title, $menu_title, $capability, self::MENU_SLUG, array(
|
71 |
-
$this,
|
72 |
-
'do_menu_page',
|
73 |
-
)
|
74 |
-
);
|
75 |
-
|
76 |
-
add_action( 'admin_print_styles-' . $this->admin_page, array( $this, 'enqueue' ) );
|
77 |
-
}
|
78 |
-
|
79 |
-
/**
|
80 |
-
* Adds a link to the shop app to the WP admin bar
|
81 |
-
*/
|
82 |
-
public function add_toolbar_item() {
|
83 |
-
|
84 |
-
$capability = apply_filters( 'tribe_events_addon_page_capability', 'install_plugins' );
|
85 |
-
|
86 |
-
// prevent users who cannot install plugins from seeing addons link
|
87 |
-
if ( current_user_can( $capability ) ) {
|
88 |
-
global $wp_admin_bar;
|
89 |
-
|
90 |
-
$where = 'edit.php?post_type=' . Tribe__Events__Main::POSTTYPE;
|
91 |
-
|
92 |
-
$wp_admin_bar->add_menu( array(
|
93 |
-
'id' => 'tribe-events-app-shop',
|
94 |
-
'title' => __( 'Event Add-Ons', 'tribe-common' ),
|
95 |
-
'href' => esc_url( admin_url( untrailingslashit( $where ) . '&page=' . esc_attr( self::MENU_SLUG ) ) ),
|
96 |
-
'parent' => 'tribe-events-settings-group',
|
97 |
-
) );
|
98 |
-
}
|
99 |
-
}
|
100 |
-
|
101 |
-
/**
|
102 |
-
* Enqueue the styles and script
|
103 |
-
*/
|
104 |
-
public function enqueue() {
|
105 |
-
wp_enqueue_style( 'app-shop', tribe_events_resource_url( 'app-shop.css' ), array(), apply_filters( 'tribe_events_css_version', Tribe__Main::VERSION ) );
|
106 |
-
wp_enqueue_script( 'app-shop', tribe_events_resource_url( 'app-shop.js' ), array(), apply_filters( 'tribe_events_js_version', Tribe__Main::VERSION ) );
|
107 |
-
}
|
108 |
-
|
109 |
-
/**
|
110 |
-
* Renders the Shop App page
|
111 |
-
*/
|
112 |
-
public function do_menu_page() {
|
113 |
-
$remote = $this->get_all_products();
|
114 |
-
|
115 |
-
if ( ! empty( $remote ) ) {
|
116 |
-
$products = null;
|
117 |
-
if ( property_exists( $remote, 'data' ) ) {
|
118 |
-
$products = $remote->data;
|
119 |
-
}
|
120 |
-
$banner = null;
|
121 |
-
if ( property_exists( $remote, 'banner' ) ) {
|
122 |
-
$banner = $remote->banner;
|
123 |
-
}
|
124 |
-
|
125 |
-
if ( empty( $products ) ) {
|
126 |
-
return;
|
127 |
-
}
|
128 |
-
|
129 |
-
$categories = array_unique( wp_list_pluck( $products, 'category' ) );
|
130 |
-
|
131 |
-
include_once( Tribe__Events__Main::instance()->pluginPath . 'common/admin-views/app-shop.php' );
|
132 |
-
}
|
133 |
-
|
134 |
-
}
|
135 |
-
|
136 |
-
/**
|
137 |
-
* Get's all products from the API
|
138 |
-
*
|
139 |
-
* @return array|WP_Error
|
140 |
-
*/
|
141 |
-
private function get_all_products() {
|
142 |
-
|
143 |
-
$cache_key = self::CACHE_KEY_BASE . '-products';
|
144 |
-
$products = get_transient( $cache_key );
|
145 |
-
|
146 |
-
if ( ! $products ) {
|
147 |
-
$products = $this->remote_get( 'get-products' );
|
148 |
-
if ( $products && ! $products->error ) {
|
149 |
-
set_transient( $cache_key, $products, self::CACHE_EXPIRATION );
|
150 |
-
}
|
151 |
-
}
|
152 |
-
|
153 |
-
if ( is_string( $products ) ) {
|
154 |
-
$products = json_decode( $products );
|
155 |
-
}
|
156 |
-
|
157 |
-
return $products;
|
158 |
-
|
159 |
-
}
|
160 |
-
|
161 |
-
/**
|
162 |
-
* Makes the remote call to the API endpoint
|
163 |
-
*
|
164 |
-
* @param $action
|
165 |
-
* @param array|null $args
|
166 |
-
*
|
167 |
-
* @return array|WP_Error
|
168 |
-
*/
|
169 |
-
private function remote_get( $action, $args = null ) {
|
170 |
-
|
171 |
-
$url = trailingslashit( self::API_ENDPOINT . self::API_VERSION ) . $action;
|
172 |
-
|
173 |
-
$ret = wp_remote_get( $url );
|
174 |
-
|
175 |
-
if ( ! is_wp_error( $ret ) && isset( $ret['body'] ) ) {
|
176 |
-
return json_decode( $ret['body'] );
|
177 |
-
}
|
178 |
-
|
179 |
-
return null;
|
180 |
-
|
181 |
-
}
|
182 |
-
|
183 |
-
/**
|
184 |
-
* Static Singleton Factory Method
|
185 |
-
*
|
186 |
-
* @return Tribe__App_Shop
|
187 |
-
*/
|
188 |
-
public static function instance() {
|
189 |
-
if ( ! isset( self::$instance ) ) {
|
190 |
-
$className = __CLASS__;
|
191 |
-
self::$instance = new $className;
|
192 |
-
}
|
193 |
-
|
194 |
-
return self::$instance;
|
195 |
-
}
|
196 |
-
|
197 |
-
}
|
198 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
common/Tribe/Asset/Factory.php
DELETED
@@ -1,57 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Tribe__Asset__Factory {
|
4 |
-
/**
|
5 |
-
* @param string $name
|
6 |
-
*
|
7 |
-
* @return Tribe__Events__Asset__Abstract_Asset|false Either a new instance of the asset class or false.
|
8 |
-
*/
|
9 |
-
public function make_for_name( $name ) {
|
10 |
-
// `jquery-resize` to `Jquery_Resize`
|
11 |
-
$class_name = $this->get_asset_class_name( $name );
|
12 |
-
|
13 |
-
// `Jquery_Resize` to `Tribe__Events__Asset__Jquery_Resize`
|
14 |
-
$full_class_name = $this->get_asset_full_class_name( $class_name );
|
15 |
-
|
16 |
-
return class_exists( $full_class_name ) ? new $full_class_name() : false;
|
17 |
-
}
|
18 |
-
|
19 |
-
protected function get_asset_class_name( $name ) {
|
20 |
-
// `jquery-resize` to `Jquery_Resize`
|
21 |
-
$class_name = str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $name ) ) );
|
22 |
-
|
23 |
-
return $class_name;
|
24 |
-
}
|
25 |
-
|
26 |
-
/**
|
27 |
-
* @param string $class_name
|
28 |
-
*
|
29 |
-
* @return string
|
30 |
-
*/
|
31 |
-
private function get_asset_full_class_name( $class_name ) {
|
32 |
-
// `Jquery_Resize` to `Tribe__Events__Asset__Jquery_Resize`
|
33 |
-
$full_class_name = $this->get_asset_class_name_prefix() . $class_name;
|
34 |
-
|
35 |
-
return $full_class_name;
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* @return string
|
40 |
-
*/
|
41 |
-
protected function get_asset_class_name_prefix() {
|
42 |
-
return 'Tribe__Asset__';
|
43 |
-
}
|
44 |
-
|
45 |
-
/**
|
46 |
-
* @return Tribe__Asset__Factory
|
47 |
-
*/
|
48 |
-
public static function instance() {
|
49 |
-
static $instance;
|
50 |
-
|
51 |
-
if ( ! $instance ) {
|
52 |
-
$instance = new self;
|
53 |
-
}
|
54 |
-
|
55 |
-
return $instance;
|
56 |
-
}
|
57 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
common/Tribe/Autoloader.php
DELETED
@@ -1,246 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if ( ! class_exists( 'Tribe__Autoloader' ) ) {
|
4 |
-
/**
|
5 |
-
* Class Tribe__Autoloader
|
6 |
-
*
|
7 |
-
* Allows for autoloading of Tribe plugins classes.
|
8 |
-
*
|
9 |
-
* Example usage:
|
10 |
-
*
|
11 |
-
* // will be `/var/www/site/wp-content/plugins/the-events-calendar'
|
12 |
-
* $this_dir = dirname(__FILE__);
|
13 |
-
*
|
14 |
-
* // gets hold of the singleton instance of the class
|
15 |
-
* $autoloader = Tribe__Autoloader::instance();
|
16 |
-
*
|
17 |
-
* // register one by one or use `register_prefixes` method
|
18 |
-
* $autoloader->register_prefix( 'Tribe__Admin__', $this_dir . '/src/Tribe/admin' );
|
19 |
-
* $autoloader->register_prefix( 'Tribe__Admin__', $this_dir . '/src/Tribe/another-dir' );
|
20 |
-
* $autoloader->register_prefix( 'Tribe__Utils__', $this_dir . '/src/Tribe/another-dir' );
|
21 |
-
*
|
22 |
-
* // register a direct class to path
|
23 |
-
* $autoloader->register_class( 'Tribe__Some_Class', $this_dir . '/some/path/to/Some_Class.php' );
|
24 |
-
*
|
25 |
-
* // register a fallback dir to be searched for the class before giving up
|
26 |
-
* $autoloader->add_fallback_dir( $this_dir . '/all-the-classes' );
|
27 |
-
*
|
28 |
-
* // calls `spl_autoload_register`
|
29 |
-
* $autoloader->register_autoloader();
|
30 |
-
*
|
31 |
-
* // class will be searched in the path
|
32 |
-
* // `/var/www/site/wp-content/plugins/the-events-calendar/src/Tribe/admin/Some_Class.php'
|
33 |
-
* // and
|
34 |
-
* // `/var/www/site/wp-content/plugins/the-events-calendar/src/Tribe/another-dir/Some_Class.php'
|
35 |
-
* $i = new Tribe__Admin__Some_Class();
|
36 |
-
*
|
37 |
-
* // class will be searched in the path
|
38 |
-
* // `/var/www/site/wp-content/plugins/the-events-calendar/utils/some-dir/Some_Util.php'
|
39 |
-
* $i = new Tribe__Utils__Some_Util();
|
40 |
-
*
|
41 |
-
* // class will be searched in the path
|
42 |
-
* // `/var/www/site/wp-content/plugins/the-events-calendar/deprecated/Tribe_DeprecatedClass.php'
|
43 |
-
* $i = new Tribe_DeprecatedClass();
|
44 |
-
*/
|
45 |
-
class Tribe__Autoloader {
|
46 |
-
|
47 |
-
/**
|
48 |
-
* @var Tribe__Autoloader
|
49 |
-
*/
|
50 |
-
protected static $instance;
|
51 |
-
|
52 |
-
/**
|
53 |
-
* An arrays of arrays each containing absolute paths.
|
54 |
-
*
|
55 |
-
* Paths are stored trimming any trailing `/`.
|
56 |
-
* E.g. `/var/www/tribe-pro/wp-content/plugins/the-event-calendar/src/Tribe`
|
57 |
-
*
|
58 |
-
* @var string[][]
|
59 |
-
*/
|
60 |
-
protected $prefixes;
|
61 |
-
|
62 |
-
/**
|
63 |
-
* The string acting as a directory separator in a class name.
|
64 |
-
*
|
65 |
-
* E.g.: given `__` as `$dir_separator` then `Admin__Metabox__Some_Metabox`
|
66 |
-
* will map to `/Admin/Metabox/SomeMetabox.php`.
|
67 |
-
*
|
68 |
-
* @var string
|
69 |
-
*/
|
70 |
-
protected $dir_separator = '__';
|
71 |
-
|
72 |
-
/** @var string[] */
|
73 |
-
protected $fallback_dirs = array();
|
74 |
-
|
75 |
-
/**
|
76 |
-
* @var array
|
77 |
-
*/
|
78 |
-
protected $class_paths = array();
|
79 |
-
|
80 |
-
/**
|
81 |
-
* Returns the singleton instance of the class.
|
82 |
-
*
|
83 |
-
* @return Tribe__Autoloader
|
84 |
-
*/
|
85 |
-
public static function instance() {
|
86 |
-
if ( ! self::$instance instanceof Tribe__Autoloader ) {
|
87 |
-
self::$instance = new self();
|
88 |
-
}
|
89 |
-
|
90 |
-
return self::$instance;
|
91 |
-
}
|
92 |
-
|
93 |
-
/**
|
94 |
-
* Registers prefixes and root dirs using an array.
|
95 |
-
*
|
96 |
-
* Same as calling `register_prefix` on each one.
|
97 |
-
*
|
98 |
-
* @param array $prefixes_to_root_dirs
|
99 |
-
*/
|
100 |
-
public function register_prefixes( array $prefixes_to_root_dirs ) {
|
101 |
-
foreach ( $prefixes_to_root_dirs as $prefix => $root_dir ) {
|
102 |
-
$this->register_prefix( $prefix, $root_dir );
|
103 |
-
}
|
104 |
-
}
|
105 |
-
|
106 |
-
/**
|
107 |
-
* Associates a class prefix to an absolute path.
|
108 |
-
*
|
109 |
-
* @param string $prefix A class prefix, e.g. `Tribe__Admin__`
|
110 |
-
* @param string $root_dir The absolute path to the dir containing
|
111 |
-
* the prefixed classes.
|
112 |
-
*/
|
113 |
-
public function register_prefix( $prefix, $root_dir ) {
|
114 |
-
$root_dir = $this->normalize_root_dir( $root_dir );
|
115 |
-
|
116 |
-
if ( ! isset( $this->prefixes[ $prefix ] ) ) {
|
117 |
-
$this->prefixes[ $prefix ] = array();
|
118 |
-
}
|
119 |
-
$this->prefixes[ $prefix ][] = $root_dir;
|
120 |
-
}
|
121 |
-
|
122 |
-
/**
|
123 |
-
* Triggers the registration of the autoload method in the SPL
|
124 |
-
* autoload register.
|
125 |
-
*/
|
126 |
-
public function register_autoloader() {
|
127 |
-
spl_autoload_register( array( $this, 'autoload' ) );
|
128 |
-
}
|
129 |
-
|
130 |
-
/**
|
131 |
-
* Includes the file defining a class.
|
132 |
-
*
|
133 |
-
* This is the function that's registered as an autoloader.
|
134 |
-
*
|
135 |
-
* @param string $class
|
136 |
-
*/
|
137 |
-
public function autoload( $class ) {
|
138 |
-
$include_path = $this->get_class_path( $class );
|
139 |
-
if ( ! empty( $include_path ) ) {
|
140 |
-
include_once( $include_path );
|
141 |
-
}
|
142 |
-
}
|
143 |
-
|
144 |
-
private function normalize_root_dir( $root_dir ) {
|
145 |
-
return rtrim( $root_dir, '/' );
|
146 |
-
}
|
147 |
-
|
148 |
-
protected function get_prefixed_path( $class ) {
|
149 |
-
foreach ( $this->prefixes as $prefix => $dirs ) {
|
150 |
-
if ( strpos( $class, $prefix ) !== 0 ) {
|
151 |
-
continue;
|
152 |
-
}
|
153 |
-
$class_name = str_replace( $prefix, '', $class );
|
154 |
-
$class_path_frag = implode( '/', explode( $this->dir_separator, $class_name ) ) . '.php';
|
155 |
-
foreach ( $dirs as $dir ) {
|
156 |
-
$path = $dir . '/' . $class_path_frag;
|
157 |
-
if ( ! file_exists( $path ) ) {
|
158 |
-
// check if the file exists in lowercase
|
159 |
-
$class_path_frag = strtolower( $class_path_frag );
|
160 |
-
$path = $dir . '/' . $class_path_frag;
|
161 |
-
}
|
162 |
-
if ( ! file_exists( $path ) ) {
|
163 |
-
continue;
|
164 |
-
}
|
165 |
-
|
166 |
-
return $path;
|
167 |
-
}
|
168 |
-
}
|
169 |
-
return false;
|
170 |
-
}
|
171 |
-
|
172 |
-
protected function get_fallback_path( $class ) {
|
173 |
-
foreach ( $this->fallback_dirs as $fallback_dir ) {
|
174 |
-
$include_path = $fallback_dir . '/' . $class . '.php';
|
175 |
-
if ( ! file_exists( $include_path ) ) {
|
176 |
-
// check if the file exists in lowercase
|
177 |
-
$class = strtolower( $class );
|
178 |
-
$include_path = $fallback_dir . '/' . $class . '.php';
|
179 |
-
}
|
180 |
-
if ( ! file_exists( $include_path ) ) {
|
181 |
-
continue;
|
182 |
-
}
|
183 |
-
|
184 |
-
return $include_path;
|
185 |
-
}
|
186 |
-
}
|
187 |
-
|
188 |
-
/**
|
189 |
-
* Gets the absolute path to a class file.
|
190 |
-
*
|
191 |
-
* @param string $class The class name
|
192 |
-
*
|
193 |
-
* @return string Either the absolute path to the class file or an
|
194 |
-
* empty string if the file was not found.
|
195 |
-
*/
|
196 |
-
public function get_class_path( $class ) {
|
197 |
-
$prefixed_path = $this->get_prefixed_path( $class );
|
198 |
-
if ( $prefixed_path ) {
|
199 |
-
return $prefixed_path;
|
200 |
-
}
|
201 |
-
|
202 |
-
$class_path = ! empty( $this->class_paths[ $class ] ) ? $this->class_paths[ $class ] :false;
|
203 |
-
if ( $class_path ) {
|
204 |
-
return $class_path;
|
205 |
-
}
|
206 |
-
|
207 |
-
$fallback_path = $this->get_fallback_path( $class );
|
208 |
-
|
209 |
-
return $fallback_path ? $fallback_path : '';
|
210 |
-
}
|
211 |
-
|
212 |
-
/**
|
213 |
-
* Adds a folder to search for classes that were not found among
|
214 |
-
* the prefixed ones.
|
215 |
-
*
|
216 |
-
* This is the method to use to register a directory of deprecated
|
217 |
-
* classes.
|
218 |
-
*
|
219 |
-
* @param string $dir An absolute path dto a dir.
|
220 |
-
*/
|
221 |
-
public function add_fallback_dir( $dir ) {
|
222 |
-
if ( in_array( $dir, $this->fallback_dirs ) ) {
|
223 |
-
return;
|
224 |
-
}
|
225 |
-
$this->fallback_dirs[] = $this->normalize_root_dir( $dir );
|
226 |
-
}
|
227 |
-
|
228 |
-
/**
|
229 |
-
* @return string
|
230 |
-
*/
|
231 |
-
public function get_dir_separator() {
|
232 |
-
return $this->dir_separator;
|
233 |
-
}
|
234 |
-
|
235 |
-
/**
|
236 |
-
* @param string $dir_separator
|
237 |
-
*/
|
238 |
-
public function set_dir_separator( $dir_separator ) {
|
239 |
-
$this->dir_separator = $dir_separator;
|
240 |
-
}
|
241 |
-
|
242 |
-
public function register_class( $class, $path ) {
|
243 |
-
$this->class_paths[ $class ] = $path;
|
244 |
-
}
|
245 |
-
}
|
246 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|