ACF::initialize │ public │ ACF 5.0.0
Sets up the ACF plugin.
Метод класса: ACF{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$ACF = new ACF(); $ACF->initialize();
Список изменений
| С версии 5.0.0 | Введена. |
Код ACF::initialize() ACF::initialize ACF 6.4.2
public function initialize() {
// Define constants.
$this->define( 'ACF', true );
$this->define( 'ACF_PATH', plugin_dir_path( __FILE__ ) );
$this->define( 'ACF_BASENAME', plugin_basename( __FILE__ ) );
$this->define( 'ACF_VERSION', $this->version );
$this->define( 'ACF_MAJOR_VERSION', 6 );
$this->define( 'ACF_FIELD_API_VERSION', 5 );
$this->define( 'ACF_UPGRADE_VERSION', '5.5.0' ); // Highest version with an upgrade routine. See upgrades.php.
// Register activation hook.
register_activation_hook( __FILE__, array( $this, 'acf_plugin_activated' ) );
// Define settings.
$this->settings = array(
'name' => 'Advanced Custom Fields',
'slug' => dirname( ACF_BASENAME ),
'version' => ACF_VERSION,
'basename' => ACF_BASENAME,
'path' => ACF_PATH,
'file' => __FILE__,
'url' => plugin_dir_url( __FILE__ ),
'show_admin' => true,
'show_updates' => true,
'enable_post_types' => true,
'enable_options_pages_ui' => true,
'stripslashes' => false,
'local' => true,
'json' => true,
'save_json' => '',
'load_json' => array(),
'default_language' => '',
'current_language' => '',
'capability' => 'manage_options',
'uploader' => 'wp',
'autoload' => false,
'l10n' => true,
'l10n_textdomain' => '',
'google_api_key' => '',
'google_api_client' => '',
'enqueue_google_maps' => true,
'enqueue_select2' => true,
'enqueue_datepicker' => true,
'enqueue_datetimepicker' => true,
'select2_version' => 4,
'row_index_offset' => 1,
'remove_wp_meta_box' => true,
'rest_api_enabled' => true,
'rest_api_format' => 'light',
'rest_api_embed_links' => true,
'preload_blocks' => true,
'enable_shortcode' => true,
'enable_bidirection' => true,
'enable_block_bindings' => true,
'enable_meta_box_cb_edit' => true,
);
// Include autoloader.
include_once __DIR__ . '/vendor/autoload.php';
// Include utility functions.
include_once ACF_PATH . 'includes/acf-utility-functions.php';
// Include previous API functions.
acf_include( 'includes/api/api-helpers.php' );
acf_include( 'includes/api/api-template.php' );
acf_include( 'includes/api/api-term.php' );
// Include classes.
acf_include( 'includes/class-acf-data.php' );
acf_include( 'includes/class-acf-internal-post-type.php' );
acf_include( 'includes/fields/class-acf-field.php' );
acf_include( 'includes/locations/abstract-acf-legacy-location.php' );
acf_include( 'includes/locations/abstract-acf-location.php' );
// Initialise autoloaded classes.
new ACF\Site_Health\Site_Health();
// Include functions.
acf_include( 'includes/acf-helper-functions.php' );
acf_new_instance( 'ACF\Meta\Comment' );
acf_new_instance( 'ACF\Meta\Post' );
acf_new_instance( 'ACF\Meta\Term' );
acf_new_instance( 'ACF\Meta\User' );
acf_new_instance( 'ACF\Meta\Option' );
acf_include( 'includes/acf-hook-functions.php' );
acf_include( 'includes/acf-field-functions.php' );
acf_include( 'includes/acf-bidirectional-functions.php' );
acf_include( 'includes/acf-internal-post-type-functions.php' );
acf_include( 'includes/acf-post-type-functions.php' );
acf_include( 'includes/acf-taxonomy-functions.php' );
acf_include( 'includes/acf-field-group-functions.php' );
acf_include( 'includes/acf-form-functions.php' );
acf_include( 'includes/acf-meta-functions.php' );
acf_include( 'includes/acf-post-functions.php' );
acf_include( 'includes/acf-user-functions.php' );
acf_include( 'includes/acf-value-functions.php' );
acf_include( 'includes/acf-input-functions.php' );
acf_include( 'includes/acf-wp-functions.php' );
// Override the shortcode default value based on the version when installed.
$first_activated_version = acf_get_version_when_first_activated();
// Only enable shortcode by default for versions prior to 6.3
if ( $first_activated_version && version_compare( $first_activated_version, '6.3', '>=' ) ) {
$this->settings['enable_shortcode'] = false;
}
// Include core.
acf_include( 'includes/fields.php' );
acf_include( 'includes/locations.php' );
acf_include( 'includes/assets.php' );
acf_include( 'includes/compatibility.php' );
acf_include( 'includes/deprecated.php' );
acf_include( 'includes/l10n.php' );
acf_include( 'includes/local-fields.php' );
acf_include( 'includes/local-meta.php' );
acf_include( 'includes/local-json.php' );
acf_include( 'includes/loop.php' );
acf_include( 'includes/media.php' );
acf_include( 'includes/revisions.php' );
acf_include( 'includes/upgrades.php' );
acf_include( 'includes/validation.php' );
acf_include( 'includes/rest-api.php' );
// Include field group class.
acf_include( 'includes/post-types/class-acf-field-group.php' );
// Include ajax.
acf_include( 'includes/ajax/class-acf-ajax.php' );
acf_include( 'includes/ajax/class-acf-ajax-check-screen.php' );
acf_include( 'includes/ajax/class-acf-ajax-user-setting.php' );
acf_include( 'includes/ajax/class-acf-ajax-upgrade.php' );
acf_include( 'includes/ajax/class-acf-ajax-query.php' );
acf_include( 'includes/ajax/class-acf-ajax-query-users.php' );
acf_include( 'includes/ajax/class-acf-ajax-local-json-diff.php' );
// Include forms.
acf_include( 'includes/forms/form-attachment.php' );
acf_include( 'includes/forms/form-comment.php' );
acf_include( 'includes/forms/form-customizer.php' );
acf_include( 'includes/forms/form-front.php' );
acf_include( 'includes/forms/form-nav-menu.php' );
acf_include( 'includes/forms/form-post.php' );
acf_include( 'includes/forms/form-gutenberg.php' );
acf_include( 'includes/forms/form-taxonomy.php' );
acf_include( 'includes/forms/form-user.php' );
acf_include( 'includes/forms/form-widget.php' );
// Include admin.
if ( is_admin() ) {
acf_include( 'includes/admin/admin.php' );
acf_include( 'includes/admin/admin-internal-post-type-list.php' );
acf_include( 'includes/admin/admin-internal-post-type.php' );
acf_include( 'includes/admin/admin-notices.php' );
acf_include( 'includes/admin/admin-tools.php' );
acf_include( 'includes/admin/admin-upgrade.php' );
}
// Include legacy.
acf_include( 'includes/legacy/legacy-locations.php' );
// Include updater if included with this build.
acf_include( 'includes/Updater/init.php' );
// Include PRO if included with this build.
if ( ! defined( 'ACF_PREVENT_PRO_LOAD' ) || ( defined( 'ACF_PREVENT_PRO_LOAD' ) && ! ACF_PREVENT_PRO_LOAD ) ) {
acf_include( 'pro/acf-pro.php' );
}
if ( is_admin() && function_exists( 'acf_is_pro' ) && ! acf_is_pro() ) {
acf_include( 'includes/admin/admin-options-pages-preview.php' );
}
// Add actions.
add_action( 'init', array( $this, 'register_post_status' ), 4 );
add_action( 'init', array( $this, 'init' ), 5 );
add_action( 'init', array( $this, 'register_post_types' ), 5 );
add_action( 'activated_plugin', array( $this, 'deactivate_other_instances' ) );
add_action( 'pre_current_active_plugins', array( $this, 'plugin_deactivated_notice' ) );
// Add filters.
add_filter( 'posts_where', array( $this, 'posts_where' ), 10, 2 );
}