当前位置: 首页>>代码示例>>PHP>>正文


PHP acf_hidden_input函数代码示例

本文整理汇总了PHP中acf_hidden_input函数的典型用法代码示例。如果您正苦于以下问题:PHP acf_hidden_input函数的具体用法?PHP acf_hidden_input怎么用?PHP acf_hidden_input使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了acf_hidden_input函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: render_field

 function render_field($field)
 {
     // decode value (convert to array)
     $field['value'] = acf_get_array($field['value'], false);
     // hiden input
     acf_hidden_input(array('type' => 'hidden', 'name' => $field['name']));
     // vars
     $i = 0;
     $li = '';
     $all_checked = true;
     // 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);
             // is choice selected?
             if (in_array($value, $field['value'])) {
                 $atts['checked'] = 'checked';
             } else {
                 $all_checked = false;
             }
             if (isset($field['disabled']) && acf_in_array($value, $field['disabled'])) {
                 $atts['disabled'] = 'disabled';
             }
             // 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;
             }
             // append HTML
             $li .= '<li><label><input ' . acf_esc_attr($atts) . '/>' . $label . '</label></li>';
         }
         // toggle all
         if ($field['toggle']) {
             // vars
             $label = __("Toggle All", 'acf');
             $atts = array('type' => 'checkbox', 'class' => 'acf-checkbox-toggle');
             // custom label
             if (is_string($field['toggle'])) {
                 $label = $field['toggle'];
             }
             // checked
             if ($all_checked) {
                 $atts['checked'] = 'checked';
             }
             // append HTML
             $li = '<li><label><input ' . acf_esc_attr($atts) . '/>' . $label . '</label></li>' . $li;
         }
     }
     // class
     $field['class'] .= ' acf-checkbox-list';
     $field['class'] .= $field['layout'] == 'horizontal' ? ' acf-hl' : ' acf-bl';
     // return
     echo '<ul ' . acf_esc_attr(array('class' => $field['class'])) . '>' . $li . '</ul>';
 }
开发者ID:ReLiFeD,项目名称:irreversible.eu,代码行数:58,代码来源:checkbox.php

示例2: 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 
        }
开发者ID:rmikeska,项目名称:ushipnetwork,代码行数:57,代码来源:true_false.php

示例3: render_field

 /**
  * Create the HTML interface for Currency field.
  *
  * @since 1.1.3
  *
  * @param array $field The $field being edited.
  */
 function render_field($field)
 {
     if (!is_array($field['value'])) {
         if ($field['value'] && is_string($field['value'])) {
             $field['value'] = explode(',', $field['value']);
         } elseif (!empty($field['value'])) {
             $field['value'] = array($field['value']);
         }
     }
     if (empty($field['value'])) {
         // add empty value (allows '' to be selected)
         $field['value'][''] = '';
     }
     // vars
     $atts = array('id' => $field['id'], 'class' => $field['class'], 'name' => $field['name'], 'data-multiple' => $field['multiple'], 'data-allow_null' => $field['allow_null']);
     // hidden input
     if ($field['multiple']) {
         acf_hidden_input(array('type' => 'hidden', 'name' => $field['name']));
     }
     // 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;
         }
     }
     // html
     echo '<select ' . acf_esc_attr($atts) . '>';
     // null option
     if ($field['allow_null']) {
         echo '<option value="null">- ' . __("Select", 'acf') . ' -</option>';
     }
     // get currencies via WP Currencies
     $currencies = get_currencies();
     // print options
     foreach ($currencies as $currency => $data) {
         $data = (array) $data;
         $selected = in_array($currency, $field['value']) ? 'selected="selected"' : '';
         echo '<option value="' . $currency . '" ' . $selected . '>' . $currency . ' ' . $data['name'] . '</option>' . "\n";
     }
     echo '</select>';
 }
开发者ID:nekojira,项目名称:wp-currencies,代码行数:54,代码来源:acf-v5.php

示例4: 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;
 }
开发者ID:pellio11,项目名称:ns-select-project,代码行数:39,代码来源:checkbox.php

示例5: render_field_checkbox

        function render_field_checkbox($field)
        {
            // hidden input
            acf_hidden_input(array('type' => 'hidden', 'name' => $field['name']));
            // checkbox saves an array
            if ($field['field_type'] == 'checkbox') {
                $field['name'] .= '[]';
            }
            // vars
            $args = array('taxonomy' => $field['taxonomy'], 'hide_empty' => false, 'style' => 'none', 'walker' => new acf_taxonomy_field_walker($field));
            // Un buque que le meti para que me detectara los sidebar
            if ($field['taxonomy'] == 'sidebar') {
                ?>

			<?php 
                /**
                 * Ininio parte personalizada
                 **/
                $sidebars = get_option('sidebars_widgets');
                $options_sidebar = '';
                global $post_ID;
                $save_sidebar = get_post_meta($post_ID, $field['label'], true);
                foreach ($sidebars as $sidebar_id => $sidebar) {
                    if ($sidebar_id != 'wp_inactive_widgets' and $sidebar_id != 'array_version') {
                        if (!empty($save_sidebar)) {
                            foreach ($save_sidebar as $save) {
                                if ($save == $sidebar_id) {
                                    $options_sidebar .= '<li><label class="selectit"><input type="checkbox" name="' . $field['name'] . '" value="' . $sidebar_id . '" checked> ' . $sidebar_id . '</label></li>';
                                    continue;
                                }
                            }
                        }
                        $options_sidebar .= '<li><label class="selectit"><input type="checkbox" name="' . $field['name'] . '" value="' . $sidebar_id . '"> ' . $sidebar_id . '</label></li>';
                    }
                }
                ?>
		<div class="acf-taxonomy-field" data-load_save="<?php 
                echo $field['load_save_terms'];
                ?>
">
			<input type="hidden" name="<?php 
                echo $single_name;
                ?>
" value="" />
			
			<?php 
                if ($field['field_type'] == 'select') {
                    ?>
				
				<select id="<?php 
                    echo $field['id'];
                    ?>
" name="<?php 
                    echo $field['name'];
                    ?>
" <?php 
                    if ($field['multiple']) {
                        ?>
multiple="multiple" size="5"<?php 
                    }
                    ?>
>
					<?php 
                    if ($field['allow_null']) {
                        ?>
						<option value=""><?php 
                        _e("None", 'acf');
                        ?>
</option>
					<?php 
                    }
                    ?>
			
			<?php 
                } else {
                    ?>
				<div class="categorychecklist-holder">
				<ul class="acf-checkbox-list">
					<?php 
                    if ($field['allow_null']) {
                        ?>
						<li>
							<label class="selectit">
								<input type="<?php 
                        echo $field['field_type'];
                        ?>
" name="<?php 
                        echo $field['name'];
                        ?>
" value="" /> <?php 
                        _e("None", 'acf');
                        ?>
							</label>
						</li>
					<?php 
                    }
                    ?>
			
			<?php 
                }
//.........这里部分代码省略.........
开发者ID:Telemedellin,项目名称:fonvalmed,代码行数:101,代码来源:taxonomy.php

示例6: render_field

        function render_field($field)
        {
            // vars
            $sub_fields = $field['sub_fields'];
            $value = acf_get_array($field['value']);
            $show_order = true;
            $show_add = true;
            $show_remove = true;
            // bail early if no sub fields
            if (empty($sub_fields)) {
                return;
            }
            // div
            $div = array('class' => 'acf-repeater', 'data-min' => $field['min'], 'data-max' => $field['max']);
            // empty
            if (empty($value)) {
                $div['class'] .= ' -empty';
            }
            // If there are less values than min, populate the extra values
            if ($field['min']) {
                $value = array_pad($value, $field['min'], array());
            }
            // If there are more values than man, remove some values
            if ($field['max']) {
                $value = array_slice($value, 0, $field['max']);
                // if max 1 row, don't show order
                if ($field['max'] == 1) {
                    $show_order = false;
                }
                // if max == min, don't show add or remove buttons
                if ($field['max'] <= $field['min']) {
                    $show_remove = false;
                    $show_add = false;
                }
            }
            // setup values for row clone
            $value['acfcloneindex'] = array();
            // button label
            if ($field['button_label'] === '') {
                $field['button_label'] = __('Add Row', 'acf');
            }
            // 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
            if ($field['collapsed']) {
                // add target class
                foreach ($sub_fields as $i => $sub_field) {
                    // bail early if no match
                    if ($sub_field['key'] !== $field['collapsed']) {
                        continue;
                    }
                    // class
                    $sub_field['wrapper']['class'] .= ' -collapsed-target';
                    // update
                    $sub_fields[$i] = $sub_field;
                }
            }
            ?>
<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"></th>
				<?php 
                }
                ?>
				
				<?php 
                foreach ($sub_fields as $sub_field) {
                    // prepare field (allow sub fields to be removed)
                    $sub_field = acf_prepare_field($sub_field);
                    // bail ealry if no field
                    if (!$sub_field) {
                        continue;
                    }
//.........这里部分代码省略.........
开发者ID:rmikeska,项目名称:ushipnetwork,代码行数:101,代码来源:repeater.php

示例7: render_field

        function render_field($field)
        {
            // vars
            $uploader = acf_get_setting('uploader');
            // enqueue
            if ($uploader == 'wp') {
                acf_enqueue_uploader();
            }
            // vars
            $o = array('icon' => '', 'title' => '', 'url' => '', 'filesize' => '', 'filename' => '');
            $div = array('class' => 'acf-file-uploader acf-cf', 'data-library' => $field['library'], 'data-mime_types' => $field['mime_types'], 'data-uploader' => $uploader);
            // has value?
            if ($field['value']) {
                $file = get_post($field['value']);
                if ($file) {
                    $o['icon'] = wp_mime_type_icon($file->ID);
                    $o['title'] = $file->post_title;
                    $o['filesize'] = @size_format(filesize(get_attached_file($file->ID)));
                    $o['url'] = wp_get_attachment_url($file->ID);
                    $explode = explode('/', $o['url']);
                    $o['filename'] = end($explode);
                }
                // url exists
                if ($o['url']) {
                    $div['class'] .= ' has-value';
                }
            }
            ?>
<div <?php 
            acf_esc_attr_e($div);
            ?>
>
	<div class="acf-hidden">
		<?php 
            acf_hidden_input(array('name' => $field['name'], 'value' => $field['value'], 'data-name' => 'id'));
            ?>
	</div>
	<div class="show-if-value file-wrap acf-soh">
		<div class="file-icon">
			<img data-name="icon" src="<?php 
            echo $o['icon'];
            ?>
" alt=""/>
		</div>
		<div class="file-info">
			<p>
				<strong data-name="title"><?php 
            echo $o['title'];
            ?>
</strong>
			</p>
			<p>
				<strong><?php 
            _e('File name', 'acf');
            ?>
:</strong>
				<a data-name="filename" href="<?php 
            echo $o['url'];
            ?>
" target="_blank"><?php 
            echo $o['filename'];
            ?>
</a>
			</p>
			<p>
				<strong><?php 
            _e('File size', 'acf');
            ?>
:</strong>
				<span data-name="filesize"><?php 
            echo $o['filesize'];
            ?>
</span>
			</p>
			
			<ul class="acf-hl acf-soh-target">
				<?php 
            if ($uploader != 'basic') {
                ?>
					<li><a class="acf-icon -pencil dark" data-name="edit" href="#"></a></li>
				<?php 
            }
            ?>
				<li><a class="acf-icon -cancel dark" data-name="remove" href="#"></a></li>
			</ul>
		</div>
	</div>
	<div class="hide-if-value">
		<?php 
            if ($uploader == 'basic') {
                ?>
			
			<?php 
                if ($field['value'] && !is_numeric($field['value'])) {
                    ?>
				<div class="acf-error-message"><p><?php 
                    echo $field['value'];
                    ?>
</p></div>
			<?php 
//.........这里部分代码省略.........
开发者ID:cimocimocimo,项目名称:staydrysystems.com,代码行数:101,代码来源:file.php

示例8: array

$field['prefix'] = "acf_fields[{$field['ID']}]";
// vars
$atts = array('class' => "acf-field-object acf-field-object-{$field['type']}", 'data-id' => $field['ID'], 'data-key' => $field['key'], 'data-type' => $field['type']);
$meta = array('ID' => $field['ID'], 'key' => $field['key'], 'parent' => $field['parent'], 'menu_order' => $field['menu_order'], 'save' => '');
// replace
$atts['class'] = str_replace('_', '-', $atts['class']);
?>
<div <?php 
echo acf_esc_attr($atts);
?>
>
	
	<div class="meta">
		<?php 
foreach ($meta as $k => $v) {
    acf_hidden_input(array('class' => "input-{$k}", 'name' => "{$field['prefix']}[{$k}]", 'value' => $v));
}
?>
	</div>
	
	<div class="handle">
		<ul class="acf-hl acf-tbody">
			<li class="li-field-order">
				<span class="acf-icon acf-icon-order"><?php 
echo $i + 1;
?>
</span>
				<pre class="pre-field-key"><?php 
echo $field['key'];
?>
</pre>
开发者ID:slavic18,项目名称:cats,代码行数:31,代码来源:field-group-field.php

示例9: 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
//.........这里部分代码省略.........
开发者ID:pellio11,项目名称:ns-select-project,代码行数:101,代码来源:select.php

示例10: render_field

        function render_field($field)
        {
            // ensure value is an array
            if (empty($field['value'])) {
                $field['value'] = array();
            }
            // 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();
            foreach ($field['sub_fields'] as $f) {
                $empty_row[$f['key']] = isset($f['default_value']) ? $f['default_value'] : false;
            }
            // 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 = 'tr';
                $before_fields = '<td class="acf-table-wrap"><table class="acf-table">';
                $after_fields = '</table></td>';
            } elseif ($field['layout'] == 'block') {
                $el = 'div';
                $before_fields = '<td class="acf-fields">';
                $after_fields = '</td>';
            }
            // hidden input
            acf_hidden_input(array('type' => 'hidden', 'name' => $field['name']));
            ?>
<div <?php 
            acf_esc_attr_e(array('class' => 'acf-repeater', 'data-min' => $field['min'], 'data-max' => $field['max']));
            ?>
>
<table <?php 
            acf_esc_attr_e(array('class' => "acf-table acf-input-table {$field['layout']}-layout"));
            ?>
>
	
	<?php 
            if ($field['layout'] == 'table') {
                ?>
		<thead>
			<tr>
				<?php 
                if ($show_order) {
                    ?>
					<th class="order"><span class="order-spacer"></span></th>
				<?php 
                }
                ?>
				
				<?php 
                foreach ($field['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 
//.........这里部分代码省略.........
开发者ID:quangnpd,项目名称:jobshop_web,代码行数:101,代码来源:repeater.php

示例11: 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 
            }
//.........这里部分代码省略.........
开发者ID:rmikeska,项目名称:ushipnetwork,代码行数:101,代码来源:gallery.php

示例12: 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();
        // enqueue
        acf_enqueue_uploader();
        // vars
        $o = array('icon' => '', 'title' => '', 'size' => '', 'url' => '', 'name' => '');
        $div = array('class' => 'acf-file-uploader acf-cf', 'data-library' => $field['library'], 'data-mime_types' => $field['mime_types']);
        $input_atts = array('type' => 'hidden', 'name' => $field['name'], 'value' => $field['value'], 'data-name' => 'value-id');
        $url = '';
        echo '<div class="multi-language-field multi-language-field-image">';
        foreach ($languages as $language) {
            $class = 'wp-switch-editor';
            if ($language === $currentLanguage) {
                $class .= ' current-language';
            }
            echo '<a class="' . $class . '" data-language="' . $language . '">' . $q_config['language_name'][$language] . '</a>';
        }
        foreach ($languages as $language) {
            $input_atts['name'] = $field['name'] . '[' . $language . ']';
            $field['value'] = $values[$language];
            $div['data-language'] = $language;
            $div['class'] = 'acf-file-uploader acf-cf';
            // has value?
            if ($field['value'] && is_numeric($field['value'])) {
                $file = get_post($field['value']);
                if ($file) {
                    $div['class'] .= ' has-value';
                    $o['icon'] = wp_mime_type_icon($file->ID);
                    $o['title'] = $file->post_title;
                    $o['size'] = @size_format(filesize(get_attached_file($file->ID)));
                    $o['url'] = wp_get_attachment_url($file->ID);
                    $explode = explode('/', $o['url']);
                    $o['name'] = end($explode);
                }
            }
            // basic?
            $basic = !current_user_can('upload_files');
            if ($basic) {
                $div['class'] .= ' basic';
            }
            if ($language === $currentLanguage) {
                $div['class'] .= ' current-language';
            }
            ?>
			<div <?php 
            acf_esc_attr_e($div);
            ?>
>
				<div class="acf-hidden">
					<?php 
            acf_hidden_input(array('name' => $input_atts['name'], 'value' => $field['value'], 'data-name' => 'id'));
            ?>
				</div>
				<div class="show-if-value file-wrap acf-soh">
					<div class="file-icon">
						<img data-name="icon" src="<?php 
            echo $o['icon'];
            ?>
" alt=""/>
					</div>
					<div class="file-info">
						<p>
							<strong data-name="title"><?php 
            echo $o['title'];
            ?>
</strong>
						</p>
						<p>
							<strong><?php 
            _e('File Name', 'acf');
            ?>
:</strong>
							<a data-name="name" href="<?php 
            echo $o['url'];
            ?>
" target="_blank"><?php 
            echo $o['name'];
            ?>
</a>
						</p>
						<p>
							<strong><?php 
            _e('File Size', 'acf');
            ?>
:</strong>
							<span data-name="size"><?php 
            echo $o['size'];
            ?>
</span>
						</p>

						<ul class="acf-hl acf-soh-target">
							<?php 
            if (!$basic) {
                ?>
								<li><a class="acf-icon dark" data-name="edit" href="#"><i class="acf-sprite-edit"></i></a></li>
//.........这里部分代码省略.........
开发者ID:Tusko,项目名称:acf-qtranslate,代码行数:101,代码来源:file.php

示例13: render_field

    function render_field($field)
    {
        // vars
        $div = array('class' => 'acf-image_area_selection-inner', 'data-image_field_class' => $field['image_field_class']);
        ?>
<div <?php 
        acf_esc_attr_e($div);
        ?>
>

  <div class="acf-hidden">
    <?php 
        acf_hidden_input(array('name' => $field['name'] . '[width]', 'value' => $field['value']['width'], 'data-name' => 'width'));
        ?>
    <?php 
        acf_hidden_input(array('name' => $field['name'] . '[height]', 'value' => $field['value']['height'], 'data-name' => 'height'));
        ?>
    <?php 
        acf_hidden_input(array('name' => $field['name'] . '[left]', 'value' => $field['value']['left'], 'data-name' => 'left'));
        ?>
    <?php 
        acf_hidden_input(array('name' => $field['name'] . '[top]', 'value' => $field['value']['top'], 'data-name' => 'top'));
        ?>
    <?php 
        acf_hidden_input(array('name' => $field['name'] . '[image-width]', 'value' => $field['value']['image-width'], 'data-name' => 'image-width'));
        ?>
    <?php 
        acf_hidden_input(array('name' => $field['name'] . '[image-height]', 'value' => $field['value']['image-height'], 'data-name' => 'image-height'));
        ?>
  </div>

  <div class="area-actions-wrapper">
    <input type="button" class="edit acf-button" value="<?php 
        echo $this->l10n['edit'];
        ?>
" />
    <input type="button" class="confirm acf-button button-primary" value="<?php 
        echo $this->l10n['confirm'];
        ?>
" />
    <input type="button" class="cancel acf-button" value="<?php 
        echo $this->l10n['cancel'];
        ?>
" />
  </div><!-- .area-actions-wrapper -->

</div>
<?php 
    }
开发者ID:alebiavati,项目名称:acf-image-area-selection,代码行数:49,代码来源:acf-image_area_selection-v5.php

示例14: render_field

    function render_field($field)
    {
        // ensure value is an array
        if (empty($field['value'])) {
            $field['value'] = array();
        }
        // 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();
        foreach ($field['sub_fields'] as $f) {
            $empty_row[$f['key']] = isset($f['default_value']) ? $f['default_value'] : false;
        }
        // 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 = 'tr';
            $before_fields = '<td class="acf-table-wrap"><table class="acf-table">';
            $after_fields = '</table></td>';
        } elseif ($field['layout'] == 'block') {
            $el = 'div';
            $before_fields = '<td class="acf-fields">';
            $after_fields = '</td>';
        }
        // hidden input
        acf_hidden_input(array('type' => 'hidden', 'name' => $field['name']));
        ?>

		<div <?php 
        acf_esc_attr_e(array('class' => 'acf-repeater acf-fancyrepeater', 'data-min' => $field['min'], 'data-max' => $field['max'], 'data-titlefieldkey' => $this->get_title_field_key($field)));
        ?>
>


			<div class="acf-fancyrepeater-list-wrap">
				<ul class="acf-hl acf-thead">
					<li class="li-fancyrepeater-order"><?php 
        _e('Order', 'acf_child_post_field');
        ?>
</li>
					<li class="li-fancyrepeater-label"><?php 
        _e('Item', 'acf_child_post_field');
        ?>
</li>
					<li class="li-fancyrepeater-name"></li>
					<li class="li-fancyrepeater-type"></li>
				</ul>

				<div class="acf-fancyrepeater-list">

					<?php 
        foreach ($field['value'] as $i => $row) {
            ?>
						<?php 
            $clone_class = $i === 'acfcloneindex' ? ' acf-clone' : '';
            ?>


						<div class="acf-fancyrepeater-object <?php 
            echo $clone_class;
            ?>
">
							<?php 
//.........这里部分代码省略.........
开发者ID:GrindPress,项目名称:acf-fancy-repeater-field,代码行数:101,代码来源:acf-fancy-repeater-field-v5.php

示例15: render_field

    function render_field($field)
    {
        // echo "<pre>";
        // 	print_r($field);
        // echo "</pre>";
        $taxonomies = array();
        $taxonomies = acf_get_array($taxonomies);
        $taxonomies = acf_get_pretty_taxonomies($taxonomies);
        $all_taxonomies = acf_get_taxonomy_terms();
        $selected_taxonomies = array();
        $terms = array();
        $slug_name = !empty($field['choices']) ? $field['choices'] : array_keys(acf_get_pretty_taxonomies());
        foreach ($slug_name as $k1 => $v1) {
            $terms = array_merge($terms, get_terms($v1, array('hide_empty' => false)));
            foreach ($taxonomies as $k2 => $v2) {
                if ($v1 == $k2) {
                    $field['choices'][$k1] = $v2;
                }
            }
        }
        foreach ($field['choices'] as $k1 => $v1) {
            foreach ($all_taxonomies as $k2 => $v2) {
                if ($v1 == $k2) {
                    $selected_taxonomies[$v1] = $all_taxonomies[$k2];
                }
            }
        }
        $field['choices'] = $selected_taxonomies;
        // 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'][''] = '';
            $field['value']['cat'] = '';
        }
        // placeholder
        if (empty($field['placeholder'])) {
            $field['placeholder'] = __("Select", 'acf');
        }
        // vars
        $atts = array('id' => $field['id'], 'class' => $field['class'] . ' js-multi-taxonomy-select2', '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();
        if ($field['data_type']) {
            // 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) {
                                if ($field['type_value']) {
                                    foreach ($terms as $key => $val) {
                                        if ($val->name == $v2) {
                                            $els[] = array('type' => 'option', 'value' => $val->term_id, 'label' => $v2, 'selected' => $slct = $val->term_id == $field['value'] ? "selected" : "");
                                        }
                                    }
                                } else {
                                    $els[] = array('type' => 'option', 'value' => $k2, 'label' => $v2, 'selected' => $slct = $k2 == $field['value'] ? "selected" : "");
                                }
                                $choices[] = $k2;
                            }
                        }
                        $els[] = array('type' => '/optgroup');
                    } else {
                        $els[] = array('type' => 'option', 'value' => $k, 'label' => $v, 'selected' => $slct = $k == $field['value'] ? "selected" : "");
                        $choices[] = $k;
                    }
                }
            }
            // null
            if ($field['allow_null']) {
                array_unshift($els, array('type' => 'option', 'value' => '', 'label' => '- ' . $field['placeholder'] . ' -'));
            }
            // html
//.........这里部分代码省略.........
开发者ID:marktimemedia,项目名称:acf-multi-taxonomy-chooser,代码行数:101,代码来源:acf-multi-taxonomy-chooser-v5.php


注:本文中的acf_hidden_input函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。