本文整理汇总了PHP中acf_get_user_setting函数的典型用法代码示例。如果您正苦于以下问题:PHP acf_get_user_setting函数的具体用法?PHP acf_get_user_setting怎么用?PHP acf_get_user_setting使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了acf_get_user_setting函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render_layout
function render_layout($field, $layout, $i, $value)
{
// vars
$order = 0;
$el = 'div';
$div = array('class' => 'layout', 'data-id' => $i, 'data-layout' => $layout['name']);
// collapsed
$collapsed = acf_get_user_setting('collapsed_' . $field['key'], '');
// cookie fallback ( version < 5.3.2 )
if ($collapsed === '') {
$collapsed = acf_extract_var($_COOKIE, "acf_collapsed_{$field['key']}", '');
$collapsed = str_replace('|', ',', $collapsed);
acf_update_user_setting('collapsed_' . $field['key'], $collapsed);
}
// explode
$collapsed = explode(',', $collapsed);
$collapsed = array_filter($collapsed, 'is_numeric');
// collapsed class
if (in_array($i, $collapsed)) {
$div['class'] .= ' -collapsed';
}
// clone
if (is_numeric($i)) {
$order = $i + 1;
} else {
$div['class'] .= ' acf-clone';
}
?>
<div <?php
acf_esc_attr_e($div);
?>
>
<div class="acf-hidden">
<?php
acf_hidden_input(array('name' => "{$field['name']}[{$i}][acf_fc_layout]", 'value' => $layout['name']));
?>
</div>
<div class="acf-fc-layout-handle">
<span class="fc-layout-order"><?php
echo $order;
?>
</span> <?php
echo $layout['label'];
?>
</div>
<ul class="acf-fc-layout-controlls acf-hl">
<li class="acf-fc-show-on-hover">
<a class="acf-icon -plus small" href="#" data-event="add-layout" title="<?php
_e('Add layout', 'acf');
?>
"></a>
</li>
<li class="acf-fc-show-on-hover">
<a class="acf-icon -minus small" href="#" data-event="remove-layout" title="<?php
_e('Remove layout', 'acf');
?>
"></a>
</li>
<li>
<a class="acf-icon -collapse small" href="#" data-event="collapse-layout" title="<?php
_e('Click to toggle', 'acf');
?>
"></a>
</li>
</ul>
<?php
if (!empty($layout['sub_fields'])) {
?>
<?php
if ($layout['display'] == 'table') {
// update vars
$el = 'td';
?>
<table class="acf-table">
<thead>
<tr>
<?php
foreach ($layout['sub_fields'] as $sub_field) {
$atts = array('class' => "acf-th acf-th-{$sub_field['name']}", 'data-key' => $sub_field['key']);
// Add custom width
if ($sub_field['wrapper']['width']) {
$atts['data-width'] = $sub_field['wrapper']['width'];
}
?>
<th <?php
acf_esc_attr_e($atts);
?>
>
<?php
acf_the_field_label($sub_field);
?>
<?php
if ($sub_field['instructions']) {
?>
//.........这里部分代码省略.........
示例2: screen_settings
function screen_settings($current)
{
// vars
$show_field_keys = acf_get_user_setting('show_field_keys', 0);
// heading
$current .= '<h5>' . __("Fields", 'acf') . '</h5>';
// radio buttons
$current .= '<div class="show-field-keys">' . __('Show Field Keys', 'acf') . ':';
$current .= '<label><input type="radio" ' . ($show_field_keys ? 'checked="checked"' : '') . ' name="show_field_keys" value="1" />' . __('Yes', 'acf') . '</label>';
$current .= '<label><input type="radio" ' . ($show_field_keys ? '' : 'checked="checked"') . ' name="show_field_keys" value="0" />' . __('No', 'acf') . '</label>';
$current .= '</div>';
// return
return $current;
}
示例3: render_field
function render_field($field)
{
// enqueue
acf_enqueue_uploader();
// vars
$posts = array();
$atts = array('id' => $field['id'], 'class' => "acf-gallery {$field['class']}", 'data-preview_size' => $field['preview_size'], 'data-library' => $field['library'], 'data-min' => $field['min'], 'data-max' => $field['max'], 'data-mime_types' => $field['mime_types']);
// set gallery height
$height = acf_get_user_setting('gallery_height', 400);
$height = max($height, 200);
// minimum height is 200
$atts['style'] = "height:{$height}px";
// load posts
if (!empty($field['value'])) {
$posts = acf_get_posts(array('post_type' => 'attachment', 'post__in' => $field['value']));
}
?>
<div <?php
acf_esc_attr_e($atts);
?>
>
<div class="acf-hidden">
<input type="hidden" <?php
acf_esc_attr_e(array('name' => $field['name'], 'value' => '', 'data-name' => 'ids'));
?>
/>
</div>
<div class="acf-gallery-main">
<div class="acf-gallery-attachments">
<?php
if (!empty($posts)) {
?>
<?php
foreach ($posts as $post) {
// vars
$type = acf_maybe_get(explode('/', $post->post_mime_type), 0);
$thumb_id = $post->ID;
$thumb_url = '';
$thumb_class = 'acf-gallery-attachment acf-soh';
$filename = wp_basename($post->guid);
// thumb
if ($type === 'image' || $type === 'audio' || $type === 'video') {
// change $thumb_id
if ($type === 'audio' || $type === 'video') {
$thumb_id = get_post_thumbnail_id($post->ID);
}
// get attachment
if ($thumb_id) {
$thumb_url = wp_get_attachment_image_src($thumb_id, $field['preview_size']);
$thumb_url = acf_maybe_get($thumb_url, 0);
}
}
// fallback
if (!$thumb_url) {
$thumb_url = wp_mime_type_icon($post->ID);
$thumb_class .= ' is-mime-icon';
}
?>
<div class="<?php
echo $thumb_class;
?>
" data-id="<?php
echo $post->ID;
?>
">
<input type="hidden" name="<?php
echo $field['name'];
?>
[]" value="<?php
echo $post->ID;
?>
" />
<div class="margin" title="<?php
echo $filename;
?>
">
<div class="thumbnail">
<img src="<?php
echo $thumb_url;
?>
"/>
</div>
<?php
if ($type !== 'image') {
?>
<div class="filename"><?php
echo acf_get_truncated($filename, 18);
?>
</div>
<?php
}
?>
</div>
<div class="actions acf-soh-target">
<a class="acf-icon dark remove-attachment" data-id="<?php
//.........这里部分代码省略.........
示例4: screen_settings
function screen_settings($html)
{
// vars
$checked = acf_get_user_setting('show_field_keys') ? 'checked="checked"' : '';
// append
$html .= '<div id="acf-append-show-on-screen" class="acf-hidden">';
$html .= '<label for="acf-field-key-hide"><input id="acf-field-key-hide" type="checkbox" value="1" name="show_field_keys" ' . $checked . ' /> ' . __('Field Keys', 'acf') . '</label>';
$html .= '</div>';
// return
return $html;
}
示例5: render_field
function render_field($field)
{
// global
global $wp_version;
// enqueue
acf_enqueue_uploader();
// vars
$id = uniqid('acf-editor-');
$default_editor = 'html';
$show_tabs = true;
$button = '';
// get height
$height = acf_get_user_setting('wysiwyg_height', 300);
$height = max($height, 300);
// minimum height is 300
// detect mode
if (!user_can_richedit()) {
$show_tabs = false;
} elseif ($field['tabs'] == 'visual') {
// case: visual tab only
$default_editor = 'tinymce';
$show_tabs = false;
} elseif ($field['tabs'] == 'text') {
// case: text tab only
$show_tabs = false;
} elseif (wp_default_editor() == 'tinymce') {
// case: both tabs
$default_editor = 'tinymce';
}
// must be logged in tp upload
if (!current_user_can('upload_files')) {
$field['media_upload'] = 0;
}
// mode
$switch_class = $default_editor === 'html' ? 'html-active' : 'tmce-active';
// filter value for editor
remove_filter('acf_the_editor_content', 'format_for_editor', 10, 2);
remove_filter('acf_the_editor_content', 'wp_htmledit_pre', 10, 1);
remove_filter('acf_the_editor_content', 'wp_richedit_pre', 10, 1);
// WP 4.3
if (version_compare($wp_version, '4.3', '>=')) {
add_filter('acf_the_editor_content', 'format_for_editor', 10, 2);
$button = 'data-wp-editor-id="' . $id . '"';
// WP < 4.3
} else {
$function = $default_editor === 'html' ? 'wp_htmledit_pre' : 'wp_richedit_pre';
add_filter('acf_the_editor_content', $function, 10, 1);
$button = 'onclick="switchEditors.switchto(this);"';
}
// filter
$field['value'] = apply_filters('acf_the_editor_content', $field['value'], $default_editor);
?>
<div id="wp-<?php
echo $id;
?>
-wrap" class="acf-editor-wrap wp-core-ui wp-editor-wrap <?php
echo $switch_class;
?>
" data-toolbar="<?php
echo $field['toolbar'];
?>
" data-upload="<?php
echo $field['media_upload'];
?>
">
<div id="wp-<?php
echo $id;
?>
-editor-tools" class="wp-editor-tools hide-if-no-js">
<?php
if ($field['media_upload']) {
?>
<div id="wp-<?php
echo $id;
?>
-media-buttons" class="wp-media-buttons">
<?php
do_action('media_buttons', $id);
?>
</div>
<?php
}
?>
<?php
if (user_can_richedit() && $show_tabs) {
?>
<div class="wp-editor-tabs">
<button id="<?php
echo $id;
?>
-tmce" class="wp-switch-editor switch-tmce" <?php
echo $button;
?>
type="button"><?php
echo __('Visual', 'acf');
?>
</button>
<button id="<?php
echo $id;
?>
//.........这里部分代码省略.........
示例6: render_field
function render_field($field)
{
// enqueue
acf_enqueue_uploader();
// vars
$atts = array('id' => $field['id'], 'class' => "acf-gallery {$field['class']}", 'data-library' => $field['library'], 'data-min' => $field['min'], 'data-max' => $field['max'], 'data-mime_types' => $field['mime_types'], 'data-insert' => $field['insert'], 'data-columns' => 4);
// set gallery height
$height = acf_get_user_setting('gallery_height', 400);
$height = max($height, 200);
// minimum height is 200
$atts['style'] = "height:{$height}px";
// get posts
$value = $this->get_attachments($field['value']);
?>
<div <?php
acf_esc_attr_e($atts);
?>
>
<div class="acf-hidden">
<?php
acf_hidden_input(array('name' => $field['name'], 'value' => ''));
?>
</div>
<div class="acf-gallery-main">
<div class="acf-gallery-attachments">
<?php
if ($value) {
?>
<?php
foreach ($value as $i => $v) {
// bail early if no value
if (!$v) {
continue;
}
// vars
$a = array('ID' => $v->ID, 'title' => $v->post_title, 'filename' => wp_basename($v->guid), 'type' => acf_maybe_get(explode('/', $v->post_mime_type), 0), 'class' => 'acf-gallery-attachment acf-soh');
// thumbnail
$thumbnail = acf_get_post_thumbnail($a['ID'], 'medium');
// remove filename if is image
if ($a['type'] == 'image') {
$a['filename'] = '';
}
// class
$a['class'] .= ' -' . $a['type'];
if ($thumbnail['type'] == 'icon') {
$a['class'] .= ' -icon';
}
?>
<div class="<?php
echo $a['class'];
?>
" data-id="<?php
echo $a['ID'];
?>
">
<?php
acf_hidden_input(array('name' => $field['name'] . '[]', 'value' => $a['ID']));
?>
<div class="margin">
<div class="thumbnail">
<img src="<?php
echo $thumbnail['url'];
?>
" alt="" title="<?php
echo $a['title'];
?>
"/>
</div>
<?php
if ($a['filename']) {
?>
<div class="filename"><?php
echo acf_get_truncated($a['filename'], 30);
?>
</div>
<?php
}
?>
</div>
<div class="actions acf-soh-target">
<a class="acf-icon -cancel dark acf-gallery-remove" href="#" data-id="<?php
echo $a['ID'];
?>
" title="<?php
_e('Remove', 'acf');
?>
"></a>
</div>
</div>
<?php
}
?>
<?php
}
//.........这里部分代码省略.........
示例7: render_field
function render_field($field)
{
// enqueue
acf_enqueue_uploader();
// vars
$id = $field['id'] . '-' . uniqid();
$mode = 'html';
$show_tabs = true;
// get height
$height = acf_get_user_setting('wysiwyg_height', 300);
$height = max($height, 300);
// minimum height is 300
// detect mode
if ($field['tabs'] == 'visual') {
// case: visual tab only
$mode = 'tmce';
$show_tabs = false;
} elseif ($field['tabs'] == 'text') {
// case: text tab only
$show_tabs = false;
} elseif (wp_default_editor() == 'tinymce') {
// case: both tabs
$mode = 'tmce';
}
// mode
$switch_class = $mode . '-active';
// filter value for editor
remove_all_filters('acf_the_editor_content');
if ($mode == 'tmce') {
add_filter('acf_the_editor_content', 'wp_richedit_pre');
} else {
add_filter('acf_the_editor_content', 'wp_htmledit_pre');
}
$field['value'] = apply_filters('acf_the_editor_content', $field['value']);
?>
<div id="wp-<?php
echo $id;
?>
-wrap" class="acf-wysiwyg-wrap wp-core-ui wp-editor-wrap <?php
echo $switch_class;
?>
" data-toolbar="<?php
echo $field['toolbar'];
?>
" data-upload="<?php
echo $field['media_upload'];
?>
">
<div id="wp-<?php
echo $id;
?>
-editor-tools" class="wp-editor-tools hide-if-no-js">
<?php
if ($field['media_upload']) {
?>
<div id="wp-<?php
echo $id;
?>
-media-buttons" class="wp-media-buttons">
<?php
do_action('media_buttons');
?>
</div>
<?php
}
?>
<?php
if (user_can_richedit() && $show_tabs) {
?>
<div class="wp-editor-tabs">
<a id="<?php
echo $id;
?>
-html" class="wp-switch-editor switch-html" onclick="switchEditors.switchto(this);"><?php
echo _x('Text', 'Name for the Text editor tab (formerly HTML)');
?>
</a>
<a id="<?php
echo $id;
?>
-tmce" class="wp-switch-editor switch-tmce" onclick="switchEditors.switchto(this);"><?php
echo __('Visual');
?>
</a>
</div>
<?php
}
?>
</div>
<div id="wp-<?php
echo $id;
?>
-editor-container" class="wp-editor-container">
<textarea id="<?php
echo $id;
?>
" class="wp-editor-area" name="<?php
echo $field['name'];
?>
" <?php
//.........这里部分代码省略.........
示例8: acf_is_row_collapsed
function acf_is_row_collapsed($field_key = '', $row_index = 0)
{
// collapsed
$collapsed = acf_get_user_setting('collapsed_' . $field_key, '');
// cookie fallback ( version < 5.3.2 )
if ($collapsed === '') {
$collapsed = acf_extract_var($_COOKIE, "acf_collapsed_{$field_key}", '');
$collapsed = str_replace('|', ',', $collapsed);
// update
acf_update_user_setting('collapsed_' . $field_key, $collapsed);
}
// explode
$collapsed = explode(',', $collapsed);
$collapsed = array_filter($collapsed, 'is_numeric');
// collapsed class
return in_array($row_index, $collapsed);
}
示例9: render_field
function render_field($field)
{
// enqueue
acf_enqueue_uploader();
// vars
$id = uniqid('acf-editor-');
//$id = $field['id'] . '-' . uniqid();
$mode = 'html';
$show_tabs = true;
// get height
$height = acf_get_user_setting('wysiwyg_height', 300);
$height = max($height, 300);
// minimum height is 300
// detect mode
// case: visual tab only
if ($field['tabs'] == 'visual') {
$mode = 'tmce';
$show_tabs = false;
} elseif ($field['tabs'] == 'text') {
$show_tabs = false;
} elseif (wp_default_editor() == 'tinymce') {
$mode = 'tmce';
}
// mode
$switch_class = $mode . '-active';
// filter value for editor
remove_all_filters('acf_the_editor_content');
if ($mode == 'tmce') {
add_filter('acf_the_editor_content', 'wp_richedit_pre');
} else {
add_filter('acf_the_editor_content', 'wp_htmledit_pre');
}
global $q_config, $wp_version;
$languages = qtrans_getSortedLanguages(true);
$values = qtrans_split($field['value'], $quicktags = true);
$currentLanguage = $this->plugin->get_active_language();
echo '<div class="multi-language-field multi-language-field-wysiwyg">';
foreach ($languages as $language) {
$class = $language === $currentLanguage ? 'wp-switch-editor current-language' : 'wp-switch-editor';
echo '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
}
$uid = uniqid('acf-editor-');
foreach ($languages as $language) {
$value = apply_filters('acf_the_editor_content', $values[$language]);
$id = $uid . "-{$language}";
$name = $field['name'] . "[{$language}]";
$class = $switch_class;
if ($language === $currentLanguage) {
$class .= ' current-language';
}
?>
<div id="wp-<?php
echo $id;
?>
-wrap" class="acf-editor-wrap wp-core-ui wp-editor-wrap <?php
echo $class;
?>
" data-toolbar="<?php
echo $field['toolbar'];
?>
" data-upload="<?php
echo $field['media_upload'];
?>
" data-language="<?php
echo $language;
?>
">
<div id="wp-<?php
echo $id;
?>
-editor-tools" class="wp-editor-tools hide-if-no-js">
<?php
if ($field['media_upload']) {
?>
<div id="wp-<?php
echo $id;
?>
-media-buttons" class="wp-media-buttons">
<?php
do_action('media_buttons');
?>
</div>
<?php
}
?>
<?php
if (user_can_richedit() && $show_tabs) {
?>
<div class="wp-editor-tabs">
<button id="<?php
echo $id;
?>
-tmce" class="wp-switch-editor switch-tmce" onclick="switchEditors.switchto(this);" type="button"><?php
echo __('Visual', 'acf');
?>
</button>
<button id="<?php
echo $id;
?>
-html" class="wp-switch-editor switch-html" onclick="switchEditors.switchto(this);" type="button"><?php
//.........这里部分代码省略.........
示例10: render_field
function render_field($field)
{
// vars
$div = array('class' => 'acf-repeater', 'data-min' => $field['min'], 'data-max' => $field['max']);
// ensure value is an array
if (empty($field['value'])) {
$field['value'] = array();
$div['class'] .= ' -empty';
}
// rows
$field['min'] = empty($field['min']) ? 0 : $field['min'];
$field['max'] = empty($field['max']) ? 0 : $field['max'];
// populate the empty row data (used for acfcloneindex and min setting)
$empty_row = array();
// If there are less values than min, populate the extra values
if ($field['min']) {
for ($i = 0; $i < $field['min']; $i++) {
// continue if already have a value
if (array_key_exists($i, $field['value'])) {
continue;
}
// populate values
$field['value'][$i] = $empty_row;
}
}
// If there are more values than man, remove some values
if ($field['max']) {
for ($i = 0; $i < count($field['value']); $i++) {
if ($i >= $field['max']) {
unset($field['value'][$i]);
}
}
}
// setup values for row clone
$field['value']['acfcloneindex'] = $empty_row;
// show columns
$show_order = true;
$show_add = true;
$show_remove = true;
if ($field['max']) {
if ($field['max'] == 1) {
$show_order = false;
}
if ($field['max'] <= $field['min']) {
$show_remove = false;
$show_add = false;
}
}
// field wrap
$el = 'td';
$before_fields = '';
$after_fields = '';
if ($field['layout'] == 'row') {
$el = 'div';
$before_fields = '<td class="acf-fields -left">';
$after_fields = '</td>';
} elseif ($field['layout'] == 'block') {
$el = 'div';
$before_fields = '<td class="acf-fields">';
$after_fields = '</td>';
}
// layout
$div['class'] .= ' -' . $field['layout'];
// hidden input
acf_hidden_input(array('type' => 'hidden', 'name' => $field['name']));
// collapsed
$collapsed = array();
if ($field['collapsed']) {
// get user setting
$collapsed = acf_get_user_setting('collapsed_' . $field['key'], '');
$collapsed = explode(',', $collapsed);
$collapsed = array_filter($collapsed, 'is_numeric');
// add target class
foreach (array_keys($field['sub_fields']) as $i) {
if ($field['sub_fields'][$i]['key'] === $field['collapsed']) {
$field['sub_fields'][$i]['wrapper']['class'] .= ' -collapsed-target';
}
}
}
?>
<div <?php
acf_esc_attr_e($div);
?>
>
<table class="acf-table">
<?php
if ($field['layout'] == 'table') {
?>
<thead>
<tr>
<?php
if ($show_order) {
?>
<th class="acf-row-handle"><span></span></th>
<?php
}
?>
<?php
//.........这里部分代码省略.........
示例11: render_field
function render_field($field)
{
// enqueue
acf_enqueue_uploader();
// vars
$atts = array('id' => $field['id'], 'class' => "acf-gallery {$field['class']}", 'data-preview_size' => $field['preview_size'], 'data-library' => $field['library'], 'data-min' => $field['min'], 'data-max' => $field['max']);
// vars
$height = acf_get_user_setting('gallery_height', 400);
$height = max($height, 200);
// minimum height is 200
$atts['style'] = "height:{$height}px";
?>
<div <?php
acf_esc_attr_e($atts);
?>
>
<div class="acf-hidden">
<input type="hidden" <?php
acf_esc_attr_e(array('name' => $field['name'], 'value' => '', 'data-name' => 'ids'));
?>
/>
</div>
<div class="acf-gallery-main">
<div class="acf-gallery-attachments">
<?php
if (!empty($field['value'])) {
// force value to array
$field['value'] = acf_force_type_array($field['value']);
// convert values to int
$field['value'] = array_map('intval', $field['value']);
foreach ($field['value'] as $id) {
// vars
$mime_type = get_post_mime_type($id);
$src = '';
if (strpos($mime_type, 'image') !== false) {
$src = wp_get_attachment_image_src($id, $field['preview_size']);
$src = $src[0];
} else {
$src = wp_mime_type_icon($id);
}
?>
<div class="acf-gallery-attachment acf-soh" data-id="<?php
echo $id;
?>
">
<input type="hidden" name="<?php
echo $field['name'];
?>
[]" value="<?php
echo $id;
?>
" />
<div class="padding">
<img src="<?php
echo $src;
?>
" alt="" />
</div>
<div class="actions acf-soh-target">
<a class="acf-icon dark remove-attachment" data-id="<?php
echo $id;
?>
" href="#">
<i class="acf-sprite-delete"></i>
</a>
</div>
</div>
<?php
}
?>
<?php
}
?>
</div>
<div class="acf-gallery-toolbar">
<ul class="acf-hl">
<li>
<a href="#" class="acf-button blue add-attachment"><?php
_e('Add to gallery', 'acf');
?>
</a>
</li>
<li class="acf-fr">
<select class="bulk-actions">
<option value=""><?php
_e('Bulk actions', 'acf');
?>
</option>
<option value="date"><?php
//.........这里部分代码省略.........