acf-extended.php
| 1 | <?php |
| 2 | /** |
| 3 | * Plugin Name: Advanced Custom Fields: Extended |
| 4 | * Description: Enhancement Suite which improves Advanced Custom Fields administration |
| 5 | * Version: 0.8.6 |
| 6 | * Author: ACF Extended |
| 7 | * Author URI: https://www.acf-extended.com |
| 8 | * Text Domain: acfe |
| 9 | */ |
| 10 | |
| 11 | if(!defined('ABSPATH')) |
| 12 | exit; |
| 13 | |
| 14 | if(!class_exists('ACFE')): |
| 15 | |
| 16 | class ACFE{ |
| 17 | |
| 18 | // Version |
| 19 | var $version = '0.8.6'; |
| 20 | |
| 21 | // Settings |
| 22 | var $settings = array(); |
| 23 | |
| 24 | // ACF |
| 25 | var $acf = false; |
| 26 | |
| 27 | /** |
| 28 | * ACFE: Construct |
| 29 | */ |
| 30 | function __construct(){ |
| 31 | // ... |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * ACFE: Initialize |
| 36 | */ |
| 37 | function initialize(){ |
| 38 | |
| 39 | // Constants |
| 40 | $this->define('ACFE', true); |
| 41 | $this->define('ACFE_FILE', __FILE__); |
| 42 | $this->define('ACFE_PATH', plugin_dir_path(__FILE__)); |
| 43 | $this->define('ACFE_VERSION', $this->version); |
| 44 | $this->define('ACFE_BASENAME', plugin_basename(__FILE__)); |
| 45 | $this->define('ACFE_THEME_PATH', get_stylesheet_directory()); |
| 46 | $this->define('ACFE_THEME_URL', get_stylesheet_directory_uri()); |
| 47 | |
| 48 | // Define settings |
| 49 | $this->settings = array( |
| 50 | 'acfe/url' => plugin_dir_url(__FILE__), |
| 51 | 'acfe/php' => true, |
| 52 | 'acfe/php_save' => ACFE_THEME_PATH . '/acfe-php', |
| 53 | 'acfe/php_load' => array(ACFE_THEME_PATH . '/acfe-php'), |
| 54 | 'acfe/php_found' => false, |
| 55 | 'acfe/json_found' => false, |
| 56 | 'acfe/dev' => false, |
| 57 | 'acfe/modules/author' => true, |
| 58 | 'acfe/modules/dynamic_block_types' => true, |
| 59 | 'acfe/modules/dynamic_forms' => true, |
| 60 | 'acfe/modules/dynamic_options_pages' => true, |
| 61 | 'acfe/modules/dynamic_post_types' => true, |
| 62 | 'acfe/modules/dynamic_taxonomies' => true, |
| 63 | 'acfe/modules/options' => true, |
| 64 | 'acfe/modules/single_meta' => false, |
| 65 | 'acfe/modules/taxonomies' => true, |
| 66 | ); |
| 67 | |
| 68 | // Init |
| 69 | include_once(ACFE_PATH . 'init.php'); |
| 70 | |
| 71 | // Load |
| 72 | add_action('acf/include_field_types', array($this, 'load')); |
| 73 | |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * ACFE: Load |
| 78 | */ |
| 79 | function load(){ |
| 80 | |
| 81 | if(!$this->has_acf()) |
| 82 | return; |
| 83 | |
| 84 | // Settings |
| 85 | foreach($this->settings as $name => $value){ |
| 86 | |
| 87 | acf_update_setting($name, $value); |
| 88 | |
| 89 | } |
| 90 | |
| 91 | // Load |
| 92 | add_action('acf/init', array($this, 'includes'), 99); |
| 93 | |
| 94 | // AutoSync |
| 95 | add_action('acf/include_fields', array($this, 'autosync'), 5); |
| 96 | |
| 97 | // Fields |
| 98 | add_action('acf/include_field_types', array($this, 'fields'), 99); |
| 99 | |
| 100 | // Tools |
| 101 | add_action('acf/include_admin_tools', array($this, 'tools')); |
| 102 | |
| 103 | // Additional |
| 104 | acfe_include('includes/core/compatibility.php'); |
| 105 | acfe_include('includes/core/settings.php'); |
| 106 | acfe_include('includes/core/upgrades.php'); |
| 107 | |
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * ACFE: includes |
| 112 | */ |
| 113 | function includes(){ |
| 114 | |
| 115 | /** |
| 116 | * Core |
| 117 | */ |
| 118 | acfe_include('includes/core/enqueue.php'); |
| 119 | acfe_include('includes/core/helpers.php'); |
| 120 | acfe_include('includes/core/menu.php'); |
| 121 | |
| 122 | /** |
| 123 | * Admin Pages |
| 124 | */ |
| 125 | acfe_include('includes/admin/options.php'); |
| 126 | acfe_include('includes/admin/plugins.php'); |
| 127 | acfe_include('includes/admin/settings.php'); |
| 128 | |
| 129 | /** |
| 130 | * Fields |
| 131 | */ |
| 132 | acfe_include('includes/fields/field-clone.php'); |
| 133 | acfe_include('includes/fields/field-file.php'); |
| 134 | acfe_include('includes/fields/field-flexible-content.php'); |
| 135 | acfe_include('includes/fields/field-group.php'); |
| 136 | acfe_include('includes/fields/field-image.php'); |
| 137 | acfe_include('includes/fields/field-post-object.php'); |
| 138 | acfe_include('includes/fields/field-repeater.php'); |
| 139 | acfe_include('includes/fields/field-select.php'); |
| 140 | acfe_include('includes/fields/field-textarea.php'); |
| 141 | |
| 142 | /** |
| 143 | * Fields settings |
| 144 | */ |
| 145 | acfe_include('includes/fields-settings/bidirectional.php'); |
| 146 | acfe_include('includes/fields-settings/data.php'); |
| 147 | acfe_include('includes/fields-settings/fields.php'); |
| 148 | acfe_include('includes/fields-settings/permissions.php'); |
| 149 | acfe_include('includes/fields-settings/settings.php'); |
| 150 | acfe_include('includes/fields-settings/validation.php'); |
| 151 | |
| 152 | /** |
| 153 | * Field Groups |
| 154 | */ |
| 155 | acfe_include('includes/field-groups/field-group.php'); |
| 156 | acfe_include('includes/field-groups/field-group-category.php'); |
| 157 | acfe_include('includes/field-groups/field-groups.php'); |
| 158 | acfe_include('includes/field-groups/field-groups-local.php'); |
| 159 | |
| 160 | /** |
| 161 | * Locations |
| 162 | */ |
| 163 | acfe_include('includes/locations/post-type-all.php'); |
| 164 | acfe_include('includes/locations/post-type-archive.php'); |
| 165 | acfe_include('includes/locations/post-type-list.php'); |
| 166 | acfe_include('includes/locations/taxonomy-list.php'); |
| 167 | |
| 168 | /** |
| 169 | * Modules |
| 170 | */ |
| 171 | acfe_include('includes/modules/author.php'); |
| 172 | acfe_include('includes/modules/dev.php'); |
| 173 | acfe_include('includes/modules/dynamic-block-type.php'); |
| 174 | acfe_include('includes/modules/dynamic-form.php'); |
| 175 | acfe_include('includes/modules/dynamic-options-page.php'); |
| 176 | acfe_include('includes/modules/dynamic-post-type.php'); |
| 177 | acfe_include('includes/modules/dynamic-taxonomy.php'); |
| 178 | acfe_include('includes/modules/single-meta.php'); |
| 179 | acfe_include('includes/modules/taxonomy.php'); |
| 180 | |
| 181 | } |
| 182 | |
| 183 | /** |
| 184 | * ACFE: AutoSync |
| 185 | */ |
| 186 | function autosync(){ |
| 187 | |
| 188 | acfe_include('includes/modules/autosync.php'); |
| 189 | |
| 190 | } |
| 191 | |
| 192 | /** |
| 193 | * ACFE: Fields |
| 194 | */ |
| 195 | function fields(){ |
| 196 | |
| 197 | acfe_include('includes/fields/field-advanced-link.php'); |
| 198 | acfe_include('includes/fields/field-button.php'); |
| 199 | acfe_include('includes/fields/field-code-editor.php'); |
| 200 | acfe_include('includes/fields/field-column.php'); |
| 201 | acfe_include('includes/fields/field-dynamic-message.php'); |
| 202 | acfe_include('includes/fields/field-forms.php'); |
| 203 | acfe_include('includes/fields/field-hidden.php'); |
| 204 | acfe_include('includes/fields/field-post-statuses.php'); |
| 205 | acfe_include('includes/fields/field-post-types.php'); |
| 206 | acfe_include('includes/fields/field-recaptcha.php'); |
| 207 | acfe_include('includes/fields/field-slug.php'); |
| 208 | acfe_include('includes/fields/field-taxonomies.php'); |
| 209 | acfe_include('includes/fields/field-taxonomy-terms.php'); |
| 210 | acfe_include('includes/fields/field-user-roles.php'); |
| 211 | |
| 212 | } |
| 213 | |
| 214 | /** |
| 215 | * ACFE: Tools |
| 216 | */ |
| 217 | function tools(){ |
| 218 | |
| 219 | acfe_include('includes/admin/tools/dbt-export.php'); |
| 220 | acfe_include('includes/admin/tools/dbt-import.php'); |
| 221 | acfe_include('includes/admin/tools/dpt-export.php'); |
| 222 | acfe_include('includes/admin/tools/dpt-import.php'); |
| 223 | acfe_include('includes/admin/tools/dt-export.php'); |
| 224 | acfe_include('includes/admin/tools/dt-import.php'); |
| 225 | acfe_include('includes/admin/tools/dop-export.php'); |
| 226 | acfe_include('includes/admin/tools/dop-import.php'); |
| 227 | |
| 228 | acfe_include('includes/admin/tools/form-export.php'); |
| 229 | acfe_include('includes/admin/tools/form-import.php'); |
| 230 | acfe_include('includes/admin/tools/fg-local.php'); |
| 231 | acfe_include('includes/admin/tools/fg-export.php'); |
| 232 | |
| 233 | } |
| 234 | |
| 235 | /** |
| 236 | * ACFE: Define |
| 237 | * |
| 238 | * @param $name |
| 239 | * @param bool $value |
| 240 | */ |
| 241 | function define($name, $value = true){ |
| 242 | |
| 243 | if(!defined($name)) |
| 244 | define($name, $value); |
| 245 | |
| 246 | } |
| 247 | |
| 248 | /** |
| 249 | * ACFE: Has ACF |
| 250 | */ |
| 251 | function has_acf(){ |
| 252 | |
| 253 | if($this->acf) |
| 254 | return true; |
| 255 | |
| 256 | $this->acf = class_exists('ACF') && defined('ACF_PRO') && defined('ACF_VERSION') && version_compare(ACF_VERSION, '5.7.10', '>='); |
| 257 | |
| 258 | return $this->acf; |
| 259 | |
| 260 | } |
| 261 | |
| 262 | } |
| 263 | |
| 264 | |
| 265 | function acfe(){ |
| 266 | |
| 267 | global $acfe; |
| 268 | |
| 269 | if(!isset($acfe)){ |
| 270 | |
| 271 | $acfe = new ACFE(); |
| 272 | $acfe->initialize(); |
| 273 | |
| 274 | } |
| 275 | |
| 276 | return $acfe; |
| 277 | |
| 278 | } |
| 279 | |
| 280 | // Instantiate. |
| 281 | acfe(); |
| 282 | |
| 283 | endif; |