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.5 1.3.8.6 1.3.8.7 1.3.8.8 1.3.8.9 1.3.9.0 1.3.9.1 1.3.9.2 1.3.9.3 1.3.9.4 1.3.9.5 1.3.9.6 1.3.9.7 1.3.9.8 1.3.9.9 1.4 1.4.0.1 1.4.0.2 1.4.0.3 1.4.0.4
wp-asset-clean-up / classes / LoadExceptions.php
wp-asset-clean-up / classes Last commit date
Admin 1 week ago OptimiseAssets 1 week ago ThirdParty 1 year ago AdminBar.php 1 week ago AssetsManager.php 1 week ago BulkChanges.php 1 week ago CleanUp.php 2 months ago Debug.php 1 week ago DebugException.php 1 week ago FileSystem.php 1 year ago HardcodedAssets.php 1 week ago LoadExceptions.php 1 week ago Main.php 1 week ago MainFront.php 1 week ago Maintenance.php 1 week ago Menu.php 1 week ago MetaBoxes.php 1 week ago Misc.php 1 week ago MiscArray.php 1 week ago ObjectCache.php 2 months ago OwnAssets.php 1 week ago PluginTracking.php 1 week ago Preloads.php 1 week ago Regex.php 1 week ago Settings.php 1 week ago Tips.php 1 year ago Update.php 1 week ago
LoadExceptions.php
133 lines
1 <?php
2 namespace WpAssetCleanUp;
3
4 /**
5 * Class LoadExceptions
6 * @package WpAssetCleanUp
7 */
8 class LoadExceptions
9 {
10 /**
11 * Case 1: If $postType is not mentioned, it will get all post types
12 * Case 2: If $postType is set and $assetType & $handle are not set, it will get all rules for $postType
13 * Case 3: If all parameters are set, it will get any terms set for the CSS/JS handle loaded within $postType pages
14 *
15 * @param string $postType
16 * @param string $assetType
17 * @param string $handle
18 *
19 * @return array|\array[][]|mixed
20 */
21 public static function getTaxonomyValuesAssocToPostTypeLoadExceptions($postType = '', $assetType = '', $handle = '')
22 {
23 $exceptionsListDefault = array();
24
25 if ($postType) {
26 if ($assetType === '' && $handle === '') {
27 // Default for all results for this $postType
28 $exceptionsListDefault = array($postType => array('styles' => array(), 'scripts' => array()));
29 } else {
30 // Default for the terms list for the specific $handle of $assetType ("styles" or "scripts")
31 $exceptionsListDefault = array();
32 }
33 }
34
35 $exceptionsListJson = get_option(WPACU_PLUGIN_ID . '_post_type_via_tax_load_exceptions');
36 $exceptionsList = @json_decode($exceptionsListJson, true);
37
38 // Issues with decoding the JSON file? Return an empty list
39 if (wpacuJsonLastError() !== JSON_ERROR_NONE) {
40 return $exceptionsListDefault;
41 }
42
43 // Return any handles added as load exceptions for the requested $postType
44 if ($postType !== '' && isset($exceptionsList[$postType])) {
45 /*
46 * Fetch load exceptions for a certain handle (either a CSS or a JS)
47 */
48 if ( ! empty($exceptionsList[$postType][$assetType][$handle]['values'])) {
49 return $exceptionsList[$postType] [$assetType] [$handle] ['values'];
50 }
51
52 if ($assetType === '' && $handle === '') {
53 /*
54 * Fetch all load exceptions (CSS & JS)
55 */
56 return $exceptionsList[$postType];
57 }
58 } elseif (is_array($exceptionsList) && ! empty($exceptionsList)) {
59 return $exceptionsList;
60 }
61
62 return $exceptionsListDefault;
63 }
64
65 /**
66 * e.g. When an asset is unloaded, site-wide
67 * exceptions to the rule can be added, for the asset to load on all pages of [taxonomy] type
68 * You might need a CSS/JS to be unloaded site-wide, but on /category/food/, /category/other/
69 * you can make an exception, and have the CSS/JS loaded
70 *
71 * @param $taxonomy (optional, if it's not there, all load exceptions will load for all taxonomies)
72 *
73 * @return array|array[]|mixed
74 */
75 public static function getLoadExceptionsViaTaxType($taxonomy = '')
76 {
77 if ($taxonomy) {
78 // Default for all results for this $taxonomy
79 $exceptionsListDefault = array($taxonomy => array('styles' => array(), 'scripts' => array()));
80 } else {
81 // Default for the asset list for the specific $taxonomy ("styles" / "scripts")
82 $exceptionsListDefault = array();
83 }
84
85 $exceptionsListJson = get_option(WPACU_PLUGIN_ID . '_tax_type_load_exceptions');
86
87 $exceptionsList = @json_decode($exceptionsListJson, true);
88
89 // Issues with decoding the JSON file? Return an empty list
90 if (wpacuJsonLastError() !== JSON_ERROR_NONE) {
91 return $exceptionsListDefault;
92 }
93
94 // Return any handles added as load exceptions for the requested $taxonomy
95 if ($taxonomy !== '' && isset($exceptionsList[$taxonomy])) {
96 return $exceptionsList[$taxonomy];
97 }
98
99 if (is_array($exceptionsList) && ! empty($exceptionsList)) {
100 return $exceptionsList;
101 }
102
103 return $exceptionsListDefault;
104 }
105
106 /**
107 * e.g. When an asset is unloaded, site-wide
108 * * exceptions to the rule can be added, for the asset to load on all archive pages of any author
109 * * You might need a CSS/JS to be unloaded site-wide, but on /author/[any_author_title_slug_here]/
110 * * you can make an exception, and have the CSS/JS loaded
111 *
112 * @return array|array[]
113 */
114 public static function getLoadExceptionsViaAuthorType()
115 {
116 $exceptionsListDefault = array('styles' => array(), 'scripts' => array());
117
118 $exceptionsListJson = get_option(WPACU_PLUGIN_ID . '_author_type_load_exceptions');
119
120 $exceptionsList = @json_decode($exceptionsListJson, true);
121
122 // Issues with decoding the JSON file? Return an empty list
123 if (wpacuJsonLastError() !== JSON_ERROR_NONE) {
124 return $exceptionsListDefault;
125 }
126
127 if (is_array($exceptionsList) && ! empty($exceptionsList)) {
128 return $exceptionsList;
129 }
130
131 return $exceptionsListDefault;
132 }
133 }