本文整理汇总了PHP中acf_esc_attr函数的典型用法代码示例。如果您正苦于以下问题:PHP acf_esc_attr函数的具体用法?PHP acf_esc_attr怎么用?PHP acf_esc_attr使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了acf_esc_attr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render_field
function render_field($field)
{
// vars
$atts = array();
$o = array('id', 'class', 'name', 'placeholder', 'rows');
$s = array('readonly', 'disabled');
$e = '';
// maxlength
if ($field['maxlength']) {
$o[] = 'maxlength';
}
// rows
if (empty($field['rows'])) {
$field['rows'] = 8;
}
// append atts
foreach ($o as $k) {
$atts[$k] = $field[$k];
}
// append special atts
foreach ($s as $k) {
if (!empty($field[$k])) {
$atts[$k] = $k;
}
}
$e .= '<textarea ' . acf_esc_attr($atts) . ' >';
$e .= esc_textarea($field['value']);
$e .= '</textarea>';
// return
echo $e;
}
示例2: render_field
function render_field($field)
{
// vars
$o = array('type', 'id', 'class', 'name', 'value', 'placeholder');
$e = '';
// prepend
if ($field['prepend'] !== "") {
$field['class'] .= ' acf-is-prepended';
$e .= '<div class="acf-input-prepend">' . $field['prepend'] . '</div>';
}
// append
if ($field['append'] !== "") {
$field['class'] .= ' acf-is-appended';
$e .= '<div class="acf-input-append">' . $field['append'] . '</div>';
}
// populate atts
$atts = array();
foreach ($o as $k) {
$atts[$k] = $field[$k];
}
// special atts
foreach (array('readonly', 'disabled') as $k) {
if ($field[$k]) {
$atts[$k] = $k;
}
}
// render
$e .= '<div class="acf-input-wrap">';
$e .= '<input ' . acf_esc_attr($atts) . ' />';
$e .= '</div>';
// return
echo $e;
}
示例3: render_field
function render_field($field)
{
// vars
$input = array('type' => 'checkbox', 'id' => $field['id'], 'name' => $field['name'], 'value' => '1', 'class' => $field['class'], 'autocomplete' => 'off');
$hidden = array('name' => $field['name'], 'value' => 0);
$active = $field['value'] ? true : false;
$switch = '';
// checked
if ($active) {
$input['checked'] = 'checked';
}
// ui
if ($field['ui']) {
// vars
if ($field['ui_on_text'] === '') {
$field['ui_on_text'] = __('Yes', 'acf');
}
if ($field['ui_off_text'] === '') {
$field['ui_off_text'] = __('No', 'acf');
}
// update input
$input['class'] .= ' acf-switch-input';
$input['style'] = 'display:none;';
$switch .= '<div class="acf-switch' . ($active ? ' -on' : '') . '">';
$switch .= '<span class="acf-switch-on">' . $field['ui_on_text'] . '</span>';
$switch .= '<span class="acf-switch-off">' . $field['ui_off_text'] . '</span>';
$switch .= '<div class="acf-switch-slider"></div>';
$switch .= '</div>';
}
?>
<div class="acf-true-false">
<?php
acf_hidden_input($hidden);
?>
<label>
<input <?php
echo acf_esc_attr($input);
?>
/>
<?php
if ($switch) {
echo $switch;
}
?>
<?php
if ($field['message']) {
?>
<span><?php
echo $field['message'];
?>
</span><?php
}
?>
</label>
</div>
<?php
}
示例4: render_field
function render_field($field)
{
// vars
$e = '';
$div = array('class' => 'acf-date_picker', 'data-display_format' => acf_convert_date_to_js($field['display_format']), 'data-first_day' => $field['first_day']);
$input = array('id' => $field['id'], 'class' => 'input-alt', 'type' => 'hidden', 'name' => $field['name'], 'value' => $field['value']);
// html
$e .= '<div ' . acf_esc_attr($div) . '>';
$e .= '<input ' . acf_esc_attr($input) . '/>';
$e .= '<input type="text" value="" class="input" />';
$e .= '</div>';
// return
echo $e;
}
示例5: render_field
function render_field($field)
{
global $q_config;
$languages = qtrans_getSortedLanguages(true);
$values = qtrans_split($field['value'], $quicktags = true);
$currentLanguage = $this->plugin->get_active_language();
// vars
$o = array('id', 'class', 'name', 'placeholder', 'rows');
$s = array('readonly', 'disabled');
$e = '';
// maxlength
if ($field['maxlength'] !== '') {
$o[] = 'maxlength';
}
// rows
if (empty($field['rows'])) {
$field['rows'] = 8;
}
// populate atts
$atts = array();
foreach ($o as $k) {
$atts[$k] = $field[$k];
}
// special atts
foreach ($s as $k) {
if ($field[$k]) {
$atts[$k] = $k;
}
}
// render
$e .= '<div class="acf-input-wrap multi-language-field">';
foreach ($languages as $language) {
$class = $language === $currentLanguage ? 'wp-switch-editor current-language' : 'wp-switch-editor';
$e .= '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
}
foreach ($languages as $language) {
$atts['class'] = $field['class'];
if ($language === $currentLanguage) {
$atts['class'] .= ' current-language';
}
$atts['name'] = $field['name'] . "[{$language}]";
$atts['data-language'] = $language;
$e .= '<textarea ' . acf_esc_attr($atts) . ' >';
$e .= esc_textarea($values[$language]);
$e .= '</textarea>';
}
$e .= '</div>';
// return
echo $e;
}
示例6: render_field
function render_field($field)
{
// vars
$atts = array('type' => 'checkbox', 'id' => "{$field['id']}-1", 'name' => $field['name'], 'value' => '1');
// checked
if (!empty($field['value'])) {
$atts['checked'] = 'checked';
}
// html
echo '<ul class="acf-checkbox-list acf-bl ' . acf_esc_attr($field['class']) . '">';
echo '<input type="hidden" name="' . acf_esc_attr($field['name']) . '" value="0" />';
echo '<li><label><input ' . acf_esc_attr($atts) . '/>' . $field['message'] . '</label></li>';
echo '</ul>';
}
示例7: render_field
function render_field($field)
{
// vars
$o = array('type', 'id', 'class', 'name', 'value', 'placeholder', 'icon_set');
$s = array('readonly', 'disabled');
$e = '';
// maxlength
if ($field['maxlength'] !== "") {
$o[] = 'maxlength';
}
// prepend
if ($field['prepend'] !== "") {
$field['class'] .= ' acf-is-prepended';
$e .= '<div class="acf-input-prepend">' . $field['prepend'] . '</div>';
}
// append
if ($field['append'] !== "") {
$field['class'] .= ' acf-is-appended';
$e .= '<div class="acf-input-append">' . $field['append'] . '</div>';
}
$field['class'] .= ' ocp-icon-set';
// populate atts
$atts = array();
foreach ($o as $k) {
$atts[$k] = $field[$k];
}
// special atts
foreach ($s as $k) {
if ($field[$k]) {
$atts[$k] = $k;
}
}
$atts['type'] = 'hidden';
// render
$e .= '<div class="acf-input-wrap">';
$e .= '<i class="fa fa-fw ' . $atts['value'] . '"></i>';
$e .= '<a href="#TB_inline?height=550&inlineId=icon-select" class="thickbox button button-small choose-icon" onclick="jQuery(this).addClass(\'insert-icon\');getIconSet(jQuery(this));" data-set="' . $atts['icon_set'] . '">Choose Icon</a>';
$e .= '<input ' . acf_esc_attr($atts) . ' />';
$e .= '</div>';
// return
echo $e;
}
示例8: render_field
function render_field($field)
{
// format value
$display_value = '';
if ($field['value']) {
$display_value = acf_format_date($field['value'], $field['display_format']);
}
// vars
$e = '';
$div = array('class' => 'acf-time-picker acf-input-wrap', 'data-time_format' => acf_convert_time_to_js($field['display_format']));
$hidden = array('id' => $field['id'], 'class' => 'input-alt', 'type' => 'hidden', 'name' => $field['name'], 'value' => $field['value']);
$input = array('class' => 'input', 'type' => 'text', 'value' => $display_value);
// html
$e .= '<div ' . acf_esc_attr($div) . '>';
$e .= '<input ' . acf_esc_attr($hidden) . '/>';
$e .= '<input ' . acf_esc_attr($input) . '/>';
$e .= '</div>';
// return
echo $e;
}
示例9: render_field
public function render_field($field)
{
$attributes = array('id', 'class', 'name');
// populate atts
$rendered_attributes = array();
foreach ($attributes as $attribute) {
$rendered_attributes[$attribute] = $field[$attribute];
}
$value = esc_textarea($field['value']);
?>
<div class='codemirror-wrapper'>
<textarea <?php
echo acf_esc_attr($rendered_attributes);
?>
><?php
echo $value;
?>
</textarea>
</div>
<?php
}
示例10: render_field
function render_field($field)
{
// decode value (convert to array)
$field['value'] = acf_force_type_array($field['value']);
// hiden input
acf_hidden_input(array('type' => 'hidden', 'name' => $field['name']));
// vars
$i = 0;
// class
$field['class'] .= ' acf-checkbox-list';
$field['class'] .= $field['layout'] == 'horizontal' ? ' acf-hl' : ' acf-bl';
// e
$e = '<ul ' . acf_esc_attr(array('class' => $field['class'])) . '>';
// checkbox saves an array
$field['name'] .= '[]';
// foreach choices
if (!empty($field['choices'])) {
foreach ($field['choices'] as $value => $label) {
// increase counter
$i++;
// vars
$atts = array('type' => 'checkbox', 'id' => $field['id'], 'name' => $field['name'], 'value' => $value);
if (in_array($value, $field['value'])) {
$atts['checked'] = 'checked';
}
if (isset($field['disabled']) && in_array($value, $field['disabled'])) {
$atts['disabled'] = 'true';
}
// each input ID is generated with the $key, however, the first input must not use $key so that it matches the field's label for attribute
if ($i > 1) {
$atts['id'] .= '-' . $value;
}
$e .= '<li><label><input ' . acf_esc_attr($atts) . '/>' . $label . '</label></li>';
}
}
$e .= '</ul>';
// return
echo $e;
}
示例11: render_field
function render_field($field)
{
// vars
$atts = array();
$o = array('type', 'id', 'class', 'min', 'max', 'step', 'name', 'value', 'placeholder');
$s = array('readonly', 'disabled');
$e = '';
// step
if (!$field['step']) {
$field['step'] = 'any';
}
// prepend
if ($field['prepend'] !== '') {
$field['class'] .= ' acf-is-prepended';
$e .= '<div class="acf-input-prepend">' . $field['prepend'] . '</div>';
}
// append
if ($field['append'] !== '') {
$field['class'] .= ' acf-is-appended';
$e .= '<div class="acf-input-append">' . $field['append'] . '</div>';
}
// append atts
foreach ($o as $k) {
$atts[$k] = $field[$k];
}
// append special atts
foreach ($s as $k) {
if (!empty($field[$k])) {
$atts[$k] = $k;
}
}
// render
$e .= '<div class="acf-input-wrap">';
$e .= '<input ' . acf_esc_attr($atts) . ' />';
$e .= '</div>';
// return
echo $e;
}
示例12: render_field
function render_field($field)
{
// vars
$o = array('type', 'id', 'class', 'name', 'value', 'placeholder');
$e = '';
// populate atts
$atts = array();
foreach ($o as $k) {
$atts[$k] = $field[$k];
}
// special atts
foreach (array('readonly', 'disabled') as $k) {
if (!empty($field[$k])) {
$atts[$k] = $k;
}
}
// render
$e .= '<div class="acf-input-wrap acf-url">';
$e .= '<i class="acf-icon acf-icon-globe small"></i><input ' . acf_esc_attr($atts) . ' />';
$e .= '</div>';
// return
echo $e;
}
示例13: render_field
function render_field($field)
{
// convert value to array
$field['value'] = acf_force_type_array($field['value']);
// add empty value (allows '' to be selected)
if (empty($field['value'])) {
$field['value'][''] = '';
}
// placeholder
if (empty($field['placeholder'])) {
$field['placeholder'] = __("Select", 'acf');
}
// vars
$atts = array('id' => $field['id'], 'class' => $field['class'], 'name' => $field['name'], 'data-ui' => $field['ui'], 'data-ajax' => $field['ajax'], 'data-multiple' => $field['multiple'], 'data-placeholder' => $field['placeholder'], 'data-allow_null' => $field['allow_null']);
// hidden input
if ($field['ui']) {
acf_hidden_input(array('type' => 'hidden', 'id' => $field['id'], 'name' => $field['name'], 'value' => implode(',', $field['value'])));
} elseif ($field['multiple']) {
acf_hidden_input(array('type' => 'hidden', 'name' => $field['name']));
}
// ui
if ($field['ui']) {
$atts['disabled'] = 'disabled';
$atts['class'] .= ' acf-hidden';
}
// multiple
if ($field['multiple']) {
$atts['multiple'] = 'multiple';
$atts['size'] = 5;
$atts['name'] .= '[]';
}
// special atts
foreach (array('readonly', 'disabled') as $k) {
if (!empty($field[$k])) {
$atts[$k] = $k;
}
}
// vars
$els = array();
$choices = array();
// loop through values and add them as options
if (!empty($field['choices'])) {
foreach ($field['choices'] as $k => $v) {
if (is_array($v)) {
// optgroup
$els[] = array('type' => 'optgroup', 'label' => $k);
if (!empty($v)) {
foreach ($v as $k2 => $v2) {
$els[] = array('type' => 'option', 'value' => $k2, 'label' => $v2, 'selected' => in_array($k2, $field['value']));
$choices[] = $k2;
}
}
$els[] = array('type' => '/optgroup');
} else {
$els[] = array('type' => 'option', 'value' => $k, 'label' => $v, 'selected' => in_array($k, $field['value']));
$choices[] = $k;
}
}
}
// prepende orphans
/*
if( !empty($field['value']) ) {
foreach( $field['value'] as $v ) {
if( empty($v) ) {
continue;
}
if( !in_array($v, $choices) ) {
array_unshift( $els, array( 'type' => 'option', 'value' => $v, 'label' => $v, 'selected' => true ) );
}
}
}
*/
// null
if ($field['allow_null']) {
array_unshift($els, array('type' => 'option', 'value' => '', 'label' => '- ' . $field['placeholder'] . ' -'));
}
// html
echo '<select ' . acf_esc_attr($atts) . '>';
// construct html
if (!empty($els)) {
foreach ($els as $el) {
// extract type
$type = acf_extract_var($el, 'type');
if ($type == 'option') {
// get label
$label = acf_extract_var($el, 'label');
// validate selected
if (acf_extract_var($el, 'selected')) {
$el['selected'] = 'selected';
}
// echo
//.........这里部分代码省略.........
示例14: acf_get_hidden_input
function acf_get_hidden_input($atts)
{
$atts['type'] = 'hidden';
return '<input ' . acf_esc_attr($atts) . ' />';
}
示例15: render_field
public function render_field($field)
{
// convert value to array
$field['value'] = acf_get_array($field['value'], false);
// add empty value (allows '' to be selected)
if (empty($field['value'])) {
$field['value'][''] = '';
}
// placeholder
if (empty($field['placeholder'])) {
$field['placeholder'] = __("Select", 'acf');
}
// vars
$atts = array('id' => $field['id'], 'class' => $field['class'], 'name' => $field['name'], 'data-multiple' => $field['multiple'], 'data-placeholder' => $field['placeholder'], 'data-allow_null' => $field['allow_null']);
// multiple
if ($field['multiple']) {
$atts['multiple'] = 'multiple';
$atts['size'] = 5;
$atts['name'] .= '[]';
}
// special atts
foreach (array('readonly', 'disabled') as $k) {
if (!empty($field[$k])) {
$atts[$k] = $k;
}
}
// vars
$els = array();
// $choices = array();
$posttypes = $this->post_type_options();
foreach ($posttypes as $pt) {
$els[] = array('type' => 'option', 'value' => $pt['value'], 'label' => $pt['label'], 'selected' => in_array($pt['value'], $field['value']));
}
// null
if ($field['allow_null']) {
array_unshift($els, array('type' => 'option', 'value' => '', 'label' => '- ' . $field['placeholder'] . ' -'));
}
// html
echo '<select ' . acf_esc_attr($atts) . '>';
// construct html
if (!empty($els)) {
foreach ($els as $el) {
// extract type
$type = acf_extract_var($el, 'type');
if ($type == 'option') {
// get label
$label = acf_extract_var($el, 'label');
// validate selected
if (acf_extract_var($el, 'selected')) {
$el['selected'] = 'selected';
}
// echo
echo '<option ' . acf_esc_attr($el) . '>' . $label . '</option>';
} else {
// echo
echo '<' . $type . ' ' . acf_esc_attr($el) . '>';
}
}
}
echo '</select>';
}