Admin
2 weeks ago
Ajax
2 weeks ago
Asset
2 weeks ago
Context
2 weeks ago
Customizer
2 weeks ago
Debug_Bar
2 weeks ago
Dialog
2 weeks ago
Documentation
2 weeks ago
Duplicate
2 weeks ago
Editor
2 weeks ago
Image
2 weeks ago
JSON_LD
2 weeks ago
Languages
2 weeks ago
Log
2 weeks ago
Meta
2 weeks ago
Models
2 weeks ago
PUE
2 weeks ago
Process
2 weeks ago
Promoter
2 weeks ago
REST
2 weeks ago
Repository
2 weeks ago
Service_Providers
2 weeks ago
Shortcode
2 weeks ago
Support
2 weeks ago
Tabbed_View
2 weeks ago
Tooltip
2 weeks ago
Traits
2 weeks ago
Utils
2 weeks ago
Validator
2 weeks ago
Widget
2 weeks ago
Abstract_Deactivation.php
2 weeks ago
Abstract_Plugin_Register.php
2 weeks ago
App_Shop.php
2 weeks ago
Assets.php
2 weeks ago
Assets_Pipeline.php
2 weeks ago
Autoloader.php
2 weeks ago
Cache.php
2 weeks ago
Cache_Listener.php
2 weeks ago
Changelog_Reader.php
2 weeks ago
Container.php
2 weeks ago
Context.php
2 weeks ago
Cost_Utils.php
2 weeks ago
Credits.php
2 weeks ago
Customizer.php
2 weeks ago
DB_Lock.php
2 weeks ago
Data.php
2 weeks ago
Date_Utils.php
2 weeks ago
Db.php
2 weeks ago
Debug.php
2 weeks ago
Dependency.php
2 weeks ago
Deprecation.php
2 weeks ago
Editor.php
2 weeks ago
Error.php
2 weeks ago
Exception.php
2 weeks ago
Extension.php
2 weeks ago
Extension_Loader.php
2 weeks ago
Feature_Detection.php
2 weeks ago
Field.php
2 weeks ago
Field_Conditional.php
2 weeks ago
Freemius.php
2 weeks ago
Log.php
2 weeks ago
Main.php
2 weeks ago
Notices.php
2 weeks ago
Plugin_Meta_Links.php
2 weeks ago
Plugins.php
2 weeks ago
Plugins_API.php
2 weeks ago
Post_History.php
2 weeks ago
Post_Transient.php
2 weeks ago
Promise.php
2 weeks ago
Repository.php
2 weeks ago
Rewrite.php
2 weeks ago
Settings.php
2 weeks ago
Settings_Manager.php
2 weeks ago
Settings_Tab.php
2 weeks ago
Simple_Table.php
2 weeks ago
Support.php
2 weeks ago
Tabbed_View.php
2 weeks ago
Template.php
2 weeks ago
Template_Factory.php
2 weeks ago
Template_Part_Cache.php
2 weeks ago
Templates.php
2 weeks ago
Terms.php
2 weeks ago
Timezones.php
2 weeks ago
Tracker.php
2 weeks ago
Updater.php
2 weeks ago
Validate.php
2 weeks ago
View_Helpers.php
2 weeks ago
Plugins.php
168 lines
| 1 | <?php |
| 2 | // Don't load directly |
| 3 | defined( 'WPINC' ) or die; |
| 4 | |
| 5 | if ( ! class_exists( 'Tribe__Plugins' ) ) { |
| 6 | /** |
| 7 | * A list of Tribe's major plugins. Useful when encouraging users to download one of these. |
| 8 | */ |
| 9 | class Tribe__Plugins { |
| 10 | |
| 11 | /** |
| 12 | * A list of tribe plugin's details in this array format: |
| 13 | * |
| 14 | * [ |
| 15 | * 'short_name' => Common name for the plugin, used in places such as WP Admin messages |
| 16 | * 'class' => Main plugin class |
| 17 | * 'thickbox_url' => Download or purchase URL for plugin from within /wp-admin/ thickbox |
| 18 | * ] |
| 19 | */ |
| 20 | private $tribe_plugins = [ |
| 21 | [ |
| 22 | 'short_name' => 'Event Tickets', |
| 23 | 'class' => 'Tribe__Tickets__Main', |
| 24 | 'thickbox_url' => 'plugin-install.php?tab=plugin-information&plugin=event-tickets&TB_iframe=true', |
| 25 | ], |
| 26 | [ |
| 27 | 'short_name' => 'Event Tickets Plus', |
| 28 | 'class' => 'Tribe__Tickets_Plus__Main', |
| 29 | 'thickbox_url' => 'https://theeventscalendar.com/product/wordpress-event-tickets-plus/?TB_iframe=true', |
| 30 | ], |
| 31 | [ |
| 32 | 'short_name' => 'The Events Calendar', |
| 33 | 'class' => 'Tribe__Events__Main', |
| 34 | 'thickbox_url' => 'plugin-install.php?tab=plugin-information&plugin=the-events-calendar&TB_iframe=true', |
| 35 | ], |
| 36 | [ |
| 37 | 'short_name' => 'Events Calendar Pro', |
| 38 | 'class' => 'Tribe__Events__Pro__Main', |
| 39 | 'thickbox_url' => 'https://theeventscalendar.com/product/wordpress-events-calendar-pro/?TB_iframe=true', |
| 40 | ], |
| 41 | [ |
| 42 | 'short_name' => 'Community Events', |
| 43 | 'class' => 'Tribe__Events__Community__Main', |
| 44 | 'thickbox_url' => 'https://theeventscalendar.com/product/wordpress-community-events/?TB_iframe=true', |
| 45 | ], |
| 46 | [ |
| 47 | 'short_name' => 'Community Tickets', |
| 48 | 'class' => 'Tribe__Events__Community__Tickets__Main', |
| 49 | 'thickbox_url' => 'https://theeventscalendar.com/product/community-tickets/?TB_iframe=true', |
| 50 | ], |
| 51 | [ |
| 52 | 'short_name' => 'Filter Bar', |
| 53 | 'class' => 'Tribe__Events__Filterbar__View', |
| 54 | 'thickbox_url' => 'https://theeventscalendar.com/product/wordpress-events-filterbar/?TB_iframe=true', |
| 55 | ], |
| 56 | [ |
| 57 | 'short_name' => 'Facebook Events', |
| 58 | 'class' => 'Tribe__Events__Facebook__Importer', |
| 59 | 'thickbox_url' => 'https://theeventscalendar.com/product/facebook-events/?TB_iframe=true', |
| 60 | ], |
| 61 | [ |
| 62 | 'short_name' => 'iCal Importer', |
| 63 | 'class' => 'Tribe__Events__Ical_Importer__Main', |
| 64 | 'thickbox_url' => 'https://theeventscalendar.com/product/ical-importer/?TB_iframe=true', |
| 65 | ], |
| 66 | [ |
| 67 | 'short_name' => 'Eventbrite Tickets', |
| 68 | 'class' => 'Tribe__Events__Tickets__Eventbrite__Main', |
| 69 | 'thickbox_url' => 'https://theeventscalendar.com/product/wordpress-eventbrite-tickets/?TB_iframe=true', |
| 70 | ], |
| 71 | [ |
| 72 | 'short_name' => 'Advanced Post Manager', |
| 73 | 'class' => 'Tribe_APM', |
| 74 | 'thickbox_url' => 'plugin-install.php?tab=plugin-information&plugin=advanced-post-manager&TB_iframe=true', |
| 75 | ], |
| 76 | ]; |
| 77 | |
| 78 | /** |
| 79 | * Searches the plugin list for key/value pair and return the full details for that plugin |
| 80 | * |
| 81 | * @param string $search_key The array key this value will appear in |
| 82 | * @param string $search_val The value itself |
| 83 | * |
| 84 | * @return array|null |
| 85 | */ |
| 86 | public function get_plugin_by_key( $search_key, $search_val ) { |
| 87 | foreach ( $this->get_list() as $plugin ) { |
| 88 | if ( isset( $plugin[ $search_key ] ) && $plugin[ $search_key ] === $search_val ) { |
| 89 | return $plugin; |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | return null; |
| 94 | } |
| 95 | |
| 96 | /** |
| 97 | * Retrieves plugins details by plugin name |
| 98 | * |
| 99 | * @param string $name Common name for the plugin, not necessarily the lengthy name in the WP Admin Plugins list |
| 100 | * |
| 101 | * @return array|null |
| 102 | */ |
| 103 | public function get_plugin_by_name( $name ) { |
| 104 | return $this->get_plugin_by_key( 'short_name', $name ); |
| 105 | } |
| 106 | |
| 107 | /** |
| 108 | * Retrieves plugins details by class name |
| 109 | * |
| 110 | * @param string $main_class Main/base class for this plugin |
| 111 | * |
| 112 | * @return array|null |
| 113 | */ |
| 114 | public function get_plugin_by_class( $main_class ) { |
| 115 | return $this->get_plugin_by_key( 'class', $main_class ); |
| 116 | } |
| 117 | |
| 118 | /** |
| 119 | * Retrieves the entire list |
| 120 | * |
| 121 | * @return array |
| 122 | */ |
| 123 | public function get_list() { |
| 124 | /** |
| 125 | * Gives an opportunity to filter the list of tribe plugins |
| 126 | * |
| 127 | * @since 4.7.18 |
| 128 | * |
| 129 | * @param array Contains a list of all tribe plugins |
| 130 | */ |
| 131 | return apply_filters( 'tribe_plugins_get_list', $this->tribe_plugins ); |
| 132 | } |
| 133 | |
| 134 | /** |
| 135 | * Checks if given plugin is active. Usually a The Events Calendar plugin. |
| 136 | * |
| 137 | * @param string $plugin_name The name of the plugin. Each plugin defines their name upon hooking on the filter. |
| 138 | * |
| 139 | * @since 4.12.1 |
| 140 | * |
| 141 | * @return bool True if plugin is active. False if plugin is not active. |
| 142 | */ |
| 143 | public static function is_active( $plugin_name ) { |
| 144 | if ( ! did_action( "plugins_loaded" ) ) { |
| 145 | _doing_it_wrong( |
| 146 | __METHOD__, |
| 147 | __( 'Using this function before "plugins_loaded" action has fired can return unreliable results.', 'tribe-common' ), |
| 148 | '4.12.6' |
| 149 | ); |
| 150 | } |
| 151 | |
| 152 | /** |
| 153 | * Filters the array that each Tribe plugin overrides to |
| 154 | * set itself as active when this function is called. |
| 155 | * |
| 156 | * @example [ 'the-events-calendar' => true, 'event-tickets' => true ] |
| 157 | * |
| 158 | * @since 4.12.1 |
| 159 | * |
| 160 | * @return array Plugin slugs as keys and bool as value for whether it's active or not. |
| 161 | */ |
| 162 | $plugins = apply_filters( 'tribe_active_plugins', [] ); |
| 163 | |
| 164 | return isset( $plugins[ $plugin_name ] ) && tribe_is_truthy( $plugins[ $plugin_name ] ); |
| 165 | } |
| 166 | } |
| 167 | } |
| 168 |