acf-extended
Last commit date
assets
6 years ago
includes
6 years ago
acf-extended.php
6 years ago
init.php
6 years ago
readme.txt
6 years ago
acf-extended.php
268 lines
| 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 | * 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'; |
| 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_URL', plugin_dir_url(__FILE__)); |
| 44 | $this->define('ACFE_VERSION', $this->version); |
| 45 | $this->define('ACFE_BASENAME', plugin_basename(__FILE__)); |
| 46 | $this->define('ACFE_THEME_PATH', get_stylesheet_directory()); |
| 47 | $this->define('ACFE_THEME_URL', get_stylesheet_directory_uri()); |
| 48 | |
| 49 | // Define settings |
| 50 | $this->settings = array( |
| 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/dev' => false, |
| 56 | 'acfe/modules/author' => true, |
| 57 | 'acfe/modules/dynamic_block_types' => true, |
| 58 | 'acfe/modules/dynamic_forms' => true, |
| 59 | 'acfe/modules/dynamic_options_pages' => true, |
| 60 | 'acfe/modules/dynamic_post_types' => true, |
| 61 | 'acfe/modules/dynamic_taxonomies' => true, |
| 62 | 'acfe/modules/options' => true, |
| 63 | 'acfe/modules/taxonomies' => true, |
| 64 | ); |
| 65 | |
| 66 | // Init |
| 67 | include_once(ACFE_PATH . 'init.php'); |
| 68 | |
| 69 | // Load |
| 70 | add_action('plugins_loaded', array($this, 'load')); |
| 71 | |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * ACFE: Load |
| 76 | */ |
| 77 | function load(){ |
| 78 | |
| 79 | if(!$this->has_acf()) |
| 80 | return; |
| 81 | |
| 82 | // Settings |
| 83 | foreach($this->settings as $name => $value){ |
| 84 | |
| 85 | acf_update_setting($name, $value); |
| 86 | |
| 87 | } |
| 88 | |
| 89 | // Load |
| 90 | add_action('acf/init', array($this, 'includes'), 99); |
| 91 | |
| 92 | // AutoSync |
| 93 | add_action('acf/include_fields', array($this, 'autosync'), 5); |
| 94 | |
| 95 | // Fields |
| 96 | add_action('acf/include_field_types', array($this, 'fields')); |
| 97 | |
| 98 | // Tools |
| 99 | add_action('acf/include_admin_tools', array($this, 'tools')); |
| 100 | |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * ACFE: includes |
| 105 | */ |
| 106 | function includes(){ |
| 107 | |
| 108 | /** |
| 109 | * Core |
| 110 | */ |
| 111 | acfe_include('includes/core/compatibility.php'); |
| 112 | acfe_include('includes/core/enqueue.php'); |
| 113 | acfe_include('includes/core/helpers.php'); |
| 114 | acfe_include('includes/core/menu.php'); |
| 115 | |
| 116 | /** |
| 117 | * Admin Pages |
| 118 | */ |
| 119 | acfe_include('includes/admin/options.php'); |
| 120 | acfe_include('includes/admin/plugins.php'); |
| 121 | acfe_include('includes/admin/settings.php'); |
| 122 | |
| 123 | /** |
| 124 | * Fields |
| 125 | */ |
| 126 | acfe_include('includes/fields/field-clone.php'); |
| 127 | acfe_include('includes/fields/field-file.php'); |
| 128 | acfe_include('includes/fields/field-flexible-content.php'); |
| 129 | acfe_include('includes/fields/field-group.php'); |
| 130 | acfe_include('includes/fields/field-image.php'); |
| 131 | acfe_include('includes/fields/field-repeater.php'); |
| 132 | acfe_include('includes/fields/field-select.php'); |
| 133 | acfe_include('includes/fields/field-textarea.php'); |
| 134 | |
| 135 | /** |
| 136 | * Fields settings |
| 137 | */ |
| 138 | acfe_include('includes/fields-settings/bidirectional.php'); |
| 139 | acfe_include('includes/fields-settings/data.php'); |
| 140 | acfe_include('includes/fields-settings/fields.php'); |
| 141 | acfe_include('includes/fields-settings/permissions.php'); |
| 142 | acfe_include('includes/fields-settings/settings.php'); |
| 143 | acfe_include('includes/fields-settings/validation.php'); |
| 144 | |
| 145 | /** |
| 146 | * Field Groups |
| 147 | */ |
| 148 | acfe_include('includes/field-groups/field-group.php'); |
| 149 | acfe_include('includes/field-groups/field-group-category.php'); |
| 150 | acfe_include('includes/field-groups/field-groups.php'); |
| 151 | acfe_include('includes/field-groups/field-groups-third-party.php'); |
| 152 | |
| 153 | /** |
| 154 | * Locations |
| 155 | */ |
| 156 | acfe_include('includes/locations/post-type-all.php'); |
| 157 | acfe_include('includes/locations/post-type-archive.php'); |
| 158 | acfe_include('includes/locations/post-type-list.php'); |
| 159 | acfe_include('includes/locations/taxonomy-list.php'); |
| 160 | |
| 161 | /** |
| 162 | * Modules |
| 163 | */ |
| 164 | acfe_include('includes/modules/author.php'); |
| 165 | acfe_include('includes/modules/dev.php'); |
| 166 | acfe_include('includes/modules/dynamic-block-type.php'); |
| 167 | acfe_include('includes/modules/dynamic-form.php'); |
| 168 | acfe_include('includes/modules/dynamic-options-page.php'); |
| 169 | acfe_include('includes/modules/dynamic-post-type.php'); |
| 170 | acfe_include('includes/modules/dynamic-taxonomy.php'); |
| 171 | acfe_include('includes/modules/taxonomy.php'); |
| 172 | |
| 173 | } |
| 174 | |
| 175 | /** |
| 176 | * ACFE: AutoSync |
| 177 | */ |
| 178 | function autosync(){ |
| 179 | |
| 180 | acfe_include('includes/modules/autosync.php'); |
| 181 | |
| 182 | } |
| 183 | |
| 184 | /** |
| 185 | * ACFE: Fields |
| 186 | */ |
| 187 | function fields(){ |
| 188 | |
| 189 | acfe_include('includes/fields/field-advanced-link.php'); |
| 190 | acfe_include('includes/fields/field-button.php'); |
| 191 | acfe_include('includes/fields/field-column.php'); |
| 192 | acfe_include('includes/fields/field-dynamic-message.php'); |
| 193 | acfe_include('includes/fields/field-forms.php'); |
| 194 | acfe_include('includes/fields/field-hidden.php'); |
| 195 | acfe_include('includes/fields/field-post-statuses.php'); |
| 196 | acfe_include('includes/fields/field-post-types.php'); |
| 197 | acfe_include('includes/fields/field-recaptcha.php'); |
| 198 | acfe_include('includes/fields/field-slug.php'); |
| 199 | acfe_include('includes/fields/field-taxonomies.php'); |
| 200 | acfe_include('includes/fields/field-taxonomy-terms.php'); |
| 201 | acfe_include('includes/fields/field-user-roles.php'); |
| 202 | |
| 203 | } |
| 204 | |
| 205 | /** |
| 206 | * ACFE: Tools |
| 207 | */ |
| 208 | function tools(){ |
| 209 | |
| 210 | acfe_include('includes/admin/tools/dbt-export.php'); |
| 211 | acfe_include('includes/admin/tools/dbt-import.php'); |
| 212 | acfe_include('includes/admin/tools/dpt-export.php'); |
| 213 | acfe_include('includes/admin/tools/dpt-import.php'); |
| 214 | acfe_include('includes/admin/tools/dt-export.php'); |
| 215 | acfe_include('includes/admin/tools/dt-import.php'); |
| 216 | acfe_include('includes/admin/tools/dop-export.php'); |
| 217 | acfe_include('includes/admin/tools/dop-import.php'); |
| 218 | |
| 219 | acfe_include('includes/admin/tools/fg-local.php'); |
| 220 | |
| 221 | } |
| 222 | |
| 223 | /** |
| 224 | * ACFE: Define |
| 225 | */ |
| 226 | function define($name, $value = true){ |
| 227 | |
| 228 | if(!defined($name)) |
| 229 | define($name, $value); |
| 230 | |
| 231 | } |
| 232 | |
| 233 | /** |
| 234 | * ACFE: Has ACF |
| 235 | */ |
| 236 | function has_acf(){ |
| 237 | |
| 238 | if($this->acf) |
| 239 | return true; |
| 240 | |
| 241 | $this->acf = class_exists('ACF') && defined('ACF_PRO') && defined('ACF_VERSION') && version_compare(ACF_VERSION, '5.7.10', '>='); |
| 242 | |
| 243 | return $this->acf; |
| 244 | |
| 245 | } |
| 246 | |
| 247 | } |
| 248 | |
| 249 | |
| 250 | function acfe(){ |
| 251 | |
| 252 | global $acfe; |
| 253 | |
| 254 | if(!isset($acfe)){ |
| 255 | |
| 256 | $acfe = new ACFE(); |
| 257 | $acfe->initialize(); |
| 258 | |
| 259 | } |
| 260 | |
| 261 | return $acfe; |
| 262 | |
| 263 | } |
| 264 | |
| 265 | // Instantiate. |
| 266 | acfe(); |
| 267 | |
| 268 | endif; |