<?php

// vars
$rule_types = apply_filters('acf/location/rule_types', array(__("Post", 'acf') => array('post_type' => __("Post Type", 'acf'), 'post_template' => __("Post Template", 'acf'), 'post_status' => __("Post Status", 'acf'), 'post_format' => __("Post Format", 'acf'), 'post_category' => __("Post Category", 'acf'), 'post_taxonomy' => __("Post Taxonomy", 'acf'), 'post' => __("Post", 'acf')), __("Page", 'acf') => array('page_template' => __("Page Template", 'acf'), 'page_type' => __("Page Type", 'acf'), 'page_parent' => __("Page Parent", 'acf'), 'page' => __("Page", 'acf')), __("User", 'acf') => array('current_user' => __("Current User", 'acf'), 'current_user_role' => __("Current User Role", 'acf'), 'user_form' => __("User Form", 'acf'), 'user_role' => __("User Role", 'acf')), __("Forms", 'acf') => array('attachment' => __("Attachment", 'acf'), 'taxonomy' => __("Taxonomy Term", 'acf'), 'comment' => __("Comment", 'acf'), 'widget' => __("Widget", 'acf'))));
// WP < 4.7
if (acf_version_compare('wp', '<', '4.7')) {
    unset($rule_types[__("Post", 'acf')]['post_template']);
}
$rule_operators = apply_filters('acf/location/rule_operators', array('==' => __("is equal to", 'acf'), '!=' => __("is not equal to", 'acf')));
?>
<div class="acf-field">
	<div class="acf-label">
		<label><?php 
_e("Rules", 'acf');
?>
</label>
		<p><?php 
_e("Create a set of rules to determine which edit screens will use these advanced custom fields", 'acf');
?>
</p>
	</div>
	<div class="acf-input">
		<div class="rule-groups">
			
			<?php 
foreach ($field_group['location'] as $group_id => $group) {
    // validate
    if (empty($group)) {
        continue;
    }
    // $group_id must be completely different to $rule_id to avoid JS issues
Ejemplo n.º 2
0
 function get_toolbars()
 {
     // global
     global $wp_version;
     // vars
     $editor_id = 'acf_content';
     // toolbars
     $toolbars = array();
     $mce_buttons = 'formatselect, bold, italic, bullist, numlist, blockquote, alignleft, aligncenter, alignright, link, unlink, wp_more, spellchecker, fullscreen, wp_adv';
     $mce_buttons_2 = 'strikethrough, hr, forecolor, pastetext, removeformat, charmap, outdent, indent, undo, redo, wp_help';
     $teeny_mce_buttons = 'bold, italic, underline, blockquote, strikethrough, bullist, numlist, alignleft, aligncenter, alignright, undo, redo, link, unlink, fullscreen';
     // WP < 3.9
     if (acf_version_compare('wp', '<', '3.9')) {
         $mce_buttons = 'bold, italic, strikethrough, bullist, numlist, blockquote, justifyleft, justifycenter, justifyright, link, unlink, wp_more, spellchecker, fullscreen, wp_adv';
         $mce_buttons_2 = 'formatselect, underline, justifyfull, forecolor, pastetext, pasteword, removeformat, charmap, outdent, indent, undo, redo, wp_help';
         $teeny_mce_buttons = 'bold, italic, underline, blockquote, strikethrough, bullist, numlist, justifyleft, justifycenter, justifyright, undo, redo, link, unlink, fullscreen';
         // WP < 4.7
     } elseif (acf_version_compare('wp', '<', '4.7')) {
         $mce_buttons = 'bold, italic, strikethrough, bullist, numlist, blockquote, hr, alignleft, aligncenter, alignright, link, unlink, wp_more, spellchecker, fullscreen, wp_adv';
         $mce_buttons_2 = 'formatselect, underline, alignjustify, forecolor, pastetext, removeformat, charmap, outdent, indent, undo, redo, wp_help';
         //$teeny_mce_buttons = 'bold, italic, underline, blockquote, strikethrough, bullist, numlist, alignleft, aligncenter, alignright, undo, redo, link, unlink, fullscreen';
     }
     // explode
     $mce_buttons = explode(', ', $mce_buttons);
     $mce_buttons_2 = explode(', ', $mce_buttons_2);
     $teeny_mce_buttons = explode(', ', $teeny_mce_buttons);
     // Full
     $toolbars['Full'] = array(1 => apply_filters('mce_buttons', $mce_buttons, $editor_id), 2 => apply_filters('mce_buttons_2', $mce_buttons_2, $editor_id), 3 => apply_filters('mce_buttons_3', array(), $editor_id), 4 => apply_filters('mce_buttons_4', array(), $editor_id));
     // Basic
     $toolbars['Basic'] = array(1 => apply_filters('teeny_mce_buttons', $teeny_mce_buttons, $editor_id));
     // Filter for 3rd party
     $toolbars = apply_filters('acf/fields/wysiwyg/toolbars', $toolbars);
     // return
     return $toolbars;
 }
Ejemplo n.º 3
0
 function rule_match_post_template($match, $rule, $options)
 {
     // bail early if not a post
     if (!$options['post_id']) {
         return false;
     }
     // vars
     $templates = array();
     $post_type = get_post_type($options['post_id']);
     $page_template = $options['page_template'];
     // get templates (WP 4.7)
     if (acf_version_compare('wp', '>=', '4.7')) {
         $templates = wp_get_theme()->get_post_templates();
     }
     // 'page' is always a valid pt even if no templates exist in the theme
     // allows scenario where page_template = 'default' and no templates exist
     if (!isset($templates['page'])) {
         $templates['page'] = array();
     }
     // bail early if this post type does not allow for templates
     if (!isset($templates[$post_type])) {
         return false;
     }
     // get page template
     if (!$page_template) {
         $page_template = get_post_meta($options['post_id'], '_wp_page_template', true);
     }
     // new post - no page template
     if (!$page_template) {
         $page_template = "default";
     }
     // match
     return $this->compare_value_to_rule($page_template, $rule);
 }
Ejemplo n.º 4
0
function acf_get_db_updates()
{
    // vars
    $available = array();
    $db_updates = acf()->admin->install->db_updates;
    $acf_version = acf_get_setting('version');
    $db_version = acf_get_db_version();
    // bail early if is fresh install
    if (!$db_version) {
        acf_update_db_version($acf_version);
        return false;
    }
    // bail early if is up to date
    if (acf_version_compare($db_version, '>=', $acf_version)) {
        return false;
    }
    // loop
    foreach ($db_updates as $version => $callback) {
        // ignore if update is for a future version (may exist for testing)
        if (acf_version_compare($version, '>', $acf_version)) {
            continue;
        }
        // ignore if update has already been run
        if (acf_version_compare($version, '<=', $db_version)) {
            continue;
        }
        // append
        $available[$version] = $callback;
    }
    // bail early if no updates available
    // - also update DB to current version
    if (empty($available)) {
        acf_update_db_version($acf_version);
        return false;
    }
    // return
    return $available;
}