@@ -5,9 +5,9 @@ |
||
| 5 | 5 | interface SessionIdentifierInterface |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - /** |
|
| 9 | - * @return string |
|
| 10 | - */ |
|
| 11 | - public function id(); |
|
| 8 | + /** |
|
| 9 | + * @return string |
|
| 10 | + */ |
|
| 11 | + public function id(); |
|
| 12 | 12 | |
| 13 | 13 | } |
| 14 | 14 | \ No newline at end of file |
@@ -199,13 +199,13 @@ discard block |
||
| 199 | 199 | ); |
| 200 | 200 | return CollectionLoader::ENTITY_ADDED; |
| 201 | 201 | } |
| 202 | - do_action( |
|
| 203 | - 'FHEE__CollectionLoader__addEntityToCollection__entity_not_added', |
|
| 204 | - $this, |
|
| 205 | - $this->collection_details->collectionName(), |
|
| 206 | - $this->collection_details |
|
| 207 | - ); |
|
| 208 | - return CollectionLoader::ENTITY_NOT_ADDED; |
|
| 202 | + do_action( |
|
| 203 | + 'FHEE__CollectionLoader__addEntityToCollection__entity_not_added', |
|
| 204 | + $this, |
|
| 205 | + $this->collection_details->collectionName(), |
|
| 206 | + $this->collection_details |
|
| 207 | + ); |
|
| 208 | + return CollectionLoader::ENTITY_NOT_ADDED; |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | |
@@ -220,37 +220,37 @@ discard block |
||
| 220 | 220 | * @throws \EventEspresso\core\exceptions\InvalidEntityException |
| 221 | 221 | */ |
| 222 | 222 | protected function setIdentifier( $entity, $identifier ) { |
| 223 | - switch($this->collection_details->identifierType()) { |
|
| 224 | - // every unique object gets added to the collection, but not duplicates of the exact same object |
|
| 225 | - case CollectionDetails::ID_OBJECT_HASH : |
|
| 226 | - $identifier = spl_object_hash($entity); |
|
| 227 | - break; |
|
| 228 | - // only one entity per class can be added to collection, like a singleton |
|
| 229 | - case CollectionDetails::ID_CLASS_NAME : |
|
| 230 | - $identifier = get_class($entity); |
|
| 231 | - break; |
|
| 232 | - // objects added to the collection based on entity callback, so the entity itself decides |
|
| 233 | - case CollectionDetails::ID_CALLBACK_METHOD : |
|
| 234 | - $identifier_callback = $this->collection_details->identifierCallback(); |
|
| 235 | - if ( ! method_exists($entity, $identifier_callback)) { |
|
| 236 | - throw new InvalidEntityException( |
|
| 237 | - $entity, |
|
| 238 | - $this->collection_details->getCollectionInterface(), |
|
| 239 | - sprintf( |
|
| 240 | - __( |
|
| 241 | - 'The current collection is configured to use a method named "%1$s" when setting or retrieving objects. The supplied entity is an instance |
|
| 223 | + switch($this->collection_details->identifierType()) { |
|
| 224 | + // every unique object gets added to the collection, but not duplicates of the exact same object |
|
| 225 | + case CollectionDetails::ID_OBJECT_HASH : |
|
| 226 | + $identifier = spl_object_hash($entity); |
|
| 227 | + break; |
|
| 228 | + // only one entity per class can be added to collection, like a singleton |
|
| 229 | + case CollectionDetails::ID_CLASS_NAME : |
|
| 230 | + $identifier = get_class($entity); |
|
| 231 | + break; |
|
| 232 | + // objects added to the collection based on entity callback, so the entity itself decides |
|
| 233 | + case CollectionDetails::ID_CALLBACK_METHOD : |
|
| 234 | + $identifier_callback = $this->collection_details->identifierCallback(); |
|
| 235 | + if ( ! method_exists($entity, $identifier_callback)) { |
|
| 236 | + throw new InvalidEntityException( |
|
| 237 | + $entity, |
|
| 238 | + $this->collection_details->getCollectionInterface(), |
|
| 239 | + sprintf( |
|
| 240 | + __( |
|
| 241 | + 'The current collection is configured to use a method named "%1$s" when setting or retrieving objects. The supplied entity is an instance |
|
| 242 | 242 | of "%2$s", but does not contain this method.', |
| 243 | - 'event_espresso' |
|
| 244 | - ), |
|
| 245 | - $identifier_callback, |
|
| 246 | - get_class($entity) |
|
| 247 | - ) |
|
| 248 | - ); |
|
| 249 | - } |
|
| 250 | - $identifier = $entity->{$identifier_callback}(); |
|
| 251 | - break; |
|
| 252 | - |
|
| 253 | - } |
|
| 243 | + 'event_espresso' |
|
| 244 | + ), |
|
| 245 | + $identifier_callback, |
|
| 246 | + get_class($entity) |
|
| 247 | + ) |
|
| 248 | + ); |
|
| 249 | + } |
|
| 250 | + $identifier = $entity->{$identifier_callback}(); |
|
| 251 | + break; |
|
| 252 | + |
|
| 253 | + } |
|
| 254 | 254 | return apply_filters( |
| 255 | 255 | 'FHEE__CollectionLoader__addEntityToCollection__identifier', |
| 256 | 256 | $identifier, |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | // with these parameters |
| 141 | 141 | $cache_id .= filter_input(INPUT_SERVER, 'QUERY_STRING', FILTER_SANITIZE_URL); |
| 142 | 142 | // then md5 the above to control it's length, add all of our prefixes, and truncate |
| 143 | - return substr($this->cachePrefix() . $id_prefix . '-' . md5($cache_id), 0, 182); |
|
| 143 | + return substr($this->cachePrefix().$id_prefix.'-'.md5($cache_id), 0, 182); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | |
@@ -170,9 +170,9 @@ discard block |
||
| 170 | 170 | return ' |
| 171 | 171 | <div class="ee-cached-content-notice" style="position:fixed; bottom:0; left: 0;"> |
| 172 | 172 | <p style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;margin:0 0 3px 5px"> |
| 173 | - <b>' . $type . '</b><span style="color:#999"> : </span> |
|
| 174 | - <span>' . $cache_id . '</span> |
|
| 175 | - <span style="margin-left:2em;">' . __FILE__ . '</span> |
|
| 173 | + <b>' . $type.'</b><span style="color:#999"> : </span> |
|
| 174 | + <span>' . $cache_id.'</span> |
|
| 175 | + <span style="margin-left:2em;">' . __FILE__.'</span> |
|
| 176 | 176 | </p> |
| 177 | 177 | </div>'; |
| 178 | 178 | } |
@@ -19,140 +19,140 @@ discard block |
||
| 19 | 19 | class BasicCacheManager implements CacheManagerInterface |
| 20 | 20 | { |
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * @type string |
|
| 24 | - */ |
|
| 25 | - const CACHE_PREFIX = 'ee_cache_'; |
|
| 26 | - |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * @var CacheStorageInterface $cache_storage |
|
| 30 | - */ |
|
| 31 | - private $cache_storage; |
|
| 32 | - |
|
| 33 | - |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * BasicCacheManager constructor. |
|
| 37 | - * |
|
| 38 | - * @param CacheStorageInterface $cache_storage [required] |
|
| 39 | - */ |
|
| 40 | - public function __construct(CacheStorageInterface $cache_storage) |
|
| 41 | - { |
|
| 42 | - $this->cache_storage = $cache_storage; |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * returns a string that will be prepended to all cache identifiers |
|
| 49 | - * |
|
| 50 | - * @return string |
|
| 51 | - */ |
|
| 52 | - public function cachePrefix() |
|
| 53 | - { |
|
| 54 | - return BasicCacheManager::CACHE_PREFIX; |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * @param string $id_prefix [required] Prepended to all cache IDs. Can be helpful in finding specific cache types. |
|
| 61 | - * May also be helpful to include an additional specific identifier, |
|
| 62 | - * such as a post ID as part of the $id_prefix so that individual caches |
|
| 63 | - * can be found and/or cleared. ex: "venue-28", or "shortcode-156". |
|
| 64 | - * BasicCacheManager::CACHE_PREFIX will also be prepended to the cache id. |
|
| 65 | - * @param string $cache_id [required] Additional identifying details that make this cache unique. |
|
| 66 | - * It is advisable to use some of the actual data |
|
| 67 | - * that is used to generate the content being cached, |
|
| 68 | - * in order to guarantee that the cache id is unique for that content. |
|
| 69 | - * The cache id will be md5'd before usage to make it more db friendly, |
|
| 70 | - * and the entire cache id string will be truncated to 190 characters. |
|
| 71 | - * @param Closure $callback [required] since the point of caching is to avoid generating content when not |
|
| 72 | - * necessary, |
|
| 73 | - * we wrap our content creation in a Closure so that it is not executed until needed. |
|
| 74 | - * @param int $expiration |
|
| 75 | - * @return Closure|mixed |
|
| 76 | - */ |
|
| 77 | - public function get($id_prefix, $cache_id, Closure $callback, $expiration = HOUR_IN_SECONDS) |
|
| 78 | - { |
|
| 79 | - $content = ''; |
|
| 80 | - $expiration = absint( |
|
| 81 | - apply_filters( |
|
| 82 | - 'FHEE__CacheManager__get__cache_expiration', |
|
| 83 | - $expiration, |
|
| 84 | - $id_prefix, |
|
| 85 | - $cache_id |
|
| 86 | - ) |
|
| 87 | - ); |
|
| 88 | - $cache_id = $this->generateCacheIdentifier($id_prefix, $cache_id); |
|
| 89 | - // is caching enabled for this content ? |
|
| 90 | - if ($expiration) { |
|
| 91 | - $content = $this->cache_storage->get($cache_id); |
|
| 92 | - } |
|
| 93 | - // any existing content ? |
|
| 94 | - if (empty($content)) { |
|
| 95 | - // nope! let's generate some new stuff |
|
| 96 | - $content = $callback(); |
|
| 97 | - // save the new content if caching is enabled |
|
| 98 | - if ($expiration) { |
|
| 99 | - $this->cache_storage->add($cache_id, $content, $expiration); |
|
| 100 | - if (EE_DEBUG) { |
|
| 101 | - $content .= $this->displayCacheNotice($cache_id, 'REFRESH CACHE'); |
|
| 102 | - } |
|
| 103 | - } |
|
| 104 | - } else { |
|
| 105 | - if (EE_DEBUG) { |
|
| 106 | - $content .= $this->displayCacheNotice($cache_id, 'CACHED CONTENT'); |
|
| 107 | - } |
|
| 108 | - } |
|
| 109 | - return $content; |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * Generates a unique identifier string for the cache |
|
| 116 | - * |
|
| 117 | - * @param string $id_prefix [required] see BasicCacheManager::get() |
|
| 118 | - * @param string $cache_id [required] see BasicCacheManager::get() |
|
| 119 | - * @return string |
|
| 120 | - */ |
|
| 121 | - private function generateCacheIdentifier($id_prefix, $cache_id) |
|
| 122 | - { |
|
| 123 | - // let's make the cached content unique for this "page" |
|
| 124 | - $cache_id .= filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_URL); |
|
| 125 | - // with these parameters |
|
| 126 | - $cache_id .= filter_input(INPUT_SERVER, 'QUERY_STRING', FILTER_SANITIZE_URL); |
|
| 127 | - // then md5 the above to control it's length, add all of our prefixes, and truncate |
|
| 128 | - return substr($this->cachePrefix() . $id_prefix . '-' . md5($cache_id), 0, 182); |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * @param array|string $cache_id [required] Could be an ID prefix affecting many caches |
|
| 135 | - * or a specific ID targeting a single cache item |
|
| 136 | - * @return void |
|
| 137 | - */ |
|
| 138 | - public function clear($cache_id) |
|
| 139 | - { |
|
| 140 | - // ensure incoming arg is in an array |
|
| 141 | - $cache_id = is_array($cache_id) ? $cache_id : array($cache_id); |
|
| 142 | - // delete corresponding transients for the supplied id prefix |
|
| 143 | - $this->cache_storage->deleteMany($cache_id); |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - |
|
| 147 | - |
|
| 148 | - /** |
|
| 149 | - * @param array|string $cache_id [required] Could be an ID prefix affecting many caches |
|
| 150 | - * or a specific ID targeting a single cache item |
|
| 151 | - * @param string $type |
|
| 152 | - * @return string |
|
| 153 | - */ |
|
| 154 | - private function displayCacheNotice($cache_id, $type) { |
|
| 155 | - return ' |
|
| 22 | + /** |
|
| 23 | + * @type string |
|
| 24 | + */ |
|
| 25 | + const CACHE_PREFIX = 'ee_cache_'; |
|
| 26 | + |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * @var CacheStorageInterface $cache_storage |
|
| 30 | + */ |
|
| 31 | + private $cache_storage; |
|
| 32 | + |
|
| 33 | + |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * BasicCacheManager constructor. |
|
| 37 | + * |
|
| 38 | + * @param CacheStorageInterface $cache_storage [required] |
|
| 39 | + */ |
|
| 40 | + public function __construct(CacheStorageInterface $cache_storage) |
|
| 41 | + { |
|
| 42 | + $this->cache_storage = $cache_storage; |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * returns a string that will be prepended to all cache identifiers |
|
| 49 | + * |
|
| 50 | + * @return string |
|
| 51 | + */ |
|
| 52 | + public function cachePrefix() |
|
| 53 | + { |
|
| 54 | + return BasicCacheManager::CACHE_PREFIX; |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * @param string $id_prefix [required] Prepended to all cache IDs. Can be helpful in finding specific cache types. |
|
| 61 | + * May also be helpful to include an additional specific identifier, |
|
| 62 | + * such as a post ID as part of the $id_prefix so that individual caches |
|
| 63 | + * can be found and/or cleared. ex: "venue-28", or "shortcode-156". |
|
| 64 | + * BasicCacheManager::CACHE_PREFIX will also be prepended to the cache id. |
|
| 65 | + * @param string $cache_id [required] Additional identifying details that make this cache unique. |
|
| 66 | + * It is advisable to use some of the actual data |
|
| 67 | + * that is used to generate the content being cached, |
|
| 68 | + * in order to guarantee that the cache id is unique for that content. |
|
| 69 | + * The cache id will be md5'd before usage to make it more db friendly, |
|
| 70 | + * and the entire cache id string will be truncated to 190 characters. |
|
| 71 | + * @param Closure $callback [required] since the point of caching is to avoid generating content when not |
|
| 72 | + * necessary, |
|
| 73 | + * we wrap our content creation in a Closure so that it is not executed until needed. |
|
| 74 | + * @param int $expiration |
|
| 75 | + * @return Closure|mixed |
|
| 76 | + */ |
|
| 77 | + public function get($id_prefix, $cache_id, Closure $callback, $expiration = HOUR_IN_SECONDS) |
|
| 78 | + { |
|
| 79 | + $content = ''; |
|
| 80 | + $expiration = absint( |
|
| 81 | + apply_filters( |
|
| 82 | + 'FHEE__CacheManager__get__cache_expiration', |
|
| 83 | + $expiration, |
|
| 84 | + $id_prefix, |
|
| 85 | + $cache_id |
|
| 86 | + ) |
|
| 87 | + ); |
|
| 88 | + $cache_id = $this->generateCacheIdentifier($id_prefix, $cache_id); |
|
| 89 | + // is caching enabled for this content ? |
|
| 90 | + if ($expiration) { |
|
| 91 | + $content = $this->cache_storage->get($cache_id); |
|
| 92 | + } |
|
| 93 | + // any existing content ? |
|
| 94 | + if (empty($content)) { |
|
| 95 | + // nope! let's generate some new stuff |
|
| 96 | + $content = $callback(); |
|
| 97 | + // save the new content if caching is enabled |
|
| 98 | + if ($expiration) { |
|
| 99 | + $this->cache_storage->add($cache_id, $content, $expiration); |
|
| 100 | + if (EE_DEBUG) { |
|
| 101 | + $content .= $this->displayCacheNotice($cache_id, 'REFRESH CACHE'); |
|
| 102 | + } |
|
| 103 | + } |
|
| 104 | + } else { |
|
| 105 | + if (EE_DEBUG) { |
|
| 106 | + $content .= $this->displayCacheNotice($cache_id, 'CACHED CONTENT'); |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | + return $content; |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + |
|
| 113 | + |
|
| 114 | + /** |
|
| 115 | + * Generates a unique identifier string for the cache |
|
| 116 | + * |
|
| 117 | + * @param string $id_prefix [required] see BasicCacheManager::get() |
|
| 118 | + * @param string $cache_id [required] see BasicCacheManager::get() |
|
| 119 | + * @return string |
|
| 120 | + */ |
|
| 121 | + private function generateCacheIdentifier($id_prefix, $cache_id) |
|
| 122 | + { |
|
| 123 | + // let's make the cached content unique for this "page" |
|
| 124 | + $cache_id .= filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_URL); |
|
| 125 | + // with these parameters |
|
| 126 | + $cache_id .= filter_input(INPUT_SERVER, 'QUERY_STRING', FILTER_SANITIZE_URL); |
|
| 127 | + // then md5 the above to control it's length, add all of our prefixes, and truncate |
|
| 128 | + return substr($this->cachePrefix() . $id_prefix . '-' . md5($cache_id), 0, 182); |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * @param array|string $cache_id [required] Could be an ID prefix affecting many caches |
|
| 135 | + * or a specific ID targeting a single cache item |
|
| 136 | + * @return void |
|
| 137 | + */ |
|
| 138 | + public function clear($cache_id) |
|
| 139 | + { |
|
| 140 | + // ensure incoming arg is in an array |
|
| 141 | + $cache_id = is_array($cache_id) ? $cache_id : array($cache_id); |
|
| 142 | + // delete corresponding transients for the supplied id prefix |
|
| 143 | + $this->cache_storage->deleteMany($cache_id); |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + |
|
| 147 | + |
|
| 148 | + /** |
|
| 149 | + * @param array|string $cache_id [required] Could be an ID prefix affecting many caches |
|
| 150 | + * or a specific ID targeting a single cache item |
|
| 151 | + * @param string $type |
|
| 152 | + * @return string |
|
| 153 | + */ |
|
| 154 | + private function displayCacheNotice($cache_id, $type) { |
|
| 155 | + return ' |
|
| 156 | 156 | <div class="ee-cached-content-notice" style="position:fixed; bottom:0; left: 0;"> |
| 157 | 157 | <p style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;margin:0 0 3px 5px"> |
| 158 | 158 | <b>' . $type . '</b><span style="color:#999"> : </span> |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | <span style="margin-left:2em;">' . __FILE__ . '</span> |
| 161 | 161 | </p> |
| 162 | 162 | </div>'; |
| 163 | - } |
|
| 163 | + } |
|
| 164 | 164 | |
| 165 | 165 | } |
| 166 | 166 | // End of file BasicCacheManager.php |
@@ -18,93 +18,93 @@ |
||
| 18 | 18 | class PostRelatedCacheManager extends BasicCacheManager |
| 19 | 19 | { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @type string |
|
| 23 | - */ |
|
| 24 | - const POST_CACHE_PREFIX = 'ee_cache_post_'; |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * wp-option option_name for tracking post related cache |
|
| 28 | - * |
|
| 29 | - * @type string |
|
| 30 | - */ |
|
| 31 | - const POST_CACHE_OPTIONS_KEY = 'ee_post_cache'; |
|
| 32 | - |
|
| 33 | - |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * PostRelatedCacheManager constructor. |
|
| 37 | - * |
|
| 38 | - * @param CacheStorageInterface $cache_storage |
|
| 39 | - * @param SessionIdentifierInterface $session |
|
| 40 | - */ |
|
| 41 | - public function __construct(CacheStorageInterface $cache_storage, SessionIdentifierInterface $session) |
|
| 42 | - { |
|
| 43 | - parent::__construct($cache_storage, $session); |
|
| 44 | - add_action('save_post', array($this, 'clearPostRelatedCache')); |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * returns a string that will be prepended to all cache identifiers |
|
| 51 | - * |
|
| 52 | - * @return string |
|
| 53 | - */ |
|
| 54 | - public function cachePrefix() |
|
| 55 | - { |
|
| 56 | - return PostRelatedCacheManager::POST_CACHE_PREFIX; |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * If you are caching content that pertains to a Post of any type, |
|
| 63 | - * then it is recommended to pass the post id and cache id prefix to this method |
|
| 64 | - * so that it can be added to the post related cache tracking. |
|
| 65 | - * Then, whenever that post is updated, the cache will automatically be deleted, |
|
| 66 | - * which helps to ensure that outdated cache content will not be served |
|
| 67 | - * |
|
| 68 | - * @param int $post_ID [required] |
|
| 69 | - * @param string $id_prefix [required] Appended to all cache IDs. Can be helpful in finding specific cache types. |
|
| 70 | - * May also be helpful to include an additional specific identifier, |
|
| 71 | - * such as a post ID as part of the $id_prefix so that individual caches |
|
| 72 | - * can be found and/or cleared. ex: "venue-28", or "shortcode-156". |
|
| 73 | - * BasicCacheManager::CACHE_PREFIX will also be prepended to the cache id. |
|
| 74 | - */ |
|
| 75 | - public function clearPostRelatedCacheOnUpdate($post_ID, $id_prefix) |
|
| 76 | - { |
|
| 77 | - $post_related_cache = (array)get_option(PostRelatedCacheManager::POST_CACHE_OPTIONS_KEY, array()); |
|
| 78 | - // if post is not already being tracked |
|
| 79 | - if ( ! isset($post_related_cache[$post_ID])) { |
|
| 80 | - // add array to add cache ids to |
|
| 81 | - $post_related_cache[$post_ID] = array(); |
|
| 82 | - } |
|
| 83 | - // add cache id to be tracked |
|
| 84 | - $post_related_cache[$post_ID][] = $id_prefix; |
|
| 85 | - update_option(PostRelatedCacheManager::POST_CACHE_OPTIONS_KEY, $post_related_cache); |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * callback hooked into the WordPress "save_post" action |
|
| 92 | - * deletes any cache content associated with the post |
|
| 93 | - * |
|
| 94 | - * @param int $post_ID [required] |
|
| 95 | - */ |
|
| 96 | - public function clearPostRelatedCache($post_ID) |
|
| 97 | - { |
|
| 98 | - $post_related_cache = (array)get_option(PostRelatedCacheManager::POST_CACHE_OPTIONS_KEY, array()); |
|
| 99 | - // if post is not being tracked |
|
| 100 | - if ( ! isset($post_related_cache[$post_ID])) { |
|
| 101 | - return; |
|
| 102 | - } |
|
| 103 | - // get cache id prefixes for post, and delete their corresponding transients |
|
| 104 | - $this->clear($post_related_cache[$post_ID]); |
|
| 105 | - unset($post_related_cache[$post_ID]); |
|
| 106 | - update_option(PostRelatedCacheManager::POST_CACHE_OPTIONS_KEY, $post_related_cache); |
|
| 107 | - } |
|
| 21 | + /** |
|
| 22 | + * @type string |
|
| 23 | + */ |
|
| 24 | + const POST_CACHE_PREFIX = 'ee_cache_post_'; |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * wp-option option_name for tracking post related cache |
|
| 28 | + * |
|
| 29 | + * @type string |
|
| 30 | + */ |
|
| 31 | + const POST_CACHE_OPTIONS_KEY = 'ee_post_cache'; |
|
| 32 | + |
|
| 33 | + |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * PostRelatedCacheManager constructor. |
|
| 37 | + * |
|
| 38 | + * @param CacheStorageInterface $cache_storage |
|
| 39 | + * @param SessionIdentifierInterface $session |
|
| 40 | + */ |
|
| 41 | + public function __construct(CacheStorageInterface $cache_storage, SessionIdentifierInterface $session) |
|
| 42 | + { |
|
| 43 | + parent::__construct($cache_storage, $session); |
|
| 44 | + add_action('save_post', array($this, 'clearPostRelatedCache')); |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * returns a string that will be prepended to all cache identifiers |
|
| 51 | + * |
|
| 52 | + * @return string |
|
| 53 | + */ |
|
| 54 | + public function cachePrefix() |
|
| 55 | + { |
|
| 56 | + return PostRelatedCacheManager::POST_CACHE_PREFIX; |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * If you are caching content that pertains to a Post of any type, |
|
| 63 | + * then it is recommended to pass the post id and cache id prefix to this method |
|
| 64 | + * so that it can be added to the post related cache tracking. |
|
| 65 | + * Then, whenever that post is updated, the cache will automatically be deleted, |
|
| 66 | + * which helps to ensure that outdated cache content will not be served |
|
| 67 | + * |
|
| 68 | + * @param int $post_ID [required] |
|
| 69 | + * @param string $id_prefix [required] Appended to all cache IDs. Can be helpful in finding specific cache types. |
|
| 70 | + * May also be helpful to include an additional specific identifier, |
|
| 71 | + * such as a post ID as part of the $id_prefix so that individual caches |
|
| 72 | + * can be found and/or cleared. ex: "venue-28", or "shortcode-156". |
|
| 73 | + * BasicCacheManager::CACHE_PREFIX will also be prepended to the cache id. |
|
| 74 | + */ |
|
| 75 | + public function clearPostRelatedCacheOnUpdate($post_ID, $id_prefix) |
|
| 76 | + { |
|
| 77 | + $post_related_cache = (array)get_option(PostRelatedCacheManager::POST_CACHE_OPTIONS_KEY, array()); |
|
| 78 | + // if post is not already being tracked |
|
| 79 | + if ( ! isset($post_related_cache[$post_ID])) { |
|
| 80 | + // add array to add cache ids to |
|
| 81 | + $post_related_cache[$post_ID] = array(); |
|
| 82 | + } |
|
| 83 | + // add cache id to be tracked |
|
| 84 | + $post_related_cache[$post_ID][] = $id_prefix; |
|
| 85 | + update_option(PostRelatedCacheManager::POST_CACHE_OPTIONS_KEY, $post_related_cache); |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + |
|
| 89 | + |
|
| 90 | + /** |
|
| 91 | + * callback hooked into the WordPress "save_post" action |
|
| 92 | + * deletes any cache content associated with the post |
|
| 93 | + * |
|
| 94 | + * @param int $post_ID [required] |
|
| 95 | + */ |
|
| 96 | + public function clearPostRelatedCache($post_ID) |
|
| 97 | + { |
|
| 98 | + $post_related_cache = (array)get_option(PostRelatedCacheManager::POST_CACHE_OPTIONS_KEY, array()); |
|
| 99 | + // if post is not being tracked |
|
| 100 | + if ( ! isset($post_related_cache[$post_ID])) { |
|
| 101 | + return; |
|
| 102 | + } |
|
| 103 | + // get cache id prefixes for post, and delete their corresponding transients |
|
| 104 | + $this->clear($post_related_cache[$post_ID]); |
|
| 105 | + unset($post_related_cache[$post_ID]); |
|
| 106 | + update_option(PostRelatedCacheManager::POST_CACHE_OPTIONS_KEY, $post_related_cache); |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | 109 | |
| 110 | 110 | } |
@@ -32,211 +32,211 @@ |
||
| 32 | 32 | class ShortcodesManager |
| 33 | 33 | { |
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @var LegacyShortcodesManager $legacy_shortcodes_manager |
|
| 37 | - */ |
|
| 38 | - private $legacy_shortcodes_manager; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * @var ShortcodeInterface[] $shortcodes |
|
| 42 | - */ |
|
| 43 | - private $shortcodes; |
|
| 44 | - |
|
| 45 | - |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * ShortcodesManager constructor |
|
| 49 | - * |
|
| 50 | - * @param LegacyShortcodesManager $legacy_shortcodes_manager |
|
| 51 | - */ |
|
| 52 | - public function __construct(LegacyShortcodesManager $legacy_shortcodes_manager) { |
|
| 53 | - $this->legacy_shortcodes_manager = $legacy_shortcodes_manager; |
|
| 54 | - // assemble a list of installed and active shortcodes |
|
| 55 | - add_action( |
|
| 56 | - 'AHEE__EE_System__register_shortcodes_modules_and_widgets', |
|
| 57 | - array($this, 'registerShortcodes'), |
|
| 58 | - 999 |
|
| 59 | - ); |
|
| 60 | - // call add_shortcode() for all installed shortcodes |
|
| 61 | - add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'addShortcodes')); |
|
| 62 | - // check content for shortcodes the old way |
|
| 63 | - add_action('parse_query', array($this->legacy_shortcodes_manager, 'initializeShortcodes'), 5); |
|
| 64 | - // check content for shortcodes the NEW more efficient way |
|
| 65 | - add_action('wp_head', array($this, 'wpHead'), 0); |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * @return CollectionInterface|ShortcodeInterface[] |
|
| 72 | - * @throws InvalidIdentifierException |
|
| 73 | - * @throws InvalidInterfaceException |
|
| 74 | - * @throws InvalidFilePathException |
|
| 75 | - * @throws InvalidEntityException |
|
| 76 | - * @throws InvalidDataTypeException |
|
| 77 | - * @throws InvalidClassException |
|
| 78 | - */ |
|
| 79 | - public function getShortcodes() |
|
| 80 | - { |
|
| 81 | - if ( ! $this->shortcodes instanceof CollectionInterface) { |
|
| 82 | - $this->shortcodes = $this->loadShortcodesCollection(); |
|
| 83 | - } |
|
| 84 | - return $this->shortcodes; |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * @return CollectionInterface|ShortcodeInterface[] |
|
| 91 | - * @throws InvalidIdentifierException |
|
| 92 | - * @throws InvalidInterfaceException |
|
| 93 | - * @throws InvalidFilePathException |
|
| 94 | - * @throws InvalidEntityException |
|
| 95 | - * @throws InvalidDataTypeException |
|
| 96 | - * @throws InvalidClassException |
|
| 97 | - */ |
|
| 98 | - protected function loadShortcodesCollection() |
|
| 99 | - { |
|
| 100 | - $loader = new CollectionLoader( |
|
| 101 | - new CollectionDetails( |
|
| 102 | - // collection name |
|
| 103 | - 'shortcodes', |
|
| 104 | - // collection interface |
|
| 105 | - 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
| 106 | - // FQCNs for classes to add (all classes within that namespace will be loaded) |
|
| 107 | - array('EventEspresso\core\domain\entities\shortcodes'), |
|
| 108 | - // filepaths to classes to add |
|
| 109 | - array(), |
|
| 110 | - // file mask to use if parsing folder for files to add |
|
| 111 | - '', |
|
| 112 | - // what to use as identifier for collection entities |
|
| 113 | - // using CLASS NAME prevents duplicates (works like a singleton) |
|
| 114 | - CollectionDetails::ID_CLASS_NAME |
|
| 115 | - ) |
|
| 116 | - ); |
|
| 117 | - return $loader->getCollection(); |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * @return void |
|
| 124 | - * @throws DomainException |
|
| 125 | - * @throws InvalidInterfaceException |
|
| 126 | - * @throws InvalidIdentifierException |
|
| 127 | - * @throws InvalidFilePathException |
|
| 128 | - * @throws InvalidEntityException |
|
| 129 | - * @throws InvalidDataTypeException |
|
| 130 | - * @throws InvalidClassException |
|
| 131 | - */ |
|
| 132 | - public function registerShortcodes() |
|
| 133 | - { |
|
| 134 | - try { |
|
| 135 | - $this->shortcodes = apply_filters( |
|
| 136 | - 'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection', |
|
| 137 | - $this->getShortcodes() |
|
| 138 | - ); |
|
| 139 | - if (! $this->shortcodes instanceof CollectionInterface) { |
|
| 140 | - throw new InvalidEntityException( |
|
| 141 | - $this->shortcodes, |
|
| 142 | - 'CollectionInterface', |
|
| 143 | - sprintf( |
|
| 144 | - esc_html__( |
|
| 145 | - 'The "FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection" filter must return a Collection of EspressoShortcode objects. "%1$s" was received instead.', |
|
| 146 | - 'event_espresso' |
|
| 147 | - ), |
|
| 148 | - is_object($this->shortcodes) ? get_class($this->shortcodes) : gettype($this->shortcodes) |
|
| 149 | - ) |
|
| 150 | - ); |
|
| 151 | - } |
|
| 152 | - $this->legacy_shortcodes_manager->registerShortcodes(); |
|
| 153 | - } catch (Exception $exception) { |
|
| 154 | - new ExceptionStackTraceDisplay($exception); |
|
| 155 | - } |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - |
|
| 159 | - |
|
| 160 | - /** |
|
| 161 | - * @return void |
|
| 162 | - */ |
|
| 163 | - public function addShortcodes() |
|
| 164 | - { |
|
| 165 | - try { |
|
| 166 | - // cycle thru shortcode folders |
|
| 167 | - foreach ($this->shortcodes as $shortcode) { |
|
| 168 | - /** @var ShortcodeInterface $shortcode */ |
|
| 169 | - if ( $shortcode instanceof EnqueueAssetsInterface) { |
|
| 170 | - add_action('wp_enqueue_scripts', array($shortcode, 'registerScriptsAndStylesheets'), 10); |
|
| 171 | - add_action('wp_enqueue_scripts', array($shortcode, 'enqueueStylesheets'), 11); |
|
| 172 | - } |
|
| 173 | - // add_shortcode() if it has not already been added |
|
| 174 | - if ( ! shortcode_exists($shortcode->getTag())) { |
|
| 175 | - add_shortcode($shortcode->getTag(), array($shortcode, 'processShortcodeCallback')); |
|
| 176 | - } |
|
| 177 | - } |
|
| 178 | - $this->legacy_shortcodes_manager->addShortcodes(); |
|
| 179 | - } catch (Exception $exception) { |
|
| 180 | - new ExceptionStackTraceDisplay($exception); |
|
| 181 | - } |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - |
|
| 185 | - |
|
| 186 | - /** |
|
| 187 | - * callback for the "wp_head" hook point |
|
| 188 | - * checks posts for EE shortcodes, and initializes them, |
|
| 189 | - * then toggles filter switch that loads core default assets |
|
| 190 | - * |
|
| 191 | - * @return void |
|
| 192 | - */ |
|
| 193 | - public function wpHead() |
|
| 194 | - { |
|
| 195 | - global $wp_query; |
|
| 196 | - if (empty($wp_query->posts)) { |
|
| 197 | - return; |
|
| 198 | - } |
|
| 199 | - $load_assets = false; |
|
| 200 | - // array of posts displayed in current request |
|
| 201 | - $posts = is_array($wp_query->posts) ? $wp_query->posts : array($wp_query->posts); |
|
| 202 | - foreach ($posts as $post) { |
|
| 203 | - // now check post content and excerpt for EE shortcodes |
|
| 204 | - $load_assets = $this->parseContentForShortcodes($post->post_content) |
|
| 205 | - ? true |
|
| 206 | - : $load_assets; |
|
| 207 | - } |
|
| 208 | - if ($load_assets) { |
|
| 209 | - $this->legacy_shortcodes_manager->registry()->REQ->set_espresso_page(true); |
|
| 210 | - add_filter('FHEE_load_css', '__return_true'); |
|
| 211 | - add_filter('FHEE_load_js', '__return_true'); |
|
| 212 | - } |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - |
|
| 216 | - |
|
| 217 | - /** |
|
| 218 | - * checks supplied content against list of shortcodes, |
|
| 219 | - * then initializes any found shortcodes, and returns true. |
|
| 220 | - * returns false if no shortcodes found. |
|
| 221 | - * |
|
| 222 | - * @param string $content |
|
| 223 | - * @return bool |
|
| 224 | - */ |
|
| 225 | - public function parseContentForShortcodes($content) |
|
| 226 | - { |
|
| 227 | - $has_shortcode = false; |
|
| 228 | - if(empty($this->shortcodes)){ |
|
| 229 | - return $has_shortcode; |
|
| 230 | - } |
|
| 231 | - foreach ($this->shortcodes as $shortcode) { |
|
| 232 | - /** @var ShortcodeInterface $shortcode */ |
|
| 233 | - if (has_shortcode($content, $shortcode->getTag())) { |
|
| 234 | - $shortcode->initializeShortcode(); |
|
| 235 | - $has_shortcode = true; |
|
| 236 | - } |
|
| 237 | - } |
|
| 238 | - return $has_shortcode; |
|
| 239 | - } |
|
| 35 | + /** |
|
| 36 | + * @var LegacyShortcodesManager $legacy_shortcodes_manager |
|
| 37 | + */ |
|
| 38 | + private $legacy_shortcodes_manager; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * @var ShortcodeInterface[] $shortcodes |
|
| 42 | + */ |
|
| 43 | + private $shortcodes; |
|
| 44 | + |
|
| 45 | + |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * ShortcodesManager constructor |
|
| 49 | + * |
|
| 50 | + * @param LegacyShortcodesManager $legacy_shortcodes_manager |
|
| 51 | + */ |
|
| 52 | + public function __construct(LegacyShortcodesManager $legacy_shortcodes_manager) { |
|
| 53 | + $this->legacy_shortcodes_manager = $legacy_shortcodes_manager; |
|
| 54 | + // assemble a list of installed and active shortcodes |
|
| 55 | + add_action( |
|
| 56 | + 'AHEE__EE_System__register_shortcodes_modules_and_widgets', |
|
| 57 | + array($this, 'registerShortcodes'), |
|
| 58 | + 999 |
|
| 59 | + ); |
|
| 60 | + // call add_shortcode() for all installed shortcodes |
|
| 61 | + add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'addShortcodes')); |
|
| 62 | + // check content for shortcodes the old way |
|
| 63 | + add_action('parse_query', array($this->legacy_shortcodes_manager, 'initializeShortcodes'), 5); |
|
| 64 | + // check content for shortcodes the NEW more efficient way |
|
| 65 | + add_action('wp_head', array($this, 'wpHead'), 0); |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * @return CollectionInterface|ShortcodeInterface[] |
|
| 72 | + * @throws InvalidIdentifierException |
|
| 73 | + * @throws InvalidInterfaceException |
|
| 74 | + * @throws InvalidFilePathException |
|
| 75 | + * @throws InvalidEntityException |
|
| 76 | + * @throws InvalidDataTypeException |
|
| 77 | + * @throws InvalidClassException |
|
| 78 | + */ |
|
| 79 | + public function getShortcodes() |
|
| 80 | + { |
|
| 81 | + if ( ! $this->shortcodes instanceof CollectionInterface) { |
|
| 82 | + $this->shortcodes = $this->loadShortcodesCollection(); |
|
| 83 | + } |
|
| 84 | + return $this->shortcodes; |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * @return CollectionInterface|ShortcodeInterface[] |
|
| 91 | + * @throws InvalidIdentifierException |
|
| 92 | + * @throws InvalidInterfaceException |
|
| 93 | + * @throws InvalidFilePathException |
|
| 94 | + * @throws InvalidEntityException |
|
| 95 | + * @throws InvalidDataTypeException |
|
| 96 | + * @throws InvalidClassException |
|
| 97 | + */ |
|
| 98 | + protected function loadShortcodesCollection() |
|
| 99 | + { |
|
| 100 | + $loader = new CollectionLoader( |
|
| 101 | + new CollectionDetails( |
|
| 102 | + // collection name |
|
| 103 | + 'shortcodes', |
|
| 104 | + // collection interface |
|
| 105 | + 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
| 106 | + // FQCNs for classes to add (all classes within that namespace will be loaded) |
|
| 107 | + array('EventEspresso\core\domain\entities\shortcodes'), |
|
| 108 | + // filepaths to classes to add |
|
| 109 | + array(), |
|
| 110 | + // file mask to use if parsing folder for files to add |
|
| 111 | + '', |
|
| 112 | + // what to use as identifier for collection entities |
|
| 113 | + // using CLASS NAME prevents duplicates (works like a singleton) |
|
| 114 | + CollectionDetails::ID_CLASS_NAME |
|
| 115 | + ) |
|
| 116 | + ); |
|
| 117 | + return $loader->getCollection(); |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * @return void |
|
| 124 | + * @throws DomainException |
|
| 125 | + * @throws InvalidInterfaceException |
|
| 126 | + * @throws InvalidIdentifierException |
|
| 127 | + * @throws InvalidFilePathException |
|
| 128 | + * @throws InvalidEntityException |
|
| 129 | + * @throws InvalidDataTypeException |
|
| 130 | + * @throws InvalidClassException |
|
| 131 | + */ |
|
| 132 | + public function registerShortcodes() |
|
| 133 | + { |
|
| 134 | + try { |
|
| 135 | + $this->shortcodes = apply_filters( |
|
| 136 | + 'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection', |
|
| 137 | + $this->getShortcodes() |
|
| 138 | + ); |
|
| 139 | + if (! $this->shortcodes instanceof CollectionInterface) { |
|
| 140 | + throw new InvalidEntityException( |
|
| 141 | + $this->shortcodes, |
|
| 142 | + 'CollectionInterface', |
|
| 143 | + sprintf( |
|
| 144 | + esc_html__( |
|
| 145 | + 'The "FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection" filter must return a Collection of EspressoShortcode objects. "%1$s" was received instead.', |
|
| 146 | + 'event_espresso' |
|
| 147 | + ), |
|
| 148 | + is_object($this->shortcodes) ? get_class($this->shortcodes) : gettype($this->shortcodes) |
|
| 149 | + ) |
|
| 150 | + ); |
|
| 151 | + } |
|
| 152 | + $this->legacy_shortcodes_manager->registerShortcodes(); |
|
| 153 | + } catch (Exception $exception) { |
|
| 154 | + new ExceptionStackTraceDisplay($exception); |
|
| 155 | + } |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + |
|
| 159 | + |
|
| 160 | + /** |
|
| 161 | + * @return void |
|
| 162 | + */ |
|
| 163 | + public function addShortcodes() |
|
| 164 | + { |
|
| 165 | + try { |
|
| 166 | + // cycle thru shortcode folders |
|
| 167 | + foreach ($this->shortcodes as $shortcode) { |
|
| 168 | + /** @var ShortcodeInterface $shortcode */ |
|
| 169 | + if ( $shortcode instanceof EnqueueAssetsInterface) { |
|
| 170 | + add_action('wp_enqueue_scripts', array($shortcode, 'registerScriptsAndStylesheets'), 10); |
|
| 171 | + add_action('wp_enqueue_scripts', array($shortcode, 'enqueueStylesheets'), 11); |
|
| 172 | + } |
|
| 173 | + // add_shortcode() if it has not already been added |
|
| 174 | + if ( ! shortcode_exists($shortcode->getTag())) { |
|
| 175 | + add_shortcode($shortcode->getTag(), array($shortcode, 'processShortcodeCallback')); |
|
| 176 | + } |
|
| 177 | + } |
|
| 178 | + $this->legacy_shortcodes_manager->addShortcodes(); |
|
| 179 | + } catch (Exception $exception) { |
|
| 180 | + new ExceptionStackTraceDisplay($exception); |
|
| 181 | + } |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + |
|
| 185 | + |
|
| 186 | + /** |
|
| 187 | + * callback for the "wp_head" hook point |
|
| 188 | + * checks posts for EE shortcodes, and initializes them, |
|
| 189 | + * then toggles filter switch that loads core default assets |
|
| 190 | + * |
|
| 191 | + * @return void |
|
| 192 | + */ |
|
| 193 | + public function wpHead() |
|
| 194 | + { |
|
| 195 | + global $wp_query; |
|
| 196 | + if (empty($wp_query->posts)) { |
|
| 197 | + return; |
|
| 198 | + } |
|
| 199 | + $load_assets = false; |
|
| 200 | + // array of posts displayed in current request |
|
| 201 | + $posts = is_array($wp_query->posts) ? $wp_query->posts : array($wp_query->posts); |
|
| 202 | + foreach ($posts as $post) { |
|
| 203 | + // now check post content and excerpt for EE shortcodes |
|
| 204 | + $load_assets = $this->parseContentForShortcodes($post->post_content) |
|
| 205 | + ? true |
|
| 206 | + : $load_assets; |
|
| 207 | + } |
|
| 208 | + if ($load_assets) { |
|
| 209 | + $this->legacy_shortcodes_manager->registry()->REQ->set_espresso_page(true); |
|
| 210 | + add_filter('FHEE_load_css', '__return_true'); |
|
| 211 | + add_filter('FHEE_load_js', '__return_true'); |
|
| 212 | + } |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + |
|
| 216 | + |
|
| 217 | + /** |
|
| 218 | + * checks supplied content against list of shortcodes, |
|
| 219 | + * then initializes any found shortcodes, and returns true. |
|
| 220 | + * returns false if no shortcodes found. |
|
| 221 | + * |
|
| 222 | + * @param string $content |
|
| 223 | + * @return bool |
|
| 224 | + */ |
|
| 225 | + public function parseContentForShortcodes($content) |
|
| 226 | + { |
|
| 227 | + $has_shortcode = false; |
|
| 228 | + if(empty($this->shortcodes)){ |
|
| 229 | + return $has_shortcode; |
|
| 230 | + } |
|
| 231 | + foreach ($this->shortcodes as $shortcode) { |
|
| 232 | + /** @var ShortcodeInterface $shortcode */ |
|
| 233 | + if (has_shortcode($content, $shortcode->getTag())) { |
|
| 234 | + $shortcode->initializeShortcode(); |
|
| 235 | + $has_shortcode = true; |
|
| 236 | + } |
|
| 237 | + } |
|
| 238 | + return $has_shortcode; |
|
| 239 | + } |
|
| 240 | 240 | |
| 241 | 241 | } |
| 242 | 242 | // End of file ShortcodesManager.php |
@@ -21,219 +21,219 @@ |
||
| 21 | 21 | abstract class EspressoShortcode implements ShortcodeInterface |
| 22 | 22 | { |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * transient prefix |
|
| 26 | - * |
|
| 27 | - * @type string |
|
| 28 | - */ |
|
| 29 | - const CACHE_TRANSIENT_PREFIX = 'ee_sc_'; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * @var PostRelatedCacheManager $cache_manager |
|
| 33 | - */ |
|
| 34 | - private $cache_manager; |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * true if ShortcodeInterface::initializeShortcode() has been called |
|
| 38 | - * if false, then that will get called before processing |
|
| 39 | - * |
|
| 40 | - * @var boolean $initialized |
|
| 41 | - */ |
|
| 42 | - private $initialized = false; |
|
| 43 | - |
|
| 44 | - |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * EspressoShortcode constructor |
|
| 48 | - * |
|
| 49 | - * @param PostRelatedCacheManager $cache_manager |
|
| 50 | - */ |
|
| 51 | - public function __construct(PostRelatedCacheManager $cache_manager) |
|
| 52 | - { |
|
| 53 | - $this->cache_manager = $cache_manager; |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * @return void |
|
| 60 | - */ |
|
| 61 | - public function shortcodeHasBeenInitialized() |
|
| 62 | - { |
|
| 63 | - $this->initialized = true; |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - |
|
| 67 | - |
|
| 68 | - /** |
|
| 69 | - * enqueues scripts then processes the shortcode |
|
| 70 | - * |
|
| 71 | - * @param array $attributes |
|
| 72 | - * @return string |
|
| 73 | - * @throws EE_Error |
|
| 74 | - */ |
|
| 75 | - final public function processShortcodeCallback($attributes = array()) |
|
| 76 | - { |
|
| 77 | - if ($this instanceof EnqueueAssetsInterface) { |
|
| 78 | - if (is_admin()) { |
|
| 79 | - $this->enqueueAdminScripts(); |
|
| 80 | - } else { |
|
| 81 | - $this->enqueueScripts(); |
|
| 82 | - } |
|
| 83 | - } |
|
| 84 | - return $this->shortcodeContent( |
|
| 85 | - $this->sanitizeAttributes((array)$attributes) |
|
| 86 | - ); |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * If shortcode caching is enabled for the shortcode, |
|
| 93 | - * and cached results exist, then that will be returned |
|
| 94 | - * else new content will be generated. |
|
| 95 | - * If caching is enabled, then the new content will be cached for later. |
|
| 96 | - * |
|
| 97 | - * @param array $attributes |
|
| 98 | - * @return mixed|string |
|
| 99 | - * @throws EE_Error |
|
| 100 | - */ |
|
| 101 | - private function shortcodeContent(array $attributes) |
|
| 102 | - { |
|
| 103 | - $shortcode = $this; |
|
| 104 | - $post_ID = $this->currentPostID(); |
|
| 105 | - // something like "SC_EVENTS-123" |
|
| 106 | - $cache_ID = $this->shortcodeCacheID($post_ID); |
|
| 107 | - $this->cache_manager->clearPostRelatedCacheOnUpdate($post_ID, $cache_ID); |
|
| 108 | - return $this->cache_manager->get( |
|
| 109 | - $cache_ID, |
|
| 110 | - // serialized attributes |
|
| 111 | - wp_json_encode($attributes), |
|
| 112 | - // Closure for generating content if cache is expired |
|
| 113 | - function () use ($shortcode, $attributes) { |
|
| 114 | - if($shortcode->initialized === false){ |
|
| 115 | - $shortcode->initializeShortcode(); |
|
| 116 | - } |
|
| 117 | - return $shortcode->processShortcode($attributes); |
|
| 118 | - }, |
|
| 119 | - // filterable cache expiration set by each shortcode |
|
| 120 | - apply_filters( |
|
| 121 | - 'FHEE__EventEspresso_core_services_shortcodes_EspressoShortcode__shortcodeContent__cache_expiration', |
|
| 122 | - $this->cacheExpiration(), |
|
| 123 | - $this->getTag(), |
|
| 124 | - $this |
|
| 125 | - ) |
|
| 126 | - ); |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - |
|
| 130 | - |
|
| 131 | - /** |
|
| 132 | - * @return int |
|
| 133 | - * @throws EE_Error |
|
| 134 | - */ |
|
| 135 | - private function currentPostID() |
|
| 136 | - { |
|
| 137 | - // try to get EE_Event any way we can |
|
| 138 | - $event = EEH_Event_View::get_event(); |
|
| 139 | - // then get some kind of ID |
|
| 140 | - if ($event instanceof \EE_Event) { |
|
| 141 | - $post_ID = $event->ID(); |
|
| 142 | - } else { |
|
| 143 | - global $post; |
|
| 144 | - $post_ID = $post->ID; |
|
| 145 | - } |
|
| 146 | - return $post_ID; |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - |
|
| 150 | - |
|
| 151 | - /** |
|
| 152 | - * @param int $post_ID |
|
| 153 | - * @return string |
|
| 154 | - * @throws EE_Error |
|
| 155 | - */ |
|
| 156 | - private function shortcodeCacheID($post_ID) |
|
| 157 | - { |
|
| 158 | - $tag = str_replace('ESPRESSO_', '', $this->getTag()); |
|
| 159 | - return "SC_{$tag}-{$post_ID}"; |
|
| 160 | - } |
|
| 161 | - |
|
| 162 | - |
|
| 163 | - |
|
| 164 | - /** |
|
| 165 | - * array for defining custom attribute sanitization callbacks, |
|
| 166 | - * where keys match keys in your attributes array, |
|
| 167 | - * and values represent the sanitization function you wish to be applied to that attribute. |
|
| 168 | - * So for example, if you had an integer attribute named "event_id" |
|
| 169 | - * that you wanted to be sanitized using absint(), |
|
| 170 | - * then you would return the following: |
|
| 171 | - * array('event_id' => 'absint') |
|
| 172 | - * Entering 'skip_sanitization' for the callback value |
|
| 173 | - * means that no sanitization will be applied |
|
| 174 | - * on the assumption that the attribute |
|
| 175 | - * will be sanitized at some point... right? |
|
| 176 | - * You wouldn't pass around unsanitized attributes would you? |
|
| 177 | - * That would be very Tom Foolery of you!!! |
|
| 178 | - * |
|
| 179 | - * @return array |
|
| 180 | - */ |
|
| 181 | - protected function customAttributeSanitizationMap() |
|
| 182 | - { |
|
| 183 | - return array(); |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - |
|
| 187 | - |
|
| 188 | - /** |
|
| 189 | - * Performs basic sanitization on shortcode attributes |
|
| 190 | - * Since incoming attributes from the shortcode usage in the WP editor will all be strings, |
|
| 191 | - * most attributes will by default be sanitized using the sanitize_text_field() function. |
|
| 192 | - * This can be overridden using the customAttributeSanitizationMap() method (see above), |
|
| 193 | - * all other attributes would be sanitized using the defaults in the switch statement below |
|
| 194 | - * |
|
| 195 | - * @param array $attributes |
|
| 196 | - * @return array |
|
| 197 | - */ |
|
| 198 | - private function sanitizeAttributes(array $attributes) |
|
| 199 | - { |
|
| 200 | - $custom_sanitization = $this->customAttributeSanitizationMap(); |
|
| 201 | - foreach ($attributes as $key => $value) { |
|
| 202 | - // is a custom sanitization callback specified ? |
|
| 203 | - if (isset($custom_sanitization[$key])) { |
|
| 204 | - $callback = $custom_sanitization[$key]; |
|
| 205 | - if ($callback === 'skip_sanitization') { |
|
| 206 | - $attributes[$key] = $value; |
|
| 207 | - continue; |
|
| 208 | - } |
|
| 209 | - if (function_exists($callback)) { |
|
| 210 | - $attributes[$key] = $callback($value); |
|
| 211 | - continue; |
|
| 212 | - } |
|
| 213 | - } |
|
| 214 | - switch (true) { |
|
| 215 | - case $value === null : |
|
| 216 | - case is_int($value) : |
|
| 217 | - case is_float($value) : |
|
| 218 | - // typical booleans |
|
| 219 | - case in_array($value, array(true, 'true', '1', 'on', 'yes', false, 'false', '0', 'off', 'no'), true) : |
|
| 220 | - $attributes[$key] = $value; |
|
| 221 | - break; |
|
| 222 | - case is_string($value) : |
|
| 223 | - $attributes[$key] = sanitize_text_field($value); |
|
| 224 | - break; |
|
| 225 | - case is_array($value) : |
|
| 226 | - $attributes[$key] = $this->sanitizeAttributes($value); |
|
| 227 | - break; |
|
| 228 | - default : |
|
| 229 | - // only remaining data types are Object and Resource |
|
| 230 | - // which are not allowed as shortcode attributes |
|
| 231 | - $attributes[$key] = null; |
|
| 232 | - break; |
|
| 233 | - } |
|
| 234 | - } |
|
| 235 | - return $attributes; |
|
| 236 | - } |
|
| 24 | + /** |
|
| 25 | + * transient prefix |
|
| 26 | + * |
|
| 27 | + * @type string |
|
| 28 | + */ |
|
| 29 | + const CACHE_TRANSIENT_PREFIX = 'ee_sc_'; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * @var PostRelatedCacheManager $cache_manager |
|
| 33 | + */ |
|
| 34 | + private $cache_manager; |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * true if ShortcodeInterface::initializeShortcode() has been called |
|
| 38 | + * if false, then that will get called before processing |
|
| 39 | + * |
|
| 40 | + * @var boolean $initialized |
|
| 41 | + */ |
|
| 42 | + private $initialized = false; |
|
| 43 | + |
|
| 44 | + |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * EspressoShortcode constructor |
|
| 48 | + * |
|
| 49 | + * @param PostRelatedCacheManager $cache_manager |
|
| 50 | + */ |
|
| 51 | + public function __construct(PostRelatedCacheManager $cache_manager) |
|
| 52 | + { |
|
| 53 | + $this->cache_manager = $cache_manager; |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * @return void |
|
| 60 | + */ |
|
| 61 | + public function shortcodeHasBeenInitialized() |
|
| 62 | + { |
|
| 63 | + $this->initialized = true; |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + |
|
| 67 | + |
|
| 68 | + /** |
|
| 69 | + * enqueues scripts then processes the shortcode |
|
| 70 | + * |
|
| 71 | + * @param array $attributes |
|
| 72 | + * @return string |
|
| 73 | + * @throws EE_Error |
|
| 74 | + */ |
|
| 75 | + final public function processShortcodeCallback($attributes = array()) |
|
| 76 | + { |
|
| 77 | + if ($this instanceof EnqueueAssetsInterface) { |
|
| 78 | + if (is_admin()) { |
|
| 79 | + $this->enqueueAdminScripts(); |
|
| 80 | + } else { |
|
| 81 | + $this->enqueueScripts(); |
|
| 82 | + } |
|
| 83 | + } |
|
| 84 | + return $this->shortcodeContent( |
|
| 85 | + $this->sanitizeAttributes((array)$attributes) |
|
| 86 | + ); |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * If shortcode caching is enabled for the shortcode, |
|
| 93 | + * and cached results exist, then that will be returned |
|
| 94 | + * else new content will be generated. |
|
| 95 | + * If caching is enabled, then the new content will be cached for later. |
|
| 96 | + * |
|
| 97 | + * @param array $attributes |
|
| 98 | + * @return mixed|string |
|
| 99 | + * @throws EE_Error |
|
| 100 | + */ |
|
| 101 | + private function shortcodeContent(array $attributes) |
|
| 102 | + { |
|
| 103 | + $shortcode = $this; |
|
| 104 | + $post_ID = $this->currentPostID(); |
|
| 105 | + // something like "SC_EVENTS-123" |
|
| 106 | + $cache_ID = $this->shortcodeCacheID($post_ID); |
|
| 107 | + $this->cache_manager->clearPostRelatedCacheOnUpdate($post_ID, $cache_ID); |
|
| 108 | + return $this->cache_manager->get( |
|
| 109 | + $cache_ID, |
|
| 110 | + // serialized attributes |
|
| 111 | + wp_json_encode($attributes), |
|
| 112 | + // Closure for generating content if cache is expired |
|
| 113 | + function () use ($shortcode, $attributes) { |
|
| 114 | + if($shortcode->initialized === false){ |
|
| 115 | + $shortcode->initializeShortcode(); |
|
| 116 | + } |
|
| 117 | + return $shortcode->processShortcode($attributes); |
|
| 118 | + }, |
|
| 119 | + // filterable cache expiration set by each shortcode |
|
| 120 | + apply_filters( |
|
| 121 | + 'FHEE__EventEspresso_core_services_shortcodes_EspressoShortcode__shortcodeContent__cache_expiration', |
|
| 122 | + $this->cacheExpiration(), |
|
| 123 | + $this->getTag(), |
|
| 124 | + $this |
|
| 125 | + ) |
|
| 126 | + ); |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * @return int |
|
| 133 | + * @throws EE_Error |
|
| 134 | + */ |
|
| 135 | + private function currentPostID() |
|
| 136 | + { |
|
| 137 | + // try to get EE_Event any way we can |
|
| 138 | + $event = EEH_Event_View::get_event(); |
|
| 139 | + // then get some kind of ID |
|
| 140 | + if ($event instanceof \EE_Event) { |
|
| 141 | + $post_ID = $event->ID(); |
|
| 142 | + } else { |
|
| 143 | + global $post; |
|
| 144 | + $post_ID = $post->ID; |
|
| 145 | + } |
|
| 146 | + return $post_ID; |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + |
|
| 150 | + |
|
| 151 | + /** |
|
| 152 | + * @param int $post_ID |
|
| 153 | + * @return string |
|
| 154 | + * @throws EE_Error |
|
| 155 | + */ |
|
| 156 | + private function shortcodeCacheID($post_ID) |
|
| 157 | + { |
|
| 158 | + $tag = str_replace('ESPRESSO_', '', $this->getTag()); |
|
| 159 | + return "SC_{$tag}-{$post_ID}"; |
|
| 160 | + } |
|
| 161 | + |
|
| 162 | + |
|
| 163 | + |
|
| 164 | + /** |
|
| 165 | + * array for defining custom attribute sanitization callbacks, |
|
| 166 | + * where keys match keys in your attributes array, |
|
| 167 | + * and values represent the sanitization function you wish to be applied to that attribute. |
|
| 168 | + * So for example, if you had an integer attribute named "event_id" |
|
| 169 | + * that you wanted to be sanitized using absint(), |
|
| 170 | + * then you would return the following: |
|
| 171 | + * array('event_id' => 'absint') |
|
| 172 | + * Entering 'skip_sanitization' for the callback value |
|
| 173 | + * means that no sanitization will be applied |
|
| 174 | + * on the assumption that the attribute |
|
| 175 | + * will be sanitized at some point... right? |
|
| 176 | + * You wouldn't pass around unsanitized attributes would you? |
|
| 177 | + * That would be very Tom Foolery of you!!! |
|
| 178 | + * |
|
| 179 | + * @return array |
|
| 180 | + */ |
|
| 181 | + protected function customAttributeSanitizationMap() |
|
| 182 | + { |
|
| 183 | + return array(); |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + |
|
| 187 | + |
|
| 188 | + /** |
|
| 189 | + * Performs basic sanitization on shortcode attributes |
|
| 190 | + * Since incoming attributes from the shortcode usage in the WP editor will all be strings, |
|
| 191 | + * most attributes will by default be sanitized using the sanitize_text_field() function. |
|
| 192 | + * This can be overridden using the customAttributeSanitizationMap() method (see above), |
|
| 193 | + * all other attributes would be sanitized using the defaults in the switch statement below |
|
| 194 | + * |
|
| 195 | + * @param array $attributes |
|
| 196 | + * @return array |
|
| 197 | + */ |
|
| 198 | + private function sanitizeAttributes(array $attributes) |
|
| 199 | + { |
|
| 200 | + $custom_sanitization = $this->customAttributeSanitizationMap(); |
|
| 201 | + foreach ($attributes as $key => $value) { |
|
| 202 | + // is a custom sanitization callback specified ? |
|
| 203 | + if (isset($custom_sanitization[$key])) { |
|
| 204 | + $callback = $custom_sanitization[$key]; |
|
| 205 | + if ($callback === 'skip_sanitization') { |
|
| 206 | + $attributes[$key] = $value; |
|
| 207 | + continue; |
|
| 208 | + } |
|
| 209 | + if (function_exists($callback)) { |
|
| 210 | + $attributes[$key] = $callback($value); |
|
| 211 | + continue; |
|
| 212 | + } |
|
| 213 | + } |
|
| 214 | + switch (true) { |
|
| 215 | + case $value === null : |
|
| 216 | + case is_int($value) : |
|
| 217 | + case is_float($value) : |
|
| 218 | + // typical booleans |
|
| 219 | + case in_array($value, array(true, 'true', '1', 'on', 'yes', false, 'false', '0', 'off', 'no'), true) : |
|
| 220 | + $attributes[$key] = $value; |
|
| 221 | + break; |
|
| 222 | + case is_string($value) : |
|
| 223 | + $attributes[$key] = sanitize_text_field($value); |
|
| 224 | + break; |
|
| 225 | + case is_array($value) : |
|
| 226 | + $attributes[$key] = $this->sanitizeAttributes($value); |
|
| 227 | + break; |
|
| 228 | + default : |
|
| 229 | + // only remaining data types are Object and Resource |
|
| 230 | + // which are not allowed as shortcode attributes |
|
| 231 | + $attributes[$key] = null; |
|
| 232 | + break; |
|
| 233 | + } |
|
| 234 | + } |
|
| 235 | + return $attributes; |
|
| 236 | + } |
|
| 237 | 237 | |
| 238 | 238 | |
| 239 | 239 | |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | use EventEspresso\widgets\EspressoWidget; |
| 4 | 4 | |
| 5 | 5 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
| 6 | - exit('No direct script access allowed'); |
|
| 6 | + exit('No direct script access allowed'); |
|
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | /** |
@@ -26,379 +26,379 @@ discard block |
||
| 26 | 26 | final class EE_Front_Controller |
| 27 | 27 | { |
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * @var string $_template_path |
|
| 31 | - */ |
|
| 32 | - private $_template_path; |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * @var string $_template |
|
| 36 | - */ |
|
| 37 | - private $_template; |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * @type EE_Registry $Registry |
|
| 41 | - */ |
|
| 42 | - protected $Registry; |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * @type EE_Request_Handler $Request_Handler |
|
| 46 | - */ |
|
| 47 | - protected $Request_Handler; |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * @type EE_Module_Request_Router $Module_Request_Router |
|
| 51 | - */ |
|
| 52 | - protected $Module_Request_Router; |
|
| 53 | - |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * class constructor |
|
| 57 | - * should fire after shortcode, module, addon, or other plugin's default priority init phases have run |
|
| 58 | - * |
|
| 59 | - * @access public |
|
| 60 | - * @param \EE_Registry $Registry |
|
| 61 | - * @param \EE_Request_Handler $Request_Handler |
|
| 62 | - * @param \EE_Module_Request_Router $Module_Request_Router |
|
| 63 | - */ |
|
| 64 | - public function __construct( |
|
| 65 | - EE_Registry $Registry, |
|
| 66 | - EE_Request_Handler $Request_Handler, |
|
| 67 | - EE_Module_Request_Router $Module_Request_Router |
|
| 68 | - ) { |
|
| 69 | - $this->Registry = $Registry; |
|
| 70 | - $this->Request_Handler = $Request_Handler; |
|
| 71 | - $this->Module_Request_Router = $Module_Request_Router; |
|
| 72 | - // determine how to integrate WP_Query with the EE models |
|
| 73 | - add_action('AHEE__EE_System__initialize', array($this, 'employ_CPT_Strategy')); |
|
| 74 | - // load other resources and begin to actually run shortcodes and modules |
|
| 75 | - add_action('wp_loaded', array($this, 'wp_loaded'), 5); |
|
| 76 | - // analyse the incoming WP request |
|
| 77 | - add_action('parse_request', array($this, 'get_request'), 1, 1); |
|
| 78 | - // process request with module factory |
|
| 79 | - add_action('pre_get_posts', array($this, 'pre_get_posts'), 10, 1); |
|
| 80 | - // before headers sent |
|
| 81 | - add_action('wp', array($this, 'wp'), 5); |
|
| 82 | - // after headers sent but before any markup is output, |
|
| 83 | - // primarily used to process any content shortcodes |
|
| 84 | - add_action('wp_head', array($this, 'wpHead'), 0); |
|
| 85 | - // header |
|
| 86 | - add_action('wp_head', array($this, 'header_meta_tag'), 5); |
|
| 87 | - add_action('wp_print_scripts', array($this, 'wp_print_scripts'), 10); |
|
| 88 | - add_filter('template_include', array($this, 'template_include'), 1); |
|
| 89 | - // display errors |
|
| 90 | - add_action('loop_start', array($this, 'display_errors'), 2); |
|
| 91 | - // the content |
|
| 92 | - // add_filter( 'the_content', array( $this, 'the_content' ), 5, 1 ); |
|
| 93 | - //exclude our private cpt comments |
|
| 94 | - add_filter('comments_clauses', array($this, 'filter_wp_comments'), 10, 1); |
|
| 95 | - //make sure any ajax requests will respect the url schema when requests are made against admin-ajax.php (http:// or https://) |
|
| 96 | - add_filter('admin_url', array($this, 'maybe_force_admin_ajax_ssl'), 200, 1); |
|
| 97 | - // action hook EE |
|
| 98 | - do_action('AHEE__EE_Front_Controller__construct__done', $this); |
|
| 99 | - // for checking that browser cookies are enabled |
|
| 100 | - if (apply_filters('FHEE__EE_Front_Controller____construct__set_test_cookie', true)) { |
|
| 101 | - setcookie('ee_cookie_test', uniqid('ect',true), time() + DAY_IN_SECONDS, '/'); |
|
| 102 | - } |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - |
|
| 106 | - /** |
|
| 107 | - * @return EE_Request_Handler |
|
| 108 | - */ |
|
| 109 | - public function Request_Handler() |
|
| 110 | - { |
|
| 111 | - return $this->Request_Handler; |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * @return EE_Module_Request_Router |
|
| 117 | - */ |
|
| 118 | - public function Module_Request_Router() |
|
| 119 | - { |
|
| 120 | - return $this->Module_Request_Router; |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - |
|
| 124 | - |
|
| 125 | - /** |
|
| 126 | - * @return LegacyShortcodesManager |
|
| 127 | - */ |
|
| 128 | - public function getLegacyShortcodesManager() |
|
| 129 | - { |
|
| 130 | - return EE_Config::getLegacyShortcodesManager(); |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - |
|
| 134 | - |
|
| 135 | - |
|
| 136 | - |
|
| 137 | - /*********************************************** INIT ACTION HOOK ***********************************************/ |
|
| 138 | - |
|
| 139 | - |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * filter_wp_comments |
|
| 143 | - * This simply makes sure that any "private" EE CPTs do not have their comments show up in any wp comment |
|
| 144 | - * widgets/queries done on frontend |
|
| 145 | - * |
|
| 146 | - * @param array $clauses array of comment clauses setup by WP_Comment_Query |
|
| 147 | - * @return array array of comment clauses with modifications. |
|
| 148 | - */ |
|
| 149 | - public function filter_wp_comments($clauses) |
|
| 150 | - { |
|
| 151 | - global $wpdb; |
|
| 152 | - if (strpos($clauses['join'], $wpdb->posts) !== false) { |
|
| 153 | - $cpts = EE_Register_CPTs::get_private_CPTs(); |
|
| 154 | - foreach ($cpts as $cpt => $details) { |
|
| 155 | - $clauses['where'] .= $wpdb->prepare(" AND $wpdb->posts.post_type != %s", $cpt); |
|
| 156 | - } |
|
| 157 | - } |
|
| 158 | - return $clauses; |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - |
|
| 162 | - /** |
|
| 163 | - * employ_CPT_Strategy |
|
| 164 | - * |
|
| 165 | - * @access public |
|
| 166 | - * @return void |
|
| 167 | - */ |
|
| 168 | - public function employ_CPT_Strategy() |
|
| 169 | - { |
|
| 170 | - if (apply_filters('FHEE__EE_Front_Controller__employ_CPT_Strategy', true)) { |
|
| 171 | - $this->Registry->load_core('CPT_Strategy'); |
|
| 172 | - } |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - |
|
| 176 | - /** |
|
| 177 | - * this just makes sure that if the site is using ssl that we force that for any admin ajax calls from frontend |
|
| 178 | - * |
|
| 179 | - * @param string $url incoming url |
|
| 180 | - * @return string final assembled url |
|
| 181 | - */ |
|
| 182 | - public function maybe_force_admin_ajax_ssl($url) |
|
| 183 | - { |
|
| 184 | - if (is_ssl() && preg_match('/admin-ajax.php/', $url)) { |
|
| 185 | - $url = str_replace('http://', 'https://', $url); |
|
| 186 | - } |
|
| 187 | - return $url; |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - |
|
| 191 | - |
|
| 192 | - |
|
| 193 | - |
|
| 194 | - |
|
| 195 | - /*********************************************** WP_LOADED ACTION HOOK ***********************************************/ |
|
| 196 | - |
|
| 197 | - |
|
| 198 | - /** |
|
| 199 | - * wp_loaded - should fire after shortcode, module, addon, or other plugin's have been registered and their |
|
| 200 | - * default priority init phases have run |
|
| 201 | - * |
|
| 202 | - * @access public |
|
| 203 | - * @return void |
|
| 204 | - */ |
|
| 205 | - public function wp_loaded() |
|
| 206 | - { |
|
| 207 | - } |
|
| 208 | - |
|
| 209 | - |
|
| 210 | - |
|
| 211 | - |
|
| 212 | - |
|
| 213 | - /*********************************************** PARSE_REQUEST HOOK ***********************************************/ |
|
| 214 | - /** |
|
| 215 | - * _get_request |
|
| 216 | - * |
|
| 217 | - * @access public |
|
| 218 | - * @param WP $WP |
|
| 219 | - * @return void |
|
| 220 | - */ |
|
| 221 | - public function get_request(WP $WP) |
|
| 222 | - { |
|
| 223 | - do_action('AHEE__EE_Front_Controller__get_request__start'); |
|
| 224 | - $this->Request_Handler->parse_request($WP); |
|
| 225 | - do_action('AHEE__EE_Front_Controller__get_request__complete'); |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - |
|
| 229 | - |
|
| 230 | - /** |
|
| 231 | - * pre_get_posts - basically a module factory for instantiating modules and selecting the final view template |
|
| 232 | - * |
|
| 233 | - * @access public |
|
| 234 | - * @param WP_Query $WP_Query |
|
| 235 | - * @return void |
|
| 236 | - */ |
|
| 237 | - public function pre_get_posts($WP_Query) |
|
| 238 | - { |
|
| 239 | - // only load Module_Request_Router if this is the main query |
|
| 240 | - if ( |
|
| 241 | - $this->Module_Request_Router instanceof EE_Module_Request_Router |
|
| 242 | - && $WP_Query->is_main_query() |
|
| 243 | - ) { |
|
| 244 | - // cycle thru module routes |
|
| 245 | - while ($route = $this->Module_Request_Router->get_route($WP_Query)) { |
|
| 246 | - // determine module and method for route |
|
| 247 | - $module = $this->Module_Request_Router->resolve_route($route[0], $route[1]); |
|
| 248 | - if ($module instanceof EED_Module) { |
|
| 249 | - // get registered view for route |
|
| 250 | - $this->_template_path = $this->Module_Request_Router->get_view($route); |
|
| 251 | - // grab module name |
|
| 252 | - $module_name = $module->module_name(); |
|
| 253 | - // map the module to the module objects |
|
| 254 | - $this->Registry->modules->{$module_name} = $module; |
|
| 255 | - } |
|
| 256 | - } |
|
| 257 | - } |
|
| 258 | - } |
|
| 259 | - |
|
| 260 | - |
|
| 261 | - |
|
| 262 | - |
|
| 263 | - |
|
| 264 | - /*********************************************** WP HOOK ***********************************************/ |
|
| 265 | - |
|
| 266 | - |
|
| 267 | - /** |
|
| 268 | - * wp - basically last chance to do stuff before headers sent |
|
| 269 | - * |
|
| 270 | - * @access public |
|
| 271 | - * @return void |
|
| 272 | - */ |
|
| 273 | - public function wp() |
|
| 274 | - { |
|
| 275 | - } |
|
| 276 | - |
|
| 277 | - |
|
| 278 | - |
|
| 279 | - /*********************** GET_HEADER && WP_HEAD HOOK ***********************/ |
|
| 280 | - |
|
| 281 | - |
|
| 282 | - |
|
| 283 | - /** |
|
| 284 | - * callback for the "wp_head" hook point |
|
| 285 | - * checks sidebars for EE widgets |
|
| 286 | - * loads resources and assets accordingly |
|
| 287 | - * |
|
| 288 | - * @return void |
|
| 289 | - */ |
|
| 290 | - public function wpHead() |
|
| 291 | - { |
|
| 292 | - global $wp_query; |
|
| 293 | - if (empty($wp_query->posts)){ |
|
| 294 | - return; |
|
| 295 | - } |
|
| 296 | - // if we already know this is an espresso page, then load assets |
|
| 297 | - $load_assets = $this->Request_Handler->is_espresso_page(); |
|
| 298 | - // if we are already loading assets then just move along, otherwise check for widgets |
|
| 299 | - $load_assets = $load_assets ? $load_assets : $this->espresso_widgets_in_active_sidebars(); |
|
| 300 | - if ( $load_assets){ |
|
| 301 | - wp_enqueue_style('espresso_default'); |
|
| 302 | - wp_enqueue_style('espresso_custom_css'); |
|
| 303 | - wp_enqueue_script('espresso_core'); |
|
| 304 | - } |
|
| 305 | - } |
|
| 306 | - |
|
| 307 | - |
|
| 308 | - |
|
| 309 | - /** |
|
| 310 | - * builds list of active widgets then scans active sidebars looking for them |
|
| 311 | - * returns true is an EE widget is found in an active sidebar |
|
| 312 | - * Please Note: this does NOT mean that the sidebar or widget |
|
| 313 | - * is actually in use in a given template, as that is unfortunately not known |
|
| 314 | - * until a sidebar and it's widgets are actually loaded |
|
| 315 | - * |
|
| 316 | - * @return boolean |
|
| 317 | - */ |
|
| 318 | - private function espresso_widgets_in_active_sidebars() |
|
| 319 | - { |
|
| 320 | - $espresso_widgets = array(); |
|
| 321 | - foreach ($this->Registry->widgets as $widget_class => $widget) { |
|
| 322 | - $id_base = EspressoWidget::getIdBase($widget_class); |
|
| 323 | - if (is_active_widget(false, false, $id_base)) { |
|
| 324 | - $espresso_widgets[] = $id_base; |
|
| 325 | - } |
|
| 326 | - } |
|
| 327 | - $all_sidebar_widgets = wp_get_sidebars_widgets(); |
|
| 328 | - foreach ($all_sidebar_widgets as $sidebar_name => $sidebar_widgets) { |
|
| 329 | - if (is_array($sidebar_widgets) && ! empty($sidebar_widgets)) { |
|
| 330 | - foreach ($sidebar_widgets as $sidebar_widget) { |
|
| 331 | - foreach ($espresso_widgets as $espresso_widget) { |
|
| 332 | - if (strpos($sidebar_widget, $espresso_widget) !== false) { |
|
| 333 | - return true; |
|
| 334 | - } |
|
| 335 | - } |
|
| 336 | - } |
|
| 337 | - } |
|
| 338 | - } |
|
| 339 | - return false; |
|
| 340 | - } |
|
| 341 | - |
|
| 342 | - |
|
| 343 | - |
|
| 344 | - |
|
| 345 | - /** |
|
| 346 | - * header_meta_tag |
|
| 347 | - * |
|
| 348 | - * @access public |
|
| 349 | - * @return void |
|
| 350 | - */ |
|
| 351 | - public function header_meta_tag() |
|
| 352 | - { |
|
| 353 | - print( |
|
| 354 | - apply_filters( |
|
| 355 | - 'FHEE__EE_Front_Controller__header_meta_tag', |
|
| 356 | - '<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n") |
|
| 357 | - ); |
|
| 358 | - |
|
| 359 | - //let's exclude all event type taxonomy term archive pages from search engine indexing |
|
| 360 | - //@see https://events.codebasehq.com/projects/event-espresso/tickets/10249 |
|
| 361 | - //also exclude all critical pages from indexing |
|
| 362 | - if ( |
|
| 363 | - ( |
|
| 364 | - is_tax('espresso_event_type') |
|
| 365 | - && get_option( 'blog_public' ) !== '0' |
|
| 366 | - ) |
|
| 367 | - || is_page(EE_Registry::instance()->CFG->core->get_critical_pages_array()) |
|
| 368 | - ) { |
|
| 369 | - print( |
|
| 370 | - apply_filters( |
|
| 371 | - 'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type', |
|
| 372 | - '<meta name="robots" content="noindex,follow" />' . "\n" |
|
| 373 | - ) |
|
| 374 | - ); |
|
| 375 | - } |
|
| 376 | - } |
|
| 377 | - |
|
| 378 | - |
|
| 379 | - |
|
| 380 | - /** |
|
| 381 | - * wp_print_scripts |
|
| 382 | - * |
|
| 383 | - * @return void |
|
| 384 | - */ |
|
| 385 | - public function wp_print_scripts() |
|
| 386 | - { |
|
| 387 | - global $post; |
|
| 388 | - if ( |
|
| 389 | - isset($post->EE_Event) |
|
| 390 | - && $post->EE_Event instanceof EE_Event |
|
| 391 | - && get_post_type() === 'espresso_events' |
|
| 392 | - && is_singular() |
|
| 393 | - ) { |
|
| 394 | - \EEH_Schema::add_json_linked_data_for_event($post->EE_Event); |
|
| 395 | - } |
|
| 396 | - } |
|
| 397 | - |
|
| 398 | - |
|
| 399 | - |
|
| 400 | - |
|
| 401 | - /*********************************************** THE_CONTENT FILTER HOOK ********************************************** |
|
| 29 | + /** |
|
| 30 | + * @var string $_template_path |
|
| 31 | + */ |
|
| 32 | + private $_template_path; |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * @var string $_template |
|
| 36 | + */ |
|
| 37 | + private $_template; |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * @type EE_Registry $Registry |
|
| 41 | + */ |
|
| 42 | + protected $Registry; |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * @type EE_Request_Handler $Request_Handler |
|
| 46 | + */ |
|
| 47 | + protected $Request_Handler; |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * @type EE_Module_Request_Router $Module_Request_Router |
|
| 51 | + */ |
|
| 52 | + protected $Module_Request_Router; |
|
| 53 | + |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * class constructor |
|
| 57 | + * should fire after shortcode, module, addon, or other plugin's default priority init phases have run |
|
| 58 | + * |
|
| 59 | + * @access public |
|
| 60 | + * @param \EE_Registry $Registry |
|
| 61 | + * @param \EE_Request_Handler $Request_Handler |
|
| 62 | + * @param \EE_Module_Request_Router $Module_Request_Router |
|
| 63 | + */ |
|
| 64 | + public function __construct( |
|
| 65 | + EE_Registry $Registry, |
|
| 66 | + EE_Request_Handler $Request_Handler, |
|
| 67 | + EE_Module_Request_Router $Module_Request_Router |
|
| 68 | + ) { |
|
| 69 | + $this->Registry = $Registry; |
|
| 70 | + $this->Request_Handler = $Request_Handler; |
|
| 71 | + $this->Module_Request_Router = $Module_Request_Router; |
|
| 72 | + // determine how to integrate WP_Query with the EE models |
|
| 73 | + add_action('AHEE__EE_System__initialize', array($this, 'employ_CPT_Strategy')); |
|
| 74 | + // load other resources and begin to actually run shortcodes and modules |
|
| 75 | + add_action('wp_loaded', array($this, 'wp_loaded'), 5); |
|
| 76 | + // analyse the incoming WP request |
|
| 77 | + add_action('parse_request', array($this, 'get_request'), 1, 1); |
|
| 78 | + // process request with module factory |
|
| 79 | + add_action('pre_get_posts', array($this, 'pre_get_posts'), 10, 1); |
|
| 80 | + // before headers sent |
|
| 81 | + add_action('wp', array($this, 'wp'), 5); |
|
| 82 | + // after headers sent but before any markup is output, |
|
| 83 | + // primarily used to process any content shortcodes |
|
| 84 | + add_action('wp_head', array($this, 'wpHead'), 0); |
|
| 85 | + // header |
|
| 86 | + add_action('wp_head', array($this, 'header_meta_tag'), 5); |
|
| 87 | + add_action('wp_print_scripts', array($this, 'wp_print_scripts'), 10); |
|
| 88 | + add_filter('template_include', array($this, 'template_include'), 1); |
|
| 89 | + // display errors |
|
| 90 | + add_action('loop_start', array($this, 'display_errors'), 2); |
|
| 91 | + // the content |
|
| 92 | + // add_filter( 'the_content', array( $this, 'the_content' ), 5, 1 ); |
|
| 93 | + //exclude our private cpt comments |
|
| 94 | + add_filter('comments_clauses', array($this, 'filter_wp_comments'), 10, 1); |
|
| 95 | + //make sure any ajax requests will respect the url schema when requests are made against admin-ajax.php (http:// or https://) |
|
| 96 | + add_filter('admin_url', array($this, 'maybe_force_admin_ajax_ssl'), 200, 1); |
|
| 97 | + // action hook EE |
|
| 98 | + do_action('AHEE__EE_Front_Controller__construct__done', $this); |
|
| 99 | + // for checking that browser cookies are enabled |
|
| 100 | + if (apply_filters('FHEE__EE_Front_Controller____construct__set_test_cookie', true)) { |
|
| 101 | + setcookie('ee_cookie_test', uniqid('ect',true), time() + DAY_IN_SECONDS, '/'); |
|
| 102 | + } |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + |
|
| 106 | + /** |
|
| 107 | + * @return EE_Request_Handler |
|
| 108 | + */ |
|
| 109 | + public function Request_Handler() |
|
| 110 | + { |
|
| 111 | + return $this->Request_Handler; |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * @return EE_Module_Request_Router |
|
| 117 | + */ |
|
| 118 | + public function Module_Request_Router() |
|
| 119 | + { |
|
| 120 | + return $this->Module_Request_Router; |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + |
|
| 124 | + |
|
| 125 | + /** |
|
| 126 | + * @return LegacyShortcodesManager |
|
| 127 | + */ |
|
| 128 | + public function getLegacyShortcodesManager() |
|
| 129 | + { |
|
| 130 | + return EE_Config::getLegacyShortcodesManager(); |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + |
|
| 134 | + |
|
| 135 | + |
|
| 136 | + |
|
| 137 | + /*********************************************** INIT ACTION HOOK ***********************************************/ |
|
| 138 | + |
|
| 139 | + |
|
| 140 | + |
|
| 141 | + /** |
|
| 142 | + * filter_wp_comments |
|
| 143 | + * This simply makes sure that any "private" EE CPTs do not have their comments show up in any wp comment |
|
| 144 | + * widgets/queries done on frontend |
|
| 145 | + * |
|
| 146 | + * @param array $clauses array of comment clauses setup by WP_Comment_Query |
|
| 147 | + * @return array array of comment clauses with modifications. |
|
| 148 | + */ |
|
| 149 | + public function filter_wp_comments($clauses) |
|
| 150 | + { |
|
| 151 | + global $wpdb; |
|
| 152 | + if (strpos($clauses['join'], $wpdb->posts) !== false) { |
|
| 153 | + $cpts = EE_Register_CPTs::get_private_CPTs(); |
|
| 154 | + foreach ($cpts as $cpt => $details) { |
|
| 155 | + $clauses['where'] .= $wpdb->prepare(" AND $wpdb->posts.post_type != %s", $cpt); |
|
| 156 | + } |
|
| 157 | + } |
|
| 158 | + return $clauses; |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + |
|
| 162 | + /** |
|
| 163 | + * employ_CPT_Strategy |
|
| 164 | + * |
|
| 165 | + * @access public |
|
| 166 | + * @return void |
|
| 167 | + */ |
|
| 168 | + public function employ_CPT_Strategy() |
|
| 169 | + { |
|
| 170 | + if (apply_filters('FHEE__EE_Front_Controller__employ_CPT_Strategy', true)) { |
|
| 171 | + $this->Registry->load_core('CPT_Strategy'); |
|
| 172 | + } |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + |
|
| 176 | + /** |
|
| 177 | + * this just makes sure that if the site is using ssl that we force that for any admin ajax calls from frontend |
|
| 178 | + * |
|
| 179 | + * @param string $url incoming url |
|
| 180 | + * @return string final assembled url |
|
| 181 | + */ |
|
| 182 | + public function maybe_force_admin_ajax_ssl($url) |
|
| 183 | + { |
|
| 184 | + if (is_ssl() && preg_match('/admin-ajax.php/', $url)) { |
|
| 185 | + $url = str_replace('http://', 'https://', $url); |
|
| 186 | + } |
|
| 187 | + return $url; |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + |
|
| 191 | + |
|
| 192 | + |
|
| 193 | + |
|
| 194 | + |
|
| 195 | + /*********************************************** WP_LOADED ACTION HOOK ***********************************************/ |
|
| 196 | + |
|
| 197 | + |
|
| 198 | + /** |
|
| 199 | + * wp_loaded - should fire after shortcode, module, addon, or other plugin's have been registered and their |
|
| 200 | + * default priority init phases have run |
|
| 201 | + * |
|
| 202 | + * @access public |
|
| 203 | + * @return void |
|
| 204 | + */ |
|
| 205 | + public function wp_loaded() |
|
| 206 | + { |
|
| 207 | + } |
|
| 208 | + |
|
| 209 | + |
|
| 210 | + |
|
| 211 | + |
|
| 212 | + |
|
| 213 | + /*********************************************** PARSE_REQUEST HOOK ***********************************************/ |
|
| 214 | + /** |
|
| 215 | + * _get_request |
|
| 216 | + * |
|
| 217 | + * @access public |
|
| 218 | + * @param WP $WP |
|
| 219 | + * @return void |
|
| 220 | + */ |
|
| 221 | + public function get_request(WP $WP) |
|
| 222 | + { |
|
| 223 | + do_action('AHEE__EE_Front_Controller__get_request__start'); |
|
| 224 | + $this->Request_Handler->parse_request($WP); |
|
| 225 | + do_action('AHEE__EE_Front_Controller__get_request__complete'); |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + |
|
| 229 | + |
|
| 230 | + /** |
|
| 231 | + * pre_get_posts - basically a module factory for instantiating modules and selecting the final view template |
|
| 232 | + * |
|
| 233 | + * @access public |
|
| 234 | + * @param WP_Query $WP_Query |
|
| 235 | + * @return void |
|
| 236 | + */ |
|
| 237 | + public function pre_get_posts($WP_Query) |
|
| 238 | + { |
|
| 239 | + // only load Module_Request_Router if this is the main query |
|
| 240 | + if ( |
|
| 241 | + $this->Module_Request_Router instanceof EE_Module_Request_Router |
|
| 242 | + && $WP_Query->is_main_query() |
|
| 243 | + ) { |
|
| 244 | + // cycle thru module routes |
|
| 245 | + while ($route = $this->Module_Request_Router->get_route($WP_Query)) { |
|
| 246 | + // determine module and method for route |
|
| 247 | + $module = $this->Module_Request_Router->resolve_route($route[0], $route[1]); |
|
| 248 | + if ($module instanceof EED_Module) { |
|
| 249 | + // get registered view for route |
|
| 250 | + $this->_template_path = $this->Module_Request_Router->get_view($route); |
|
| 251 | + // grab module name |
|
| 252 | + $module_name = $module->module_name(); |
|
| 253 | + // map the module to the module objects |
|
| 254 | + $this->Registry->modules->{$module_name} = $module; |
|
| 255 | + } |
|
| 256 | + } |
|
| 257 | + } |
|
| 258 | + } |
|
| 259 | + |
|
| 260 | + |
|
| 261 | + |
|
| 262 | + |
|
| 263 | + |
|
| 264 | + /*********************************************** WP HOOK ***********************************************/ |
|
| 265 | + |
|
| 266 | + |
|
| 267 | + /** |
|
| 268 | + * wp - basically last chance to do stuff before headers sent |
|
| 269 | + * |
|
| 270 | + * @access public |
|
| 271 | + * @return void |
|
| 272 | + */ |
|
| 273 | + public function wp() |
|
| 274 | + { |
|
| 275 | + } |
|
| 276 | + |
|
| 277 | + |
|
| 278 | + |
|
| 279 | + /*********************** GET_HEADER && WP_HEAD HOOK ***********************/ |
|
| 280 | + |
|
| 281 | + |
|
| 282 | + |
|
| 283 | + /** |
|
| 284 | + * callback for the "wp_head" hook point |
|
| 285 | + * checks sidebars for EE widgets |
|
| 286 | + * loads resources and assets accordingly |
|
| 287 | + * |
|
| 288 | + * @return void |
|
| 289 | + */ |
|
| 290 | + public function wpHead() |
|
| 291 | + { |
|
| 292 | + global $wp_query; |
|
| 293 | + if (empty($wp_query->posts)){ |
|
| 294 | + return; |
|
| 295 | + } |
|
| 296 | + // if we already know this is an espresso page, then load assets |
|
| 297 | + $load_assets = $this->Request_Handler->is_espresso_page(); |
|
| 298 | + // if we are already loading assets then just move along, otherwise check for widgets |
|
| 299 | + $load_assets = $load_assets ? $load_assets : $this->espresso_widgets_in_active_sidebars(); |
|
| 300 | + if ( $load_assets){ |
|
| 301 | + wp_enqueue_style('espresso_default'); |
|
| 302 | + wp_enqueue_style('espresso_custom_css'); |
|
| 303 | + wp_enqueue_script('espresso_core'); |
|
| 304 | + } |
|
| 305 | + } |
|
| 306 | + |
|
| 307 | + |
|
| 308 | + |
|
| 309 | + /** |
|
| 310 | + * builds list of active widgets then scans active sidebars looking for them |
|
| 311 | + * returns true is an EE widget is found in an active sidebar |
|
| 312 | + * Please Note: this does NOT mean that the sidebar or widget |
|
| 313 | + * is actually in use in a given template, as that is unfortunately not known |
|
| 314 | + * until a sidebar and it's widgets are actually loaded |
|
| 315 | + * |
|
| 316 | + * @return boolean |
|
| 317 | + */ |
|
| 318 | + private function espresso_widgets_in_active_sidebars() |
|
| 319 | + { |
|
| 320 | + $espresso_widgets = array(); |
|
| 321 | + foreach ($this->Registry->widgets as $widget_class => $widget) { |
|
| 322 | + $id_base = EspressoWidget::getIdBase($widget_class); |
|
| 323 | + if (is_active_widget(false, false, $id_base)) { |
|
| 324 | + $espresso_widgets[] = $id_base; |
|
| 325 | + } |
|
| 326 | + } |
|
| 327 | + $all_sidebar_widgets = wp_get_sidebars_widgets(); |
|
| 328 | + foreach ($all_sidebar_widgets as $sidebar_name => $sidebar_widgets) { |
|
| 329 | + if (is_array($sidebar_widgets) && ! empty($sidebar_widgets)) { |
|
| 330 | + foreach ($sidebar_widgets as $sidebar_widget) { |
|
| 331 | + foreach ($espresso_widgets as $espresso_widget) { |
|
| 332 | + if (strpos($sidebar_widget, $espresso_widget) !== false) { |
|
| 333 | + return true; |
|
| 334 | + } |
|
| 335 | + } |
|
| 336 | + } |
|
| 337 | + } |
|
| 338 | + } |
|
| 339 | + return false; |
|
| 340 | + } |
|
| 341 | + |
|
| 342 | + |
|
| 343 | + |
|
| 344 | + |
|
| 345 | + /** |
|
| 346 | + * header_meta_tag |
|
| 347 | + * |
|
| 348 | + * @access public |
|
| 349 | + * @return void |
|
| 350 | + */ |
|
| 351 | + public function header_meta_tag() |
|
| 352 | + { |
|
| 353 | + print( |
|
| 354 | + apply_filters( |
|
| 355 | + 'FHEE__EE_Front_Controller__header_meta_tag', |
|
| 356 | + '<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n") |
|
| 357 | + ); |
|
| 358 | + |
|
| 359 | + //let's exclude all event type taxonomy term archive pages from search engine indexing |
|
| 360 | + //@see https://events.codebasehq.com/projects/event-espresso/tickets/10249 |
|
| 361 | + //also exclude all critical pages from indexing |
|
| 362 | + if ( |
|
| 363 | + ( |
|
| 364 | + is_tax('espresso_event_type') |
|
| 365 | + && get_option( 'blog_public' ) !== '0' |
|
| 366 | + ) |
|
| 367 | + || is_page(EE_Registry::instance()->CFG->core->get_critical_pages_array()) |
|
| 368 | + ) { |
|
| 369 | + print( |
|
| 370 | + apply_filters( |
|
| 371 | + 'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type', |
|
| 372 | + '<meta name="robots" content="noindex,follow" />' . "\n" |
|
| 373 | + ) |
|
| 374 | + ); |
|
| 375 | + } |
|
| 376 | + } |
|
| 377 | + |
|
| 378 | + |
|
| 379 | + |
|
| 380 | + /** |
|
| 381 | + * wp_print_scripts |
|
| 382 | + * |
|
| 383 | + * @return void |
|
| 384 | + */ |
|
| 385 | + public function wp_print_scripts() |
|
| 386 | + { |
|
| 387 | + global $post; |
|
| 388 | + if ( |
|
| 389 | + isset($post->EE_Event) |
|
| 390 | + && $post->EE_Event instanceof EE_Event |
|
| 391 | + && get_post_type() === 'espresso_events' |
|
| 392 | + && is_singular() |
|
| 393 | + ) { |
|
| 394 | + \EEH_Schema::add_json_linked_data_for_event($post->EE_Event); |
|
| 395 | + } |
|
| 396 | + } |
|
| 397 | + |
|
| 398 | + |
|
| 399 | + |
|
| 400 | + |
|
| 401 | + /*********************************************** THE_CONTENT FILTER HOOK ********************************************** |
|
| 402 | 402 | |
| 403 | 403 | |
| 404 | 404 | |
@@ -409,99 +409,99 @@ discard block |
||
| 409 | 409 | // * @param $the_content |
| 410 | 410 | // * @return string |
| 411 | 411 | // */ |
| 412 | - // public function the_content( $the_content ) { |
|
| 413 | - // // nothing gets loaded at this point unless other systems turn this hookpoint on by using: add_filter( 'FHEE_run_EE_the_content', '__return_true' ); |
|
| 414 | - // if ( apply_filters( 'FHEE_run_EE_the_content', FALSE ) ) { |
|
| 415 | - // } |
|
| 416 | - // return $the_content; |
|
| 417 | - // } |
|
| 418 | - |
|
| 419 | - |
|
| 420 | - |
|
| 421 | - /*********************************************** WP_FOOTER ***********************************************/ |
|
| 422 | - |
|
| 423 | - |
|
| 424 | - /** |
|
| 425 | - * display_errors |
|
| 426 | - * |
|
| 427 | - * @access public |
|
| 428 | - * @return void |
|
| 429 | - */ |
|
| 430 | - public function display_errors() |
|
| 431 | - { |
|
| 432 | - static $shown_already = false; |
|
| 433 | - do_action('AHEE__EE_Front_Controller__display_errors__begin'); |
|
| 434 | - if ( |
|
| 435 | - ! $shown_already |
|
| 436 | - && apply_filters('FHEE__EE_Front_Controller__display_errors', true) |
|
| 437 | - && is_main_query() |
|
| 438 | - && ! is_feed() |
|
| 439 | - && in_the_loop() |
|
| 440 | - && $this->Request_Handler->is_espresso_page() |
|
| 441 | - ) { |
|
| 442 | - echo EE_Error::get_notices(); |
|
| 443 | - $shown_already = true; |
|
| 444 | - EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php'); |
|
| 445 | - } |
|
| 446 | - do_action('AHEE__EE_Front_Controller__display_errors__end'); |
|
| 447 | - } |
|
| 448 | - |
|
| 449 | - |
|
| 450 | - |
|
| 451 | - |
|
| 452 | - |
|
| 453 | - /*********************************************** UTILITIES ***********************************************/ |
|
| 454 | - /** |
|
| 455 | - * template_include |
|
| 456 | - * |
|
| 457 | - * @access public |
|
| 458 | - * @param string $template_include_path |
|
| 459 | - * @return string |
|
| 460 | - */ |
|
| 461 | - public function template_include($template_include_path = null) |
|
| 462 | - { |
|
| 463 | - if ($this->Request_Handler->is_espresso_page()) { |
|
| 464 | - $this->_template_path = ! empty($this->_template_path) ? basename($this->_template_path) : basename($template_include_path); |
|
| 465 | - $template_path = EEH_Template::locate_template($this->_template_path, array(), false); |
|
| 466 | - $this->_template_path = ! empty($template_path) ? $template_path : $template_include_path; |
|
| 467 | - $this->_template = basename($this->_template_path); |
|
| 468 | - return $this->_template_path; |
|
| 469 | - } |
|
| 470 | - return $template_include_path; |
|
| 471 | - } |
|
| 472 | - |
|
| 473 | - |
|
| 474 | - /** |
|
| 475 | - * get_selected_template |
|
| 476 | - * |
|
| 477 | - * @access public |
|
| 478 | - * @param bool $with_path |
|
| 479 | - * @return string |
|
| 480 | - */ |
|
| 481 | - public function get_selected_template($with_path = false) |
|
| 482 | - { |
|
| 483 | - return $with_path ? $this->_template_path : $this->_template; |
|
| 484 | - } |
|
| 485 | - |
|
| 486 | - |
|
| 487 | - |
|
| 488 | - /** |
|
| 489 | - * @deprecated 4.9.26 |
|
| 490 | - * @param string $shortcode_class |
|
| 491 | - * @param \WP $wp |
|
| 492 | - */ |
|
| 493 | - public function initialize_shortcode($shortcode_class = '', WP $wp = null) |
|
| 494 | - { |
|
| 495 | - \EE_Error::doing_it_wrong( |
|
| 496 | - __METHOD__, |
|
| 497 | - __( |
|
| 498 | - 'Usage is deprecated. Please use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::initializeShortcode() instead.', |
|
| 499 | - 'event_espresso' |
|
| 500 | - ), |
|
| 501 | - '4.9.26' |
|
| 502 | - ); |
|
| 503 | - $this->getLegacyShortcodesManager()->initializeShortcode($shortcode_class, $wp); |
|
| 504 | - } |
|
| 412 | + // public function the_content( $the_content ) { |
|
| 413 | + // // nothing gets loaded at this point unless other systems turn this hookpoint on by using: add_filter( 'FHEE_run_EE_the_content', '__return_true' ); |
|
| 414 | + // if ( apply_filters( 'FHEE_run_EE_the_content', FALSE ) ) { |
|
| 415 | + // } |
|
| 416 | + // return $the_content; |
|
| 417 | + // } |
|
| 418 | + |
|
| 419 | + |
|
| 420 | + |
|
| 421 | + /*********************************************** WP_FOOTER ***********************************************/ |
|
| 422 | + |
|
| 423 | + |
|
| 424 | + /** |
|
| 425 | + * display_errors |
|
| 426 | + * |
|
| 427 | + * @access public |
|
| 428 | + * @return void |
|
| 429 | + */ |
|
| 430 | + public function display_errors() |
|
| 431 | + { |
|
| 432 | + static $shown_already = false; |
|
| 433 | + do_action('AHEE__EE_Front_Controller__display_errors__begin'); |
|
| 434 | + if ( |
|
| 435 | + ! $shown_already |
|
| 436 | + && apply_filters('FHEE__EE_Front_Controller__display_errors', true) |
|
| 437 | + && is_main_query() |
|
| 438 | + && ! is_feed() |
|
| 439 | + && in_the_loop() |
|
| 440 | + && $this->Request_Handler->is_espresso_page() |
|
| 441 | + ) { |
|
| 442 | + echo EE_Error::get_notices(); |
|
| 443 | + $shown_already = true; |
|
| 444 | + EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php'); |
|
| 445 | + } |
|
| 446 | + do_action('AHEE__EE_Front_Controller__display_errors__end'); |
|
| 447 | + } |
|
| 448 | + |
|
| 449 | + |
|
| 450 | + |
|
| 451 | + |
|
| 452 | + |
|
| 453 | + /*********************************************** UTILITIES ***********************************************/ |
|
| 454 | + /** |
|
| 455 | + * template_include |
|
| 456 | + * |
|
| 457 | + * @access public |
|
| 458 | + * @param string $template_include_path |
|
| 459 | + * @return string |
|
| 460 | + */ |
|
| 461 | + public function template_include($template_include_path = null) |
|
| 462 | + { |
|
| 463 | + if ($this->Request_Handler->is_espresso_page()) { |
|
| 464 | + $this->_template_path = ! empty($this->_template_path) ? basename($this->_template_path) : basename($template_include_path); |
|
| 465 | + $template_path = EEH_Template::locate_template($this->_template_path, array(), false); |
|
| 466 | + $this->_template_path = ! empty($template_path) ? $template_path : $template_include_path; |
|
| 467 | + $this->_template = basename($this->_template_path); |
|
| 468 | + return $this->_template_path; |
|
| 469 | + } |
|
| 470 | + return $template_include_path; |
|
| 471 | + } |
|
| 472 | + |
|
| 473 | + |
|
| 474 | + /** |
|
| 475 | + * get_selected_template |
|
| 476 | + * |
|
| 477 | + * @access public |
|
| 478 | + * @param bool $with_path |
|
| 479 | + * @return string |
|
| 480 | + */ |
|
| 481 | + public function get_selected_template($with_path = false) |
|
| 482 | + { |
|
| 483 | + return $with_path ? $this->_template_path : $this->_template; |
|
| 484 | + } |
|
| 485 | + |
|
| 486 | + |
|
| 487 | + |
|
| 488 | + /** |
|
| 489 | + * @deprecated 4.9.26 |
|
| 490 | + * @param string $shortcode_class |
|
| 491 | + * @param \WP $wp |
|
| 492 | + */ |
|
| 493 | + public function initialize_shortcode($shortcode_class = '', WP $wp = null) |
|
| 494 | + { |
|
| 495 | + \EE_Error::doing_it_wrong( |
|
| 496 | + __METHOD__, |
|
| 497 | + __( |
|
| 498 | + 'Usage is deprecated. Please use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::initializeShortcode() instead.', |
|
| 499 | + 'event_espresso' |
|
| 500 | + ), |
|
| 501 | + '4.9.26' |
|
| 502 | + ); |
|
| 503 | + $this->getLegacyShortcodesManager()->initializeShortcode($shortcode_class, $wp); |
|
| 504 | + } |
|
| 505 | 505 | |
| 506 | 506 | } |
| 507 | 507 | // End of file EE_Front_Controller.core.php |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | do_action('AHEE__EE_Front_Controller__construct__done', $this); |
| 99 | 99 | // for checking that browser cookies are enabled |
| 100 | 100 | if (apply_filters('FHEE__EE_Front_Controller____construct__set_test_cookie', true)) { |
| 101 | - setcookie('ee_cookie_test', uniqid('ect',true), time() + DAY_IN_SECONDS, '/'); |
|
| 101 | + setcookie('ee_cookie_test', uniqid('ect', true), time() + DAY_IN_SECONDS, '/'); |
|
| 102 | 102 | } |
| 103 | 103 | } |
| 104 | 104 | |
@@ -290,14 +290,14 @@ discard block |
||
| 290 | 290 | public function wpHead() |
| 291 | 291 | { |
| 292 | 292 | global $wp_query; |
| 293 | - if (empty($wp_query->posts)){ |
|
| 293 | + if (empty($wp_query->posts)) { |
|
| 294 | 294 | return; |
| 295 | 295 | } |
| 296 | 296 | // if we already know this is an espresso page, then load assets |
| 297 | 297 | $load_assets = $this->Request_Handler->is_espresso_page(); |
| 298 | 298 | // if we are already loading assets then just move along, otherwise check for widgets |
| 299 | 299 | $load_assets = $load_assets ? $load_assets : $this->espresso_widgets_in_active_sidebars(); |
| 300 | - if ( $load_assets){ |
|
| 300 | + if ($load_assets) { |
|
| 301 | 301 | wp_enqueue_style('espresso_default'); |
| 302 | 302 | wp_enqueue_style('espresso_custom_css'); |
| 303 | 303 | wp_enqueue_script('espresso_core'); |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | print( |
| 354 | 354 | apply_filters( |
| 355 | 355 | 'FHEE__EE_Front_Controller__header_meta_tag', |
| 356 | - '<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n") |
|
| 356 | + '<meta name="generator" content="Event Espresso Version '.EVENT_ESPRESSO_VERSION."\" />\n") |
|
| 357 | 357 | ); |
| 358 | 358 | |
| 359 | 359 | //let's exclude all event type taxonomy term archive pages from search engine indexing |
@@ -362,14 +362,14 @@ discard block |
||
| 362 | 362 | if ( |
| 363 | 363 | ( |
| 364 | 364 | is_tax('espresso_event_type') |
| 365 | - && get_option( 'blog_public' ) !== '0' |
|
| 365 | + && get_option('blog_public') !== '0' |
|
| 366 | 366 | ) |
| 367 | 367 | || is_page(EE_Registry::instance()->CFG->core->get_critical_pages_array()) |
| 368 | 368 | ) { |
| 369 | 369 | print( |
| 370 | 370 | apply_filters( |
| 371 | 371 | 'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type', |
| 372 | - '<meta name="robots" content="noindex,follow" />' . "\n" |
|
| 372 | + '<meta name="robots" content="noindex,follow" />'."\n" |
|
| 373 | 373 | ) |
| 374 | 374 | ); |
| 375 | 375 | } |
@@ -441,7 +441,7 @@ discard block |
||
| 441 | 441 | ) { |
| 442 | 442 | echo EE_Error::get_notices(); |
| 443 | 443 | $shown_already = true; |
| 444 | - EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php'); |
|
| 444 | + EEH_Template::display_template(EE_TEMPLATES.'espresso-ajax-notices.template.php'); |
|
| 445 | 445 | } |
| 446 | 446 | do_action('AHEE__EE_Front_Controller__display_errors__end'); |
| 447 | 447 | } |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | use EventEspresso\core\services\loaders\LoaderInterface; |
| 5 | 5 | |
| 6 | 6 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
| 7 | - exit('No direct script access allowed'); |
|
| 7 | + exit('No direct script access allowed'); |
|
| 8 | 8 | } |
| 9 | 9 | |
| 10 | 10 | |
@@ -24,228 +24,228 @@ discard block |
||
| 24 | 24 | class EE_Load_Espresso_Core implements EEI_Request_Decorator, EEI_Request_Stack_Core_App |
| 25 | 25 | { |
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * @type LoaderInterface $loader |
|
| 29 | - */ |
|
| 30 | - protected $loader; |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * @var EE_Request $request |
|
| 34 | - */ |
|
| 35 | - protected $request; |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * @var EE_Response $response |
|
| 39 | - */ |
|
| 40 | - protected $response; |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * @var EE_Dependency_Map $dependency_map |
|
| 44 | - */ |
|
| 45 | - protected $dependency_map; |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * @var EE_Registry $registry |
|
| 49 | - */ |
|
| 50 | - protected $registry; |
|
| 51 | - |
|
| 52 | - |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * EE_Load_Espresso_Core constructor |
|
| 56 | - */ |
|
| 57 | - public function __construct() |
|
| 58 | - { |
|
| 59 | - espresso_load_required('EventEspresso\core\Factory', EE_CORE . 'Factory.php'); |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * handle |
|
| 66 | - * sets hooks for running rest of system |
|
| 67 | - * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point |
|
| 68 | - * starting EE Addons from any other point may lead to problems |
|
| 69 | - * |
|
| 70 | - * @param EE_Request $request |
|
| 71 | - * @param EE_Response $response |
|
| 72 | - * @return EE_Response |
|
| 73 | - * @throws EE_Error |
|
| 74 | - * @throws InvalidDataTypeException |
|
| 75 | - * @throws InvalidInterfaceException |
|
| 76 | - * @throws InvalidArgumentException |
|
| 77 | - */ |
|
| 78 | - public function handle_request(EE_Request $request, EE_Response $response) |
|
| 79 | - { |
|
| 80 | - $this->request = $request; |
|
| 81 | - $this->response = $response; |
|
| 82 | - // info about how to load classes required by other classes |
|
| 83 | - $this->dependency_map = $this->_load_dependency_map(); |
|
| 84 | - // central repository for classes |
|
| 85 | - $this->registry = $this->_load_registry(); |
|
| 86 | - // PSR4 Autoloaders |
|
| 87 | - $this->registry->load_core('EE_Psr4AutoloaderInit'); |
|
| 88 | - do_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading'); |
|
| 89 | - $this->loader = $this->registry->create('EventEspresso\core\services\loaders\Loader'); |
|
| 90 | - $this->dependency_map->setLoader($this->loader); |
|
| 91 | - // build DI container |
|
| 92 | - $OpenCoffeeShop = new EventEspresso\core\services\container\OpenCoffeeShop(); |
|
| 93 | - $OpenCoffeeShop->addRecipes(); |
|
| 94 | - // $CoffeeShop = $OpenCoffeeShop->CoffeeShop(); |
|
| 95 | - // create and cache the CommandBus, and also add middleware |
|
| 96 | - $this->registry->create( |
|
| 97 | - 'CommandBusInterface', |
|
| 98 | - array( |
|
| 99 | - null, |
|
| 100 | - apply_filters( |
|
| 101 | - 'FHEE__EE_Load_Espresso_Core__handle_request__CommandBus_middleware', |
|
| 102 | - array( |
|
| 103 | - $this->registry->create('CapChecker'), |
|
| 104 | - $this->registry->create('AddActionHook'), |
|
| 105 | - ) |
|
| 106 | - ), |
|
| 107 | - ), |
|
| 108 | - true |
|
| 109 | - ); |
|
| 110 | - // workarounds for PHP < 5.3 |
|
| 111 | - $this->_load_class_tools(); |
|
| 112 | - // load interfaces |
|
| 113 | - espresso_load_required('EEI_Payment_Method_Interfaces', |
|
| 114 | - EE_LIBRARIES . 'payment_methods' . DS . 'EEI_Payment_Method_Interfaces.php'); |
|
| 115 | - // deprecated functions |
|
| 116 | - espresso_load_required('EE_Deprecated', EE_CORE . 'EE_Deprecated.core.php'); |
|
| 117 | - // WP cron jobs |
|
| 118 | - $this->registry->load_core('Cron_Tasks'); |
|
| 119 | - $this->registry->load_core('EE_Request_Handler'); |
|
| 120 | - $this->registry->load_core('EE_System'); |
|
| 121 | - return $this->response; |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - |
|
| 125 | - |
|
| 126 | - /** |
|
| 127 | - * @return EE_Request |
|
| 128 | - */ |
|
| 129 | - public function request() |
|
| 130 | - { |
|
| 131 | - return $this->request; |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - |
|
| 135 | - |
|
| 136 | - /** |
|
| 137 | - * @return EE_Response |
|
| 138 | - */ |
|
| 139 | - public function response() |
|
| 140 | - { |
|
| 141 | - return $this->response; |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - |
|
| 145 | - |
|
| 146 | - /** |
|
| 147 | - * @return EE_Dependency_Map |
|
| 148 | - * @throws EE_Error |
|
| 149 | - */ |
|
| 150 | - public function dependency_map() |
|
| 151 | - { |
|
| 152 | - if (! $this->dependency_map instanceof EE_Dependency_Map) { |
|
| 153 | - throw new EE_Error( |
|
| 154 | - sprintf( |
|
| 155 | - __('Invalid EE_Dependency_Map: "%1$s"', 'event_espresso'), |
|
| 156 | - print_r($this->dependency_map, true) |
|
| 157 | - ) |
|
| 158 | - ); |
|
| 159 | - } |
|
| 160 | - return $this->dependency_map; |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - |
|
| 164 | - |
|
| 165 | - /** |
|
| 166 | - * @return EE_Registry |
|
| 167 | - * @throws EE_Error |
|
| 168 | - */ |
|
| 169 | - public function registry() |
|
| 170 | - { |
|
| 171 | - if (! $this->registry instanceof EE_Registry) { |
|
| 172 | - throw new EE_Error( |
|
| 173 | - sprintf( |
|
| 174 | - __('Invalid EE_Registry: "%1$s"', 'event_espresso'), |
|
| 175 | - print_r($this->registry, true) |
|
| 176 | - ) |
|
| 177 | - ); |
|
| 178 | - } |
|
| 179 | - return $this->registry; |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - |
|
| 183 | - |
|
| 184 | - /** |
|
| 185 | - * @return EE_Dependency_Map |
|
| 186 | - */ |
|
| 187 | - private function _load_dependency_map() |
|
| 188 | - { |
|
| 189 | - if (! is_readable(EE_CORE . 'EE_Dependency_Map.core.php')) { |
|
| 190 | - EE_Error::add_error( |
|
| 191 | - __('The EE_Dependency_Map core class could not be loaded.', 'event_espresso'), |
|
| 192 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 193 | - ); |
|
| 194 | - wp_die(EE_Error::get_notices()); |
|
| 195 | - } |
|
| 196 | - require_once(EE_CORE . 'EE_Dependency_Map.core.php'); |
|
| 197 | - return EE_Dependency_Map::instance($this->request, $this->response); |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - |
|
| 201 | - |
|
| 202 | - /** |
|
| 203 | - * @return EE_Registry |
|
| 204 | - */ |
|
| 205 | - private function _load_registry() |
|
| 206 | - { |
|
| 207 | - if (! is_readable(EE_CORE . 'EE_Registry.core.php')) { |
|
| 208 | - EE_Error::add_error( |
|
| 209 | - __('The EE_Registry core class could not be loaded.', 'event_espresso'), |
|
| 210 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 211 | - ); |
|
| 212 | - wp_die(EE_Error::get_notices()); |
|
| 213 | - } |
|
| 214 | - require_once(EE_CORE . 'EE_Registry.core.php'); |
|
| 215 | - return EE_Registry::instance($this->dependency_map); |
|
| 216 | - } |
|
| 217 | - |
|
| 218 | - |
|
| 219 | - |
|
| 220 | - /** |
|
| 221 | - * @return void |
|
| 222 | - */ |
|
| 223 | - private function _load_class_tools() |
|
| 224 | - { |
|
| 225 | - if (! is_readable(EE_HELPERS . 'EEH_Class_Tools.helper.php')) { |
|
| 226 | - EE_Error::add_error( |
|
| 227 | - __('The EEH_Class_Tools helper could not be loaded.', 'event_espresso'), |
|
| 228 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 229 | - ); |
|
| 230 | - } |
|
| 231 | - require_once(EE_HELPERS . 'EEH_Class_Tools.helper.php'); |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - |
|
| 235 | - |
|
| 236 | - /** |
|
| 237 | - * called after the request stack has been fully processed |
|
| 238 | - * if any of the middleware apps has requested the plugin be deactivated, then we do that now |
|
| 239 | - * |
|
| 240 | - * @param EE_Request $request |
|
| 241 | - * @param EE_Response $response |
|
| 242 | - */ |
|
| 243 | - public function handle_response(EE_Request $request, EE_Response $response) |
|
| 244 | - { |
|
| 245 | - if ($response->plugin_deactivated()) { |
|
| 246 | - espresso_deactivate_plugin(EE_PLUGIN_BASENAME); |
|
| 247 | - } |
|
| 248 | - } |
|
| 27 | + /** |
|
| 28 | + * @type LoaderInterface $loader |
|
| 29 | + */ |
|
| 30 | + protected $loader; |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * @var EE_Request $request |
|
| 34 | + */ |
|
| 35 | + protected $request; |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * @var EE_Response $response |
|
| 39 | + */ |
|
| 40 | + protected $response; |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * @var EE_Dependency_Map $dependency_map |
|
| 44 | + */ |
|
| 45 | + protected $dependency_map; |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * @var EE_Registry $registry |
|
| 49 | + */ |
|
| 50 | + protected $registry; |
|
| 51 | + |
|
| 52 | + |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * EE_Load_Espresso_Core constructor |
|
| 56 | + */ |
|
| 57 | + public function __construct() |
|
| 58 | + { |
|
| 59 | + espresso_load_required('EventEspresso\core\Factory', EE_CORE . 'Factory.php'); |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * handle |
|
| 66 | + * sets hooks for running rest of system |
|
| 67 | + * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point |
|
| 68 | + * starting EE Addons from any other point may lead to problems |
|
| 69 | + * |
|
| 70 | + * @param EE_Request $request |
|
| 71 | + * @param EE_Response $response |
|
| 72 | + * @return EE_Response |
|
| 73 | + * @throws EE_Error |
|
| 74 | + * @throws InvalidDataTypeException |
|
| 75 | + * @throws InvalidInterfaceException |
|
| 76 | + * @throws InvalidArgumentException |
|
| 77 | + */ |
|
| 78 | + public function handle_request(EE_Request $request, EE_Response $response) |
|
| 79 | + { |
|
| 80 | + $this->request = $request; |
|
| 81 | + $this->response = $response; |
|
| 82 | + // info about how to load classes required by other classes |
|
| 83 | + $this->dependency_map = $this->_load_dependency_map(); |
|
| 84 | + // central repository for classes |
|
| 85 | + $this->registry = $this->_load_registry(); |
|
| 86 | + // PSR4 Autoloaders |
|
| 87 | + $this->registry->load_core('EE_Psr4AutoloaderInit'); |
|
| 88 | + do_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading'); |
|
| 89 | + $this->loader = $this->registry->create('EventEspresso\core\services\loaders\Loader'); |
|
| 90 | + $this->dependency_map->setLoader($this->loader); |
|
| 91 | + // build DI container |
|
| 92 | + $OpenCoffeeShop = new EventEspresso\core\services\container\OpenCoffeeShop(); |
|
| 93 | + $OpenCoffeeShop->addRecipes(); |
|
| 94 | + // $CoffeeShop = $OpenCoffeeShop->CoffeeShop(); |
|
| 95 | + // create and cache the CommandBus, and also add middleware |
|
| 96 | + $this->registry->create( |
|
| 97 | + 'CommandBusInterface', |
|
| 98 | + array( |
|
| 99 | + null, |
|
| 100 | + apply_filters( |
|
| 101 | + 'FHEE__EE_Load_Espresso_Core__handle_request__CommandBus_middleware', |
|
| 102 | + array( |
|
| 103 | + $this->registry->create('CapChecker'), |
|
| 104 | + $this->registry->create('AddActionHook'), |
|
| 105 | + ) |
|
| 106 | + ), |
|
| 107 | + ), |
|
| 108 | + true |
|
| 109 | + ); |
|
| 110 | + // workarounds for PHP < 5.3 |
|
| 111 | + $this->_load_class_tools(); |
|
| 112 | + // load interfaces |
|
| 113 | + espresso_load_required('EEI_Payment_Method_Interfaces', |
|
| 114 | + EE_LIBRARIES . 'payment_methods' . DS . 'EEI_Payment_Method_Interfaces.php'); |
|
| 115 | + // deprecated functions |
|
| 116 | + espresso_load_required('EE_Deprecated', EE_CORE . 'EE_Deprecated.core.php'); |
|
| 117 | + // WP cron jobs |
|
| 118 | + $this->registry->load_core('Cron_Tasks'); |
|
| 119 | + $this->registry->load_core('EE_Request_Handler'); |
|
| 120 | + $this->registry->load_core('EE_System'); |
|
| 121 | + return $this->response; |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + |
|
| 125 | + |
|
| 126 | + /** |
|
| 127 | + * @return EE_Request |
|
| 128 | + */ |
|
| 129 | + public function request() |
|
| 130 | + { |
|
| 131 | + return $this->request; |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + |
|
| 135 | + |
|
| 136 | + /** |
|
| 137 | + * @return EE_Response |
|
| 138 | + */ |
|
| 139 | + public function response() |
|
| 140 | + { |
|
| 141 | + return $this->response; |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + |
|
| 145 | + |
|
| 146 | + /** |
|
| 147 | + * @return EE_Dependency_Map |
|
| 148 | + * @throws EE_Error |
|
| 149 | + */ |
|
| 150 | + public function dependency_map() |
|
| 151 | + { |
|
| 152 | + if (! $this->dependency_map instanceof EE_Dependency_Map) { |
|
| 153 | + throw new EE_Error( |
|
| 154 | + sprintf( |
|
| 155 | + __('Invalid EE_Dependency_Map: "%1$s"', 'event_espresso'), |
|
| 156 | + print_r($this->dependency_map, true) |
|
| 157 | + ) |
|
| 158 | + ); |
|
| 159 | + } |
|
| 160 | + return $this->dependency_map; |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + |
|
| 164 | + |
|
| 165 | + /** |
|
| 166 | + * @return EE_Registry |
|
| 167 | + * @throws EE_Error |
|
| 168 | + */ |
|
| 169 | + public function registry() |
|
| 170 | + { |
|
| 171 | + if (! $this->registry instanceof EE_Registry) { |
|
| 172 | + throw new EE_Error( |
|
| 173 | + sprintf( |
|
| 174 | + __('Invalid EE_Registry: "%1$s"', 'event_espresso'), |
|
| 175 | + print_r($this->registry, true) |
|
| 176 | + ) |
|
| 177 | + ); |
|
| 178 | + } |
|
| 179 | + return $this->registry; |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + |
|
| 183 | + |
|
| 184 | + /** |
|
| 185 | + * @return EE_Dependency_Map |
|
| 186 | + */ |
|
| 187 | + private function _load_dependency_map() |
|
| 188 | + { |
|
| 189 | + if (! is_readable(EE_CORE . 'EE_Dependency_Map.core.php')) { |
|
| 190 | + EE_Error::add_error( |
|
| 191 | + __('The EE_Dependency_Map core class could not be loaded.', 'event_espresso'), |
|
| 192 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 193 | + ); |
|
| 194 | + wp_die(EE_Error::get_notices()); |
|
| 195 | + } |
|
| 196 | + require_once(EE_CORE . 'EE_Dependency_Map.core.php'); |
|
| 197 | + return EE_Dependency_Map::instance($this->request, $this->response); |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + |
|
| 201 | + |
|
| 202 | + /** |
|
| 203 | + * @return EE_Registry |
|
| 204 | + */ |
|
| 205 | + private function _load_registry() |
|
| 206 | + { |
|
| 207 | + if (! is_readable(EE_CORE . 'EE_Registry.core.php')) { |
|
| 208 | + EE_Error::add_error( |
|
| 209 | + __('The EE_Registry core class could not be loaded.', 'event_espresso'), |
|
| 210 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 211 | + ); |
|
| 212 | + wp_die(EE_Error::get_notices()); |
|
| 213 | + } |
|
| 214 | + require_once(EE_CORE . 'EE_Registry.core.php'); |
|
| 215 | + return EE_Registry::instance($this->dependency_map); |
|
| 216 | + } |
|
| 217 | + |
|
| 218 | + |
|
| 219 | + |
|
| 220 | + /** |
|
| 221 | + * @return void |
|
| 222 | + */ |
|
| 223 | + private function _load_class_tools() |
|
| 224 | + { |
|
| 225 | + if (! is_readable(EE_HELPERS . 'EEH_Class_Tools.helper.php')) { |
|
| 226 | + EE_Error::add_error( |
|
| 227 | + __('The EEH_Class_Tools helper could not be loaded.', 'event_espresso'), |
|
| 228 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 229 | + ); |
|
| 230 | + } |
|
| 231 | + require_once(EE_HELPERS . 'EEH_Class_Tools.helper.php'); |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + |
|
| 235 | + |
|
| 236 | + /** |
|
| 237 | + * called after the request stack has been fully processed |
|
| 238 | + * if any of the middleware apps has requested the plugin be deactivated, then we do that now |
|
| 239 | + * |
|
| 240 | + * @param EE_Request $request |
|
| 241 | + * @param EE_Response $response |
|
| 242 | + */ |
|
| 243 | + public function handle_response(EE_Request $request, EE_Response $response) |
|
| 244 | + { |
|
| 245 | + if ($response->plugin_deactivated()) { |
|
| 246 | + espresso_deactivate_plugin(EE_PLUGIN_BASENAME); |
|
| 247 | + } |
|
| 248 | + } |
|
| 249 | 249 | |
| 250 | 250 | |
| 251 | 251 | |
@@ -6,24 +6,33 @@ discard block |
||
| 6 | 6 | <?php if ( $disabled ) : ?> |
| 7 | 7 | <input type="hidden" id="edit-ticket-TKT_start_date-<?php echo $tkt_row; ?>" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_start_date]" class="edit-ticket-TKT_start_date ee-text-inp" value="<?php echo $TKT_start_date; ?>" > |
| 8 | 8 | <input type="text" name="archived_ticket[TKT_start_date]" class="edit-ticket-TKT_start_date ee-text-inp" value="<?php echo $TKT_start_date; ?>" disabled> |
| 9 | - <?php else : ?> |
|
| 10 | - <input id="edit-ticket-TKT_start_date-<?php echo $tkt_row; ?>" type="text" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_start_date]" class="edit-ticket-TKT_start_date ee-text-inp ee-datepicker" value="<?php echo $TKT_start_date; ?>" data-context="start-ticket" data-date-field-context="#display-ticketrow-<?php echo $tkt_row; ?>" data-related-field=".edit-ticket-TKT_end_date" data-next-field=".edit-ticket-TKT_end_date"> |
|
| 9 | + <?php else { |
|
| 10 | + : ?> |
|
| 11 | + <input id="edit-ticket-TKT_start_date-<?php echo $tkt_row; |
|
| 12 | +} |
|
| 13 | +?>" type="text" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_start_date]" class="edit-ticket-TKT_start_date ee-text-inp ee-datepicker" value="<?php echo $TKT_start_date; ?>" data-context="start-ticket" data-date-field-context="#display-ticketrow-<?php echo $tkt_row; ?>" data-related-field=".edit-ticket-TKT_end_date" data-next-field=".edit-ticket-TKT_end_date"> |
|
| 11 | 14 | <?php endif; ?> |
| 12 | 15 | </td> |
| 13 | 16 | <td> |
| 14 | 17 | <?php if ( $disabled ) : ?> |
| 15 | 18 | <input type="hidden" id="edit-ticket-TKT_end_date-<?php echo $tkt_row; ?>" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_end_date]" class="edit-ticket-TKT_end_date ee-text-inp" value="<?php echo $TKT_end_date; ?>" > |
| 16 | 19 | <input type="text" name="archived_ticket[TKT_end_date]" class="edit-ticket-TKT_end_date ee-text-inp" value="<?php echo $TKT_end_date; ?>" disabled> |
| 17 | - <?php else : ?> |
|
| 18 | - <input id="edit-ticket-TKT_end_date-<?php echo $tkt_row; ?>" type="text" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_end_date]" class="edit-ticket-TKT_end_date ee-text-inp ee-datepicker" value="<?php echo $TKT_end_date; ?>" data-context="end-ticket" data-date-field-context="#display-ticketrow-<?php echo $tkt_row; ?>" data-related-field=".edit-ticket-TKT_start_date" data-next-field=".edit-ticket-TKT_qty"> |
|
| 20 | + <?php else { |
|
| 21 | + : ?> |
|
| 22 | + <input id="edit-ticket-TKT_end_date-<?php echo $tkt_row; |
|
| 23 | +} |
|
| 24 | +?>" type="text" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_end_date]" class="edit-ticket-TKT_end_date ee-text-inp ee-datepicker" value="<?php echo $TKT_end_date; ?>" data-context="end-ticket" data-date-field-context="#display-ticketrow-<?php echo $tkt_row; ?>" data-related-field=".edit-ticket-TKT_start_date" data-next-field=".edit-ticket-TKT_qty"> |
|
| 19 | 25 | <?php endif; ?> |
| 20 | 26 | </td> |
| 21 | 27 | <td> |
| 22 | 28 | <?php if ( $disabled ) : ?> |
| 23 | 29 | <input id="edit-ticket-TKT_base_price-<?php echo $tkt_row; ?>" type="hidden" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_base_price]" class="edit-ticket-TKT_base_price ee-small-text-inp edit-price-PRC_amount ee-numeric" value="<?php echo $TKT_base_price; ?>"> |
| 24 | 30 | <input type="text" name="archived_ticket[<?php echo $tkt_row; ?>][TKT_base_price]" class="edit-ticket-TKT_base_price ee-small-text-inp edit-price-PRC_amount ee-numeric" value="<?php echo $TKT_base_price; ?>" disabled> |
| 25 | - <?php else : ?> |
|
| 26 | - <input id="edit-ticket-TKT_base_price-<?php echo $tkt_row; ?>" type="text" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_base_price]" class="edit-ticket-TKT_base_price ee-small-text-inp edit-price-PRC_amount ee-numeric" value="<?php echo $TKT_base_price; ?>"> |
|
| 31 | + <?php else { |
|
| 32 | + : ?> |
|
| 33 | + <input id="edit-ticket-TKT_base_price-<?php echo $tkt_row; |
|
| 34 | +} |
|
| 35 | +?>" type="text" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_base_price]" class="edit-ticket-TKT_base_price ee-small-text-inp edit-price-PRC_amount ee-numeric" value="<?php echo $TKT_base_price; ?>"> |
|
| 27 | 36 | <?php endif; ?> |
| 28 | 37 | <input type="hidden" id="edit-ticket-TKT_base_price_ID-<?php echo $tkt_row; ?>" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_base_price_ID]" value="<?php echo $TKT_base_price_ID; ?>"> |
| 29 | 38 | </td> |
@@ -31,8 +40,11 @@ discard block |
||
| 31 | 40 | <?php if ( $disabled ) : ?> |
| 32 | 41 | <input type="hidden" class="edit-ticket-TKT_qty ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_qty]" value="<?php echo $TKT_qty_for_input; ?>"> |
| 33 | 42 | <input type="text" class="edit-ticket-TKT_qty ee-small-text-inp ee-numeric" name="archived_ticket[<?php echo $tkt_row; ?>][TKT_qty]" value="<?php echo $TKT_qty_for_input; ?>" disabled> |
| 34 | - <?php else : ?> |
|
| 35 | - <input type="text" id="edit-ticket-TKT_qty-<?php echo $tkt_row; ?>" class="edit-ticket-TKT_qty ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_qty]" value="<?php echo $TKT_qty_for_input; ?>"> |
|
| 43 | + <?php else { |
|
| 44 | + : ?> |
|
| 45 | + <input type="text" id="edit-ticket-TKT_qty-<?php echo $tkt_row; |
|
| 46 | +} |
|
| 47 | +?>" class="edit-ticket-TKT_qty ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_qty]" value="<?php echo $TKT_qty_for_input; ?>"> |
|
| 36 | 48 | <?php endif; ?> |
| 37 | 49 | </td> |
| 38 | 50 | <!--<td><span class="ticket-display-row-TKT_price"><?php //echo $TKT_price; ?></span></td>--> |
@@ -78,24 +90,33 @@ discard block |
||
| 78 | 90 | <?php if ( $disabled ) : ?> |
| 79 | 91 | <input type="hidden" class="edit-ticket-TKT_uses ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_uses]" value="<?php echo $TKT_uses; ?>"> |
| 80 | 92 | <input type="text" class="edit-ticket-TKT_uses ee-small-text-inp ee-numeric" name="archived_ticket[<?php echo $tkt_row; ?>][TKT_uses]" value="<?php echo $TKT_uses; ?>" disabled> |
| 81 | - <?php else : ?> |
|
| 82 | - <input type="text" class="edit-ticket-TKT_uses ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_uses]" value="<?php echo $TKT_uses; ?>"> |
|
| 93 | + <?php else { |
|
| 94 | + : ?> |
|
| 95 | + <input type="text" class="edit-ticket-TKT_uses ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; |
|
| 96 | +} |
|
| 97 | +?>[<?php echo $tkt_row; ?>][TKT_uses]" value="<?php echo $TKT_uses; ?>"> |
|
| 83 | 98 | <?php endif; ?> |
| 84 | 99 | </td> |
| 85 | 100 | <td> |
| 86 | 101 | <?php if ( $disabled ) : ?> |
| 87 | 102 | <input type="hidden" class="edit-ticket-TKT_min ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_min]" value="<?php echo $TKT_min; ?>"> |
| 88 | 103 | <input type="text" class="edit-ticket-TKT_min ee-small-text-inp ee-numeric" name="archived_ticket[<?php echo $tkt_row; ?>][TKT_min]" value="<?php echo $TKT_min; ?>" disabled> |
| 89 | - <?php else: ?> |
|
| 90 | - <input type="text" class="edit-ticket-TKT_min ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_min]" value="<?php echo $TKT_min; ?>"> |
|
| 104 | + <?php else { |
|
| 105 | + : ?> |
|
| 106 | + <input type="text" class="edit-ticket-TKT_min ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; |
|
| 107 | +} |
|
| 108 | +?>[<?php echo $tkt_row; ?>][TKT_min]" value="<?php echo $TKT_min; ?>"> |
|
| 91 | 109 | <?php endif; ?> |
| 92 | 110 | </td> |
| 93 | 111 | <td> |
| 94 | 112 | <?php if ( $disabled ) : ?> |
| 95 | 113 | <input type="hidden" class="edit-ticket-TKT_max ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_max]" value="<?php echo $TKT_max; ?>"> |
| 96 | 114 | <input type="text" class="edit-ticket-TKT_max ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_max]" value="<?php echo $TKT_max; ?>" disabled> |
| 97 | - <?php else : ?> |
|
| 98 | - <input type="text" class="edit-ticket-TKT_max ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; ?>[<?php echo $tkt_row; ?>][TKT_max]" value="<?php echo $TKT_max; ?>"> |
|
| 115 | + <?php else { |
|
| 116 | + : ?> |
|
| 117 | + <input type="text" class="edit-ticket-TKT_max ee-small-text-inp ee-numeric" name="<?php echo $edit_tickets_name; |
|
| 118 | +} |
|
| 119 | +?>[<?php echo $tkt_row; ?>][TKT_max]" value="<?php echo $TKT_max; ?>"> |
|
| 99 | 120 | <?php endif; ?> |
| 100 | 121 | </td> |
| 101 | 122 | </tr> |
@@ -116,8 +137,11 @@ discard block |
||
| 116 | 137 | ?> |
| 117 | 138 | <input class="TKT-taxable-checkbox" type="hidden" name="<?php echo $edit_tickets_name;?>[<?php echo $tkt_row; ?>][TKT_taxable]" value="<?php echo $tax_value; ?>"> |
| 118 | 139 | <input class="TKT-taxable-checkbox" id="edit-ticket-TKT_taxable-<?php echo $tkt_row; ?>" type="checkbox" name="archived_ticket[<?php echo $tkt_row; ?>][TKT_taxable]" value="1"<?php echo $TKT_taxable; ?> disabled> |
| 119 | - <?php else : ?> |
|
| 120 | - <input class="TKT-taxable-checkbox" id="edit-ticket-TKT_taxable-<?php echo $tkt_row; ?>" type="checkbox" name="<?php echo $edit_tickets_name;?>[<?php echo $tkt_row; ?>][TKT_taxable]" value="1"<?php echo $TKT_taxable; ?>> |
|
| 140 | + <?php else { |
|
| 141 | + : ?> |
|
| 142 | + <input class="TKT-taxable-checkbox" id="edit-ticket-TKT_taxable-<?php echo $tkt_row; |
|
| 143 | +} |
|
| 144 | +?>" type="checkbox" name="<?php echo $edit_tickets_name;?>[<?php echo $tkt_row; ?>][TKT_taxable]" value="1"<?php echo $TKT_taxable; ?>> |
|
| 121 | 145 | <?php endif; ?> |
| 122 | 146 | <label for="edit-ticket-TKT_taxable-<?php echo $tkt_row; ?>"> <?php esc_html_e('This ticket is taxable.', 'event_espresso'); ?> |
| 123 | 147 | <?php } //end tax_rows check ?> |