Completed
Branch FET-10768-extract-admin-bar (2dd98c)
by
unknown
146:19 queued 134:18
created
core/services/collections/CollectionLoader.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -199,13 +199,13 @@  discard block
 block discarded – undo
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
 block discarded – undo
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,
Please login to merge, or discard this patch.
core/services/cache/BasicCacheManager.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
Indentation   +135 added lines, -135 removed lines patch added patch discarded remove patch
@@ -19,140 +19,140 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
Please login to merge, or discard this patch.
core/services/cache/PostRelatedCacheManager.php 1 patch
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -18,93 +18,93 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
core/services/shortcodes/EspressoShortcode.php 1 patch
Indentation   +213 added lines, -213 removed lines patch added patch discarded remove patch
@@ -21,219 +21,219 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
shortcodes/espresso_events/EES_Espresso_Events.shortcode.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -10,15 +10,15 @@  discard block
 block discarded – undo
10 10
 class EES_Espresso_Events  extends EES_Shortcode {
11 11
 
12 12
 	/**
13
-     * @deprecated 4.9.27
14
-     *  @return 	void
13
+	 * @deprecated 4.9.27
14
+	 *  @return 	void
15 15
 	 */
16 16
 	public static function set_hooks() {
17 17
 	}
18 18
 
19 19
 	/**
20
-     * @deprecated 4.9.27
21
-     *  @return 	void
20
+	 * @deprecated 4.9.27
21
+	 *  @return 	void
22 22
 	 */
23 23
 	public static function set_hooks_admin() {
24 24
 	}
@@ -26,8 +26,8 @@  discard block
 block discarded – undo
26 26
 
27 27
 
28 28
 	/**
29
-     * @deprecated 4.9.27
30
-     * @param WP $WP
29
+	 * @deprecated 4.9.27
30
+	 * @param WP $WP
31 31
 	 * @return    void
32 32
 	 */
33 33
 	public function run( WP $WP ) {
@@ -36,21 +36,21 @@  discard block
 block discarded – undo
36 36
 
37 37
 
38 38
 	/**
39
-     * @deprecated 4.9.27
40
-     *  @param 	array 	$attributes
39
+	 * @deprecated 4.9.27
40
+	 *  @param 	array 	$attributes
41 41
 	 *  @return 	string
42 42
 	 */
43 43
 	public function process_shortcode( $attributes = array() ) {
44
-        \EE_Error::doing_it_wrong(
45
-            __METHOD__,
46
-            __(
47
-                'Usage is deprecated. Please use \EventEspresso\core\domain\entities\shortcodes\EspressoEvents instead.',
48
-                'event_espresso'
49
-            ),
50
-            '4.9.27'
51
-        );
52
-        return '';
53
-    }
44
+		\EE_Error::doing_it_wrong(
45
+			__METHOD__,
46
+			__(
47
+				'Usage is deprecated. Please use \EventEspresso\core\domain\entities\shortcodes\EspressoEvents instead.',
48
+				'event_espresso'
49
+			),
50
+			'4.9.27'
51
+		);
52
+		return '';
53
+	}
54 54
 
55 55
 
56 56
 
Please login to merge, or discard this patch.
core/EE_Load_Espresso_Core.core.php 1 patch
Indentation   +223 added lines, -223 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
admin/new/pricing/templates/event_tickets_datetime_ticket_row.template.php 1 patch
Braces   +40 added lines, -16 removed lines patch added patch discarded remove patch
@@ -6,24 +6,33 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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 ?>
Please login to merge, or discard this patch.
acceptance_tests/Page/EventsAdmin.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -120,7 +120,7 @@
 block discarded – undo
120 120
 
121 121
     /**
122 122
      * Wrapper for getting the selector for a given field and given display row of a ticket in the event editor.
123
-     * @param     $field_name
123
+     * @param     string $field_name
124 124
      * @param int $row_number
125 125
      * @return string
126 126
      */
Please login to merge, or discard this patch.
Indentation   +177 added lines, -177 removed lines patch added patch discarded remove patch
@@ -14,181 +14,181 @@
 block discarded – undo
14 14
 class EventsAdmin extends CoreAdmin
15 15
 {
16 16
 
17
-    /**
18
-     * Selector for the Add new Event button in the admin.
19
-     * @var string
20
-     */
21
-    const ADD_NEW_EVENT_BUTTON_SELECTOR = '#add-new-event';
22
-
23
-
24
-    /**
25
-     * Selector for the Event Title field in the event editor
26
-     * @var string
27
-     */
28
-    const EVENT_EDITOR_TITLE_FIELD_SELECTOR = "//input[@id='title']";
29
-
30
-    /**
31
-     * Selector for the publish submit button in the event editor.
32
-     * @var string
33
-     */
34
-    const EVENT_EDITOR_PUBLISH_BUTTON_SELECTOR = "#publish";
35
-
36
-
37
-    /**
38
-     * @var string
39
-     */
40
-    const EVENT_EDITOR_DEFAULT_REGISTRATION_STATUS_FIELD_SELECTOR = '#EVT_default_registration_status';
41
-
42
-    /**
43
-     * Selector for the view link after publishing an event.
44
-     * @var string
45
-     */
46
-    const EVENT_EDITOR_VIEW_LINK_AFTER_PUBLISH_SELECTOR = "//div[@id='message']/p/a";
47
-
48
-
49
-    /**
50
-     * Selector for the ID of the event in the event editor
51
-     * @var string
52
-     */
53
-    const EVENT_EDITOR_EVT_ID_SELECTOR = "//input[@id='post_ID']";
54
-
55
-
56
-    /**
57
-     * Selector for the search input on the event list table page.
58
-     * @var string
59
-     */
60
-    const EVENT_LIST_TABLE_SEARCH_INPUT_SELECTOR = '#toplevel_page_espresso_events-search-input';
61
-
62
-
63
-
64
-
65
-    /**
66
-     * @param string $additional_params
67
-     * @return string
68
-     */
69
-    public static function defaultEventsListTableUrl($additional_params = '')
70
-    {
71
-        return self::adminUrl('espresso_events', 'default', $additional_params);
72
-    }
73
-
74
-
75
-    /**
76
-     * The selector for the DTTname field for the given row in the event editor.
77
-     * @param int $row_number
78
-     * @return string
79
-     */
80
-    public static function eventEditorDatetimeNameFieldSelector($row_number = 1)
81
-    {
82
-        return self::eventEditorDatetimeFieldSelectorForField('DTT_name', $row_number);
83
-    }
84
-
85
-
86
-    /**
87
-     * The selector for the DTT_EVT_start field for the given row in the event editor.d
88
-     * @param int $row_number
89
-     * @return string
90
-     */
91
-    public static function eventEditorDatetimeStartDateFieldSelector($row_number = 1)
92
-    {
93
-        return self::eventEditorDatetimeFieldSelectorForField('DTT_EVT_start', $row_number);
94
-    }
95
-
96
-
97
-    /**
98
-     * Wrapper for getting the selector for a given field and given row of a datetime in the event editor.
99
-     *
100
-     * @param string $field_name
101
-     * @param int    $row_number
102
-     * @return string
103
-     */
104
-    public static function eventEditorDatetimeFieldSelectorForField($field_name, $row_number = 1)
105
-    {
106
-        return "//input[@id='event-datetime-$field_name-$row_number']";
107
-    }
108
-
109
-
110
-    /**
111
-     * The selector for the TKT_name field for the given display row in the event editor.
112
-     * @param int $row_number
113
-     * @return string
114
-     */
115
-    public static function eventEditorTicketNameFieldSelector($row_number = 1)
116
-    {
117
-        return self::eventEditorTicketFieldSelectorForFieldInDisplayRow('TKT_name', $row_number);
118
-    }
119
-
120
-
121
-    /**
122
-     * Wrapper for getting the selector for a given field and given display row of a ticket in the event editor.
123
-     * @param     $field_name
124
-     * @param int $row_number
125
-     * @return string
126
-     */
127
-    public static function eventEditorTicketFieldSelectorForFieldInDisplayRow($field_name, $row_number = 1)
128
-    {
129
-        return "//tr[@id='display-ticketrow-$row_number']"
130
-               . "/td[2]/input[@class='edit-ticket-$field_name ee-large-text-inp']";
131
-    }
132
-
133
-
134
-    /**
135
-     * Returns the selector for the event title edit link in the events list table for the given Event Title.
136
-     * @param string $event_title
137
-     * @return string
138
-     */
139
-    public static function eventListTableEventTitleEditLinkSelectorForTitle($event_title)
140
-    {
141
-        return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']";
142
-    }
143
-
144
-
145
-    /**
146
-     * Locator for for the ID column in the event list table for a given event title.
147
-     * @param string $event_title
148
-     * @return string
149
-     */
150
-    public static function eventListTableEventIdSelectorForTitle($event_title)
151
-    {
152
-        return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']"
153
-               . "//ancestor::tr/th[contains(@class, 'check-column')]/input";
154
-    }
155
-
156
-
157
-    /**
158
-     * Locator for the view link in the row of an event list table for the given event title.
159
-     * @param string $event_title
160
-     * @return string
161
-     */
162
-    public static function eventListTableEventTitleViewLinkSelectorForTitle($event_title)
163
-    {
164
-        return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']"
165
-               . "//ancestor::td//span[@class='view']/a";
166
-    }
167
-
168
-
169
-    /**
170
-     * Locator for the messenger tab in the Notifications metabox in the event editor.
171
-     * @param string $messenger_slug  The slug for the messenger (it's reference slug).
172
-     * @return string
173
-     */
174
-    public static function eventEditorNotificationsMetaBoxMessengerTabSelector($messenger_slug)
175
-    {
176
-        return "//div[@id='espresso_events_Messages_Hooks_Extend_messages_metabox_metabox']"
177
-               . "//a[@rel='ee-tab-$messenger_slug']";
178
-    }
179
-
180
-
181
-    /**
182
-     * Locator for the select input within the notifications metabox.
183
-     * Note, this assumes the tab content for the related messenger is already visible.
184
-     * @param string $message_type_label The message type label (visible string in the table) you want the selector for.
185
-     * @return string
186
-     */
187
-    public static function eventEditorNotificationsMetaBoxSelectSelectorForMessageType($message_type_label)
188
-    {
189
-        return "//div[@id='espresso_events_Messages_Hooks_Extend_messages_metabox_metabox']"
190
-               . "//table[@class='messages-custom-template-switcher']"
191
-               . "//tr/td[contains(.,'Registration Approved')]"
192
-               . "//ancestor::tr//select[contains(@class,'message-template-selector')]";
193
-    }
17
+	/**
18
+	 * Selector for the Add new Event button in the admin.
19
+	 * @var string
20
+	 */
21
+	const ADD_NEW_EVENT_BUTTON_SELECTOR = '#add-new-event';
22
+
23
+
24
+	/**
25
+	 * Selector for the Event Title field in the event editor
26
+	 * @var string
27
+	 */
28
+	const EVENT_EDITOR_TITLE_FIELD_SELECTOR = "//input[@id='title']";
29
+
30
+	/**
31
+	 * Selector for the publish submit button in the event editor.
32
+	 * @var string
33
+	 */
34
+	const EVENT_EDITOR_PUBLISH_BUTTON_SELECTOR = "#publish";
35
+
36
+
37
+	/**
38
+	 * @var string
39
+	 */
40
+	const EVENT_EDITOR_DEFAULT_REGISTRATION_STATUS_FIELD_SELECTOR = '#EVT_default_registration_status';
41
+
42
+	/**
43
+	 * Selector for the view link after publishing an event.
44
+	 * @var string
45
+	 */
46
+	const EVENT_EDITOR_VIEW_LINK_AFTER_PUBLISH_SELECTOR = "//div[@id='message']/p/a";
47
+
48
+
49
+	/**
50
+	 * Selector for the ID of the event in the event editor
51
+	 * @var string
52
+	 */
53
+	const EVENT_EDITOR_EVT_ID_SELECTOR = "//input[@id='post_ID']";
54
+
55
+
56
+	/**
57
+	 * Selector for the search input on the event list table page.
58
+	 * @var string
59
+	 */
60
+	const EVENT_LIST_TABLE_SEARCH_INPUT_SELECTOR = '#toplevel_page_espresso_events-search-input';
61
+
62
+
63
+
64
+
65
+	/**
66
+	 * @param string $additional_params
67
+	 * @return string
68
+	 */
69
+	public static function defaultEventsListTableUrl($additional_params = '')
70
+	{
71
+		return self::adminUrl('espresso_events', 'default', $additional_params);
72
+	}
73
+
74
+
75
+	/**
76
+	 * The selector for the DTTname field for the given row in the event editor.
77
+	 * @param int $row_number
78
+	 * @return string
79
+	 */
80
+	public static function eventEditorDatetimeNameFieldSelector($row_number = 1)
81
+	{
82
+		return self::eventEditorDatetimeFieldSelectorForField('DTT_name', $row_number);
83
+	}
84
+
85
+
86
+	/**
87
+	 * The selector for the DTT_EVT_start field for the given row in the event editor.d
88
+	 * @param int $row_number
89
+	 * @return string
90
+	 */
91
+	public static function eventEditorDatetimeStartDateFieldSelector($row_number = 1)
92
+	{
93
+		return self::eventEditorDatetimeFieldSelectorForField('DTT_EVT_start', $row_number);
94
+	}
95
+
96
+
97
+	/**
98
+	 * Wrapper for getting the selector for a given field and given row of a datetime in the event editor.
99
+	 *
100
+	 * @param string $field_name
101
+	 * @param int    $row_number
102
+	 * @return string
103
+	 */
104
+	public static function eventEditorDatetimeFieldSelectorForField($field_name, $row_number = 1)
105
+	{
106
+		return "//input[@id='event-datetime-$field_name-$row_number']";
107
+	}
108
+
109
+
110
+	/**
111
+	 * The selector for the TKT_name field for the given display row in the event editor.
112
+	 * @param int $row_number
113
+	 * @return string
114
+	 */
115
+	public static function eventEditorTicketNameFieldSelector($row_number = 1)
116
+	{
117
+		return self::eventEditorTicketFieldSelectorForFieldInDisplayRow('TKT_name', $row_number);
118
+	}
119
+
120
+
121
+	/**
122
+	 * Wrapper for getting the selector for a given field and given display row of a ticket in the event editor.
123
+	 * @param     $field_name
124
+	 * @param int $row_number
125
+	 * @return string
126
+	 */
127
+	public static function eventEditorTicketFieldSelectorForFieldInDisplayRow($field_name, $row_number = 1)
128
+	{
129
+		return "//tr[@id='display-ticketrow-$row_number']"
130
+			   . "/td[2]/input[@class='edit-ticket-$field_name ee-large-text-inp']";
131
+	}
132
+
133
+
134
+	/**
135
+	 * Returns the selector for the event title edit link in the events list table for the given Event Title.
136
+	 * @param string $event_title
137
+	 * @return string
138
+	 */
139
+	public static function eventListTableEventTitleEditLinkSelectorForTitle($event_title)
140
+	{
141
+		return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']";
142
+	}
143
+
144
+
145
+	/**
146
+	 * Locator for for the ID column in the event list table for a given event title.
147
+	 * @param string $event_title
148
+	 * @return string
149
+	 */
150
+	public static function eventListTableEventIdSelectorForTitle($event_title)
151
+	{
152
+		return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']"
153
+			   . "//ancestor::tr/th[contains(@class, 'check-column')]/input";
154
+	}
155
+
156
+
157
+	/**
158
+	 * Locator for the view link in the row of an event list table for the given event title.
159
+	 * @param string $event_title
160
+	 * @return string
161
+	 */
162
+	public static function eventListTableEventTitleViewLinkSelectorForTitle($event_title)
163
+	{
164
+		return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']"
165
+			   . "//ancestor::td//span[@class='view']/a";
166
+	}
167
+
168
+
169
+	/**
170
+	 * Locator for the messenger tab in the Notifications metabox in the event editor.
171
+	 * @param string $messenger_slug  The slug for the messenger (it's reference slug).
172
+	 * @return string
173
+	 */
174
+	public static function eventEditorNotificationsMetaBoxMessengerTabSelector($messenger_slug)
175
+	{
176
+		return "//div[@id='espresso_events_Messages_Hooks_Extend_messages_metabox_metabox']"
177
+			   . "//a[@rel='ee-tab-$messenger_slug']";
178
+	}
179
+
180
+
181
+	/**
182
+	 * Locator for the select input within the notifications metabox.
183
+	 * Note, this assumes the tab content for the related messenger is already visible.
184
+	 * @param string $message_type_label The message type label (visible string in the table) you want the selector for.
185
+	 * @return string
186
+	 */
187
+	public static function eventEditorNotificationsMetaBoxSelectSelectorForMessageType($message_type_label)
188
+	{
189
+		return "//div[@id='espresso_events_Messages_Hooks_Extend_messages_metabox_metabox']"
190
+			   . "//table[@class='messages-custom-template-switcher']"
191
+			   . "//tr/td[contains(.,'Registration Approved')]"
192
+			   . "//ancestor::tr//select[contains(@class,'message-template-selector')]";
193
+	}
194 194
 }
Please login to merge, or discard this patch.
acceptance_tests/Helpers/BaseCoreAdmin.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -13,58 +13,58 @@
 block discarded – undo
13 13
 trait BaseCoreAdmin
14 14
 {
15 15
 
16
-    /**
17
-     * Core method for going to an Event Espresso Admin page.
18
-     * @param string $page
19
-     * @param string $action
20
-     * @param string $additional_params
21
-     */
22
-    public function amOnEventEspressoAdminPage($page = '', $action = '', $additional_params = '')
23
-    {
24
-        $this->actor()->amOnAdminPage(CoreAdmin::adminUrl($page, $action, $additional_params));
25
-    }
16
+	/**
17
+	 * Core method for going to an Event Espresso Admin page.
18
+	 * @param string $page
19
+	 * @param string $action
20
+	 * @param string $additional_params
21
+	 */
22
+	public function amOnEventEspressoAdminPage($page = '', $action = '', $additional_params = '')
23
+	{
24
+		$this->actor()->amOnAdminPage(CoreAdmin::adminUrl($page, $action, $additional_params));
25
+	}
26 26
 
27 27
 
28
-    /**
29
-     * Helper method for returning an instance of the Actor.  Intended to help with IDE fill out of methods.
30
-     * @return \EventEspressoAcceptanceTester;
31
-     */
32
-    protected function actor()
33
-    {
34
-        /** @var \EventEspressoAcceptanceTester $this */
35
-        return $this;
36
-    }
28
+	/**
29
+	 * Helper method for returning an instance of the Actor.  Intended to help with IDE fill out of methods.
30
+	 * @return \EventEspressoAcceptanceTester;
31
+	 */
32
+	protected function actor()
33
+	{
34
+		/** @var \EventEspressoAcceptanceTester $this */
35
+		return $this;
36
+	}
37 37
 
38 38
 
39
-    /**
40
-     * Use this to set the per page option for a list table page.
41
-     * Assumes you are on a page that has this field exposed.
42
-     *
43
-     * @param int|string $per_page_value
44
-     * @throws \Codeception\Exception\TestRuntimeException
45
-     */
46
-    public function setPerPageOptionForScreen($per_page_value)
47
-    {
48
-        $this->actor()->click(CoreAdmin::WP_SCREEN_SETTINGS_LINK_SELECTOR);
49
-        $this->actor()->fillField(CoreAdmin::WP_SCREEN_SETTINGS_PER_PAGE_FIELD_SELECTOR, $per_page_value);
50
-        $this->actor()->click(CoreAdmin::WP_SCREEN_OPTIONS_APPLY_SETTINGS_BUTTON_SELECTOR);
51
-        $this->actor()->wait(8);
52
-    }
39
+	/**
40
+	 * Use this to set the per page option for a list table page.
41
+	 * Assumes you are on a page that has this field exposed.
42
+	 *
43
+	 * @param int|string $per_page_value
44
+	 * @throws \Codeception\Exception\TestRuntimeException
45
+	 */
46
+	public function setPerPageOptionForScreen($per_page_value)
47
+	{
48
+		$this->actor()->click(CoreAdmin::WP_SCREEN_SETTINGS_LINK_SELECTOR);
49
+		$this->actor()->fillField(CoreAdmin::WP_SCREEN_SETTINGS_PER_PAGE_FIELD_SELECTOR, $per_page_value);
50
+		$this->actor()->click(CoreAdmin::WP_SCREEN_OPTIONS_APPLY_SETTINGS_BUTTON_SELECTOR);
51
+		$this->actor()->wait(8);
52
+	}
53 53
 
54 54
 
55 55
 
56
-    /**
57
-     * Use this to append a given value to a wpEditor instance.
58
-     * How it works is it first switched the instance to the text (or html) view so that the textarea is exposed and
59
-     * the value is added to the text area.
60
-     *
61
-     * @param $field_reference
62
-     * @param $value
63
-     * @throws \Codeception\Exception\ElementNotFound
64
-     */
65
-    public function appendToWPEditorField($field_reference, $value)
66
-    {
67
-        $this->actor()->click(CoreAdmin::wpEditorTextTabSelector($field_reference));
68
-        $this->actor()->appendField(CoreAdmin::wpEditorTextAreaSelector($field_reference), $value);
69
-    }
56
+	/**
57
+	 * Use this to append a given value to a wpEditor instance.
58
+	 * How it works is it first switched the instance to the text (or html) view so that the textarea is exposed and
59
+	 * the value is added to the text area.
60
+	 *
61
+	 * @param $field_reference
62
+	 * @param $value
63
+	 * @throws \Codeception\Exception\ElementNotFound
64
+	 */
65
+	public function appendToWPEditorField($field_reference, $value)
66
+	{
67
+		$this->actor()->click(CoreAdmin::wpEditorTextTabSelector($field_reference));
68
+		$this->actor()->appendField(CoreAdmin::wpEditorTextAreaSelector($field_reference), $value);
69
+	}
70 70
 }
Please login to merge, or discard this patch.