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