Пример #1
0
 function __construct()
 {
     // update setting
     acf_update_setting('pro', true);
     acf_update_setting('name', __('Advanced Custom Fields PRO', 'acf'));
     // api
     acf_include('pro/api/api-pro.php');
     acf_include('pro/api/api-options-page.php');
     // updates
     acf_include('pro/core/updates.php');
     // admin
     if (is_admin()) {
         // options page
         acf_include('pro/admin/options-page.php');
         // settings
         acf_include('pro/admin/settings-updates.php');
     }
     // fields
     acf_include('pro/fields/repeater.php');
     acf_include('pro/fields/flexible-content.php');
     acf_include('pro/fields/gallery.php');
     // actions
     add_action('init', array($this, 'wp_init'));
     add_action('acf/input/admin_enqueue_scripts', array($this, 'input_admin_enqueue_scripts'));
     add_action('acf/field_group/admin_enqueue_scripts', array($this, 'field_group_admin_enqueue_scripts'));
     add_action('acf/field_group/admin_l10n', array($this, 'field_group_admin_l10n'));
     // filters
     add_filter('acf/get_valid_field', array($this, 'get_valid_field'), 11, 1);
     add_filter('acf/update_field', array($this, 'update_field'), 1, 1);
     add_filter('acf/prepare_field_for_export', array($this, 'prepare_field_for_export'));
     add_filter('acf/prepare_field_for_import', array($this, 'prepare_field_for_import'));
 }
Пример #2
0
 function include_field_types()
 {
     acf_include('pro/fields/repeater.php');
     acf_include('pro/fields/flexible-content.php');
     acf_include('pro/fields/gallery.php');
     acf_include('pro/fields/clone.php');
 }
Пример #3
0
 /**
  * Use an ACF function to export field groups
  * @return null
  */
 public function export()
 {
     // include ACF file needed for export
     acf_include("admin/settings-tools.php");
     $tools = new \acf_settings_tools();
     // create post variable for ACF function
     $_POST["acf_export_keys"] = $this->getFieldGroupNames();
     $data = $tools->get_json();
     $this->saveConfig($data);
 }
Пример #4
0
 function complete()
 {
     // bail early if actions have not passed 'plugins_loaded'
     if (!did_action('plugins_loaded')) {
         return;
     }
     // once run once
     if (acf_get_setting('complete')) {
         return;
     }
     // update setting
     acf_update_setting('complete', true);
     // wpml
     if (defined('ICL_SITEPRESS_VERSION')) {
         acf_include('core/wpml.php');
     }
     // action for 3rd party customization
     do_action('acf/include_field_types', 5);
     do_action('acf/include_fields', 5);
 }
Пример #5
0
 function complete()
 {
     // bail early if actions have not passed 'plugins_loaded'
     // this allows all plugins / theme to hook in
     if (!did_action('plugins_loaded')) {
         return;
     }
     // once run once
     if (acf_get_setting('complete')) {
         return;
     }
     // update setting
     acf_update_setting('complete', true);
     // wpml
     if (defined('ICL_SITEPRESS_VERSION')) {
         acf_include('core/wpml.php');
     }
     // include field types
     do_action('acf/include_field_types', 5);
     // include local fields
     do_action('acf/include_fields', 5);
     // final action
     do_action('acf/init');
 }
Пример #6
0
 function init()
 {
     // bail early if a plugin called get_field early
     if (!did_action('plugins_loaded')) {
         return;
     }
     // bail early if already init
     if (acf_get_setting('init')) {
         return;
     }
     // only run once
     acf_update_setting('init', true);
     // vars
     $major = intval(acf_get_setting('version'));
     // redeclare dir
     // - allow another plugin to modify dir (maybe force SSL)
     acf_update_setting('dir', plugin_dir_url(__FILE__));
     // set text domain
     load_textdomain('acf', acf_get_path('lang/acf-' . get_locale() . '.mo'));
     // include wpml support
     if (defined('ICL_SITEPRESS_VERSION')) {
         acf_include('core/wpml.php');
     }
     // field types
     acf_include('fields/text.php');
     acf_include('fields/textarea.php');
     acf_include('fields/number.php');
     acf_include('fields/email.php');
     acf_include('fields/url.php');
     acf_include('fields/password.php');
     acf_include('fields/wysiwyg.php');
     acf_include('fields/oembed.php');
     acf_include('fields/image.php');
     acf_include('fields/file.php');
     acf_include('fields/select.php');
     acf_include('fields/checkbox.php');
     acf_include('fields/radio.php');
     acf_include('fields/true_false.php');
     acf_include('fields/post_object.php');
     acf_include('fields/page_link.php');
     acf_include('fields/relationship.php');
     acf_include('fields/taxonomy.php');
     acf_include('fields/user.php');
     acf_include('fields/google-map.php');
     acf_include('fields/date_picker.php');
     acf_include('fields/date_time_picker.php');
     acf_include('fields/time_picker.php');
     acf_include('fields/color_picker.php');
     acf_include('fields/message.php');
     acf_include('fields/tab.php');
     // 3rd party field types
     do_action('acf/include_field_types', $major);
     // local fields
     do_action('acf/include_fields', $major);
     // action for 3rd party
     do_action('acf/init');
 }
Пример #7
0
<?php

namespace Yare\ThemeSetup\ACF;

use Yare\Yare;
if (function_exists('acf_add_options_page')) {
    if (!class_exists('acf_pro_options_page')) {
        acf_include('pro/admin/options-page.php');
    }
    foreach ((array) Yare::config('register.options_page') as $slug => $option) {
        if (is_numeric($slug)) {
            acf_add_options_page($option);
            continue;
        }
        $args = array('capability' => 'edit_posts', 'redirect' => false, 'menu_slug' => $slug);
        if (is_string($option)) {
            $args['page_title'] = $option;
            $args['menu_title'] = $option;
            acf_add_options_page($args);
        } elseif (is_array($option)) {
            if (isset($option['page_title'])) {
                $args = array_merge($args, $option);
            } elseif (isset($option['main_page'])) {
                if (!is_array($option['main_page'])) {
                    $args['page_title'] = $option['main_page'];
                    $args['menu_title'] = $option['main_page'];
                } else {
                    $args = array_merge($args, $option['main_page']);
                }
            }
        }
Пример #8
0
 function run_update($callback = '')
 {
     // include update functions
     acf_include('admin/install-updates.php');
     // bail early if not found
     if (!function_exists($callback)) {
         return false;
     }
     // load any errors / feedback from update
     ob_start();
     // include
     call_user_func($callback);
     // get feedback
     $message = ob_get_clean();
     // return
     return $message;
 }