admin
6 months ago
field-groups
6 months ago
fields
6 months ago
fields-settings
6 months ago
locations
1 year ago
modules
6 months ago
screens
7 months ago
acfe-deprecated-functions.php
2 years ago
acfe-field-functions.php
1 year ago
acfe-field-group-functions.php
2 years ago
acfe-file-functions.php
1 year ago
acfe-form-functions.php
2 years ago
acfe-helper-functions.php
6 months ago
acfe-meta-functions.php
3 years ago
acfe-post-functions.php
3 years ago
acfe-screen-functions.php
3 years ago
acfe-template-functions.php
1 year ago
acfe-term-functions.php
3 years ago
acfe-user-functions.php
3 years ago
acfe-wp-functions.php
3 years ago
assets.php
2 years ago
compatibility-acf-6.0.php
7 months ago
compatibility-acf-6.4.php
6 months ago
compatibility-acf-6.5.php
6 months ago
compatibility.php
7 months ago
field-extend.php
6 months ago
field.php
6 months ago
hooks.php
3 years ago
init.php
6 months ago
local-meta.php
3 years ago
module-acf.php
2 years ago
module-db.php
3 years ago
module-l10n.php
2 years ago
module-legacy.php
3 years ago
module-manager.php
3 years ago
module-post.php
2 years ago
module-posts.php
2 years ago
module-upgrades.php
3 years ago
module.php
2 years ago
multilang.php
3 years ago
settings.php
3 years ago
template-tags.php
7 months ago
third-party.php
3 years ago
upgrades.php
10 months ago
init.php
230 lines
| 1 | <?php |
| 2 | |
| 3 | if(!defined('ABSPATH')){ |
| 4 | exit; |
| 5 | } |
| 6 | |
| 7 | /** |
| 8 | * acfe_has_acf |
| 9 | * |
| 10 | * Checks ACF version |
| 11 | * |
| 12 | * @return bool |
| 13 | */ |
| 14 | function acfe_has_acf(){ |
| 15 | return class_exists('ACF') && defined('ACF_PRO') && defined('ACF_VERSION') && version_compare(ACF_VERSION, '5.8', '>='); |
| 16 | } |
| 17 | |
| 18 | /** |
| 19 | * acfe_is_acf_59 |
| 20 | * |
| 21 | * @return bool |
| 22 | */ |
| 23 | function acfe_is_acf_59(){ |
| 24 | return acf_version_compare(acf_get_setting('version'), '>=', '5.9'); |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * acfe_is_acf_6 |
| 29 | * |
| 30 | * @return bool |
| 31 | */ |
| 32 | function acfe_is_acf_6(){ |
| 33 | return acf_version_compare(acf_get_setting('version'), '>=', '6.0'); |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * acfe_is_acf_61 |
| 38 | * |
| 39 | * @return bool |
| 40 | */ |
| 41 | function acfe_is_acf_61(){ |
| 42 | return acf_version_compare(acf_get_setting('version'), '>=', '6.1'); |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * acfe_is_acf_622 |
| 47 | * |
| 48 | * @return bool |
| 49 | */ |
| 50 | function acfe_is_acf_622(){ |
| 51 | return acf_version_compare(acf_get_setting('version'), '>=', '6.2.2'); |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * acfe_is_acf_64 |
| 56 | * |
| 57 | * @return bool |
| 58 | */ |
| 59 | function acfe_is_acf_64(){ |
| 60 | return acf_version_compare(acf_get_setting('version'), '>=', '6.4'); |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * acfe_is_acf_65 |
| 65 | * |
| 66 | * @return bool |
| 67 | */ |
| 68 | function acfe_is_acf_65(){ |
| 69 | return acf_version_compare(acf_get_setting('version'), '>=', '6.5'); |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * acfe_is_acf_66 |
| 74 | * |
| 75 | * @return bool |
| 76 | */ |
| 77 | function acfe_is_acf_66(){ |
| 78 | return acf_version_compare(acf_get_setting('version'), '>=', '6.6'); |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * acfe_include |
| 83 | * |
| 84 | * Includes a file within the plugin |
| 85 | * |
| 86 | * @param $filename |
| 87 | * @param $once |
| 88 | * |
| 89 | * @return false|mixed |
| 90 | */ |
| 91 | function acfe_include($filename = '', $once = true){ |
| 92 | |
| 93 | $file_path = acfe_get_path($filename); |
| 94 | |
| 95 | if(file_exists($file_path)){ |
| 96 | if($once){ |
| 97 | return include_once($file_path); |
| 98 | }else{ |
| 99 | return include($file_path); |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | return false; |
| 104 | |
| 105 | } |
| 106 | |
| 107 | /** |
| 108 | * acfe_get_path |
| 109 | * |
| 110 | * Returns the plugin path |
| 111 | * |
| 112 | * @param string $filename |
| 113 | * |
| 114 | * @return string |
| 115 | */ |
| 116 | function acfe_get_path($filename = ''){ |
| 117 | return ACFE_PATH . ltrim($filename, '/'); |
| 118 | } |
| 119 | |
| 120 | /** |
| 121 | * acfe_get_url |
| 122 | * |
| 123 | * Returns the plugin url |
| 124 | * |
| 125 | * @param string $filename |
| 126 | * |
| 127 | * @return string |
| 128 | */ |
| 129 | function acfe_get_url($filename = ''){ |
| 130 | |
| 131 | if(!defined('ACFE_URL')){ |
| 132 | define('ACFE_URL', acf_get_setting('acfe/url')); |
| 133 | } |
| 134 | |
| 135 | return ACFE_URL . ltrim($filename, '/'); |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * acfe_get_view |
| 140 | * |
| 141 | * Load in a file from the 'admin/views' folder and allow variables to be passed through |
| 142 | * Based on acf_get_view() |
| 143 | * |
| 144 | * @param string $path |
| 145 | * @param array $args |
| 146 | */ |
| 147 | function acfe_get_view($path = '', $args = array()){ |
| 148 | |
| 149 | // allow view file name shortcut |
| 150 | if(substr($path, -4) !== '.php'){ |
| 151 | $path = acfe_get_path("includes/admin/views/{$path}.php"); |
| 152 | } |
| 153 | |
| 154 | // include |
| 155 | if(file_exists($path)){ |
| 156 | |
| 157 | extract($args); |
| 158 | include($path); |
| 159 | |
| 160 | } |
| 161 | |
| 162 | } |
| 163 | |
| 164 | /** |
| 165 | * acfe_load_textdomain |
| 166 | * |
| 167 | * Load textdomain files based on acf_load_textdomain() |
| 168 | * |
| 169 | * @param string $domain |
| 170 | * |
| 171 | * @return bool |
| 172 | */ |
| 173 | function acfe_load_textdomain($domain = 'acfe'){ |
| 174 | |
| 175 | $locale = apply_filters('plugin_locale', acf_get_locale(), $domain); |
| 176 | $mofile = $domain . '-' . $locale . '.mo'; |
| 177 | |
| 178 | // Try to load from the languages directory first. |
| 179 | if(load_textdomain($domain, WP_LANG_DIR . '/plugins/' . $mofile)){ |
| 180 | return true; |
| 181 | } |
| 182 | |
| 183 | // Load from plugin lang folder. |
| 184 | return load_textdomain($domain, acfe_get_path('lang/' . $mofile)); |
| 185 | |
| 186 | } |
| 187 | |
| 188 | /** |
| 189 | * acfe_after_plugin_row |
| 190 | * |
| 191 | * after_plugin_row |
| 192 | * |
| 193 | * @param $plugin_file |
| 194 | * @param $plugin_data |
| 195 | * @param $status |
| 196 | */ |
| 197 | add_action('after_plugin_row_' . ACFE_BASENAME, 'acfe_after_plugin_row', 5, 3); |
| 198 | function acfe_after_plugin_row($plugin_file, $plugin_data, $status){ |
| 199 | |
| 200 | // bail early |
| 201 | if(acfe_has_acf()){ |
| 202 | return; |
| 203 | } |
| 204 | |
| 205 | // vars |
| 206 | $colspan = version_compare($GLOBALS['wp_version'], '5.5', '<') ? 3 : 4; |
| 207 | |
| 208 | // class |
| 209 | $class = 'acfe-plugin-tr'; |
| 210 | if(isset($plugin_data['update']) && !empty($plugin_data['update'])){ |
| 211 | $class .= ' acfe-plugin-tr-update'; |
| 212 | } |
| 213 | |
| 214 | ?> |
| 215 | <style> |
| 216 | .plugins tr[data-plugin='<?php echo $plugin_file; ?>'] th, |
| 217 | .plugins tr[data-plugin='<?php echo $plugin_file; ?>'] td{ |
| 218 | box-shadow:none; |
| 219 | } |
| 220 | </style> |
| 221 | <tr class="plugin-update-tr active <?php echo $class; ?>"> |
| 222 | <td colspan="<?php echo $colspan; ?>" class="plugin-update colspanchange"> |
| 223 | <div class="update-message notice inline notice-error notice-alt"> |
| 224 | <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> |
| 225 | </div> |
| 226 | </td> |
| 227 | </tr> |
| 228 | <?php |
| 229 | |
| 230 | } |