admin
1 month ago
field-groups
1 month ago
fields
1 month ago
fields-settings
1 month ago
forms
1 month ago
locations
1 month ago
modules
1 month ago
screens
1 month ago
acfe-deprecated-functions.php
2 years ago
acfe-field-functions.php
1 month ago
acfe-field-group-functions.php
1 month ago
acfe-file-functions.php
1 year ago
acfe-form-functions.php
1 month ago
acfe-helper-array-functions.php
1 month ago
acfe-helper-functions.php
1 month ago
acfe-helper-multi-functions.php
1 month ago
acfe-helper-string-functions.php
1 month ago
acfe-meta-functions.php
1 month ago
acfe-post-functions.php
1 month ago
acfe-screen-functions.php
1 month ago
acfe-template-functions.php
1 month ago
acfe-term-functions.php
1 month ago
acfe-user-functions.php
1 month ago
acfe-wp-functions.php
3 years ago
assets.php
1 month ago
compatibility-acf-5.8.php
2 months ago
compatibility-acf-5.9.php
1 month ago
compatibility-acf-6.5.php
1 month ago
compatibility.php
1 month ago
field-extend.php
2 months ago
field.php
2 months ago
hooks.php
1 month ago
init.php
1 month ago
local-meta.php
3 years ago
media.php
1 month ago
module-acf.php
1 month ago
module-db.php
1 month ago
module-l10n.php
1 month ago
module-legacy.php
3 years ago
module-manager.php
2 months ago
module-post.php
1 month ago
module-posts.php
2 months ago
module-upgrades.php
3 years ago
module.php
1 month ago
multilang.php
1 month ago
revisions.php
2 months ago
screen.php
1 month ago
settings.php
1 month ago
template-tags.php
1 month ago
third-party.php
3 years ago
upgrades.php
1 month ago
init.php
304 lines
| 1 | <?php |
| 2 | |
| 3 | if(!defined('ABSPATH')){ |
| 4 | exit; |
| 5 | } |
| 6 | |
| 7 | /** |
| 8 | * acfe_is_acf |
| 9 | * |
| 10 | * Check the ACF version |
| 11 | * |
| 12 | * @param $min |
| 13 | * @param $max |
| 14 | * |
| 15 | * @return bool |
| 16 | */ |
| 17 | function acfe_is_acf($min = '', $max = ''){ |
| 18 | |
| 19 | // no version to check |
| 20 | if(empty($min) && empty($max)){ |
| 21 | return class_exists('ACF') && defined('ACF_PRO') && defined('ACF_VERSION') && version_compare(ACF_VERSION, '5.8', '>='); |
| 22 | } |
| 23 | |
| 24 | // get version |
| 25 | $version = (string) acf_get_setting('version'); |
| 26 | $version = preg_replace('/[^0-9.].*$/', '', $version); // remove any non-numeric characters (e.g. -beta) |
| 27 | |
| 28 | // check only one version |
| 29 | if(empty($max)){ |
| 30 | return acf_version_compare($version, '>=', $min); |
| 31 | } |
| 32 | |
| 33 | // check both versions |
| 34 | return acf_version_compare($version, '>=', $min) && acf_version_compare($version, '<', $max); |
| 35 | } |
| 36 | |
| 37 | |
| 38 | /** |
| 39 | * acfe_is_wp |
| 40 | * |
| 41 | * Check the WP version |
| 42 | * |
| 43 | * @param $min |
| 44 | * @param $max |
| 45 | * |
| 46 | * @return bool |
| 47 | */ |
| 48 | function acfe_is_wp($min = '', $max = ''){ |
| 49 | |
| 50 | // get version |
| 51 | global $wp_version; |
| 52 | $version = (string) $wp_version; |
| 53 | $version = preg_replace('/[^0-9.].*$/', '', $version); // remove any non-numeric characters (e.g. -beta) |
| 54 | |
| 55 | // check only one version |
| 56 | if(empty($max)){ |
| 57 | return acf_version_compare($version, '>=', $min); |
| 58 | } |
| 59 | |
| 60 | // check both versions |
| 61 | return acf_version_compare($version, '>=', $min) && acf_version_compare($version, '<', $max); |
| 62 | } |
| 63 | |
| 64 | |
| 65 | /** |
| 66 | * acfe_include |
| 67 | * |
| 68 | * Includes a file within the plugin |
| 69 | * |
| 70 | * @param $filename |
| 71 | * @param $once |
| 72 | * |
| 73 | * @return false|mixed |
| 74 | */ |
| 75 | function acfe_include($filename = '', $once = true){ |
| 76 | |
| 77 | $file_path = acfe_get_path($filename); |
| 78 | |
| 79 | if(file_exists($file_path)){ |
| 80 | if($once){ |
| 81 | return include_once($file_path); |
| 82 | }else{ |
| 83 | return include($file_path); |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | return false; |
| 88 | |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * acfe_get_path |
| 93 | * |
| 94 | * Returns the plugin path |
| 95 | * |
| 96 | * @param string $filename |
| 97 | * |
| 98 | * @return string |
| 99 | */ |
| 100 | function acfe_get_path($filename = ''){ |
| 101 | return ACFE_PATH . ltrim($filename, '/'); |
| 102 | } |
| 103 | |
| 104 | /** |
| 105 | * acfe_get_url |
| 106 | * |
| 107 | * Returns the plugin url |
| 108 | * |
| 109 | * @param string $filename |
| 110 | * |
| 111 | * @return string |
| 112 | */ |
| 113 | function acfe_get_url($filename = ''){ |
| 114 | |
| 115 | if(!defined('ACFE_URL')){ |
| 116 | define('ACFE_URL', acf_get_setting('acfe/url')); |
| 117 | } |
| 118 | |
| 119 | return ACFE_URL . ltrim($filename, '/'); |
| 120 | } |
| 121 | |
| 122 | /** |
| 123 | * acfe_get_view |
| 124 | * |
| 125 | * Load in a file from the 'admin/views' folder and allow variables to be passed through |
| 126 | * Based on acf_get_view() |
| 127 | * |
| 128 | * @param string $path |
| 129 | * @param array $args |
| 130 | */ |
| 131 | function acfe_get_view($path = '', $args = array()){ |
| 132 | |
| 133 | // allow view file name shortcut |
| 134 | if(substr($path, -4) !== '.php'){ |
| 135 | $path = acfe_get_path("includes/admin/views/{$path}.php"); |
| 136 | } |
| 137 | |
| 138 | // include |
| 139 | if(file_exists($path)){ |
| 140 | |
| 141 | extract($args); |
| 142 | include($path); |
| 143 | |
| 144 | } |
| 145 | |
| 146 | } |
| 147 | |
| 148 | /** |
| 149 | * acfe_load_textdomain |
| 150 | * |
| 151 | * Load textdomain files based on acf_load_textdomain() |
| 152 | * |
| 153 | * @param string $domain |
| 154 | * |
| 155 | * @return bool |
| 156 | */ |
| 157 | function acfe_load_textdomain($domain = 'acfe'){ |
| 158 | |
| 159 | $locale = apply_filters('plugin_locale', acf_get_locale(), $domain); |
| 160 | $mofile = $domain . '-' . $locale . '.mo'; |
| 161 | |
| 162 | // Try to load from the languages directory first. |
| 163 | if(load_textdomain($domain, WP_LANG_DIR . '/plugins/' . $mofile)){ |
| 164 | return true; |
| 165 | } |
| 166 | |
| 167 | // Load from plugin lang folder. |
| 168 | return load_textdomain($domain, acfe_get_path('lang/' . $mofile)); |
| 169 | |
| 170 | } |
| 171 | |
| 172 | /** |
| 173 | * acfe_after_plugin_row |
| 174 | * |
| 175 | * after_plugin_row |
| 176 | * |
| 177 | * @param $plugin_file |
| 178 | * @param $plugin_data |
| 179 | * @param $status |
| 180 | */ |
| 181 | add_action('after_plugin_row_' . ACFE_BASENAME, 'acfe_after_plugin_row', 5, 3); |
| 182 | function acfe_after_plugin_row($plugin_file, $plugin_data, $status){ |
| 183 | |
| 184 | // bail early |
| 185 | if(acfe_is_acf()){ |
| 186 | return; |
| 187 | } |
| 188 | |
| 189 | // vars |
| 190 | $colspan = version_compare($GLOBALS['wp_version'], '5.5', '<') ? 3 : 4; |
| 191 | |
| 192 | // class |
| 193 | $class = 'acfe-plugin-tr'; |
| 194 | if(isset($plugin_data['update']) && !empty($plugin_data['update'])){ |
| 195 | $class .= ' acfe-plugin-tr-update'; |
| 196 | } |
| 197 | |
| 198 | ?> |
| 199 | <style> |
| 200 | .plugins tr[data-plugin='<?php echo $plugin_file; ?>'] th, |
| 201 | .plugins tr[data-plugin='<?php echo $plugin_file; ?>'] td{ |
| 202 | box-shadow:none; |
| 203 | } |
| 204 | </style> |
| 205 | <tr class="plugin-update-tr active <?php echo $class; ?>"> |
| 206 | <td colspan="<?php echo $colspan; ?>" class="plugin-update colspanchange"> |
| 207 | <div class="update-message notice inline notice-error notice-alt"> |
| 208 | <p><?php _e('ACF Extended requires <a href="https://www.advancedcustomfields.com/pro/" target="_blank">Advanced Custom Fields PRO</a> (minimum: 5.8).', 'acfe'); ?></p> |
| 209 | </div> |
| 210 | </td> |
| 211 | </tr> |
| 212 | <?php |
| 213 | |
| 214 | } |
| 215 | |
| 216 | /** |
| 217 | * acfe_has_acf |
| 218 | * |
| 219 | * Checks ACF version |
| 220 | * |
| 221 | * @depecated |
| 222 | * @return bool |
| 223 | */ |
| 224 | function acfe_has_acf(){ |
| 225 | acfe_deprecated_function(__FUNCTION__, '0.9.2.5', "acfe_is_acf()"); |
| 226 | return acfe_is_acf(); |
| 227 | } |
| 228 | |
| 229 | /** |
| 230 | * acfe_is_acf_59 |
| 231 | * |
| 232 | * @deprecated |
| 233 | * @return bool |
| 234 | */ |
| 235 | function acfe_is_acf_59(){ |
| 236 | acfe_deprecated_function(__FUNCTION__, '0.9.2.5', "acfe_is_acf('5.9')"); |
| 237 | return acfe_is_acf('5.9'); |
| 238 | } |
| 239 | |
| 240 | /** |
| 241 | * acfe_is_acf_6 |
| 242 | * |
| 243 | * @deprecated |
| 244 | * @return bool |
| 245 | */ |
| 246 | function acfe_is_acf_6(){ |
| 247 | acfe_deprecated_function(__FUNCTION__, '0.9.2.5', "acfe_is_acf('6.0')"); |
| 248 | return acfe_is_acf('6.0'); |
| 249 | } |
| 250 | |
| 251 | /** |
| 252 | * acfe_is_acf_61 |
| 253 | * |
| 254 | * @deprecated |
| 255 | * @return bool |
| 256 | */ |
| 257 | function acfe_is_acf_61(){ |
| 258 | acfe_deprecated_function(__FUNCTION__, '0.9.2.5', "acfe_is_acf('6.1')"); |
| 259 | return acfe_is_acf('6.1'); |
| 260 | } |
| 261 | |
| 262 | /** |
| 263 | * acfe_is_acf_622 |
| 264 | * |
| 265 | * @deprecated |
| 266 | * @return bool |
| 267 | */ |
| 268 | function acfe_is_acf_622(){ |
| 269 | acfe_deprecated_function(__FUNCTION__, '0.9.2.5', "acfe_is_acf('6.2.2')"); |
| 270 | return acfe_is_acf('6.2.2'); |
| 271 | } |
| 272 | |
| 273 | /** |
| 274 | * acfe_is_acf_64 |
| 275 | * |
| 276 | * @deprecated |
| 277 | * @return bool |
| 278 | */ |
| 279 | function acfe_is_acf_64(){ |
| 280 | acfe_deprecated_function(__FUNCTION__, '0.9.2.5', "acfe_is_acf('6.4')"); |
| 281 | return acfe_is_acf('6.4'); |
| 282 | } |
| 283 | |
| 284 | /** |
| 285 | * acfe_is_acf_65 |
| 286 | * |
| 287 | * @deprecated |
| 288 | * @return bool |
| 289 | */ |
| 290 | function acfe_is_acf_65(){ |
| 291 | acfe_deprecated_function(__FUNCTION__, '0.9.2.5', "acfe_is_acf('6.5')"); |
| 292 | return acfe_is_acf('6.5'); |
| 293 | } |
| 294 | |
| 295 | /** |
| 296 | * acfe_is_acf_66 |
| 297 | * |
| 298 | * @deprecated |
| 299 | * @return bool |
| 300 | */ |
| 301 | function acfe_is_acf_66(){ |
| 302 | acfe_deprecated_function(__FUNCTION__, '0.9.2.5', "acfe_is_acf('6.6')"); |
| 303 | return acfe_is_acf('6.6'); |
| 304 | } |