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 4.6.1.1 6.5.1.4 4.6.10 6.5.1.5 4.6.10.2 6.5.1.6 4.6.11 6.5.2 4.6.11.2 6.6.0 4.6.12.1 6.6.0.1 4.6.13.1 6.6.0.2 4.6.14 6.6.1 4.6.14.2 6.6.2 4.6.15.1 6.6.3 4.6.16.1 6.6.4 4.6.17.1 6.6.4.1 4.6.18.1 6.6.4.2 4.6.19.1 6.7.0 4.6.2.1 6.7.1 4.6.20 6.8.0 4.6.20.2 6.8.1 4.6.21.1 6.8.2 4.6.22 6.8.2.1 4.6.22.2 6.8.3 4.6.23.1 6.9.0 4.6.24 6.9.1 4.6.24.2 4.6.25.1 4.6.26 4.6.26.2 4.6.3.1 4.6.4.1 4.6.5.1 4.6.6.1 4.6.7.1 4.6.8.1 4.6.9.1 4.7 4.7.0.2 4.7.1.1 4.7.2.1 4.7.3.1 4.7.4.1 4.8 4.8.0.2 4.8.1.1 4.8.2.1 4.9.0.1 4.9.0.2 4.9.0.4 4.9.1 4.9.1.2 4.9.10.1 4.9.11.1 4.9.12.1 4.9.13.1 4.9.14.1 4.9.2.1 4.9.3 4.9.3.1 4.9.3.3 4.9.4.1 4.9.5.1 4.9.6.1 4.9.7.1 4.9.8.1 4.9.9.1 5.0.0 5.0.0.1 5.0.0.3 5.0.1.1 5.0.1.2 5.0.2 5.0.2.2 5.0.2.3 5.0.3 5.0.3.2 5.0.3.3 5.1.0.1 5.1.0.2
the-events-calendar / common / src / Tribe / Template_Factory.php
the-events-calendar / common / src / Tribe Last commit date
Admin 8 years ago Ajax 8 years ago Asset 8 years ago Customizer 8 years ago Documentation 8 years ago Duplicate 8 years ago Image 8 years ago JSON_LD 8 years ago Languages 8 years ago Log 8 years ago Meta 8 years ago PUE 8 years ago Process 8 years ago REST 8 years ago Service_Providers 8 years ago Support 8 years ago Tabbed_View 8 years ago Utils 8 years ago Validator 8 years ago Abstract_Deactivation.php 8 years ago App_Shop.php 8 years ago Assets.php 8 years ago Assets_Pipeline.php 8 years ago Autoloader.php 8 years ago Cache.php 8 years ago Cache_Listener.php 8 years ago Changelog_Reader.php 8 years ago Container.php 8 years ago Context.php 8 years ago Cost_Utils.php 8 years ago Credits.php 8 years ago Customizer.php 8 years ago Data.php 8 years ago Date_Utils.php 8 years ago Debug.php 8 years ago Dependency.php 8 years ago Deprecation.php 8 years ago Error.php 8 years ago Exception.php 8 years ago Extension.php 8 years ago Extension_Loader.php 8 years ago Field.php 8 years ago Field_Conditional.php 8 years ago Log.php 8 years ago Main.php 8 years ago Notices.php 8 years ago Plugin_Meta_Links.php 8 years ago Plugins.php 8 years ago Plugins_API.php 8 years ago Post_History.php 8 years ago Post_Transient.php 8 years ago Rewrite.php 8 years ago Settings.php 8 years ago Settings_Manager.php 8 years ago Settings_Tab.php 8 years ago Simple_Table.php 8 years ago Support.php 8 years ago Tabbed_View.php 8 years ago Template.php 8 years ago Template_Factory.php 8 years ago Template_Part_Cache.php 8 years ago Templates.php 8 years ago Terms.php 8 years ago Timezones.php 8 years ago Tracker.php 8 years ago Validate.php 8 years ago View_Helpers.php 8 years ago
Template_Factory.php
193 lines
1 <?php
2 /**
3 * Template Factory
4 *
5 * The parent class for managing the view methods in core and addons
6 *
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 die( '-1' );
11 }
12
13 if ( class_exists( 'Tribe__Template_Factory' ) ) {
14 return;
15 }
16
17 class Tribe__Template_Factory {
18
19 /**
20 * Array of asset packages needed for this template
21 *
22 * @var array
23 **/
24 protected $asset_packages = array();
25
26 /**
27 * Static variable that holds array of vendor script handles, for adding to later deps.
28 *
29 * @static
30 * @var array
31 */
32 protected static $vendor_scripts = array();
33
34 /**
35 * Constant that holds the ajax hook suffix for the view
36 *
37 * @static
38 * @var string
39 */
40 const AJAX_HOOK = '';
41
42 /**
43 * Run include packages, set up hooks
44 *
45 * @return void
46 **/
47 public function __construct() {
48 $this->asset_packages();
49 }
50
51 /**
52 * Manage the asset packages defined for this template
53 *
54 * @return void
55 **/
56 protected function asset_packages() {
57 foreach ( $this->asset_packages as $asset_package ) {
58 $this->asset_package( $asset_package );
59 }
60 }
61
62 /**
63 * Handles an asset package request.
64 *
65 * @param string $name The asset name in the `hyphen-separated-format`
66 * @param array $deps An array of dependency handles
67 * @param string $vendor_url URL to vendor scripts and styles dir
68 * @param string $prefix MT script and style prefix
69 * @param Tribe__Main $tec An instance of the main plugin class
70 */
71 protected static function handle_asset_package_request( $name, $deps, $vendor_url, $prefix, $tec ) {
72
73 $asset = self::get_asset_factory_instance( $name );
74
75 self::prepare_asset_package_request( $asset, $name, $deps, $vendor_url, $prefix, $tec );
76 }
77
78 /**
79 * initializes asset package request
80 *
81 * @param object $asset The Tribe__*Asset object
82 * @param string $name The asset name in the `hyphen-separated-format`
83 * @param array $deps An array of dependency handles
84 * @param string $vendor_url URL to vendor scripts and styles dir
85 * @param string $prefix MT script and style prefix
86 * @param Tribe__Main $common An instance of the main plugin class
87 */
88 protected static function prepare_asset_package_request( $asset, $name, $deps, $vendor_url, $prefix, $common ) {
89 if ( ! $asset ) {
90 do_action( $prefix . '-' . $name );
91
92 return;
93 }
94
95 $asset->set_name( $name );
96 $asset->set_deps( $deps );
97 $asset->set_vendor_url( $vendor_url );
98 $asset->set_prefix( $prefix );
99 $asset->set_tec( $common );
100
101 $asset->handle();
102 }
103
104 /**
105 * Retrieves the appropriate asset factory instance
106 */
107 protected static function get_asset_factory_instance( $name ) {
108 $asset = Tribe__Asset__Factory::instance()->make_for_name( $name );
109 return $asset;
110 }
111
112 /**
113 * @param string $script_handle A registered script handle.
114 */
115 public static function add_vendor_script( $script_handle ) {
116 if ( in_array( $script_handle, self::$vendor_scripts ) ) {
117 return;
118 }
119 self::$vendor_scripts[] = $script_handle;
120 }
121
122 /**
123 * @return string[] An array of registered vendor script handles.
124 */
125 public static function get_vendor_scripts() {
126 return self::$vendor_scripts;
127 }
128
129 /**
130 * Asset calls for vendor packages
131 *
132 * @param string $name
133 * @param array $deps Dependents
134 */
135 public static function asset_package( $name, $deps = array() ) {
136
137 $common = Tribe__Main::instance();
138 $prefix = 'tribe-events';
139
140 // setup plugin resources & 3rd party vendor urls
141 $vendor_url = trailingslashit( $common->plugin_url ) . 'vendor/';
142
143 self::handle_asset_package_request( $name, $deps, $vendor_url, $prefix, $common );
144 }
145
146 /**
147 * Returns the path to a minified version of a js or css file, if it exists.
148 * If the file does not exist, returns false.
149 *
150 * @param string $url The path or URL to the un-minified file.
151 * @param bool $default_to_original Whether to just return original path if min version not found.
152 *
153 * @return string|false The path/url to minified version or false, if file not found.
154 */
155 public static function getMinFile( $url, $default_to_original = false ) {
156 if ( ! defined( 'SCRIPT_DEBUG' ) || SCRIPT_DEBUG === false ) {
157 if ( substr( $url, - 3, 3 ) == '.js' ) {
158 $url_new = substr_replace( $url, '.min', - 3, 0 );
159 }
160 if ( substr( $url, - 4, 4 ) == '.css' ) {
161 $url_new = substr_replace( $url, '.min', - 4, 0 );
162 }
163 }
164
165 if ( isset( $url_new ) && file_exists( str_replace( content_url(), WP_CONTENT_DIR, $url_new ) ) ) {
166 return $url_new;
167 } elseif ( $default_to_original ) {
168 return $url;
169 } else {
170 return false;
171 }
172 }
173
174 /**
175 * Playing ping-pong with WooCommerce. They keep changing their script.
176 * See https://github.com/woothemes/woocommerce/issues/3623
177 */
178 public static function get_placeholder_handle() {
179 $placeholder_handle = 'jquery-placeholder';
180
181 global $woocommerce;
182 if (
183 class_exists( 'Woocommerce' ) &&
184 version_compare( $woocommerce->version, '2.0.11', '>=' ) &&
185 version_compare( $woocommerce->version, '2.0.13', '<=' )
186 ) {
187 $placeholder_handle = 'tribe-placeholder';
188 }
189
190 return $placeholder_handle;
191 }
192 }
193