admin
2 years ago
field-groups
2 years ago
fields
2 years ago
fields-settings
2 years ago
locations
3 years ago
modules
2 years ago
screens
3 years ago
acfe-deprecated-functions.php
2 years ago
acfe-field-functions.php
2 years ago
acfe-field-group-functions.php
2 years ago
acfe-file-functions.php
3 years ago
acfe-form-functions.php
2 years ago
acfe-helper-functions.php
2 years 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
3 years 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-6.0.php
2 years ago
compatibility.php
2 years ago
field-extend.php
3 years ago
field.php
3 years ago
hooks.php
3 years ago
init.php
3 years ago
local-meta.php
3 years ago
module-acf.php
2 years ago
module-db.php
3 years ago
module-l10n.php
3 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
2 years ago
third-party.php
3 years ago
upgrades.php
3 years ago
init.php
180 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 | /** |
| 20 | * acfe_is_acf_admin_6 |
| 21 | * |
| 22 | * @return bool |
| 23 | */ |
| 24 | function acfe_is_acf_6(){ |
| 25 | return acf_version_compare(acf_get_setting('version'), '>=', '6.0'); |
| 26 | } |
| 27 | |
| 28 | |
| 29 | /** |
| 30 | * acfe_is_acf_admin_61 |
| 31 | * |
| 32 | * @return bool |
| 33 | */ |
| 34 | function acfe_is_acf_61(){ |
| 35 | return acf_version_compare(acf_get_setting('version'), '>=', '6.1'); |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * acfe_include |
| 40 | * |
| 41 | * Includes a file within the plugin |
| 42 | * |
| 43 | * @param string $filename |
| 44 | */ |
| 45 | function acfe_include($filename = ''){ |
| 46 | |
| 47 | $file_path = ACFE_PATH . ltrim($filename, '/'); |
| 48 | |
| 49 | if(file_exists($file_path)){ |
| 50 | return include_once($file_path); |
| 51 | } |
| 52 | |
| 53 | return false; |
| 54 | |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * acfe_get_path |
| 59 | * |
| 60 | * Returns the plugin path |
| 61 | * |
| 62 | * @param string $filename |
| 63 | * |
| 64 | * @return string |
| 65 | */ |
| 66 | function acfe_get_path($filename = ''){ |
| 67 | return ACFE_PATH . ltrim($filename, '/'); |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * acfe_get_url |
| 72 | * |
| 73 | * Returns the plugin url |
| 74 | * |
| 75 | * @param string $filename |
| 76 | * |
| 77 | * @return string |
| 78 | */ |
| 79 | function acfe_get_url($filename = ''){ |
| 80 | |
| 81 | if(!defined('ACFE_URL')){ |
| 82 | define('ACFE_URL', acf_get_setting('acfe/url')); |
| 83 | } |
| 84 | |
| 85 | return ACFE_URL . ltrim($filename, '/'); |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * acfe_get_view |
| 90 | * |
| 91 | * Load in a file from the 'admin/views' folder and allow variables to be passed through |
| 92 | * Based on acf_get_view() |
| 93 | * |
| 94 | * @param string $path |
| 95 | * @param array $args |
| 96 | */ |
| 97 | function acfe_get_view($path = '', $args = array()){ |
| 98 | |
| 99 | // allow view file name shortcut |
| 100 | if(substr($path, -4) !== '.php'){ |
| 101 | $path = acfe_get_path("includes/admin/views/{$path}.php"); |
| 102 | } |
| 103 | |
| 104 | // include |
| 105 | if(file_exists($path)){ |
| 106 | |
| 107 | extract($args); |
| 108 | include($path); |
| 109 | |
| 110 | } |
| 111 | |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * acfe_load_textdomain |
| 116 | * |
| 117 | * Load textdomain files based on acf_load_textdomain() |
| 118 | * |
| 119 | * @param string $domain |
| 120 | * |
| 121 | * @return bool |
| 122 | */ |
| 123 | function acfe_load_textdomain($domain = 'acfe'){ |
| 124 | |
| 125 | $locale = apply_filters('plugin_locale', acf_get_locale(), $domain); |
| 126 | $mofile = $domain . '-' . $locale . '.mo'; |
| 127 | |
| 128 | // Try to load from the languages directory first. |
| 129 | if(load_textdomain($domain, WP_LANG_DIR . '/plugins/' . $mofile)){ |
| 130 | return true; |
| 131 | } |
| 132 | |
| 133 | // Load from plugin lang folder. |
| 134 | return load_textdomain($domain, acfe_get_path('lang/' . $mofile)); |
| 135 | |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * acfe_after_plugin_row |
| 140 | * |
| 141 | * after_plugin_row |
| 142 | * |
| 143 | * @param $plugin_file |
| 144 | * @param $plugin_data |
| 145 | * @param $status |
| 146 | */ |
| 147 | add_action('after_plugin_row_' . ACFE_BASENAME, 'acfe_after_plugin_row', 5, 3); |
| 148 | function acfe_after_plugin_row($plugin_file, $plugin_data, $status){ |
| 149 | |
| 150 | // bail early |
| 151 | if(acfe_has_acf()){ |
| 152 | return; |
| 153 | } |
| 154 | |
| 155 | // vars |
| 156 | $colspan = version_compare($GLOBALS['wp_version'], '5.5', '<') ? 3 : 4; |
| 157 | |
| 158 | // class |
| 159 | $class = 'acfe-plugin-tr'; |
| 160 | if(isset($plugin_data['update']) && !empty($plugin_data['update'])){ |
| 161 | $class .= ' acfe-plugin-tr-update'; |
| 162 | } |
| 163 | |
| 164 | ?> |
| 165 | <style> |
| 166 | .plugins tr[data-plugin='<?php echo $plugin_file; ?>'] th, |
| 167 | .plugins tr[data-plugin='<?php echo $plugin_file; ?>'] td{ |
| 168 | box-shadow:none; |
| 169 | } |
| 170 | </style> |
| 171 | <tr class="plugin-update-tr active <?php echo $class; ?>"> |
| 172 | <td colspan="<?php echo $colspan; ?>" class="plugin-update colspanchange"> |
| 173 | <div class="update-message notice inline notice-error notice-alt"> |
| 174 | <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> |
| 175 | </div> |
| 176 | </td> |
| 177 | </tr> |
| 178 | <?php |
| 179 | |
| 180 | } |