Beispiel #1
0
 function load()
 {
     // hide upgrade
     remove_action('admin_notices', array($this, 'admin_notices'), 1);
     // load acf scripts
     acf_enqueue_scripts();
 }
 function network_load()
 {
     // hide notice on this page
     remove_action('network_admin_notices', array($this, 'network_admin_notices'), 1);
     // load acf scripts
     acf_enqueue_scripts();
 }
Beispiel #3
0
 function admin_enqueue_scripts()
 {
     // validate page
     if (!$this->validate_page()) {
         return;
     }
     // load acf scripts
     acf_enqueue_scripts();
 }
Beispiel #4
0
 function admin_enqueue_scripts()
 {
     // bail early if not valid page
     if (!$this->validate_page()) {
         return;
     }
     // load acf scripts
     acf_enqueue_scripts();
 }
Beispiel #5
0
 function admin_enqueue_scripts()
 {
     // validate page
     if (!$this->validate_page()) {
         return;
     }
     // load acf scripts
     acf_enqueue_scripts();
     // actions
     add_action('add_meta_boxes_comment', array($this, 'edit_comment'), 10, 1);
 }
Beispiel #6
0
 function admin_enqueue_scripts()
 {
     // validate page
     if (!$this->validate_page()) {
         return;
     }
     // load acf scripts
     acf_enqueue_scripts();
     // actions
     add_action('acf/input/admin_footer', array($this, 'admin_footer'));
 }
Beispiel #7
0
 function admin_enqueue_scripts()
 {
     // validate screen
     if (acf_is_screen('widgets') || acf_is_screen('customize')) {
         // valid
     } else {
         return;
     }
     // load acf scripts
     acf_enqueue_scripts();
     // actions
     add_action('acf/input/admin_footer', array($this, 'admin_footer'), 1);
 }
Beispiel #8
0
 function admin_enqueue_scripts()
 {
     // validate page
     if (!$this->validate_page()) {
         return;
     }
     // vars
     $screen = get_current_screen();
     $taxonomy = $screen->taxonomy;
     // load acf scripts
     acf_enqueue_scripts();
     // render
     add_action("{$taxonomy}_add_form_fields", array($this, 'add_term'), 10, 1);
     add_action("{$taxonomy}_edit_form", array($this, 'edit_term'), 10, 2);
 }
Beispiel #9
0
 function load()
 {
     // disable filters to ensure ACF loads raw data from DB
     acf_disable_filters();
     // run import / export
     if (acf_verify_nonce('import')) {
         $this->import();
     } elseif (acf_verify_nonce('export')) {
         if (isset($_POST['generate'])) {
             $this->generate();
         } else {
             $this->export();
         }
     }
     // load acf scripts
     acf_enqueue_scripts();
 }
Beispiel #10
0
 function load()
 {
     // all export pages should not load local fields
     acf_disable_local();
     // run import / export
     if (acf_verify_nonce('import')) {
         $this->import();
     } elseif (acf_verify_nonce('export')) {
         if (isset($_POST['generate'])) {
             $this->generate();
         } else {
             $this->export();
         }
     }
     // load acf scripts
     acf_enqueue_scripts();
 }
Beispiel #11
0
 function current_screen()
 {
     // validate screen
     if (!acf_is_screen('acf-field-group')) {
         return;
     }
     // disable filters to ensure ACF loads raw data from DB
     acf_disable_filters();
     // enqueue scripts
     acf_enqueue_scripts();
     // actions
     add_action('acf/input/admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
     add_action('acf/input/admin_head', array($this, 'admin_head'));
     add_action('acf/input/form_data', array($this, 'form_data'));
     add_action('acf/input/admin_footer', array($this, 'admin_footer'));
     add_action('acf/input/admin_footer_js', array($this, 'admin_footer_js'));
     // filters
     add_filter('acf/input/admin_l10n', array($this, 'admin_l10n'));
 }
Beispiel #12
0
 function current_screen()
 {
     // validate screen
     if (!acf_is_screen('acf-field-group')) {
         return;
     }
     // disable JSON to avoid conflicts between DB and JSON
     acf_disable_local();
     // enqueue scripts
     acf_enqueue_scripts();
     // actions
     add_action('acf/input/admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
     add_action('acf/input/admin_head', array($this, 'admin_head'));
     add_action('acf/input/form_data', array($this, 'form_data'));
     add_action('acf/input/admin_footer', array($this, 'admin_footer'));
     add_action('acf/input/admin_footer_js', array($this, 'admin_footer_js'));
     // filters
     add_filter('acf/input/admin_l10n', array($this, 'admin_l10n'));
 }
Beispiel #13
0
function acf_form_head()
{
    // verify nonce
    if (acf_verify_nonce('acf_form')) {
        // validate data
        if (acf_validate_save_post(true)) {
            // form
            $form = acf_extract_var($_POST, '_acf_form');
            $form = @json_decode(base64_decode($form), true);
            // validate
            if (empty($form)) {
                return;
            }
            // allow for custom save
            $form['post_id'] = apply_filters('acf/pre_save_post', $form['post_id'], $form);
            // save
            acf_save_post($form['post_id']);
            // redirect
            if (!empty($form['return'])) {
                // update %placeholders%
                $form['return'] = str_replace('%post_url%', get_permalink($form['post_id']), $form['return']);
                // redirect
                wp_redirect($form['return']);
                exit;
            }
        }
        // if
    }
    // if
    // load acf scripts
    acf_enqueue_scripts();
}
Beispiel #14
0
 function admin_load()
 {
     // globals
     global $plugin_page;
     // vars
     $this->page = acf_get_options_page($plugin_page);
     // verify and remove nonce
     if (acf_verify_nonce('options')) {
         // save data
         if (acf_validate_save_post(true)) {
             // get post_id (allow lang modification)
             $post_id = acf_get_valid_post_id($this->page['post_id']);
             // set autoload
             acf_update_setting('autoload', $this->page['autoload']);
             // save
             acf_save_post($post_id);
             // redirect
             wp_redirect(add_query_arg(array('message' => '1')));
             exit;
         }
     }
     // load acf scripts
     acf_enqueue_scripts();
     // actions
     add_action('acf/input/admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
     add_action('acf/input/admin_head', array($this, 'admin_head'));
     // add columns support
     add_screen_option('layout_columns', array('max' => 2, 'default' => 2));
 }
Beispiel #15
0
function acf_form_head()
{
    // verify nonce
    if (acf_verify_nonce('acf_form')) {
        // validate data
        if (acf_validate_save_post(true)) {
            // form
            $GLOBALS['acf_form'] = acf_extract_var($_POST, '_acf_form');
            $GLOBALS['acf_form'] = @json_decode(base64_decode($GLOBALS['acf_form']), true);
            // validate
            if (empty($GLOBALS['acf_form'])) {
                return;
            }
            // vars
            $post_id = acf_maybe_get($GLOBALS['acf_form'], 'post_id', 0);
            // allow for custom save
            $post_id = apply_filters('acf/pre_save_post', $post_id, $GLOBALS['acf_form']);
            // save
            acf_save_post($post_id);
            // vars
            $return = acf_maybe_get($GLOBALS['acf_form'], 'return', '');
            // redirect
            if ($return) {
                // update %placeholders%
                $return = str_replace('%post_url%', get_permalink($post_id), $return);
                // redirect
                wp_redirect($return);
                exit;
            }
        }
        // if
    }
    // if
    // load acf scripts
    acf_enqueue_scripts();
}
    public function render()
    {
        acf_enqueue_scripts();
        do_action('acf/view', $this->args, $this);
        $post_id = $this->post_id;
        $args = $this->args;
        // vars
        $field_groups = array();
        $fields = array();
        // post_title
        if ($args['post_title']) {
            $fields[] = acf_get_valid_field(array('name' => '_post_title', 'label' => 'Title', 'type' => 'text', 'value' => $post_id ? get_post_field('post_title', $post_id) : '', 'required' => true));
        }
        // post_content
        if ($args['post_content']) {
            $fields[] = acf_get_valid_field(array('name' => '_post_content', 'label' => 'Content', 'type' => 'wysiwyg', 'value' => $post_id ? get_post_field('post_content', $post_id) : ''));
        }
        // specific fields
        if ($args['fields']) {
            foreach ($args['fields'] as $selector) {
                // append field ($strict = false to allow for better compatibility with field names)
                $fields[] = acf_maybe_get_field($selector, $post_id, false);
            }
        } elseif ($args['field_groups']) {
            foreach ($args['field_groups'] as $selector) {
                $field_groups[] = acf_get_field_group($selector);
            }
        } elseif ($args['post_id'] == 'new_post') {
            $field_groups = acf_get_field_groups(array('post_type' => $args['new_post']['post_type']));
        } else {
            $field_groups = acf_get_field_groups(array('post_id' => $args['post_id']));
        }
        //load fields based on field groups
        if (!empty($field_groups)) {
            foreach ($field_groups as $field_group) {
                $field_group_fields = acf_get_fields($field_group);
                if (!empty($field_group_fields)) {
                    foreach (array_keys($field_group_fields) as $i) {
                        $fields[] = acf_extract_var($field_group_fields, $i);
                    }
                }
            }
        }
        ?>
		<div class="acf-fields acf-form-fields -<?php 
        echo $args['label_placement'];
        ?>
">

		<?php 
        // html before fields
        echo $args['html_before_fields'];
        // render
        acf_views_render_fields($post_id, $fields, $args['field_el'], $args['instruction_placement']);
        // html after fields
        echo $args['html_after_fields'];
        ?>

		</div><!-- acf-form-fields -->
		<?php 
    }
Beispiel #17
0
 function admin_enqueue_scripts()
 {
     // load acf scripts
     acf_enqueue_scripts();
     // actions
     add_action('acf/input/admin_head', array($this, 'admin_head'));
 }
Beispiel #18
0
 function html()
 {
     // view
     $view = array('updates' => acf_get_updates(), 'plugin_version' => acf_get_setting('version'));
     // enqueue
     acf_enqueue_scripts();
     // load view
     acf_get_view('update', $view);
 }
Beispiel #19
0
function acf_form_data($args = array())
{
    // make sure scripts and styles have been included
    // case: front end bbPress edit user
    acf_enqueue_scripts();
    // set form data
    $args = acf_set_form_data($args);
    ?>
	<div id="acf-form-data" class="acf-hidden">
		<input type="hidden" name="_acfnonce" value="<?php 
    echo wp_create_nonce($args['nonce']);
    ?>
" />
		<input type="hidden" name="_acfchanged" value="0" />
		<?php 
    do_action('acf/input/form_data', $args);
    ?>
	</div>
	<?php 
}
Beispiel #20
0
function acf_form_data($args = array())
{
    // make sure scripts and styles have been included
    // case: front end bbPress edit user
    acf_enqueue_scripts();
    // defaults
    $args = acf_parse_args($args, array('post_id' => 0, 'nonce' => 'post', 'validation' => 1, 'ajax' => 0));
    // save form_data for later actions
    acf_update_setting('form_data', $args);
    // enqueue uploader if page allows AJAX fields to appear
    if ($args['ajax']) {
        add_action('admin_footer', 'acf_enqueue_uploader', 1);
        //acf_enqueue_uploader();
    }
    ?>
	<div id="acf-form-data" class="acf-hidden">
		<input type="hidden" name="_acfnonce" value="<?php 
    echo wp_create_nonce($args['nonce']);
    ?>
" />
		<input type="hidden" name="_acfchanged" value="0" />
		<?php 
    do_action('acf/input/form_data', $args);
    ?>
	</div>
	<?php 
}
Beispiel #21
0
 function admin_load()
 {
     // globals
     global $plugin_page;
     // vars
     $this->page = acf_get_options_page($plugin_page);
     // verify and remove nonce
     if (acf_verify_nonce('options')) {
         // save data
         if (acf_validate_save_post(true)) {
             // get post_id (allow lang modification)
             $post_id = acf_get_valid_post_id($this->page['post_id']);
             // set autoload
             acf_update_setting('autoload', $this->page['autoload']);
             // save
             acf_save_post($post_id);
             // redirect
             wp_redirect(admin_url("admin.php?page={$plugin_page}&message=1"));
             exit;
         }
     }
     // load acf scripts
     acf_enqueue_scripts();
     // actions
     add_action('acf/input/admin_head', array($this, 'admin_head'));
 }